4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS
18 #include <boost/shared_ptr.hpp>
21 class ButtonController;
24 struct CheckedWidget {
26 virtual ~CheckedWidget();
28 /** Returns true if the widget is in a valid state.
29 * Might also change the visual appearance of the widget,
30 * to reflect this state.
32 virtual bool check() const = 0;
38 BCView(ButtonController const &);
42 virtual void refresh() = 0;
44 virtual void refreshReadOnly() = 0;
46 ButtonPolicy & bp() const;
48 void addCheckedWidget(CheckedWidget * ptr);
55 typedef boost::shared_ptr<CheckedWidget> checked_widget_ptr;
56 typedef std::list<checked_widget_ptr> checked_widget_list;
58 checked_widget_list checked_widgets;
60 ButtonController const & parent;
64 /** A templatised instantiation of the ButtonController's View requiring the
65 * gui-frontend widgets.
67 template <class Button, class Widget>
68 class GuiBC : public BCView {
71 GuiBC(ButtonController const & parent,
72 string const & cancel, string const & close);
75 void setOK(Button * obj) { okay_ = obj; }
77 void setApply(Button * obj) { apply_ = obj; }
79 void setCancel(Button * obj) { cancel_ = obj; }
81 void setRestore(Button * obj) { restore_ = obj; }
83 void addReadOnly(Widget * obj) { read_only_.push_back(obj); }
85 void eraseReadOnly() { read_only_.clear(); }
87 /// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
89 /// Refresh the status of any widgets in the read_only list
90 void refreshReadOnly();
92 /// Enable/Disable a widget
93 virtual void setWidgetEnabled(Widget * obj, bool enable) = 0;
94 /// Enable/Disable a button
95 virtual void setButtonEnabled(Button * obj, bool enable) = 0;
96 /// Set the Label on the button
97 virtual void setButtonLabel(Button * obj, string const & label) = 0;
107 typedef std::list<Widget *> Widgets;
112 #include "BCView.tmpl"