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 << "\" could not be initialized" << std::endl;
97 bc().readOnly(kernel().isBufferReadonly());
100 // The widgets may not be valid, so refresh the button controller
107 if (!view().isVisible())
110 controller().clearParams();
112 kernel().disconnect(name());
118 if (controller().isBufferDependent()) {
119 if (!kernel().isBufferAvailable() ||
120 kernel().isBufferReadonly())
125 controller().dispatchParams();
127 if (controller().disconnectOnApply() && !is_closing_) {
128 kernel().disconnect(name());
129 controller().initialiseParams(string());
135 bool Dialog::isVisible() const
137 return view().isVisible();
141 void Dialog::redraw()
147 ButtonController & Dialog::bc() const
149 BOOST_ASSERT(bc_ptr_.get());
150 return *bc_ptr_.get();
154 void Dialog::setController(Controller * i)
156 BOOST_ASSERT(i && !controller_ptr_.get());
157 controller_ptr_.reset(i);
161 void Dialog::setView(View * v)
163 BOOST_ASSERT(v && !view_ptr_.get());
168 Dialog::Controller::Controller(Dialog & parent)
173 Dialog::Controller & Dialog::controller() const
175 BOOST_ASSERT(controller_ptr_.get());
176 return *controller_ptr_.get();
180 Dialog::View::View(Dialog & parent, string title) :
181 p_(parent), title_(title)
185 Dialog::View & Dialog::view() const
187 BOOST_ASSERT(view_ptr_.get());
188 return *view_ptr_.get();
192 void Dialog::View::setTitle(string const & newtitle)
198 string const & Dialog::View::getTitle() const
204 void Dialog::View::partialUpdate(int)