foobar2000 SDK  2015-08-03
menu.h
Go to the documentation of this file.
1 class NOVTABLE mainmenu_group : public service_base {
2 public:
3  virtual GUID get_guid() = 0;
4  virtual GUID get_parent() = 0;
5  virtual t_uint32 get_sort_priority() = 0;
6 
7  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_group);
8 };
9 
10 class NOVTABLE mainmenu_group_popup : public mainmenu_group {
11 public:
12  virtual void get_display_string(pfc::string_base & p_out) = 0;
13  void get_name(pfc::string_base & out) {get_display_string(out);}
14 
15  FB2K_MAKE_SERVICE_INTERFACE(mainmenu_group_popup,mainmenu_group);
16 };
17 
18 class NOVTABLE mainmenu_commands : public service_base {
19 public:
20  enum {
21  flag_disabled = 1<<0,
22  flag_checked = 1<<1,
23  flag_radiochecked = 1<<2,
26  flag_defaulthidden = 1<<3,
27  sort_priority_base = 0x10000,
28  sort_priority_dontcare = 0x80000000,
29  sort_priority_last = ~0,
30  };
31 
33  virtual t_uint32 get_command_count() = 0;
35  virtual GUID get_command(t_uint32 p_index) = 0;
37  virtual void get_name(t_uint32 p_index,pfc::string_base & p_out) = 0;
39  virtual bool get_description(t_uint32 p_index,pfc::string_base & p_out) = 0;
41  virtual GUID get_parent() = 0;
43  virtual t_uint32 get_sort_priority() {return sort_priority_dontcare;}
45  virtual bool get_display(t_uint32 p_index,pfc::string_base & p_text,t_uint32 & p_flags) {p_flags = 0;get_name(p_index,p_text);return true;}
47  virtual void execute(t_uint32 p_index,service_ptr_t<service_base> p_callback) = 0;
48 
49  static bool g_execute(const GUID & p_guid,service_ptr_t<service_base> p_callback = NULL);
50  static bool g_execute_dynamic(const GUID & p_guid, const GUID & p_subGuid,service_ptr_t<service_base> p_callback = NULL);
51  static bool g_find_by_name(const char * p_name,GUID & p_guid);
52 
53  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_commands);
54 };
55 
56 class NOVTABLE mainmenu_manager : public service_base {
57 public:
58  enum {
59  flag_show_shortcuts = 1 << 0,
60  flag_show_shortcuts_global = 1 << 1,
63  flag_view_reduced = 1 << 2,
66  flag_view_full = 1 << 3,
67  };
68 
69  virtual void instantiate(const GUID & p_root) = 0;
70 
71 #ifdef _WIN32
72  virtual void generate_menu_win32(HMENU p_menu,t_uint32 p_id_base,t_uint32 p_id_count,t_uint32 p_flags) = 0;
73 #else
74 #error portme
75 #endif
76  //@param p_id Identifier of command to execute, relative to p_id_base of generate_menu_*()
77  //@returns true if command was executed successfully, false if not (e.g. command with given identifier not found).
78  virtual bool execute_command(t_uint32 p_id,service_ptr_t<service_base> p_callback = service_ptr_t<service_base>()) = 0;
79 
80  virtual bool get_description(t_uint32 p_id,pfc::string_base & p_out) = 0;
81 
82  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_manager);
83 };
84 
86 public:
87  static const GUID file,view,edit,playback,library,help;
88  static const GUID file_open,file_add,file_playlist,file_etc;
89  static const GUID playback_controls,playback_etc;
90  static const GUID view_visualisations, view_alwaysontop;
91  static const GUID edit_part1,edit_part2,edit_part3;
92  static const GUID edit_part2_selection,edit_part2_sort,edit_part2_selection_sort;
93  static const GUID file_etc_preferences, file_etc_exit;
94  static const GUID help_about;
95  static const GUID library_refresh;
96 
97  enum {priority_edit_part1,priority_edit_part2,priority_edit_part3};
98  enum {priority_edit_part2_commands,priority_edit_part2_selection,priority_edit_part2_sort};
99  enum {priority_edit_part2_selection_commands,priority_edit_part2_selection_sort};
100  enum {priority_file_open,priority_file_add,priority_file_playlist,priority_file_etc = mainmenu_commands::sort_priority_last};
101 };
102 
103 
105 public:
106  mainmenu_group_impl(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority) : m_guid(p_guid), m_parent(p_parent), m_priority(p_priority) {}
107  GUID get_guid() {return m_guid;}
108  GUID get_parent() {return m_parent;}
109  t_uint32 get_sort_priority() {return m_priority;}
110 private:
111  GUID m_guid,m_parent; t_uint32 m_priority;
112 };
113 
115 public:
116  mainmenu_group_popup_impl(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority,const char * p_name) : m_guid(p_guid), m_parent(p_parent), m_priority(p_priority), m_name(p_name) {}
117  GUID get_guid() {return m_guid;}
118  GUID get_parent() {return m_parent;}
119  t_uint32 get_sort_priority() {return m_priority;}
120  void get_display_string(pfc::string_base & p_out) {p_out = m_name;}
121 private:
122  GUID m_guid,m_parent; t_uint32 m_priority; pfc::string8 m_name;
123 };
124 
127 
128 class mainmenu_group_factory : public __mainmenu_group_factory {
129 public:
130  mainmenu_group_factory(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority) : __mainmenu_group_factory(p_guid,p_parent,p_priority) {}
131 };
132 
133 class mainmenu_group_popup_factory : public __mainmenu_group_popup_factory {
134 public:
135  mainmenu_group_popup_factory(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority,const char * p_name) : __mainmenu_group_popup_factory(p_guid,p_parent,p_priority,p_name) {}
136 };
137 
138 template<typename T>
140 
141 
142 
143 
144 
145 
146 // \since 1.0
147 class NOVTABLE mainmenu_node : public service_base {
148  FB2K_MAKE_SERVICE_INTERFACE(mainmenu_node, service_base)
149 public:
150  enum { //same as contextmenu_item_node::t_type
151  type_group,type_command,type_separator
152  };
153 
154  virtual t_uint32 get_type() = 0;
155  virtual void get_display(pfc::string_base & text, t_uint32 & flags) = 0;
157  virtual t_size get_children_count() = 0;
159  virtual ptr get_child(t_size index) = 0;
161  virtual void execute(service_ptr_t<service_base> callback) = 0;
163  virtual GUID get_guid() = 0;
165  virtual bool get_description(pfc::string_base & out) {return false;}
166 
167 };
168 
170 public:
171  t_uint32 get_type() {return type_separator;}
172  void get_display(pfc::string_base & text, t_uint32 & flags) {text = ""; flags = 0;}
174  ptr get_child(t_size index) {throw pfc::exception_invalid_params();}
177 };
178 
180 public:
181  t_uint32 get_type() {return type_command;}
183  ptr get_child(t_size index) {throw pfc::exception_invalid_params();}
184 /*
185  void get_display(pfc::string_base & text, t_uint32 & flags);
186  void execute(service_ptr_t<service_base> callback);
187  GUID get_guid();
188  bool get_description(pfc::string_base & out) {return false;}
189 */
190 };
191 
193 public:
194  t_uint32 get_type() {return type_group;}
197 /*
198  void get_display(pfc::string_base & text, t_uint32 & flags);
199  t_size get_children_count();
200  ptr get_child(t_size index);
201 */
202 };
203 
204 
205 // \since 1.0
206 class NOVTABLE mainmenu_commands_v2 : public mainmenu_commands {
207  FB2K_MAKE_SERVICE_INTERFACE(mainmenu_commands_v2, mainmenu_commands)
208 public:
209  virtual bool is_command_dynamic(t_uint32 index) = 0;
211  virtual mainmenu_node::ptr dynamic_instantiate(t_uint32 index) = 0;
213  virtual bool dynamic_execute(t_uint32 index, const GUID & subID, service_ptr_t<service_base> callback);
214 };
virtual bool get_description(pfc::string_base &out)
Valid only if type is type_command.
Definition: menu.h:165
mainmenu_group_popup_impl(const GUID &p_guid, const GUID &p_parent, t_uint32 p_priority, const char *p_name)
Definition: menu.h:116
void execute(service_ptr_t< service_base >)
Valid only if type is type_command.
Definition: menu.h:175
static const GUID edit_part3
Definition: menu.h:91
t_uint32 get_sort_priority()
Definition: menu.h:119
Definition: pfc.h:71
t_uint32 get_type()
Definition: menu.h:171
void get_display_string(pfc::string_base &p_out)
Definition: menu.h:120
void get_name(pfc::string_base &out)
Definition: menu.h:13
GUID get_guid()
Valid only if type is type_command.
Definition: menu.h:176
t_size get_children_count()
Valid only if type is type_group.
Definition: menu.h:182
GUID get_guid()
Definition: menu.h:107
void execute(service_ptr_t< service_base > callback)
Valid only if type is type_command.
Definition: menu.h:195
mainmenu_group_impl(const GUID &p_guid, const GUID &p_parent, t_uint32 p_priority)
Definition: menu.h:106
GUID get_parent()
Definition: menu.h:108
static const GUID view
Definition: menu.h:87
t_uint32 m_priority
Definition: menu.h:111
virtual bool get_display(t_uint32 p_index, pfc::string_base &p_text, t_uint32 &p_flags)
Retrieves display string and display flags to use when menu is about to be displayed. If returns false, menu item won&#39;t be displayed. You can create keyboard-shortcut-only commands by always returning false from get_display().
Definition: menu.h:45
ptr get_child(t_size index)
Valid only if type is type_group.
Definition: menu.h:174
size_t t_size
Definition: int_types.h:48
void get_display(pfc::string_base &text, t_uint32 &flags)
Definition: menu.h:172
static const GUID library_refresh
Definition: menu.h:95
static const GUID view_visualisations
Definition: menu.h:90
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
GUID get_guid()
Valid only if type is type_command.
Definition: menu.h:196
t_size get_children_count()
Valid only if type is type_group.
Definition: menu.h:173
static const GUID file_etc_preferences
Definition: menu.h:93
mainmenu_group_popup_factory(const GUID &p_guid, const GUID &p_parent, t_uint32 p_priority, const char *p_name)
Definition: menu.h:135
static const GUID file_playlist
Definition: menu.h:88
static const GUID playback_etc
Definition: menu.h:89
ptr get_child(t_size index)
Valid only if type is type_group.
Definition: menu.h:183
t_uint32 get_sort_priority()
Definition: menu.h:109
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
static const GUID help_about
Definition: menu.h:94
virtual t_uint32 get_sort_priority()
Retrieves sorting priority of the command; the lower the number, the upper in the menu your commands ...
Definition: menu.h:43
static const GUID edit_part2_sort
Definition: menu.h:92
t_uint32 get_type()
Definition: menu.h:194
const GUID guid_null
Definition: guid.cpp:175
mainmenu_group_factory(const GUID &p_guid, const GUID &p_parent, t_uint32 p_priority)
Definition: menu.h:130
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
t_uint32 get_type()
Definition: menu.h:181
uint32_t t_uint32
Definition: int_types.h:5