]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Toolbar_pimpl.h
toolbar - remove dead code
[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 QLComboBox;
32 class ToolbarProxy;
33
34 struct Toolbar::Pimpl {
35  
36         friend class ToolbarProxy;
37  
38 public:
39         Pimpl(LyXView * o, Dialogs &, 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
58 private:
59         void changed_layout(string const & sel);
60
61         void button_selected(QToolButton * button);
62  
63         QtView * owner_; 
64
65         boost::scoped_ptr<ToolbarProxy> proxy_;
66
67         std::vector<QToolBar *> toolbars_;
68
69         QLComboBox * combo_;
70
71         typedef std::map<QToolButton *, int> ButtonMap;
72
73         ButtonMap map_;
74  
75 };
76
77  
78 // moc is mind-numbingly stupid
79 class ToolbarProxy : public QObject {
80         Q_OBJECT
81
82 public:
83         ToolbarProxy(Toolbar::Pimpl & owner)
84                 : owner_(owner) { };
85  
86 public slots:
87  
88         void layout_selected(const QString & str) {
89                 owner_.changed_layout(str.latin1());
90         }
91
92         void button_selected() {
93                 owner_.button_selected(
94                         const_cast<QToolButton *>(
95                         static_cast<QToolButton const *>(sender()))
96                 );
97         }
98
99 private:
100         Toolbar::Pimpl & owner_;
101 };
102  
103 #endif