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"
19 Dialog::Dialog(LyXView & lv, string const & name)
20 : is_closing_(false), kernel_(lv), name_(name),
21 bc_ptr_(new ButtonController)
29 void Dialog::ApplyButton()
36 void Dialog::OKButton()
46 void Dialog::CancelButton()
53 void Dialog::RestoreButton()
55 // Tell the kernel that a request to refresh the dialog's contents
56 // has been received. It's up to the kernel to supply the necessary
57 // info by calling Dialog::update().
58 kernel().updateDialog(name_);
63 void Dialog::show(string const & data)
65 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
68 if (!controller().initialiseParams(data)) {
69 lyxerr << "Dialog \"" << name_
70 << "\" failed to translate the data "
71 "string passed to show()" << std::endl;
75 bc().readOnly(kernel().isBufferReadonly());
78 // The widgets may not be valid, so refresh the button controller
83 void Dialog::update(string const & data)
85 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
88 if (!controller().initialiseParams(data)) {
89 lyxerr << "Dialog \"" << name_
90 << "\" failed to translate the data "
91 "string passed to update()" << std::endl;
95 bc().readOnly(kernel().isBufferReadonly());
98 // The widgets may not be valid, so refresh the button controller
105 if (!view().isVisible())
108 controller().clearParams();
115 if (kernel().isBufferReadonly())
119 controller().dispatchParams();
121 if (controller().disconnectOnApply() && !is_closing_) {
122 kernel().disconnect(name());
123 controller().initialiseParams(string());
129 bool Dialog::isVisible() const
131 return view().isVisible();
135 void Dialog::redraw()
141 ButtonController & Dialog::bc() const
143 BOOST_ASSERT(bc_ptr_.get());
144 return *bc_ptr_.get();
148 void Dialog::setController(Controller * i)
150 BOOST_ASSERT(i && !controller_ptr_.get());
151 controller_ptr_.reset(i);
155 void Dialog::setView(View * v)
157 BOOST_ASSERT(v && !view_ptr_.get());
162 Dialog::Controller::Controller(Dialog & parent)
167 Dialog::Controller & Dialog::controller() const
169 BOOST_ASSERT(controller_ptr_.get());
170 return *controller_ptr_.get();
174 Dialog::View::View(Dialog & parent, string title) :
175 p_(parent), title_(title)
179 Dialog::View & Dialog::view() const
181 BOOST_ASSERT(view_ptr_.get());
182 return *view_ptr_.get();
186 void Dialog::View::setTitle(string const & newtitle)
192 string const & Dialog::View::getTitle() const
198 void Dialog::View::partialUpdate(int)