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();
118 if (kernel().isBufferReadonly())
122 controller().dispatchParams();
124 if (controller().disconnectOnApply() && !is_closing_) {
125 kernel().disconnect(name());
126 controller().initialiseParams(string());
132 bool Dialog::isVisible() const
134 return view().isVisible();
138 void Dialog::redraw()
144 ButtonController & Dialog::bc() const
146 BOOST_ASSERT(bc_ptr_.get());
147 return *bc_ptr_.get();
151 void Dialog::setController(Controller * i)
153 BOOST_ASSERT(i && !controller_ptr_.get());
154 controller_ptr_.reset(i);
158 void Dialog::setView(View * v)
160 BOOST_ASSERT(v && !view_ptr_.get());
165 Dialog::Controller::Controller(Dialog & parent)
170 Dialog::Controller & Dialog::controller() const
172 BOOST_ASSERT(controller_ptr_.get());
173 return *controller_ptr_.get();
177 Dialog::View::View(Dialog & parent, string title) :
178 p_(parent), title_(title)
182 Dialog::View & Dialog::view() const
184 BOOST_ASSERT(view_ptr_.get());
185 return *view_ptr_.get();
189 void Dialog::View::setTitle(string const & newtitle)
195 string const & Dialog::View::getTitle() const
201 void Dialog::View::partialUpdate(int)