]> git.lyx.org Git - features.git/commitdiff
create and use a little setEnabled() xforms wrapper function.
authorAngus Leeming <leeming@lyx.org>
Mon, 5 Mar 2001 19:02:40 +0000 (19:02 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 5 Mar 2001 19:02:40 +0000 (19:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1676 a592a061-630c-0410-9148-cb99ea01b6c8

40 files changed:
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormBase.h
src/frontends/xforms/FormBibitem.h
src/frontends/xforms/FormBibtex.h
src/frontends/xforms/FormBrowser.h
src/frontends/xforms/FormCharacter.h
src/frontends/xforms/FormCitation.C
src/frontends/xforms/FormCitation.h
src/frontends/xforms/FormCopyright.C
src/frontends/xforms/FormCopyright.h
src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormDocument.h
src/frontends/xforms/FormError.h
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormGraphics.h
src/frontends/xforms/FormInclude.C
src/frontends/xforms/FormInclude.h
src/frontends/xforms/FormIndex.h
src/frontends/xforms/FormParagraph.C
src/frontends/xforms/FormParagraph.h
src/frontends/xforms/FormPreamble.C
src/frontends/xforms/FormPreamble.h
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/FormPreferences.h
src/frontends/xforms/FormPrint.C
src/frontends/xforms/FormPrint.h
src/frontends/xforms/FormRef.C
src/frontends/xforms/FormRef.h
src/frontends/xforms/FormSplash.C
src/frontends/xforms/FormSplash.h
src/frontends/xforms/FormTabular.C
src/frontends/xforms/FormTabular.h
src/frontends/xforms/FormTabularCreate.h
src/frontends/xforms/FormToc.h
src/frontends/xforms/FormUrl.h
src/frontends/xforms/Makefile.am
src/frontends/xforms/xform_helpers.C [deleted file]
src/frontends/xforms/xform_helpers.h [deleted file]
src/frontends/xforms/xforms_helpers.C [new file with mode: 0644]
src/frontends/xforms/xforms_helpers.h [new file with mode: 0644]

index 9baa2e5e424a4834b0ebe54ed6630cdc06ebe9e8..97d04907f8e646ace1d9c6f7e59124d40452d53f 100644 (file)
@@ -1,3 +1,27 @@
+2001-03-05  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * xform_helpers.[Ch]: renamed as xforms_helpers.[Ch].
+
+       * various: in a rush of delayed guilt, I've renamed all instances of
+       xform as xforms. Jean-Marc sowed this seed a long, long time ago and it
+       finally sprouted.
+
+       * xforms_helpers.[Ch] (setEnabled): a little wrapper function to
+       activate/deactivate an FL_OBJECT.
+
+       * FormCitation.C:
+       * FormDocument.C:
+       * FormInclude.C:
+       * FormParagraph.C:
+       * FormPreamble.C:
+       * FormPreferences.C:
+       * FormRef.C:
+       * FormTabular.C: used it.
+
+2001-03-05  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormPreferences.C: removed three unused using directives.
+
 2001-02-27  Dekel Tsur  <dekelts@tau.ac.il>
 
        * FormRef.C: Fixed the behaviour of Goto-Ref.
index 1cf0f693b1531b3836b376cac5136841247370b0..a9dff0d80d532187295a6a0e452130d7dadbc95d 100644 (file)
@@ -56,7 +56,7 @@ protected: // methods
        virtual ~FormBase();
 
        /** Redraw the form (on receipt of a Signal indicating, for example,
-           that the xform colors have been re-mapped).
+           that the xforms colors have been re-mapped).
            Must be virtual because dialogs with tabbed folders will need to
            redraw the form for each tab.
        */
@@ -95,7 +95,7 @@ protected: // methods
        virtual void restore() {
                update();
        }
-       /// Pointer to the actual instantiation of xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const = 0;
 
        /** Which LyXFunc do we use?
index 14c9dbfecc3ba3b384e5445452ea476aaefd1778..2627beeeb9c9758e22581553ba3521a898344b9c 100644 (file)
@@ -37,7 +37,7 @@ private:
        virtual bool input(FL_OBJECT *,long);
        /// Apply from dialog (modify or create inset)
        virtual void apply();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        ///
        FD_form_bibitem * build_bibitem();
index b5ec1a4b17ee2a783995eb998b553ce95a4f259c..c3402992f5bcf227a6683a298fc257373546cada 100644 (file)
@@ -37,7 +37,7 @@ private:
        virtual bool input(FL_OBJECT *, long);
        /// Apply from dialog (modify or create inset)
        virtual void apply();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        ///
        FD_form_bibtex * build_bibtex();
index 5adda12759933bf7a98c93e881972119f00e3a9e..7749ce822d6d54661ad4b2001b510539376f8434 100644 (file)
@@ -36,7 +36,7 @@ protected:
        FD_form_browser * dialog_;
 
 private:
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        /// Filter the inputs on callback from xforms
        virtual bool input(FL_OBJECT *, long);
index 2f5317f8acdfa0caa99348ff7e7a2308968c77f7..17ee3ad3aa2fa3582a353fba90b689a23b90826e 100644 (file)
@@ -45,7 +45,7 @@ private:
    /// Update the popup.
    virtual void update();
    
-   /// Pointer to the actual instantiation of the xform's form
+   /// Pointer to the actual instantiation of the xforms form
    virtual FL_FORM * form() const;
 
    FD_form_character * build_character();
index 7da7f348e0707cf51eebf39849ae484fc3cf65df..b56a3e30f82f94d4b0d97254da9338d8e8c5f3e0 100644 (file)
@@ -24,6 +24,7 @@
 #include "form_citation.h"
 #include "lyxfunc.h"
 #include "support/filetools.h"
+#include "xforms_helpers.h"
 
 using std::find;
 using std::max;
@@ -164,65 +165,22 @@ void FormCitation::updateBrowser(FL_OBJECT * browser,
 
 void FormCitation::setBibButtons(State status) const
 {
-       switch (status) {
-       case ON:
-               fl_activate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_BLACK);
-               break;
-
-       case OFF:
-               fl_deactivate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-               break;
-
-       default:
-               break;
-       }
+       setEnabled(dialog_->button_add, (status == ON));
 }
 
 
 void FormCitation::setCiteButtons(State status) const
 {
-       switch (status) {
-       case ON:
-        {
-               fl_activate_object(dialog_->button_del);
-               fl_set_object_lcol(dialog_->button_del, FL_BLACK);
-
-               int sel = fl_get_browser(dialog_->browser_cite);
-
-               if (sel != 1) {
-                       fl_activate_object(dialog_->button_up);
-                       fl_set_object_lcol(dialog_->button_up, FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->button_up);
-                       fl_set_object_lcol(dialog_->button_up, FL_INACTIVE);
-               }
-
-               if (sel != fl_get_browser_maxline(dialog_->browser_cite)) {
-                       fl_activate_object(dialog_->button_down);
-                       fl_set_object_lcol(dialog_->button_down, FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->button_down);
-                       fl_set_object_lcol(dialog_->button_down, FL_INACTIVE);
-               }
+       int const sel     = fl_get_browser(dialog_->browser_cite);
+       int const maxline = fl_get_browser_maxline(dialog_->browser_cite);
 
-               break;
-       }
-       case OFF:
-       {
-               fl_deactivate_object(dialog_->button_del);
-               fl_set_object_lcol(dialog_->button_del, FL_INACTIVE);
-
-               fl_deactivate_object(dialog_->button_up);
-               fl_set_object_lcol(dialog_->button_up, FL_INACTIVE);
+       bool const activate      = (status == ON);
+       bool const activate_up   = (activate && sel != 1);
+       bool const activate_down = (activate && sel != maxline);
 
-               fl_deactivate_object(dialog_->button_down);
-               fl_set_object_lcol(dialog_->button_down, FL_INACTIVE);
-       }
-       default:
-               break;
-       }
+       setEnabled(dialog_->button_del,  activate);
+       setEnabled(dialog_->button_up,   activate_up);
+       setEnabled(dialog_->button_down, activate_down);
 }
 
 
index 5319520f0997260ddcd3b263da09c1b3e892a476..48e176eca00a632b9521feffb05edf4d6b5fa7d7 100644 (file)
@@ -47,7 +47,7 @@ private:
        virtual void update();
        /// Apply from dialog (modify or create inset)
        virtual void apply();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
 
        ///
index 5a2a97d18b5d9a62f0ffb17567d9e42e1c1049bc..1018c9a80d97dd71ef2c4159c1d078909d192623 100644 (file)
@@ -14,7 +14,7 @@
 #include "LyXView.h"
 #include "form_copyright.h"
 #include "FormCopyright.h"
-#include "xform_helpers.h"
+#include "xforms_helpers.h"
 
 FormCopyright::FormCopyright( LyXView * lv, Dialogs * d        )
        : FormBaseBI(lv, d, _("Copyright and Warranty"), new OkCancelPolicy),
index 8a0cf83aef066c55cc52ad0ebe29d53ff7b32982..652e7798d2dbc599b642089c8788bea4f25d0903 100644 (file)
@@ -37,7 +37,7 @@ public:
 private:
        /// Build the dialog
        virtual void build();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        /// Fdesign generated method
        FD_form_copyright * build_copyright();
index c7aed5ed2024ef208f2fe7803a9bf79dc38a5b4f..7461145e69227025243a7973e784757a0d6aa4bf 100644 (file)
@@ -37,6 +37,7 @@
 #include "Liason.h"
 #include "CutAndPaste.h"
 #include "bufferview_funcs.h"
+#include "xforms_helpers.h" 
 
 #ifdef CXX_WORKING_NAMESPACES
 using Liason::setMinibuffer;
@@ -796,14 +797,10 @@ void FormDocument::bullets_update(BufferParams const & params)
     if (!bullets_ || ((XpmVersion<4) || (XpmVersion==4 && XpmRevision<7)))
         return;
 
-    if (lv_->buffer()->isLinuxDoc()) {
-       fl_deactivate_object(fbullet);
-       fl_set_object_lcol(fbullet, FL_INACTIVE);
-       return;
-    } else {
-       fl_activate_object(fbullet);
-       fl_set_object_lcol(fbullet, FL_BLACK);
-    }
+    bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
+    setEnabled(fbullet, !isLinuxDoc);
+
+    if (isLinuxDoc) return;
 
     fl_set_button(bullets_->radio_bullet_depth_1, 1);
     fl_set_input(bullets_->input_bullet_latex,
index 566f3acd432ea554c1b04cae4f9bf37987cac81b..2ac54e80dac006070de4b924a803ca582d864a32 100644 (file)
@@ -80,7 +80,7 @@ private:
                BULLETBMTABLE
        };
        /** Redraw the form (on receipt of a Signal indicating, for example,
-           that the xform colours have been re-mapped). */
+           that the xforms colours have been re-mapped). */
        virtual void redraw();
        /// Build the dialog
        virtual void build();
index b0b62e255bfd8c4e8deb4adc8692d713d0df7f2e..748d71a0e57763c31c7fe757bf4cb547af2fe21e 100644 (file)
@@ -39,7 +39,7 @@ private:
        virtual void update();
        /// Build the dialog
        virtual void build();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        /// Fdesign generated method
        FD_form_error * build_error();
index 48838a712d3464d73d653074cc409db423b4e1c2..d37fad399d7ce4ad0831590c0a69edf33431456f 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "support/lstrings.h"  // for strToDbl & tostr
 #include "support/FileInfo.h"  // for FileInfo
-#include "xform_helpers.h"     // for browseFile
+#include "xforms_helpers.h"     // for browseFile
 #include "support/filetools.h" // for AddName
 #include "insets/insetgraphics.h"
 #include "insets/insetgraphicsParams.h"
index 6c42fbbab810c57cd9d884bdd1a6eb8d0065abc5..f0946bc187626d6c419abbb3e809d918d0e48e24 100644 (file)
@@ -91,7 +91,7 @@ private:
        /// Open the file browse dialog to select an image file.
        void browse();
 
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        /// Fdesign generated method
        FD_form_graphics * build_graphics();
index bf9608ccaf6c26879b15dd421cf2148d0e948f92..8abf18ccf8569465652d114509004b2fdbb8186b 100644 (file)
@@ -24,6 +24,7 @@
 #include "buffer.h"
 #include "lyxrc.h" 
 #include "lyxfunc.h" 
+#include "xforms_helpers.h" 
  
 #include "form_include.h"
 
@@ -198,15 +199,13 @@ bool FormInclude::input(FL_OBJECT *, long data)
                        break;
 
                case VERBATIM:
-                       fl_activate_object(dialog_->flag41);
-                       fl_set_object_lcol(dialog_->flag41, FL_BLACK); 
+                       setEnabled(dialog_->flag41, true);
                        break;
         
                case INPUTINCLUDE:
                        cout << "inputinclude" << endl;
                        /* huh ? why doesn't this work ? */ 
-                       fl_deactivate_object(dialog_->flag41);
-                       fl_set_object_lcol(dialog_->flag41, FL_INACTIVE);
+                       setEnabled(dialog_->flag41, false);
                        fl_set_button(dialog_->flag41, 0);
                        break;
        }
