]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Toolbar_pimpl.h
doxygen fixes.
[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 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "frontends/Toolbar.h"
20
21 #include <qobject.h>
22 #include <qtoolbutton.h>
23
24 #include <boost/scoped_ptr.hpp>
25 #include <map>
26 #include <vector>
27
28 class QtView;
29 class QToolBar;
30 class QLComboBox;
31 class ToolbarProxy;
32
33 struct Toolbar::Pimpl {
34
35         friend class ToolbarProxy;
36
37 public:
38         Pimpl(LyXView * o, int x, int y);
39
40         ~Pimpl();
41
42         /// add a new button to the toolbar.
43         void add(int action);
44
45         /// update the state of the icons
46         void update();
47
48         /// select the right layout in the combox
49         void setLayout(string const & layout);
50         /// Populate the layout combox; re-do everything if force is true.
51         void updateLayoutList(bool force);
52         /// Drop down the layout list
53         void openLayoutList();
54         /// Erase the layout list
55         void clearLayoutList();
56
57 private:
58         void changed_layout(string const & sel);
59
60         void button_selected(QToolButton * button);
61
62         QtView * owner_;
63
64         boost::scoped_ptr<ToolbarProxy> proxy_;
65
66         std::vector<QToolBar *> toolbars_;
67
68         QLComboBox * combo_;
69
70         typedef std::map<QToolButton *, int> ButtonMap;
71
72         ButtonMap map_;
73
74 };
75
76
77 // moc is mind-numbingly stupid
78 class ToolbarProxy : public QObject {
79         Q_OBJECT
80
81 public:
82         ToolbarProxy(Toolbar::Pimpl & owner)
83                 : owner_(owner) { };
84
85 public slots:
86
87         void layout_selected(const QString & str) {
88                 owner_.changed_layout(str.latin1());
89         }
90
91         void button_selected() {
92                 owner_.button_selected(
93                         const_cast<QToolButton *>(
94                         static_cast<QToolButton const *>(sender()))
95                 );
96         }
97
98 private:
99         Toolbar::Pimpl & owner_;
100 };
101
102 #endif