]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Menubar_pimpl.h
It compiles, ship it. JMarc, can you see why I might be segfaulting
[lyx.git] / src / frontends / qt2 / Menubar_pimpl.h
1 // -*- C++ -*-
2 /**
3  * \file Menubar_pimpl.h
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Lars Gullik Bjønnes <larsbj@lyx.org>
8  * \author John Levon <moz@compsoc.man.ac.uk>
9  */
10
11  
12 #ifndef MENUBAR_PIMPL_H
13 #define MENUBAR_PIMPL_H
14
15 #include <vector>
16 #include <map>
17
18 #include <config.h>
19  
20 #ifdef __GNUG__
21 #pragma interface
22 #endif
23
24 #include "LString.h"
25 #include "frontends/Menubar.h"
26 #include "commandtags.h"
27
28 class LyXView;
29 class QtView;
30 class QMenuData;
31 class Menu;
32 class MenuItem;
33 class MenuBackend;
34
35 /// stored state for menu items
36 struct MenuItemInfo {
37         // I REALLY hate this stupid requirement of std::map
38         MenuItemInfo::MenuItemInfo()
39                 : parent_(0), id_(0), item_(0) {};
40  
41         MenuItemInfo::MenuItemInfo(QMenuData * p, int id, MenuItem const * item)
42                 : parent_(p), id_(id), item_(item) {};
43  
44         /// menu containing item
45         QMenuData * parent_;
46  
47         /// id in containing menu
48         int id_;
49  
50         /// LyX info for item
51         MenuItem const * item_;
52 };
53  
54
55 struct Menubar::Pimpl {
56 public:
57         Pimpl(LyXView *, MenuBackend const &);
58  
59         /// opens a top-level submenu given its name
60         void openByName(string const &);
61
62         /// update the state of the menuitems
63         void update();
64
65 private:
66         /// create a menu
67         void makeMenu(QMenuData * parent, MenuItem const * item, Menu const & menu);
68  
69         /// special handling updating a submenu label
70         void updateSubmenu(MenuItemInfo const & i);
71  
72         /// update an individual item, returns true if enabled
73         void updateItem(MenuItemInfo const & i);
74
75         /// owning view
76         QtView * owner_;
77
78         /// menu controller
79         MenuBackend const & menubackend_;
80
81         typedef std::map<string, MenuItemInfo> ItemMap;
82
83         /// menu items
84         ItemMap items_;
85 };
86  
87 #endif // MENUBAR_PIMPL_H