2 * \file ButtonController.h
5 * ======================================================
7 * LyX, The Document Processor
9 * Copyright 2000-2001 The LyX Team.
11 * ======================================================
13 * \author Allan Rae, rae@lyx.org
16 #ifndef BUTTONCONTROLLER_H
17 #define BUTTONCONTROLLER_H
23 #include "ButtonPolicies.h"
27 /** Abstract base class for a ButtonController
29 * Controls the activation of the OK, Apply and Cancel buttons.
30 * Actually supports 4 buttons in all and it's up to the user to decide on
31 * the activation policy and which buttons correspond to which output of the
33 * Author: Allan Rae <rae@lyx.org>.
34 * This abstract base class stripped of xforms-specific code by
35 * Angus Leeming <a.leeming@ic.ac.uk>
37 class ButtonControllerBase : public boost::noncopyable
41 The cancel/close label entries are _not_ managed within the class
42 thereby allowing you to reassign at will and to use static labels.
43 It also means if you really don't want to have the Cancel button
44 label be different when there is nothing changed in the dialog then
45 you can just assign "Cancel" to both labels. Or even reuse this
46 class for something completely different.
48 ButtonControllerBase(string const & cancel, string const & close);
50 virtual ~ButtonControllerBase() {}
52 virtual void refresh() = 0;
54 virtual ButtonPolicy & bp() = 0;
56 virtual void input(ButtonPolicy::SMInput);
67 /// Passthrough function -- returns its input value
68 bool readOnly(bool = true);
72 void valid(bool = true);
84 template <class BP, class GUIBC>
85 class ButtonController: public GUIBC
89 ButtonController(string const & = _("Cancel"),
90 string const & = _("Close"));
92 virtual ButtonPolicy & bp() { return bp_; }
100 template <class BP, class GUIBC>
101 ButtonController<BP, GUIBC>::ButtonController(string const & cancel,
102 string const & close)
103 : GUIBC(cancel, close)
106 #endif // BUTTONCONTROLLER_H