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"
24 Dialog::Dialog(LyXView & lv, string const & name)
25 : is_closing_(false), kernel_(lv), name_(name),
26 bc_ptr_(new ButtonController)
34 void Dialog::ApplyButton()
41 void Dialog::OKButton()
51 void Dialog::CancelButton()
58 void Dialog::RestoreButton()
60 // Tell the kernel that a request to refresh the dialog's contents
61 // has been received. It's up to the kernel to supply the necessary
62 // info by calling Dialog::update().
63 kernel().updateDialog(name_);
68 void Dialog::show(string const & data)
70 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
73 if (!controller().initialiseParams(data)) {
74 lyxerr << "Dialog \"" << name_
75 << "\" failed to translate the data "
76 "string passed to show()" << std::endl;
80 bc().readOnly(kernel().isBufferReadonly());
83 // The widgets may not be valid, so refresh the button controller
88 void Dialog::update(string const & data)
90 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
93 if (!controller().initialiseParams(data)) {
94 lyxerr << "Dialog \"" << name_
95 << "\" could not be initialized" << std::endl;
99 bc().readOnly(kernel().isBufferReadonly());
102 // The widgets may not be valid, so refresh the button controller
109 if (!view().isVisible())
112 controller().clearParams();
114 kernel().disconnect(name());
120 if (controller().isBufferDependent()) {
121 if (!kernel().isBufferAvailable() ||
122 kernel().isBufferReadonly())
127 controller().dispatchParams();
129 if (controller().disconnectOnApply() && !is_closing_) {
130 kernel().disconnect(name());
131 controller().initialiseParams(string());
137 bool Dialog::isVisible() const
139 return view().isVisible();
143 void Dialog::redraw()
149 ButtonController & Dialog::bc() const
151 BOOST_ASSERT(bc_ptr_.get());
152 return *bc_ptr_.get();
156 void Dialog::setController(Controller * i)
158 BOOST_ASSERT(i && !controller_ptr_.get());
159 controller_ptr_.reset(i);
163 void Dialog::setView(View * v)
165 BOOST_ASSERT(v && !view_ptr_.get());
170 Dialog::Controller::Controller(Dialog & parent)
175 Dialog::Controller & Dialog::controller() const
177 BOOST_ASSERT(controller_ptr_.get());
178 return *controller_ptr_.get();
182 Dialog::View::View(Dialog & parent, string title) :
183 p_(parent), title_(title)
187 Dialog::View & Dialog::view() const
189 BOOST_ASSERT(view_ptr_.get());
190 return *view_ptr_.get();
194 void Dialog::View::setTitle(string const & newtitle)
200 string const & Dialog::View::getTitle() const
206 void Dialog::View::partialUpdate(int)
209 } // namespace frontend