]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/ButtonPolicy.h
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / ButtonPolicy.h
index 1f39f1b8339ff35e009eaf18015d4ab4558f7289..43f384baa8b9869a524e4123907c12b61d1eba19 100644 (file)
@@ -15,9 +15,6 @@
 #ifndef BUTTONPOLICY_H
 #define BUTTONPOLICY_H
 
 #ifndef BUTTONPOLICY_H
 #define BUTTONPOLICY_H
 
-#include <vector>
-#include <iosfwd>
-
 namespace lyx {
 namespace frontend {
 
 namespace lyx {
 namespace frontend {
 
@@ -26,7 +23,7 @@ namespace frontend {
     dialogs. Only the policy is implemented here.  Separate ButtonController
     classes are needed for each GUI implementation.
 
     dialogs. Only the policy is implemented here.  Separate ButtonController
     classes are needed for each GUI implementation.
 
-               Policy                    | ReadOnly | Apply Button | Repeated Apply
+    Policy                    | ReadOnly | Apply Button | Repeated Apply
     ========================================================================
     OkCancel                  |     N    |      N        |      -
     OkCancelReadOnly          |     Y    |      N        |      -
     ========================================================================
     OkCancel                  |     N    |      N        |      -
     OkCancelReadOnly          |     Y    |      N        |      -
@@ -34,6 +31,7 @@ namespace frontend {
     OkApplyCancelReadOnly     |     Y    |      Y        |      Y
     NoRepeatedApply           |     N    |      Y        |      N
     NoRepeatedApplyReadOnly   |     Y    |      Y        |      N
     OkApplyCancelReadOnly     |     Y    |      Y        |      Y
     NoRepeatedApply           |     N    |      Y        |      N
     NoRepeatedApplyReadOnly   |     Y    |      Y        |      N
+    OkApplyCancelAutoReadOnly |     Y    |      Y        |      Y
     Preferences               |     N    |      Y        | No (Ok-Close)
     Ignorant                  |    N/A   |     N/A       |     N/A
     ========================================================================
     Preferences               |     N    |      Y        | No (Ok-Close)
     Ignorant                  |    N/A   |     N/A       |     N/A
     ========================================================================
@@ -63,7 +61,8 @@ namespace frontend {
     The IgnorantPolicy is a special case that allows anything.
  */
 
     The IgnorantPolicy is a special case that allows anything.
  */
 
-class ButtonPolicy {
+class ButtonPolicy
+{
 public:
 
        // The various poicies
 public:
 
        // The various poicies
@@ -74,7 +73,7 @@ public:
                        This is based on the value of the bool state of the Button::CANCEL.
                        true == Cancel, false == Close
                 */
                        This is based on the value of the bool state of the Button::CANCEL.
                        true == Cancel, false == Close
                 */
-    OkCancelPolicy,
+               OkCancelPolicy,
 
 
                /** Ok and Cancel buttons for dialogs where read-only operation is blocked.
 
 
                /** Ok and Cancel buttons for dialogs where read-only operation is blocked.
@@ -123,7 +122,7 @@ public:
                OkApplyCancelReadOnlyPolicy,
 
                /** Ok, Apply and Cancel buttons for dialogs where repeated
                OkApplyCancelReadOnlyPolicy,
 
                /** Ok, Apply and Cancel buttons for dialogs where repeated
*    Apply is allowed.
                      Apply is allowed.
                        Note: This scheme supports the relabelling of Cancel to Close
                        and vice versa.
                        This is based on the value of the bool state of the Button::CANCEL.
                        Note: This scheme supports the relabelling of Cancel to Close
                        and vice versa.
                        This is based on the value of the bool state of the Button::CANCEL.
@@ -139,6 +138,14 @@ public:
                 */
                NoRepeatedApplyPolicy,
 
                 */
                NoRepeatedApplyPolicy,
 
+               /** Ok, Apply and Cancel buttons and an AutoApply checkbox.
+                       Note: This scheme supports the relabelling of Cancel to Close
+                       and vice versa.
+                       This is based on the value of the bool state of the Button::CANCEL.
+                       true == Cancel, false == Close
+                */
+               OkApplyCancelAutoReadOnlyPolicy,
+
                /** Defines the policy used by the Preferences dialog.
                        Four buttons: Ok (Save), Apply, Cancel/Close, Restore.
                        Note: This scheme supports the relabelling of Cancel to Close
                /** Defines the policy used by the Preferences dialog.
                        Four buttons: Ok (Save), Apply, Cancel/Close, Restore.
                        Note: This scheme supports the relabelling of Cancel to Close
@@ -159,6 +166,10 @@ public:
 
        /// Constructor
        explicit ButtonPolicy(Policy policy);
 
        /// Constructor
        explicit ButtonPolicy(Policy policy);
+       /// Destructor
+       ~ButtonPolicy();
+       ///
+       void setPolicy(Policy policy);
 
        /** The various possible state names.
            Not all state-machines have this many states.  However, we need
 
        /** The various possible state names.
            Not all state-machines have this many states.  However, we need
@@ -174,6 +185,10 @@ public:
                ///
                APPLIED,
                ///
                ///
                APPLIED,
                ///
+               AUTOAPPLY_INITIAL,
+               ///
+               AUTOAPPLY_CHANGED,
+               ///
                RO_INITIAL,
                ///
                RO_VALID,
                RO_INITIAL,
                ///
                RO_VALID,
@@ -182,25 +197,29 @@ public:
                ///
                RO_APPLIED,
                ///
                ///
                RO_APPLIED,
                ///
+               RO_AUTOAPPLY,
+               ///
                BOGUS = 55
        };
 
        /// The various button types.
        enum Button {
                ///
                BOGUS = 55
        };
 
        /// The various button types.
        enum Button {
                ///
-               CLOSE    = 0,  // Not a real button, but effectively !CANCEL
+               CLOSE     = 0,  // Not a real button, but effectively !CANCEL
                ///
                ///
-               OKAY     = 1,
+               OKAY      = 1,
                ///
                ///
-               APPLY    = 2,
+               APPLY     = 2,
                ///
                ///
-               CANCEL   = 4,
+               CANCEL    = 4,
                ///
                ///
-               RESTORE  = 8
+               RESTORE   = 8,
+               ///
+               AUTOAPPLY = 16  // This is usually a checkbox
        };
        ///
        static const Button ALL_BUTTONS =
        };
        ///
        static const Button ALL_BUTTONS =
-               Button(OKAY | APPLY | CANCEL | RESTORE);
+               Button(OKAY | APPLY | CANCEL | RESTORE | AUTOAPPLY);
 
        /** State machine inputs.
            All the policies so far have both CANCEL and HIDE always going to
 
        /** State machine inputs.
            All the policies so far have both CANCEL and HIDE always going to
@@ -223,6 +242,8 @@ public:
                SMI_CANCEL,
                /// a restore action has happened
                SMI_RESTORE,
                SMI_CANCEL,
                /// a restore action has happened
                SMI_RESTORE,
+               /// apply auto-apply
+               SMI_AUTOAPPLY,
                /// the dialog has been hidden
                SMI_HIDE,
                /// the dialog contents are read-only
                /// the dialog has been hidden
                SMI_HIDE,
                /// the dialog contents are read-only
@@ -249,40 +270,16 @@ public:
        bool isReadOnly() const;
 
 private:
        bool isReadOnly() const;
 
 private:
-       ///
-       Policy policy_;
-
-       /// Transition map of the state machine.
-       typedef std::vector<State> StateArray;
-       ///
-       typedef std::vector<StateArray> StateMachine;
-       /// The state outputs are the status of the buttons.
-       typedef std::vector<int> StateOutputs;
-
-       /// Current state.
-       State state_;
-       /// Which buttons are active for a given state.
-       StateOutputs outputs_;
-       ///
-       StateMachine state_machine_;
-
-private:
-       // Helpers
-       void nextState(SMInput input);
-
-       void initOkCancel();
-       void initOkCancelReadOnly();
-       void initNoRepeatedApplyReadOnly();
-       void initOkApplyCancelReadOnly();
-       void initOkApplyCancel();
-       void initNoRepeatedApply();
-       void initPreferences();
+       /// noncopyable
+       ButtonPolicy(ButtonPolicy const &);
+       void operator=(ButtonPolicy const &);
+       
+       /// pimpl
+       class Private;
+       Private * d;
 };
 
 
 };
 
 
-std::ostream & operator<<(std::ostream & os, ButtonPolicy::State st);
-std::ostream & operator<<(std::ostream & os, ButtonPolicy::SMInput smi);
-
 } // namespace frontend
 } // namespace lyx
 
 } // namespace frontend
 } // namespace lyx