index 1e8f744638fdb6d86f66199581bc4881e618c11d..8959a602e69366ac356540cdeeb08cf0e886027e 100644 (file)
@@ -48,7 +48,7 @@ private:
        virtual void update();
        /// Apply from dialog (modify or create inset)
        virtual void apply();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
 
        /// Type definition from the fdesign produced header file.
index 6714b1d06ff06ef80fafb1f6e2fcd6ae67b55cb2..698802d7292c723cc11f3c3ce666b18a0f81cebc 100644 (file)
@@ -36,7 +36,7 @@ private:
        virtual void update();
        /// Apply from dialog (modify or create inset)
        virtual void apply();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        ///
        FD_form_index * build_index();
index 98072f13aa76772e2b9e5e4029a77788b957b7c8..9d2eb01028c751abebd3c73096961a84c42612ec 100644 (file)
@@ -24,6 +24,7 @@
 #include "LyXView.h"
 #include "buffer.h"
 #include "lyxtext.h"
+#include "xforms_helpers.h"
 
 #ifdef CXX_WORKING_NAMESPACES
 using Liason::setMinibuffer;
@@ -441,19 +442,17 @@ void FormParagraph::general_update()
                   added_space_bottom.keep());
     fl_set_button(general_->check_noindent,
                  text->cursor.par()->FirstPhysicalPar()->noindent);
-    if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
-       fl_set_button(general_->check_pagebreaks_top, 0);
-       fl_deactivate_object(general_->check_pagebreaks_top);
-       fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
-       fl_set_button(general_->check_pagebreaks_bottom, 0);
-       fl_deactivate_object(general_->check_pagebreaks_bottom);
-       fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
-    } else {
-       fl_activate_object(general_->check_pagebreaks_top);
-       fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
-       fl_activate_object(general_->check_pagebreaks_bottom);
-       fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
+
+    bool const enable = (!text->cursor.par()->FirstPhysicalPar()->InInset());
+
+    setEnabled(general_->check_pagebreaks_top,    enable);
+    setEnabled(general_->check_pagebreaks_bottom, enable);
+    
+    if (!enable) {
+           fl_set_button(general_->check_pagebreaks_top, 0);
+           fl_set_button(general_->check_pagebreaks_bottom, 0);
     }
+
 #else
         fl_set_input(general_->input_space_below, text->cursor.par()->
                     added_space_bottom.length().asString().c_str());
@@ -474,10 +473,9 @@ void FormParagraph::extra_update()
 
     LyXParagraph * par = lv_->view()->text->cursor.par();
 
-    fl_activate_object(extra_->input_pextra_width);
-    fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
-    fl_activate_object(extra_->input_pextra_widthp);
-    fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
+    setEnabled(extra_->input_pextra_width,  true);
+    setEnabled(extra_->input_pextra_widthp, true);
+
     fl_set_input(extra_->input_pextra_width,
                 par->pextra_width.c_str());
     fl_set_input(extra_->input_pextra_widthp,
@@ -501,49 +499,35 @@ void FormParagraph::extra_update()
        fl_set_button(extra_->radio_pextra_indent, 1);
        fl_set_button(extra_->radio_pextra_minipage, 0);
        fl_set_button(extra_->radio_pextra_floatflt, 0);
-       fl_deactivate_object(extra_->radio_pextra_top);
-       fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_middle);
-       fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_bottom);
-       fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
+       setEnabled(extra_->radio_pextra_top,    false);
+       setEnabled(extra_->radio_pextra_middle, false);
+       setEnabled(extra_->radio_pextra_bottom, false);
        input(extra_->radio_pextra_indent, 0);
     } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
        fl_set_button(extra_->radio_pextra_indent, 0);
        fl_set_button(extra_->radio_pextra_minipage, 1);
        fl_set_button(extra_->radio_pextra_floatflt, 0);
-       fl_activate_object(extra_->radio_pextra_top);
-       fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
-       fl_activate_object(extra_->radio_pextra_middle);
-       fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
-       fl_activate_object(extra_->radio_pextra_bottom);
-       fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
+       setEnabled(extra_->radio_pextra_top,    true);
+       setEnabled(extra_->radio_pextra_middle, true);
+       setEnabled(extra_->radio_pextra_bottom, true);
        input(extra_->radio_pextra_minipage, 0);
     } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
        fl_set_button(extra_->radio_pextra_indent, 0);
        fl_set_button(extra_->radio_pextra_minipage, 0);
        fl_set_button(extra_->radio_pextra_floatflt, 1);
-       fl_deactivate_object(extra_->radio_pextra_top);
-       fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_middle);
-       fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_bottom);
-       fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
+       setEnabled(extra_->radio_pextra_top,    false);
+       setEnabled(extra_->radio_pextra_middle, false);
+       setEnabled(extra_->radio_pextra_bottom, false);
        input(extra_->radio_pextra_floatflt, 0);
     } else {
        fl_set_button(extra_->radio_pextra_indent, 0);
        fl_set_button(extra_->radio_pextra_minipage, 0);
        fl_set_button(extra_->radio_pextra_floatflt, 0);
-       fl_deactivate_object(extra_->input_pextra_width);
-       fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
-       fl_deactivate_object(extra_->input_pextra_widthp);
-       fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_top);
-       fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_middle);
-       fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_bottom);
-       fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
+       setEnabled(extra_->input_pextra_width,  false);
+       setEnabled(extra_->input_pextra_widthp, false);
+       setEnabled(extra_->radio_pextra_top,    false);
+       setEnabled(extra_->radio_pextra_middle, false);
+       setEnabled(extra_->radio_pextra_bottom, false);
        input(0, 0);
     }
     fl_hide_object(dialog_->text_warning);
