]> git.lyx.org Git - features.git/commitdiff
Added %x support in vspace.C (LyXLenght) and use it for the minipages.
authorJürgen Vigna <jug@sad.it>
Thu, 29 Mar 2001 15:00:20 +0000 (15:00 +0000)
committerJürgen Vigna <jug@sad.it>
Thu, 29 Mar 2001 15:00:20 +0000 (15:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1853 a592a061-630c-0410-9148-cb99ea01b6c8

26 files changed:
po/POTFILES.in
src/ChangeLog
src/buffer.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlMinipage.C
src/frontends/controllers/ControlMinipage.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormMinipage.C
src/frontends/xforms/form_minipage.C
src/frontends/xforms/form_minipage.h
src/frontends/xforms/forms/form_minipage.fd
src/insets/ChangeLog
src/insets/inset.C
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetminipage.C
src/insets/insetminipage.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/tabular.C
src/text.C
src/vspace.C
src/vspace.h

index 53ffdc22a4638fda580ff54660f82a1b9cb1134d..9514d916d160289b63671f2f55a0fdc02b78fdab 100644 (file)
@@ -10,9 +10,11 @@ src/CutAndPaste.C
 src/debug.C
 src/exporter.C
 src/ext_l10n.h
+src/figure_form.C
+src/figureForm.C
 src/FontLoader.C
-src/form1.C
 src/frontends/controllers/ButtonController.h
+src/frontends/controllers/character.C
 src/frontends/controllers/ControlCharacter.C
 src/frontends/controllers/ControlCopyright.C
 src/frontends/controllers/ControlCredits.C
@@ -26,7 +28,6 @@ src/frontends/gnome/FormIndex.C
 src/frontends/gnome/FormPrint.C
 src/frontends/gnome/FormRef.C
 src/frontends/gnome/FormToc.C
-src/frontends/gnome/FormUrl.C
 src/frontends/gnome/Menubar_pimpl.C
 src/frontends/kde/citationdlg.C
 src/frontends/kde/dlg/copyrightdlgdata.C
@@ -181,7 +182,6 @@ src/LaTeX.C
 src/layout.C
 src/LColor.C
 src/LyXAction.C
-src/lyx.C
 src/lyx_cb.C
 src/lyxfind.C
 src/lyxfont.C
index 191291e70bdd4420a0ec86d78353c7532725f56b..fce7eaf50cc07f76f0ae6a02adf6cc5edd63bec4 100644 (file)
@@ -1,3 +1,11 @@
+2001-03-29  Juergen Vigna  <jug@sad.it>
+
+       * vspace.C: added support for %, c%, p%, l%.
+       (stringFromUnit): added helper function.
+       (asLatexString): changed to give right results for the %-values.
+
+       * buffer.C: convert the widthp in a width%.
+
 2001-03-28  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * Makefile.am: removed form1.[Ch], lyx.[Ch] and added figure_form.[Ch],
index f13af04fe5d5e8f80fdad47a6b54a56e4339414c..0a6f45d5f68721a1180eacb902f21f607656c61f 100644 (file)
@@ -1153,7 +1153,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                        InsetMinipage * mini = new InsetMinipage;
                        mini->pos(static_cast<InsetMinipage::Position>(par->params.pextraAlignment()));
                        mini->width(par->params.pextraWidth());
-                       mini->widthp(par->params.pextraWidthp());
+                       if (!par->params.pextraWidthp().empty()) {
+                           lyxerr << "WP:" << mini->width() << endl;
+                           mini->width(tostr(par->params.pextraWidthp())+"%");
+                       }
                        mini->inset->par = par;
                        // Insert the minipage last in the
                        // previous paragraph.
@@ -1220,7 +1223,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                InsetMinipage * mini = new InsetMinipage;
                mini->pos(static_cast<InsetMinipage::Position>(minipar->params.pextraAlignment()));
                mini->width(minipar->params.pextraWidth());
-               mini->widthp(minipar->params.pextraWidthp());
+               if (!par->params.pextraWidthp().empty()) {
+                   lyxerr << "WP:" << mini->width() << endl;
+                   mini->width(tostr(par->params.pextraWidthp())+"%");
+               }
                mini->inset->par = minipar;
                        
                // Insert the minipage last in the
index 5c43d0ecc6774cee7769cec14ca8fe8ab5f1072a..3fbf3fc3156038faf4c145020ed9c33c89c431b1 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-29  Juergen Vigna  <jug@sad.it>
+
+       * ControlMinipage.C: removed widthp_ and all it's functions and changed
+       to use new %-lengths of LyXLength.
+
 2001-03-29  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * ControlCitation.C (bibkeysInfo): removed Assert.
index f9ce97d0346be58f4b7edc237b4b9928b047ad86..54802e7420f5c3fa0b7cae3d955544815e1233fc 100644 (file)
@@ -7,7 +7,7 @@
  *
  * ======================================================
  *
- * \author Juergen Vigna, jug@sad.it
+ * \author Jürgen Vigna, jug@sad.it
  * \author Angus Leeming, a.leeming@ic.ac.uk
  */
 
@@ -25,6 +25,9 @@
 using std::vector;
 using SigC::slot;
 
+// sorry this is just a temporary hack we should include vspace.h! (Jug)
+extern const char * stringFromUnit(int);
+
 ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
        : ControlInset<InsetMinipage, MinipageParams>(lv, d)
 {
@@ -40,7 +43,6 @@ ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
 void ControlMinipage::applyParamsToInset()
 {
        inset()->width(params().width);
-       inset()->widthp(params().widthp);
        inset()->pos(params().pos);
 
        lv_.view()->updateInset(inset(), true);
@@ -59,16 +61,16 @@ MinipageParams const ControlMinipage::getParams(InsetMinipage const & inset)
 
 
 MinipageParams::MinipageParams()
-       : widthp(0), pos(InsetMinipage::top)
+       : pos(InsetMinipage::top)
 {}
 
 MinipageParams::MinipageParams(InsetMinipage const & inset)
-       : width(inset.width()), widthp(inset.widthp()), pos(inset.pos())
+       : width(inset.width()), pos(inset.pos())
 {}
 
 bool MinipageParams::operator==(MinipageParams const & o) const
 {
-       return (width == o.width && widthp == o.widthp && pos == o.pos);
+       return (width == o.width && pos == o.pos);
 }
 
 bool MinipageParams::operator!=(MinipageParams const & o) const
@@ -81,16 +83,11 @@ namespace minipage {
 vector<string> const getUnits()
 {
        vector<string> units;
-       units.push_back("mm");
-       units.push_back("in");
-       units.push_back("em");
-       units.push_back("%%");
-       units.push_back("%%c");
-       units.push_back("%%l");
-       units.push_back("%%p");
+       const char * str;
+       for(int i=0;(str=stringFromUnit(i));++i)
+           units.push_back(str);
 
        return units;
 }
  
 } // namespace minipage
-
index b5ef4fdca509a72a14b5a7a54ccf92209ba0537e..344f5fd53bd62516eb843ea6920ac59639a49129 100644 (file)
@@ -40,8 +40,6 @@ struct MinipageParams {
        ///
        string width;
        ///
-       int widthp;
-       ///
        InsetMinipage::Position pos;
 };
 
index 67554e2360a96e150b90c5864bfbc438cbe53194..c108e5c24ce271269be45b0f378bd916a811bfaf 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-29  Juergen Vigna  <jug@sad.it>
+
+       * FormMinipage.C: removed widthp_ and all it's functions and changed
+       to use new %-lengths of LyXLength.
+
 2001-03-28  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormGraphics.C:
index 7ca95f30f73bbcbe39990d284b1880b224bb7141..bf31c4f7c84a867a2b201de25c249f37af1ac8c4 100644 (file)
@@ -22,6 +22,8 @@
 #include "FormMinipage.h"
 #include "form_minipage.h"
 #include "support/lstrings.h"
+#include "helper_funcs.h"
+#include "debug.h"
 
 typedef FormCB<ControlMinipage, FormDB<FD_form_minipage> > base_class;
 
@@ -35,7 +37,9 @@ void FormMinipage::build()
        dialog_.reset(build_minipage());
 
        fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
-       fl_set_input_return(dialog_->input_widthp, FL_RETURN_CHANGED);
+
+       string const choice = getStringFromVector(minipage::getUnits(), "|");
+       fl_addto_choice(dialog_->choice_width_units, subst(choice, "%", "%%").c_str());
 
        // Manage the ok, apply and cancel/close buttons
        bc().setOK(dialog_->button_ok);
@@ -44,7 +48,7 @@ void FormMinipage::build()
        bc().setUndoAll(dialog_->button_restore);
 
        bc().addReadOnly(dialog_->input_width);
-       bc().addReadOnly(dialog_->input_widthp);
+       bc().addReadOnly(dialog_->choice_width_units);
        bc().addReadOnly(dialog_->radio_top);
        bc().addReadOnly(dialog_->radio_middle);
        bc().addReadOnly(dialog_->radio_bottom);
@@ -55,9 +59,11 @@ void FormMinipage::build()
 
 void FormMinipage::apply()
 {
-       controller().params().width = fl_get_input(dialog_->input_width);
-       controller().params().widthp =
-               strToInt(fl_get_input(dialog_->input_widthp));
+       string const units = fl_get_choice_text(dialog_->choice_width_units);
+       double const val = strToDbl(fl_get_input(dialog_->input_width));
+
+       controller().params().width =
+               tostr(val) + frontStrip(strip(subst(units,"%%","%")));
 
        if (fl_get_button(dialog_->radio_top))
                controller().params().pos = InsetMinipage::top;
@@ -70,11 +76,10 @@ void FormMinipage::apply()
 
 void FormMinipage::update()
 {
-    fl_set_input(dialog_->input_width,
-                controller().params().width.c_str());
-    fl_set_input(dialog_->input_widthp,
-                tostr(controller().params().widthp).c_str());
-                
+    LyXLength len(controller().params().width.c_str());
+    fl_set_input(dialog_->input_width,tostr(len.value()).c_str());
+    fl_set_choice(dialog_->choice_width_units, len.unit()+1);
+
     switch (controller().params().pos) {
     case InsetMinipage::top:
        fl_set_button(dialog_->radio_top, 1);
index ed97867bec68738bc1278895da178e5ad4728a4f..a4cc039bba8097e4c9d6fb06b45decf0a68659e0 100644 (file)
@@ -25,33 +25,17 @@ FD_form_minipage * FormMinipage::build_minipage()
   fdui->form = fl_bgn_form(FL_NO_BOX, 430, 170);
   fdui->form->u_vdata = this;
   obj = fl_add_box(FL_FLAT_BOX, 0, 0, 430, 170, "");
-  obj = fl_add_frame(FL_ENGRAVED_FRAME, 230, 20, 190, 100, "");
-    fl_set_object_color(obj, FL_COL1, FL_COL1);
-  obj = fl_add_frame(FL_ENGRAVED_FRAME, 20, 20, 200, 100, "");
-    fl_set_object_color(obj, FL_COL1, FL_COL1);
-  {
-    char const * const dummy = N_("Length|#L");
-    fdui->input_width = obj = fl_add_input(FL_NORMAL_INPUT, 100, 30, 110, 30, idex(_(dummy)));
-    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
-  }
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 20, 200, 60, _("Width"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  {
-    // xgettext:no-c-format
-    char const * const dummy = N_("or %|#o");
-    fdui->input_widthp = obj = fl_add_input(FL_INT_INPUT, 100, 70, 110, 30, idex(_(dummy)));
-    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
-  }
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  obj = fl_add_text(FL_NORMAL_TEXT, 30, 10, 100, 20, _("Width"));
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
-  obj = fl_add_text(FL_NORMAL_TEXT, 240, 10, 140, 20, _("Alignment"));
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 240, 20, 180, 100, _("Alignment"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  fdui->input_width = obj = fl_add_input(FL_NORMAL_INPUT, 30, 30, 110, 30, "");
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  fdui->choice_width_units = obj = fl_add_choice(FL_NORMAL_CHOICE2, 150, 30, 60, 30, "");
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
 
   fdui->group_alignment = fl_bgn_group();
   {
index bf386ac471c75f705628b1ba3189c257953fd87c..9598da08caddb3363c4bb52cf56f921ee423bd70 100644 (file)
@@ -18,7 +18,7 @@ struct FD_form_minipage {
 
        FL_FORM *form;
        FL_OBJECT *input_width;
-       FL_OBJECT *input_widthp;
+       FL_OBJECT *choice_width_units;
        FL_OBJECT *group_alignment;
        FL_OBJECT *radio_top;
        FL_OBJECT *radio_middle;
index 5a3e22e25b6b15da4f9a44a18accae09c3ac065b..c0bad20f0f00e1c1c713821d9f2a98dd25ff5af5 100644 (file)
@@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
 Name: form_minipage
 Width: 430
 Height: 170
-Number of Objects: 16
+Number of Objects: 14
 
 --------------------
 class: FL_BOX
@@ -31,16 +31,16 @@ callback:
 argument: 
 
 --------------------
-class: FL_FRAME
+class: FL_LABELFRAME
 type: ENGRAVED_FRAME
-box: 230 20 190 100
+box: 20 20 200 60
 boxtype: FL_NO_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: 
+label: Width
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
@@ -49,16 +49,16 @@ callback:
 argument: 
 
 --------------------
-class: FL_FRAME
+class: FL_LABELFRAME
 type: ENGRAVED_FRAME
-box: 20 20 200 100
+box: 240 20 180 100
 boxtype: FL_NO_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: 
+label: Alignment
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
@@ -69,14 +69,14 @@ argument:
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 100 30 110 30
+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: Length|#L
+label: 
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
@@ -85,63 +85,27 @@ callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
-class: FL_INPUT
-type: INT_INPUT
-box: 100 70 110 30
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_MCOL
+class: FL_CHOICE
+type: NORMAL_CHOICE2
+box: 150 30 60 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_BLACK
 alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
+size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
-label: or %|#o
+label: 
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: input_widthp
+name: choice_width_units
 callback: C_FormBaseInputCB
 argument: 0
 
---------------------
-class: FL_TEXT
-type: NORMAL_TEXT
-box: 30 10 100 20
-boxtype: FL_FLAT_BOX
-colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
-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_TEXT
-type: NORMAL_TEXT
-box: 240 10 140 20
-boxtype: FL_FLAT_BOX
-colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
-style: FL_BOLD_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Alignment
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: 
-callback: 
-argument: 
-
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
index e8469158e9cd0c93dfa7ba931d1d39215bd6d607..848f352cbc4174819d7ac7763382178d5f72ac52 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-29  Juergen Vigna  <jug@sad.it>
+
+       * insetminipage.C: removed widthp_ and all it's functions and changed
+       to use new %-lengths of LyXLength.
+
 2001-03-28  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * insets/figinset.[Ch]: changed headers lyx.h, form1.h -> figure_form.h.
index 95e69d268254f45d95607cdc2a425f42e40d5bac..73211ba25a8c2b993e84dd85208369c4b73f8eb6 100644 (file)
@@ -229,9 +229,9 @@ UpdatableInset::LocalDispatch(BufferView * bv,
 }
 
 
-int UpdatableInset::getMaxWidth(Painter & pain, UpdatableInset const *) const
+int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
 {
     if (owner())
-        return static_cast<UpdatableInset*>(owner())->getMaxWidth(pain, this);
-    return pain.paperWidth();
+        return static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, this);
+    return bv->workWidth();
 }
index 7d7e92c8552317f30c3e4cd83ab1ba1086d449d2..6bb4d92bb1156f1a3afd5fe8bd42f0eceb3cfc46 100644 (file)
@@ -299,10 +299,10 @@ int InsetCollapsable::Latex(Buffer const * buf, ostream & os,
 }
 
 
-int InsetCollapsable::getMaxWidth(Painter & pain,
+int InsetCollapsable::getMaxWidth(BufferView * bv,
                                  UpdatableInset const * inset) const
 {
-    int const w = UpdatableInset::getMaxWidth(pain, inset);
+    int const w = UpdatableInset::getMaxWidth(bv, inset);
 
     if (w < 0) {
        // What does a negative max width signify? (Lgb)
index f7bb4258f48c7301ff626430b23328b3d0838c29..9674eb2882e89aaf1c617c0129890d535bfb5069 100644 (file)
@@ -121,7 +121,7 @@ public:
     ///
     void setAutoCollapse(bool f) { autocollapse = f; }
     ///
-    int getMaxWidth(Painter & pain, UpdatableInset const *) const;
+    int getMaxWidth(BufferView *, UpdatableInset const *) const;
     ///
     LyXText * getLyXText(BufferView const *, bool const recursive) const;
     ///
index cc096f24e2d3351943178c208700a2831f58beeb..9a2f1e2739810177166ec770d922f48537e81941 100644 (file)
@@ -69,7 +69,7 @@ InsetMinipage::InsetMinipage()
        setLabelFont(font);
        setAutoCollapse(false);
        setInsetName("Minipage");
-       widthp_ = 100; // set default to 100% of column_width
+       width_ = "100%"; // set default to 100% of column_width
 }
 
 
@@ -85,8 +85,7 @@ void InsetMinipage::Write(Buffer const * buf, ostream & os) const
           << "position " << pos_ << "\n"
           << "inner_position " << inner_pos_ << "\n"
           << "height \"" << height_ << "\"\n"
-          << "width \"" << width_ << "\"\n"
-          << "widthp " << widthp_ << "\n";
+          << "width \"" << width_ << "\"\n";
        InsetCollapsable::Write(buf, os);
 }
 
@@ -149,6 +148,9 @@ void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
                       << endl;
        }
     }
+#warning Remove me before final 1.2.0 (Jug)
+    // this is only for compatibility to the intermediate format and should
+    // vanish till the final 1.2.0!
     if (lex.IsOK()) {
        if (token.empty()) {
            lex.next();
@@ -156,13 +158,17 @@ void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
        }
        if (token == "widthp") {
            lex.next();
-           widthp_ = lex.GetInteger();
+           // only do this if the width_-string was not already set!
+           if (width_.empty())
+               width_ = lex.GetString() + "%";
            token = string();
        } else {
                lyxerr << "InsetMinipage::Read: Missing 'widthp_'-tag!"
                       << endl;
        }
     }
+    if (!token.empty())
+       lex.pushToken(token);
     InsetCollapsable::Read(buf, lex);
 }
 
@@ -177,7 +183,6 @@ Inset * InsetMinipage::Clone(Buffer const &) const
        result->inner_pos_ = inner_pos_;
        result->height_ = height_;
        result->width_ = width_;
-       result->widthp_ = widthp_;
        return result;
 }
 
@@ -251,18 +256,12 @@ int InsetMinipage::Latex(Buffer const * buf,
                s_pos += "b";
                break;
        }
-       
-       if (width_.empty()) {
-           os << "\\begin{minipage}[" << s_pos << "]{."
-              << widthp_ << "\\columnwidth}%\n";
-       } else {
-           os << "\\begin{minipage}[" << s_pos << "]{"
-              << width_ << "}%\n";
-       }
+       os << "\\begin{minipage}[" << s_pos << "]{"
+          << LyXLength(width_).asLatexString() << "}%\n";
        
        int i = inset->Latex(buf, os, fragile, fp);
+
        os << "\\end{minipage}%\n";
-       
        return i + 2;
 }
 
@@ -324,23 +323,6 @@ void InsetMinipage::width(string const & ll)
        width_ = ll;
 }
 
-int InsetMinipage::widthp() const
-{
-       return widthp_;
-}
-
-
-void InsetMinipage::widthp(int ll)
-{
-       widthp_ = ll;
-}
-
-
-void InsetMinipage::widthp(string const & ll)
-{
-       widthp_ = strToInt(ll);
-}
-
 
 bool InsetMinipage::ShowInsetDialog(BufferView * bv) const
 {
@@ -361,10 +343,11 @@ void InsetMinipage::InsetButtonRelease(BufferView * bv, int x, int y,
 }
 
 
-int InsetMinipage::getMaxWidth(Painter & pain, UpdatableInset const * inset)
+int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
     const
 {
     if (!width_.empty())
-       return VSpace(width_).inPixels(0, 0);
-    return InsetCollapsable::getMaxWidth(pain, inset) / 100 * widthp_;
+       return VSpace(width_).inPixels(bv);
+    // this should not happen!
+    return InsetCollapsable::getMaxWidth(bv, inset);
 }
index e324f27a3efba19168a0d3b192ca0103e967e017..01880f1da754f1d6fea4350fc2ea173f2a7405f4 100644 (file)
@@ -77,17 +77,11 @@ public:
        ///
        void width(string const &);
        ///
-       int widthp() const;
-       ///
-       void widthp(int);
-       ///
-       void widthp(string const &);
-       ///
        SigC::Signal0<void> hideDialog;
        ///
        void InsetButtonRelease(BufferView * bv, int x, int y, int button);
        ///
-       int getMaxWidth(Painter &, UpdatableInset const *) const;
+       int getMaxWidth(BufferView *, UpdatableInset const *) const;
        ///
        bool needFullRow() const { return false; }
        ///
@@ -101,8 +95,6 @@ private:
        string height_;
        ///
        string width_;
-       ///
-       int widthp_;
 };
 
 #endif
index cce5b9affc976ddaccdae88fde4a7fd115c91d24..143f1d3beaf13d89abab44c7d44cdc7b8a87fd08 100644 (file)
@@ -1812,17 +1812,17 @@ bool InsetTabular::InsetHit(BufferView *, int x, int) const
 
 // This returns paperWidth() if the cell-width is unlimited or the width
 // in pixels if we have a pwidth for this cell.
-int InsetTabular::GetMaxWidthOfCell(Painter &, int cell) const
+int InsetTabular::GetMaxWidthOfCell(BufferView * bv, int cell) const
 {
     string const s = tabular->GetPWidth(cell);
 
     if (s.empty())
        return -1;
-    return VSpace(s).inPixels(0, 0);
+    return VSpace(s).inPixels(bv);
 }
 
 
-int InsetTabular::getMaxWidth(Painter & pain,
+int InsetTabular::getMaxWidth(BufferView * bv,
                              UpdatableInset const * inset) const
 {
     int const n = tabular->GetNumberOfCells();
@@ -1833,7 +1833,7 @@ int InsetTabular::getMaxWidth(Painter & pain,
     }
     if (cell >= n)
        return -1;
-    int w = GetMaxWidthOfCell(pain, cell);
+    int w = GetMaxWidthOfCell(bv, cell);
     if (w > 0)
        // because the inset then subtracts it's top_x and owner->x()
        w += (inset->x() - top_x);
index da12246a229dd727a7940d651df379d0ed7e730a..e6ac44f7b1f4d0e6263d3d36188c5144c214b504 100644 (file)
@@ -159,7 +159,7 @@ public:
     ///
     void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
     ///
-    int getMaxWidth(Painter & pain, UpdatableInset const *) const;
+    int getMaxWidth(BufferView *, UpdatableInset const *) const;
     ///
     Buffer * BufferOwner() const { return const_cast<Buffer *>(buffer); }
     ///
@@ -232,7 +232,7 @@ private:
     ///
     bool InsetHit(BufferView * bv, int x, int y) const;
     ///
-    int GetMaxWidthOfCell(Painter &, int cell) const;
+    int GetMaxWidthOfCell(BufferView * bv, int cell) const;
     ///
     bool hasPasteBuffer() const;
     ///
index 833eb64c621b705b31d4007e9b76d99bc5ebb9a1..1fdad5dc02065a0836368eb1e76063e1339b052c 100644 (file)
@@ -288,15 +288,15 @@ int InsetText::descent(BufferView * bv, LyXFont const &) const
 
 int InsetText::width(BufferView * bv, LyXFont const &) const
 {
-    insetWidth = max(textWidth(bv->painter()),
+    insetWidth = max(textWidth(bv),
                     (int)TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET));
     return insetWidth;
 }
 
 
-int InsetText::textWidth(Painter & pain) const
+int InsetText::textWidth(BufferView * bv) const
 {
-    int const w = getMaxWidth(pain, this);
+    int const w = getMaxWidth(bv, this);
     return w;
 }
 
@@ -470,7 +470,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
     // static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
     // (2 * TEXT_TO_INSET_OFFSET);
 #else
-    insetWidth = textWidth(bv->painter());
+    insetWidth = textWidth(bv);
     if (insetWidth < 0)
            insetWidth = static_cast<int>(TEXT(bv)->width);
 #endif
@@ -1517,9 +1517,9 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
 }
 
 
-int InsetText::getMaxWidth(Painter & pain, UpdatableInset const * inset) const
+int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const
 {
-    int w = UpdatableInset::getMaxWidth(pain, inset);
+    int w = UpdatableInset::getMaxWidth(bv, inset);
     if (w < 0) {
        return w;
     }
index e464507de04cb465f507cac45844a2b8ab6b2d0b..934781980e08ae257cd59c6e58a0a5d9a024fd6e 100644 (file)
@@ -93,7 +93,7 @@ public:
     ///
     int width(BufferView *, LyXFont const & f) const;
     ///
-    int textWidth(Painter &) const;
+    int textWidth(BufferView *) const;
     ///
     void draw(BufferView *, LyXFont const &, int , float &, bool) const;
     ///
@@ -154,7 +154,7 @@ public:
     ///
     void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
     ///
-    int getMaxWidth(Painter &, UpdatableInset const *) const;
+    int getMaxWidth(BufferView *, UpdatableInset const *) const;
     ///
     void init(InsetText const * ins = 0);
     ///
index 240b08841ef0c779f19fe65a802d004915073567..86321f977cf7f3fcda1cb2e12d679410534130f0 100644 (file)
@@ -361,7 +361,7 @@ public:
        ///
        virtual bool isCursorVisible() const { return cursor_visible; }
        ///
-       virtual int getMaxWidth(Painter & pain, UpdatableInset const *) const;
+       virtual int getMaxWidth(BufferView * bv, UpdatableInset const *) const;
        ///
        int scroll() const { return scx; }
        ///
index 5f149ce2660bc1ca72a7eee90ba8133aefd410f0..ab3b4d8d1449a02d25752444cad19cd125c9355a 100644 (file)
@@ -1993,7 +1993,6 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
            if (LeftLine(cell))
                os << '|';
            if (!GetPWidth(cell).empty()) {
-#warning Jürgen, are these alignments correct? (Lgb)
                switch (GetVAlignment(cell)) {
                case LYX_VALIGN_TOP:
                    os << "p";
@@ -2044,7 +2043,6 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
     } else if (GetUsebox(cell) == BOX_MINIPAGE) {
        os << "\\begin{minipage}[";
        switch (GetVAlignment(cell)) {
-#warning Jürgen, are these alignments correct? (Lgb)
        case LYX_VALIGN_TOP:
            os << "t";
            break;
@@ -2109,7 +2107,6 @@ int LyXTabular::Latex(Buffer const * buf,
            os << column_info[i].align_special;
        } else if (!column_info[i].p_width.empty()) {
            switch (column_info[i].valignment) {
-#warning Jürgen, are these alignments correct? (Lgb)
            case LYX_VALIGN_TOP:
                os << "p";
                break;
index 42def16a1997b3c9f67a01ae75b1f31e3f4d9b08..adfd49e924f4d4a23cd6c8f0facd63d32932be78 100644 (file)
@@ -52,7 +52,7 @@ extern int bibitemMaxWidth(BufferView *, LyXFont const &);
 int LyXText::workWidth(BufferView * bview) const
 {
        if (inset_owner) {
-               return inset_owner->textWidth(bview->painter());
+               return inset_owner->textWidth(bview);
        }
        return bview->workWidth();
 }
index 03e6128afffa51670428c758a51ccd544f38900d..a3b94aa0547f34f383f5b54154d4f66bf5bf4094 100644 (file)
@@ -34,7 +34,8 @@ int const num_units = LyXLength::UNIT_NONE;
 // I am not sure if "mu" should be possible to select (Lgb)
 char const * unit_name[num_units] = { "sp", "pt", "bp", "dd",
                                      "mm", "pc", "cc", "cm",
-                                     "in", "ex", "em", "mu" }; 
+                                     "in", "ex", "em", "mu",
+                                     "%",  "c%", "p%", "l%" }; 
 
 
 /*  The following static items form a simple scanner for
@@ -104,7 +105,7 @@ char nextToken(string & data)
                        } else return 'E';
                }
                
-               i = data.find_first_not_of("abcdefghijklmnopqrstuvwxyz");
+               i = data.find_first_not_of("abcdefghijklmnopqrstuvwxyz%");
                if (i != 0) {
                        if (unit_index > 3) return 'E';
 
@@ -162,6 +163,13 @@ LaTeXLength table[] = {
 
 } // namespace anon
 
+const char * stringFromUnit(int unit)
+{
+    if (unit < 0 || unit >= num_units)
+       return 0;
+    return unit_name[unit];
+}
+
 
 LyXLength::UNIT unitFromString (string const & data)
 {
@@ -323,6 +331,28 @@ string const LyXLength::asString() const
 }
 
 
+string const LyXLength::asLatexString() const
+{
+       std::ostringstream buffer;
+       switch(uni) {
+       case PW:
+       case PE:
+           buffer << "." << abs(static_cast<int>(val)) << "\\columnwidth";
+           break;
+       case PP:
+           buffer << "." << abs(static_cast<int>(val)) << "\\pagewidth";
+           break;
+       case PL:
+           buffer << "." << abs(static_cast<int>(val)) << "\\linewidth";
+           break;
+       default:
+           buffer << val << unit_name[uni]; // setw?
+           break;
+       }
+       return buffer.str().c_str();
+}
+
+
 /*  LyXGlueLength class
  */
 
@@ -521,13 +551,15 @@ int VSpace::inPixels(BufferView * bv) const
        // Height of a normal line in pixels (zoom factor considered)
        int height = bv->text->DefaultHeight(); // [pixels]
        int skip = 0;
+       int width = bv->workWidth();
+
        if (kin == DEFSKIP)
            skip = bv->buffer()->params.getDefSkip().inPixels(bv);
 
-       return inPixels(height, skip);
+       return inPixels(height, skip, width);
 }
 
-int VSpace::inPixels(int default_height, int default_skip) const
+int VSpace::inPixels(int default_height, int default_skip, int default_width) const
 {
        // Height of a normal line in pixels (zoom factor considered)
        int height = default_height; // [pixels]
@@ -623,6 +655,12 @@ int VSpace::inPixels(int default_height, int default_skip) const
                        // math mode
                        result = zoom * value * height;
                        break;
+               case LyXLength::PW: // Always % of workarea
+               case LyXLength::PE:
+               case LyXLength::PP:
+               case LyXLength::PL:
+                       result = value * default_width / 100;
+                       break;
                case LyXLength::UNIT_NONE:
                        result = 0;  // this cannot happen
                        break;  
index f3c8f5072d04d239bcc7646d66bd2370a3cb4b0f..fec4083b68c410e99de66cc1edc4c211726adf81 100644 (file)
@@ -50,6 +50,13 @@ public:
                EM,
                /// Math unit (18mu = 1em) for positioning in math mode
                MU,
+               /// Percent of columnwidth both "%" or "%c"
+               PW,
+               PE,
+               /// Percent of pagewidth
+               PP,
+               /// Percent of linewidth
+               PL,
                /// no unit
                UNIT_NONE
        };
@@ -71,9 +78,7 @@ public:
        /// conversion
        virtual string const asString() const;
        ///
-       virtual string const asLatexString() const {
-               return this->asString();
-       }
+       virtual string const asLatexString() const;
 
        /** If "data" is valid, the length represented by it is
          stored into "result", if that is not 0. */
@@ -99,6 +104,8 @@ bool operator==(LyXLength const & l1, LyXLength const & l2)
 extern LyXLength::UNIT unitFromString (string const & data);
 ///
 extern bool isValidLength(string const & data, LyXLength * result);
+///
+extern const char * stringFromUnit(int unit);
 
 /// LyXGlueLength class
 class LyXGlueLength : public LyXLength {
@@ -239,7 +246,7 @@ public:
        ///
        int inPixels(BufferView * bv) const;
        ///
-       int inPixels(int default_height, int default_skip) const;
+       int inPixels(int default_height, int default_skip, int default_width=0) const;
 private:
        /// This VSpace kind
        vspace_kind kin;