1: /*
2: ============================================================================
3: xoblite™ -> an advanced "extended shell" for Microsoft® Windows® 11
4: Copyright © 2002-2026 Karl Henrik Henriksson [qwilk/@xoblite]
5: Copyright © 2001-2004 The Blackbox for Windows Development Team
6: http://xoblite.net/ + https://github.com/xoblite/
7: ============================================================================
8:
9: Blackbox for Windows is free software, released under the
10: GNU General Public License (GPL version 2 or later), with an extension
11: that allows linking of proprietary modules under a controlled interface.
12: What this means is that plugins etc. are allowed to be released
13: under any license the author wishes. Please note, however, that the
14: original Blackbox gradient math code used in Blackbox for Windows
15: is available under the BSD license.
16:
17: http://www.fsf.org/licenses/gpl.html
18: http://www.fsf.org/licenses/gpl-faq.html#LinkingOverControlledInterface
19: http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5
20:
21: This program is distributed in the hope that it will be useful,
22: but WITHOUT ANY WARRANTY; without even the implied warranty of
23: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24: GNU General Public License for more details.
25:
26: For additional license information, please read the included license.html.
27:
28: ============================================================================
29: */
30:
31: #include "..\API\BBApi.h"
32: #include "..\Menu\MenuCommon.h"
33: #include "HotkeysMenu.h"
34: #include "..\Menu\MenuItem.h"
35: #include "..\Menu\FolderItem.h"
36: #include "..\Settings\ConfigMenu.h"
37: #include "Hotkeys.h"
38: #include "..\Settings\Settings.h"
39:
40: extern MenuCommon *pMenuCommon;
41: extern Hotkeys* pHotkeys;
42: extern Settings *pSettings;
43:
44: //===========================================================================
45:
46: HotkeysMenu::HotkeysMenu(char* pszTitle) : FolderItem(NULL, pszTitle, NULL)
47: {
48: }
49:
50: HotkeysMenu::~HotkeysMenu()
51: {
52: m_pParent->RemoveChild(m_pSubMenu);
53: if (m_pSubMenu) delete m_pSubMenu;
54: m_pSubMenu = NULL;
55: }
56:
57: //===========================================================================
58:
59: bool HotkeysMenu::Active(bool bActivate)
60: {
61: if (bActivate && !m_bActive) UpdateFolder();
62: return FolderItem::Active(bActivate);
63: }
64:
65: void HotkeysMenu::Attached(Menu* pMenu)
66: {
67: m_pParent = pMenu;
68: m_pSubMenu = new Menu(pMenuCommon->hInst);
69: m_pParent->AddChild(m_pSubMenu);
70: m_pSubMenu->SetParent(m_pParent);
71: }
72:
73: //===========================================================================
74:
75: void HotkeysMenu::UpdateFolder()
76: {
77: m_pSubMenu->DeleteMenuItems();
78: pMenuCommon->AddHeaderItem(m_pSubMenu, m_pszTitleANSI);
79:
80: pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_COMMAND, "@xoblite Edit", pSettings->hotkeysFile, "Edit hotkeys.rc", false);
81: pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_SEPARATOR, NULL, NULL, NULL, false);
82:
83: //====================
84:
85: if (pHotkeys)
86: {
87: char hotkeyMenuItemString[MAX_LINE_LENGTH], number[10], hotkeyAsNumber[10];
88:
89: for (int i=0; i<(int)pHotkeys->hotkeyList.size(); i++)
90: {
91: hotkeyMenuItemString[0] = '\0';
92: if (pHotkeys->hotkeyList[i]->mods & MOD_CONTROL) strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), "C");
93: if (pHotkeys->hotkeyList[i]->mods & MOD_ALT) strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), "A");
94: if (pHotkeys->hotkeyList[i]->mods & MOD_SHIFT) strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), "S");
95: if (pHotkeys->hotkeyList[i]->mods & MOD_WIN) strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), "W");
96: strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), " ");
97: strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), pHotkeys->hotkeyList[i]->keyAsString);
98: strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), " -> ");
99: strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), pHotkeys->hotkeyList[i]->cmd);
100: strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), " ");
101: strcat_s(hotkeyMenuItemString, sizeofArray(hotkeyMenuItemString), pHotkeys->hotkeyList[i]->args);
102:
103: strcpy_s(hotkeyAsNumber, sizeofArray(hotkeyAsNumber), "#");
104: strcat_s(hotkeyAsNumber, sizeofArray(hotkeyAsNumber), _itoa(i+1, number, 10)); // Nb. Using more human friendly 1-N numbering for the Hotkey bro@ms!
105:
106: pMenuCommon->CreateMenuItem(m_pSubMenu, MENUITEM_COMMAND, "@xoblite Hotkey", hotkeyAsNumber, hotkeyMenuItemString, false);
107: }
108: }
109:
110: //====================
111:
112: pMenuCommon->AddFooterItem(m_pSubMenu, "");
113:
114: m_pSubMenu->Invalidate();
115: m_pSubMenu->Validate();
116: }
117:
118: //===========================================================================
119: