foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Static Public Member Functions
contextmenu_managerabstract

#include <contextmenu_manager.h>

+ Inheritance diagram for contextmenu_manager:

Public Types

enum  {
  flag_show_shortcuts = 1 << 0, flag_show_shortcuts_global = 1 << 1, flag_view_reduced = 1 << 2, flag_view_full = 1 << 3,
  FLAG_SHOW_SHORTCUTS = 1, FLAG_SHOW_SHORTCUTS_GLOBAL = 2
}
 
- Public Types inherited from service_base
typedef service_base t_interface
 

Public Member Functions

bool execute_by_id (unsigned id)
 
 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT (contextmenu_manager)
 
virtual contextmenu_nodefind_by_id (unsigned id)=0
 
bool get_description_by_id (unsigned id, pfc::string_base &out)
 
virtual contextmenu_nodeget_root ()=0
 
virtual void init_context (metadb_handle_list_cref data, unsigned flags)=0
 
virtual void init_context_ex (metadb_handle_list_cref data, unsigned flags, const GUID &caller)=0
 
virtual bool init_context_now_playing (unsigned flags)=0
 
virtual void init_context_playlist (unsigned flags)=0
 
virtual void set_shortcut_preference (const keyboard_shortcut_manager::shortcut_type *data, unsigned count)=0
 
void win32_build_menu (HMENU menu, int base_id, int max_id)
 
void win32_run_menu_popup (HWND parent, const POINT *pt=0)
 
- Public Member Functions inherited from service_base
template<typename outPtr_t >
bool cast (outPtr_t &outPtr)
 
virtual int service_add_ref ()=0 throw ()
 
virtual bool service_query (service_ptr_t< service_base > &p_out, const GUID &p_guid)
 
template<class T >
bool service_query_t (service_ptr_t< T > &p_out)
 
virtual int service_release ()=0 throw ()
 

Static Public Member Functions

static void g_create (service_ptr_t< contextmenu_manager > &p_out)
 
static void win32_build_menu (HMENU menu, contextmenu_node *parent, int base_id, int max_id)
 
static void win32_run_menu_context (HWND parent, metadb_handle_list_cref data, const POINT *pt=0, unsigned flags=0)
 
static void win32_run_menu_context_playlist (HWND parent, const POINT *pt=0, unsigned flags=0)
 

Additional Inherited Members

- Protected Member Functions inherited from service_base
 service_base ()
 
 ~service_base ()
 

Detailed Description

Definition at line 72 of file contextmenu_manager.h.

Member Enumeration Documentation

anonymous enum
Enumerator
flag_show_shortcuts 
flag_show_shortcuts_global 
flag_view_reduced 
Since
1.0 To control which commands are shown, you should specify either flag_view_reduced or flag_view_full. If neither is specified, the implementation will decide automatically based on shift key being pressed, for backwards compatibility.
flag_view_full 
Since
1.0 To control which commands are shown, you should specify either flag_view_reduced or flag_view_full. If neither is specified, the implementation will decide automatically based on shift key being pressed, for backwards compatibility.
FLAG_SHOW_SHORTCUTS 
FLAG_SHOW_SHORTCUTS_GLOBAL 

Definition at line 75 of file contextmenu_manager.h.

Member Function Documentation

bool contextmenu_manager::execute_by_id ( unsigned  id)

Definition at line 82 of file menu_manager.cpp.

82  {
83  contextmenu_node * ptr = find_by_id(id);
84  if (ptr == NULL) return false;
85  ptr->execute();
86  return true;
87 }
virtual void execute()=0
virtual contextmenu_node * find_by_id(unsigned id)=0
contextmenu_manager::FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT ( contextmenu_manager  )
virtual contextmenu_node* contextmenu_manager::find_by_id ( unsigned  id)
pure virtual
static void contextmenu_manager::g_create ( service_ptr_t< contextmenu_manager > &  p_out)
inlinestatic

Definition at line 99 of file contextmenu_manager.h.

99 {standard_api_create_t(p_out);}
void standard_api_create_t(service_ptr_t< T > &p_out)
Definition: service.h:492
bool contextmenu_manager::get_description_by_id ( unsigned  id,
pfc::string_base out 
)

Definition at line 77 of file menu_manager.cpp.

77  {
78  contextmenu_node * ptr = find_by_id(id);
79  if (ptr == NULL) return false;
80  return ptr->get_description(out);
81 }
virtual contextmenu_node * find_by_id(unsigned id)=0
virtual bool get_description(pfc::string_base &out)=0
virtual contextmenu_node* contextmenu_manager::get_root ( )
pure virtual
virtual void contextmenu_manager::init_context ( metadb_handle_list_cref  data,
unsigned  flags 
)
pure virtual
virtual void contextmenu_manager::init_context_ex ( metadb_handle_list_cref  data,
unsigned  flags,
const GUID caller 
)
pure virtual
virtual bool contextmenu_manager::init_context_now_playing ( unsigned  flags)
pure virtual
virtual void contextmenu_manager::init_context_playlist ( unsigned  flags)
pure virtual
virtual void contextmenu_manager::set_shortcut_preference ( const keyboard_shortcut_manager::shortcut_type data,
unsigned  count 
)
pure virtual
void contextmenu_manager::win32_build_menu ( HMENU  menu,
contextmenu_node parent,
int  base_id,
int  max_id 
)
static

