]> git.lyx.org Git - features.git/commitdiff
Modification to ButtonController, so that read-only list of widgets is
authorAngus Leeming <leeming@lyx.org>
Sat, 2 Jun 2001 14:53:35 +0000 (14:53 +0000)
committerAngus Leeming <leeming@lyx.org>
Sat, 2 Jun 2001 14:53:35 +0000 (14:53 +0000)
not refreshed every time Restore,Apply,Ok,Cancel are pressed. Has the real
advantage that the GUI's can control the widgets more accurately, since the
ButtonController cannot.

Demonstrated with some small change to the Paragraph dialog: enabling the
align buttons is now dependent on the AlignPossible entry in the Layout.

Also apply a small bug fix to getVectorFromString in helper_funcs.C

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2087 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ButtonController.h
src/frontends/controllers/ButtonControllerBase.C
src/frontends/controllers/ButtonControllerBase.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/biblio.C
src/frontends/controllers/helper_funcs.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormParagraph.C

index b0337d3fd81a0c6956f4f4824af0ab60a5c89f56..8b4725976c471b0dd5ed0ede6ffb7936bb049f11 100644 (file)
@@ -39,8 +39,10 @@ public:
        ///
        void eraseReadOnly() { read_only_.clear(); }
 
-       /// Refresh the widgets status.
+       /// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
        void refresh();
+       /// Refresh the status of any widgets in the read_only list
+       void refreshReadOnly();
 
 private:
        /// Enable/Disable a widget
@@ -89,18 +91,21 @@ void GuiBC<Button, Widget>::refresh()
                else
                        setButtonLabel(cancel_, close_label_);
        }
+}
 
-       // Enable/Disable read-only handled widgets.
-       if (!read_only_.empty()) {
-               bool const enable = !bp().isReadOnly();
 
-               Widgets::const_iterator end = read_only_.end();
-               Widgets::const_iterator iter = read_only_.begin();
-               for (; iter != end; ++iter) {
-                       setWidgetEnabled(*iter, enable);
-               }
-       }
+template <class Button, class Widget>
+void GuiBC<Button, Widget>::refreshReadOnly()
+{
+       if (read_only_.empty()) return;
+
+       bool const enable = !bp().isReadOnly();
 
+       Widgets::const_iterator end = read_only_.end();
+       Widgets::const_iterator iter = read_only_.begin();
+       for (; iter != end; ++iter) {
+               setWidgetEnabled(*iter, enable);
+       }
 }
 
 
index ecd9f2dd7d068ae4edd506f0c9d48d2f66888af5..3529710ef6b334a6a2f225a71577e42871c52410 100644 (file)
@@ -84,10 +84,11 @@ void ButtonControllerBase::invalid()
 bool ButtonControllerBase::readOnly(bool ro)
 {
        if (ro) {
-               input(ButtonPolicy::SMI_READ_ONLY);
+               bp().input(ButtonPolicy::SMI_READ_ONLY);
        } else {
-               input(ButtonPolicy::SMI_READ_WRITE);
+               bp().input(ButtonPolicy::SMI_READ_WRITE);
        }
+       refreshReadOnly();
        return ro;
 }
 
index 5114fb483b23d4aa0c5e625bd3727c71721f0b01..5d4b876413e556a43fc21852ab8e4e1e462b2a3e 100644 (file)
@@ -62,6 +62,8 @@ public:
        void hide();
        ///
        virtual void refresh() = 0;
+       ///
+       virtual void refreshReadOnly() = 0;
 
        /// Passthrough function -- returns its input value
        bool readOnly(bool = true);
index bf920d2a48240b14395007f6fe6895ddd6b34637..fb09eee6a021a53cc3d24196c6d1dc824f0529e6 100644 (file)
@@ -1,3 +1,16 @@
+2001-06-01  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * helper_funcs.C (getVectorFromString): bug fix.
+
+2001-05-30  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ButtonController.h
+       * ButtonControllerBase.[Ch] (refreshReadOnly): new method, called direct
+       from ButtonControllerBase::readOnly. Updates the state of the widgets
+       in the read-only list only when the read-only status of the document
+       changes.
+       (refresh): moved this stuff into refreshReadOnly.
+
 2001-05-18  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * ControlPrint.C (c-tor):
