]> git.lyx.org Git - features.git/commitdiff
J�rgen Spitz�ller's patch for the tabular dialog + some tweaking of the
authorAngus Leeming <leeming@lyx.org>
Tue, 23 Oct 2001 11:35:48 +0000 (11:35 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 23 Oct 2001 11:35:48 +0000 (11:35 +0000)
document dialog.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2924 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_document.C
src/frontends/xforms/form_tabular.C
src/frontends/xforms/form_tabular.h
src/frontends/xforms/forms/form_document.fd
src/frontends/xforms/forms/form_tabular.fd

index 9ea9acee987aa7e7dece6b975f371786bbb6f728..9e90310c2b8d7fe306901d7e45c6281966da648a 100644 (file)
@@ -1,3 +1,10 @@
+2001-10-23  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * forms/form_tabular.fd: Add value choices
+       * FormTabular.C: Handle that choices
+
+       * FormDocument.C: fix small bug.
+
 2001-10-23  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormGraphics.[Ch]: move some parameters out of the heaader file and
index 2fda2c10b7409cba29a718d53e81ffb241cb4297..897293828797ae82630d35931e14b42d201f80db 100644 (file)
@@ -419,8 +419,10 @@ bool FormDocument::input( FL_OBJECT * ob, long data )
        if (ob == class_->radio_doc_skip ||
            ob == class_->radio_doc_indent) {
                setEnabled(class_->choice_doc_skip, skip_used);
-               setEnabled(class_->input_doc_skip, skip_used);
-               setEnabled(class_->choice_default_skip_units, skip_used);
+               setEnabled(class_->input_doc_skip,
+                          skip_used && length_input);
+               setEnabled(class_->choice_default_skip_units,
+                          skip_used && length_input);
                // Default unit choice is cm if metric, inches if US paper.
                int const paperchoice = fl_get_choice(paper_->choice_papersize);
                bool const metric = paperchoice < 3 || paperchoice > 5;
index fc124e9524c7dafedd29ad9daa7f713a4680ce3f..428de22351c2d25974a60d3edbbe137d23846ed4 100644 (file)
@@ -24,6 +24,9 @@
 #include "insets/insettabular.h"
 #include "buffer.h"
 #include "xforms_helpers.h"
+#include "helper_funcs.h"
+#include "input_validators.h"
+#include "support/lstrings.h"
 
 using SigC::slot;
 
@@ -122,6 +125,29 @@ void FormTabular::build()
                           cell_options_->form);
        fl_addto_tabfolder(dialog_->tabFolder, _("LongTable"),
                           longtable_options_->form);
+
+       // We should set these input filters on width fields to make them accept
+       // only unsigned numbers.
+       // But this leeds to trouble with the current apply behaviour (JSpitzm).
+       // fl_set_input_filter(column_options_->input_column_width,
+       //                  fl_unsigned_float_filter);
+       // fl_set_input_filter(cell_options_->input_mcolumn_width,
+       //                  fl_unsigned_float_filter);
+
+       // Create the contents of the unit choices
+       // Don't include the "%" terms...
+       std::vector<string> units_vec = getLatexUnits();
+       for (std::vector<string>::iterator it = units_vec.begin();
+            it != units_vec.end(); ++it) {
+               if (contains(*it, "%"))
+                       it = units_vec.erase(it, it+1) - 1;
+       }
+       string units = getStringFromVector(units_vec, "|");
+
+       fl_addto_choice(column_options_->choice_value_column_width,
+                       units.c_str());
+       fl_addto_choice(cell_options_->choice_value_mcolumn_width,
+                       units.c_str());
 }
 
 
@@ -143,6 +169,7 @@ void FormTabular::update()
        fl_activate_object(column_options_->input_special_alignment);
        fl_activate_object(cell_options_->input_special_multialign);
        fl_activate_object(column_options_->input_column_width);
+       fl_activate_object(column_options_->choice_value_column_width);
        sprintf(buf,"%d",column);
        fl_set_input(dialog_->input_tabular_column, buf);
        fl_deactivate_object(dialog_->input_tabular_column);
@@ -190,10 +217,15 @@ void FormTabular::update()
                setEnabled(cell_options_->radio_valign_center, true);
                special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_MULTI);
                fl_set_input(cell_options_->input_special_multialign, special.c_str());
-               fl_set_input(cell_options_->input_mcolumn_width,pwidth.c_str());
+               string const default_unit = "cm";
+               updateWidgetsFromLengthString(cell_options_->input_mcolumn_width,
+                                             cell_options_->choice_value_mcolumn_width,
+                                             pwidth.c_str(), default_unit);
+
                if (!lv_->buffer()->isReadonly()) {
                        setEnabled(cell_options_->input_special_multialign, true);
                        setEnabled(cell_options_->input_mcolumn_width, true);
+                       setEnabled(cell_options_->choice_value_mcolumn_width, true);
                }
 
                setEnabled(cell_options_->radio_valign_top,    !pwidth.empty());