@@ -574,90 +558,53 @@ bool FormParagraph::input(FL_OBJECT * ob, long)
     // then the extra form
     //
     if (ob == extra_->radio_pextra_indent) {
-       int n = fl_get_button(extra_->radio_pextra_indent);
-       if (n) {
+       bool const enable = (fl_get_button(extra_->radio_pextra_indent) != 0);
+
+       if (enable) {
            fl_set_button(extra_->radio_pextra_minipage, 0);
            fl_set_button(extra_->radio_pextra_floatflt, 0);
-           fl_activate_object(extra_->input_pextra_width);
-           fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
-           fl_activate_object(extra_->input_pextra_widthp);
-           fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
-       } else {
-           fl_deactivate_object(extra_->input_pextra_width);
-           fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
-           fl_deactivate_object(extra_->input_pextra_widthp);
-           fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
        }
-       fl_deactivate_object(extra_->radio_pextra_top);
-       fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_middle);
-       fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_bottom);
-       fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
-       fl_activate_object(extra_->radio_pextra_hfill);
-       fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
-       fl_activate_object(extra_->radio_pextra_startmp);
-       fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
+
+       setEnabled(extra_->input_pextra_width,  enable);
+       setEnabled(extra_->input_pextra_widthp, enable);
+
+       setEnabled(extra_->radio_pextra_top,     false);
+       setEnabled(extra_->radio_pextra_middle,  false);
+       setEnabled(extra_->radio_pextra_bottom,  false);
+       setEnabled(extra_->radio_pextra_hfill,   false);
+       setEnabled(extra_->radio_pextra_startmp, false);
+
     } else if (ob == extra_->radio_pextra_minipage) {
-       int n = fl_get_button(extra_->radio_pextra_minipage);
-       if (n) {
+       bool const enable = (fl_get_button(extra_->radio_pextra_minipage) != 0);
+       
+       if (enable) {
            fl_set_button(extra_->radio_pextra_indent, 0);
            fl_set_button(extra_->radio_pextra_floatflt, 0);
-           fl_activate_object(extra_->input_pextra_width);
-           fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
-           fl_activate_object(extra_->input_pextra_widthp);
-           fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
-           fl_activate_object(extra_->radio_pextra_top);
-           fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
-           fl_activate_object(extra_->radio_pextra_middle);
-           fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
-           fl_activate_object(extra_->radio_pextra_bottom);
-           fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
-           fl_activate_object(extra_->radio_pextra_hfill);
-           fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
-           fl_activate_object(extra_->radio_pextra_startmp);
-           fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
-       } else {
-           fl_deactivate_object(extra_->input_pextra_width);
-           fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
-           fl_deactivate_object(extra_->input_pextra_widthp);
-           fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
-           fl_deactivate_object(extra_->radio_pextra_top);
-           fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
-           fl_deactivate_object(extra_->radio_pextra_middle);
-           fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
-           fl_deactivate_object(extra_->radio_pextra_bottom);
-           fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
-           fl_activate_object(extra_->radio_pextra_hfill);
-           fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
-           fl_activate_object(extra_->radio_pextra_startmp);
-           fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
        }
+       
+       setEnabled(extra_->input_pextra_width,   enable);
+       setEnabled(extra_->input_pextra_widthp,  enable);
+       setEnabled(extra_->radio_pextra_top,     enable);
+       setEnabled(extra_->radio_pextra_middle,  enable);
+       setEnabled(extra_->radio_pextra_bottom,  enable);
+       setEnabled(extra_->radio_pextra_hfill,   enable);
+       setEnabled(extra_->radio_pextra_startmp, enable);
     } else if (ob == extra_->radio_pextra_floatflt) {
-       int n = fl_get_button(extra_->radio_pextra_floatflt);
-       if (n) {
+       bool const enable = (fl_get_button(extra_->radio_pextra_floatflt) != 0);
+       
+       if (enable) {
            fl_set_button(extra_->radio_pextra_indent, 0);
            fl_set_button(extra_->radio_pextra_minipage, 0);
-           fl_activate_object(extra_->input_pextra_width);
-           fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
-           fl_activate_object(extra_->input_pextra_widthp);
-           fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
-       } else {
-           fl_deactivate_object(extra_->input_pextra_width);
-           fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
-           fl_deactivate_object(extra_->input_pextra_widthp);
-           fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
        }
-       fl_deactivate_object(extra_->radio_pextra_top);
-       fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_middle);
-       fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
-       fl_deactivate_object(extra_->radio_pextra_bottom);
-       fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
-       fl_activate_object(extra_->radio_pextra_hfill);
-       fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
-       fl_activate_object(extra_->radio_pextra_startmp);
-       fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
+       
+       setEnabled(extra_->input_pextra_width,  enable);
+       setEnabled(extra_->input_pextra_widthp, enable);
+
+       setEnabled(extra_->radio_pextra_top,     false);
+       setEnabled(extra_->radio_pextra_middle,  false);
+       setEnabled(extra_->radio_pextra_bottom,  false);
+       setEnabled(extra_->radio_pextra_hfill,   false);
+       setEnabled(extra_->radio_pextra_startmp, false);
     }
     
     //
@@ -695,23 +642,17 @@ bool FormParagraph::input(FL_OBJECT * ob, long)
     string s1 = fl_get_input(extra_->input_pextra_width);
     string s2 = fl_get_input(extra_->input_pextra_widthp);
     if (!n) { // no button pressed both should be deactivated now
-       fl_deactivate_object(extra_->input_pextra_width);
-       fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
-       fl_deactivate_object(extra_->input_pextra_widthp);
-       fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
+       setEnabled(extra_->input_pextra_width,  false);
+       setEnabled(extra_->input_pextra_widthp, false);
        fl_hide_object(dialog_->text_warning);
     } else if (s1.empty() && s2.empty()) {
-       fl_activate_object(extra_->input_pextra_width);
-       fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
-       fl_activate_object(extra_->input_pextra_widthp);
-       fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
+       setEnabled(extra_->input_pextra_width,  true);
+       setEnabled(extra_->input_pextra_widthp, true);
        fl_hide_object(dialog_->text_warning);
        ret = false;
     } else if (!s1.empty()) { // LyXLength parameter
-       fl_activate_object(extra_->input_pextra_width);
-       fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
-       fl_deactivate_object(extra_->input_pextra_widthp);
-       fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
+       setEnabled(extra_->input_pextra_width,  true);
+       setEnabled(extra_->input_pextra_widthp, false);
        if (!isValidLength(s1)) {
            fl_set_object_label(dialog_->text_warning,
                        _("Warning: Invalid Length (valid example: 10mm)"));
@@ -719,10 +660,8 @@ bool FormParagraph::input(FL_OBJECT * ob, long)
            ret = false;
        }
     } else { // !s2.empty() % parameter
-       fl_deactivate_object(extra_->input_pextra_width);
-       fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
-       fl_activate_object(extra_->input_pextra_widthp);
-       fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
+       setEnabled(extra_->input_pextra_width,  false);
+       setEnabled(extra_->input_pextra_widthp, true);
        if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
            ret = false;
            fl_set_object_label(dialog_->text_warning,
index c8458eb64a14d1db732945d41b0a82b742a473ba..7104131d6bad6039c64c2df4ea1a3436a1fffaef 100644 (file)
@@ -36,7 +36,7 @@ public:
 
 private:
        /** Redraw the form (on receipt of a Signal indicating, for example,
-           that the xform colours have been re-mapped). */
+           that the xforms colours have been re-mapped). */
        virtual void redraw();
        /// Build the popup
        virtual void build();
index 1075d8a77b8b372c15341f3424268cb0a38025aa..79897e4769f16f420572909e41dc7257dee12531 100644 (file)
@@ -17,6 +17,7 @@
 #include "LyXView.h"
 #include "buffer.h"
 #include "gettext.h"
+#include "xforms_helpers.h"
 
 #ifdef CXX_WORKING_NAMESPACES
 using Liason::setMinibuffer;
@@ -81,19 +82,11 @@ void FormPreamble::update()
      return;
 
    fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
-   if (lv_->buffer()->isReadonly()) {
-      fl_deactivate_object(dialog_->input_preamble);
-      fl_deactivate_object(dialog_->button_ok);
-      fl_deactivate_object(dialog_->button_apply);
-      fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE);
-      fl_set_object_lcol(dialog_->button_apply, FL_INACTIVE);
-   } else {
-      fl_activate_object(dialog_->input_preamble);
-      fl_activate_object(dialog_->button_ok);
-      fl_activate_object(dialog_->button_apply);
-      fl_set_object_lcol(dialog_->button_ok, FL_BLACK);
-      fl_set_object_lcol(dialog_->button_apply, FL_BLACK);
-   }
+
+   bool const enable = (! lv_->buffer()->isReadonly());
+   setEnabled(dialog_->input_preamble, enable);
+   setEnabled(dialog_->button_ok,      enable);
+   setEnabled(dialog_->button_apply,   enable);
    
    // need this?
    // bc_.readOnly(lv_->buffer()->isReadonly());
index ac681dedf85090750e31fa4d55bab9bfadb266c4..55ca68fe7ebef401a8adc52058c28c4ff0365c9d 100644 (file)
@@ -24,7 +24,7 @@ public:
    
 private:
    /** Redraw the form (on receipt of a Signal indicating, for example,
-    *  that the xform colours have been re-mapped). 
+    *  that the xforms colours have been re-mapped). 
     */
 
    /// Filter the inputs
index 55d351ffafffc63f873953b0280cd039f5650ff0..783abb3498462754ddba9ca2c1ec6a5f4fc4c225 100644 (file)
 #include "lyx_gui_misc.h" // idex, scex
 #include "lyxlex.h"
 #include "input_validators.h"
-#include "xform_helpers.h"
+#include "xforms_helpers.h"
 #include "converter.h"
 #include "support/lyxfunctional.h"
 #include "support/lyxmanip.h"
 
 using std::endl;
-using std::find;
-using std::find_if;
 using std::pair;
 using std::make_pair;
 using std::max;
 using std::min;
-using std::sort;
 using std::vector;
 
 extern string system_lyxdir;
@@ -155,10 +152,10 @@ void FormPreferences::ok()
 {
        FormBase::ok();
 
-       if (colors_.modifiedXformPrefs) {
+       if (colors_.modifiedXformsPrefs) {
                string const filename =
                        AddName(user_lyxdir, "preferences.xform");
-               colors_.modifiedXformPrefs = !XformColor::write(filename);
+               colors_.modifiedXformsPrefs = !XformsColor::write(filename);
        }
        
        lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
@@ -411,12 +408,12 @@ void FormPreferences::Colors::apply()
        bool modifiedText = false;
        bool modifiedBackground = false;
 
-       for (vector<XformColor>::const_iterator cit = xformColorDB.begin();
-            cit != xformColorDB.end(); ++cit) {
+       for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
+            cit != xformsColorDB.end(); ++cit) {
                RGBColor col;
                fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
                if (col != (*cit).color()) {
-                       modifiedXformPrefs = true;
+                       modifiedXformsPrefs = true;
                        if ((*cit).colorID == FL_BLACK)
                                modifiedText = true;
                        if ((*cit).colorID == FL_COL1)
@@ -424,10 +421,10 @@ void FormPreferences::Colors::apply()
                }
        }
 
-       if (modifiedXformPrefs) {
-               for (vector<XformColor>::const_iterator cit =
-                            xformColorDB.begin(); 
-                    cit != xformColorDB.end(); ++cit) {
+       if (modifiedXformsPrefs) {
+               for (vector<XformsColor>::const_iterator cit =
+                            xformsColorDB.begin(); 
+                    cit != xformsColorDB.end(); ++cit) {
                        fl_mapcolor((*cit).colorID,
                                    (*cit).r, (*cit).g, (*cit).b);
 
@@ -599,14 +596,14 @@ void FormPreferences::Colors::InputBrowserLyX() const
        // Is the choice an Xforms color...
        RGBColor col;
 
-       if( selLyX-1 < xformColorDB.size() ) {
-               vector<XformColor>::size_type const i = selLyX - 1;
-               col = xformColorDB[i].color();
+       if( selLyX-1 < xformsColorDB.size() ) {
+               vector<XformsColor>::size_type const i = selLyX - 1;
+               col = xformsColorDB[i].color();
        }
        // or a LyX Logical color?
        else {
                vector<NamedColor>::size_type const i = selLyX - 1 -
-                       xformColorDB.size();
+                       xformsColorDB.size();
                col = lyxColorDB[i].color();
        }
 
@@ -619,8 +616,7 @@ void FormPreferences::Colors::InputBrowserLyX() const
        SwitchColorSpace();
        
        // Deactivate the modify button to begin with...
-       fl_deactivate_object(dialog_->button_modify);
-       fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
+       setEnabled(dialog_->button_modify, false);
        
        fl_unfreeze_form(dialog_->form);
 }
@@ -663,24 +659,18 @@ void FormPreferences::Colors::InputHSV()
        bool modify = false;
        
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformColorDB.size() ) {
-               vector<XformColor>::size_type const i = selLyX - 1;
-               modify = (xformColorDB[i].color() != col);
+       if( selLyX-1 < xformsColorDB.size() ) {
+               vector<XformsColor>::size_type const i = selLyX - 1;
+               modify = (xformsColorDB[i].color() != col);
        }
        // or a LyX Logical color?
        else {
                vector<NamedColor>::size_type const i = selLyX - 1 -
-                       xformColorDB.size();
+                       xformsColorDB.size();
                modify = (lyxColorDB[i].color() != col);
        }
 
-       if (modify) {
-               fl_activate_object(dialog_->button_modify);
-               fl_set_object_lcol(dialog_->button_modify, FL_BLACK);
-       } else {
-               fl_deactivate_object(dialog_->button_modify);
-               fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
-       }
+       setEnabled(dialog_->button_modify, modify);
 }
 
 
@@ -710,24 +700,18 @@ void FormPreferences::Colors::InputRGB()
        bool modify = false;
        
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformColorDB.size() ) {
-               vector<XformColor>::size_type const i = selLyX - 1;
-               modify = (xformColorDB[i].color() != col);
+       if( selLyX-1 < xformsColorDB.size() ) {
+               vector<XformsColor>::size_type const i = selLyX - 1;
+               modify = (xformsColorDB[i].color() != col);
        }
        // or a LyX Logical color?
        else {
                vector<NamedColor>::size_type const i = selLyX - 1 -
-                       xformColorDB.size();
+                       xformsColorDB.size();
                modify = (lyxColorDB[i].color() != col);
        }
 
-       if (modify) {
-               fl_activate_object(dialog_->button_modify);
-               fl_set_object_lcol(dialog_->button_modify, FL_BLACK);
-       } else {
-               fl_deactivate_object(dialog_->button_modify);
-               fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
-       }
+       setEnabled(dialog_->button_modify, modify);
 }
 
 
@@ -735,15 +719,15 @@ void FormPreferences::Colors::LoadBrowserLyX()
 {
        if (!dialog_->browser_lyx_objs->visible) return;
 
-       // First, define the modifiable xform colors
-       xformColorDB.clear();
-       XformColor xcol;
+       // First, define the modifiable xforms colors
+       xformsColorDB.clear();
+       XformsColor xcol;
 
        xcol.name = _("GUI background");
        xcol.colorID = FL_COL1;
        fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
 
-       xformColorDB.push_back(xcol);
+       xformsColorDB.push_back(xcol);
 
        xcol.name = _("GUI text");
        xcol.colorID = FL_BLACK;
@@ -752,19 +736,19 @@ void FormPreferences::Colors::LoadBrowserLyX()
        fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
        fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
 
-       xformColorDB.push_back(xcol);
+       xformsColorDB.push_back(xcol);
 
        xcol.name = _("GUI selection");
        xcol.colorID = FL_YELLOW;
        fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
 
-       xformColorDB.push_back(xcol);
+       xformsColorDB.push_back(xcol);
 
        xcol.name = _("GUI pointer");
        xcol.colorID = GUI_COLOR_CURSOR;
        fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
 
-       xformColorDB.push_back(xcol);
+       xformsColorDB.push_back(xcol);
 
        // Now create the the LyX LColors database
        lyxColorDB.clear();
@@ -831,8 +815,8 @@ void FormPreferences::Colors::LoadBrowserLyX()
        FL_OBJECT * colbr = dialog_->browser_lyx_objs;
        fl_freeze_form(dialog_->form);
        fl_clear_browser(colbr);
-       for (vector<XformColor>::const_iterator cit = xformColorDB.begin();
-            cit != xformColorDB.end(); ++cit) {
+       for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
+            cit != xformsColorDB.end(); ++cit) {
                fl_addto_browser(colbr, (*cit).getname().c_str());
        }
        for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
@@ -859,26 +843,23 @@ void FormPreferences::Colors::Modify()
        fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
 
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformColorDB.size() ) {
-               vector<XformColor>::size_type const i = selLyX - 1;
-               xformColorDB[i].r  = col.r;
-               xformColorDB[i].g  = col.g;
-               xformColorDB[i].b  = col.b;
+       if( selLyX-1 < xformsColorDB.size() ) {
+               vector<XformsColor>::size_type const i = selLyX - 1;
+               xformsColorDB[i].r  = col.r;
+               xformsColorDB[i].g  = col.g;
+               xformsColorDB[i].b  = col.b;
        }
        // or a LyX Logical color?
        else {
                vector<NamedColor>::size_type const i = selLyX - 1 -
-                       xformColorDB.size();
+                       xformsColorDB.size();
                lyxColorDB[i].r  = col.r;
                lyxColorDB[i].g  = col.g;
                lyxColorDB[i].b  = col.b;
        }
 
        fl_freeze_form(dialog_->form);
-
-       fl_deactivate_object(dialog_->button_modify);
-       fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
-       
+       setEnabled(dialog_->button_modify, false);      
        fl_unfreeze_form(dialog_->form);
 }
 
@@ -1083,8 +1064,7 @@ bool FormPreferences::Converters::Add()
                local_converters.UpdateLast(local_formats);
                UpdateBrowser();
        }
-       fl_deactivate_object(dialog_->button_add);
-       fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
+       setEnabled(dialog_->button_add, false);
 
        return true;
 }
@@ -1113,11 +1093,8 @@ bool FormPreferences::Converters::Browser()
        fl_set_button_shortcut(dialog_->button_add,
                                scex(_("Modify|#M")), 1);
 
-       fl_deactivate_object(dialog_->button_add);
-       fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-
-       fl_activate_object(dialog_->button_delete);
-       fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+       setEnabled(dialog_->button_add,    false);
+       setEnabled(dialog_->button_delete, true);
                                
        fl_unfreeze_form(dialog_->form);
        return false;
@@ -1150,9 +1127,7 @@ bool FormPreferences::Converters::Input()
                                        scex(_("Add|#A")), 1);
 
                fl_deselect_browser(dialog_->browser_all);
-
-               fl_deactivate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+               setEnabled(dialog_->button_delete, false);
 
        } else {
                fl_set_object_label(dialog_->button_add,
@@ -1163,19 +1138,12 @@ bool FormPreferences::Converters::Input()
                int top = max(sel-5, 0);
                fl_set_browser_topline(dialog_->browser_all, top);
                fl_select_browser_line(dialog_->browser_all, sel+1);
-               
-               fl_activate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+               setEnabled(dialog_->button_delete, true);
        }
 
        string const command = fl_get_input(dialog_->input_converter);
-       if (command.empty() || from == to) {
-               fl_deactivate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-       } else {
-               fl_activate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_BLACK);
-       }
+       bool const enable = !(command.empty() || from == to);
+       setEnabled(dialog_->button_add, enable);
 
        fl_unfreeze_form(dialog_->form);
        return false;
@@ -1367,8 +1335,7 @@ bool FormPreferences::Formats::Add()
                if (old)
                        parent_.converters_.UpdateBrowser();
        }
