foobar2000 SDK  2015-01-14
Functions
menu_manager.cpp File Reference

Go to the source code of this file.

Functions

static bool filterTypableWindowMessage (const MSG *msg, t_uint32 modifiers)
 
static void fix_ampersand (const char *src, pfc::string_base &out)
 
static unsigned flags_to_win32 (unsigned flags)
 
static t_uint32 get_key_code (WPARAM wp)
 
static t_uint32 get_key_code (WPARAM wp, t_uint32 mods)
 
static bool should_relay_key_restricted (UINT p_key)
 
static bool test_key (unsigned k)
 

Function Documentation

static bool filterTypableWindowMessage ( const MSG *  msg,
t_uint32  modifiers 
)
static

Definition at line 350 of file menu_manager.cpp.

350  {
351  if (keyboard_shortcut_manager::is_typing_key_combo((t_uint32)msg->wParam, modifiers)) {
352  try {
353  if (static_api_ptr_t<ui_element_typable_window_manager>()->is_registered(msg->hwnd)) return false;
354  } catch(exception_service_not_found) {}
355  }
356  return true;
357 }
static bool is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers)
Helper template used to easily access core services. Usage: static_api_ptr_t api; api->doso...
Definition: service.h:533
uint32_t t_uint32
Definition: int_types.h:5
static void fix_ampersand ( const char *  src,
pfc::string_base out 
)
static

Definition at line 5 of file menu_manager.cpp.

6 {
7  out.reset();
8  unsigned ptr = 0;
9  while(src[ptr])
10  {
11  if (src[ptr]=='&')
12  {
13  out.add_string("&&");
14  ptr++;
15  while(src[ptr]=='&')
16  {
17  out.add_string("&&");
18  ptr++;
19  }
20  }
21  else out.add_byte(src[ptr++]);
22  }
23 }
virtual void add_string(const char *p_string, t_size p_length=~0)=0
void add_byte(char c)
Definition: string_base.h:42
static unsigned flags_to_win32 ( unsigned  flags)
static

Definition at line 25 of file menu_manager.cpp.

26 {
27  unsigned ret = 0;
28  if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) {/* dealt with elsewhere */}
29  else if (flags & contextmenu_item_node::FLAG_CHECKED) ret |= MF_CHECKED;
30  if (flags & contextmenu_item_node::FLAG_DISABLED) ret |= MF_DISABLED;
31  if (flags & contextmenu_item_node::FLAG_GRAYED) ret |= MF_GRAYED;
32  return ret;
33 }
static t_uint32 get_key_code ( WPARAM  wp)
static

Definition at line 272 of file menu_manager.cpp.

272  {
273  t_uint32 code = (t_uint32)(wp & 0xFF);
274  if (test_key(VK_CONTROL)) code|=F_CTRL;
275  if (test_key(VK_SHIFT)) code|=F_SHIFT;
276  if (test_key(VK_MENU)) code|=F_ALT;
277  if (test_key(VK_LWIN) || test_key(VK_RWIN)) code|=F_WIN;
278  return code;
279 }
uint32_t t_uint32
Definition: int_types.h:5
static t_uint32 get_key_code ( WPARAM  wp,
t_uint32  mods 
)
static

Definition at line 281 of file menu_manager.cpp.

281  {
282  t_uint32 code = (t_uint32)(wp & 0xFF);
283  if (mods & MOD_CONTROL) code|=F_CTRL;
284  if (mods & MOD_SHIFT) code|=F_SHIFT;
285  if (mods & MOD_ALT) code|=F_ALT;
286  if (mods & MOD_WIN) code|=F_WIN;
287  return code;
288 }
uint32_t t_uint32
Definition: int_types.h:5
static bool should_relay_key_restricted ( UINT  p_key)
static

Definition at line 325 of file menu_manager.cpp.

325  {
326  switch(p_key) {
327  case VK_LEFT:
328  case VK_RIGHT:
329  case VK_UP:
330  case VK_DOWN:
331  return false;
332  default:
333  return (p_key >= VK_F1 && p_key <= VK_F24) || IsKeyPressed(VK_CONTROL) || IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN);
334  }
335 }
bool IsKeyPressed(unsigned vk)
static bool test_key ( unsigned  k)
static

Definition at line 262 of file menu_manager.cpp.

263 {
264  return (GetKeyState(k) & 0x8000) ? true : false;
265 }