]> git.lyx.org Git - features.git/commitdiff
Add insetwrap.
authorDekel Tsur <dekelts@tau.ac.il>
Tue, 10 Sep 2002 10:18:58 +0000 (10:18 +0000)
committerDekel Tsur <dekelts@tau.ac.il>
Tue, 10 Sep 2002 10:18:58 +0000 (10:18 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5247 a592a061-630c-0410-9148-cb99ea01b6c8

28 files changed:
lib/ui/default.ui
src/ChangeLog
src/LyXAction.C
src/buffer.C
src/commandtags.h
src/factory.C
src/frontends/Dialogs.h
src/frontends/controllers/ControlFloat.h
src/frontends/controllers/ControlWrap.C [new file with mode: 0644]
src/frontends/controllers/ControlWrap.h [new file with mode: 0644]
src/frontends/controllers/Makefile.am
src/frontends/guiapi.C
src/frontends/guiapi.h
src/frontends/xforms/Dialogs.C
src/frontends/xforms/Dialogs2.C
src/frontends/xforms/Dialogs_impl.h
src/frontends/xforms/FormWrap.C [new file with mode: 0644]
src/frontends/xforms/FormWrap.h [new file with mode: 0644]
src/frontends/xforms/Makefile.am
src/frontends/xforms/forms/Makefile.am
src/frontends/xforms/forms/form_wrap.fd [new file with mode: 0644]
src/insets/Makefile.am
src/insets/inset.h
src/insets/insetwrap.C [new file with mode: 0644]
src/insets/insetwrap.h [new file with mode: 0644]
src/lyxfunc.C
src/text2.C
src/text3.C

index f10987b2d370792bc2b0407479476a5fa50946c6..a6de1034487677440bbe398c97d12e42a55f2661 100644 (file)
@@ -250,6 +250,7 @@ Menuset
 
     Menu "insert_floats"
        FloatInsert
+       Item "Floatflt Figure" "wrap-insert figure"
     End
 
     Menu "insert_toc"
index c55f71f2a67cc635131ec7c697262b99af8fff08..d22d3c724b6e20a20f55cb6c7fc40c6c1b07d7a7 100644 (file)
@@ -1,3 +1,7 @@
+2002-09-10  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * many files: Add insetwrap.
+
 2002-09-09  John Levon  <levon@movementarian.org>
 
        * text2.C: remove confusing and awkward depth wraparound
index b42c04528ccf996a1df6424840a6b188bd4cc298..a12086705f661885472196560de10a4f014ebb26 100644 (file)
@@ -196,12 +196,13 @@ void LyXAction::init()
                { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", _("Insert ASCII files as lines"), Noop },
                { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", _("Insert ASCII file as a paragraph"), Noop },
                { LFUN_FILE_NEW, "file-new", "", NoBuffer },
-               { LFUN_FILE_OPEN, "file-open", _("Open a file"), NoBuffer },
+               { LFUN_FILE_OPEN, "file-open", N_("Open a file"), NoBuffer },
                { LFUN_MENUSEARCH, "find-replace", N_("Find & Replace"),
                  ReadOnly },
-               { LFUN_INSET_FLOAT, "float-insert", "Insert a Float", Noop },
+               { LFUN_INSET_FLOAT, "float-insert", N_("Insert a Float"), Noop },
                { LFUN_INSET_WIDE_FLOAT, "float-wide-insert",
-                 "Insert a wide Float", Noop },
+                 N_("Insert a wide Float"), Noop },
+               { LFUN_INSET_WRAP, "wrap-insert", N_("Insert a Wrap"), Noop },
                { LFUN_BOLD, "font-bold", N_("Toggle bold"), Noop },
                { LFUN_CODE, "font-code", N_("Toggle code style"), Noop },
                { LFUN_DEFAULT, "font-default", N_("Default font style"),
index 7538be4e6d7a6863ccca7c86a34aa0eac20e53ca..610f3dd2cdd26f48568e5a50813ff9e74fadba6e 100644 (file)
@@ -75,6 +75,7 @@
 #include "insets/insetoptarg.h"
 #include "insets/insetminipage.h"
 #include "insets/insetfloat.h"
+#include "insets/insetwrap.h"
 #include "insets/insettabular.h"
 #if 0
 #include "insets/insettheorem.h"
@@ -1116,6 +1117,10 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                        lex.next();
                        string tmptok = lex.getString();
                        inset = new InsetFloat(params, tmptok);
+               } else if (tmptok == "Wrap") {
+                       lex.next();
+                       string tmptok = lex.getString();
+                       inset = new InsetWrap(params, tmptok);
 #if 0
                } else if (tmptok == "List") {
                        inset = new InsetList;
index 1ef2827646add12ec2452ff40acad52f03a18829..fd6692bee95c461a97aa2588159b7e90d7e13f99 100644 (file)
@@ -289,6 +289,7 @@ enum kb_action {
        LFUN_MOUSE_DOUBLE,             // André 9 Aug 2002
        LFUN_MOUSE_TRIPLE,             // André 9 Aug 2002
        LFUN_EDIT,                      // André 16 Aug 2002
+       LFUN_INSET_WRAP,                // Dekel 7 Apr 2002
        LFUN_LASTACTION  /* this marks the end of the table */
 };
 
index 11d0832578641e998b4c3828eaa1d3f2fd5397e5..520da4ba22b003ebcb4d355d0314be74805dee39 100644 (file)
@@ -23,6 +23,7 @@
 #include "insets/insettext.h"
 #include "insets/insettoc.h"
 #include "insets/inseturl.h"
+#include "insets/insetwrap.h"
 #include "frontends/Dialogs.h"
 #include "frontends/LyXView.h"
 
@@ -74,6 +75,12 @@ Inset * createInset(FuncRequest const & cmd)
                        lyxerr << "Non-existent float type: " << cmd.argument << endl;
                        return 0;
 
+               case LFUN_INSET_WRAP:
+                       if (cmd.argument == "figure")
+                               return new InsetWrap(params, cmd.argument);
+                       lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
+                       return 0;
+
                case LFUN_INDEX_INSERT: {
                        string entry = cmd.argument;
                        if (entry.empty())
index 1cb3b30a2dbfa00bf41d9170439028a533470623..cb8a929dd4dcfe6619add2950df8a17973a99758 100644 (file)
@@ -30,6 +30,7 @@ class InsetError;
 class InsetERT;
 class InsetExternal;
 class InsetFloat;
+class InsetWrap;
 class InsetGraphics;
 class InsetInclude;
 class InsetInfo;
@@ -109,6 +110,8 @@ public:
        void showFile(string const &);
        ///
        void showFloat(InsetFloat *);
+       ///
+       void showWrap(InsetWrap *);
        /// show all forked child processes
        void showForks();
        ///
index d6e68910729d16fe7247d20d9f013866a1c8ee79..3319163ab8ea9834c2dabb79da0aa296913a07c7 100644 (file)
@@ -12,8 +12,6 @@
 #ifndef CONTROLFLOAT_H
 #define CONTROLFLOAT_H
 
-#include <vector>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
diff --git a/src/frontends/controllers/ControlWrap.C b/src/frontends/controllers/ControlWrap.C
new file mode 100644 (file)
index 0000000..41b6c83
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ * \file ControlWrap.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ControlWrap.h"
+#include "BufferView.h"
+#include "buffer.h"
+
+
+ControlWrap::ControlWrap(LyXView & lv, Dialogs & d)
+       : ControlInset<InsetWrap, WrapParams>(lv, d)
+{}
+
+
+
+void ControlWrap::applyParamsToInset()
+{
+       inset()->pageWidth(params().pageWidth);
+       inset()->placement(params().placement);
+       bufferview()->updateInset(inset(), true);
+
+}
+
+
+void ControlWrap::applyParamsNoInset()
+{}
+
+
+WrapParams const ControlWrap::getParams(InsetWrap const & inset)
+{
+       return WrapParams(inset);
+}
+
+
+WrapParams::WrapParams()
+       : placement("")
+{}
+
+
+WrapParams::WrapParams(InsetWrap const & inset)
+       : pageWidth(inset.pageWidth()),
+         placement(inset.placement())
+{}
diff --git a/src/frontends/controllers/ControlWrap.h b/src/frontends/controllers/ControlWrap.h
new file mode 100644 (file)
index 0000000..df42b3a
--- /dev/null
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+/**
+ * \file ControlWrap.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef CONTROLWRAP_H
+#define CONTROLWRAP_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlInset.h"
+#include "lyxlength.h"
+
+// needed to instatiate inset->hideDialog in ControlInset
+#include "insets/insetwrap.h"
+
+class InsetWrap;
+
+///
+struct WrapParams {
+       ///
+       WrapParams();
+       ///
+       WrapParams(InsetWrap const &);
+       ///
+       LyXLength pageWidth;
+       ///
+       string placement;
+};
+
+
+inline
+bool operator==(WrapParams const & p1, WrapParams const & p2)
+{
+       return p1.pageWidth == p2.pageWidth && p1.placement == p2.placement;
+}
+
+
+inline
+bool operator!=(WrapParams const & p1, WrapParams const & p2)
+{
+       return !(p1 == p2);
+}
+
+
+/** A controller for Minipage dialogs.
+ */
+class ControlWrap : public ControlInset<InsetWrap, WrapParams>  {
+public:
+       ///
+       ControlWrap(LyXView &, Dialogs &);
+private:
+       /// Dispatch the changed parameters to the kernel.
+       virtual void applyParamsToInset();
+       ///
+       virtual void applyParamsNoInset();
+       /// get the parameters from the string passed to createInset.
+       virtual WrapParams const getParams(string const &)
+               { return WrapParams(); }
+       /// get the parameters from the inset passed to showInset.
+       virtual WrapParams const getParams(InsetWrap const &);
+};
+
+#endif
index a00d438b8df1c576f10fec96c3b8437f12f76de3..158ca0b5a19c14c7059eb57ac1a3254058ac4638 100644 (file)
@@ -50,6 +50,8 @@ libcontrollers_la_SOURCES= \
        ControlExternal.h \
        ControlFloat.C \
        ControlFloat.h \
+       ControlWrap.C \
+       ControlWrap.h \
        ControlForks.C \
        ControlForks.h \
        ControlGraphics.C \
index 400015f7efdddf5aaf4448b96379c9fca0f0b387..28338a5cfae78f727a4cdb26369cb18f5f1ed019 100644 (file)
@@ -103,6 +103,10 @@ extern "C" {
                d.showFloat(ifl);
        }
 
+       void gui_ShowWrap(InsetWrap * iw, Dialogs & d)
+       {
+               d.showWrap(iw);
+       }
 
        void gui_ShowForks(Dialogs & d)
        {
index b5f4c803d2295b863a8ca8187a7d445b81fa2794..69c85ebe7c96f0a5f02dca140bd4976cb6ff676a 100644 (file)
@@ -24,6 +24,7 @@ class InsetError;
 class InsetERT;
 class InsetExternal;
 class InsetFloat;
+class InsetWrap;
 class InsetGraphics;
 class InsetInclude;
 class InsetMinipage;
@@ -45,6 +46,7 @@ extern "C" {
        void gui_ShowExternal(InsetExternal *, Dialogs &);
        void gui_ShowFile(string const &, Dialogs &);
        void gui_ShowFloat(InsetFloat *, Dialogs &);
+       void gui_ShowWrap(InsetWrap *, Dialogs &);
        void gui_ShowForks(Dialogs &);
        void gui_ShowGraphics(InsetGraphics *, Dialogs &);
        void gui_ShowInclude(InsetInclude *, Dialogs &);
index 2c570a1a453ee00c5dbb4f4cb4e4d72c2466f45b..c79539325a015c8be2102fdca52baf6800271f13 100644 (file)
@@ -81,5 +81,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
 
          toc(lv, d),
          url(lv, d),
-         vclogfile(lv, d)
+         vclogfile(lv, d),
+         wrap(lv, d)
 {}
index 9ed8e939ca1bab3855b03572eecc61c543efee88..740badd8d387133ff91ba386170c44321b5c7ef4 100644 (file)
@@ -284,3 +284,9 @@ void Dialogs::showVCLogFile()
 {
        pimpl_->vclogfile.controller().show();
 }
+
+
+void Dialogs::showWrap(InsetWrap * iw)
+{
+       pimpl_->wrap.controller().showInset(iw);
+}
index 345d66b95a6a401c2feef873332875421102f40a..f552ee3055e8e2cdebdee3b34e991e8ba33d6949 100644 (file)
 #include "ControlVCLog.h"
 #include "FormVCLog.h"
 
+#include "ControlWrap.h"
+#include "FormWrap.h"
+#include "forms/form_wrap.h"
+
 
 typedef GUI<ControlAboutlyx, FormAboutlyx, OkCancelPolicy, xformsBC>
 AboutlyxDialog;
@@ -267,6 +271,9 @@ UrlDialog;
 typedef GUI<ControlVCLog, FormVCLog, OkCancelPolicy, xformsBC>
 VCLogFileDialog;
 
+typedef GUI<ControlWrap, FormWrap, NoRepeatedApplyReadOnlyPolicy, xformsBC>
+WrapDialog;
+
 struct Dialogs::Impl {
        Impl(LyXView & lv, Dialogs & d);
 
@@ -307,6 +314,7 @@ struct Dialogs::Impl {
        TocDialog           toc;
        UrlDialog           url;
        VCLogFileDialog     vclogfile;
+       WrapDialog          wrap;
 };
 
 #endif // DIALOGS_IMPL_H
diff --git a/src/frontends/xforms/FormWrap.C b/src/frontends/xforms/FormWrap.C
new file mode 100644 (file)
index 0000000..17f99ef
--- /dev/null
@@ -0,0 +1,123 @@
+/**
+ * \file FormWrap.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "xformsBC.h"
+#include "ControlWrap.h"
+#include "FormWrap.h"
+#include "forms/form_wrap.h"
+#include "support/lstrings.h"
+#include "helper_funcs.h"
+#include "debug.h"
+#include "xforms_helpers.h"
+#include FORMS_H_LOCATION
+
+typedef FormCB<ControlWrap, FormDB<FD_wrap> > base_class;
+
+FormWrap::FormWrap()
+       : base_class(_("Wrap Options"))
+{}
+
+
+void FormWrap::build()
+{
+       dialog_.reset(build_wrap(this));
+
+       // Allow the base class to control messages
+       setMessageWidget(dialog_->text_warning);
+
+       fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
+       setPrehandler(dialog_->input_width);
+
+       string const choice = getStringFromVector(getLatexUnits(), "|");
+       fl_addto_choice(dialog_->choice_width_units, subst(choice, "%", "%%").c_str());
+
+       // Manage the ok, apply and cancel/close buttons
+       bc().setOK(dialog_->button_ok);
+       bc().setApply(dialog_->button_apply);
+       bc().setCancel(dialog_->button_close);
+       bc().setRestore(dialog_->button_restore);
+
+       bc().addReadOnly(dialog_->input_width);
+       bc().addReadOnly(dialog_->choice_width_units);
+       bc().addReadOnly(dialog_->radio_left);
+       bc().addReadOnly(dialog_->radio_right);
+       bc().addReadOnly(dialog_->radio_inner);
+       bc().addReadOnly(dialog_->radio_default);
+}
+
+
+void FormWrap::apply()
+{
+       controller().params().pageWidth =
+               LyXLength(getLengthFromWidgets(dialog_->input_width,
+                                              dialog_->choice_width_units));
+
+       if (fl_get_button(dialog_->radio_left))
+               controller().params().placement = "l";
+       else if (fl_get_button(dialog_->radio_right))
+               controller().params().placement = "r";
+       else if (fl_get_button(dialog_->radio_inner))
+               controller().params().placement = "p";
+       else
+               controller().params().placement.erase();
+}
+
+
+void FormWrap::update()
+{
+       LyXLength len(controller().params().pageWidth);
+       fl_set_input(dialog_->input_width, tostr(len.value()).c_str());
+       fl_set_choice(dialog_->choice_width_units, len.unit() + 1);
+
+       if (controller().params().placement == "l")
+               fl_set_button(dialog_->radio_left, 1);
+       else if (controller().params().placement == "r")
+               fl_set_button(dialog_->radio_right, 1);
+       else if (controller().params().placement == "p")
+               fl_set_button(dialog_->radio_inner, 1);
+       else
+               fl_set_button(dialog_->radio_default, 1);
+}
+
+
+ButtonPolicy::SMInput FormWrap::input(FL_OBJECT * ob, long)
+{
+       clearMessage();
+
+       ButtonPolicy::SMInput action = ButtonPolicy::SMI_NOOP;
+
+       if (ob == dialog_->radio_left ||
+           ob == dialog_->radio_right ||
+           ob == dialog_->radio_inner ||
+           ob == dialog_->radio_default ||
+           ob == dialog_->choice_width_units)
+               return ButtonPolicy::SMI_VALID;
+
+       // disallow senseless data
+       // warnings if input is senseless
+       if (ob == dialog_->input_width) {
+               string const input = getString(dialog_->input_width);
+               bool const invalid = !isValidLength(input) && !isStrDbl(input);
+               if (invalid) {
+                       postWarning(_("Invalid Length!"));
+                       action = ButtonPolicy::SMI_INVALID;
+               } else {
+                       action = ButtonPolicy::SMI_VALID;
+               }
+       }
+
+       return action;
+}
diff --git a/src/frontends/xforms/FormWrap.h b/src/frontends/xforms/FormWrap.h
new file mode 100644 (file)
index 0000000..2e1a16c
--- /dev/null
@@ -0,0 +1,43 @@
+// -*- C++ -*-
+/**
+ * \file FormMinipage.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef FORMWRAP_H
+#define FORMWRAP_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "FormBase.h"
+
+class ControlWrap;
+struct FD_wrap;
+
+/** This class provides an XForms implementation of the Wrap
+    Dialog.
+ */
+class FormWrap
+       : public FormCB<ControlWrap, FormDB<FD_wrap> > {
+public:
+       ///
+       FormWrap();
+private:
+       /// Set the Params variable for the Controller.
+       virtual void apply();
+       /// Build the dialog.
+       virtual void build();
+       /// Update dialog before/whilst showing it.
+       virtual void update();
+       /// Filter the inputs on callback from xforms
+       virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
+};
+
+#endif // FORMWRAP_H
index 93dbf037ae3882b4ca86f24cc05eabfff0ac4ad0..2193c969a35a0ac31480d9b999d4a40480c3a054 100644 (file)
@@ -85,6 +85,8 @@ libxforms_la_SOURCES = \
        FormExternal.h \
        FormFloat.C \
        FormFloat.h \
+       FormWrap.C \
+       FormWrap.h \
        FormForks.C \
        FormForks.h \
        FormGraphics.C \
index 1fe63fa9e0d5aed07229f35e2621b39c669ae1b1..1dd0be27fc843590a57e4013350e0ff0e8a8644e 100644 (file)
@@ -19,6 +19,7 @@ SRCS =  form_aboutlyx.fd \
        form_external.fd \
        form_filedialog.fd \
        form_float.fd \
+       form_wrap.fd \
        form_forks.fd \
        form_graphics.fd \
        form_include.fd \
diff --git a/src/frontends/xforms/forms/form_wrap.fd b/src/frontends/xforms/forms/form_wrap.fd
new file mode 100644 (file)
index 0000000..132dcc2
--- /dev/null
@@ -0,0 +1,304 @@
+Magic: 13000
+
+Internal Form Definition File
+    (do not change)
+
+Number of forms: 1
+Unit of measure: FL_COORD_PIXEL
+
+=============== FORM ===============
+Name: form_wrap
+Width: 430
+Height: 200
+Number of Objects: 16
+
+--------------------
+class: FL_BOX
+type: FLAT_BOX
+box: 0 0 430 200
+boxtype: FL_FLAT_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 20 20 200 60
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Width
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 240 20 180 130
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Placement
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 30 30 110 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: input_width
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHOICE
+type: NORMAL_CHOICE
+box: 150 30 60 30
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: choice_width_units
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BEGIN_GROUP
+type: 0
+box: 0 0 0 0
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_ROUND3DBUTTON
+type: RADIO_BUTTON
+box: 249 30 152 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Left|#L
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_left
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_ROUND3DBUTTON
+type: RADIO_BUTTON
+box: 249 60 152 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Right|#R
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_right
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_ROUND3DBUTTON
+type: RADIO_BUTTON
+box: 249 90 152 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Inner|#I
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_inner
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_ROUND3DBUTTON
+type: RADIO_BUTTON
+box: 250 120 152 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Default (outer)|#D
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_default
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_END_GROUP
+type: 0
+box: 0 0 0 0
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 330 160 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Cancel|^[
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_close
+callback: C_FormBaseCancelCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 230 160 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Apply|#A
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_apply
+callback: C_FormBaseApplyCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: RETURN_BUTTON
+box: 130 160 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: OK
+shortcut: ^M
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_ok
+callback: C_FormBaseOKCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 10 160 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Restore|#R
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_restore
+callback: C_FormBaseRestoreCB
+argument: 0
+
+--------------------
+class: FL_TEXT
+type: NORMAL_TEXT
+box: 20 90 210 30
+boxtype: FL_FLAT_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: text_warning
+callback: 
+argument: 
+
+==============================
+create_the_forms
index e755ca7b058a3fc7f6e09e0f8a6dc909f4c96c57..a187d28d670ed2472cd24ad5e680e253fffef790 100644 (file)
@@ -39,6 +39,8 @@ libinsets_la_SOURCES = \
        insetexternal.h \
        insetfloat.h \
        insetfloat.C \
+       insetwrap.h \
+       insetwrap.C \
        insetfloatlist.C \
        insetfloatlist.h \
        insetfoot.C \
index 4f7467838bf5473267431e275c383269d02eaac0..54459c5e6c5bc946bae835f8fdbdcb7842e0c3ba 100644 (file)
@@ -93,6 +93,8 @@ public:
                ///
                FLOAT_CODE,
                ///
+               WRAP_CODE,
+               ///
                MINIPAGE_CODE,
                ///
                SPECIALCHAR_CODE, // 25
diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C
new file mode 100644 (file)
index 0000000..ae39aac
--- /dev/null
@@ -0,0 +1,231 @@
+/**
+ * \file insetwrap.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetwrap.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "BufferView.h"
+#include "lyxtext.h"
+#include "insets/insettext.h"
+#include "support/LOstream.h"
+#include "support/lstrings.h"
+#include "LaTeXFeatures.h"
+#include "debug.h"
+#include "buffer.h"
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "lyxlex.h"
+
+using std::ostream;
+using std::endl;
+
+
+InsetWrap::InsetWrap(BufferParams const & bp, string const & type)
+       : InsetCollapsable(bp), width_(50, LyXLength::PCW)
+{
+       string lab(_("wrap"));
+       lab += type;
+       setLabel(lab);
+       LyXFont font(LyXFont::ALL_SANE);
+       font.decSize();
+       font.decSize();
+       font.setColor(LColor::collapsable);
+       setLabelFont(font);
+       Type_ = type;
+       setInsetName(type);
+}
+
+
+InsetWrap::InsetWrap(InsetWrap const & in, bool same_id)
+       : InsetCollapsable(in, same_id), Type_(in.Type_),
+         Placement_(in.Placement_), width_(in.width_)
+{}
+
+
+InsetWrap::~InsetWrap()
+{
+       hideDialog();
+}
+
+
+void InsetWrap::write(Buffer const * buf, ostream & os) const
+{
+       os << "Wrap " // getInsetName()
+          << Type_ << '\n';
+
+       if (!Placement_.empty()) {
+               os << "placement " << Placement_ << "\n";
+       }
+       os << "width \"" << width_.asString() << "\"\n";
+
+       InsetCollapsable::write(buf, os);
+}
+
+
+void InsetWrap::read(Buffer const * buf, LyXLex & lex)
+{
+       if (lex.isOK()) {
+               lex.next();
+               string token = lex.getString();
+               if (token == "placement") {
+                       lex.next();
+                       Placement_ = lex.getString();
+               } else {
+                       // take countermeasures
+                       lex.pushToken(token);
+               }
+       }
+       if (lex.isOK()) {
+               lex.next();
+               string token = lex.getString();
+               if (token == "width") {
+                       lex.next();
+                       width_ = LyXLength(lex.getString());
+               } else {
+                       lyxerr << "InsetWrap::Read:: Missing 'width'-tag!"
+                              << endl;
+                       // take countermeasures
+                       lex.pushToken(token);
+               }
+       }
+       InsetCollapsable::read(buf, lex);
+}
+
+
+void InsetWrap::validate(LaTeXFeatures & features) const
+{
+       features.require("floatflt");
+       InsetCollapsable::validate(features);
+}
+
+
+Inset * InsetWrap::clone(Buffer const &, bool same_id) const
+{
+       return new InsetWrap(*const_cast<InsetWrap *>(this), same_id);
+}
+
+
+string const InsetWrap::editMessage() const
+{
+       return _("Opened Wrap Inset");
+}
+
+
+int InsetWrap::latex(Buffer const * buf,
+                     ostream & os, bool fragile, bool fp) const
+{
+       os << "\\begin{floating" << Type_ << "}";
+       if (!Placement_.empty()) {
+               os << "[" << Placement_ << "]";
+       }
+       os  << "{" << width_.asLatexString() << "}%\n";
+
+       int const i = inset.latex(buf, os, fragile, fp);
+
+       os << "\\end{floating" << Type_ << "}%\n";
+       return i + 2;
+}
+
+
+int InsetWrap::docbook(Buffer const * buf, ostream & os, bool mixcont) const
+{
+       os << "<" << Type_ << ">";
+       int const i = inset.docbook(buf, os, mixcont);
+       os << "</" << Type_ << ">";
+
+       return i;
+}
+
+
+bool InsetWrap::insetAllowed(Inset::Code code) const
+{
+       switch(code) {
+       case FLOAT_CODE:
+       case FOOT_CODE:
+       case MARGIN_CODE:
+                return false;
+       default:
+               return InsetCollapsable::insetAllowed(code);
+       }
+}
+
+int InsetWrap::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
+       const
+{
+       if (owner() &&
+           static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, inset) < 0) {
+               return -1;
+       }
+       if (!width_.zero()) {
+               int ww1 = latexTextWidth(bv);
+               int ww2 = InsetCollapsable::getMaxWidth(bv, inset);
+               if (ww2 > 0 && ww2 < ww1) {
+                       return ww2;
+               }
+               return ww1;
+       }
+       // this should not happen!
+       return InsetCollapsable::getMaxWidth(bv, inset);
+}
+
+
+int InsetWrap::latexTextWidth(BufferView * bv) const
+{
+       return width_.inPixels(InsetCollapsable::latexTextWidth(bv),
+                              bv->text->defaultHeight());
+}
+
+
+string const & InsetWrap::type() const
+{
+       return Type_;
+}
+
+
+LyXLength const & InsetWrap::pageWidth() const
+{
+       return width_;
+}
+
+
+void InsetWrap::pageWidth(LyXLength const & ll)
+{
+       if (ll != width_) {
+               width_ = ll;
+               need_update = FULL;
+       }
+}
+
+
+void InsetWrap::placement(string const & p)
+{
+       Placement_ = p;
+}
+
+
+string const & InsetWrap::placement() const
+{
+       return Placement_;
+}
+
+
+bool InsetWrap::showInsetDialog(BufferView * bv) const
+{
+       if (!inset.showInsetDialog(bv)) {
+               bv->owner()->getDialogs().showWrap(const_cast<InsetWrap *>(this));
+       }
+       return true;
+}
diff --git a/src/insets/insetwrap.h b/src/insets/insetwrap.h
new file mode 100644 (file)
index 0000000..4ddc3e8
--- /dev/null
@@ -0,0 +1,81 @@
+/**
+ * \file insetwrap.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef InsetWrap_H
+#define InsetWrap_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insetcollapsable.h"
+#include "lyxlength.h"
+
+#include <boost/signals/signal0.hpp>
+
+class Painter;
+
+/** The wrap inset
+
+*/
+class InsetWrap : public InsetCollapsable {
+public:
+       ///
+       InsetWrap(BufferParams const &, string const &);
+       ///
+       InsetWrap(InsetWrap const &, bool same_id = false);
+       ///
+       ~InsetWrap();
+       ///
+       void write(Buffer const * buf, std::ostream & os) const;
+       ///
+       void read(Buffer const * buf, LyXLex & lex);
+       ///
+       void validate(LaTeXFeatures & features) const;
+       ///
+       Inset * clone(Buffer const &, bool same_id = false) const;
+       ///
+       Inset::Code lyxCode() const { return Inset::WRAP_CODE; }
+       ///
+       int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
+       ///
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+       ///
+       string const editMessage() const;
+       ///
+       bool insetAllowed(Inset::Code) const;
+       ///
+       int getMaxWidth(BufferView *, UpdatableInset const *) const;
+       ///
+       string const & type() const;
+       ///
+       LyXLength const & pageWidth() const;
+        ///
+        void pageWidth(LyXLength const &);
+       ///
+       void placement(string const & p);
+       ///
+       string const & placement() const;
+       ///
+       bool  showInsetDialog(BufferView *) const;
+       ///
+       boost::signal0<void> hideDialog;
+       ///
+       int latexTextWidth(BufferView *) const;
+private:
+       ///
+       string Type_;
+       ///
+       string Placement_;
+       ///
+       LyXLength width_;
+};
+
+#endif
index 968c5225ca367f67fc52da49527592df5139230c..8e08ed42c30c60d38681e1c027377bc76567818f 100644 (file)
@@ -493,6 +493,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_INSET_WIDE_FLOAT:
                code = Inset::FLOAT_CODE;
                break;
+       case LFUN_INSET_WRAP:
+               code == Inset::WRAP_CODE;
+               break;
        case LFUN_FLOAT_LIST:
                code = Inset::FLOAT_LIST_CODE;
                break;
index e8e261b9913a0bf6c7d5260250cc41155a203c9b..075fcc6a58b0a59c3ae56c4ec6a6b96a979a1d01 100644 (file)
@@ -39,6 +39,7 @@
 #include "insets/insetspecialchar.h"
 #include "insets/insettext.h"
 #include "insets/insetfloat.h"
+#include "insets/insetwrap.h"
 
 #include "support/LAssert.h"
 #include "support/textutils.h"
@@ -1315,7 +1316,8 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
                        while (tmppar && tmppar->inInset()
                               // the single '=' is intended below
                               && (in = tmppar->inInset()->owner())) {
-                               if (in->lyxCode() == Inset::FLOAT_CODE) {
+                               if (in->lyxCode() == Inset::FLOAT_CODE ||
+                                   in->lyxCode() == Inset::WRAP_CODE) {
                                        isOK = true;
                                        break;
                                } else {
index 3abab9fc6919970e76df86ae1308f30cb75ef398..eae7919996ef97f7220243d76495f2a385cc294e 100644 (file)
@@ -1577,6 +1577,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_INSET_MINIPAGE:
        case LFUN_INSET_OPTARG:
        case LFUN_INSET_WIDE_FLOAT:
+       case LFUN_INSET_WRAP:
        case LFUN_TABULAR_INSERT:
        case LFUN_INDEX_INSERT:
        case LFUN_INDEX_PRINT: