libt3widget
menupanel.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_MENUPANEL_H
15 #define T3_WIDGET_MENUPANEL_H
16 
17 #include <t3widget/dialogs/dialog.h>
18 #include <t3widget/widgets/menu.h>
19 
20 namespace t3_widget {
21 
22 class menu_item_base_t;
23 class menu_item_t;
24 
25 class T3_WIDGET_API menu_panel_t : public dialog_t {
26  friend class menu_bar_t;
27  friend class menu_item_t;
28  private:
29  struct T3_WIDGET_LOCAL implementation_t {
30  int width, label_width, hotkey_width;
31  smart_label_text_t label;
32  menu_bar_t *menu_bar;
33 
34  implementation_t(const char *name) : label(name), menu_bar(NULL) {}
35  };
36  pimpl_ptr<implementation_t>::t impl;
37 
38  void signal(int id);
39  void close(void);
40  void set_menu_bar(menu_bar_t *_menu_bar);
41  void draw_label(t3_window_t *draw_window, t3_attr_t attr, bool selected) const;
42  int get_label_width(void) const;
43  bool is_hotkey(key_t key) const;
44 
45  protected:
46  virtual bool is_child(window_component_t *widget);
47 
48  /* Menu panels get their events from the menu_t, because that grabs the
49  mouse as soon as it is activated. */
50  void process_mouse_event_from_menu(mouse_event_t event);
51 
52  public:
53  menu_panel_t(const char *name, menu_bar_t *_menu_bar = NULL);
54  virtual bool process_key(key_t key);
55  virtual void set_position(optint top, optint left);
56  virtual bool set_size(optint height, optint width);
57  menu_item_base_t *add_item(const char *label, const char *hotkey, int id);
58  menu_item_base_t *add_item(menu_item_t *item);
59  menu_item_base_t *add_separator(void);
60  void remove_item(menu_item_base_t *item);
61 };
62 
63 }; // namespace
64 #endif
The t3_widget namespace is contains all classes, functions and global variables in the libt3widget li...
Definition: autocompleter.cc:18
Definition: menuitem.h:37
Abstract base class for all items displayed on screen.
Definition: interfaces.h:28
long key_t
Integer type holding a single key symbol.
Definition: key.h:24
Definition: menuitem.h:22
Class defining values with a separate validity check.
Definition: util.h:29
Base class for dialogs.
Definition: dialog.h:27
Structure holding the relevant elements of a mouse event.
Definition: mouse.h:23
Definition: menupanel.h:25
Definition: smartlabel.h:22
Class implementing a menu bar.
Definition: menu.h:26