]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/DockView.h
* ControlToc:
[lyx.git] / src / frontends / qt4 / DockView.h
1 // -*- C++ -*-
2 /**
3  * \file DockView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef DOCK_VIEW_H
13 #define DOCK_VIEW_H
14
15 #include "controllers/dialog.h"
16
17 #include <boost/scoped_ptr.hpp>
18
19 #include <QDockWidget>
20 #include <QMainWindow>
21
22 namespace lyx {
23 namespace frontend {
24
25 /// Dock Widget container for LyX dialogs.
26 /// This template class that encapsulates a given Widget inside a
27 /// DockWidget and presents a Dialog::View interface
28 template<class Controller, class Widget>
29 class DockView : public QDockWidget, public Dialog::View 
30 {
31 public:
32         DockView(
33                 Dialog & dialog, ///< The (one) parent Dialog class.
34                 Controller * form, ///< Associated model/controller
35                 QMainWindow * parent, ///< the main window where to dock.
36                 docstring const & title ///< Window title (shown in the top title bar).
37                 )
38                 : QDockWidget(toqstr(title), parent), Dialog::View(dialog, title)
39         {
40                 widget_.reset(new Widget(form));
41                 setWidget(widget_.get());
42                 parent->addDockWidget(Qt::LeftDockWidgetArea, this);
43         }
44
45         /// Dialog::View inherited methods
46         //@{
47         void apply() {}
48         void hide()     { QDockWidget::hide(); }
49         void show()     { QDockWidget::show(); }
50         bool isVisible() const  
51         { return QDockWidget::isVisible(); }
52         void redraw() {}
53         void update()
54         {
55                 widget_->update();
56                 QDockWidget::update();
57         }
58         //@}
59 private:
60         /// The encapsulated widget.
61         boost::scoped_ptr<Widget> widget_;
62 };
63
64 } // frontend
65 } // lyx
66
67 #endif // TOC_WIDGET_H