diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-19 08:02:41 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-19 08:02:41 +0000 |
commit | 08dc125be616458112368e7154b29d5d23f1126e (patch) | |
tree | 1c27ef9b8525f45913c19bb6f4c18a31b6593749 /plugins/Utils | |
parent | a63798c1b60eeb77352323ad4545630cdc5458f2 (diff) |
Unicode in status message plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@1033 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Utils')
-rw-r--r-- | plugins/Utils/mir_memory.h | 2 | ||||
-rw-r--r-- | plugins/Utils/mir_options.cpp | 42 | ||||
-rw-r--r-- | plugins/Utils/mir_smileys.cpp | 55 | ||||
-rw-r--r-- | plugins/Utils/mir_smileys.h | 4 |
4 files changed, 46 insertions, 57 deletions
diff --git a/plugins/Utils/mir_memory.h b/plugins/Utils/mir_memory.h index 51b16866ab..678972805c 100644 --- a/plugins/Utils/mir_memory.h +++ b/plugins/Utils/mir_memory.h @@ -75,7 +75,7 @@ static int strcmpnullW(WCHAR *str1, WCHAR *str2) #define CHECK_VERSION(_NAME_) \
- if (!mir_is_unicode()) \
+ if ( !mir_is_unicode()) \
{ \
MessageBox(NULL, _T("Your Miranda is ansi. You have to install ansi ") _T(_NAME_), \
_T(_NAME_), MB_OK | MB_ICONERROR); \
diff --git a/plugins/Utils/mir_options.cpp b/plugins/Utils/mir_options.cpp index c52995471e..493f01f527 100644 --- a/plugins/Utils/mir_options.cpp +++ b/plugins/Utils/mir_options.cpp @@ -37,7 +37,7 @@ Boston, MA 02111-1307, USA. #include "mir_memory.h"
-#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]))
+#define SIZEOF(_A_) ( sizeof(_A_) / sizeof(_A_[0]))
static TCHAR* MyDBGetContactSettingTString(HANDLE hContact, char* module, char* setting, TCHAR* out, size_t len, TCHAR *def)
@@ -46,7 +46,7 @@ static TCHAR* MyDBGetContactSettingTString(HANDLE hContact, char* module, char* out[0] = _T('\0');
- if (!DBGetContactSettingTString(hContact, module, setting, &dbv))
+ if ( !DBGetContactSettingTString(hContact, module, setting, &dbv))
{
lstrcpyn(out, dbv.ptszVal, (int)len);
DBFreeVariant(&dbv);
@@ -66,7 +66,7 @@ static TCHAR dbPath[MAX_PATH] = {0}; // database profile path (read at startup static int PathIsAbsolute(const TCHAR *path)
{
- if (!path || !(lstrlen(path) > 2))
+ if ( !path || !(lstrlen(path) > 2))
return 0;
if ((path[1]==_T(':') && path[2]==_T('\\')) || (path[0]==_T('\\')&&path[1]==_T('\\')))
return 1;
@@ -75,7 +75,7 @@ static int PathIsAbsolute(const TCHAR *path) static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc)
{
- if (!PathIsAbsolute(pSrc))
+ if ( !PathIsAbsolute(pSrc))
{
lstrcpyn(pOut, pSrc, (int)outSize);
}
@@ -84,8 +84,8 @@ static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) if (dbPath[0] == _T('\0'))
{
char tmp[1024];
- CallService(MS_DB_GETPROFILEPATH, MAX_REGS(tmp), (LPARAM) tmp);
- mir_sntprintf(dbPath, MAX_REGS(dbPath), _T(TCHAR_STR_PARAM) _T("\\"), tmp);
+ CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM) tmp);
+ mir_sntprintf(dbPath, SIZEOF(dbPath), _T(TCHAR_STR_PARAM) _T("\\"), tmp);
}
size_t len = lstrlen(dbPath);
@@ -111,8 +111,8 @@ static void PathToAbsolute(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) if (dbPath[0] == _T('\0'))
{
char tmp[1024];
- CallService(MS_DB_GETPROFILEPATH, MAX_REGS(tmp), (LPARAM) tmp);
- mir_sntprintf(dbPath, MAX_REGS(dbPath), _T(TCHAR_STR_PARAM) _T("\\"), tmp);
+ CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM) tmp);
+ mir_sntprintf(dbPath, SIZEOF(dbPath), _T(TCHAR_STR_PARAM) _T("\\"), tmp);
}
mir_sntprintf(pOut, outSize, _T("%s%s"), dbPath, pSrc);
@@ -167,16 +167,16 @@ static void LoadOpt(OptPageControl *ctrl, char *module) tmp[0]=0;
DBVARIANT dbv = {0};
- if (!DBGetContactSettingString(NULL, module, ctrl->setting, &dbv))
+ if ( !DBGetContactSettingString(NULL, module, ctrl->setting, &dbv))
{
- lstrcpynA(tmp, dbv.pszVal, MAX_REGS(tmp));
+ lstrcpynA(tmp, dbv.pszVal, SIZEOF(tmp));
DBFreeVariant(&dbv);
}
if (tmp[0] != 0)
- CallService(MS_DB_CRYPT_DECODESTRING, MAX_REGS(tmp), (LPARAM) tmp);
+ CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(tmp), (LPARAM) tmp);
else if (ctrl->szDefValue != NULL)
- lstrcpynA(tmp, ctrl->szDefValue, MAX_REGS(tmp));
+ lstrcpynA(tmp, ctrl->szDefValue, SIZEOF(tmp));
char *var = (char *) ctrl->var;
int size = min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024);
@@ -340,16 +340,16 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha tmp[0]=0;
DBVARIANT dbv = {0};
- if (!DBGetContactSettingString(NULL, module, ctrl->setting, &dbv))
+ if ( !DBGetContactSettingString(NULL, module, ctrl->setting, &dbv))
{
- lstrcpynA(tmp, dbv.pszVal, MAX_REGS(tmp));
+ lstrcpynA(tmp, dbv.pszVal, SIZEOF(tmp));
DBFreeVariant(&dbv);
}
if (tmp[0] != 0)
- CallService(MS_DB_CRYPT_DECODESTRING, MAX_REGS(tmp), (LPARAM) tmp);
+ CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(tmp), (LPARAM) tmp);
else if (ctrl->szDefValue != NULL)
- lstrcpynA(tmp, ctrl->szDefValue, MAX_REGS(tmp));
+ lstrcpynA(tmp, ctrl->szDefValue, SIZEOF(tmp));
SetDlgItemTextA(hwndDlg, ctrl->nID, tmp);
SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0);
@@ -386,7 +386,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
int count = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCOUNT, 0, 0);
int i;
- for(i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
{
TCHAR *id = (TCHAR *) SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM) i, 0);
if (lstrcmp(id, tmp) == 0)
@@ -500,14 +500,14 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha case CONTROL_TEXT:
{
TCHAR tmp[1024];
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp));
+ GetDlgItemText(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp));
DBWriteContactSettingTString(NULL, module, ctrl->setting, tmp);
break;
}
case CONTROL_PASSWORD:
{
char tmp[1024];
- GetDlgItemTextA(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp));
+ GetDlgItemTextA(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp));
if (ctrl->var != NULL)
{
@@ -522,7 +522,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha continue;
}
- CallService(MS_DB_CRYPT_ENCODESTRING, MAX_REGS(tmp), (LPARAM) tmp);
+ CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(tmp), (LPARAM) tmp);
DBWriteContactSettingString(NULL, module, ctrl->setting, tmp);
// Don't load from DB
@@ -532,7 +532,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha {
BOOL trans;
int val = GetDlgItemInt(hwndDlg, ctrl->nID, &trans, ctrl->min <= 0);
- if (!trans)
+ if ( !trans)
val = ctrl->dwDefValue;
if (ctrl->max != 0)
val = min(val, ctrl->max);
diff --git a/plugins/Utils/mir_smileys.cpp b/plugins/Utils/mir_smileys.cpp index 59587f4c9c..7313f093d8 100644 --- a/plugins/Utils/mir_smileys.cpp +++ b/plugins/Utils/mir_smileys.cpp @@ -60,10 +60,10 @@ typedef struct -SortedList * ReplaceSmileys(const char *text, int text_size, const char *protocol, int *max_smiley_height);
-void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height);
+SortedList * ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height);
+void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height);
void DestroySmileyList( SortedList* p_list );
-SIZE GetTextSize(HDC hdcMem, const char *szText, SortedList *plText, UINT uTextFormat, int max_smiley_height);
+SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SortedList *plText, UINT uTextFormat, int max_smiley_height);
@@ -86,7 +86,7 @@ int InitContactListSmileys() return 0;
}
-SmileysParseInfo Smileys_PreParse(LPCSTR lpString, int nCount, const char *protocol)
+SmileysParseInfo Smileys_PreParse(const TCHAR* lpString, int nCount, const char *protocol)
{
SmileysParseInfo info = (SmileysParseInfo) mir_alloc0(sizeof(_SmileysParseInfo));
@@ -106,26 +106,17 @@ void Smileys_FreeParse(SmileysParseInfo parseInfo) }
}
-int skin_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat)
+int skin_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat)
{
if ((uFormat & DT_CALCRECT) == 0 && ServiceExists(MS_SKINENG_ALPHATEXTOUT))
{
COLORREF color = SetTextColor(hDC, 0);
SetTextColor(hDC, color);
- if (mir_is_unicode())
- {
- return AlphaText(hDC, (char *) (const WCHAR *) CharToWchar(lpString), nCount, lpRect, uFormat, color);
- }
- else
- {
- return AlphaText(hDC, lpString, nCount, lpRect, uFormat, color);
- }
- }
- else
- {
- return DrawText(hDC, lpString, nCount, lpRect, uFormat);
+ return AlphaText(hDC, lpString, nCount, lpRect, uFormat, color);
}
+
+ return DrawText(hDC, lpString, nCount, lpRect, uFormat);
}
int skin_DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth,
@@ -142,13 +133,13 @@ int skin_DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int // Similar to DrawText win32 api function
// Pass uFormat | DT_CALCRECT to calc rectangle to be returned by lpRect
// parseInfo is optional (pass NULL and it will be calculated and deleted inside function
-int Smileys_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo)
+int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo)
{
SmileysParseInfo info;
int ret;
if (nCount < 0)
- nCount = strlen(lpString);
+ nCount = _tcslen(lpString);
// Get parse info
if (parseInfo == NULL)
@@ -225,7 +216,7 @@ int Smileys_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT u -SIZE GetTextSize(HDC hdcMem, const char *szText, SortedList *plText, UINT uTextFormat, int max_smiley_height)
+SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SortedList *plText, UINT uTextFormat, int max_smiley_height)
{
SIZE text_size;
@@ -248,7 +239,7 @@ SIZE GetTextSize(HDC hdcMem, const char *szText, SortedList *plText, UINT uTextF }
else
{
- if (!(uTextFormat & DT_RESIZE_SMILEYS))
+ if ( !(uTextFormat & DT_RESIZE_SMILEYS))
text_size.cy = max(text_size.cy, max_smiley_height);
text_size.cx = 0;
@@ -287,12 +278,10 @@ SIZE GetTextSize(HDC hdcMem, const char *szText, SortedList *plText, UINT uTextF return text_size;
}
-void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height)
+void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height)
{
if (szText == NULL)
- {
return;
- }
uTextFormat &= ~DT_RIGHT;
@@ -308,7 +297,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, Sorte i = 0;
// Get real height of the line
- text_height = skin_DrawText(hdcMem, "A", 1, &tmp_rc, DT_CALCRECT | uTextFormat);
+ text_height = skin_DrawText(hdcMem, _T("A"), 1, &tmp_rc, DT_CALCRECT | uTextFormat);
if (uTextFormat & DT_RESIZE_SMILEYS)
row_height = text_height;
else
@@ -317,7 +306,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, Sorte // Just draw ellipsis
if (free_rc.right <= free_rc.left)
{
- skin_DrawText(hdcMem, "...", 3, &free_rc, uTextFormat & ~DT_END_ELLIPSIS);
+ skin_DrawText(hdcMem, _T("..."), 3, &free_rc, uTextFormat & ~DT_END_ELLIPSIS);
}
else
{
@@ -381,7 +370,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, Sorte else
{
text_rc.top += (row_height - text_height) >> 1;
- skin_DrawText(hdcMem, "...", 3, &text_rc, uTextFormat);
+ skin_DrawText(hdcMem, _T("..."), 3, &text_rc, uTextFormat);
}
pos_x += (LONG)(piece->smiley_width * factor);
@@ -420,7 +409,7 @@ void DestroySmileyList( SortedList* p_list ) // Generete the list of smileys / text to be drawn
-SortedList * ReplaceSmileys(const char *text, int text_size, const char *protocol, int *max_smiley_height)
+SortedList * ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height)
{
SMADD_BATCHPARSE2 sp = {0};
SMADD_BATCHPARSERES *spres;
@@ -435,7 +424,7 @@ SortedList * ReplaceSmileys(const char *text, int text_size, const char *protoco // Parse it!
sp.cbSize = sizeof(sp);
sp.Protocolname = protocol;
- sp.str = (char *)text;
+ sp.str = (TCHAR*)text;
sp.oflag = SAFL_TCHAR;
spres = (SMADD_BATCHPARSERES *) CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp);
@@ -448,13 +437,13 @@ SortedList * ReplaceSmileys(const char *text, int text_size, const char *protoco // Lets add smileys
SortedList *plText = List_Create(0, 10);
- const char *next_text_pos = text;
- const char *last_text_pos = _tcsninc(text, text_size);
+ const TCHAR *next_text_pos = text;
+ const TCHAR *last_text_pos = _tcsninc(text, text_size);
for (unsigned int i = 0; i < sp.numSmileys; i++)
{
- char * start = _tcsninc(text, spres[i].startChar);
- char * end = _tcsninc(start, spres[i].size);
+ TCHAR* start = _tcsninc(text, spres[i].startChar);
+ TCHAR* end = _tcsninc(start, spres[i].size);
if (spres[i].hIcon != NULL) // For deffective smileypacks
{
diff --git a/plugins/Utils/mir_smileys.h b/plugins/Utils/mir_smileys.h index cfbebb853a..8b3b2a504b 100644 --- a/plugins/Utils/mir_smileys.h +++ b/plugins/Utils/mir_smileys.h @@ -55,13 +55,13 @@ void Smileys_FreeParse(SmileysParseInfo parseInfo); // Similar to DrawText win32 api function
// Pass uFormat | DT_CALCRECT to calc rectangle to be returned by lpRect
// parseInfo is optional (pass NULL and it will be calculated and deleted inside function)
-int Smileys_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo);
+int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo);
// TODO:
// int Smileys_DrawTextW(HDC hDC, LPCWSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo);
-int skin_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat);
+int skin_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat);
int skin_DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags);
|