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

#include <contextmenu.h>

+ Inheritance diagram for contextmenu_item:

Public Types

enum  t_enabled_state { FORCE_OFF, DEFAULT_OFF, DEFAULT_ON }
 
- Public Types inherited from service_base
typedef service_base t_interface
 

Public Member Functions

 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT (contextmenu_item)
 
virtual t_enabled_state get_enabled_state (unsigned p_index)=0
 
virtual void get_item_default_path (unsigned p_index, pfc::string_base &p_out)
 
virtual bool get_item_description (unsigned p_index, pfc::string_base &p_out)=0
 
virtual GUID get_item_guid (unsigned p_index)=0
 
virtual void get_item_name (unsigned p_index, pfc::string_base &p_out)=0
 
virtual unsigned get_num_items ()=0
 
GUID get_parent_ ()
 
GUID get_parent_fallback ()
 
virtual contextmenu_item_node_rootinstantiate_item (unsigned p_index, metadb_handle_list_cref p_data, const GUID &p_caller)=0
 
virtual void item_execute_simple (unsigned p_index, const GUID &p_node, metadb_handle_list_cref p_data, const GUID &p_caller)=0
 
bool item_get_display_data (pfc::string_base &p_out, unsigned &displayflags, unsigned p_index, const GUID &p_node, metadb_handle_list_cref p_data, const GUID &p_caller)
 
bool item_get_display_data_root (pfc::string_base &p_out, unsigned &displayflags, unsigned p_index, metadb_handle_list_cref p_data, const GUID &p_caller)
 
- 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 Attributes

static const GUID caller_active_playlist
 
static const GUID caller_active_playlist_selection
 
static const GUID caller_keyboard_shortcut_list
 
static const GUID caller_media_library_viewer
 
static const GUID caller_now_playing
 
static const GUID caller_playlist = caller_active_playlist_selection
 
static const GUID caller_playlist_manager
 
static const GUID caller_undefined
 

Additional Inherited Members

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

Detailed Description

Service class for declaring context menu commands.
See contextmenu_item_simple for implementation helper without dynamic menu generation features.
All methods are valid from main app thread only.

Definition at line 100 of file contextmenu.h.

Member Enumeration Documentation

Enumerator
FORCE_OFF 
DEFAULT_OFF 
DEFAULT_ON 

Definition at line 102 of file contextmenu.h.

Member Function Documentation

contextmenu_item::FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT ( contextmenu_item  )
virtual t_enabled_state contextmenu_item::get_enabled_state ( unsigned  p_index)
pure virtual

Controls default state of context menu preferences for this item:
Return DEFAULT_ON to show this item in the context menu by default - useful for most cases.
Return DEFAULT_OFF to hide this item in the context menu by default - useful for rarely used utility commands.
Return FORCE_OFF to hide this item by default and prevent the user from making it visible (very rarely used).
Values returned by this method should be constant for this context menu item and not change later. Do not use this to conditionally hide the item - return false from get_display_data() instead.

Implemented in contextmenu_item_simple.

virtual void contextmenu_item::get_item_default_path ( unsigned  p_index,
pfc::string_base p_out 
)
inlinevirtual

Obsolete since v1.0, don't use or override in new components.

Definition at line 117 of file contextmenu.h.

117 {p_out = "";}
virtual bool contextmenu_item::get_item_description ( unsigned  p_index,
pfc::string_base p_out 
)
pure virtual

Retrieves item's description to show in the status bar. Set p_out to the string to be displayed and return true if you provide a description, return false otherwise.

Implemented in contextmenu_item_simple, and myitem.

virtual GUID contextmenu_item::get_item_guid ( unsigned  p_index)
pure virtual

Retrieves GUID of the context menu item.

Implemented in contextmenu_item_simple, and myitem.

virtual void contextmenu_item::get_item_name ( unsigned  p_index,
pfc::string_base p_out 
)
pure virtual

Retrieves human-readable name of the context menu item.

Implemented in contextmenu_item_simple, and myitem.

virtual unsigned contextmenu_item::get_num_items ( )
pure virtual

Retrieves number of menu items provided by this contextmenu_item implementation.

Implemented in contextmenu_item_simple, and myitem.

GUID contextmenu_item::get_parent_ ( )

Definition at line 54 of file menu_item.cpp.

54  {
55  contextmenu_item_v2::ptr v2;
56  if (service_query_t(v2)) {
57  return v2->get_parent();
58  } else {
59  return get_parent_fallback();
60  }
61 }
bool service_query_t(service_ptr_t< T > &p_out)
Queries whether the object supports specific interface and retrieves a pointer to that interface...
Definition: service.h:350
GUID get_parent_fallback()
Definition: menu_item.cpp:43
GUID contextmenu_item::get_parent_fallback ( )

Definition at line 43 of file menu_item.cpp.

43  {
44  unsigned total = get_num_items();
45  if (total < 1) return pfc::guid_null; // hide the item
46  pfc::string_formatter path, base; this->get_item_default_path(0, base);
47  for(unsigned walk = 1; walk < total; ++walk) {
48  this->get_item_default_path(walk, path);
49  if (strcmp(path, base) != 0) return contextmenu_groups::legacy;
50  }
51  return static_api_ptr_t<contextmenu_group_manager>()->path_to_group(base);
52 }
virtual void get_item_default_path(unsigned p_index, pfc::string_base &p_out)
Obsolete since v1.0, don&#39;t use or override in new components.
Definition: contextmenu.h:117
virtual unsigned get_num_items()=0
Retrieves number of menu items provided by this contextmenu_item implementation.
static const GUID legacy
Definition: contextmenu.h:282
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
const GUID guid_null
Definition: guid.cpp:175
virtual contextmenu_item_node_root* contextmenu_item::instantiate_item ( unsigned  p_index,
metadb_handle_list_cref  p_data,
const GUID p_caller 
)
pure virtual

