From f12d8b56f2894e94491bd7424d69f595d285f01f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 3 Nov 2012 20:16:42 +0000 Subject: no more MS_CLIST_EXTRA_ADD_ICON in the application code git-svn-id: http://svn.miranda-ng.org/main/trunk@2175 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AuthState/res/authstate.rc | 5 -- plugins/AuthState/src/commonheaders.h | 7 +- plugins/AuthState/src/main.cpp | 86 ++++----------------- plugins/AuthState/src/options.cpp | 140 ++++++++++------------------------ plugins/AuthState/src/resource.h | 2 - 5 files changed, 60 insertions(+), 180 deletions(-) (limited to 'plugins/AuthState') diff --git a/plugins/AuthState/res/authstate.rc b/plugins/AuthState/res/authstate.rc index 071abc75d3..50f067b1c0 100644 --- a/plugins/AuthState/res/authstate.rc +++ b/plugins/AuthState/res/authstate.rc @@ -79,8 +79,6 @@ IDD_AUTHSTATE_OPT DIALOGEX 0, 0, 314, 240 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_ADVICON,95,127,78,81,CBS_DROPDOWNLIST | WS_VSCROLL | - WS_TABSTOP,WS_EX_CLIENTEDGE CONTROL "Show Auth icon",IDC_AUTHICON,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,76,93,167,18 CONTROL "Show Grant icon",IDC_GRANTICON,"Button",BS_AUTOCHECKBOX | @@ -93,9 +91,6 @@ BEGIN CONTROL "Show icons only for recently added contacts", IDC_ICONSFORRECENT,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,76,78,167,17 - RTEXT "* Restart of Miranda required",IDC_STATIC,58,171,210,11 - LTEXT "Note: if you still don't see the icons try changing icon slot. Perhaps its used by some other plugin.", - IDC_NOTICE,54,143,198,20 END diff --git a/plugins/AuthState/src/commonheaders.h b/plugins/AuthState/src/commonheaders.h index 3e8e85c51c..7d199a835b 100644 --- a/plugins/AuthState/src/commonheaders.h +++ b/plugins/AuthState/src/commonheaders.h @@ -53,13 +53,10 @@ static const int DefaultSlot = EXTRA_ICON_ADV2; #define MODULENAME "AuthState" -extern int onOptInitialise(WPARAM wParam, LPARAM lParam); -extern int onExtraImageApplying(WPARAM wParam, LPARAM lParam); -extern int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam); +int onOptInitialise(WPARAM wParam, LPARAM lParam); +int onExtraImageApplying(WPARAM wParam, LPARAM lParam); extern HINSTANCE g_hInst; -extern IconExtraColumn g_IECAuth, g_IECGrant, g_IECAuthGrant, g_IECClear; -extern INT clistIcon; extern byte bUseAuthIcon, bUseGrantIcon, bContactMenuItem, bIconsForRecentContacts; extern HANDLE hExtraIcon; diff --git a/plugins/AuthState/src/main.cpp b/plugins/AuthState/src/main.cpp index 842d2c912b..0917db41fb 100644 --- a/plugins/AuthState/src/main.cpp +++ b/plugins/AuthState/src/main.cpp @@ -33,11 +33,6 @@ static HANDLE hUserMenu = NULL; HANDLE hExtraIcon = NULL; int hLangpack; -IconExtraColumn g_IECAuth = {0}; -IconExtraColumn g_IECGrant = {0}; -IconExtraColumn g_IECAuthGrant = {0}; -IconExtraColumn g_IECClear = {0}; -INT clistIcon = 0; //Icon slot to use BYTE bUseAuthIcon = 0, bUseGrantIcon = 0, bContactMenuItem = 0, bIconsForRecentContacts = 0, bUseAuthGroup = 0; enum { @@ -101,50 +96,16 @@ int onExtraImageApplying(WPARAM wParam, LPARAM lParam) if (wParam == NULL) return 0; - int usedIcon; - usedIcon = getIconToUse((HANDLE) wParam, lParam); + int usedIcon = getIconToUse((HANDLE) wParam, lParam); - if (hExtraIcon != NULL) - { - const char *icon; - switch (usedIcon) - { - case icon_both: icon = "authgrant_icon"; break; - case icon_grant: icon = "grant_icon"; break; - case icon_auth: icon = "auth_icon"; break; - default: icon = NULL; break; - } - ExtraIcon_SetIcon(hExtraIcon, (HANDLE)wParam, icon); - } - else - { - switch (usedIcon) - { - case icon_both: CallService(MS_CLIST_EXTRA_SET_ICON, wParam, (LPARAM) &g_IECAuthGrant); break; - case icon_grant: CallService(MS_CLIST_EXTRA_SET_ICON, wParam, (LPARAM) &g_IECGrant); break; - case icon_auth: CallService(MS_CLIST_EXTRA_SET_ICON, wParam, (LPARAM) &g_IECAuth); break; - default: CallService(MS_CLIST_EXTRA_SET_ICON, wParam, (LPARAM) &g_IECClear); break; - } - } - - return 0; -} - -int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam) -{ - g_IECAuth.cbSize = sizeof(IconExtraColumn); - g_IECAuth.ColumnType = clistIcon; - g_IECGrant.cbSize = sizeof(IconExtraColumn); - g_IECGrant.ColumnType = clistIcon; - g_IECAuthGrant.cbSize = sizeof(IconExtraColumn); - g_IECAuthGrant.ColumnType = clistIcon; - - if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) { - g_IECAuth.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIcon("auth_icon"), 0); - g_IECGrant.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIcon("grant_icon"), 0); - g_IECAuthGrant.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIcon("authgrant_icon"), 0); + const char *icon; + switch (usedIcon) { + case icon_both: icon = "authgrant_icon"; break; + case icon_grant: icon = "grant_icon"; break; + case icon_auth: icon = "auth_icon"; break; + default: icon = NULL; break; } - + ExtraIcon_SetIcon(hExtraIcon, (HANDLE)wParam, icon); return 0; } @@ -175,11 +136,7 @@ INT_PTR onAuthMenuSelected(WPARAM wParam, LPARAM lParam) byte enabled = DBGetContactSettingByte((HANDLE)wParam,"AuthState","ShowIcons",1); DBWriteContactSettingByte((HANDLE)wParam, MODULENAME, "ShowIcons", !enabled); - if (enabled) - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECClear); - else - onExtraImageApplying(wParam, 0); - + onExtraImageApplying(wParam, 0); return 0; } @@ -242,20 +199,14 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) // extra icons hExtraIcon = ExtraIcon_Register("authstate", "Auth State", "authgrant_icon"); - if (hExtraIcon != NULL) { - // Set initial value for all contacts - HANDLE hContact = db_find_first(); - while (hContact != NULL) { - onExtraImageApplying((WPARAM)hContact, 1); - hContact = db_find_next(hContact); - } - } - else { - hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild); - hHookExtraIconsRebuild = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuild); - hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying); - onExtraImageListRebuild(0,0); + + // Set initial value for all contacts + HANDLE hContact = db_find_first(); + while (hContact != NULL) { + onExtraImageApplying((WPARAM)hContact, 1); + hContact = db_find_next(hContact); } + hOptInitialise = HookEvent(ME_OPT_INITIALISE, onOptInitialise); if (bContactMenuItem) hPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu); @@ -290,7 +241,6 @@ extern "C" int __declspec(dllexport) Load(void) hSystemOKToExit = HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit); hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged); - clistIcon = DBGetContactSettingByte(NULL, MODULENAME, "AdvancedIcon", DefaultSlot); bUseAuthIcon = DBGetContactSettingByte(NULL, MODULENAME, "EnableAuthIcon", 1); bUseGrantIcon = DBGetContactSettingByte(NULL, MODULENAME, "EnableGrantIcon", 1); bContactMenuItem = DBGetContactSettingByte(NULL, MODULENAME, "MenuItem", 0); @@ -311,10 +261,6 @@ extern "C" int __declspec(dllexport) Load(void) hUserMenu = Menu_AddContactMenuItem(&mi); } - g_IECClear.cbSize = sizeof(IconExtraColumn); - g_IECClear.ColumnType = clistIcon; - g_IECClear.hImage = (HANDLE) -1; - return 0; } diff --git a/plugins/AuthState/src/options.cpp b/plugins/AuthState/src/options.cpp index cef1db78b8..bc4a3dcf1e 100644 --- a/plugins/AuthState/src/options.cpp +++ b/plugins/AuthState/src/options.cpp @@ -25,112 +25,56 @@ #include "commonheaders.h" -const TCHAR* szAdvancedIcons[] = {_T("Email"), _T("Protocol"), _T("SMS"), _T("Advanced 1"), _T("Advanced 2"), _T("Web"), _T("Client"), _T("Advanced 3"), _T("Advanced 4"), _T("Advanced 5")}; -const INT cAdvancedIcons = sizeof(szAdvancedIcons) / sizeof(szAdvancedIcons[0]); - INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static int bInitializing = 0; - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - bInitializing = 1; - if (hExtraIcon==NULL) - { - for (int i = 0; i < cAdvancedIcons; i++) - { - SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szAdvancedIcons[i])); - } - SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_SETCURSEL, clistIcon-1, 0); - } - else - { - SendDlgItemMessage(hwndDlg,IDC_NOTICE, WM_SETTEXT,0,(LPARAM)TranslateT("Extraicons plugin is used, use Contact list > Extraicons for customize.")); - ShowWindow(GetDlgItem(hwndDlg, IDC_NOTICE), SW_SHOW); - EnableWindow(GetDlgItem(hwndDlg, IDC_ADVICON), 0); - } - - CheckDlgButton(hwndDlg, IDC_AUTHICON, bUseAuthIcon ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_GRANTICON, bUseGrantIcon ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ENABLEMENUITEM, bContactMenuItem ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ICONSFORRECENT, bIconsForRecentContacts ? BST_CHECKED : BST_UNCHECKED); - - bInitializing = 0; - return TRUE; - } - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_AUTHICON: - case IDC_GRANTICON: - case IDC_ENABLEMENUITEM: - case IDC_ICONSFORRECENT: - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - case IDC_ADVICON: - { - if ((HIWORD(wParam) == EN_CHANGE) && (!bInitializing) || (HIWORD(wParam) == CBN_SELENDOK)) - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - } - } - break; + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + bInitializing = 1; + + CheckDlgButton(hwndDlg, IDC_AUTHICON, bUseAuthIcon ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_GRANTICON, bUseGrantIcon ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ENABLEMENUITEM, bContactMenuItem ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ICONSFORRECENT, bIconsForRecentContacts ? BST_CHECKED : BST_UNCHECKED); + + bInitializing = 0; + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_AUTHICON: + case IDC_GRANTICON: + case IDC_ENABLEMENUITEM: + case IDC_ICONSFORRECENT: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; } - - case WM_NOTIFY: - { - if (((LPNMHDR)lParam)->idFrom == 0) - switch (((LPNMHDR)lParam)->code) + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->idFrom == 0) + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + bUseAuthIcon = IsDlgButtonChecked(hwndDlg, IDC_AUTHICON); + bUseGrantIcon = IsDlgButtonChecked(hwndDlg, IDC_GRANTICON); + bContactMenuItem = IsDlgButtonChecked(hwndDlg, IDC_ENABLEMENUITEM); + bIconsForRecentContacts = IsDlgButtonChecked(hwndDlg, IDC_ICONSFORRECENT); { - case PSN_APPLY: - { - bUseAuthIcon = IsDlgButtonChecked(hwndDlg, IDC_AUTHICON); - bUseGrantIcon = IsDlgButtonChecked(hwndDlg, IDC_GRANTICON); - bContactMenuItem = IsDlgButtonChecked(hwndDlg, IDC_ENABLEMENUITEM); - bIconsForRecentContacts = IsDlgButtonChecked(hwndDlg, IDC_ICONSFORRECENT); - - clistIcon = SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_GETCURSEL, 0, 0); - clistIcon++; - - HANDLE hContact = db_find_first(); - while (hContact) - { - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)&g_IECClear); - hContact = db_find_next(hContact); - } - - g_IECClear.ColumnType = clistIcon; - onExtraImageListRebuild(0,0); - - hContact = db_find_first(); - while (hContact) - { - onExtraImageApplying((WPARAM)hContact,0); - hContact = db_find_next(hContact); - } - - //Store options values to DB - DBWriteContactSettingByte(NULL, MODULENAME, "AdvancedIcon", clistIcon); - DBWriteContactSettingByte(NULL, MODULENAME, "EnableAuthIcon", bUseAuthIcon); - DBWriteContactSettingByte(NULL, MODULENAME, "EnableGrantIcon", bUseGrantIcon); - DBWriteContactSettingByte(NULL, MODULENAME, "MenuItem", bContactMenuItem); - DBWriteContactSettingByte(NULL, MODULENAME, "EnableOnlyForRecent", bIconsForRecentContacts); + HANDLE hContact = db_find_first(); + while (hContact) { + onExtraImageApplying((WPARAM)hContact,0); + hContact = db_find_next(hContact); } - return TRUE; } - } - - case WM_DESTROY: - break; + //Store options values to DB + DBWriteContactSettingByte(NULL, MODULENAME, "EnableAuthIcon", bUseAuthIcon); + DBWriteContactSettingByte(NULL, MODULENAME, "EnableGrantIcon", bUseGrantIcon); + DBWriteContactSettingByte(NULL, MODULENAME, "MenuItem", bContactMenuItem); + DBWriteContactSettingByte(NULL, MODULENAME, "EnableOnlyForRecent", bIconsForRecentContacts); + return TRUE; + } } return FALSE; } diff --git a/plugins/AuthState/src/resource.h b/plugins/AuthState/src/resource.h index 49c8f2fb6a..9e3a220c78 100644 --- a/plugins/AuthState/src/resource.h +++ b/plugins/AuthState/src/resource.h @@ -6,12 +6,10 @@ #define IDI_GRANT 102 #define IDI_AUTHGRANT 103 #define IDD_AUTHSTATE_OPT 103 -#define IDC_ADVICON 1001 #define IDC_AUTHICON 1002 #define IDC_GRANTICON 1003 #define IDC_ENABLEMENUITEM 1005 #define IDC_ICONSFORRECENT 1006 -#define IDC_NOTICE 1009 // Next default values for new objects // -- cgit v1.2.3