+// -*- C++ -*-
/* This file is part of
* ======================================================
*
#include <list>
+#include "gettext.h"
+#include "ButtonControllerBase.h"
+
template <class Button, class Widget>
class GuiBC : public ButtonControllerBase
{
///
void setCancel(Button * obj) { cancel_ = obj; }
///
- void setUndoAll(Button * obj) { undo_all_ = obj; }
+ void setRestore(Button * obj) { restore_ = obj; }
///
void addReadOnly(Widget * obj) { read_only_.push_back(obj); }
///
void eraseReadOnly() { read_only_.clear(); }
- /// Refresh the widgets status.
+ /// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
void refresh();
+ /// Refresh the status of any widgets in the read_only list
+ void refreshReadOnly();
private:
/// Enable/Disable a widget
Button * okay_;
Button * apply_;
- Button * undo_all_;
Button * cancel_;
+ Button * restore_;
typedef std::list<Widget *> Widgets;
Widgets read_only_;
template <class Button, class Widget>
GuiBC<Button, Widget>::GuiBC(string const & cancel, string const & close)
- : ButtonControllerBase(cancel, close)
- , okay_(0), apply_(0), cancel_(0), undo_all_(0)
+ : ButtonControllerBase(cancel, close),
+ okay_(0), apply_(0), cancel_(0), restore_(0)
{}
bool const enabled = bp().buttonStatus(ButtonPolicy::APPLY);
setButtonEnabled(apply_, enabled);
}
- if (undo_all_) {
- bool const enabled = bp().buttonStatus(ButtonPolicy::UNDO_ALL);
- setButtonEnabled(undo_all_, enabled);
+ if (restore_) {
+ bool const enabled = bp().buttonStatus(ButtonPolicy::RESTORE);
+ setButtonEnabled(restore_, enabled);
}
if (cancel_) {
bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
else
setButtonLabel(cancel_, close_label_);
}
+}
- // Enable/Disable read-only handled widgets.
- if (!read_only_.empty()) {
- bool const enable = !bp().isReadOnly();
- Widgets::const_iterator end = read_only_.end();
- Widgets::const_iterator iter = read_only_.begin();
- for (; iter != end; ++iter) {
- setWidgetEnabled(*iter, enable);
- }
- }
+template <class Button, class Widget>
+void GuiBC<Button, Widget>::refreshReadOnly()
+{
+ if (read_only_.empty()) return;
+
+ bool const enable = !bp().isReadOnly();
+ Widgets::const_iterator end = read_only_.end();
+ Widgets::const_iterator iter = read_only_.begin();
+ for (; iter != end; ++iter) {
+ setWidgetEnabled(*iter, enable);
+ }
}