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