libt3widget
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
menu.h
1 /* Copyright (C) 2011-2013 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WIDGET_MENU_H
15 #define T3_WIDGET_MENU_H
16 
17 #include <vector>
18 #include <t3widget/interfaces.h>
19 #include <t3widget/widgets/smartlabel.h>
20 
21 namespace t3_widget {
22 
23 class menu_panel_t;
24 
26 class T3_WIDGET_API menu_bar_t : public widget_t {
27  friend class menu_panel_t;
28 
29  private:
30  struct T3_WIDGET_LOCAL implementation_t {
31  int current_menu,
32  old_menu;
33  int start_col;
34  bool hidden,
38  has_focus;
39 
40  std::vector<menu_panel_t *> menus;
41  int button_down_idx;
43  implementation_t(bool _hidden) : current_menu(0), old_menu(0),
44  start_col(0), hidden(_hidden), has_focus(false), button_down_idx(-1)
45  {}
46  };
47  pimpl_ptr<implementation_t>::t impl;
48 
50  void draw_menu_name(menu_panel_t *menu, bool selected);
52  void draw(void);
53 
55  void close(void);
57  void next_menu(void);
59  void previous_menu(void);
60 
62  int coord_to_menu_idx(int x);
63  public:
71  menu_bar_t(bool _hidden = false);
75  virtual ~menu_bar_t(void);
76 
77  virtual bool process_key(key_t key);
78  virtual bool set_size(optint height, optint width);
79  virtual void update_contents(void);
80  virtual void set_focus(focus_t focus);
81  virtual void show(void);
82  virtual void hide(void);
83  virtual bool is_hotkey(key_t key);
84  virtual bool accepts_focus(void);
85  virtual bool process_mouse_event(mouse_event_t event);
89  void add_menu(menu_panel_t *menu);
93  void remove_menu(menu_panel_t *menu);
97  void set_hidden(bool _hidden);
98 
106  T3_WIDGET_SIGNAL(activate, void, int);
107 };
108 
109 }; // namespace
110 #endif