Definition at line 35 of file menu_manager.cpp.

36 {
37  if (parent!=0 && parent->get_type()==contextmenu_item_node::TYPE_POPUP)
38  {
40  t_size child_idx,child_num = parent->get_num_children();
41  for(child_idx=0;child_idx<child_num;child_idx++)
42  {
43  contextmenu_node * child = parent->get_child(child_idx);
44  if (child)
45  {
46  const char * name = child->get_name();
47  if (strchr(name,'&')) {fix_ampersand(name,temp);name=temp;}
50  {
51  HMENU new_menu = CreatePopupMenu();
52  uAppendMenu(menu,MF_STRING|MF_POPUP | flags_to_win32(child->get_display_flags()),(UINT_PTR)new_menu,name);
53  win32_build_menu(new_menu,child,base_id,max_id);
54  }
55  else if (type==contextmenu_item_node::TYPE_SEPARATOR)
56  {
57  uAppendMenu(menu,MF_SEPARATOR,0,0);
58  }
60  {
61  int id = child->get_id();
62  if (id>=0 && (max_id<0 || id<max_id))
63  {
64  const unsigned flags = child->get_display_flags();
65  const UINT ID = base_id+id;
66  uAppendMenu(menu,MF_STRING | flags_to_win32(flags),ID,name);
67  if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) CheckMenuRadioItem(menu,ID,ID,ID,MF_BYCOMMAND);
68  }
69  }
70  }
71  }
72  }
73 }
virtual contextmenu_node * get_child(t_size n)=0
virtual t_size get_num_children()=0
virtual contextmenu_item_node::t_type get_type()=0
virtual const char * get_name()=0
size_t t_size
Definition: int_types.h:48
virtual unsigned get_id()=0
BOOL SHARED_EXPORT uAppendMenu(HMENU menu, UINT flags, UINT_PTR id, const char *content)
static void win32_build_menu(HMENU menu, contextmenu_node *parent, int base_id, int max_id)
virtual unsigned get_display_flags()=0
string8_t< pfc::alloc_fast_aggressive > string8_fastalloc
Definition: string_base.h:436
void contextmenu_manager::win32_build_menu ( HMENU  menu,
int  base_id,
int  max_id 
)
inline

Definition at line 106 of file contextmenu_manager.h.

106 {win32_build_menu(menu,get_root(),base_id,max_id);}
virtual contextmenu_node * get_root()=0
static void win32_build_menu(HMENU menu, contextmenu_node *parent, int base_id, int max_id)
void contextmenu_manager::win32_run_menu_context ( HWND  parent,
metadb_handle_list_cref  data,
const POINT *  pt = 0,
unsigned  flags = 0 
)
static

Definition at line 123 of file menu_manager.cpp.

124 {
127  manager->init_context(data,flags);
128  manager->win32_run_menu_popup(parent,pt);
129 }
static void g_create(service_ptr_t< contextmenu_manager > &p_out)
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
void contextmenu_manager::win32_run_menu_context_playlist ( HWND  parent,
const POINT *  pt = 0,
unsigned  flags = 0 
)
static

Definition at line 131 of file menu_manager.cpp.

132 {
135  manager->init_context_playlist(flags);
136  manager->win32_run_menu_popup(parent,pt);
137 }
static void g_create(service_ptr_t< contextmenu_manager > &p_out)
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
void contextmenu_manager::win32_run_menu_popup ( HWND  parent,
const POINT *  pt = 0 
)

Definition at line 91 of file menu_manager.cpp.

92 {
93  enum {ID_CUSTOM_BASE = 1};
94 
95  int cmd;
96 
97  {
98  POINT p;
99  if (pt) p = *pt;
100  else GetCursorPos(&p);
101 
102  HMENU hmenu = CreatePopupMenu();
103  try {
104 
105  win32_build_menu(hmenu,ID_CUSTOM_BASE,-1);
107 
108  cmd = TrackPopupMenu(hmenu,TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,p.x,p.y,0,parent,0);
109  } catch(...) {DestroyMenu(hmenu); throw;}
110 
111  DestroyMenu(hmenu);
112  }
113 
114  if (cmd>0)
115  {
116  if (cmd>=ID_CUSTOM_BASE)
117  {
118  execute_by_id(cmd - ID_CUSTOM_BASE);
119  }
120  }
121 }
void win32_auto_mnemonics(HMENU menu)
static void win32_build_menu(HMENU menu, contextmenu_node *parent, int base_id, int max_id)
bool execute_by_id(unsigned id)

The documentation for this class was generated from the following files: