]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormParagraph.C
More pref work from Angus
[lyx.git] / src / frontends / xforms / FormParagraph.C
index 1adfec0e3f2bf1e870c54ee2bb0c851d335870dc..0f9beea210d1f31ca2268c9f534332dd09787e7b 100644 (file)
@@ -30,8 +30,8 @@ using Liason::setMinibuffer;
 #endif
 
 FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
-       : FormBase(lv, d, _("Paragraph Layout"), BUFFER_DEPENDENT, UPDATE,
-                  new NoRepeatedApplyReadOnlyPolicy),
+       : FormBaseBD(lv, d, _("Paragraph Layout"),
+                    new NoRepeatedApplyReadOnlyPolicy),
        dialog_(0), general_(0), extra_(0)
 {
     // let the popup be shown
@@ -61,6 +61,10 @@ void FormParagraph::build()
     // the tabbed folder
     dialog_ = build_tabbed_paragraph();
 
+    // Workaround dumb xforms sizing bug
+    minw_ = form()->w;
+    minh_ = form()->h;
+
     // manage the restore, ok, apply and cancel/close buttons
     bc_.setOK(dialog_->button_ok);
     bc_.setApply(dialog_->button_apply);
@@ -88,6 +92,8 @@ void FormParagraph::build()
     bc_.addReadOnly (general_->radio_align_center);
     bc_.addReadOnly (general_->check_lines_top);
     bc_.addReadOnly (general_->check_lines_bottom);
+    bc_.addReadOnly (general_->check_pagebreaks_top);
+    bc_.addReadOnly (general_->check_pagebreaks_bottom);
     bc_.addReadOnly (general_->choice_space_above);
     bc_.addReadOnly (general_->input_space_above);
     bc_.addReadOnly (general_->check_space_above);
@@ -106,6 +112,8 @@ void FormParagraph::build()
     bc_.addReadOnly (extra_->radio_pextra_indent);
     bc_.addReadOnly (extra_->radio_pextra_minipage);
     bc_.addReadOnly (extra_->radio_pextra_floatflt);
+    bc_.addReadOnly (extra_->radio_pextra_hfill);
+    bc_.addReadOnly (extra_->radio_pextra_startmp);
 
     // now make them fit together
     fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
@@ -135,6 +143,7 @@ void FormParagraph::update()
 
     general_update();
     extra_update();
+    bc_.readOnly(lv_->buffer()->isReadonly());
 }
 
 
@@ -183,7 +192,8 @@ void FormParagraph::general_apply()
        space_top = VSpace(VSpace::VFILL);
        break;
     case 7:
-       space_top = VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
+       space_top =
+               VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
        break;
     }
     if (fl_get_button (general_->check_space_above))
@@ -208,7 +218,8 @@ void FormParagraph::general_apply()
        space_bottom = VSpace(VSpace::VFILL);
        break;
     case 7:
-       space_bottom = VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
+       space_bottom =
+               VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
        break;
     }
     if (fl_get_button (general_->check_space_below))
@@ -539,17 +550,17 @@ bool FormParagraph::input(FL_OBJECT * ob, long)
     //
     // "Synchronize" the choices and input fields, making it
     // impossible to commit senseless data.
-    if (ob == general_->choice_space_above) {
-       if (fl_get_choice (general_->choice_space_above) != 7)
-           fl_set_input (general_->input_space_above, "");
-    } else if (ob == general_->choice_space_below) {
-       if (fl_get_choice (general_->choice_space_below) != 7)
-           fl_set_input (general_->input_space_below, "");
-    }
+
+    if (fl_get_choice (general_->choice_space_above) != 7)
+        fl_set_input (general_->input_space_above, "");
+
+    if (fl_get_choice (general_->choice_space_below) != 7)
+        fl_set_input (general_->input_space_below, "");
+
     //
     // then the extra form
     //
-    else if (ob == extra_->radio_pextra_indent) {
+    if (ob == extra_->radio_pextra_indent) {
        int n = fl_get_button(extra_->radio_pextra_indent);
        if (n) {
            fl_set_button(extra_->radio_pextra_minipage, 0);
@@ -640,32 +651,28 @@ bool FormParagraph::input(FL_OBJECT * ob, long)
     // first the general form
     //
     string input = fl_get_input (general_->input_space_above);
+    bool invalid = false;
        
-    if (input.empty()) {
-       fl_set_choice (general_->choice_space_above, 1);
-    } else if (isValidGlueLength (input)) {
-       fl_set_choice (general_->choice_space_above, 7);
-    } else {
-       fl_set_choice (general_->choice_space_above, 7);
-       fl_set_object_label(dialog_->text_warning,
-                   _("Warning: Invalid Length (valid example: 10mm)"));
-       fl_show_object(dialog_->text_warning);
-       ret = false;
-    }
-    
+    if (fl_get_choice(general_->choice_space_above)==7)
+        invalid = !input.empty() && !isValidGlueLength(input);
+
     input = fl_get_input (general_->input_space_below);
-       
-    if (input.empty()) {
-       fl_set_choice (general_->choice_space_below, 1);
-    } else if (isValidGlueLength(input)) {
-       fl_set_choice (general_->choice_space_below, 7);
-    } else {
-       fl_set_choice (general_->choice_space_below, 7);
-       fl_set_object_label(dialog_->text_warning,
-                   _("Warning: Invalid Length (valid example: 10mm)"));
-       fl_show_object(dialog_->text_warning);
-       ret = false;
+
+    if (fl_get_choice(general_->choice_space_below)==7)
+        invalid = invalid || (!input.empty() && !isValidGlueLength(input));
+    
+    if (ob == general_->input_space_above || ob == general_->input_space_below) {
+        if (invalid) {
+            fl_set_object_label(dialog_->text_warning,
+                _("Warning: Invalid Length (valid example: 10mm)"));
+            fl_show_object(dialog_->text_warning);
+            return false;
+        } else {
+            fl_hide_object(dialog_->text_warning);
+            return true;
+        }
     }
+
     //
     // then the extra form
     //