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 "ButtonController.h"
18 #include "support/LAssert.h"
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 controller().initialiseParams(data);
71 bc().readOnly(kernel().isBufferReadonly());
74 // The widgets may not be valid, so refresh the button controller
79 void Dialog::update(string const & data)
81 if (controller().isBufferDependent() && !kernel().isBufferAvailable())
84 controller().initialiseParams(data);
86 bc().readOnly(kernel().isBufferReadonly());
89 // The widgets may not be valid, so refresh the button controller
96 if (!view().isVisible())
99 controller().clearParams();
106 if (kernel().isBufferReadonly())
110 controller().dispatchParams();
112 if (controller().disconnectOnApply() && !is_closing_) {
113 kernel().disconnect(name());
114 controller().initialiseParams(string());
120 bool Dialog::isVisible() const
122 return view().isVisible();
126 void Dialog::redraw()
132 ButtonController & Dialog::bc() const
134 lyx::Assert(bc_ptr_.get());
135 return *bc_ptr_.get();
139 Dialog::Controller & Dialog::controller() const
141 lyx::Assert(controller_ptr_.get());
142 return *controller_ptr_.get();
146 Dialog::View & Dialog::view() const
148 lyx::Assert(view_ptr_.get());
149 return *view_ptr_.get();
153 void Dialog::setController(Controller * i)
155 lyx::Assert(i && !controller_ptr_.get());
156 controller_ptr_.reset(i);
160 void Dialog::setView(View * v)
162 lyx::Assert(v && !view_ptr_.get());