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 ButtonControllerBase;
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);
37 string const & name() const { return name_; }
39 /** These methods are publicly accessible because they are invoked
53 /** These methods are publicly accessible because they are invoked
54 * by the Dialogs class.
57 /** Some dialogs, eg the Tabular or Preferences dialog, can extract
58 the information they require from the kernel. These dialogs will
59 probably be passed an empty string by the calling Dialogs class.
60 The inset dialogs, however, require information specific to
61 an individual inset. This information will be encoded in "data"
62 and must be translated into a set of parameters that can be
63 updated from the dialog.
65 void show(string const & data = string());
67 void update(string const & data = string());
71 bool isVisible() const;
72 /// (Eg, the GUI colours have been changed.)
76 /** When Applying it's useful to know whether the dialog is about
77 * to close or not (no point refreshing the display for example).
79 bool isClosing() const { return is_closing_; }
81 /// The LyX kernel is made available through this.
82 Kernel & kernel() { return kernel_; }
84 /** Different dialogs will have different
85 Controllers, Views and ButtonControllers.
94 void setController(Controller *);
98 void setButtonController(ButtonControllerBase *);
101 Controller & controller() const;
103 ButtonControllerBase & bc() const;
119 boost::scoped_ptr<ButtonControllerBase> 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 Kernel & kernel() { return parent_.kernel(); }
146 Kernel const & kernel() const { return parent_.kernel(); }
154 class Dialog::View : boost::noncopyable {
157 View(Dialog & parent) : p_(parent) {}
161 /// Apply changes to LyX data from dialog.
162 virtual void apply() = 0;
164 virtual void hide() = 0;
165 /// Redraw the dialog (e.g. if the colors have been remapped).
166 virtual void redraw() {}
167 /// Create the dialog if necessary, update it and display it.
168 virtual void show() = 0;
169 /// Update dialog before/whilst showing it.
170 virtual void update() = 0;
172 virtual bool isVisible() const = 0;
174 /** Defaults to nothing. Can be used by the controller, however, to
175 * indicate to the view that something has changed and that the
176 * dialog therefore needs updating.
178 virtual void partialUpdate(int) {}
181 Dialog & dialog() { return p_; }
183 Dialog const & dialog() const { return p_; }
186 Kernel & kernel() { return p_.kernel(); }
188 Kernel const & kernel() const { return p_.kernel(); }
191 Controller & getController() { return p_.controller(); }
193 Controller const & getController() const { return p_.controller(); }