4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
16 #include "ButtonControllerBase.h"
17 #include "support/LAssert.h"
20 Dialog::Dialog(LyXView & lv, string const & name)
21 : is_closing_(false), kernel_(lv), name_(name)
25 void Dialog::ApplyButton()
32 void Dialog::OKButton()
42 void Dialog::CancelButton()
49 void Dialog::RestoreButton()
51 // Tell the kernel that a request to refresh the dialog's contents
52 // has been received. It's up to the kernel to supply the necessary
53 // info by calling Dialog::update().
54 kernel().updateDialog(name_);
59 void Dialog::show(string const & data)
61 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
64 controller().initialiseParams(data);
65 bc().readOnly(kernel().isBufferReadonly());
68 // The widgets may not be valid, so refresh the button controller
73 void Dialog::update(string const & data)
75 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
78 controller().initialiseParams(data);
80 bc().readOnly(kernel().isBufferReadonly());
83 // The widgets may not be valid, so refresh the button controller
90 if (!view().isVisible())
93 controller().clearParams();
100 if (kernel().isBufferReadonly())
104 controller().dispatchParams();
106 if (controller().disconnectOnApply() && !is_closing_) {
107 kernel().disconnect(name());
108 controller().initialiseParams(string());
114 bool Dialog::isVisible() const
116 return view().isVisible();
120 void Dialog::redraw()
126 ButtonControllerBase & Dialog::bc() const
128 lyx::Assert(bc_ptr_.get());
129 return *bc_ptr_.get();
133 Dialog::Controller & Dialog::controller() const
135 lyx::Assert(controller_ptr_.get());
136 return *controller_ptr_.get();
140 Dialog::View & Dialog::view() const
142 lyx::Assert(view_ptr_.get());
143 return *view_ptr_.get();
147 void Dialog::setButtonController(ButtonControllerBase * bc)
149 lyx::Assert(bc && !bc_ptr_.get());
154 void Dialog::setController(Controller * i)
156 lyx::Assert(i && !controller_ptr_.get());
157 controller_ptr_.reset(i);
161 void Dialog::setView(View * v)
163 lyx::Assert(v && !view_ptr_.get());