-       fl_deactivate_object(dialog_->button_add);
-       fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
+       setEnabled(dialog_->button_add, false);
 
        return true;
 }
@@ -1392,11 +1359,8 @@ bool FormPreferences::Formats::Browser()
        fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
        fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
 
-       fl_deactivate_object(dialog_->button_add);
-       fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-
-       fl_activate_object(dialog_->button_delete);
-       fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+       setEnabled(dialog_->button_add,    false);
+       setEnabled(dialog_->button_delete, true);
                                
        fl_unfreeze_form(dialog_->form);
        return false;
@@ -1409,8 +1373,7 @@ bool FormPreferences::Formats::Delete()
 
        if (local_converters.FormatIsUsed(name)) {
                parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
-               fl_deactivate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+               setEnabled(dialog_->button_delete, false);
                return false;
        }
 
@@ -1433,9 +1396,7 @@ bool FormPreferences::Formats::Input()
                                        scex(_("Add|#A")), 1);
 
                fl_deselect_browser(dialog_->browser_all);
-
-               fl_deactivate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+               setEnabled(dialog_->button_delete, false);
 
        } else {
                fl_set_object_label(dialog_->button_add,
@@ -1446,22 +1407,14 @@ bool FormPreferences::Formats::Input()
                int const top = max(sel-5, 0);
                fl_set_browser_topline(dialog_->browser_all, top);
                fl_select_browser_line(dialog_->browser_all, sel+1);
-               
-               fl_activate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_BLACK);
 
-               fl_activate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+               setEnabled(dialog_->button_add, true);
+               setEnabled(dialog_->button_delete, true);
        }
 
        string const prettyname = fl_get_input(dialog_->input_gui_name);
-       if (name.empty() || prettyname.empty()) {
-               fl_deactivate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-       } else {
-               fl_activate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_BLACK);
-       }
+       bool const enable = !(name.empty() || prettyname.empty());
+       setEnabled(dialog_->button_add, enable);
 
        fl_unfreeze_form(dialog_->form);
        return false;
