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());
92 /* Action Functions */
93 /// force a refresh of the buttons
97 void input(ButtonPolicy::SMInput in);
108 /// Passthrough function -- returns its input value
109 bool readOnly(bool ro = true);
112 /// Passthrough function -- returns its input value
113 bool valid(bool v = true);
126 FL_OBJECT * undo_all_;
127 /// List of items to be deactivated when in one of the read-only states
128 std::list<FL_OBJECT *> read_only_;
130 char const * cancel_label;
132 char const * close_label;