]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xformsBC.h
d65ac7d714b9bf671cd5e9c88fde802202116a1f
[lyx.git] / src / frontends / xforms / xformsBC.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 The LyX Team.
9  *
10  *           This file Copyright 2000
11  *           Allan Rae
12  * ======================================================
13  *
14  * Author: Allan Rae <rae@lyx.org>
15  * Non-xforms-specific code stripped-out and placed in a base class by
16  * Angus Leeming <a.leeming@ic.ac.uk>
17  */
18
19 #ifndef XFORMSBC_H
20 #define XFORMSBC_H
21
22 #include "ButtonController.h"
23 #include <list>
24
25 #ifdef __GNUG__
26 #pragma interface
27 #endif
28
29 /** General purpose button controller for up to four buttons.
30     Controls the activation of the OK, Apply and Cancel buttons.
31     Actually supports 4 buttons in all and it's up to the user to decide on
32     the activation policy and which buttons correspond to which output of the
33     state machine.
34 */
35 class xformsBC : public ButtonControllerBase
36 {
37 public:
38         ///
39         xformsBC(string const &, string const &);
40
41         /* Initialise Button Functions */
42         /// Call refresh() when finished setting the buttons.
43         void setOK(FL_OBJECT * obj) {
44                 okay_ = obj;
45         }
46         ///
47         void setApply(FL_OBJECT * obj) {
48                 apply_ = obj;
49         }
50         ///
51         void setCancel(FL_OBJECT * obj) {
52                 cancel_ = obj;
53         }
54         ///
55         void setUndoAll(FL_OBJECT * obj) {
56                 undo_all_ = obj;
57         }
58         ///
59         void addReadOnly(FL_OBJECT * obj) {
60                 read_only_.push_front(obj);
61         }
62         ///
63         void eraseReadOnly() {
64                 read_only_.erase(read_only_.begin(), read_only_.end());
65         }
66
67         /* Action Functions */
68         /// force a refresh of the buttons
69         virtual void refresh();
70
71 private:
72         ///
73         FL_OBJECT * okay_;
74         ///
75         FL_OBJECT * apply_;
76         ///
77         FL_OBJECT * cancel_;
78         ///
79         FL_OBJECT * undo_all_;
80         /// List of items to be deactivated when in one of the read-only states
81         std::list<FL_OBJECT *> read_only_;
82 };
83
84 #endif // XFORMSBC_H