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
53 /** Check whether we may apply our data.
55 * The buttons are disabled if not and (re-)enabled if yes.
58 void setButtonsValid(bool valid);
60 /** \name Dialog Components
61 * Methods to access the various components making up a dialog.
64 ButtonController const & bc() const { return bc_; }
65 ButtonController & bc() { return bc_; }
68 void setViewTitle(docstring const & title);
71 /// the dialog has changed contents
72 virtual void changed();
74 /// default: do nothing
75 virtual void applyView() {}
76 /// default: do nothing
77 virtual void updateContents() {}
81 virtual void hideView();
82 /// Create the dialog if necessary, update it and display it.
83 virtual void showView();
85 virtual bool isVisibleView() const;
86 /// is the dialog currently valid ?
87 virtual bool isValid() { return true; }
90 /** \name Container Access
91 * These methods are publicly accessible because they are invoked
92 * by the parent container acting on commands from the LyX kernel.
95 /// \param data is a string encoding of the data to be displayed.
96 /// It is passed to the Controller to be translated into a useable form.
97 void showData(std::string const & data);
98 void updateData(std::string const & data);
102 /** This function is called, for example, if the GUI colours
105 void redraw() { redrawView(); }
108 /** When applying, it's useful to know whether the dialog is about
109 * to close or not (no point refreshing the display for example).
111 bool isClosing() const { return is_closing_; }
113 /** \name Dialog Specialization
114 * Methods to set the Controller and View and so specialise
115 * to a particular dialog.
118 /// \param ptr is stored and destroyed by \c Dialog.
119 void setController(Controller * ptr);
122 /** \name Dialog Components
123 * Methods to access the various components making up a dialog.
126 virtual Controller & controller() { return *controller_; }
129 /** Defaults to nothing. Can be used by the Controller, however, to
130 * indicate to the View that something has changed and that the
131 * dialog therefore needs updating.
132 * \param id identifies what should be updated.
134 virtual void partialUpdateView(int /*id*/) {}
137 std::string name() const { return name_; }
143 /// Update the display of the dialog whilst it is still visible.
144 virtual void updateView();
146 ButtonController bc_;
147 /// are we updating ?
151 /** The Dialog's name is the means by which a dialog identifies
152 * itself to the kernel.
155 Controller * controller_;
156 LyXView * lyxview_; // FIXME: replace by moving to constructor
159 } // namespace frontend
162 #endif // GUIDIALOG_H