index febb0f94c5df55bfd0781d89c8f9e171709eadf3..f363c8107fe0aeb95891cb94627eb911b1fd926b 100644 (file)
@@ -11,6 +11,8 @@
  * \author Angus Leeming <a.leeming@ic.ac.uk>
  */
 
+#include <config.h>
+
 #include <vector>
 #include <algorithm>
 
 #pragma implementation
 #endif
 
-#include <config.h>
-
-/*
-#include "buffer.h"
-#include "Dialogs.h"
-#include "LyXView.h"
-*/
 #include "LString.h"
 #include "biblio.h"
 #include "helper_funcs.h"
@@ -34,7 +29,6 @@
 
 using std::find;
 using std::min;
-using std::pair;
 using std::vector;
 using std::sort;
 
index 3b0cc86d24ebc372030d00ccbde9a60d84837ff1..147fef18ea211497f3fd532fe87861ff7cfbe9d5 100644 (file)
@@ -54,7 +54,10 @@ vector<string> const getVectorFromString(string const & str,
 
        for(;;) {
                string::size_type const idx = keys.find(delim);
-               if (idx == string::npos) break;
+               if (idx == string::npos) {
+                       vec.push_back(keys);
+                       break;
+               }
 
                string const key = keys.substr(0, idx);
                if (!key.empty())
@@ -64,9 +67,6 @@ vector<string> const getVectorFromString(string const & str,
                keys = keys.substr(start);
        }
 
-       if (vec.empty()) // unable to separate
-               vec.push_back(str);
-
        return vec;
 }
 
index 569e573cd9c45faf1c2aa094d066f71a6f2f1318..94d3e8ca235ac1099a6e905fb9932246b371193f 100644 (file)
@@ -1,3 +1,8 @@
+2001-05-30  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormParagraph.C (update, general_update): enabling the align buttons
+       is now dependent on the AlignPossible entry in the Layout.
+
 2001-06-01  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * MathsSymbols.C: 
index 2c299281d53905def469b23a43a0f2d46968afa7..ef51c02e2761b00cf17314aac01ddcb1f89ad0c8 100644 (file)
@@ -126,9 +126,10 @@ void FormParagraph::update()
     if (!dialog_.get())
         return;
 
-    general_update();
-
+    // Do this first; some objects may be de/activated subsequently.
     bc_.readOnly(lv_->buffer()->isReadonly());
+
+    general_update();
 }
 
 
@@ -257,7 +258,7 @@ void FormParagraph::general_update()
     if (align == LYX_ALIGN_LAYOUT)
        align = textclasslist.Style(buf->params.textclass,
                                    text->cursor.par()->GetLayout()).align;
-        
+
     switch (align) {
     case LYX_ALIGN_RIGHT:
        fl_set_button(general_->radio_align_right, 1);
@@ -273,6 +274,15 @@ void FormParagraph::general_update()
        break;
     }
 
+    LyXAlignment alignpos =
+           textclasslist.Style(buf->params.textclass,
+                               text->cursor.par()->GetLayout()).alignpossible;
+
+    setEnabled(general_->radio_align_block,  bool(alignpos & LYX_ALIGN_BLOCK));
+    setEnabled(general_->radio_align_center, bool(alignpos & LYX_ALIGN_CENTER));
+    setEnabled(general_->radio_align_left,   bool(alignpos & LYX_ALIGN_LEFT));
+    setEnabled(general_->radio_align_right,  bool(alignpos & LYX_ALIGN_RIGHT));
+    
     fl_set_button(general_->check_lines_top,
                  text->cursor.par()->params.lineTop());
     fl_set_button(general_->check_lines_bottom,