From cdc0cab2bc782aac9599358fe116042983376a21 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Thu, 11 Oct 2001 17:28:28 +0000 Subject: [PATCH] =?UTF-8?q?Various=20fixes=20suggested=20by=20J=EF=BF=BDrg?= =?UTF-8?q?en?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2863 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/FormDocument.C | 164 +++++--------------- src/frontends/xforms/FormDocument.h | 2 - src/frontends/xforms/form_document.C | 2 +- src/frontends/xforms/forms/form_document.fd | 2 +- src/frontends/xforms/xforms_helpers.C | 10 +- 5 files changed, 47 insertions(+), 133 deletions(-) diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index c952be8514..5bdef12c4a 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -345,10 +345,6 @@ void FormDocument::update() BufferParams const & params = lv_->buffer()->params; -// fl_set_object_label(dialog_->button_save_defaults, -// _("Save as Defaults")); -// fl_set_object_label(dialog_->button_reset_defaults, -// _("Use Class Defaults")); setEnabled(dialog_->button_reset_defaults, !params.hasClassDefaults()); @@ -416,10 +412,38 @@ bool FormDocument::input( FL_OBJECT * ob, long data ) BufferParams::PACKAGE_NONE + 1); if (ob == paper_->choice_papersize) { - if (fl_get_choice(paper_->choice_papersize) == 2) - fl_set_button(paper_->radio_portrait, 1); bool const custom = fl_get_choice(paper_->choice_papersize) == 2; + bool const a3size = + fl_get_choice(paper_->choice_papersize) == 6; + bool const b3size = + fl_get_choice(paper_->choice_papersize) == 9; + bool const b4size = + fl_get_choice(paper_->choice_papersize) == 10; + + fl_set_button(paper_->radio_portrait, int(custom)); + + bool const use_geom = (custom || a3size || b3size || b4size); + + fl_set_button(paper_->check_use_geometry, int(use_geom)); + + setEnabled(paper_->input_top_margin, use_geom); + setEnabled(paper_->input_bottom_margin, use_geom); + setEnabled(paper_->input_left_margin, use_geom); + setEnabled(paper_->input_right_margin, use_geom); + setEnabled(paper_->input_head_height, use_geom); + setEnabled(paper_->input_head_sep, use_geom); + setEnabled(paper_->input_foot_skip, use_geom); + setEnabled(paper_->choice_top_margin_units, use_geom); + setEnabled(paper_->choice_bottom_margin_units, use_geom); + setEnabled(paper_->choice_left_margin_units, use_geom); + setEnabled(paper_->choice_right_margin_units, use_geom); + setEnabled(paper_->choice_head_height_units, use_geom); + setEnabled(paper_->choice_head_sep_units, use_geom); + setEnabled(paper_->choice_foot_skip_units, use_geom); + setEnabled(paper_->choice_custom_width_units, use_geom); + setEnabled(paper_->choice_custom_height_units, use_geom); + setEnabled(paper_->input_custom_width, custom); setEnabled(paper_->input_custom_height, custom); setEnabled(paper_->choice_custom_width_units, custom); @@ -428,9 +452,9 @@ bool FormDocument::input( FL_OBJECT * ob, long data ) setEnabled(paper_->radio_landscape, !custom); } - if (ob == paper_->choice_papersize - || paper_->radio_portrait - || paper_->radio_landscape) { + if (ob == paper_->choice_papersize || + ob == paper_->radio_portrait || + ob == paper_->radio_landscape) { setEnabled(paper_->choice_paperpackage, //either default papersize (preferences) @@ -464,8 +488,11 @@ bool FormDocument::input( FL_OBJECT * ob, long data ) if (ob == paper_->check_use_geometry) { //don't allow switching geometry off in custom papersize mode - if (fl_get_choice(paper_->choice_papersize) == 2) + //nor in A3, B3, and B4 + int const choice = fl_get_choice(paper_->choice_papersize); + if (choice == 2 || choice == 6 || choice == 9 || choice == 10) fl_set_button(paper_->check_use_geometry, 1); + fl_set_choice(paper_->choice_paperpackage, BufferParams::PACKAGE_NONE + 1); @@ -1030,129 +1057,12 @@ void FormDocument::checkReadOnly() } -void FormDocument::checkMarginValues() -{ -//this is not needed after the recent redesign (JSpitzm) -#if 0 - bool const not_empty = - strlen(fl_get_input(paper_->input_top_margin)) || - strlen(fl_get_input(paper_->input_bottom_margin)) || - strlen(fl_get_input(paper_->input_left_margin)) || - strlen(fl_get_input(paper_->input_right_margin)) || - strlen(fl_get_input(paper_->input_head_height)) || - strlen(fl_get_input(paper_->input_head_sep)) || - strlen(fl_get_input(paper_->input_foot_skip)) || - strlen(fl_get_input(paper_->input_custom_width)) || - strlen(fl_get_input(paper_->input_custom_height)); -#endif -} - - - bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long) { string str; bool ok = true; char const * input; -// this is not needed after the recent redesign (Angus) -#if 0 - int val; - checkMarginValues(); - if (ob == paper_->choice_papersize) { - val = fl_get_choice(paper_->choice_papersize)-1; - if (val == BufferParams::VM_PAPER_DEFAULT) { - fl_set_button(paper_->check_use_geometry, 0); - setEnabled(paper_->input_top_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_bottom_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_left_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_right_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_head_height, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_head_sep, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_foot_skip, - fl_get_button(paper_->check_use_geometry)); - checkMarginValues(); - } else { - if ((val != BufferParams::VM_PAPER_USLETTER) && - (val != BufferParams::VM_PAPER_USLEGAL) && - (val != BufferParams::VM_PAPER_USEXECUTIVE) && - (val != BufferParams::VM_PAPER_A4) && - (val != BufferParams::VM_PAPER_A5) && - (val != BufferParams::VM_PAPER_B5)) { - fl_set_button(paper_->check_use_geometry, 1); - setEnabled(paper_->input_top_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_bottom_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_left_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_right_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_head_height, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_head_sep, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_foot_skip, - fl_get_button(paper_->check_use_geometry)); - } - fl_set_choice(paper_->choice_paperpackage, - BufferParams::PACKAGE_NONE + 1); - } - } else if (ob == paper_->choice_paperpackage) { - val = fl_get_choice(paper_->choice_paperpackage)-1; - if (val != BufferParams::PACKAGE_NONE) { - fl_set_button(paper_->check_use_geometry, 0); - setEnabled(paper_->input_top_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_bottom_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_left_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_right_margin, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_head_height, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_head_sep, - fl_get_button(paper_->check_use_geometry)); - setEnabled(paper_->input_foot_skip, - fl_get_button(paper_->check_use_geometry)); - } - } else if (ob == class_->input_doc_spacing) { - input = fl_get_input(class_->input_doc_spacing); - if (!*input) { - fl_set_choice (class_->choice_doc_spacing, 1); - } else { - fl_set_choice(class_->choice_doc_spacing, 4); - } - } - // this has to be all out of if/elseif because it has to deactivate - // the document buttons and so the whole stuff has to be tested again. - str = fl_get_input(paper_->input_custom_width); - ok = ok && (str.empty() || isValidLength(str)); - str = fl_get_input(paper_->input_custom_height); - ok = ok && (str.empty() || isValidLength(str)); - str = fl_get_input(paper_->input_left_margin); - ok = ok && (str.empty() || isValidLength(str)); - str = fl_get_input(paper_->input_right_margin); - ok = ok && (str.empty() || isValidLength(str)); - str = fl_get_input(paper_->input_top_margin); - ok = ok && (str.empty() || isValidLength(str)); - str = fl_get_input(paper_->input_bottom_margin); - ok = ok && (str.empty() || isValidLength(str)); - str = fl_get_input(paper_->input_head_height); - ok = ok && (str.empty() || isValidLength(str)); - str = fl_get_input(paper_->input_head_sep); - ok = ok && (str.empty() || isValidLength(str)); - str = fl_get_input(paper_->input_foot_skip); - ok = ok && (str.empty() || isValidLength(str)); -#endif - // "Synchronize" the choice and the input field, so that it // is impossible to commit senseless data. input = fl_get_input (class_->input_doc_skip); diff --git a/src/frontends/xforms/FormDocument.h b/src/frontends/xforms/FormDocument.h index 5b28972e5c..51c15d5844 100644 --- a/src/frontends/xforms/FormDocument.h +++ b/src/frontends/xforms/FormDocument.h @@ -107,8 +107,6 @@ private: /// void BulletBMTable(FL_OBJECT * ob, long); /// - void checkMarginValues(); - /// void checkReadOnly(); /// void CheckChoiceClass(FL_OBJECT * ob, long); diff --git a/src/frontends/xforms/form_document.C b/src/frontends/xforms/form_document.C index 684a61d233..5c53e0480b 100644 --- a/src/frontends/xforms/form_document.C +++ b/src/frontends/xforms/form_document.C @@ -141,7 +141,7 @@ FD_form_doc_paper * FormDocument::build_doc_paper() obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 150, 415, 185, _("Margins")); { - char const * const dummy = N_("Custom Margins/Sizes|#M"); + char const * const dummy = N_("Custom sizes|#M"); fdui->check_use_geometry = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 155, 30, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } diff --git a/src/frontends/xforms/forms/form_document.fd b/src/frontends/xforms/forms/form_document.fd index e74153b07f..768ff67e1a 100644 --- a/src/frontends/xforms/forms/form_document.fd +++ b/src/frontends/xforms/forms/form_document.fd @@ -425,7 +425,7 @@ alignment: FL_ALIGN_RIGHT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Custom Margins/Sizes|#M +label: Custom sizes|#M shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 274874989b..3aa0260d67 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -75,9 +75,9 @@ string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice) lyx::Assert(input && input->objclass == FL_INPUT && choice && choice->objclass == FL_CHOICE); - string length = strip(frontStrip(fl_get_input(input))); + string const length = strip(frontStrip(fl_get_input(input))); if (length.empty()) - length = "0"; + return string(); string const units = strip(frontStrip(fl_get_choice_text(choice))); @@ -92,6 +92,12 @@ void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice, lyx::Assert(input && input->objclass == FL_INPUT && choice && choice->objclass == FL_CHOICE); + if (str.empty()) { + fl_set_input(input, ""); + fl_set_choice(choice, 1); + return; + } + // The unit is presumed to begin at the first char a-z string const tmp = lowercase(strip(frontStrip(str)));