]> git.lyx.org Git - features.git/commitdiff
cleanup ButtonController and rename a few things in ButtonPolicies
authorAllan Rae <rae@lyx.org>
Fri, 1 Sep 2000 03:00:16 +0000 (03:00 +0000)
committerAllan Rae <rae@lyx.org>
Fri, 1 Sep 2000 03:00:16 +0000 (03:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@997 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/frontends/ButtonPolicies.C
src/frontends/ButtonPolicies.h
src/frontends/xforms/ButtonController.h

index 06ff45676928f9c3c743999ea9455ddf58546f21..bcd5384391cab6de35baef39f2564d46e04c6a78 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-09-01  Allan Rae  <rae@lyx.org>
+
+       * src/frontends/ButtonPolicies.C: renamed all the references to
+       PreferencesPolicy::{AllButtons,BOGUS} to be ButtonPolicy.
+
+       * src/frontends/ButtonPolicies.h: rename AllButtons to ALL_BUTTONS
+       since it's a const not a type.
+
+       * src/frontends/xforms/ButtonController.h: cleanup before Lars does.
+
 2000-08-31  Juergen Vigna  <jug@sad.it>
 
        * src/insets/figinset.C: Various changes to look if the filename has
index 585a5e4270d3a1d5ddc7db6d18fb318e3521237f..11d833394829ac5e3da3ff5d3521fa20cc1be4bc 100644 (file)
@@ -48,9 +48,9 @@ void nextState(ButtonPolicy::State & state,
 
 PreferencesPolicy::PreferencesPolicy()
        : state_(INITIAL),
-         outputs_(APPLIED + 1, PreferencesPolicy::AllButtons),
+         outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
          state_machine_(APPLIED + 1,
-                        StateArray(SMI_TOTAL, PreferencesPolicy::BOGUS))
+                        StateArray(SMI_TOTAL, ButtonPolicy::BOGUS))
 {
        // Build the state output map
        outputs_[INITIAL] = CLOSE;
@@ -121,9 +121,9 @@ void PreferencesPolicy::input(SMInput input)
 
 OkCancelPolicy::OkCancelPolicy()
        : state_(INITIAL),
-         outputs_(INVALID + 1, PreferencesPolicy::AllButtons),
+         outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
          state_machine_(INVALID + 1,
-                        StateArray(SMI_TOTAL, PreferencesPolicy::BOGUS))
+                        StateArray(SMI_TOTAL, ButtonPolicy::BOGUS))
 {
        // Build the state output map
        outputs_[INITIAL] = CLOSE;
@@ -174,9 +174,9 @@ void OkCancelPolicy::input(SMInput input)
 
 OkCancelReadOnlyPolicy::OkCancelReadOnlyPolicy()
        : state_(INITIAL),
-         outputs_(RO_INVALID + 1, PreferencesPolicy::AllButtons),
+         outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
          state_machine_(RO_INVALID + 1,
-                        StateArray(SMI_TOTAL, PreferencesPolicy::BOGUS))
+                        StateArray(SMI_TOTAL, ButtonPolicy::BOGUS))
 {
        // Build the state output map
        outputs_[INITIAL] = CLOSE;
@@ -249,9 +249,9 @@ void OkCancelReadOnlyPolicy::input(SMInput input)
 
 NoRepeatedApplyReadOnlyPolicy::NoRepeatedApplyReadOnlyPolicy()
        : state_(INITIAL),
-         outputs_(RO_INVALID + 1, PreferencesPolicy::AllButtons),
+         outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
          state_machine_(RO_INVALID + 1,
-                        StateArray(SMI_TOTAL, PreferencesPolicy::BOGUS))
+                        StateArray(SMI_TOTAL, ButtonPolicy::BOGUS))
 {
        // Build the state output map
        outputs_[INITIAL] = CLOSE;
@@ -325,9 +325,9 @@ void NoRepeatedApplyReadOnlyPolicy::input(SMInput input)
 
 OkApplyCancelReadOnlyPolicy::OkApplyCancelReadOnlyPolicy()
        : state_(INITIAL),
-         outputs_(RO_APPLIED + 1, PreferencesPolicy::AllButtons),
+         outputs_(RO_APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
          state_machine_(RO_APPLIED + 1,
-                        StateArray(SMI_TOTAL, PreferencesPolicy::BOGUS))
+                        StateArray(SMI_TOTAL, ButtonPolicy::BOGUS))
 {
        // Build the state output map
        outputs_[INITIAL] = CLOSE;
@@ -415,9 +415,9 @@ void OkApplyCancelReadOnlyPolicy::input(SMInput input)
 
 OkApplyCancelPolicy::OkApplyCancelPolicy()
        : state_(INITIAL),
-         outputs_(APPLIED + 1, PreferencesPolicy::AllButtons),
+         outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
          state_machine_(APPLIED + 1,
-                        StateArray(SMI_TOTAL, PreferencesPolicy::BOGUS))
+                        StateArray(SMI_TOTAL, ButtonPolicy::BOGUS))
 {
        // Build the state output map
        outputs_[INITIAL] = CLOSE;
@@ -479,9 +479,9 @@ void OkApplyCancelPolicy::input(SMInput input)
 
 NoRepeatedApplyPolicy::NoRepeatedApplyPolicy()
        : state_(INITIAL),
-         outputs_(INVALID + 1, PreferencesPolicy::AllButtons),
+         outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
          state_machine_(INVALID + 1,
-                        StateArray(SMI_TOTAL, PreferencesPolicy::BOGUS))
+                        StateArray(SMI_TOTAL, ButtonPolicy::BOGUS))
 {
        // Build the state output map
        outputs_[INITIAL] = CLOSE;
index 40aed42457d76d385449936517159a9405052e4f..80661a662ffa3128034b5fd4e0a40ed94bd7b771 100644 (file)
@@ -106,9 +106,9 @@ public:
                UNDO_ALL = 8
        };
        ///
-       static const Button AllButtons =
-       Button(OKAY | APPLY | CANCEL | UNDO_ALL);
-       
+       static const Button ALL_BUTTONS =
+               Button(OKAY | APPLY | CANCEL | UNDO_ALL);
+  
        /** State machine inputs.
            All the policies so far have both CANCEL and HIDE always going to
            INITIAL. This won't necessarily be true for all [future] policies
index 2add560b7586d1b1a14abf8bb666f80220bd366e..17462efcf482e9d1d3c08be51c601ccbcd9aef5b 100644 (file)
     Actually supports 4 buttons in all and it's up to the user to decide on
     the activation policy and which buttons correspond to which output of the
     state machine.
+    @author Allan Rae <rae@lyx.org>
 */
 template <class Policy>
 class ButtonController : public noncopyable
 {
 public:
-       /**@name Constructors and Deconstructors */
-       //@{
        /** Constructor.
            The cancel/close label entries are _not_ managed within the class
            thereby allowing you to reassign at will and to use static labels.
@@ -49,153 +48,161 @@ public:
                  read_only_(), cancel_label(cancel), close_label(close) {}
        /// Somebody else owns the FL_OBJECTs we just manipulate them.
        ~ButtonController() {}
-       //@}
 
-       /**@name Initialise Button Functions */
-       //@{
+       /* Initialise Button Functions */
        /// Call refresh() when finished setting the buttons.
-       void setOK(FL_OBJECT * obj)
-               { okay_ = obj; }
+       void setOK(FL_OBJECT * obj) {
+               okay_ = obj;
+       }
        ///
-       void setApply(FL_OBJECT * obj)
-               { apply_ = obj; }
+       void setApply(FL_OBJECT * obj) {
+               apply_ = obj;
+       }
        ///
-       void setCancel(FL_OBJECT * obj)
-               { cancel_ = obj; }
+       void setCancel(FL_OBJECT * obj) {
+               cancel_ = obj;
+       }
        ///
-       void setUndoAll(FL_OBJECT * obj)
-               { undo_all_ = obj; }
+       void setUndoAll(FL_OBJECT * obj) {
+               undo_all_ = obj;
+       }
        ///
-       void setCancelTrueLabel(char const * c)
-               { cancel_label = c; }
+       void setCancelTrueLabel(char const * c) {
+               cancel_label = c;
+       }
        ///
-       void setCancelFalseLabel(char const * c)
-               { close_label = c; }
+       void setCancelFalseLabel(char const * c) {
+               close_label = c;
+       }
        ///
-       void addReadOnly(FL_OBJECT * obj)
-               { read_only_.push_front(obj); }
+       void addReadOnly(FL_OBJECT * obj) {
+               read_only_.push_front(obj);
+       }
        ///
-       void eraseReadOnly()
-               { read_only_.erase(read_only_.begin(), read_only_.end()); }
-       //@}
+       void eraseReadOnly() {
+               read_only_.erase(read_only_.begin(), read_only_.end());
+       }
 
-       /**@name Action Functions */
-       //@{
+       /* Action Functions */
        ///
-       void input(ButtonPolicy::SMInput in)
-               {
-                       bp_.input(in);
-                       refresh();
-               }
+       void input(ButtonPolicy::SMInput in) {
+               bp_.input(in);
+               refresh();
+       }
        ///
-       void ok()
-               { input(ButtonPolicy::SMI_OKAY); }
+       void ok() {
+               input(ButtonPolicy::SMI_OKAY);
+       }
        ///
-       void apply()
-               { input(ButtonPolicy::SMI_APPLY); }
+       void apply() {
+               input(ButtonPolicy::SMI_APPLY);
+       }
        ///
-       void cancel()
-               { input(ButtonPolicy::SMI_CANCEL); }
+       void cancel() {
+               input(ButtonPolicy::SMI_CANCEL);
+       }
        ///
-       void undoAll()
-               { input(ButtonPolicy::SMI_UNDO_ALL); }
+       void undoAll() {
+               input(ButtonPolicy::SMI_UNDO_ALL);
+       }
        ///
-       void hide()
-               { input(ButtonPolicy::SMI_HIDE); }
+       void hide() {
+               input(ButtonPolicy::SMI_HIDE);
+       }
        /// Passthrough function -- returns its input value
-       bool readOnly(bool ro = true)
-               {
-                       if (ro) {
-                               input(ButtonPolicy::SMI_READ_ONLY);
-                       } else {
-                               input(ButtonPolicy::SMI_READ_WRITE);
-                       }
-                       return ro;
+       bool readOnly(bool ro = true) {
+               if (ro) {
+                       input(ButtonPolicy::SMI_READ_ONLY);
+               } else {
+                       input(ButtonPolicy::SMI_READ_WRITE);
                }
+               return ro;
+       }
        ///
-       void readWrite()
-               { read_only(false); }
+       void readWrite() {
+               read_only(false);
+       }
        /// Passthrough function -- returns its input value
-       bool valid(bool v = true)
-               { 
-                       if (v) {
-                               input(ButtonPolicy::SMI_VALID);
-                       } else {
-                               input(ButtonPolicy::SMI_INVALID);
-                       }
-                       return v;
+       bool valid(bool v = true) { 
+               if (v) {
+                       input(ButtonPolicy::SMI_VALID);
+               } else {
+                       input(ButtonPolicy::SMI_INVALID);
                }
+               return v;
+       }
        ///
-       void invalid()
-               { valid(false); }
+       void invalid() {
+               valid(false);
+       }
        /// force a refresh of the buttons
-       void refresh()
-               {
-                       if (okay_) {
-                               if (bp_.buttonStatus(ButtonPolicy::OKAY)) {
-                                       fl_activate_object(okay_);
-                                       fl_set_object_lcol(okay_, FL_BLACK);
-                               } else {
-                                       fl_deactivate_object(okay_);
-                                       fl_set_object_lcol(okay_, FL_INACTIVE);
-                               }
+       void refresh() {
+               if (okay_) {
+                       if (bp_.buttonStatus(ButtonPolicy::OKAY)) {
+                               fl_activate_object(okay_);
+                               fl_set_object_lcol(okay_, FL_BLACK);
+                       } else {
+                               fl_deactivate_object(okay_);
+                               fl_set_object_lcol(okay_, FL_INACTIVE);
                        }
-                       if (apply_) {
-                               if (bp_.buttonStatus(ButtonPolicy::APPLY)) {
-                                       fl_activate_object(apply_);
-                                       fl_set_object_lcol(apply_, FL_BLACK);
-                               } else {
-                                       fl_deactivate_object(apply_);
-                                       fl_set_object_lcol(apply_, FL_INACTIVE);
-                               }
+               }
+               if (apply_) {
+                       if (bp_.buttonStatus(ButtonPolicy::APPLY)) {
+                               fl_activate_object(apply_);
+                               fl_set_object_lcol(apply_, FL_BLACK);
+                       } else {
+                               fl_deactivate_object(apply_);
+                               fl_set_object_lcol(apply_, FL_INACTIVE);
                        }
-                       if (undo_all_) {
-                               if (bp_.buttonStatus(ButtonPolicy::UNDO_ALL)) {
-                                       fl_activate_object(undo_all_);
-                                       fl_set_object_lcol(undo_all_, FL_BLACK);
-                               } else {
-                                       fl_deactivate_object(undo_all_);
-                                       fl_set_object_lcol(undo_all_,
-                                                          FL_INACTIVE);
-                               }
+               }
+               if (undo_all_) {
+                       if (bp_.buttonStatus(ButtonPolicy::UNDO_ALL)) {
+                               fl_activate_object(undo_all_);
+                               fl_set_object_lcol(undo_all_, FL_BLACK);
+                       } else {
+                               fl_deactivate_object(undo_all_);
+                               fl_set_object_lcol(undo_all_,
+                                                  FL_INACTIVE);
                        }
-                       if (cancel_) {
-                               if (bp_.buttonStatus(ButtonPolicy::CANCEL)) {
-                                       fl_set_object_label(cancel_,
-                                                           cancel_label);
-                               } else {
-                                       fl_set_object_label(cancel_,
-                                                           close_label);
-                               }
+               }
+               if (cancel_) {
+                       if (bp_.buttonStatus(ButtonPolicy::CANCEL)) {
+                               fl_set_object_label(cancel_,
+                                                   cancel_label);
+                       } else {
+                               fl_set_object_label(cancel_,
+                                                   close_label);
                        }
-                       if (!read_only_.empty()) {
-                               if (bp_.isReadOnly()) {
-                                       for (std::list<FL_OBJECT *>::iterator
-                                                    iter = read_only_.begin();
-                                            iter != read_only_.end();
-                                            ++iter) {
-                                               fl_deactivate_object(*iter);
-                                               fl_set_object_lcol(*iter,
-                                                                  FL_INACTIVE);
-                                       }
-                               } else {
-                                       for (std::list<FL_OBJECT *>::iterator
-                                                    iter = read_only_.begin();
-                                            iter != read_only_.end();
-                                            ++iter) {
-                                               fl_activate_object(*iter);
-                                               fl_set_object_lcol(*iter,
-                                                                  FL_BLACK);
-                                       }
+               }
+               if (!read_only_.empty()) {
+                       if (bp_.isReadOnly()) {
+                               std::list<FL_OBJECT *>::iterator
+                                       end = read_only_.end();
+                               for (std::list<FL_OBJECT *>::iterator
+                                    iter = read_only_.begin();
+                                    iter != end;
+                                    ++iter) {
+                                       fl_deactivate_object(*iter);
+                                       fl_set_object_lcol(*iter,
+                                                          FL_INACTIVE);
+                               }
+                       } else {
+                               std::list<FL_OBJECT *>::iterator
+                                       end = read_only_.end();
+                               for (std::list<FL_OBJECT *>::iterator
+                                    iter = read_only_.begin();
+                                    iter != end;
+                                    ++iter) {
+                                       fl_activate_object(*iter);
+                                       fl_set_object_lcol(*iter,
+                                                          FL_BLACK);
                                }
                        }
                }
-       //@}
+       }
 private:
        ///
        Policy bp_;
-       /**@name Button Widgets */
-       //@{
        ///
        FL_OBJECT * okay_;
        ///
@@ -206,14 +213,10 @@ private:
        FL_OBJECT * undo_all_;
        /// List of items to be deactivated when in one of the read-only states
        std::list<FL_OBJECT *> read_only_;
-       //@}
-       /**@name Cancel/Close Button Labels */
-       //@{
        ///
        char const * cancel_label;
        ///
        char const * close_label;       
-       //@}
 };
 
 #endif