foobar2000 SDK  2015-01-14
contextmenu_manager.h
Go to the documentation of this file.
1 class NOVTABLE keyboard_shortcut_manager : public service_base
2 {
3 public:
5 
7  {
12  };
13 
14 
15  virtual bool process_keydown(shortcut_type type,const pfc::list_base_const_t<metadb_handle_ptr> & data,unsigned keycode)=0;
16  virtual bool process_keydown_ex(shortcut_type type,const pfc::list_base_const_t<metadb_handle_ptr> & data,unsigned keycode,const GUID & caller)=0;
17  bool on_keydown(shortcut_type type,WPARAM wp);
18  bool on_keydown_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
19 
20  bool on_keydown_auto(WPARAM wp);
21  bool on_keydown_auto_playlist(WPARAM wp);
22  bool on_keydown_auto_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
23 
24  bool on_keydown_restricted_auto(WPARAM wp);
25  bool on_keydown_restricted_auto_playlist(WPARAM wp);
26  bool on_keydown_restricted_auto_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
27 
28  virtual bool get_key_description_for_action(const GUID & p_command,const GUID & p_subcommand, pfc::string_base & out, shortcut_type type, bool is_global)=0;
29 
30  static bool is_text_key(t_uint32 vkCode);
31  static bool is_typing_key(t_uint32 vkCode);
32  static bool is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers);
33  static bool is_typing_modifier(t_uint32 flags);
34  static bool is_typing_message(HWND editbox, const MSG * msg);
35  static bool is_typing_message(const MSG * msg);
36 
37  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(keyboard_shortcut_manager);
38 };
39 
40 
43 public:
45  virtual bool process_keydown_simple(t_uint32 keycode) = 0;
46 
48  bool pretranslate_message(const MSG * msg, HWND thisPopupWnd);
49 
51 };
52 
53 class NOVTABLE contextmenu_node {
54 public:
55  virtual contextmenu_item_node::t_type get_type()=0;
56  virtual const char * get_name()=0;
57  virtual t_size get_num_children()=0;//TYPE_POPUP only
58  virtual contextmenu_node * get_child(t_size n)=0;//TYPE_POPUP only
59  virtual unsigned get_display_flags()=0;//TYPE_COMMAND/TYPE_POPUP only, see contextmenu_item::FLAG_*
60  virtual unsigned get_id()=0;//TYPE_COMMAND only, returns zero-based index (helpful for win32 menu command ids)
61  virtual void execute()=0;//TYPE_COMMAND only
62  virtual bool get_description(pfc::string_base & out)=0;//TYPE_COMMAND only
63  virtual bool get_full_name(pfc::string_base & out)=0;//TYPE_COMMAND only
64  virtual void * get_glyph()=0;//RESERVED, do not use
65 protected:
68 };
69 
70 
71 
72 class NOVTABLE contextmenu_manager : public service_base
73 {
74 public:
75  enum
76  {
77  flag_show_shortcuts = 1 << 0,
78  flag_show_shortcuts_global = 1 << 1,
81  flag_view_reduced = 1 << 2,
84  flag_view_full = 1 << 3,
85 
86  //for compatibility
87  FLAG_SHOW_SHORTCUTS = 1,
88  FLAG_SHOW_SHORTCUTS_GLOBAL = 2,
89  };
90 
91  virtual void init_context(metadb_handle_list_cref data,unsigned flags) = 0;
92  virtual void init_context_playlist(unsigned flags) = 0;
93  virtual contextmenu_node * get_root() = 0;//releasing contextmenu_manager service releaases nodes; root may be null in case of error or something
94  virtual contextmenu_node * find_by_id(unsigned id)=0;
95  virtual void set_shortcut_preference(const keyboard_shortcut_manager::shortcut_type * data,unsigned count)=0;
96 
97 
98 
100 
101 #ifdef WIN32
102  static void win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id);//menu item identifiers are base_id<=N<base_id+max_id (if theres too many items, they will be clipped)
103  static void win32_run_menu_context(HWND parent,metadb_handle_list_cref data, const POINT * pt = 0,unsigned flags = 0);
104  static void win32_run_menu_context_playlist(HWND parent,const POINT * pt = 0,unsigned flags = 0);
105  void win32_run_menu_popup(HWND parent,const POINT * pt = 0);
106  void win32_build_menu(HMENU menu,int base_id,int max_id) {win32_build_menu(menu,get_root(),base_id,max_id);}
107 
108 
109 #endif
110 
111  virtual void init_context_ex(metadb_handle_list_cref data,unsigned flags,const GUID & caller)=0;
112  virtual bool init_context_now_playing(unsigned flags)=0;//returns false if not playing
113 
114  bool execute_by_id(unsigned id);
115 
116  bool get_description_by_id(unsigned id,pfc::string_base & out);
117 
118 
119  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(contextmenu_manager);
120 };
121 
123 class NOVTABLE contextmenu_group_manager : public service_base {
124  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(contextmenu_group_manager)
125 public:
126  virtual GUID path_to_group(const char * path) = 0;
127  virtual void group_to_path(const GUID & group, pfc::string_base & path) = 0;
128 };
static bool service_enum_create_t(service_ptr_t< T > &p_out, t_size p_index)
Definition: service.h:433
Definition: pfc.h:53
static void g_create(service_ptr_t< contextmenu_manager > &p_out)
void standard_api_create_t(service_ptr_t< T > &p_out)
Definition: service.h:492
bool pretranslate_message(const MSG *msg, HWND thisPopupWnd)
Helper for use with message filters.
virtual bool process_keydown_simple(t_uint32 keycode)=0
Deprecates old keyboard_shortcut_manager methods. If the action requires selected items...
size_t t_size
Definition: int_types.h:48
static bool g_get(service_ptr_t< keyboard_shortcut_manager > &p_out)
void win32_build_menu(HMENU menu, int base_id, int max_id)
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
FB2K_MAKE_SERVICE_INTERFACE(keyboard_shortcut_manager_v2, keyboard_shortcut_manager)
uint32_t t_uint32
Definition: int_types.h:5