@@ -241,6 +273,7 @@ void FormTabular::update()
 
                fl_set_input(cell_options_->input_mcolumn_width, "");
                setEnabled(cell_options_->input_mcolumn_width, false);
+               setEnabled(cell_options_->choice_value_mcolumn_width, false);
        }
        if (tabular->GetRotateCell(cell))
                fl_set_button(cell_options_->radio_rotate_cell, 1);
@@ -269,8 +302,12 @@ void FormTabular::update()
        setEnabled(column_options_->input_special_alignment, !isReadonly);
 
        pwidth = tabular->GetColumnPWidth(cell);
-       fl_set_input(column_options_->input_column_width,pwidth.c_str());
+       string const default_unit = "cm";
+       updateWidgetsFromLengthString(column_options_->input_column_width,
+                                     column_options_->choice_value_column_width,
+                                     pwidth.c_str(), default_unit);
        setEnabled(column_options_->input_column_width, !isReadonly);
+       setEnabled(column_options_->choice_value_column_width, !isReadonly);
 
        setEnabled(cell_options_->radio_useminipage, !pwidth.empty());
        if (!pwidth.empty()) {
@@ -369,37 +406,22 @@ bool FormTabular::input(FL_OBJECT * ob, long)
       return false;
     }
     if (ob == column_options_->input_column_width) {
-        string const str = fl_get_input(ob);
-        if (!str.empty() && !isValidLength(str)) {
-            fl_set_object_label(dialog_->text_warning,
-                 _("Warning: Invalid Length (valid example: 10mm)"));
-            fl_show_object(dialog_->text_warning);
-            return false;
-        }
+           string const str =
+                   getLengthFromWidgets(column_options_->input_column_width,
+                                        column_options_->choice_value_column_width);
         inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH,str);
         update(); // update for alignment
         return true;
     }
     if (ob == cell_options_->input_mcolumn_width) {
-        string const str = fl_get_input(ob);
-        if (!str.empty() && !isValidLength(str)) {
-            fl_set_object_label(dialog_->text_warning,
-                 _("Warning: Invalid Length (valid example: 10mm)"));
-            fl_show_object(dialog_->text_warning);
-            return false;
-        }
+           string const str =
+                   getLengthFromWidgets(cell_options_->input_mcolumn_width,
+                                        cell_options_->choice_value_mcolumn_width);
         inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH,str);
         update(); // update for alignment
         return true;
     }
-    string const str = fl_get_input(column_options_->input_column_width);
-    if (!str.empty() && !isValidLength(str)) {
-        fl_set_object_label(
-           dialog_->text_warning,
-           _("Warning: Invalid Length (valid example: 10mm)"));
-        fl_show_object(dialog_->text_warning);
-        return false;
-    }
+
     if (ob == tabular_options_->button_append_row)
         num = LyXTabular::APPEND_ROW;
     else if (ob == tabular_options_->button_append_column)
index c3513c60bddee5a3eb81a188d034c08f0dc42e94..4a75174ebf76a09bbb627994f84c6f7689f39c54 100644 (file)
@@ -253,7 +253,7 @@ FD_form_doc_class * FormDocument::build_doc_class()
   obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 245, 400, 85, _("Separation"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
-  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 300, 110, 115, 80, _("Page cols"));
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 300, 110, 120, 75, _("Page cols"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
   obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 300, 20, 120, 75, _("Sides"));
@@ -372,7 +372,7 @@ FD_form_doc_class * FormDocument::build_doc_class()
     fl_set_button(obj, 1);
   fl_end_group();
 
-  fdui->input_doc_spacing = obj = fl_add_input(FL_NORMAL_INPUT, 300, 200, 115, 30, "");
+  fdui->input_doc_spacing = obj = fl_add_input(FL_NORMAL_INPUT, 300, 200, 120, 30, "");
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT);
   fdui->choice_default_skip_units = obj = fl_add_choice(FL_NORMAL_CHOICE, 350, 290, 60, 30, "");
index 7111cbb6a97499bf2ed40edc42c5494c23ee5a5c..76eb5af3a368c88bd45fed8ed527d99043ce919d 100644 (file)
@@ -143,9 +143,9 @@ FD_form_column_options * FormTabular::build_column_options()
   FL_OBJECT *obj;
   FD_form_column_options *fdui = new FD_form_column_options;
 
-  fdui->form = fl_bgn_form(FL_NO_BOX, 505, 227);
+  fdui->form = fl_bgn_form(FL_NO_BOX, 505, 225);
   fdui->form->u_vdata = this;
-  obj = fl_add_box(FL_FLAT_BOX, 0, 0, 505, 227, "");
+  obj = fl_add_box(FL_FLAT_BOX, 0, 0, 505, 225, "");
   {
     char const * const dummy = N_("Top|#t");
     fdui->radio_border_top = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 85, 45, 25, 25, idex(_(dummy)));
