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);
39 // dialog closed from WM
41 // Restore button clicked
45 // Apply button clicked
47 // Close button clicked
52 * These methods are publicly accessible because they are invoked
53 * by the View when the user presses... guess what ;-)
62 /** Check whether we may apply our data.
64 * The buttons are disabled if not and (re-)enabled if yes.
67 void setButtonsValid(bool valid);
69 /** \name Dialog Components
70 * Methods to access the various components making up a dialog.
73 ButtonController const & bc() const { return bc_; }
74 ButtonController & bc() { return bc_; }
77 void setViewTitle(docstring const & title);
80 bool readOnly() const;
82 /// the dialog has changed contents
83 virtual void changed();
85 /// default: do nothing
86 virtual void applyView() {}
87 /// default: do nothing
88 virtual void update_contents() {}
92 virtual void hideView();
93 /// Create the dialog if necessary, update it and display it.
94 virtual void showView();
96 virtual bool isVisibleView() const;
97 /// is the dialog currently valid ?
98 virtual bool isValid() { return true; }
101 /** \name Container Access
102 * These methods are publicly accessible because they are invoked
103 * by the parent container acting on commands from the LyX kernel.
106 /// \param data is a string encoding of the data to be displayed.
107 /// It is passed to the Controller to be translated into a useable form.
108 void showData(std::string const & data);
109 void updateData(std::string const & data);
113 /** This function is called, for example, if the GUI colours
116 void redraw() { redrawView(); }
119 /** When applying, it's useful to know whether the dialog is about
120 * to close or not (no point refreshing the display for example).
122 bool isClosing() const { return is_closing_; }
124 /** \name Dialog Specialization
125 * Methods to set the Controller and View and so specialise
126 * to a particular dialog.
129 /// \param ptr is stored and destroyed by \c Dialog.
130 void setController(Controller * ptr);
133 /** \name Dialog Components
134 * Methods to access the various components making up a dialog.
137 virtual Controller & controller() const { return *controller_; }
140 /** Defaults to nothing. Can be used by the Controller, however, to
141 * indicate to the View that something has changed and that the
142 * dialog therefore needs updating.
143 * \param id identifies what should be updated.
145 virtual void partialUpdateView(int /*id*/) {}
148 std::string name() const { return name_; }
154 /// Update the display of the dialog whilst it is still visible.
155 virtual void updateView();
157 ButtonController bc_;
158 /// are we updating ?
162 /** The Dialog's name is the means by which a dialog identifies
163 * itself to the kernel.
166 Controller * controller_;
167 LyXView * lyxview_; // FIXME: replace by moving to constructor
170 } // namespace frontend
173 #endif // GUIDIALOG_H