@@ -1774,35 +1727,11 @@ bool FormPreferences::Language::input(FL_OBJECT const * const ob)
        // objects,
        // otherwise the function is called by an xforms CB via input().
        if (!ob || ob == dialog_->check_use_kbmap) {
-               if (fl_get_button(dialog_->check_use_kbmap)) {
-                       fl_activate_object(dialog_->button_kbmap1_browse);
-                       fl_set_object_lcol(dialog_->button_kbmap1_browse,
-                                          FL_BLACK);
-
-                       fl_activate_object(dialog_->button_kbmap2_browse);
-                       fl_set_object_lcol(dialog_->button_kbmap2_browse,
-                                          FL_BLACK);
-
-                       fl_activate_object(dialog_->input_kbmap1);
-                       fl_set_object_lcol(dialog_->input_kbmap1, FL_BLACK);
-                       fl_activate_object(dialog_->input_kbmap2);
-                       fl_set_object_lcol(dialog_->input_kbmap2, FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->button_kbmap1_browse);
-                       fl_set_object_lcol(dialog_->button_kbmap1_browse,
-                                          FL_INACTIVE);
-
-                       fl_deactivate_object(dialog_->button_kbmap2_browse);
-                       fl_set_object_lcol(dialog_->button_kbmap2_browse,
-                                          FL_INACTIVE);
-
-                       fl_deactivate_object(dialog_->input_kbmap1);
-                       fl_set_object_lcol(dialog_->input_kbmap1,
-                                          FL_INACTIVE);
-                       fl_deactivate_object(dialog_->input_kbmap2);
-                       fl_set_object_lcol(dialog_->input_kbmap2,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_use_kbmap);
+               setEnabled(dialog_->button_kbmap1_browse, enable);
+               setEnabled(dialog_->button_kbmap2_browse, enable);
+               setEnabled(dialog_->input_kbmap1, enable);
+               setEnabled(dialog_->input_kbmap2, enable);
        }
 
        if (ob == dialog_->button_kbmap1_browse) {
@@ -2148,39 +2077,18 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
        // objects,
        // otherwise the function is called by an xforms CB via input().
        if (!ob || ob == dialog_->check_use_temp_dir) {
-               if (fl_get_button(dialog_->check_use_temp_dir)) {
-                       fl_activate_object(dialog_->input_temp_dir);
-                       fl_set_object_lcol(dialog_->input_temp_dir,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_temp_dir);
-                       fl_set_object_lcol(dialog_->input_temp_dir,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_use_temp_dir);
+               setEnabled(dialog_->input_temp_dir, enable);
        }
 
        if (!ob || ob == dialog_->check_last_files) {
-               if (fl_get_button(dialog_->check_last_files)) {
-                       fl_activate_object(dialog_->input_lastfiles);
-                       fl_set_object_lcol(dialog_->input_lastfiles,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_lastfiles);
-                       fl_set_object_lcol(dialog_->input_lastfiles,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_last_files);
+               setEnabled(dialog_->input_lastfiles, enable);
        }
 
        if (!ob || ob == dialog_->check_make_backups) {
-               if (fl_get_button(dialog_->check_make_backups)) {
-                       fl_activate_object(dialog_->input_backup_path);
-                       fl_set_object_lcol(dialog_->input_backup_path,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_backup_path);
-                       fl_set_object_lcol(dialog_->input_backup_path,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_make_backups);
+               setEnabled(dialog_->input_backup_path, enable);
        }
 
        if (!ob || ob == dialog_->input_default_path) {
@@ -2931,39 +2839,18 @@ bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
        }
 
        if (!ob || ob == dialog_->check_alt_lang) {
-               if (fl_get_button(dialog_->check_alt_lang)) {
-                       fl_activate_object(dialog_->input_alt_lang);
-                       fl_set_object_lcol(dialog_->input_alt_lang,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_alt_lang);
-                       fl_set_object_lcol(dialog_->input_alt_lang,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_alt_lang);
+               setEnabled(dialog_->input_alt_lang, enable);
        }
 
        if (!ob || ob == dialog_->check_escape_chars) {
-               if (fl_get_button(dialog_->check_escape_chars)) {
-                       fl_activate_object(dialog_->input_escape_chars);
-                       fl_set_object_lcol(dialog_->input_escape_chars,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_escape_chars);
-                       fl_set_object_lcol(dialog_->input_escape_chars,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_escape_chars);
+               setEnabled(dialog_->input_escape_chars, enable);
        }
 
        if (!ob || ob == dialog_->check_personal_dict) {
-               if (fl_get_button(dialog_->check_personal_dict)) {
-                       fl_activate_object(dialog_->input_personal_dict);
-                       fl_set_object_lcol(dialog_->input_personal_dict,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_personal_dict);
-                       fl_set_object_lcol(dialog_->input_personal_dict,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_personal_dict);
+               setEnabled(dialog_->input_personal_dict, enable);
        }
 
        if (ob == dialog_->button_personal_dict) {
index 928f826f0e426ba9e1dacba0b88fd8459ce0df73..da1ea04e0f0de400df4f75c5203f3f88c96b69ec 100644 (file)
@@ -24,7 +24,7 @@
 #include <utility> // pair
 #include "FormBase.h"
 #include "Color.h" // NamedColor
-#include "xform_helpers.h" // XformColor
+#include "xforms_helpers.h" // XformsColor
 
 class Combox;
 class Dialogs;
@@ -65,7 +65,7 @@ private:
        /// Disconnect signals. Also perform any necessary housekeeping.
        virtual void disconnect();
        /** Redraw the form (on receipt of a Signal indicating, for example,
-           that the xform colours have been re-mapped). */
+           that the xforms colours have been re-mapped). */
        virtual void redraw();
        /// Update the dialog.
        virtual void update();
@@ -79,7 +79,7 @@ private:
        virtual bool input(FL_OBJECT *, long);
        /// Build the dialog
        virtual void build();
-       /// Pointer to the actual instantiation of xform's form.
+       /// Pointer to the actual instantiation of the xforms form.
        virtual FL_FORM * form() const;
        /// control which feedback message is output
        void feedback(FL_OBJECT *);
@@ -91,7 +91,7 @@ private:
        /// Print a warning message and set warning flag.
        void printWarning( string const & );
        /** Launch a file dialog and modify input if it returns a new file.
-           For an explanation of the various parameters, see xform_helpers.h.
+           For an explanation of the various parameters, see xforms_helpers.h.
         */
        void browse( FL_OBJECT * input,
                     string const & title, string const & pattern, 
@@ -162,7 +162,7 @@ private:
                ///
                FD_form_colors const * dialog() { return dialog_; }
                ///
-               void apply(); // not const as modifies modifiedXformPrefs.
+               void apply(); // not const as modifies modifiedXformsPrefs.
                ///
                void build();
                ///
@@ -173,7 +173,7 @@ private:
                void update() { LoadBrowserLyX(); }
                
                /// Flag whether Xforms colors have changed since last file save
-               bool modifiedXformPrefs;
+               bool modifiedXformsPrefs;
 
        private:
                ///
@@ -200,8 +200,8 @@ private:
 
                /// A vector of LyX LColor GUI name and associated RGB color.
                std::vector<NamedColor> lyxColorDB;
-               /// A vector of xform color ID, RGB colors and associated name.
-               std::vector<XformColor> xformColorDB;
+               /// A vector of xforms color ID, RGB colors and associated name.
+               std::vector<XformsColor> xformsColorDB;
        };
        ///
        friend class Colors;
index 884e544edbbbc645d80185a8adfd26f66a4270a6..e7881bc39da69a51ef462bdf183a8bfa31324e8e 100644 (file)
@@ -22,7 +22,7 @@
 #include "debug.h"
 #include "BufferView.h"
 #include "lyx_gui_misc.h"      // WriteAlert
-#include "xform_helpers.h"     // for browseFile
+#include "xforms_helpers.h"     // for browseFile
 
 #ifdef SIGC_CXX_NAMESPACES
 using SigC::slot;
index 5357913feb6f3b0f51f3bc16b32c195f30bbe2bc..aee8d8c6bdf00ed45035823cbd3340226dba2e34 100644 (file)
@@ -45,7 +45,7 @@ private:
        virtual void apply();
        /// Filter the inputs
        virtual bool input(FL_OBJECT *, long);
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        /// Build the dialog
        virtual void build();
index 3e079088c65b37e2b41e71bb45126772dc86bae8..bf8fd574c0506de21d3c6bedfc958e8c9d2e4d97 100644 (file)
 
 #include <config.h>
 
+#include <algorithm>
 #include FORMS_H_LOCATION
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-
 #include "Dialogs.h"
 #include "FormRef.h"
 #include "LyXView.h"
@@ -25,8 +25,7 @@
 #include "form_ref.h"
 #include "lyxfunc.h"
 #include "insets/insetref.h"
-
-#include <algorithm>
+#include "xforms_helpers.h"
 
 using std::find;
 using std::max;
@@ -110,17 +109,13 @@ void FormRef::update()
        // Name is irrelevant to LaTeX/Literate documents, while
        // type is irrelevant to LinuxDoc/DocBook.
        if (lv_->buffer()->isLatex() || lv_->buffer()->isLatex()) {
-               fl_deactivate_object(dialog_->name);
-               fl_set_object_lcol(dialog_->name, FL_INACTIVE);
-               fl_activate_object(dialog_->type);
-               fl_set_object_lcol(dialog_->type, FL_BLACK);
+               setEnabled(dialog_->name, false);
+               setEnabled(dialog_->type, true);
        } else {
                fl_set_choice(dialog_->type, 1);
 
-               fl_activate_object(dialog_->name);
-               fl_set_object_lcol(dialog_->name, FL_BLACK);
-               fl_deactivate_object(dialog_->type);
-               fl_set_object_lcol(dialog_->type, FL_INACTIVE);
+               setEnabled(dialog_->name, true);
+               setEnabled(dialog_->type, false);
        }
 
        refs = lv_->buffer()->getLabelList();
@@ -144,17 +139,14 @@ void FormRef::updateBrowser(vector<string> const & akeys) const
        if (keys.empty()) {
                fl_add_browser_line(dialog_->browser,
                                    _("*** No labels found in document ***"));
+       
+               setEnabled(dialog_->browser, false);
+               setEnabled(dialog_->sort,    false);
 
-               fl_deactivate_object(dialog_->browser);
-               fl_deactivate_object(dialog_->sort);
-               fl_set_object_lcol(dialog_->browser, FL_INACTIVE);
-               fl_set_object_lcol(dialog_->sort, FL_INACTIVE);
                fl_set_input(dialog_->ref, "");
        } else {
-               fl_activate_object(dialog_->browser);
-               fl_set_object_lcol(dialog_->browser, FL_BLACK);
-               fl_activate_object(dialog_->sort);
-               fl_set_object_lcol(dialog_->sort, FL_BLACK);
+               setEnabled(dialog_->browser, true);
+               setEnabled(dialog_->sort,    true);
 
                string ref = fl_get_input(dialog_->ref);
                vector<string>::const_iterator cit =
@@ -237,10 +229,8 @@ bool FormRef::input(FL_OBJECT *, long data)
                at_ref = false;
                fl_set_object_label(dialog_->button_go, _("Goto reference"));
 
-               fl_activate_object(dialog_->type);
-               fl_set_object_lcol(dialog_->type, FL_BLACK);
-               fl_activate_object(dialog_->button_go);
-               fl_set_object_lcol(dialog_->button_go, FL_BLACK);
+               setEnabled(dialog_->type,      true);
+               setEnabled(dialog_->button_go, true);
                fl_set_object_lcol(dialog_->ref, FL_BLACK);
        }
        break;
index 4716b9610d5bdfa5fc19068ef4d59e041e5fe19f..e899ee92dc3100bbbbae6a9583b075e9e7954e8d 100644 (file)
@@ -40,7 +40,7 @@ private:
        virtual void update();
        /// Not used but must be instantiated
        virtual void apply();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
 
        ///
index 3700d1efd3e3a2773fca0ad7e0800a5efea69483..e99305a92dff250d2ed77aeb73afdf3d9c79910d 100644 (file)
@@ -19,7 +19,7 @@
 #include "LyXView.h"
 #include "form_splash.h"
 #include "FormSplash.h"
-#include "xform_helpers.h"
+#include "xforms_helpers.h"
 #include "version.h"
 #include "support/filetools.h"
 #include "lyxrc.h"
index 162eb757165618efec55c15a0befcb4bdb0813f6..90acad81391670473c5444e0a8c7aad268efb23e 100644 (file)
@@ -34,7 +34,7 @@ private:
        virtual void show(); 
        /// Build the dialog
        virtual void build();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        /// Fdesign generated method
        FD_form_splash * build_splash();
index fa7a051ed3c5b35359ec6a2890e1ce665c3a106f..ba3dba511310045e175eb8d50f93343337506277 100644 (file)
@@ -20,6 +20,7 @@
 #include "Dialogs.h"
 #include "insets/insettabular.h"
 #include "buffer.h"
+#include "xforms_helpers.h"
 
 
 FormTabular::FormTabular(LyXView * lv, Dialogs * d)
@@ -166,20 +167,16 @@ void FormTabular::update()
                fl_set_button(cell_options_->radio_multicolumn, 1);
                fl_set_button(cell_options_->radio_border_top,
                              tabular->TopLine(cell)?1:0);
-               fl_activate_object(cell_options_->radio_border_top);
-               fl_set_object_lcol(cell_options_->radio_border_top, FL_BLACK);
+               setEnabled(cell_options_->radio_border_top, true);
                fl_set_button(cell_options_->radio_border_bottom,
                              tabular->BottomLine(cell)?1:0);
-               fl_activate_object(cell_options_->radio_border_bottom);
-               fl_set_object_lcol(cell_options_->radio_border_bottom, FL_BLACK);
+               setEnabled(cell_options_->radio_border_bottom, true);
                fl_set_button(cell_options_->radio_border_left,
                              tabular->LeftLine(cell)?1:0);
-               fl_activate_object(cell_options_->radio_border_left);
-               fl_set_object_lcol(cell_options_->radio_border_left, FL_BLACK);
+               setEnabled(cell_options_->radio_border_left, true);
                fl_set_button(cell_options_->radio_border_right,
                              tabular->RightLine(cell)?1:0);
-               fl_activate_object(cell_options_->radio_border_right);
-               fl_set_object_lcol(cell_options_->radio_border_right, FL_BLACK);
+               setEnabled(cell_options_->radio_border_right, true);
                pwidth = tabular->GetMColumnPWidth(cell);
                align = tabular->GetAlignment(cell);
                if (!pwidth.empty() || (align == LYX_ALIGN_LEFT))
@@ -188,12 +185,9 @@ void FormTabular::update()
                        fl_set_button(cell_options_->radio_align_right, 1);
                else
                        fl_set_button(cell_options_->radio_align_center, 1);
-               fl_activate_object(cell_options_->radio_align_left);
-               fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK);
-               fl_activate_object(cell_options_->radio_align_right);
-               fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK);
-               fl_activate_object(cell_options_->radio_align_center);
-               fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK);
+               setEnabled(cell_options_->radio_align_left,   true);
+               setEnabled(cell_options_->radio_align_right,  true);
+               setEnabled(cell_options_->radio_align_center, true);
                align = tabular->GetVAlignment(cell);
                fl_set_button(cell_options_->radio_valign_top, 0);
                fl_set_button(cell_options_->radio_valign_bottom, 0);
@@ -204,87 +198,62 @@ void FormTabular::update()
                        fl_set_button(cell_options_->radio_valign_bottom, 1);
                else
                        fl_set_button(cell_options_->radio_valign_top, 1);
-               fl_activate_object(cell_options_->radio_valign_top);
-               fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK);
-               fl_activate_object(cell_options_->radio_valign_bottom);
-               fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK);
-               fl_activate_object(cell_options_->radio_valign_center);
-               fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK);
+               setEnabled(cell_options_->radio_valign_top,    true);
+               setEnabled(cell_options_->radio_valign_bottom, true);
+               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());
                if (!lv_->buffer()->isReadonly()) {
-                       fl_activate_object(cell_options_->input_special_multialign);
-                       fl_set_object_lcol(cell_options_->input_special_multialign,
-                                          FL_BLACK);
-                       fl_activate_object(cell_options_->input_mcolumn_width);
-                       fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_BLACK);
-               }
-               if (!pwidth.empty()) {
-                       fl_deactivate_object(cell_options_->radio_align_left);
-                       fl_deactivate_object(cell_options_->radio_align_right);
-                       fl_deactivate_object(cell_options_->radio_align_center);
-                       fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE);
-                       fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE);
-                       fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE);
-                       fl_activate_object(cell_options_->radio_valign_top);
-                       fl_activate_object(cell_options_->radio_valign_bottom);
-                       fl_activate_object(cell_options_->radio_valign_center);
-                       fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK);
-                       fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK);
-                       fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK);
-               } else {
-                       fl_activate_object(cell_options_->radio_align_left);
-                       fl_activate_object(cell_options_->radio_align_right);
-                       fl_activate_object(cell_options_->radio_align_center);
-                       fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK);
-                       fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK);
-                       fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK);
-                       fl_deactivate_object(cell_options_->radio_valign_top);
-                       fl_deactivate_object(cell_options_->radio_valign_bottom);
-                       fl_deactivate_object(cell_options_->radio_valign_center);
-                       fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE);
-                       fl_set_object_lcol(cell_options_->radio_valign_bottom,FL_INACTIVE);
-                       fl_set_object_lcol(cell_options_->radio_valign_center,FL_INACTIVE);
+                       setEnabled(cell_options_->input_special_multialign, true);
+                       setEnabled(cell_options_->input_mcolumn_width, true);
                }
+
+               setEnabled(cell_options_->radio_valign_top,    !pwidth.empty());
+               setEnabled(cell_options_->radio_valign_bottom, !pwidth.empty());
+               setEnabled(cell_options_->radio_valign_center, !pwidth.empty());
+               
+               setEnabled(cell_options_->radio_align_left,   pwidth.empty());
+               setEnabled(cell_options_->radio_align_right,  pwidth.empty());
+               setEnabled(cell_options_->radio_align_center, pwidth.empty());
        } else {
                fl_set_button(cell_options_->radio_multicolumn, 0);
+
                fl_set_button(cell_options_->radio_border_top, 0);
-               fl_deactivate_object(cell_options_->radio_border_top);
-               fl_set_object_lcol(cell_options_->radio_border_top, FL_INACTIVE);
+               setEnabled(cell_options_->radio_border_top, false);
+
                fl_set_button(cell_options_->radio_border_bottom, 0);
-               fl_deactivate_object(cell_options_->radio_border_bottom);
-               fl_set_object_lcol(cell_options_->radio_border_bottom, FL_INACTIVE);
+               setEnabled(cell_options_->radio_border_bottom, false);
+
                fl_set_button(cell_options_->radio_border_left, 0);
-               fl_deactivate_object(cell_options_->radio_border_left);
-               fl_set_object_lcol(cell_options_->radio_border_left, FL_INACTIVE);
+               setEnabled(cell_options_->radio_border_left, false);
+
                fl_set_button(cell_options_->radio_border_right, 0);
-               fl_deactivate_object(cell_options_->radio_border_right);
-               fl_set_object_lcol(cell_options_->radio_border_right, FL_INACTIVE);
+               setEnabled(cell_options_->radio_border_right, false);
+
                fl_set_button(cell_options_->radio_align_left, 0);
-               fl_deactivate_object(cell_options_->radio_align_left);
-               fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE);
+               setEnabled(cell_options_->radio_align_left, false);
+
                fl_set_button(cell_options_->radio_align_right, 0);
-               fl_deactivate_object(cell_options_->radio_align_right);
-               fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE);
+               setEnabled(cell_options_->radio_align_right, false);
+
                fl_set_button(cell_options_->radio_align_center, 0);
-               fl_deactivate_object(cell_options_->radio_align_center);
-               fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE);
+               setEnabled(cell_options_->radio_align_center, false);
+
                fl_set_button(cell_options_->radio_valign_top, 0);
-               fl_deactivate_object(cell_options_->radio_valign_top);
-               fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE);
+               setEnabled(cell_options_->radio_valign_top, false);
+
                fl_set_button(cell_options_->radio_valign_bottom, 0);
-               fl_deactivate_object(cell_options_->radio_valign_bottom);
-               fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_INACTIVE);
+               setEnabled(cell_options_->radio_valign_bottom, false);
+
                fl_set_button(cell_options_->radio_valign_center, 0);
-               fl_deactivate_object(cell_options_->radio_valign_center);
-               fl_set_object_lcol(cell_options_->radio_valign_center, FL_INACTIVE);
+               setEnabled(cell_options_->radio_valign_center, false);
+
                fl_set_input(cell_options_->input_special_multialign, "");
