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.
16 #include "ButtonController.h"
24 /** \c Dialog collects the different parts of a Model-Controller-View
25 * split of a generic dialog together.
27 class GuiDialog : public QDialog, public Dialog
32 /// \param lv is the access point for the dialog to the LyX kernel.
33 /// \param name is the identifier given to the dialog by its parent
35 explicit GuiDialog(LyXView & lv, std::string const & name);
40 * These methods are publicly accessible because they are invoked
41 * by the View when the user presses... guess what ;-)
43 // Restore button clicked
47 // Apply button clicked
49 // Close button clicked or closed from WindowManager
54 /** Check whether we may apply our data.
56 * The buttons are disabled if not and (re-)enabled if yes.
59 void setButtonsValid(bool valid);
61 /** \name Dialog Components
62 * Methods to access the various components making up a dialog.
65 ButtonController const & bc() const { return bc_; }
66 ButtonController & bc() { return bc_; }
69 void setViewTitle(docstring const & title);
72 bool readOnly() const;
74 /// the dialog has changed contents
75 virtual void changed();
77 /// default: do nothing
78 virtual void applyView() {}
79 /// default: do nothing
80 virtual void update_contents() {}
84 virtual void hideView();
85 /// Create the dialog if necessary, update it and display it.
86 virtual void showView();
88 virtual bool isVisibleView() const;
89 /// is the dialog currently valid ?
90 virtual bool isValid() { return true; }
93 /** \name Container Access
94 * These methods are publicly accessible because they are invoked
95 * by the parent container acting on commands from the LyX kernel.
98 /// \param data is a string encoding of the data to be displayed.
99 /// It is passed to the Controller to be translated into a useable form.
100 void showData(std::string const & data);
101 void updateData(std::string const & data);
105 /** This function is called, for example, if the GUI colours
108 void redraw() { redrawView(); }
111 /** When applying, it's useful to know whether the dialog is about
112 * to close or not (no point refreshing the display for example).
114 bool isClosing() const { return is_closing_; }
116 /** \name Dialog Specialization
117 * Methods to set the Controller and View and so specialise
118 * to a particular dialog.
121 /// \param ptr is stored and destroyed by \c Dialog.
122 void setController(Controller * ptr);
125 /** \name Dialog Components
126 * Methods to access the various components making up a dialog.
129 virtual Controller & controller() const { return *controller_; }
132 /** Defaults to nothing. Can be used by the Controller, however, to
133 * indicate to the View that something has changed and that the
134 * dialog therefore needs updating.
135 * \param id identifies what should be updated.
137 virtual void partialUpdateView(int /*id*/) {}
140 std::string name() const { return name_; }
146 /// Update the display of the dialog whilst it is still visible.
147 virtual void updateView();
149 ButtonController bc_;
150 /// are we updating ?
154 /** The Dialog's name is the means by which a dialog identifies
155 * itself to the kernel.
158 Controller * controller_;
159 LyXView * lyxview_; // FIXME: replace by moving to constructor
162 } // namespace frontend
165 #endif // GUIDIALOG_H