From 393b989dd82764b10152c06a51d77d27550ccd8e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 1 Nov 2012 11:34:39 +0000 Subject: extraicons Unicode git-svn-id: http://svn.miranda-ng.org/main/trunk@2127 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ExtraIcons/extraicons.vcxproj | 8 ++-- plugins/ExtraIcons/src/BaseExtraIcon.cpp | 6 +-- plugins/ExtraIcons/src/BaseExtraIcon.h | 8 ++-- plugins/ExtraIcons/src/CallbackExtraIcon.cpp | 2 +- plugins/ExtraIcons/src/CallbackExtraIcon.h | 2 +- plugins/ExtraIcons/src/DefaultExtraIcons.cpp | 8 ++-- plugins/ExtraIcons/src/ExtraIcon.h | 2 +- plugins/ExtraIcons/src/ExtraIconGroup.cpp | 6 +-- plugins/ExtraIcons/src/ExtraIconGroup.h | 4 +- plugins/ExtraIcons/src/IcolibExtraIcon.cpp | 2 +- plugins/ExtraIcons/src/IcolibExtraIcon.h | 2 +- plugins/ExtraIcons/src/Version.h | 4 +- plugins/ExtraIcons/src/commons.h | 5 +-- plugins/ExtraIcons/src/extraicons.cpp | 31 +++++++------- plugins/ExtraIcons/src/options.cpp | 62 +++++++++++++--------------- 15 files changed, 72 insertions(+), 80 deletions(-) (limited to 'plugins') diff --git a/plugins/ExtraIcons/extraicons.vcxproj b/plugins/ExtraIcons/extraicons.vcxproj index 22fdd5ac11..2358001d9f 100644 --- a/plugins/ExtraIcons/extraicons.vcxproj +++ b/plugins/ExtraIcons/extraicons.vcxproj @@ -25,20 +25,20 @@ DynamicLibrary - MultiByte + Unicode DynamicLibrary - MultiByte + Unicode DynamicLibrary - MultiByte + Unicode true DynamicLibrary - MultiByte + Unicode true diff --git a/plugins/ExtraIcons/src/BaseExtraIcon.cpp b/plugins/ExtraIcons/src/BaseExtraIcon.cpp index f1aea5438c..594b4b7637 100644 --- a/plugins/ExtraIcons/src/BaseExtraIcon.cpp +++ b/plugins/ExtraIcons/src/BaseExtraIcon.cpp @@ -19,7 +19,7 @@ #include "commons.h" -BaseExtraIcon::BaseExtraIcon(int id, const char *name, const char *description, const char *descIcon, +BaseExtraIcon::BaseExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param) : ExtraIcon(name), id(id), description(description), descIcon(descIcon), OnClick(OnClick), onClickParam(param) { @@ -40,12 +40,12 @@ int BaseExtraIcon::getID() const return id; } -const char *BaseExtraIcon::getDescription() const +const TCHAR *BaseExtraIcon::getDescription() const { return description.c_str(); } -void BaseExtraIcon::setDescription(const char *desc) +void BaseExtraIcon::setDescription(const TCHAR *desc) { description = desc; } diff --git a/plugins/ExtraIcons/src/BaseExtraIcon.h b/plugins/ExtraIcons/src/BaseExtraIcon.h index e484dd2e4b..e382d0d3a9 100644 --- a/plugins/ExtraIcons/src/BaseExtraIcon.h +++ b/plugins/ExtraIcons/src/BaseExtraIcon.h @@ -25,13 +25,13 @@ class BaseExtraIcon : public ExtraIcon { public: - BaseExtraIcon(int id, const char *name, const char *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, + BaseExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param); virtual ~BaseExtraIcon(); virtual int getID() const; - virtual const char *getDescription() const; - virtual void setDescription(const char *desc); + virtual const TCHAR *getDescription() const; + virtual void setDescription(const TCHAR *desc); virtual const char *getDescIcon() const; virtual void setDescIcon(const char *icon); virtual int getType() const =0; @@ -43,7 +43,7 @@ public: protected: int id; - std::string description; + std::tstring description; std::string descIcon; MIRANDAHOOKPARAM OnClick; LPARAM onClickParam; diff --git a/plugins/ExtraIcons/src/CallbackExtraIcon.cpp b/plugins/ExtraIcons/src/CallbackExtraIcon.cpp index 3f4d368f75..2b8b2da7b5 100644 --- a/plugins/ExtraIcons/src/CallbackExtraIcon.cpp +++ b/plugins/ExtraIcons/src/CallbackExtraIcon.cpp @@ -19,7 +19,7 @@ #include "commons.h" -CallbackExtraIcon::CallbackExtraIcon(int id, const char *name, const char *description, const char *descIcon, +CallbackExtraIcon::CallbackExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick, LPARAM param) : BaseExtraIcon(id, name, description, descIcon, OnClick, param), RebuildIcons(RebuildIcons), ApplyIcon(ApplyIcon), needToRebuild(true) diff --git a/plugins/ExtraIcons/src/CallbackExtraIcon.h b/plugins/ExtraIcons/src/CallbackExtraIcon.h index 7b46c88da9..547f81a477 100644 --- a/plugins/ExtraIcons/src/CallbackExtraIcon.h +++ b/plugins/ExtraIcons/src/CallbackExtraIcon.h @@ -25,7 +25,7 @@ class CallbackExtraIcon : public BaseExtraIcon { public: - CallbackExtraIcon(int id, const char *name, const char *description, const char *descIcon, + CallbackExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick, LPARAM param); virtual ~CallbackExtraIcon(); diff --git a/plugins/ExtraIcons/src/DefaultExtraIcons.cpp b/plugins/ExtraIcons/src/DefaultExtraIcons.cpp index 05d1f9eed6..33cc1afecd 100644 --- a/plugins/ExtraIcons/src/DefaultExtraIcons.cpp +++ b/plugins/ExtraIcons/src/DefaultExtraIcons.cpp @@ -151,12 +151,12 @@ static void EmailOnClick(Info *info, const char *text) { char cmd[1024]; mir_snprintf(cmd, MAX_REGS(cmd), "mailto:%s", text); - ShellExecute(NULL, "open", cmd, NULL, NULL, SW_SHOW); + ShellExecuteA(NULL, "open", cmd, NULL, NULL, SW_SHOW); } static void HomepageOnClick(Info *info, const char *text) { - ShellExecute(NULL, "open", text, NULL, NULL, SW_SHOW); + ShellExecuteA(NULL, "open", text, NULL, NULL, SW_SHOW); } static void DefaultSetIcon(HANDLE hContact, Info *info, const char *text) @@ -271,9 +271,9 @@ static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param) DBVARIANT dbv = { 0 }; if (!DBGetContactSettingString(hContact, info->db[j] == NULL ? proto : info->db[j], info->db[j+1], &dbv)) { - if (!IsEmpty(dbv.ptszVal)) + if (!IsEmpty(dbv.pszVal)) { - info->OnClick(info, dbv.ptszVal); + info->OnClick(info, dbv.pszVal); found = true; } diff --git a/plugins/ExtraIcons/src/ExtraIcon.h b/plugins/ExtraIcons/src/ExtraIcon.h index 03b0177a08..281e9e25eb 100644 --- a/plugins/ExtraIcons/src/ExtraIcon.h +++ b/plugins/ExtraIcons/src/ExtraIcon.h @@ -39,7 +39,7 @@ public: virtual void storeIcon(HANDLE hContact, void *icon) =0; virtual const char *getName() const; - virtual const char *getDescription() const =0; + virtual const TCHAR *getDescription() const =0; virtual const char *getDescIcon() const =0; virtual int getType() const =0; diff --git a/plugins/ExtraIcons/src/ExtraIconGroup.cpp b/plugins/ExtraIcons/src/ExtraIconGroup.cpp index cfad5abea7..9c31827eff 100644 --- a/plugins/ExtraIcons/src/ExtraIconGroup.cpp +++ b/plugins/ExtraIcons/src/ExtraIconGroup.cpp @@ -36,11 +36,11 @@ void ExtraIconGroup::addExtraIcon(BaseExtraIcon *extra) { items.push_back(extra); - description = ""; + description.clear(); for (unsigned int i = 0; i < items.size(); ++i) { if (i > 0) - description += " / "; + description += _T(" / "); description += items[i]->getDescription(); } } @@ -183,7 +183,7 @@ void ExtraIconGroup::storeIcon(HANDLE hContact, void *icon) { } -const char *ExtraIconGroup::getDescription() const +const TCHAR *ExtraIconGroup::getDescription() const { return description.c_str(); } diff --git a/plugins/ExtraIcons/src/ExtraIconGroup.h b/plugins/ExtraIcons/src/ExtraIconGroup.h index 906509962d..eb2aec5561 100644 --- a/plugins/ExtraIcons/src/ExtraIconGroup.h +++ b/plugins/ExtraIcons/src/ExtraIconGroup.h @@ -40,7 +40,7 @@ public: virtual int setIcon(int id, HANDLE hContact, void *icon); virtual void storeIcon(HANDLE hContact, void *icon); - virtual const char *getDescription() const; + virtual const TCHAR *getDescription() const; virtual const char *getDescIcon() const; virtual int getType() const; @@ -52,7 +52,7 @@ public: virtual int ClistSetExtraIcon(HANDLE hContact, HANDLE hImage); protected: - std::string description; + std::tstring description; bool setValidExtraIcon; bool insideApply; diff --git a/plugins/ExtraIcons/src/IcolibExtraIcon.cpp b/plugins/ExtraIcons/src/IcolibExtraIcon.cpp index 56718af753..c3381b1d7f 100644 --- a/plugins/ExtraIcons/src/IcolibExtraIcon.cpp +++ b/plugins/ExtraIcons/src/IcolibExtraIcon.cpp @@ -19,7 +19,7 @@ #include "commons.h" -IcolibExtraIcon::IcolibExtraIcon(int id, const char *name, const char *description, const char *descIcon, +IcolibExtraIcon::IcolibExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param) : BaseExtraIcon(id, name, description, descIcon, OnClick, param) { diff --git a/plugins/ExtraIcons/src/IcolibExtraIcon.h b/plugins/ExtraIcons/src/IcolibExtraIcon.h index 2f142f2607..5f113e7251 100644 --- a/plugins/ExtraIcons/src/IcolibExtraIcon.h +++ b/plugins/ExtraIcons/src/IcolibExtraIcon.h @@ -25,7 +25,7 @@ class IcolibExtraIcon : public BaseExtraIcon { public: - IcolibExtraIcon(int id, const char *name, const char *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, + IcolibExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param); virtual ~IcolibExtraIcon(); diff --git a/plugins/ExtraIcons/src/Version.h b/plugins/ExtraIcons/src/Version.h index 69096ecd40..7ce11c04b0 100644 --- a/plugins/ExtraIcons/src/Version.h +++ b/plugins/ExtraIcons/src/Version.h @@ -1,6 +1,6 @@ #define __MAJOR_VERSION 0 -#define __MINOR_VERSION 2 -#define __RELEASE_NUM 5 +#define __MINOR_VERSION 3 +#define __RELEASE_NUM 0 #define __BUILD_NUM 0 #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM diff --git a/plugins/ExtraIcons/src/commons.h b/plugins/ExtraIcons/src/commons.h index d52f4bad21..e875fd7059 100644 --- a/plugins/ExtraIcons/src/commons.h +++ b/plugins/ExtraIcons/src/commons.h @@ -22,10 +22,6 @@ #define _CRT_SECURE_NO_WARNINGS -#ifdef UNICODE -#error "Unicode not needed by this plugin" -#endif - #define _WIN32_IE 0x500 #include #include @@ -44,6 +40,7 @@ using namespace std; #include #include +#include #include #include #include diff --git a/plugins/ExtraIcons/src/extraicons.cpp b/plugins/ExtraIcons/src/extraicons.cpp index c1affd39ac..dd8e9f6dac 100644 --- a/plugins/ExtraIcons/src/extraicons.cpp +++ b/plugins/ExtraIcons/src/extraicons.cpp @@ -313,7 +313,7 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) if (ei->type == EXTRAICON_TYPE_CALLBACK && (ei->ApplyIcon == NULL || ei->RebuildIcons == NULL)) return 0; - const char *desc = Translate(ei->description); + TCHAR *desc = Langpack_PcharToTchar(ei->description); BaseExtraIcon *extra = GetExtraIconByName(ei->name); if (extra != NULL) @@ -323,10 +323,10 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) // Found one, now merge it - if (_stricmp(extra->getDescription(), desc)) + if (_tcsicmp(extra->getDescription(), desc)) { - string newDesc = extra->getDescription(); - newDesc += " / "; + tstring newDesc = extra->getDescription(); + newDesc += _T(" / "); newDesc += desc; extra->setDescription(newDesc.c_str()); } @@ -350,18 +350,17 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) int id = (int)registeredExtraIcons.size() + 1; - switch (ei->type) - { - case EXTRAICON_TYPE_CALLBACK: - extra = new CallbackExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, - ei->RebuildIcons, ei->ApplyIcon, ei->OnClick, ei->onClickParam); - break; - case EXTRAICON_TYPE_ICOLIB: - extra = new IcolibExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->OnClick, - ei->onClickParam); - break; - default: - return 0; + switch (ei->type) { + case EXTRAICON_TYPE_CALLBACK: + extra = new CallbackExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, + ei->RebuildIcons, ei->ApplyIcon, ei->OnClick, ei->onClickParam); + break; + case EXTRAICON_TYPE_ICOLIB: + extra = new IcolibExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->OnClick, + ei->onClickParam); + break; + default: + return 0; } char setting[512]; diff --git a/plugins/ExtraIcons/src/options.cpp b/plugins/ExtraIcons/src/options.cpp index d033e56b51..28deab3139 100644 --- a/plugins/ExtraIcons/src/options.cpp +++ b/plugins/ExtraIcons/src/options.cpp @@ -179,9 +179,8 @@ static void Tree_Select(HWND tree, vector &selected) LRESULT CALLBACK TreeProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { - case WM_LBUTTONDOWN: + switch (msg) { + case WM_LBUTTONDOWN: { DWORD pos = (DWORD) lParam; @@ -195,7 +194,7 @@ LRESULT CALLBACK TreeProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) } if (!(wParam & (MK_CONTROL | MK_SHIFT)) || !(hti.flags & (TVHT_ONITEMICON | TVHT_ONITEMLABEL - | TVHT_ONITEMRIGHT))) + | TVHT_ONITEMRIGHT))) { UnselectAll(hwndDlg); TreeView_SelectItem(hwndDlg, hti.hItem); @@ -276,7 +275,7 @@ static HTREEITEM Tree_AddExtraIcon(HWND tree, BaseExtraIcon *extra, bool selecte tvis.item.stateMask = TVIS_STATEIMAGEMASK; tvis.item.iSelectedImage = tvis.item.iImage = extra->getID(); tvis.item.lParam = (LPARAM) ids; - tvis.item.pszText = (char *) extra->getDescription(); + tvis.item.pszText = (LPTSTR)extra->getDescription(); tvis.item.state = INDEXTOSTATEIMAGEMASK(selected ? 2 : 1); return TreeView_InsertItem(tree, &tvis); } @@ -284,7 +283,7 @@ static HTREEITEM Tree_AddExtraIcon(HWND tree, BaseExtraIcon *extra, bool selecte static HTREEITEM Tree_AddExtraIconGroup(HWND tree, vector &group, bool selected, HTREEITEM hAfter = TVI_LAST) { vector *ids = new vector ; - string desc; + tstring desc; int img = 0; for (unsigned int i = 0; i < group.size(); ++i) { @@ -295,7 +294,7 @@ static HTREEITEM Tree_AddExtraIconGroup(HWND tree, vector &group, bool sele img = extra->getID(); if (i > 0) - desc += " / "; + desc += _T(" / "); desc += extra->getDescription(); } @@ -306,7 +305,7 @@ static HTREEITEM Tree_AddExtraIconGroup(HWND tree, vector &group, bool sele tvis.item.stateMask = TVIS_STATEIMAGEMASK; tvis.item.iSelectedImage = tvis.item.iImage = img; tvis.item.lParam = (LPARAM) ids; - tvis.item.pszText = (char *) desc.c_str(); + tvis.item.pszText = (TCHAR*) desc.c_str(); tvis.item.state = INDEXTOSTATEIMAGEMASK(selected ? 2 : 1); return TreeView_InsertItem(tree, &tvis); } @@ -439,17 +438,16 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP static int dragging = 0; static HANDLE hDragItem = NULL; - switch (msg) - { - case WM_INITDIALOG: + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); { - TranslateDialogDefault(hwndDlg); int numSlots = GetNumberOfSlots(); if (numSlots < (int) registeredExtraIcons.size()) { - char txt[512]; - mir_snprintf(txt, MAX_REGS(txt), Translate("* only the first %d icons will be shown"), numSlots); + TCHAR txt[512]; + mir_sntprintf(txt, MAX_REGS(txt), TranslateT("* only the first %d icons will be shown"), numSlots); HWND label = GetDlgItem(hwndDlg, IDC_MAX_ICONS_L); SetWindowText(label, txt); @@ -463,7 +461,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP HIMAGELIST hImageList = ImageList_Create(cx, cx, ILC_COLOR32 | ILC_MASK, 2, 2); HICON hDefaultIcon = (HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_EMPTY), IMAGE_ICON, cx, cx, - LR_DEFAULTCOLOR | LR_SHARED); + LR_DEFAULTCOLOR | LR_SHARED); ImageList_AddIcon(hImageList, hDefaultIcon); DestroyIcon(hDefaultIcon); @@ -477,7 +475,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (hIcon == NULL) { HICON hDefaultIcon = (HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_EMPTY), IMAGE_ICON, cx, cx, - LR_DEFAULTCOLOR | LR_SHARED); + LR_DEFAULTCOLOR | LR_SHARED); ImageList_AddIcon(hImageList, hDefaultIcon); DestroyIcon(hDefaultIcon); } @@ -517,7 +515,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; } - case WM_NOTIFY: + case WM_NOTIFY: { LPNMHDR lpnmhdr = (LPNMHDR) lParam; if (lpnmhdr->idFrom == 0) @@ -657,17 +655,15 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { HWND tree = GetDlgItem(hwndDlg, IDC_EXTRAORDER); - switch (lpnmhdr->code) - { - case TVN_BEGINDRAG: - { - SetCapture(hwndDlg); - dragging = 1; - hDragItem = ((LPNMTREEVIEWA) lParam)->itemNew.hItem; - TreeView_SelectItem(tree, hDragItem); - break; - } - case NM_CLICK: + switch (lpnmhdr->code) { + case TVN_BEGINDRAG: + SetCapture(hwndDlg); + dragging = 1; + hDragItem = ((LPNMTREEVIEWA) lParam)->itemNew.hItem; + TreeView_SelectItem(tree, hDragItem); + break; + + case NM_CLICK: { DWORD pos = GetMessagePos(); @@ -685,7 +681,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } break; } - case TVN_KEYDOWN: + case TVN_KEYDOWN: { TV_KEYDOWN *nmkd = (TV_KEYDOWN *) lpnmhdr; if (nmkd->wVKey == VK_SPACE) @@ -697,7 +693,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } break; } - case NM_RCLICK: + case NM_RCLICK: { HTREEITEM hSelected = (HTREEITEM) SendMessage(tree, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0); if (hSelected != NULL && !IsSelected(tree, hSelected)) @@ -735,7 +731,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; } - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: { if (!dragging) break; @@ -768,7 +764,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } break; } - case WM_LBUTTONUP: + case WM_LBUTTONUP: { if (!dragging) break; @@ -816,7 +812,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; } - case WM_DESTROY: + case WM_DESTROY: { HWND tree = GetDlgItem(hwndDlg, IDC_EXTRAORDER); HTREEITEM hItem = TreeView_GetRoot(tree); -- cgit v1.2.3