From 5ca299a56b6cc35845d0480e6a3f9862e1f36f10 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 24 Oct 2012 13:01:18 +0000 Subject: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@2065 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Popup/src/common.h | 113 ----------------------------------------- plugins/Popup/src/history.cpp | 47 ++++++----------- plugins/Popup/src/services.cpp | 4 +- 3 files changed, 17 insertions(+), 147 deletions(-) (limited to 'plugins/Popup') diff --git a/plugins/Popup/src/common.h b/plugins/Popup/src/common.h index 5319bc236d..d993232108 100644 --- a/plugins/Popup/src/common.h +++ b/plugins/Popup/src/common.h @@ -55,31 +55,6 @@ inline void DebugMsg(LPTSTR msg){ } } -/* not used -inline void GetDCBmpSize(HDC hdc, SIZE *sz) -{ - BITMAP bmp; - GetObject(GetCurrentObject(hdc, OBJ_BITMAP), sizeof(bmp), &bmp); - sz->cx = bmp.bmWidth; - sz->cy = bmp.bmHeight; -} - -inline HBITMAP myLoadBitmap(LPCTSTR fn) -{ - HBITMAP res = (HBITMAP)LoadImage(NULL, fn, IMAGE_BITMAP, LR_DEFAULTSIZE, LR_DEFAULTSIZE, LR_LOADFROMFILE); - - BITMAPFILEHEADER bfh; - BITMAPINFOHEADER bih; - FILE *f = _tfopen (fn, _T("rb")); - fread(&bfh, sizeof(bfh), 1, f); - fread(&bih, sizeof(bih), 1, f); - fclose(f); - SetBitmapDimensionEx(res, bih.biWidth, bih.biHeight, NULL); - - return res; -} -*/ - //===== Percentile to Byte and viceversa ===== inline int Byte2Percentile(int vByte) { return (vByte*100)/255; } inline int Percentile2Byte(int vPerc) { return (vPerc*255)/100; } @@ -142,66 +117,6 @@ inline INT_PTR DBGetContactSettingStringX(HANDLE hContact, const char *ModuleNam return ret; } -/* not used - -inline void SetWindowTextTraslated(HWND hwnd, const char *text) -{ - if (!(hwnd && text)) return; - if (g_popup.isOsUnicode && IsWindowUnicode(hwnd) && MySetWindowTextW) - { - UINT codepage = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); - int size = MultiByteToWideChar(codepage, 0, text, lstrlenA(text), 0, 0); - WCHAR *wtext = new WCHAR[size+1]; - MultiByteToWideChar(codepage, 0, text, lstrlenA(text), wtext, size+1); wtext[size]=0; - MySetWindowTextW(hwnd, TranslateW(wtext)); - delete [] wtext; - } else - { - SetWindowTextA(hwnd, Translate(text)); - } -} - -*/ -/*/dedrecatet (tricky thing to minimize memory fragmentation) -inline wchar_t* a2u( char* src ) -{ - int codepage = CallService( MS_LANGPACK_GETCODEPAGE, 0, 0 ); - - int cbLen = MultiByteToWideChar( codepage, 0, src, -1, NULL, 0 ); - wchar_t* result = ( wchar_t* )mir_alloc( sizeof( wchar_t )*(cbLen+1)); - if ( result == NULL ) - return NULL; - - MultiByteToWideChar( codepage, 0, src, -1, result, cbLen ); - result[ cbLen ] = 0; - return result; -} - -#define nb_a2u_init() \ - int nb_a2u_codepage = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); \ - int nb_a2u_len = 0; \ - -#define nb_a2u(dst, src) \ - bool dst##_free = false; \ - WCHAR *dst = NULL; \ - nb_a2u_len = MultiByteToWideChar(nb_a2u_codepage, 0, src, -1, NULL, 0); \ - __try \ - { \ - dst = (WCHAR *)_alloca(sizeof(WCHAR)*(nb_a2u_len+1)); \ - } \ - __except( EXCEPTION_EXECUTE_HANDLER ) \ - { \ - dst = (WCHAR *)mir_alloc(sizeof(WCHAR)*(nb_a2u_len+1)); \ - dst##_free = true; \ - } \ - MultiByteToWideChar(nb_a2u_codepage, 0, src, -1, dst, nb_a2u_len); \ - dst[nb_a2u_len] = 0; - -#define nb_a2u_free(dst) \ - if (dst##_free) \ - mir_free(dst); -*/ - inline void AddTooltipTranslated(HWND hwndToolTip, HWND hwnd, int id, RECT rc, char *text) { @@ -226,32 +141,4 @@ inline void AddTooltipTranslated(HWND hwndToolTip, HWND hwnd, int id, RECT rc, c } -/* not used -inline UINT getCodepageFromCharset(BYTE charset) -{ - switch (charset) - { - case ANSI_CHARSET: return 1252; - case BALTIC_CHARSET: return 1257; - case CHINESEBIG5_CHARSET: return 950; - case DEFAULT_CHARSET: return CP_ACP; - case EASTEUROPE_CHARSET: return 1250; - case GB2312_CHARSET: return 936; - case GREEK_CHARSET: return 1253; - case HANGUL_CHARSET: return 949; - case MAC_CHARSET: return CP_MACCP; - case OEM_CHARSET: return CP_OEMCP; - case RUSSIAN_CHARSET: return 1251; - case SHIFTJIS_CHARSET: return 932; -// case SYMBOL_CHARSET: return ; - case TURKISH_CHARSET: return 1254; - case VIETNAMESE_CHARSET: return 1258; - case JOHAB_CHARSET: return 1361; - case ARABIC_CHARSET: return 1256; - case HEBREW_CHARSET: return 1255; - default: return CP_ACP; - } -} -*/ - #endif //COMMON_H diff --git a/plugins/Popup/src/history.cpp b/plugins/Popup/src/history.cpp index 22529426b8..7da08ec60b 100644 --- a/plugins/Popup/src/history.cpp +++ b/plugins/Popup/src/history.cpp @@ -123,67 +123,50 @@ void PopupHistoryAdd(POPUPDATA2 *ppdNew) return; POPUPDATA2 *ppd; - if (popupHistorySize < popupHistoryBuffer) - { + if (popupHistorySize < popupHistoryBuffer) { ++popupHistorySize; ppd = &popupHistory[getHistoryIndex(popupHistorySize-1)]; - } else - { + } + else { popupHistoryStart = (popupHistoryStart+1)%popupHistoryBuffer; ppd = &popupHistory[getHistoryIndex(popupHistorySize-1)]; - if (ppd->flags & PU2_UNICODE) - { - mir_free(ppd->lpwzTitle); - mir_free(ppd->lpwzText); - } else - { - mir_free(ppd->lpzTitle); - mir_free(ppd->lpzText); - } - if (ppd->lpzSkin) mir_free(ppd->lpzSkin); + mir_free(ppd->lpzTitle); + mir_free(ppd->lpzText); + mir_free(ppd->lpzSkin); } *ppd = *ppdNew; - if (ppd->flags&PU2_UNICODE) - { + if (ppd->flags & PU2_UNICODE) { ppd->lpwzTitle = mir_wstrdup(ppd->lpwzTitle); ppd->lpwzText = mir_wstrdup(ppd->lpwzText); - } else - { + } + else { ppd->lpzTitle = mir_strdup(ppd->lpzTitle); ppd->lpzText = mir_strdup(ppd->lpzText); } - if (ppd->lpzSkin) - { - ppd->lpzSkin = mir_strdup(ppd->lpzSkin); - } else - { - ppd->lpzSkin = NULL; - } + ppd->lpzSkin = mir_strdup(ppd->lpzSkin); ppd->dwTimestamp = time(NULL); -// GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL,"HH':'mm", ppd->lpzTime, sizeof(ppd->lpzTime)); + if (hwndHistory) PostMessage(hwndHistory, UM_ADDITEM, 0, (LPARAM)ppd); } void PopupHistoryShow() { - if (!PopUpOptions.EnableHistory){ + if (!PopUpOptions.EnableHistory) { MessageBox(NULL, TranslateT("Popup History is disabled"), TranslateT("Popup History message"), MB_OK); return; } - if (hwndHistory) - { + if (hwndHistory) { ShowWindow(hwndHistory, SW_SHOW); SetForegroundWindow(hwndHistory); SetFocus(hwndHistory); SetActiveWindow(hwndHistory); - } else - { + } + else { hwndHistory = CreateDialog(hInst, MAKEINTRESOURCE(IDD_HISTORY), NULL, HistoryDlgProc); SetWindowText(hwndHistory, TranslateT("Popup History")); - //ShowWindow(hwndHistory, SW_SHOW); } } diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index 00d268d9ab..6d35cf3db7 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -241,12 +241,12 @@ INT_PTR PopUp_AddPopUp2(WPARAM wParam, LPARAM lParam) if (PopupThreadIsFull()) return -1; - #ifdef _DEBUG + #ifdef _DEBUG char temp[128]; OutputDebugStringA("isWorkstationLocked: \t"); OutputDebugStringA(isWorkstationLocked() ? "true":"false"); OutputDebugStringA("\n"); - #endif + #endif if (isWorkstationLocked()) return -1; -- cgit v1.2.3