@@ -231,7 +231,7 @@ FD_form_column_options * FormTabular::build_column_options()
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
   {
     char const * const dummy = N_("Width|#W");
-    fdui->input_column_width = obj = fl_add_input(FL_NORMAL_INPUT, 320, 170, 95, 30, idex(_(dummy)));
+    fdui->input_column_width = obj = fl_add_input(FL_NORMAL_INPUT, 275, 170, 95, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
@@ -239,7 +239,7 @@ FD_form_column_options * FormTabular::build_column_options()
     fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
   {
     char const * const dummy = N_("Alignment|#A");
-    fdui->input_special_alignment = obj = fl_add_input(FL_NORMAL_INPUT, 85, 170, 215, 30, idex(_(dummy)));
+    fdui->input_special_alignment = obj = fl_add_input(FL_NORMAL_INPUT, 40, 170, 215, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
@@ -249,6 +249,9 @@ FD_form_column_options * FormTabular::build_column_options()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  fdui->choice_value_column_width = obj = fl_add_choice(FL_NORMAL_CHOICE, 375, 170, 75, 30, "");
+    fl_set_object_boxtype(obj, FL_FRAME_BOX);
+    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
@@ -357,7 +360,7 @@ FD_form_cell_options * FormTabular::build_cell_options()
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
   {
     char const * const dummy = N_("Width|#W");
-    fdui->input_mcolumn_width = obj = fl_add_input(FL_NORMAL_INPUT, 280, 180, 175, 30, idex(_(dummy)));
+    fdui->input_mcolumn_width = obj = fl_add_input(FL_NORMAL_INPUT, 280, 180, 95, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
@@ -391,6 +394,9 @@ FD_form_cell_options * FormTabular::build_cell_options()
   obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 180, 135, 290, 80, _("Special Multicolumn"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  fdui->choice_value_mcolumn_width = obj = fl_add_choice(FL_NORMAL_CHOICE, 380, 180, 75, 30, "");
+    fl_set_object_boxtype(obj, FL_FRAME_BOX);
+    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
index 24be20b707b468422edb23700eff2101e8f2ce18..924114b9c9e18a22852f3be2830fb13ecf90114c 100644 (file)
@@ -56,6 +56,7 @@ struct FD_form_column_options {
        FL_OBJECT *radio_valign_bottom;
        FL_OBJECT *input_column_width;
        FL_OBJECT *input_special_alignment;
+       FL_OBJECT *choice_value_column_width;
 };
 struct FD_form_cell_options {
        ~FD_form_cell_options();
@@ -76,6 +77,7 @@ struct FD_form_cell_options {
        FL_OBJECT *radio_multicolumn;
        FL_OBJECT *radio_useminipage;
        FL_OBJECT *radio_rotate_cell;
+       FL_OBJECT *choice_value_mcolumn_width;
 };
 struct FD_form_longtable_options {
        ~FD_form_longtable_options();
index f0b688988917bc85bba6b49e5cc7d546d91d26c5..ecd88bf6f87f8c44aae725649f537deb927d7076 100644 (file)
@@ -748,7 +748,7 @@ argument:
 --------------------
 class: FL_LABELFRAME
 type: ENGRAVED_FRAME
-box: 300 110 115 80
+box: 300 110 120 75
 boxtype: FL_NO_BOX
 colors: FL_BLACK FL_COL1
 alignment: FL_ALIGN_TOP_LEFT
@@ -1145,7 +1145,7 @@ argument:
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 300 200 115 30
+box: 300 200 120 30
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_LEFT
index d5cbc0bfb0e76c917a6880c664630437c2653dc8..d50c74b339d60dc6d1582a88c2f2632fa451ac78 100644 (file)
@@ -310,13 +310,13 @@ argument:
 =============== FORM ===============
 Name: form_column_options
 Width: 505
-Height: 227
-Number of Objects: 17
+Height: 225
+Number of Objects: 18
 
 --------------------
 class: FL_BOX
 type: FLAT_BOX
-box: 0 0 505 227
+box: 0 0 505 225
 boxtype: FL_FLAT_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -568,7 +568,7 @@ argument:
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 320 170 95 30
+box: 275 170 95 30
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_TOP
@@ -586,7 +586,7 @@ argument: 0
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 85 170 215 30
+box: 40 170 215 30
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_TOP
@@ -619,11 +619,29 @@ name:
 callback: 
 argument: 
 
+--------------------
+class: FL_CHOICE
+type: NORMAL_CHOICE
+box: 375 170 75 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_value_column_width
+callback: C_FormBaseDeprecatedInputCB
+argument: 0
+
 =============== FORM ===============
 Name: form_cell_options
 Width: 505
 Height: 225
-Number of Objects: 21
+Number of Objects: 22
 
 --------------------
 class: FL_BOX
@@ -880,7 +898,7 @@ argument:
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 280 180 175 30
+box: 280 180 95 30
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_LEFT
@@ -1003,6 +1021,24 @@ name:
 callback: 
 argument: 
 
+--------------------
+class: FL_CHOICE
+type: NORMAL_CHOICE
+box: 380 180 75 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_value_mcolumn_width
+callback: C_FormBaseDeprecatedInputCB
+argument: 0
+
 =============== FORM ===============
 Name: form_longtable_options
 Width: 505