2
Copyright (C) 2009 Red Hat, Inc.
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser General Public
15
License along with this library; if not, see <http://www.gnu.org/licenses/>.
23
virtual void do_command(int command) = 0;
24
virtual ~CommandTarget() {}
29
Menu(CommandTarget& target, const std::string& name, int id = 0);
32
MENU_ITEM_TYPE_INVALID,
33
MENU_ITEM_TYPE_COMMAND,
35
MENU_ITEM_TYPE_SEPARATOR,
39
MENU_ITEM_STATE_CHECKED = 1 << 0,
40
MENU_ITEM_STATE_DIM = 1 << 1,
43
Menu* ref() { _refs++; return this;}
44
void unref() { if (!--_refs) delete this;}
46
void set_name(const std::string& name) { _name = name;}
47
const std::string& get_name() { return _name;}
48
CommandTarget& get_target() { return _target;}
49
int get_id() { return _id;}
51
void add_command(const std::string& name, int cmd_id, int state = 0);
53
void add_sub(Menu* sub);
55
void remove_command(int cmd_id);
56
void remove_sub(Menu* menu);
58
ItemType item_type_at(int pos);
59
void command_at(int pos, std::string& name, int& cmd_id, int& state);
60
Menu* sub_at(int pos);
61
Menu* find_sub(int id);
70
MenuCommand(const std::string& name, int cmd_id, int state)
77
const std::string& get_name() { return _name;}
78
int get_cmd_id() { return _cmd_id;}
79
int get_state() { return _state;}
92
void add_item(MenuItem& item);
96
CommandTarget& _target;
98
std::vector<MenuItem> _items;