-               fl_deactivate_object(cell_options_->input_special_multialign);
-               fl_set_object_lcol(cell_options_->input_special_multialign, FL_INACTIVE);
-               fl_set_input(cell_options_->input_mcolumn_width,"");
-               fl_deactivate_object(cell_options_->input_mcolumn_width);
-               fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_INACTIVE);
+               setEnabled(cell_options_->input_special_multialign, false);
+
+               fl_set_input(cell_options_->input_mcolumn_width, "");
+               setEnabled(cell_options_->input_mcolumn_width, false);
        }
        if (tabular->GetRotateCell(cell))
                fl_set_button(cell_options_->radio_rotate_cell, 1);
@@ -308,27 +277,21 @@ void FormTabular::update()
                fl_set_button(column_options_->radio_border_right, 0);
        special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_COLUMN);
        fl_set_input(column_options_->input_special_alignment, special.c_str());
-       if (lv_->buffer()->isReadonly()) 
-               fl_deactivate_object(column_options_->input_special_alignment);
-       else
-               fl_activate_object(column_options_->input_special_alignment);
+
+       bool const isReadonly = lv_->buffer()->isReadonly();
+       setEnabled(column_options_->input_special_alignment, !isReadonly);
+
        pwidth = tabular->GetColumnPWidth(cell);
        fl_set_input(column_options_->input_column_width,pwidth.c_str());
-       if (lv_->buffer()->isReadonly()) {
-               fl_deactivate_object(column_options_->input_column_width);
-       } else {
-               fl_activate_object(column_options_->input_column_width);
-       }
+       setEnabled(column_options_->input_column_width, !isReadonly);
+
+       setEnabled(cell_options_->radio_useminipage, !pwidth.empty());
        if (!pwidth.empty()) {
-               fl_activate_object(cell_options_->radio_useminipage);
-               fl_set_object_lcol(cell_options_->radio_useminipage, FL_BLACK);
                if (tabular->GetUsebox(cell) == 2)
                        fl_set_button(cell_options_->radio_useminipage, 1);
                else
                        fl_set_button(cell_options_->radio_useminipage, 0);
        } else {
-               fl_deactivate_object(cell_options_->radio_useminipage);
-               fl_set_object_lcol(cell_options_->radio_useminipage, FL_INACTIVE);
                fl_set_button(cell_options_->radio_useminipage,0);
        }
        align = tabular->GetAlignment(cell, true);
@@ -351,46 +314,26 @@ void FormTabular::update()
                fl_set_button(column_options_->radio_valign_bottom, 1);
        else
                fl_set_button(column_options_->radio_valign_top, 1);
-       if (!pwidth.empty()) {
-               fl_deactivate_object(column_options_->radio_align_left);
-               fl_deactivate_object(column_options_->radio_align_right);
-               fl_deactivate_object(column_options_->radio_align_center);
-               fl_set_object_lcol(column_options_->radio_align_left, FL_INACTIVE);
-               fl_set_object_lcol(column_options_->radio_align_right, FL_INACTIVE);
-               fl_set_object_lcol(column_options_->radio_align_center, FL_INACTIVE);
-               fl_activate_object(column_options_->radio_valign_top);
-               fl_activate_object(column_options_->radio_valign_bottom);
-               fl_activate_object(column_options_->radio_valign_center);
-               fl_set_object_lcol(column_options_->radio_valign_top, FL_BLACK);
-               fl_set_object_lcol(column_options_->radio_valign_bottom, FL_BLACK);
-               fl_set_object_lcol(column_options_->radio_valign_center, FL_BLACK);
-       } else {
-               fl_activate_object(column_options_->radio_align_left);
-               fl_activate_object(column_options_->radio_align_right);
-               fl_activate_object(column_options_->radio_align_center);
-               fl_set_object_lcol(column_options_->radio_align_left, FL_BLACK);
-               fl_set_object_lcol(column_options_->radio_align_right, FL_BLACK);
-               fl_set_object_lcol(column_options_->radio_align_center, FL_BLACK);
-               fl_deactivate_object(column_options_->radio_valign_top);
-               fl_deactivate_object(column_options_->radio_valign_bottom);
-               fl_deactivate_object(column_options_->radio_valign_center);
-               fl_set_object_lcol(column_options_->radio_valign_top, FL_INACTIVE);
-               fl_set_object_lcol(column_options_->radio_valign_bottom, FL_INACTIVE);
-               fl_set_object_lcol(column_options_->radio_valign_center, FL_INACTIVE);
-       }
+
+       setEnabled(column_options_->radio_align_left,   pwidth.empty());
+       setEnabled(column_options_->radio_align_right,  pwidth.empty());
+       setEnabled(column_options_->radio_align_center, pwidth.empty());
+       
+       setEnabled(column_options_->radio_valign_top,    !pwidth.empty());
+       setEnabled(column_options_->radio_valign_bottom, !pwidth.empty());
+       setEnabled(column_options_->radio_valign_center, !pwidth.empty());
+
        fl_set_button(tabular_options_->radio_longtable,
                      tabular->IsLongTabular());
-       if (tabular->IsLongTabular()) {
-               fl_activate_object(longtable_options_->radio_lt_firsthead);
-               fl_activate_object(longtable_options_->radio_lt_head);
-               fl_activate_object(longtable_options_->radio_lt_foot);
-               fl_activate_object(longtable_options_->radio_lt_lastfoot);
-               fl_activate_object(longtable_options_->radio_lt_newpage);
-               fl_set_object_lcol(longtable_options_->radio_lt_firsthead, FL_BLACK);
-               fl_set_object_lcol(longtable_options_->radio_lt_head, FL_BLACK);
-               fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_BLACK);
-               fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_BLACK);
-               fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_BLACK);
+
+       bool const enable = tabular->IsLongTabular();
+       setEnabled(longtable_options_->radio_lt_firsthead, enable);
+       setEnabled(longtable_options_->radio_lt_head,      enable);
+       setEnabled(longtable_options_->radio_lt_foot,      enable);
+       setEnabled(longtable_options_->radio_lt_lastfoot,  enable);
+       setEnabled(longtable_options_->radio_lt_newpage,   enable);
+
+       if (enable) {
                int dummy;
                fl_set_button(longtable_options_->radio_lt_firsthead,
                              tabular->GetRowOfLTFirstHead(cell, dummy));
@@ -403,21 +346,11 @@ void FormTabular::update()
                fl_set_button(longtable_options_->radio_lt_newpage,
                              tabular->GetLTNewPage(cell));
        } else {
-               fl_deactivate_object(longtable_options_->radio_lt_firsthead);
-               fl_deactivate_object(longtable_options_->radio_lt_head);
-               fl_deactivate_object(longtable_options_->radio_lt_foot);
-               fl_deactivate_object(longtable_options_->radio_lt_lastfoot);
-               fl_deactivate_object(longtable_options_->radio_lt_newpage);
                fl_set_button(longtable_options_->radio_lt_firsthead,0);
                fl_set_button(longtable_options_->radio_lt_head,0);
                fl_set_button(longtable_options_->radio_lt_foot,0);
                fl_set_button(longtable_options_->radio_lt_lastfoot,0);
                fl_set_button(longtable_options_->radio_lt_newpage,0);
-               fl_set_object_lcol(longtable_options_->radio_lt_firsthead,FL_INACTIVE);
-               fl_set_object_lcol(longtable_options_->radio_lt_head, FL_INACTIVE);
-               fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_INACTIVE);
-               fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_INACTIVE);
-               fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_INACTIVE);
        }
        fl_set_button(tabular_options_->radio_rotate_tabular,
                      tabular->GetRotateTabular());
@@ -514,46 +447,36 @@ bool FormTabular::input(FL_OBJECT * ob, long)
     else if (ob == cell_options_->radio_multicolumn)
         num = LyXTabular::MULTICOLUMN;
     else if (ob == tabular_options_->radio_longtable) {
-        s = fl_get_button(tabular_options_->radio_longtable);
-        if (s) {
-            num = LyXTabular::SET_LONGTABULAR;
-            fl_activate_object(longtable_options_->radio_lt_firsthead);
-            fl_activate_object(longtable_options_->radio_lt_head);
-            fl_activate_object(longtable_options_->radio_lt_foot);
-            fl_activate_object(longtable_options_->radio_lt_lastfoot);
-            fl_activate_object(longtable_options_->radio_lt_newpage);
-           int dummy;
-            fl_set_button(longtable_options_->radio_lt_firsthead,
-                          tabular->GetRowOfLTFirstHead(cell, dummy));
-            fl_set_button(longtable_options_->radio_lt_head,
-                         tabular->GetRowOfLTHead(cell, dummy));
-            fl_set_button(longtable_options_->radio_lt_foot,
-                         tabular->GetRowOfLTFoot(cell, dummy));
-            fl_set_button(longtable_options_->radio_lt_lastfoot,
-                          tabular->GetRowOfLTLastFoot(cell, dummy));
-            fl_set_button(longtable_options_->radio_lt_firsthead,
-                         tabular->GetLTNewPage(cell));
-        } else {
-           num = LyXTabular::UNSET_LONGTABULAR;
-            fl_deactivate_object(longtable_options_->radio_lt_firsthead);
-            fl_deactivate_object(longtable_options_->radio_lt_head);
-            fl_deactivate_object(longtable_options_->radio_lt_foot);
-            fl_deactivate_object(longtable_options_->radio_lt_lastfoot);
-            fl_deactivate_object(longtable_options_->radio_lt_newpage);
-            fl_set_button(longtable_options_->radio_lt_firsthead,0);
-            fl_set_button(longtable_options_->radio_lt_head,0);
-            fl_set_button(longtable_options_->radio_lt_foot,0);
-            fl_set_button(longtable_options_->radio_lt_lastfoot,0);
-            fl_set_button(longtable_options_->radio_lt_newpage,0);
-           fl_set_object_lcol(longtable_options_->radio_lt_firsthead,
-                              FL_INACTIVE);
-           fl_set_object_lcol(longtable_options_->radio_lt_head, FL_INACTIVE);
-           fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_INACTIVE);
-           fl_set_object_lcol(longtable_options_->radio_lt_lastfoot,
-                              FL_INACTIVE);
-           fl_set_object_lcol(longtable_options_->radio_lt_newpage,
-                              FL_INACTIVE);
-        }
+           bool const enable =
+                   fl_get_button(tabular_options_->radio_longtable);
+           
+           setEnabled(longtable_options_->radio_lt_firsthead, enable);
+           setEnabled(longtable_options_->radio_lt_head,      enable);
+           setEnabled(longtable_options_->radio_lt_foot,      enable);
+           setEnabled(longtable_options_->radio_lt_lastfoot,  enable);
+           setEnabled(longtable_options_->radio_lt_newpage,   enable);
+
+           if (enable) {
+                   num = LyXTabular::SET_LONGTABULAR;
+                   int dummy;
+                   fl_set_button(longtable_options_->radio_lt_firsthead,
+                                 tabular->GetRowOfLTFirstHead(cell, dummy));
+                   fl_set_button(longtable_options_->radio_lt_head,
+                                 tabular->GetRowOfLTHead(cell, dummy));
+                   fl_set_button(longtable_options_->radio_lt_foot,
+                                 tabular->GetRowOfLTFoot(cell, dummy));
+                   fl_set_button(longtable_options_->radio_lt_lastfoot,
+                                 tabular->GetRowOfLTLastFoot(cell, dummy));
+                   fl_set_button(longtable_options_->radio_lt_firsthead,
+                                 tabular->GetLTNewPage(cell));
+           } else {
+                   num = LyXTabular::UNSET_LONGTABULAR;
+                   fl_set_button(longtable_options_->radio_lt_firsthead,0);
+                   fl_set_button(longtable_options_->radio_lt_head,0);
+                   fl_set_button(longtable_options_->radio_lt_foot,0);
+                   fl_set_button(longtable_options_->radio_lt_lastfoot,0);
+                   fl_set_button(longtable_options_->radio_lt_newpage,0);
+           }
     } else if (ob == tabular_options_->radio_rotate_tabular) {
         s = fl_get_button(tabular_options_->radio_rotate_tabular);
        if (s)
index ae5b498a3c4659edaa6e6e9de3e7c2ffcc01a7da..bd890000d7176c597a830056f30074acf65a5838 100644 (file)
@@ -36,7 +36,7 @@ public:
 
 private:
        /** Redraw the form (on receipt of a Signal indicating, for example,
-           that the xform colours have been re-mapped). */
+           that the xforms colours have been re-mapped). */
        virtual void redraw();
        /// Disconnect signals. Also perform any necessary housekeeping.
        virtual void disconnect();
