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