4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
11 * The dialogs use a Model-Controller-View split, instantiated here
21 #include <boost/utility.hpp>
22 #include <boost/scoped_ptr.hpp>
26 class ButtonController;
29 class Dialog : boost::noncopyable {
31 /** the Dialog's "name" is the means with which a dialog identifies
32 * itself to the kernel.
34 Dialog(LyXView &, string const & name);
39 string const & name() const { return name_; }
41 /** These methods are publicly accessible because they are invoked
55 /** These methods are publicly accessible because they are invoked
56 * by the Dialogs class.
59 /** Some dialogs, eg the Tabular or Preferences dialog, can extract
60 the information they require from the kernel. These dialogs will
61 probably be passed an empty string by the calling Dialogs class.
62 The inset dialogs, however, require information specific to
63 an individual inset. This information will be encoded in "data"
64 and must be translated into a set of parameters that can be
65 updated from the dialog.
67 void show(string const & data = string());
69 void update(string const & data = string());
73 bool isVisible() const;
74 /// (Eg, the GUI colours have been changed.)
78 /** When Applying it's useful to know whether the dialog is about
79 * to close or not (no point refreshing the display for example).
81 bool isClosing() const { return is_closing_; }
83 /// The LyX kernel is made available through this.
84 Kernel & kernel() { return kernel_; }
86 /** Different dialogs will have different
87 Controllers, Views and ButtonControllers.
96 void setController(Controller *);
101 Controller & controller() const;
103 ButtonController & bc() const;
119 boost::scoped_ptr<ButtonController> bc_ptr_;
121 boost::scoped_ptr<Controller> controller_ptr_;
123 boost::scoped_ptr<View> view_ptr_;
127 class Dialog::Controller : boost::noncopyable {
130 Controller(Dialog & parent) : parent_(parent) {}
132 virtual ~Controller() {}
134 virtual void initialiseParams(string const & data) = 0;
136 virtual void clearParams() = 0;
138 virtual void dispatchParams() = 0;
140 virtual bool isBufferDependent() const = 0;
142 virtual bool disconnectOnApply() const { return false; }
144 Dialog & dialog() { return parent_; }
146 Dialog const & dialog() const { return parent_; }
148 Kernel & kernel() { return parent_.kernel(); }
150 Kernel const & kernel() const { return parent_.kernel(); }
158 class Dialog::View : boost::noncopyable {
161 View(Dialog & parent) : p_(parent) {}
165 /// Apply changes to LyX data from dialog.
166 virtual void apply() = 0;
168 virtual void hide() = 0;
169 /// Redraw the dialog (e.g. if the colors have been remapped).
170 virtual void redraw() {}
171 /// Create the dialog if necessary, update it and display it.
172 virtual void show() = 0;
173 /// Update dialog before/whilst showing it.
174 virtual void update() = 0;
176 virtual bool isVisible() const = 0;
178 /** Defaults to nothing. Can be used by the controller, however, to
179 * indicate to the view that something has changed and that the
180 * dialog therefore needs updating.
182 virtual void partialUpdate(int) {}
185 Dialog & dialog() { return p_; }
187 Dialog const & dialog() const { return p_; }
190 Kernel & kernel() { return p_.kernel(); }
192 Kernel const & kernel() const { return p_.kernel(); }
195 Controller & getController() { return p_.controller(); }
197 Controller const & getController() const { return p_.controller(); }
200 ButtonController & bc() { return p_.bc(); }
202 ButtonController const & bc() const { return p_.bc(); }