]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Toolbar_pimpl.h
dont use pragma impementation and interface anymore
[lyx.git] / src / frontends / qt2 / Toolbar_pimpl.h
1 // -*- C++ -*-
2 /**
3  * \file qt2/Toolbar_pimpl.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef TOOLBAR_PIMPL_H
13 #define TOOLBAR_PIMPL_H
14
15
16 #include "frontends/Toolbar.h"
17
18 #include "qt_helpers.h"
19
20 #include <boost/scoped_ptr.hpp>
21 #include <map>
22 #include <vector>
23
24 #include <qobject.h>
25 #include <qtoolbutton.h>
26
27 class QtView;
28 class QToolBar;
29 class QLComboBox;
30 class ToolbarProxy;
31
32 struct Toolbar::Pimpl {
33 public:
34         friend class ToolbarProxy;
35
36         Pimpl(LyXView * o, int x, int y);
37
38         ~Pimpl();
39
40         /// add a new button to the toolbar.
41         void add(int action);
42
43         /// update the state of the icons
44         void update();
45
46         /// select the right layout in the combox
47         void setLayout(string const & layout);
48         /// Populate the layout combox; re-do everything if force is true.
49         void updateLayoutList(bool force);
50         /// Drop down the layout list
51         void openLayoutList();
52         /// Erase the layout list
53         void clearLayoutList();
54 private:
55         void changed_layout(string const & sel);
56
57         void button_selected(QToolButton * button);
58
59         QtView * owner_;
60
61         boost::scoped_ptr<ToolbarProxy> proxy_;
62
63         std::vector<QToolBar *> toolbars_;
64
65         QLComboBox * combo_;
66
67         typedef std::map<QToolButton *, int> ButtonMap;
68
69         ButtonMap map_;
70 };
71
72
73 // moc is mind-numbingly stupid
74 class ToolbarProxy : public QObject {
75         Q_OBJECT
76 public:
77         ToolbarProxy(Toolbar::Pimpl & owner)
78                 : owner_(owner) {}
79 public slots:
80
81         void layout_selected(const QString & str) {
82                 owner_.changed_layout(fromqstr(str));
83         }
84
85         void button_selected() {
86                 owner_.button_selected(
87                         const_cast<QToolButton *>(
88                         static_cast<QToolButton const *>(sender()))
89                 );
90         }
91 private:
92         Toolbar::Pimpl & owner_;
93 };
94
95 #endif