3 * \file ButtonControllerBase.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS
12 #ifndef BUTTONCONTROLLERBASE_H
13 #define BUTTONCONTROLLERBASE_H
16 #include "ButtonPolicies.h"
19 #include <boost/shared_ptr.hpp>
22 struct CheckedWidget {
24 virtual ~CheckedWidget();
26 /** Returns true if the widget is in a valid state.
27 * Might also change the visual appearance of the widget,
28 * to reflect this state.
30 virtual bool check() const = 0;
34 /** Abstract base class for a ButtonController
36 * Controls the activation of the OK, Apply and Cancel buttons.
37 * Actually supports 4 buttons in all and it's up to the user to decide on
38 * the activation policy and which buttons correspond to which output of the
40 * Author: Allan Rae <rae@lyx.org>.
41 * This abstract base class stripped of xforms-specific code by
42 * Angus Leeming <leeming@lyx.org>
44 class ButtonControllerBase : boost::noncopyable {
47 The cancel/close label entries are _not_ managed within the class
48 thereby allowing you to reassign at will and to use static labels.
49 It also means if you really don't want to have the Cancel button
50 label be different when there is nothing changed in the dialog then
51 you can just assign "Cancel" to both labels. Or even reuse this
52 class for something completely different.
54 ButtonControllerBase(string const & cancel, string const & close);
56 virtual ~ButtonControllerBase() {}
58 virtual ButtonPolicy & bp() = 0;
60 virtual void input(ButtonPolicy::SMInput);
72 virtual void refresh() = 0;
74 virtual void refreshReadOnly() = 0;
76 /// Passthrough function -- returns its input value
77 bool readOnly(bool = true);
81 void valid(bool = true);
85 void addCheckedWidget(CheckedWidget * ptr);
97 typedef boost::shared_ptr<CheckedWidget> checked_widget_ptr;
98 typedef std::list<checked_widget_ptr> checked_widget_list;
100 checked_widget_list checked_widgets;
103 #endif // BUTTONCONTROLLERBASE_H