@@ -51,7 +51,7 @@ private:
        virtual void build();
        /// Filter the inputs
        virtual bool input(FL_OBJECT *, long);
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
 
        /// Fdesign generated methods
index 205dc180d1225d66cbb2e4efe8eb544c2704db93..61d08f1c93d85d3dd3c245186f700b54c477012c 100644 (file)
@@ -43,7 +43,7 @@ private:
        virtual void apply();
        /// Update dialog before showing it
        virtual void update();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        /// Build the dialog
        virtual void build();
index 370c25baed568155cff898203a057c16968e95a6..87242c6507b7a611c83969bbc6c2cdad885d3aa1 100644 (file)
@@ -40,7 +40,7 @@ private:
        virtual void update();
        /// Filter the inputs on callback from xforms
        virtual bool input( FL_OBJECT *, long);
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        ///
        void updateToc();
index 3aa21d665be0d47e5f3bb9de0ae8d1d573aec1d3..d39c8812e6835fcae4f770a7c4df68ca899a0ff1 100644 (file)
@@ -36,7 +36,7 @@ private:
        virtual void update();
        /// Apply from dialog (modify or create inset)
        virtual void apply();
-       /// Pointer to the actual instantiation of the xform's form
+       /// Pointer to the actual instantiation of the xforms form
        virtual FL_FORM * form() const;
        ///
        FD_form_url * build_url();
index 3d1b40dc7c57a08d2c0eca1dfaa296c9ed5d8761..60f689b7b479651eba176af2f3efbd38a35c9969 100644 (file)
@@ -120,8 +120,8 @@ libxforms_la_SOURCES = \
        Timeout_pimpl.h \
        Toolbar_pimpl.C \
        Toolbar_pimpl.h \
-       xform_helpers.C \
-       xform_helpers.h
+       xforms_helpers.C \
+       xforms_helpers.h
 
 # These still have to be added. Sooner or later. ARRae-20000411
 #      GUI_defaults.C \
