]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Toolbar_pimpl.h
reverse last change
[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 "qt_helpers.h"
22
23 #include <boost/scoped_ptr.hpp>
24 #include <map>
25 #include <vector>
26
27 #include <qobject.h>
28 #include <qtoolbutton.h>
29
30 class QtView;
31 class QToolBar;
32 class QLComboBox;
33 class ToolbarProxy;
34
35 struct Toolbar::Pimpl {
36 public:
37         friend class ToolbarProxy;
38
39         Pimpl(LyXView * o, int x, int y);
40
41         ~Pimpl();
42
43         /// add a new button to the toolbar.
44         void add(int action);
45
46         /// update the state of the icons
47         void update();
48
49         /// select the right layout in the combox
50         void setLayout(string const & layout);
51         /// Populate the layout combox; re-do everything if force is true.
52         void updateLayoutList(bool force);
53         /// Drop down the layout list
54         void openLayoutList();
55         /// Erase the layout list
56         void clearLayoutList();
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 // moc is mind-numbingly stupid
77 class ToolbarProxy : public QObject {
78         Q_OBJECT
79 public:
80         ToolbarProxy(Toolbar::Pimpl & owner)
81                 : owner_(owner) {}
82 public slots:
83
84         void layout_selected(const QString & str) {
85                 owner_.changed_layout(fromqstr(str));
86         }
87
88         void button_selected() {
89                 owner_.button_selected(
90                         const_cast<QToolButton *>(
91                         static_cast<QToolButton const *>(sender()))
92                 );
93         }
94 private:
95         Toolbar::Pimpl & owner_;
96 };
97
98 #endif