From 229ddc5929bb43a53634a6308d9ba6f9336c3ae3 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Tue, 23 Oct 2001 11:35:48 +0000 Subject: [PATCH] =?utf8?q?J=EF=BF=BDrgen=20Spitz=EF=BF=BDller's=20patch=20?= =?utf8?q?for=20the=20tabular=20dialog=20+=20some=20tweaking=20of=20the=20?= =?utf8?q?document=20dialog.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2924 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 7 +++ src/frontends/xforms/FormDocument.C | 6 +- src/frontends/xforms/FormTabular.C | 70 ++++++++++++++------- src/frontends/xforms/form_document.C | 4 +- src/frontends/xforms/form_tabular.C | 16 +++-- src/frontends/xforms/form_tabular.h | 2 + src/frontends/xforms/forms/form_document.fd | 4 +- src/frontends/xforms/forms/form_tabular.fd | 50 ++++++++++++--- 8 files changed, 117 insertions(+), 42 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 9ea9acee98..9e90310c2b 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,10 @@ +2001-10-23 Jürgen Spitzmüller + + * forms/form_tabular.fd: Add value choices + * FormTabular.C: Handle that choices + + * FormDocument.C: fix small bug. + 2001-10-23 Angus Leeming * FormGraphics.[Ch]: move some parameters out of the heaader file and diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 2fda2c10b7..8972938287 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -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; diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index fc124e9524..428de22351 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -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 units_vec = getLatexUnits(); + for (std::vector::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) diff --git a/src/frontends/xforms/form_document.C b/src/frontends/xforms/form_document.C index c3513c60bd..4a75174ebf 100644 --- a/src/frontends/xforms/form_document.C +++ b/src/frontends/xforms/form_document.C @@ -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, ""); diff --git a/src/frontends/xforms/form_tabular.C b/src/frontends/xforms/form_tabular.C index 7111cbb6a9..76eb5af3a3 100644 --- a/src/frontends/xforms/form_tabular.C +++ b/src/frontends/xforms/form_tabular.C @@ -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; diff --git a/src/frontends/xforms/form_tabular.h b/src/frontends/xforms/form_tabular.h index 24be20b707..924114b9c9 100644 --- a/src/frontends/xforms/form_tabular.h +++ b/src/frontends/xforms/form_tabular.h @@ -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(); diff --git a/src/frontends/xforms/forms/form_document.fd b/src/frontends/xforms/forms/form_document.fd index f0b6889889..ecd88bf6f8 100644 --- a/src/frontends/xforms/forms/form_document.fd +++ b/src/frontends/xforms/forms/form_document.fd @@ -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 diff --git a/src/frontends/xforms/forms/form_tabular.fd b/src/frontends/xforms/forms/form_tabular.fd index d5cbc0bfb0..d50c74b339 100644 --- a/src/frontends/xforms/forms/form_tabular.fd +++ b/src/frontends/xforms/forms/form_tabular.fd @@ -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 -- 2.39.2