Instantiates a context menu item (including sub-node tree for items that contain dynamically-generated sub-items).

Implemented in contextmenu_item_simple.

virtual void contextmenu_item::item_execute_simple ( unsigned  p_index,
const GUID p_node,
metadb_handle_list_cref  p_data,
const GUID p_caller 
)
pure virtual

Executes the menu item command without going thru the instantiate_item path. For items with dynamically-generated sub-items, p_node is identifies of the sub-item command to execute.

Implemented in contextmenu_item_simple.

bool contextmenu_item::item_get_display_data ( pfc::string_base p_out,
unsigned &  displayflags,
unsigned  p_index,
const GUID p_node,
metadb_handle_list_cref  p_data,
const GUID p_caller 
)

Definition at line 30 of file menu_item.cpp.

31 {
32  bool status = false;
33  pfc::ptrholder_t<contextmenu_item_node_root> root ( instantiate_item(p_index,p_data,p_caller) );
34  if (root.is_valid())
35  {
36  contextmenu_item_node * node = g_find_node(p_node,root.get_ptr());
37  if (node) status = node->get_display_data(p_out,p_displayflags,p_data,p_caller);
38  }
39  return status;
40 }
virtual bool get_display_data(pfc::string_base &p_out, unsigned &p_displayflags, metadb_handle_list_cref p_data, const GUID &p_caller)=0
virtual contextmenu_item_node_root * instantiate_item(unsigned p_index, metadb_handle_list_cref p_data, const GUID &p_caller)=0
Instantiates a context menu item (including sub-node tree for items that contain dynamically-generate...
Assumes t_freefunc to never throw exceptions.
Definition: other.h:93
bool contextmenu_item::item_get_display_data_root ( pfc::string_base p_out,
unsigned &  displayflags,
unsigned  p_index,
metadb_handle_list_cref  p_data,
const GUID p_caller 
)

Definition at line 5 of file menu_item.cpp.

6 {
7  bool status = false;
8  pfc::ptrholder_t<contextmenu_item_node_root> root ( instantiate_item(p_index,p_data,p_caller) );
9  if (root.is_valid()) status = root->get_display_data(p_out,p_displayflags,p_data,p_caller);
10  return status;
11 }
virtual contextmenu_item_node_root * instantiate_item(unsigned p_index, metadb_handle_list_cref p_data, const GUID &p_caller)=0
Instantiates a context menu item (including sub-node tree for items that contain dynamically-generate...
Assumes t_freefunc to never throw exceptions.
Definition: other.h:93

Field Documentation

FOOGUIDDECL const GUID contextmenu_item::caller_active_playlist
static
Initial value:
=
{ 0xb3cc1030, 0xef26, 0x45cf, { 0xa8, 0x4a, 0x7f, 0xc1, 0x69, 0xbc, 0x9f, 0xfb } }

Definition at line 138 of file contextmenu.h.

FOOGUIDDECL const GUID contextmenu_item::caller_active_playlist_selection
static
Initial value:
=
{ 0x47502ba1, 0x816d, 0x4a3e, { 0xad, 0xe5, 0xa7, 0xa9, 0x86, 0xa, 0x67, 0xdb } }

Definition at line 138 of file contextmenu.h.

FOOGUIDDECL const GUID contextmenu_item::caller_keyboard_shortcut_list
static
Initial value:
=
{ 0xfabee3e9, 0x8901, 0x4df4, { 0xa2, 0xd7, 0xb9, 0x89, 0x8d, 0x86, 0xc3, 0x9b } }

Definition at line 138 of file contextmenu.h.

FOOGUIDDECL const GUID contextmenu_item::caller_media_library_viewer
static
Initial value:
=
{ 0xfda07c56, 0x5d0, 0x4b84, { 0x9f, 0xbd, 0xa8, 0xbe, 0x55, 0x6d, 0x47, 0x4d } }

Definition at line 138 of file contextmenu.h.

FOOGUIDDECL const GUID contextmenu_item::caller_now_playing
static
Initial value:
=
{ 0x994c0d0e, 0x319e, 0x45f3, { 0x92, 0xfc, 0x51, 0x86, 0x16, 0xe7, 0x3a, 0xdc } }

Definition at line 138 of file contextmenu.h.

FOOGUIDDECL const GUID contextmenu_item::caller_playlist = caller_active_playlist_selection
static

Deprecated - use caller_active_playlist_selection instead.

Definition at line 136 of file contextmenu.h.

FOOGUIDDECL const GUID contextmenu_item::caller_playlist_manager
static
Initial value:
=
{ 0x5fdcd5e8, 0x6eb2, 0x4454, { 0x9e, 0xda, 0x52, 0x75, 0x22, 0x89, 0x3b, 0xed } }

Definition at line 138 of file contextmenu.h.

FOOGUIDDECL const GUID contextmenu_item::caller_undefined
static
Initial value:
=
{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }

Definition at line 139 of file contextmenu.h.


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