diff --git a/src/frontends/xforms/xform_helpers.C b/src/frontends/xforms/xform_helpers.C
deleted file mode 100644 (file)
index 92462f4..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-/** Collection of some useful xform helper functions
- */
-
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
-#include <fstream> // ofstream
-#include <vector>
-
-#ifdef __GNUG_
-#pragma implementation
-#endif
-
-#include "xform_helpers.h"
-#include "lyxlex.h"
-#include "filedlg.h" // LyXFileDlg
-#include "support/FileInfo.h"
-#include "support/filetools.h"
-#include "lyx_gui_misc.h" // WriteAlert
-#include "gettext.h"
-
-using std::ofstream;
-using std::pair;
-using std::vector;
-
-// Take a string and add breaks so that it fits into a desired label width, w
-string formatted(string const & sin, int w, int size, int style)
-{
-       string sout;
-       if (sin.empty()) return sout;
-
-       // break sin up into a vector of individual words
-       vector<string> sentence;
-       string word;
-       for (string::const_iterator sit = sin.begin();
-            sit != sin.end(); ++sit) {
-               if ((*sit) == ' ' || (*sit) == '\n') {
-                       sentence.push_back(word);
-                       word.erase();
-               } else {
-                       word += (*sit);
-               }
-       }
-       // Flush remaining contents of word
-       if (!word.empty() ) sentence.push_back(word);
-
-       string line, l1;
-       for (vector<string>::const_iterator vit = sentence.begin();
-            vit != sentence.end(); ++vit) {
-               if (!l1.empty() ) l1 += ' ';
-               l1 += (*vit);
-               int length = fl_get_string_width(style, size, l1.c_str(),
-                                                int(l1.length()));
-               if (length >= w) {
-                       if (!sout.empty() ) sout += '\n';
-                       sout += line;
-                       l1 = (*vit);
-               }
-
-               line = l1;
-       }
-       // Flush remaining contents of line
-       if (!line.empty()) {
-               if (!sout.empty() ) sout += '\n';
-               sout += line;
-       }
-       
-       return sout;
-}
-
-
-string const browseFile(string const & filename,
-                       string const & title,
-                       string const & pattern, 
-                       pair<string,string> const & dir1,
-                       pair<string,string> const & dir2)
-{
-       string lastPath = ".";
-       if (!filename.empty()) lastPath = OnlyPath(filename);
-
-       LyXFileDlg fileDlg;
-
-       if (!dir1.second.empty()) {
-               FileInfo fileInfo(dir1.second);
-               if (fileInfo.isOK() && fileInfo.isDir())
-                       fileDlg.SetButton(0, _(dir1.first), dir1.second);
-       }
-
-       if (!dir2.second.empty()) {
-               FileInfo fileInfo(dir2.second);
-               if (fileInfo.isOK() && fileInfo.isDir())
-                   fileDlg.SetButton(1, _(dir2.first), dir2.second);
-       }
-
-       bool error = false;
-       string buf;
-       do {
-               string p = fileDlg.Select(_(title),
-                                         lastPath,
-                                         pattern, OnlyFilename(filename));
-
-               if (p.empty()) return p;
-
-               lastPath = OnlyPath(p);
-
-               if (p.find_first_of("#~$% ") != string::npos) {
-                       WriteAlert(_("Filename can't contain any "
-                                    "of these characters:"),
-                                  _("space, '#', '~', '$' or '%'."));
-                       error = true;
-               } else {
-                       error = false;
-                       buf = p;
-               }
-       } while (error);
-
-       return buf;
-}
-
-
-// sorted by hand to prevent LyXLex from complaining on read().
-static
-keyword_item xformTags[] = {
-       { "\\gui_background", FL_COL1 },
-       { "\\gui_buttonbottom", FL_BOTTOM_BCOL },
-       { "\\gui_buttonleft", FL_LEFT_BCOL },
-       { "\\gui_buttonright", FL_RIGHT_BCOL },
-       { "\\gui_buttontop", FL_TOP_BCOL },
-       { "\\gui_inactive", FL_INACTIVE },
-       { "\\gui_push_button", FL_YELLOW },
-       { "\\gui_selected", FL_MCOL },  
-       { "\\gui_text", FL_BLACK }
-};
-
-
-static const int xformCount = sizeof(xformTags) / sizeof(keyword_item);
-
-
-bool XformColor::read(string const & filename)
-{
-       LyXLex lexrc(xformTags, xformCount);
-       if (!lexrc.setFile(filename))
-               return false;
-
-       while (lexrc.IsOK()) {
-               int const le = lexrc.lex();
-
-               switch (le) {
-               case LyXLex::LEX_UNDEF:
-                       lexrc.printError("Unknown tag `$$Token'");
-                       continue; 
-               case LyXLex::LEX_FEOF:
-                       continue;
-               default: break;
-               }
-
-               RGBColor col;
-
-               if (!lexrc.next()) break;
-               col.r = lexrc.GetInteger();
-
-               if (!lexrc.next()) break;
-               col.g = lexrc.GetInteger();
-
-               if (!lexrc.next()) break;
-               col.b = lexrc.GetInteger();
-
-               fl_mapcolor(le, col.r, col.g, col.b);
-       }
-               
-       return true;
-}
-
-
-bool XformColor::write(string const & filename)
-{
-       ofstream os(filename.c_str());
-       if (!os)
-               return false;
-
-       os << "### This file is part of\n"
-          << "### ========================================================\n"
-          << "###          LyX, The Document Processor\n"
-          << "###\n"
-          << "###          Copyright 1995 Matthias Ettrich\n"
-          << "###          Copyright 1995-2000 The LyX Team.\n"
-          << "###\n"
-          << "### ========================================================\n"
-          << "\n"
-          << "# This file is written by LyX, if you want to make your own\n"
-          << "# modifications you should do them from inside LyX and save\n"
-          << "\n";
-
-       for (int i = 0; i < xformCount; ++i) {
-               string const tag  = xformTags[i].tag;
-               int const colorID = xformTags[i].code;
-               RGBColor color;
-
-               fl_getmcolor(colorID, &color.r, &color.g, &color.b);
-
-               os << tag << " "
-                  << color.r << " " << color.g << " " << color.b << "\n";
-       }
-
-       return true;
-}
-
-
-string  RWInfo::error_message;
-
-bool RWInfo::WriteableDir(string const & name)
-{
-       error_message.erase();
-
-       if (!AbsolutePath(name)) {
-               error_message = N_("The absolute path is required.");
-               return false;
-       }
-
-       FileInfo const tp(name);
-       if (!tp.isDir()) {
-               error_message = N_("Directory does not exist.");
-               return false;
-       }
-
-       if (!tp.writable()) {
-               error_message = N_("Cannot write to this directory.");
-               return false;
-       }
-
-       return true;
-}
-
-
-bool RWInfo::ReadableDir(string const & name)
-{
-       error_message.erase();
-
-       if (!AbsolutePath(name)) {
-               error_message = N_("The absolute path is required.");
-               return false;
-       }
-
-       FileInfo const tp(name);
-       if (!tp.isDir()) {
-               error_message = N_("Directory does not exist.");
-               return false;
-       }
-
-       if (!tp.readable()) {
-               error_message = N_("Cannot read this directory.");
-               return false;
-       }
-
-       return true;
-}
-
-
-bool RWInfo::WriteableFile(string const & name)
-{
-       // A writeable file is either:
-       // * An existing file to which we have write access, or
-       // * A file that doesn't yet exist but that would exist in a writeable
-       //   directory.
-
-       error_message.erase();
-
-       if (name.empty()) {
-               error_message = N_("No file input.");
-               return false;
-       }
-
-       string const dir = OnlyPath(name);
-       if (!AbsolutePath(dir)) {
-               error_message = N_("The absolute path is required.");
-               return false;
-       }
-
-       FileInfo d(name);
-       if (!d.isDir()) {
-               d.newFile(dir);
-       }
-
-       if (!d.isDir()) {
-               error_message = N_("Directory does not exist.");
-               return false;
-       }
-       
-       if (!d.writable()) {
-               error_message = N_("Cannot write to this directory.");
-               return false;
-       }
-
-       FileInfo f(name);
-       if (dir == name || f.isDir()) {
-               error_message = N_("A file is required, not a directory.");
-               return false;
-       }
-
-       if (f.exist() && !f.writable()) {
-               error_message = N_("Cannot write to this file.");
-               return false;
-       }
-       
-       return true;
-}
-
-
-bool RWInfo::ReadableFile(string const & name)
-{
-       error_message.erase();
-
-       if (name.empty()) {
-               error_message = N_("No file input.");
-               return false;
-       }
-
-       string const dir = OnlyPath(name);
-       if (!AbsolutePath(dir)) {
-               error_message = N_("The absolute path is required.");
-               return false;
-       }
-
-       FileInfo d(name);
-       if (!d.isDir()) {
-               d.newFile(dir);
-       }
-
-       if (!d.isDir()) {
-               error_message = N_("Directory does not exist.");
-               return false;
-       }
-       
-       if (!d.readable()) {
-               error_message = N_("Cannot read from this directory.");
-               return false;
-       }
-
-       FileInfo f(name);
-       if (dir == name || f.isDir()) {
-               error_message = N_("A file is required, not a directory.");
-               return false;
-       }
-
-       if (!f.exist()) {
-               error_message = N_("File does not exist.");
-               return false;
-       }
-       
-       if (!f.readable()) {
-               error_message = N_("Cannot read from this file.");
-               return false;
-       }
-
-       return true;
-}
diff --git a/src/frontends/xforms/xform_helpers.h b/src/frontends/xforms/xform_helpers.h
deleted file mode 100644 (file)
index 7b70dc8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef XFORMHELPERS_H
-#define XFORMHELPERS_H
-
-#ifdef __GNUG_
-#pragma interface
-#endif
-
-#include <utility> // pair
-//#include <config.h>
-#include "LString.h"
-#include "Color.h"
-
-// Take a string and add breaks so that it fits into a desired label width, w
-string formatted(string const &label, int w, int size, int style);
-
-/** Launch a file dialog and return the chosen file.
-    filename: a suggested filename.
-    title: the title of the dialog.
-    pattern: *.ps etc.
-    dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
-*/
-string const browseFile(string const & filename,
-                       string const & title,
-                       string const & pattern, 
-                       std::pair<string,string> const & dir1,
-                       std::pair<string,string> const & dir2);
-
-/// struct holding xform-specific colors
-struct XformColor : public NamedColor {
-       int colorID;
-       XformColor() : NamedColor(), colorID(0) {}
-       static bool read(string const &);
-       static bool write(string const &);
-};
-
-
-/** Some functions that perform some quite detailed tests to ascertain whether
-    the directory or file is readable or writeable. If not, then an error
-    message is placed in error_message. */
-class RWInfo {
-public:
-       ///
-       static bool WriteableDir(string const & dir);
-       ///
-       static bool ReadableDir(string const & dir);
-       ///
-       static bool WriteableFile(string const & file);
-       ///
-       static bool ReadableFile(string const & file);
-       ///
-       static string const & ErrorMessage() { return error_message; }
-private:
-       ///
-       static string error_message;
-};
-#endif
diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C
new file mode 100644 (file)
index 0000000..72d346f
--- /dev/null
@@ -0,0 +1,370 @@
+/** Collection of some useful xform helper functions
+ */
+
+#include <config.h>
+
+#include FORMS_H_LOCATION
+
+#include <fstream> // ofstream
+#include <vector>
+
+#ifdef __GNUG_
+#pragma implementation
+#endif
+
+#include "xforms_helpers.h"
+#include "lyxlex.h"
+#include "filedlg.h" // LyXFileDlg
+#include "support/FileInfo.h"
+#include "support/filetools.h"
+#include "lyx_gui_misc.h" // WriteAlert
+#include "gettext.h"
+
+using std::ofstream;
+using std::pair;
+using std::vector;
+
+// Set an FL_OBJECT to activated or deactivated
+void setEnabled(FL_OBJECT * ob, bool enable)
+{
+       if (enable) {
+               fl_activate_object(ob);
+               fl_set_object_lcol(ob, FL_BLACK);
+       } else {
+               fl_deactivate_object(ob);
+               fl_set_object_lcol(ob, FL_INACTIVE);
+       }
+}
+
+       
+// Take a string and add breaks so that it fits into a desired label width, w
+string formatted(string const & sin, int w, int size, int style)
+{
+       string sout;
+       if (sin.empty()) return sout;
+
+       // break sin up into a vector of individual words
+       vector<string> sentence;
+       string word;
+       for (string::const_iterator sit = sin.begin();
+            sit != sin.end(); ++sit) {
+               if ((*sit) == ' ' || (*sit) == '\n') {
+                       sentence.push_back(word);
+                       word.erase();
+               } else {
+                       word += (*sit);
+               }
+       }
+       // Flush remaining contents of word
+       if (!word.empty() ) sentence.push_back(word);
+
+       string line, l1;
+       for (vector<string>::const_iterator vit = sentence.begin();
+            vit != sentence.end(); ++vit) {
+               if (!l1.empty() ) l1 += ' ';
+               l1 += (*vit);
+               int length = fl_get_string_width(style, size, l1.c_str(),
+                                                int(l1.length()));
+               if (length >= w) {
+                       if (!sout.empty() ) sout += '\n';
+                       sout += line;
+                       l1 = (*vit);
+               }
+
+               line = l1;
+       }
+       // Flush remaining contents of line
+       if (!line.empty()) {
+               if (!sout.empty() ) sout += '\n';
+               sout += line;
+       }
+       
+       return sout;
+}
+
+
+string const browseFile(string const & filename,
+                       string const & title,
+                       string const & pattern, 
+                       pair<string,string> const & dir1,
+                       pair<string,string> const & dir2)
+{
+       string lastPath = ".";
+       if (!filename.empty()) lastPath = OnlyPath(filename);
+
+       LyXFileDlg fileDlg;
+
+       if (!dir1.second.empty()) {
+               FileInfo fileInfo(dir1.second);
+               if (fileInfo.isOK() && fileInfo.isDir())
+                       fileDlg.SetButton(0, _(dir1.first), dir1.second);
+       }
+
+       if (!dir2.second.empty()) {
+               FileInfo fileInfo(dir2.second);
+               if (fileInfo.isOK() && fileInfo.isDir())
+                   fileDlg.SetButton(1, _(dir2.first), dir2.second);
+       }
+
+       bool error = false;
+       string buf;
+       do {
+               string p = fileDlg.Select(_(title),
+                                         lastPath,
+                                         pattern, OnlyFilename(filename));
+
+               if (p.empty()) return p;
+
+               lastPath = OnlyPath(p);
+
+               if (p.find_first_of("#~$% ") != string::npos) {
+                       WriteAlert(_("Filename can't contain any "
+                                    "of these characters:"),
+                                  _("space, '#', '~', '$' or '%'."));
+                       error = true;
+               } else {
+                       error = false;
+                       buf = p;
+               }
+       } while (error);
+
+       return buf;
+}
+
+
+// sorted by hand to prevent LyXLex from complaining on read().
+static
+keyword_item xformTags[] = {
+       { "\\gui_background", FL_COL1 },
+       { "\\gui_buttonbottom", FL_BOTTOM_BCOL },
+       { "\\gui_buttonleft", FL_LEFT_BCOL },
+       { "\\gui_buttonright", FL_RIGHT_BCOL },
+       { "\\gui_buttontop", FL_TOP_BCOL },
+       { "\\gui_inactive", FL_INACTIVE },
+       { "\\gui_push_button", FL_YELLOW },
+       { "\\gui_selected", FL_MCOL },  
+       { "\\gui_text", FL_BLACK }
+};
+
+
+static const int xformCount = sizeof(xformTags) / sizeof(keyword_item);
+
+
+bool XformsColor::read(string const & filename)
+{
+       LyXLex lexrc(xformTags, xformCount);
+       if (!lexrc.setFile(filename))
+               return false;
+
+       while (lexrc.IsOK()) {
+               int const le = lexrc.lex();
+
+               switch (le) {
+               case LyXLex::LEX_UNDEF:
+                       lexrc.printError("Unknown tag `$$Token'");
+                       continue; 
+               case LyXLex::LEX_FEOF:
+                       continue;
+               default: break;
+               }
+
+               RGBColor col;
+
+               if (!lexrc.next()) break;
+               col.r = lexrc.GetInteger();
+
+               if (!lexrc.next()) break;
+               col.g = lexrc.GetInteger();
+
+               if (!lexrc.next()) break;
+               col.b = lexrc.GetInteger();
+
+               fl_mapcolor(le, col.r, col.g, col.b);
+       }
+               
+       return true;
+}
+
+
+bool XformsColor::write(string const & filename)
+{
+       ofstream os(filename.c_str());
+       if (!os)
+               return false;
+
+       os << "### This file is part of\n"
+          << "### ========================================================\n"
+          << "###          LyX, The Document Processor\n"
+          << "###\n"
+          << "###          Copyright 1995 Matthias Ettrich\n"
+          << "###          Copyright 1995-2000 The LyX Team.\n"
+          << "###\n"
+          << "### ========================================================\n"
+          << "\n"
+          << "# This file is written by LyX, if you want to make your own\n"
+          << "# modifications you should do them from inside LyX and save\n"
+          << "\n";
+
+       for (int i = 0; i < xformCount; ++i) {
+               string const tag  = xformTags[i].tag;
+               int const colorID = xformTags[i].code;
+               RGBColor color;
+
+               fl_getmcolor(colorID, &color.r, &color.g, &color.b);
+
+               os << tag << " "
+                  << color.r << " " << color.g << " " << color.b << "\n";
+       }
+
+       return true;
+}
+
+
+string  RWInfo::error_message;
+
+bool RWInfo::WriteableDir(string const & name)
+{
+       error_message.erase();
+
+       if (!AbsolutePath(name)) {
+               error_message = N_("The absolute path is required.");
+               return false;
+       }
+
+       FileInfo const tp(name);
+       if (!tp.isDir()) {
+               error_message = N_("Directory does not exist.");
+               return false;
+       }
+
+       if (!tp.writable()) {
+               error_message = N_("Cannot write to this directory.");
+               return false;
+       }
+
+       return true;
+}
+
+
+bool RWInfo::ReadableDir(string const & name)
+{
+       error_message.erase();
+
+       if (!AbsolutePath(name)) {
+               error_message = N_("The absolute path is required.");
+               return false;
+       }
+
+       FileInfo const tp(name);
+       if (!tp.isDir()) {
+               error_message = N_("Directory does not exist.");
+               return false;
+       }
+
+       if (!tp.readable()) {
+               error_message = N_("Cannot read this directory.");
+               return false;
+       }
+
+       return true;
+}
+
+
+bool RWInfo::WriteableFile(string const & name)
+{
+       // A writeable file is either:
+       // * An existing file to which we have write access, or
+       // * A file that doesn't yet exist but that would exist in a writeable
+       //   directory.
+
+       error_message.erase();
+
+       if (name.empty()) {
+               error_message = N_("No file input.");
+               return false;
+       }
+
+       string const dir = OnlyPath(name);
+       if (!AbsolutePath(dir)) {
+               error_message = N_("The absolute path is required.");
+               return false;
+       }
+
+       FileInfo d(name);
+       if (!d.isDir()) {
+               d.newFile(dir);
+       }
+
+       if (!d.isDir()) {
+               error_message = N_("Directory does not exist.");
+               return false;
+       }
+       
+       if (!d.writable()) {
+               error_message = N_("Cannot write to this directory.");
+               return false;
+       }
+
+       FileInfo f(name);
+       if (dir == name || f.isDir()) {
+               error_message = N_("A file is required, not a directory.");
+               return false;
+       }
+
+       if (f.exist() && !f.writable()) {
+               error_message = N_("Cannot write to this file.");
+               return false;
+       }
+       
+       return true;
+}
+
+
+bool RWInfo::ReadableFile(string const & name)
+{
+       error_message.erase();
+
+       if (name.empty()) {
+               error_message = N_("No file input.");
+               return false;
+       }
+
+       string const dir = OnlyPath(name);
+       if (!AbsolutePath(dir)) {
+               error_message = N_("The absolute path is required.");
+               return false;
+       }
+
+       FileInfo d(name);
+       if (!d.isDir()) {
+               d.newFile(dir);
+       }
+
+       if (!d.isDir()) {
+               error_message = N_("Directory does not exist.");
+               return false;
+       }
+       
+       if (!d.readable()) {
+               error_message = N_("Cannot read from this directory.");
+               return false;
+       }
+
+       FileInfo f(name);
+       if (dir == name || f.isDir()) {
+               error_message = N_("A file is required, not a directory.");
+               return false;
+       }
+
+       if (!f.exist()) {
+               error_message = N_("File does not exist.");
+               return false;
+       }
+       
+       if (!f.readable()) {
+               error_message = N_("Cannot read from this file.");
+               return false;
+       }
+
+       return true;
+}
diff --git a/src/frontends/xforms/xforms_helpers.h b/src/frontends/xforms/xforms_helpers.h
new file mode 100644 (file)
index 0000000..531b26a
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef XFORMSHELPERS_H
+#define XFORMSHELPERS_H
+
+#ifdef __GNUG_
+#pragma interface
+#endif
+
+#include <utility> // pair
+//#include <config.h>
+#include "LString.h"
+#include "Color.h"
+
+// Set an FL_OBJECT to activated or deactivated
+void setEnabled(FL_OBJECT *, bool enable);
+
+// Take a string and add breaks so that it fits into a desired label width, w
+string formatted(string const &label, int w, int size, int style);
+
+/** Launch a file dialog and return the chosen file.
+    filename: a suggested filename.
+    title: the title of the dialog.
+    pattern: *.ps etc.
+    dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+*/
+string const browseFile(string const & filename,
+                       string const & title,
+                       string const & pattern, 
+                       std::pair<string,string> const & dir1,
+                       std::pair<string,string> const & dir2);
+
+/// struct holding xform-specific colors
+struct XformsColor : public NamedColor {
+       int colorID;
+       XformsColor() : NamedColor(), colorID(0) {}
+       static bool read(string const &);
+       static bool write(string const &);
+};
+
+
+/** Some functions that perform some quite detailed tests to ascertain whether
+    the directory or file is readable or writeable. If not, then an error
+    message is placed in error_message. */
+class RWInfo {
+public:
+       ///
+       static bool WriteableDir(string const & dir);
+       ///
+       static bool ReadableDir(string const & dir);
+       ///
+       static bool WriteableFile(string const & file);
+       ///
+       static bool ReadableFile(string const & file);
+       ///
+       static string const & ErrorMessage() { return error_message; }
+private:
+       ///
+       static string error_message;
+};
+#endif // XFORMSHELPERS_H