]> git.lyx.org Git - features.git/commitdiff
Various fixes suggested by J�rgen
authorAngus Leeming <leeming@lyx.org>
Thu, 11 Oct 2001 17:28:28 +0000 (17:28 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 11 Oct 2001 17:28:28 +0000 (17:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2863 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormDocument.h
src/frontends/xforms/form_document.C
src/frontends/xforms/forms/form_document.fd
src/frontends/xforms/xforms_helpers.C

index c952be85144891f9238c601d281e6d508ed598bb..5bdef12c4acc170a4c85734150940ead81c2b568 100644 (file)
@@ -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);
index 5b28972e5ca074c11c7af8c34461ea5006b70dd9..51c15d5844a186329476d4291d307be6d9dd1e76 100644 (file)
@@ -107,8 +107,6 @@ private:
        ///
        void BulletBMTable(FL_OBJECT * ob, long);
        ///
-       void checkMarginValues();
-       ///
        void checkReadOnly();
        ///
        void CheckChoiceClass(FL_OBJECT * ob, long);
index 684a61d23351b2ff1f20ce7d91c79f4d3c15b24b..5c53e0480b1225f1a68d0e4c573d05c3be6a861a 100644 (file)
@@ -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);
   }
index e74153b07f41eccbdf666fc439e57402dd38eec7..768ff67e1a3b02c70acb610e292bd9852247fccd 100644 (file)
@@ -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
index 274874989bc5924fd1c502f5683bf795d3058c80..3aa0260d673563f031fe95b99bf37a4ba59216ba 100644 (file)
@@ -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)));