3 #include FORMS_H_LOCATION
9 #include "ButtonController.h"
10 #include "support/LAssert.h"
13 ButtonController::ButtonController(ButtonPolicy * bp,
14 char const * cancel, char const * close)
15 : bp_(bp), okay_(0), apply_(0), cancel_(0), undo_all_(0),
16 read_only_(), cancel_label(cancel), close_label(close)
22 void ButtonController::refresh()
25 if (bp_->buttonStatus(ButtonPolicy::OKAY)) {
26 fl_activate_object(okay_);
27 fl_set_object_lcol(okay_, FL_BLACK);
29 fl_deactivate_object(okay_);
30 fl_set_object_lcol(okay_, FL_INACTIVE);
34 if (bp_->buttonStatus(ButtonPolicy::APPLY)) {
35 fl_activate_object(apply_);
36 fl_set_object_lcol(apply_, FL_BLACK);
38 fl_deactivate_object(apply_);
39 fl_set_object_lcol(apply_, FL_INACTIVE);
43 if (bp_->buttonStatus(ButtonPolicy::UNDO_ALL)) {
44 fl_activate_object(undo_all_);
45 fl_set_object_lcol(undo_all_, FL_BLACK);
47 fl_deactivate_object(undo_all_);
48 fl_set_object_lcol(undo_all_,
53 if (bp_->buttonStatus(ButtonPolicy::CANCEL)) {
54 fl_set_object_label(cancel_,
57 fl_set_object_label(cancel_,
61 if (!read_only_.empty()) {
62 if (bp_->isReadOnly()) {
63 std::list<FL_OBJECT *>::iterator
64 end = read_only_.end();
65 for (std::list<FL_OBJECT *>::iterator
66 iter = read_only_.begin();
69 fl_deactivate_object(*iter);
70 fl_set_object_lcol(*iter,
74 std::list<FL_OBJECT *>::iterator
75 end = read_only_.end();
76 for (std::list<FL_OBJECT *>::iterator
77 iter = read_only_.begin();
80 fl_activate_object(*iter);
81 fl_set_object_lcol(*iter,
89 void ButtonController::input(ButtonPolicy::SMInput in)
96 void ButtonController::ok()
98 input(ButtonPolicy::SMI_OKAY);
102 void ButtonController::apply()
104 input(ButtonPolicy::SMI_APPLY);
108 void ButtonController::cancel()
110 input(ButtonPolicy::SMI_CANCEL);
114 void ButtonController::undoAll()
116 input(ButtonPolicy::SMI_UNDO_ALL);
120 void ButtonController::hide()
122 input(ButtonPolicy::SMI_HIDE);
126 bool ButtonController::readOnly(bool ro)
129 input(ButtonPolicy::SMI_READ_ONLY);
131 input(ButtonPolicy::SMI_READ_WRITE);
137 void ButtonController::readWrite()
143 bool ButtonController::valid(bool v)
146 input(ButtonPolicy::SMI_VALID);
148 input(ButtonPolicy::SMI_INVALID);
154 void ButtonController::invalid()