3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
15 #include "ButtonController.h"
22 Dialog::Dialog(LyXView & lv, string const & name)
23 : is_closing_(false), kernel_(lv), name_(name),
24 bc_ptr_(new ButtonController)
32 void Dialog::ApplyButton()
39 void Dialog::OKButton()
49 void Dialog::CancelButton()
56 void Dialog::RestoreButton()
58 // Tell the kernel that a request to refresh the dialog's contents
59 // has been received. It's up to the kernel to supply the necessary
60 // info by calling Dialog::update().
61 kernel().updateDialog(name_);
66 void Dialog::show(string const & data)
68 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
71 if (!controller().initialiseParams(data)) {
72 lyxerr << "Dialog \"" << name_
73 << "\" failed to translate the data "
74 "string passed to show()" << std::endl;
78 bc().readOnly(kernel().isBufferReadonly());
81 // The widgets may not be valid, so refresh the button controller
86 void Dialog::update(string const & data)
88 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
91 if (!controller().initialiseParams(data)) {
92 lyxerr << "Dialog \"" << name_
93 << "\" failed to translate the data "
94 "string passed to update()" << std::endl;
98 bc().readOnly(kernel().isBufferReadonly());
101 // The widgets may not be valid, so refresh the button controller
108 if (!view().isVisible())
111 controller().clearParams();
113 kernel().disconnect(name());
119 if (controller().isBufferDependent()) {
120 if (!kernel().isBufferAvailable() ||
121 kernel().isBufferReadonly())
126 controller().dispatchParams();
128 if (controller().disconnectOnApply() && !is_closing_) {
129 kernel().disconnect(name());
130 controller().initialiseParams(string());
136 bool Dialog::isVisible() const
138 return view().isVisible();
142 void Dialog::redraw()
148 ButtonController & Dialog::bc() const
150 BOOST_ASSERT(bc_ptr_.get());
151 return *bc_ptr_.get();
155 void Dialog::setController(Controller * i)
157 BOOST_ASSERT(i && !controller_ptr_.get());
158 controller_ptr_.reset(i);
162 void Dialog::setView(View * v)
164 BOOST_ASSERT(v && !view_ptr_.get());
169 Dialog::Controller::Controller(Dialog & parent)
174 Dialog::Controller & Dialog::controller() const
176 BOOST_ASSERT(controller_ptr_.get());
177 return *controller_ptr_.get();
181 Dialog::View::View(Dialog & parent, string title) :
182 p_(parent), title_(title)
186 Dialog::View & Dialog::view() const
188 BOOST_ASSERT(view_ptr_.get());
189 return *view_ptr_.get();
193 void Dialog::View::setTitle(string const & newtitle)
199 string const & Dialog::View::getTitle() const
205 void Dialog::View::partialUpdate(int)