]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Toolbar_pimpl.h
Yet more (minor) compilation fixes.
[lyx.git] / src / frontends / qt2 / Toolbar_pimpl.h
1 // -*- C++ -*-
2 /**
3  * \file Toolbar_pimpl.h
4  * Copyright 2002 the LyX Team
5  * Copyright 1996-2001 Lars Gullik Bjønnes
6  * Read the file COPYING
7  *
8  * \author Lars Gullik Bjønnes, larsbj@lyx.org
9  */
10
11 #ifndef TOOLBAR_PIMPL_H
12 #define TOOLBAR_PIMPL_H
13
14 #include <config.h>
15 #include <map>
16 #include <vector>
17
18 #include <boost/smart_ptr.hpp>
19  
20 #include "frontends/Toolbar.h"
21
22 #ifdef __GNUG__
23 #pragma interface
24 #endif
25
26 #include <qobject.h>
27 #include <qtoolbutton.h>
28  
29 class QtView;
30 class QToolBar;
31 class QComboBox;
32 class ToolbarProxy;
33
34 struct Toolbar::Pimpl {
35  
36         friend class ToolbarProxy;
37  
38 public:
39         ///
40         Pimpl(LyXView * o, int x, int y);
41         ///
42         ~Pimpl();
43         
44         /// (re)sets the toolbar
45         void set(bool doingmain = false);
46
47         void reset() { }
48  
49         /** this is to be the entry point to the toolbar
50             frame, where you can change the toolbar realtime.
51         */
52         void edit();
53         /// add a new button to the toolbar.
54         void add(int, bool doclean = true);
55         /// invokes the n'th icon in the toolbar
56         void push(int);
57         /// activates the toolbar
58         void activate();
59         /// deactivates the toolbar
60         void deactivate();
61         /// update the state of the icons
62         void update();
63
64         /// select the right layout in the combox
65         void setLayout(string const & layout);
66         /// Populate the layout combox; re-do everything if force is true.
67         void updateLayoutList(bool force);
68         /// Drop down the layout list
69         void openLayoutList();
70         /// Erase the layout list
71         void clearLayoutList();
72
73 private:
74         void changed_layout(string const & sel);
75
76         void button_selected(QToolButton * button);
77  
78         QtView * owner_; 
79
80         boost::scoped_ptr<ToolbarProxy> proxy_;
81
82         std::vector<QToolBar *> toolbars_;
83
84         QComboBox * combo_;
85
86         typedef std::map<QToolButton *, int> ButtonMap;
87
88         ButtonMap map_;
89  
90 };
91
92  
93 // moc is mind-numbingly stupid
94 class ToolbarProxy : public QObject {
95         Q_OBJECT
96
97 public:
98         ToolbarProxy(Toolbar::Pimpl & owner)
99                 : owner_(owner) { };
100  
101 public slots:
102  
103         void layout_selected(const QString & str) {
104                 owner_.changed_layout(str.latin1());
105         }
106
107         void button_selected() {
108                 owner_.button_selected(
109                         const_cast<QToolButton *>(
110                         static_cast<QToolButton const *>(sender()))
111                 );
112         }
113
114 private:
115         Toolbar::Pimpl & owner_;
116 };
117  
118 #endif