e167b9835cb681a02b55240e4733d10c615a79f5
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bcmenuitem.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCMENUITEM_H
23 #define BCMENUITEM_H
24
25
26 #include "bcmenubar.inc"
27 #include "bcmenupopup.inc"
28 #include "bcpixmap.inc"
29 #include "bcpopupmenu.inc"
30 #include "bcwindowbase.inc"
31
32
33
34 class BC_MenuItem
35 {
36 public:
37         BC_MenuItem(const char *text, const char *hotkey_text = "", int hotkey = 0);
38         virtual ~BC_MenuItem();
39
40         friend class BC_MenuPopup;
41
42         void reset();
43         int add_submenu(BC_SubMenu *submenu);
44         int set_checked(int value);
45         int get_checked();
46         void set_text(const char *text);
47         char* get_text();
48         void set_icon(BC_Pixmap *icon);
49         BC_Pixmap* get_icon();
50         void set_hotkey_text(const char *text);
51         int set_shift(int value = 1);
52         int set_alt(int value = 1);
53         void set_ctrl(int value = 1);
54
55         virtual int deactivate_submenus(BC_MenuPopup *exclude);
56         virtual int activate_submenu();
57         virtual int handle_event() { return 0; };
58         int dispatch_button_press();
59         int dispatch_button_release(int &redraw);
60         int dispatch_motion_event(int &redraw);
61         int dispatch_translation_event();
62         int dispatch_cursor_leave();
63         int dispatch_key_press();
64         int add_item(BC_MenuItem *item);
65         int initialize(BC_WindowBase *top_level, BC_MenuBar *menu_bar, BC_MenuPopup *menu_popup);
66         int draw();
67         BC_WindowBase* get_top_level();
68         BC_PopupMenu* get_popup_menu();
69         BC_SubMenu *get_submenu();
70         int get_enabled(int v);
71         void set_enabled(int v);
72
73 private:
74         BC_WindowBase *top_level;
75         BC_MenuBar *menu_bar;
76         BC_MenuPopup *menu_popup;
77 // Submenu if this item owns one.
78         BC_SubMenu *submenu;
79 // whether the cursor is over or not
80         int highlighted;
81 // whether the cursor is over and the button is down
82         int down;
83 // check box
84         int checked;
85 // not drawn if not enabled
86         int enabled;
87 // title
88         char *text;
89 // text of hotkey
90         char *hotkey_text;
91 // Hotkey requires shift
92         int shift_hotkey;
93 // Hotkey requires alt
94         int alt_hotkey;
95         int ctrl_hotkey;
96 // Character code of hotkey
97         int hotkey;
98 // icon or 0 if there is no icon
99         BC_Pixmap *icon;
100 // y position of this item set during menu activation
101         int y;
102 // height of item is set during menu activation
103         int h;
104 };
105
106
107
108 #endif