4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
15 #include "controllers/Dialog.h"
16 #include "qt_helpers.h"
18 #include <boost/scoped_ptr.hpp>
20 #include <QDockWidget>
21 #include <QMainWindow>
26 /// Dock Widget container for LyX dialogs.
27 /// This template class that encapsulates a given Widget inside a
28 /// DockWidget and presents a Dialog::View interface
29 template<class Controller, class Widget>
30 class DockView : public QDockWidget, public Dialog::View
34 Dialog & dialog, ///< The (one) parent Dialog class.
35 Controller * form, ///< Associated model/controller
36 QMainWindow * parent, ///< the main window where to dock.
37 docstring const & title, ///< Window title (shown in the top title bar).
38 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea
40 : QDockWidget(toqstr(title), parent), Dialog::View(dialog, title)
42 widget_.reset(new Widget(form));
43 setWidget(widget_.get());
44 parent->addDockWidget(area, this);
47 /// Dialog::View inherited methods
50 void hide() { QDockWidget::hide(); }
51 void show() { QDockWidget::show(); }
52 bool isVisible() const
53 { return QDockWidget::isVisible(); }
58 QDockWidget::update();
62 /// The encapsulated widget.
63 boost::scoped_ptr<Widget> widget_;
69 #endif // TOC_WIDGET_H