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"
27 /** \c Dialog collects the different parts of a Model-Controller-View
28 * split of a generic dialog together.
30 class GuiDialog : public QDialog, public Dialog
35 /// \param lv is the access point for the dialog to the LyX kernel.
36 /// \param name is the identifier given to the dialog by its parent
38 explicit GuiDialog(LyXView & lv, std::string const & name);
43 * These methods are publicly accessible because they are invoked
44 * by the View when the user presses... guess what ;-)
46 // Restore button clicked
50 // Apply button clicked
52 // Close button clicked or closed from WindowManager
56 /** Check whether we may apply our data.
58 * The buttons are disabled if not and (re-)enabled if yes.
61 void setButtonsValid(bool valid);
63 /** \name Dialog Components
64 * Methods to access the various components making up a dialog.
67 ButtonController const & bc() const { return bc_; }
68 ButtonController & bc() { return bc_; }
71 void setViewTitle(docstring const & title);
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 updateContents() {}
82 void closeEvent(QCloseEvent *);
84 void showEvent(QShowEvent *);
88 virtual void hideView();
89 /// Create the dialog if necessary, update it and display it.
90 virtual void showView();
92 virtual bool isVisibleView() const;
93 /// is the dialog currently valid ?
94 virtual bool isValid() { return true; }
97 /** \name Container Access
98 * These methods are publicly accessible because they are invoked
99 * by the parent container acting on commands from the LyX kernel.
102 /// \param data is a string encoding of the data to be displayed.
103 /// It is passed to the Controller to be translated into a useable form.
104 void showData(std::string const & data);
105 void updateData(std::string const & data);
109 /** This function is called, for example, if the GUI colours
112 void redraw() { redrawView(); }
115 /** When applying, it's useful to know whether the dialog is about
116 * to close or not (no point refreshing the display for example).
118 bool isClosing() const { return is_closing_; }
120 /** \name Dialog Specialization
121 * Methods to set the Controller and View and so specialise
122 * to a particular dialog.
125 /// \param ptr is stored and destroyed by \c Dialog.
126 void setController(Controller * ptr, bool destroy = true);
129 /** \name Dialog Components
130 * Methods to access the various components making up a dialog.
133 virtual Controller & controller() { return *controller_; }
136 /** Defaults to nothing. Can be used by the Controller, however, to
137 * indicate to the View that something has changed and that the
138 * dialog therefore needs updating.
139 * \param id identifies what should be updated.
141 virtual void partialUpdateView(int /*id*/) {}
144 std::string name() const { return name_; }
150 /// Update the display of the dialog whilst it is still visible.
151 virtual void updateView();
153 ButtonController bc_;
154 /// are we updating ?
158 /** The Dialog's name is the means by which a dialog identifies
159 * itself to the kernel.
162 Controller * controller_;
163 bool destroy_controller_;
164 LyXView * lyxview_; // FIXME: replace by moving to constructor
167 } // namespace frontend
170 #endif // GUIDIALOG_H