3 * Controls the activation of the OK, Apply and Cancel buttons.
4 * Actually supports 4 buttons in all and it's up to the user to decide on
5 * the activation policy and which buttons correspond to which output of the
7 * Author: Allan Rae <rae@lyx.org>
9 * ======================================================
11 * LyX, The Document Processor
13 * Copyright 1995 Matthias Ettrich
14 * Copyright 1995-2000 The LyX Team.
16 * This file Copyright 2000
18 * ======================================================
21 #ifndef BUTTONCONTROLLER_H
22 #define BUTTONCONTROLLER_H
24 #include "ButtonPolicies.h"
31 /** General purpose button controller for up to four buttons.
32 Controls the activation of the OK, Apply and Cancel buttons.
33 Actually supports 4 buttons in all and it's up to the user to decide on
34 the activation policy and which buttons correspond to which output of the
36 @author Allan Rae <rae@lyx.org>
37 20001001 Switch from template implementation to taking Policy parameter.
38 Allows FormBase to provide a ButtonController for any dialog.
40 class ButtonController : public noncopyable
44 The cancel/close label entries are _not_ managed within the class
45 thereby allowing you to reassign at will and to use static labels.
46 It also means if you really don't want to have the Cancel button
47 label be different when there is nothing changed in the dialog then
48 you can just assign "Cancel" to both labels. Or even reuse this
49 class for something completely different.
51 ButtonController(ButtonPolicy * bp,
52 char const * cancel, char const * close);
54 // Somebody else owns the FL_OBJECTs we just manipulate them.
56 //~ButtonController() {}
58 /* Initialise Button Functions */
59 /// Call refresh() when finished setting the buttons.
60 void setOK(FL_OBJECT * obj) {
64 void setApply(FL_OBJECT * obj) {
68 void setCancel(FL_OBJECT * obj) {
72 void setUndoAll(FL_OBJECT * obj) {
76 void setCancelTrueLabel(char const * c) {
80 void setCancelFalseLabel(char const * c) {
84 void addReadOnly(FL_OBJECT * obj) {
85 read_only_.push_front(obj);
88 void eraseReadOnly() {
89 read_only_.erase(read_only_.begin(), read_only_.end());
93 void addDontTriggerChange(FL_OBJECT * obj) {
94 dont_trigger_change_.push_back(obj);
97 void eraseDontTriggerChange() {
98 dont_trigger_change_.clear();
101 /* Action Functions */
102 /// force a refresh of the buttons
106 void input(ButtonPolicy::SMInput in);
117 /// Passthrough function -- returns its input value
118 bool readOnly(bool ro = true);
121 /// Passthrough function -- returns its input value
122 bool valid(bool v = true, FL_OBJECT * obj = 0);
135 FL_OBJECT * undo_all_;
136 /// List of items to be deactivated when in one of the read-only states
137 std::list<FL_OBJECT *> read_only_;
138 /// container of items that do not trigger a change in activation status
139 std::vector<FL_OBJECT *> dont_trigger_change_;
141 char const * cancel_label;
143 char const * close_label;