]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Menubar_pimpl.h
Fix crash when using dialog with keyboard:
[lyx.git] / src / frontends / xforms / Menubar_pimpl.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2001 The LyX Team.
8  *
9  *           This file is Copyright 1996-2001
10  *           Lars Gullik Bjønnes
11  *
12  * ====================================================== */
13
14 #ifndef MENUBAR_PIMPL_H
15 #define MENUBAR_PIMPL_H
16
17 #include <vector>
18 #include <map>
19 #include <boost/smart_ptr.hpp>
20 #include FORMS_H_LOCATION
21
22 #ifdef __GNUG__
23 #pragma interface
24 #endif
25
26 #include "LString.h"
27 #include "frontends/Menubar.h"
28 #include "commandtags.h"
29 #include "MenuBackend.h"
30
31 class LyXView;
32
33 /** The LyX GUI independent menubar class
34   The GUI interface is implemented in the corresponding Menubar_pimpl class. 
35   */
36 struct Menubar::Pimpl {
37 public:
38         ///
39         Pimpl(LyXView *, MenuBackend const &);
40         ///
41         void set(string const &);
42         /// Opens a top-level submenu given its name
43         void openByName(string const &);
44
45         ///
46         static void MenuCallback(FL_OBJECT *, long);
47
48         ///
49         void add_toc(int menu, string const & extra_label,
50                      std::vector<int> & smn, Window win);
51         ///
52         void add_references(int menu, string const & extra_label,
53                             std::vector<int> & smn, Window win);
54         ///
55         int create_submenu(Window win, LyXView * view,
56                            string const & menuname,
57                            std::vector<int> & smn);
58
59         /// update the state of the menuitems
60         void update() {}
61 private:
62         //
63         void makeMenubar(Menu const &menu);
64
65         /// 
66         LyXView * owner_;
67         ///
68         MenuBackend const * menubackend_;
69         ///
70         struct ItemInfo {
71                 ///
72                 ItemInfo(Menubar::Pimpl * p, MenuItem const * i, 
73                          FL_OBJECT * o)
74                 
75                         : pimpl_(p), obj_(o) { item_.reset(i); }
76                 ///
77                 Menubar::Pimpl * pimpl_;
78                 ///
79                 boost::shared_ptr<MenuItem const> item_;
80                 ///
81                 FL_OBJECT * obj_;
82         };
83
84         ///
85         typedef std::vector<boost::shared_ptr<ItemInfo> > ButtonList;
86         ///
87         ButtonList buttonlist_;
88
89         ///
90         typedef std::map<string, FL_OBJECT *> MenubarMap;
91         ///
92         MenubarMap menubarmap_;
93         ///
94         string current_menu_name_;
95         ///
96         FL_OBJECT * current_group_;
97 };
98 #endif