summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-25 23:34:47 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-25 23:34:47 +0000
commitbe489c4e6f4c1ab4b4d7f84e35a73e34e1b0b331 (patch)
tree233968040ec6bff10b0726de4e7a69313bb78266 /src/mir_app
parentc055d21f01423462fa8d468f7c33bde55e595773 (diff)
- Menu_EnableItem & Menu_SetChecked - more suitable helpers to set flags;
- fix for checks in frame menus; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@14389 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/clistmenus.cpp14
-rw-r--r--src/mir_app/src/genmenu.cpp34
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
4 files changed, 38 insertions, 14 deletions
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp
index 9baf333882..d6ada2b63d 100644
--- a/src/mir_app/src/clistmenus.cpp
+++ b/src/mir_app/src/clistmenus.cpp
@@ -605,20 +605,6 @@ INT_PTR FreeOwnerDataStatusMenu(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
// Other menu functions
-MIR_APP_DLL(void) Menu_ShowItem(HGENMENU hMenuItem, bool bShow)
-{
- TMO_IntMenuItem *pimi = MO_GetIntMenuItem(hMenuItem);
- if (pimi == NULL)
- return;
-
- int flags = pimi->mi.flags;
- if (bShow)
- flags &= ~CMIF_HIDDEN;
- else
- flags |= CMIF_HIDDEN;
- Menu_ModifyItem(hMenuItem, NULL, INVALID_HANDLE_VALUE, flags);
-}
-
INT_PTR MenuProcessCommand(WPARAM wParam, LPARAM lParam)
{
WORD cmd = LOWORD(wParam);
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp
index ef63bd933f..05babf2759 100644
--- a/src/mir_app/src/genmenu.cpp
+++ b/src/mir_app/src/genmenu.cpp
@@ -278,6 +278,40 @@ MIR_APP_DLL(HGENMENU) Menu_GetDefaultItem(HGENMENU hMenu)
/////////////////////////////////////////////////////////////////////////////////////////
+static void Menu_SetItemFlags(HGENMENU hMenuItem, bool bSet, int mask)
+{
+ TMO_IntMenuItem *pimi = MO_GetIntMenuItem(hMenuItem);
+ if (pimi == NULL)
+ return;
+
+ int flags = pimi->mi.flags;
+ if (bSet)
+ flags |= mask;
+ else
+ flags &= ~mask;
+
+ mir_cslock lck(csMenuHook);
+ int oldflags = (pimi->mi.flags & CMIF_ROOTHANDLE);
+ pimi->mi.flags = flags | oldflags;
+}
+
+MIR_APP_DLL(void) Menu_EnableItem(HGENMENU hMenuItem, bool bEnable)
+{
+ Menu_SetItemFlags(hMenuItem, !bEnable, CMIF_GRAYED);
+}
+
+MIR_APP_DLL(void) Menu_ShowItem(HGENMENU hMenuItem, bool bShow)
+{
+ Menu_SetItemFlags(hMenuItem, !bShow, CMIF_HIDDEN);
+}
+
+MIR_APP_DLL(void) Menu_SetChecked(HGENMENU hMenuItem, bool bSet)
+{
+ Menu_SetItemFlags(hMenuItem, bSet, CMIF_CHECKED);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Menu_ModifyItem(HGENMENU hMenuItem, const TCHAR *ptszName, HANDLE hIcon, int iFlags)
{
if (!bIsGenMenuInited)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index ee225cae3c..4b2e9ec4fe 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -218,3 +218,5 @@ Menu_GetItemInfo @215
Menu_ProcessHotKey @216
Menu_DrawItem @217
Menu_MeasureItem @218
+Menu_EnableItem @219
+Menu_SetChecked @220
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index e0a756b14f..bb17f0e413 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -218,3 +218,5 @@ Menu_GetItemInfo @215
Menu_ProcessHotKey @216
Menu_DrawItem @217
Menu_MeasureItem @218
+Menu_EnableItem @219
+Menu_SetChecked @220