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"
17 #include "support/LAssert.h"
19 using namespace lyx::support;
21 Dialog::Dialog(LyXView & lv, string const & name)
22 : is_closing_(false), kernel_(lv), name_(name),
23 bc_ptr_(new ButtonController)
31 void Dialog::ApplyButton()
38 void Dialog::OKButton()
48 void Dialog::CancelButton()
55 void Dialog::RestoreButton()
57 // Tell the kernel that a request to refresh the dialog's contents
58 // has been received. It's up to the kernel to supply the necessary
59 // info by calling Dialog::update().
60 kernel().updateDialog(name_);
65 void Dialog::show(string const & data)
67 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
70 if (!controller().initialiseParams(data)) {
71 lyxerr << "Dialog \"" << name_
72 << "\" failed to translate the data "
73 "string passed to show()" << std::endl;
77 bc().readOnly(kernel().isBufferReadonly());
80 // The widgets may not be valid, so refresh the button controller
85 void Dialog::update(string const & data)
87 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
90 if (!controller().initialiseParams(data)) {
91 lyxerr << "Dialog \"" << name_
92 << "\" failed to translate the data "
93 "string passed to update()" << 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();
117 if (kernel().isBufferReadonly())
121 controller().dispatchParams();
123 if (controller().disconnectOnApply() && !is_closing_) {
124 kernel().disconnect(name());
125 controller().initialiseParams(string());
131 bool Dialog::isVisible() const
133 return view().isVisible();
137 void Dialog::redraw()
143 ButtonController & Dialog::bc() const
145 Assert(bc_ptr_.get());
146 return *bc_ptr_.get();
150 void Dialog::setController(Controller * i)
152 Assert(i && !controller_ptr_.get());
153 controller_ptr_.reset(i);
157 void Dialog::setView(View * v)
159 Assert(v && !view_ptr_.get());
164 Dialog::Controller::Controller(Dialog & parent)
169 Dialog::Controller & Dialog::controller() const
171 Assert(controller_ptr_.get());
172 return *controller_ptr_.get();
176 Dialog::View::View(Dialog & parent, string title) :
177 p_(parent), title_(title)
181 Dialog::View & Dialog::view() const
183 Assert(view_ptr_.get());
184 return *view_ptr_.get();
188 void Dialog::View::setTitle(string const & newtitle)
194 string const & Dialog::View::getTitle() const
200 void Dialog::View::partialUpdate(int)