From b1d1c1adee5a98a6f048b44fb61105d17f8de7e8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 17 Nov 2012 19:53:11 +0000 Subject: fix for core visibility icons git-svn-id: http://svn.miranda-ng.org/main/trunk@2341 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/extraicons/DefaultExtraIcons.cpp | 32 +++++------ src/modules/icolib/skin2icons.cpp | 16 +++--- src/modules/options/filter.cpp | 71 ++++++++++++------------ src/modules/options/options.cpp | 66 ++++++++++++---------- src/modules/skin/skinicons.cpp | 82 ++++++++++++---------------- 5 files changed, 128 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/modules/extraicons/DefaultExtraIcons.cpp b/src/modules/extraicons/DefaultExtraIcons.cpp index 70b7acc089..6847a3206f 100644 --- a/src/modules/extraicons/DefaultExtraIcons.cpp +++ b/src/modules/extraicons/DefaultExtraIcons.cpp @@ -71,8 +71,7 @@ static void SetVisibility(HANDLE hContact, int apparentMode, BOOL clear) const char *ico = NULL; - if (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0)) - { + if (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0)) { // Is chat if (apparentMode == ID_STATUS_OFFLINE) ico = "ChatActivity"; @@ -82,14 +81,13 @@ static void SetVisibility(HANDLE hContact, int apparentMode, BOOL clear) ExtraIcon_SetIcon(hExtraChat, hContact, ico); } - else - { + else { // Not chat if (apparentMode == ID_STATUS_OFFLINE) - ico = "NeverVis"; + ico = "core_main_47"; else if (apparentMode == ID_STATUS_ONLINE) - ico = "AlwaysVis"; + ico = "core_main_46"; if (ico == NULL && !clear) return; @@ -177,21 +175,17 @@ static void SetExtraIcons(HANDLE hContact) if (IsEmpty(proto)) return; - for (unsigned int i = 0; i < SIZEOF(infos); i++) - { + for (unsigned int i = 0; i < SIZEOF(infos); i++) { Info &info = infos[i]; bool show = false; - for (unsigned int j = 0; !show && j < SIZEOF(info.db); j += 2) - { + for (unsigned int j = 0; !show && j < SIZEOF(info.db); j += 2) { if (info.db[j + 1] == NULL) break; DBVARIANT dbv = { 0 }; - if (!DBGetContactSettingString(hContact, info.db[j] == NULL ? proto : info.db[j], info.db[j+1], &dbv)) - { - if (!IsEmpty(dbv.pszVal)) - { + if (!DBGetContactSettingString(hContact, info.db[j] == NULL ? proto : info.db[j], info.db[j+1], &dbv)) { + if (!IsEmpty(dbv.pszVal)) { info.SetIcon(hContact, &info, dbv.pszVal); show = true; } @@ -210,11 +204,10 @@ static int SettingChanged(WPARAM wParam, LPARAM lParam) return 0; char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); - if (IsEmpty(proto)) + if ( IsEmpty(proto)) return 0; bool isProto = (strcmp(cws->szModule, proto) == 0); - if (isProto && strcmp(cws->szSetting, "ApparentMode") == 0) { SetVisibility(hContact, cws->value.type == DBVT_DELETED ? 0 : cws->value.wVal, TRUE); return 0; @@ -250,7 +243,7 @@ static int SettingChanged(WPARAM wParam, LPARAM lParam) static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param) { - Info *info = (Info *) param; + Info *info = (Info*)param; if (info == NULL) return 0; @@ -258,7 +251,7 @@ static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param) if (hContact == NULL) return 0; - char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); if (IsEmpty(proto)) return 0; @@ -284,8 +277,9 @@ static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param) static void DBExtraIconsInit() { hExtraChat = ExtraIcon_Register("chat_activity", "Chat activity", "ChatActivity"); - hExtraVisibility = ExtraIcon_Register("visibility", "Visibility", "AlwaysVis"); + hExtraVisibility = ExtraIcon_Register("visibility", "Visibility"); hExtraGender = ExtraIcon_Register("gender", "Gender", "gender_male"); + for (unsigned int i = 0; i < SIZEOF(infos); i++) { Info &info = infos[i]; if (info.OnClick) diff --git a/src/modules/icolib/skin2icons.cpp b/src/modules/icolib/skin2icons.cpp index 620a82f0b3..0fd774a087 100644 --- a/src/modules/icolib/skin2icons.cpp +++ b/src/modules/icolib/skin2icons.cpp @@ -308,8 +308,7 @@ HICON IconSourceItem_GetIcon(IconSourceItem* item) int IconSourceItem_ReleaseIcon(IconSourceItem* item) { - if (item && item->icon_ref_count) - { + if (item && item->icon_ref_count) { item->icon_ref_count--; if ( !item->icon_ref_count) { if ( !item->icon_size) @@ -349,15 +348,14 @@ IconSourceItem* GetIconSourceItem(const TCHAR* file, int indx, int cxIcon, int c IconSourceItem* GetIconSourceItemFromPath(const TCHAR* path, int cxIcon, int cyIcon) { - TCHAR *comma; - TCHAR file[ MAX_PATH ]; - int n; - if ( !path) return NULL; + TCHAR file[ MAX_PATH ]; lstrcpyn(file, path, SIZEOF(file)); - comma = _tcsrchr(file, ','); + TCHAR *comma = _tcsrchr(file, ','); + + int n; if ( !comma) n = 0; else { @@ -375,7 +373,8 @@ IconSourceItem* CreateStaticIconSourceItem(int cxIcon, int cyIcon) int i=0; do { // find new unique name mir_sntprintf(sourceName, SIZEOF(sourceName), _T("*StaticIcon_%d"), i++); - } while (iconSourceFileList.getIndex(&key) != -1); + } + while (iconSourceFileList.getIndex(&key) != -1); IconSourceItem* newItem = (IconSourceItem*)mir_calloc(sizeof(IconSourceItem)); newItem->file = IconSourceFile_Get(sourceName, false); @@ -440,7 +439,6 @@ static void IcoLib_RemoveSection(SectionItem* section) return; int indx; - if ((indx = sectionList.getIndex(section)) != -1) { sectionList.remove(indx); SAFE_FREE((void**)§ion->name); diff --git a/src/modules/options/filter.cpp b/src/modules/options/filter.cpp index f931012ad5..13799b602f 100644 --- a/src/modules/options/filter.cpp +++ b/src/modules/options/filter.cpp @@ -89,43 +89,47 @@ void AddDialogString(HWND hWndDlg, const PageHash key) if (lstrcmpi(szClass, _T("SysTreeView32")) == 0) { HTREEITEM hItem = TreeView_GetRoot(hWndDlg); AddTreeViewNodes(hWndDlg, key, hItem); + return; } - else { - if (lstrcmpi(szClass, _T("listbox")) == 0) { - if (GetWindowStyle(hWndDlg) & LBS_HASSTRINGS) { - int count = ListBox_GetCount(hWndDlg); - for (int i=0; i < count; i++) { - title[0] = 0; //safety - int res = ListBox_GetText(hWndDlg, i, title); - if (res != LB_ERR) { - title[SIZEOF(title) - 1] = 0; - if (_tcslen(title) > 0) - AddFilterString(key, title); - } } } - } - else { - if (lstrcmpi(szClass, _T("SysListView32")) == 0) { - int count = ListView_GetItemCount(hWndDlg); - for (int i=0; i < count; i++) { - title[0] = 0; //safety - ListView_GetItemText(hWndDlg, i, 0, title, SIZEOF(title)); - + + if (lstrcmpi(szClass, _T("listbox")) == 0) { + if (GetWindowStyle(hWndDlg) & LBS_HASSTRINGS) { + int count = ListBox_GetCount(hWndDlg); + for (int i=0; i < count; i++) { + title[0] = 0; //safety + int res = ListBox_GetText(hWndDlg, i, title); + if (res != LB_ERR) { + title[SIZEOF(title) - 1] = 0; if (_tcslen(title) > 0) AddFilterString(key, title); - } } - - if (lstrcmpi(szClass, _T("combobox")) == 0) { - if (GetWindowStyle(hWndDlg) & CBS_HASSTRINGS) { - int count = ComboBox_GetCount(hWndDlg); - for (int i=0; i < count; i++) { - title[0] = 0; //safety - int res = ComboBox_GetLBText(hWndDlg, i, title); - if (res != CB_ERR) { - title[SIZEOF(title) - 1] = 0; + } } } + return; + } + + if (lstrcmpi(szClass, _T("SysListView32")) == 0) { + int count = ListView_GetItemCount(hWndDlg); + for (int i=0; i < count; i++) { + title[0] = 0; //safety + ListView_GetItemText(hWndDlg, i, 0, title, SIZEOF(title)); + + if (_tcslen(title) > 0) + AddFilterString(key, title); + } + return; + } + + if (lstrcmpi(szClass, _T("combobox")) == 0) { + if (GetWindowStyle(hWndDlg) & CBS_HASSTRINGS) { + int count = ComboBox_GetCount(hWndDlg); + for (int i=0; i < count; i++) { + title[0] = 0; //safety + int res = ComboBox_GetLBText(hWndDlg, i, title); + if (res != CB_ERR) { + title[SIZEOF(title) - 1] = 0; - if (_tcslen(title) > 0) - AddFilterString(key, title); -} } } } } } } + if (_tcslen(title) > 0) + AddFilterString(key, title); +} } } } } static BOOL CALLBACK GetDialogStringsCallback(HWND hWnd, LPARAM lParam) { @@ -178,7 +182,6 @@ static INT_PTR CALLBACK DlgProcOptSearch(HWND hWnd, UINT msg, WPARAM wParam, LPA DBWriteContactSettingWord(NULL, "Options", "EnableKeywordFiltering", IsDlgButtonChecked(hWnd, IDC_ENABLE_KEYWORDFILTERING)); break; } - break; } break; } diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index 56f15f7c86..64879ee5c8 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -427,33 +427,32 @@ static void AeroPaintControl(HWND hwnd, HDC hdc, WNDPROC OldWndProc, UINT msg = static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { WNDPROC OldWndProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA); - switch (msg) - { - case WM_CTLCOLOREDIT: - if ( !GetPropA((HWND)lParam, "Miranda.AeroRender.Active")) - RedrawWindow((HWND)lParam, NULL, NULL, RDW_INVALIDATE); - break; + switch (msg) { + case WM_CTLCOLOREDIT: + if ( !GetPropA((HWND)lParam, "Miranda.AeroRender.Active")) + RedrawWindow((HWND)lParam, NULL, NULL, RDW_INVALIDATE); + break; - case WM_ERASEBKGND: - return TRUE; + case WM_ERASEBKGND: + return TRUE; - case WM_PRINT: - case WM_PRINTCLIENT: - AeroPaintControl(hwnd, (HDC)wParam, OldWndProc, msg, lParam); - return TRUE; + case WM_PRINT: + case WM_PRINTCLIENT: + AeroPaintControl(hwnd, (HDC)wParam, OldWndProc, msg, lParam); + return TRUE; - case WM_PAINT: + case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); AeroPaintControl(hwnd, hdc, OldWndProc); EndPaint(hwnd, &ps); - return TRUE; } + return TRUE; - case WM_DESTROY: - RemovePropA(hwnd, "Miranda.AeroRender.Active"); - break; + case WM_DESTROY: + RemovePropA(hwnd, "Miranda.AeroRender.Active"); + break; } return CallWindowProc(OldWndProc, hwnd, msg, wParam, lParam); } @@ -493,31 +492,36 @@ static void ExecuteFindFilterStringsTimer(HWND hdlg) static void FillFilterCombo(int enableKeywordFiltering, HWND hDlg, OptionsDlgData* dat) { - HINSTANCE* KnownInstances = (HINSTANCE*)alloca(sizeof(HINSTANCE)*dat->arOpd.getCount()); + HINSTANCE *KnownInstances = (HINSTANCE*)alloca(sizeof(HINSTANCE)*dat->arOpd.getCount()); int countKnownInst = 0; SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_RESETCONTENT, 0, 0); int index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_ADDSTRING, 0, (LPARAM)TranslateTS(ALL_MODULES_FILTER)); SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, 0); index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_ADDSTRING, 0, (LPARAM)TranslateTS(CORE_MODULES_FILTER)); SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, (LPARAM)hInst); - TCHAR* tszModuleName = (TCHAR*)alloca(MAX_PATH*sizeof(TCHAR)); + TCHAR *tszModuleName = (TCHAR*)alloca(MAX_PATH*sizeof(TCHAR)); for (int i=0; i < dat->arOpd.getCount(); i++) { - TCHAR *dllName = NULL; - int j; - HINSTANCE inst = dat->arOpd[i]->hInst; - if ( !enableKeywordFiltering) FindFilterStrings(enableKeywordFiltering, FALSE, hDlg, dat->arOpd[i]); // only modules name (fast enougth) - if (inst == hInst) continue; + HINSTANCE inst = dat->arOpd[i]->hInst; + if (inst == hInst) + continue; + + int j; for (j = 0; jarOpd[i]; + OptionsPageData *opd = dat->arOpd[i]; int pages = 0; if (opd->ptszTab != NULL) { // Count tabs to calc position @@ -557,10 +561,12 @@ static BOOL IsInsideTab(HWND hdlg, OptionsDlgData * dat, int i) static bool LoadOptionsPage(OPTIONSDIALOGPAGE *src, OptionsPageData *dst) { HRSRC hrsrc = FindResourceA(src->hInstance, src->pszTemplate, MAKEINTRESOURCEA(5)); - if (hrsrc == NULL) return false; + if (hrsrc == NULL) + return false; HGLOBAL hglb = LoadResource(src->hInstance, hrsrc); - if (hglb == NULL) return false; + if (hglb == NULL) + return false; DWORD resSize = SizeofResource(src->hInstance, hrsrc); dst->pTemplate = (DLGTEMPLATE*)mir_alloc(resSize); diff --git a/src/modules/skin/skinicons.cpp b/src/modules/skin/skinicons.cpp index 44e911c468..37b01b0e40 100644 --- a/src/modules/skin/skinicons.cpp +++ b/src/modules/skin/skinicons.cpp @@ -26,10 +26,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. struct StandardIconDescription { int id; - const char* description; + LPCSTR description; int resource_id; int pf2; - const char* section; + LPCSTR section; }; static const struct StandardIconDescription mainIcons[] = @@ -103,16 +103,13 @@ static const struct StandardIconDescription statusIcons[] = HANDLE hStatusIcons[SIZEOF(statusIcons)]; -const char* mainIconsFmt = "core_main_"; -const char* statusIconsFmt = "core_status_"; -const char* protoIconsFmt = LPGEN("%s Icons"); +const char *mainIconsFmt = "core_main_"; +const char *statusIconsFmt = "core_status_"; +const char *protoIconsFmt = LPGEN("%s Icons"); #define PROTOCOLS_PREFIX "Status Icons/" #define GLOBAL_PROTO_NAME "*" - - - // load small icon (shared) it's not need to be destroyed static HICON LoadSmallIconShared(HINSTANCE hInstance, LPCTSTR lpIconName) @@ -221,9 +218,8 @@ void Button_FreeIcon_IcoLib(HWND hwndDlg, int itemId) // HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) { - int i, statusIndx = -1; + int statusIndx = -1; char iconName[MAX_PATH]; - HICON hIcon; DWORD caps2 = (szProto == NULL) ? (DWORD)-1 : CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_2, 0); if (status >= ID_STATUS_CONNECTING && status < ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES) { @@ -231,7 +227,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) return IcoLib_GetIcon(iconName, big); } - for (i=0; i < SIZEOF(statusIcons); i++) { + for (int i=0; i < SIZEOF(statusIcons); i++) { if (statusIcons[i].id == status) { statusIndx = i; break; @@ -244,12 +240,10 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) // Only return a protocol specific icon if there is only one protocol // Otherwise return the global icon. This affects the global status menu mainly. if (accounts.getCount() == 1) { - HICON hIcon; - // format: core_status_%proto%statusindex mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); - hIcon = IcoLib_GetIcon(iconName, big); + HICON hIcon = IcoLib_GetIcon(iconName, big); if (hIcon) return hIcon; } @@ -261,7 +255,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) // format: core_status_%s%d mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); - hIcon = IcoLib_GetIcon(iconName, big); + HICON hIcon = IcoLib_GetIcon(iconName, big); if (hIcon == NULL && (caps2 == 0 || (caps2 & statusIcons[statusIndx].pf2))) { PROTOACCOUNT* pa = Proto_GetAccount(szProto); if (pa) { @@ -287,7 +281,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) sid.ptszDefaultFile = szFullPath; else { mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Plugins\\") _T(TCHAR_STR_PARAM) _T(".dll"), szPath, szProto); - if ((int)ExtractIconEx(szFullPath, statusIcons[i].resource_id, NULL, &hIcon, 1) > 0) { + if ((int)ExtractIconEx(szFullPath, statusIcons[statusIndx].resource_id, NULL, &hIcon, 1) > 0) { DestroyIcon(hIcon); sid.ptszDefaultFile = szFullPath; hIcon = NULL; @@ -302,22 +296,23 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) // // Add global icons to list // - { - int lowidx, highidx; - if (caps2 == 0) - lowidx = statusIndx, highidx = statusIndx+1; - else - lowidx = 0, highidx = SIZEOF(statusIcons); - - for (i = lowidx; i < highidx; i++) { - if (caps2 == 0 || (caps2 & statusIcons[i].pf2)) { - // format: core_%s%d - mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, i); - sid.pszName = iconName; - sid.ptszDescription = cli.pfnGetStatusModeDescription(statusIcons[i].id, 0); - sid.iDefaultIndex = statusIcons[i].resource_id; - IcoLib_AddNewIcon(0, &sid); - } } } } + + int lowidx, highidx; + if (caps2 == 0) + lowidx = statusIndx, highidx = statusIndx+1; + else + lowidx = 0, highidx = SIZEOF(statusIcons); + + for (int i = lowidx; i < highidx; i++) + if (caps2 == 0 || (caps2 & statusIcons[i].pf2)) { + // format: core_%s%d + mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, i); + sid.pszName = iconName; + sid.ptszDescription = cli.pfnGetStatusModeDescription(statusIcons[i].id, 0); + sid.iDefaultIndex = statusIcons[i].resource_id; + IcoLib_AddNewIcon(0, &sid); + } + } // format: core_status_%s%d mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); @@ -336,8 +331,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) HANDLE GetSkinIconHandle(int idx) { - int i; - for (i=0; i < SIZEOF(mainIcons); i++) + for (int i=0; i < SIZEOF(mainIcons); i++) if (idx == mainIcons[i].id) return hMainIcons[i]; @@ -362,10 +356,10 @@ HICON LoadSkinIcon(int idx, bool big) ///////////////////////////////////////////////////////////////////////////////////////// // Initializes the icon skin module -static void convertOneProtocol(char* moduleName, char* iconName) +static void convertOneProtocol(char *moduleName, char *iconName) { - char* pm = moduleName + strlen(moduleName); - char* pi = iconName + strlen(iconName); + char *pm = moduleName + strlen(moduleName); + char *pi = iconName + strlen(iconName); for (int i=0; i < SIZEOF(statusIcons); i++) { _itoa(statusIcons[i].id, pm, 10); @@ -382,16 +376,10 @@ static void convertOneProtocol(char* moduleName, char* iconName) static INT_PTR sttLoadSkinIcon(WPARAM wParam, LPARAM lParam) { - switch (lParam) - { - case 0: - return (INT_PTR)LoadSkinIcon(wParam); - - case 1: - return (INT_PTR)GetSkinIconHandle(wParam); - - case 2: - return (INT_PTR)LoadSkinIcon(wParam, true); + switch (lParam) { + case 0: return (INT_PTR)LoadSkinIcon(wParam); + case 1: return (INT_PTR)GetSkinIconHandle(wParam); + case 2: return (INT_PTR)LoadSkinIcon(wParam, true); } return 0; -- cgit v1.2.3