From df60e52a47f80d89de55affae33d93f79e077885 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 31 Jan 2013 22:07:54 +0000 Subject: unicode smileys never worked in MyDetails git-svn-id: http://svn.miranda-ng.org/main/trunk@3382 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MyDetails/src/commons.h | 5 ++--- plugins/MyDetails/src/data.cpp | 5 ++--- plugins/MyDetails/src/frame.cpp | 48 +++++++++++++++++------------------------ plugins/Utils/mir_smileys.cpp | 23 ++++++-------------- 4 files changed, 30 insertions(+), 51 deletions(-) diff --git a/plugins/MyDetails/src/commons.h b/plugins/MyDetails/src/commons.h index 68cfc55bf3..a331359341 100644 --- a/plugins/MyDetails/src/commons.h +++ b/plugins/MyDetails/src/commons.h @@ -95,14 +95,13 @@ __inline static int ProtoServiceExists(const char *szModule,const char *szServic } // Helper -static __inline int DRAW_TEXT(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, - SmileysParseInfo parseInfo) +static __inline int DRAW_TEXT(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol) { if (!opts.replace_smileys) return DrawText(hDC, lpString, nCount, lpRect, uFormat); return Smileys_DrawText(hDC, lpString, nCount, lpRect, uFormat | (opts.resize_smileys ? DT_RESIZE_SMILEYS : 0), - opts.use_contact_list_smileys ? "clist" : protocol, parseInfo); + opts.use_contact_list_smileys ? "clist" : protocol, NULL); } #endif // __COMMONS_H__ diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp index 930afa2bda..103f4d2f96 100644 --- a/plugins/MyDetails/src/data.cpp +++ b/plugins/MyDetails/src/data.cpp @@ -105,10 +105,9 @@ Protocol::~Protocol() void Protocol::lcopystr(TCHAR *dest, TCHAR *src, size_t maxlen) { - if (lstrcmp(dest, src) != 0) - { + if (lstrcmp(dest, src) != 0) { data_changed = true; - lstrcpyn(dest, src, maxlen); + lstrcpyn(dest, src, (DWORD)maxlen); } } diff --git a/plugins/MyDetails/src/frame.cpp b/plugins/MyDetails/src/frame.cpp index bcedb541c5..16b134dba0 100644 --- a/plugins/MyDetails/src/frame.cpp +++ b/plugins/MyDetails/src/frame.cpp @@ -528,9 +528,9 @@ RECT GetRect(HDC hdc, RECT rc, const TCHAR *text, const TCHAR *def_text, Protoco if (pos != NULL) pos[0] = '\0'; if (smileys) - DRAW_TEXT(hdc, tmp2, _tcslen(tmp2), &r_tmp, uFormat | DT_CALCRECT, proto->name, NULL); + DRAW_TEXT(hdc, tmp2, (int)_tcslen(tmp2), &r_tmp, uFormat | DT_CALCRECT, proto->name); else - DrawText(hdc, tmp2, _tcslen(tmp2), &r_tmp, uFormat | DT_CALCRECT); + DrawText(hdc, tmp2, (int)_tcslen(tmp2), &r_tmp, uFormat | DT_CALCRECT); free(tmp2); @@ -851,8 +851,7 @@ void CalcRectangles(HWND hwnd) // Text size RECT r_tmp = r; - DrawText(hdc, proto->status_name, _tcslen(proto->status_name), &r_tmp, - DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS)); + DrawText(hdc, proto->status_name, (int)_tcslen(proto->status_name), &r_tmp, DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS)); SIZE s; s.cy = max(r_tmp.bottom - r_tmp.top, ICON_SIZE); @@ -947,8 +946,7 @@ void CalcRectangles(HWND hwnd) // Text size RECT r_tmp = r; - DrawText(hdc, proto->listening_to, _tcslen(proto->listening_to), &r_tmp, - DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS)); + DrawText(hdc, proto->listening_to, (int)_tcslen(proto->listening_to), &r_tmp, DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS)); SIZE s; s.cy = max(r_tmp.bottom - r_tmp.top, ICON_SIZE); @@ -1069,8 +1067,7 @@ void EraseBackground(HWND hwnd, HDC hdc, MyDetailsFrameData* data) } } -void DrawTextWithRect(HDC hdc, const TCHAR *text, const TCHAR *def_text, RECT rc, UINT uFormat, - bool mouse_over, Protocol *proto, bool replace_smileys = true) +void DrawTextWithRect(HDC hdc, const TCHAR *text, const TCHAR *def_text, RECT rc, UINT uFormat, bool mouse_over, Protocol *proto) { const TCHAR *tmp; if (text[0] == '\0') @@ -1123,15 +1120,10 @@ void DrawTextWithRect(HDC hdc, const TCHAR *text, const TCHAR *def_text, RECT rc } } - if (replace_smileys) - DRAW_TEXT(hdc, tmp2, _tcslen(tmp2), &r, uFormat, proto->name, NULL); - else - DrawText(hdc, tmp2, _tcslen(tmp2), &r, uFormat); + DRAW_TEXT(hdc, tmp2, (int)_tcslen(tmp2), &r, uFormat, proto->name); if (mouse_over) - { DrawText(hdc, _T(" ..."), 4, &rc_tmp, uFormat); - } SelectClipRgn(hdc, NULL); DeleteObject(rgn); @@ -1290,7 +1282,7 @@ void Draw(HWND hwnd, HDC hdc_orig) SelectObject(hdc, hFont[FONT_PROTO]); SetTextColor(hdc, font_colour[FONT_PROTO]); - DrawText(hdc, proto->description, _tcslen(proto->description), &rr, uFormat); + DrawText(hdc, proto->description, (int)_tcslen(proto->description), &rr, uFormat); // Clipping rgn SelectClipRgn(hdc, NULL); @@ -1335,7 +1327,7 @@ void Draw(HWND hwnd, HDC hdc_orig) SelectObject(hdc, hFont[FONT_STATUS]); SetTextColor(hdc, font_colour[FONT_STATUS]); - DrawText(hdc, proto->status_name, _tcslen(proto->status_name), &rc, uFormat); + DRAW_TEXT(hdc, proto->status_name, (int)_tcslen(proto->status_name), &rc, uFormat, proto->name); SelectClipRgn(hdc, NULL); DeleteObject(rgn); @@ -1410,7 +1402,7 @@ void Draw(HWND hwnd, HDC hdc_orig) SelectObject(hdc, hFont[FONT_LISTENING_TO]); SetTextColor(hdc, font_colour[FONT_LISTENING_TO]); - DrawText(hdc, proto->listening_to, _tcslen(proto->listening_to), &rc, uFormat); + DrawText(hdc, proto->listening_to, (int)_tcslen(proto->listening_to), &rc, uFormat); SelectClipRgn(hdc, NULL); DeleteObject(rgn); @@ -1587,7 +1579,7 @@ void ShowListeningToMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, P mii.fType = MFT_STRING; mii.fState = proto->ListeningToEnabled() ? MFS_CHECKED : 0; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 1; if ( !proto->CanSetListeningTo()) @@ -1806,7 +1798,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = protocols->Get(i)->description; - mii.cch = _tcslen(protocols->Get(i)->description); + mii.cch = (int)_tcslen(protocols->Get(i)->description); mii.wID = i + 1; if (i == data->protocol_number) { @@ -1878,7 +1870,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 1; if ( !proto->CanSetAvatar()) @@ -1924,7 +1916,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 1; if ( !proto->CanSetNick()) @@ -1981,7 +1973,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 1; if ( !proto->CanSetStatusMsg()) { @@ -2001,7 +1993,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 2; if (proto->status == ID_STATUS_OFFLINE) { @@ -2071,7 +2063,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fType = MFT_STRING; mii.fState = proto->ListeningToEnabled() ? MFS_CHECKED : 0; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 5; if ( !proto->CanSetListeningTo()) @@ -2090,7 +2082,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 4; if (proto->status == ID_STATUS_OFFLINE) { @@ -2110,7 +2102,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 3; if ( !proto->CanSetStatusMsg()) @@ -2129,7 +2121,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 2; if ( !proto->CanSetNick()) @@ -2147,7 +2139,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = _tcslen(tmp); + mii.cch = (int)_tcslen(tmp); mii.wID = 1; if ( !proto->CanSetAvatar()) diff --git a/plugins/Utils/mir_smileys.cpp b/plugins/Utils/mir_smileys.cpp index de0844950a..e512273c17 100644 --- a/plugins/Utils/mir_smileys.cpp +++ b/plugins/Utils/mir_smileys.cpp @@ -406,28 +406,20 @@ void DestroySmileyList( SortedList* p_list ) // Generete the list of smileys / text to be drawn SortedList * ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height) { - SMADD_BATCHPARSE2 sp = {0}; - SMADD_BATCHPARSERES *spres; - *max_smiley_height = 0; if (text[0] == '\0' || !ServiceExists(MS_SMILEYADD_BATCHPARSE)) - { return NULL; - } // Parse it! - sp.cbSize = sizeof(sp); + SMADD_BATCHPARSE2 sp = { sizeof(sp) }; sp.Protocolname = protocol; sp.str = (TCHAR*)text; - sp.oflag = SAFL_TCHAR; - spres = (SMADD_BATCHPARSERES *) CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); - + sp.flag = SAFL_TCHAR; + SMADD_BATCHPARSERES *spres = (SMADD_BATCHPARSERES *) CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); if (spres == NULL) - { // Did not find a simley return NULL; - } // Lets add smileys SortedList *plText = List_Create(0, 10); @@ -435,16 +427,13 @@ SortedList * ReplaceSmileys(const TCHAR *text, int text_size, const char *protoc const TCHAR *next_text_pos = text; const TCHAR *last_text_pos = _tcsninc(text, text_size); - for (unsigned int i = 0; i < sp.numSmileys; i++) - { + for (unsigned int i = 0; i < sp.numSmileys; i++) { TCHAR* start = _tcsninc(text, spres[i].startChar); TCHAR* end = _tcsninc(start, spres[i].size); - if (spres[i].hIcon != NULL) // For deffective smileypacks - { + if (spres[i].hIcon != NULL) { // For defective smileypacks // Add text - if (start > next_text_pos) - { + if (start > next_text_pos) { TextPiece *piece = (TextPiece *) mir_calloc(sizeof(TextPiece)); piece->type = TEXT_PIECE_TYPE_TEXT; -- cgit v1.2.3