41 for(child_idx=0;child_idx<child_num;child_idx++)
46 const char * name = child->
get_name();
51 HMENU new_menu = CreatePopupMenu();
62 if (
id>=0 && (max_id<0 ||
id<max_id))
65 const UINT ID = base_id+id;
79 if (ptr == NULL)
return false;
84 if (ptr == NULL)
return false;
93 enum {ID_CUSTOM_BASE = 1};
100 else GetCursorPos(&p);
102 HMENU hmenu = CreatePopupMenu();
108 cmd = TrackPopupMenu(hmenu,TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,p.x,p.y,0,parent,0);
109 }
catch(...) {DestroyMenu(hmenu);
throw;}
116 if (cmd>=ID_CUSTOM_BASE)
127 manager->init_context(data,flags);
128 manager->win32_run_menu_popup(parent,pt);
135 manager->init_context_playlist(flags);
136 manager->win32_run_menu_popup(parent,pt);
141 class mnemonic_manager
144 bool is_used(
unsigned c)
148 return !!strstr(used,temp);
151 static bool is_alphanumeric(
char c)
153 return (c>=
'a' && c<=
'z') || (c>=
'A' && c<='Z') || (c>=
'0' && c<=
'9');
168 bool check_string(
const char * src)
170 const char * ptr = src;
171 while(ptr = strchr(ptr,
'&'))
173 if (ptr[1]==
'&') ptr+=2;
179 if (!is_used(c)) used.add_char(
uCharLower(c));
188 if (check_string(src)) {out=src;
return false;}
190 while(src[idx]==
' ') idx++;
193 if (is_alphanumeric(src[idx]) && !is_used(src[idx]))
199 while(src[idx] && src[idx]!=
' ' && src[idx]!=
'\t') idx++;
200 if (src[idx]==
'\t')
break;
201 while(src[idx]==
' ') idx++;
208 if (src[idx]==
'\t')
break;
209 if (is_alphanumeric(src[idx]) && !is_used(src[idx]))
226 mnemonic_manager mgr;
227 unsigned n, m = GetMenuItemCount(menu);
232 if (type==MFT_STRING)
235 mgr.check_string(temp);
241 HMENU submenu = GetSubMenu(menu,n);
246 if (type==MFT_STRING)
248 unsigned state = submenu ? 0 : GetMenuState(menu,n,MF_BYPOSITION);
249 unsigned id = GetMenuItemID(menu,n);
251 if (mgr.process_string(temp,temp2))
253 uModifyMenu(menu,n,MF_BYPOSITION|MF_STRING|state,
id,temp2);
264 return (GetKeyState(k) & 0x8000) ?
true :
false;
267 #define F_SHIFT (HOTKEYF_SHIFT<<8) 268 #define F_CTRL (HOTKEYF_CONTROL<<8) 269 #define F_ALT (HOTKEYF_ALT<<8) 270 #define F_WIN (HOTKEYF_EXT<<8) 274 if (
test_key(VK_CONTROL)) code|=F_CTRL;
275 if (
test_key(VK_SHIFT)) code|=F_SHIFT;
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;
292 if (type==TYPE_CONTEXT)
return false;
300 return process_keydown_ex(TYPE_CONTEXT,data,
get_key_code(wp),caller);
305 if (on_keydown(TYPE_MAIN,wp))
return true;
306 if (on_keydown(TYPE_CONTEXT_PLAYLIST,wp))
return true;
307 if (on_keydown(TYPE_CONTEXT_NOW_PLAYING,wp))
return true;
315 api->activeplaylist_get_selected_items(data);
321 if (on_keydown_context(data,wp,caller))
return true;
322 else return on_keydown_auto(wp);
339 return on_keydown_auto(wp);
343 return on_keydown_auto_playlist(wp);
347 return on_keydown_auto_context(data,wp,caller);
354 }
catch(exception_service_not_found) {}
360 switch(msg->message) {
363 if (thisPopupWnd != NULL &&
FindOwningPopup(msg->hwnd) == thisPopupWnd) {
366 if (process_keydown_simple(
get_key_code(msg->wParam,modifiers)))
return true;
376 return vkCode == VK_SPACE
377 || (vkCode >=
'0' && vkCode < 0x40)
378 || (vkCode > 0x40 && vkCode < VK_LWIN)
379 || (vkCode >= VK_NUMPAD0 && vkCode <= VK_DIVIDE)
380 || (vkCode >= VK_OEM_1 && vkCode <= VK_OEM_3)
381 || (vkCode >= VK_OEM_4 && vkCode <= VK_OEM_8)
386 return is_text_key(vkCode)
388 || vkCode == VK_RETURN
389 || vkCode == VK_INSERT
390 || (vkCode > VK_SPACE && vkCode <
'0');
394 if (!is_typing_modifier(modifiers))
return false;
395 return is_typing_key(vkCode);
400 return flags == 0 || flags == (MOD_ALT | MOD_CONTROL);
404 if (msg->hwnd != editbox)
return false;
405 return is_typing_message(msg);
408 if (msg->message != WM_KEYDOWN && msg->message != WM_SYSKEYDOWN)
return false;
static bool is_typing_modifier(t_uint32 flags)
bool on_keydown_context(const pfc::list_base_const_t< metadb_handle_ptr > &data, WPARAM wp, const GUID &caller)
virtual void add_string(const char *p_string, t_size p_length=~0)=0
bool on_keydown_restricted_auto(WPARAM wp)
static bool is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers)
t_size utf8_encode_char(unsigned c, char *out)
bool on_keydown_restricted_auto_playlist(WPARAM wp)
UINT SHARED_EXPORT uGetMenuItemType(HMENU menu, UINT position)
bool IsKeyPressed(unsigned vk)
bool pretranslate_message(const MSG *msg, HWND thisPopupWnd)
Helper for use with message filters.
bool on_keydown(shortcut_type type, WPARAM wp)
bool on_keydown_restricted_auto_context(const pfc::list_base_const_t< metadb_handle_ptr > &data, WPARAM wp, const GUID &caller)
virtual t_size get_count() const =0
unsigned GetHotkeyModifierFlags()
Returns current modifier keys pressed, using win32 MOD_* flags.
UINT SHARED_EXPORT uCharLower(UINT c)
BOOL SHARED_EXPORT uAppendMenu(HMENU menu, UINT flags, UINT_PTR id, const char *content)
static bool is_text_key(t_uint32 vkCode)
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
BOOL SHARED_EXPORT uModifyMenu(HMENU menu, UINT id, UINT flags, UINT newitem, const char *data)
BOOL SHARED_EXPORT uGetMenuString(HMENU menu, UINT id, pfc::string_base &out, UINT flag)
bool on_keydown_auto_context(const pfc::list_base_const_t< metadb_handle_ptr > &data, WPARAM wp, const GUID &caller)
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
HWND SHARED_EXPORT FindOwningPopup(HWND p_wnd)
bool on_keydown_auto_playlist(WPARAM wp)
static bool is_typing_key(t_uint32 vkCode)
string8_t< pfc::alloc_fast_aggressive > string8_fastalloc
static bool is_typing_message(HWND editbox, const MSG *msg)
bool on_keydown_auto(WPARAM wp)