diff options
author | George Hazan <george.hazan@gmail.com> | 2012-12-01 08:43:08 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-12-01 08:43:08 +0000 |
commit | 86802925857034fec1fbfb5c0eb668e996b0518d (patch) | |
tree | 68d51590b10b9416c1e2d1bd652a00ce5807da4e | |
parent | 14517f8c04b030e4e46f6eb1167a073ef7a1ae51 (diff) |
finally mir_icons removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@2578 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Import/import_10.vcxproj | 3 | ||||
-rw-r--r-- | plugins/Import/import_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/Import/src/main.cpp | 24 | ||||
-rw-r--r-- | plugins/ListeningTo/listeningto.vcxproj | 1 | ||||
-rw-r--r-- | plugins/ListeningTo/listeningto.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/ListeningTo/src/listeningto.cpp | 20 | ||||
-rw-r--r-- | plugins/MyDetails/src/commons.h | 1 | ||||
-rw-r--r-- | plugins/SpellChecker/spellchecker.vcxproj | 3 | ||||
-rw-r--r-- | plugins/SpellChecker/spellchecker.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/SpellChecker/src/ardialog.cpp | 135 | ||||
-rw-r--r-- | plugins/SpellChecker/src/commons.h | 3 | ||||
-rw-r--r-- | plugins/SpellChecker/src/dictionary.h | 1 | ||||
-rw-r--r-- | plugins/SpellChecker/src/options.cpp | 5 | ||||
-rw-r--r-- | plugins/SpellChecker/src/spellchecker.cpp | 211 | ||||
-rw-r--r-- | plugins/Utils/mir_icons.cpp | 71 | ||||
-rw-r--r-- | plugins/Utils/mir_icons.h | 28 |
16 files changed, 181 insertions, 334 deletions
diff --git a/plugins/Import/import_10.vcxproj b/plugins/Import/import_10.vcxproj index c544c951f4..56d5ecfee2 100644 --- a/plugins/Import/import_10.vcxproj +++ b/plugins/Import/import_10.vcxproj @@ -194,9 +194,6 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\Utils\mir_icons.cpp">
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- </ClCompile>
<ClCompile Include="src\import.cpp" />
<ClCompile Include="src\stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
diff --git a/plugins/Import/import_10.vcxproj.filters b/plugins/Import/import_10.vcxproj.filters index 3495d1e132..7ec3d151a6 100644 --- a/plugins/Import/import_10.vcxproj.filters +++ b/plugins/Import/import_10.vcxproj.filters @@ -33,9 +33,6 @@ <ClCompile Include="src\utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\Utils\mir_icons.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\import.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index 3de2bee115..f06d0aa2b5 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "version.h"
#include "resource.h"
-#include "..\..\Utils\mir_icons.h"
-
int nImportOption;
int nCustomOptions;
@@ -38,7 +36,8 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP static HWND hwndWizard = NULL;
int hLangpack;
-PLUGININFOEX pluginInfo = {
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
"Import contacts and messages",
__VERSION_DWORD,
@@ -47,8 +46,9 @@ PLUGININFOEX pluginInfo = { "info@miranda-im.org",
"© 2000-2010 Martin Öberg, Richard Hughes, Dmitry Kuzkin, George Hazan",
"http://miranda-ng.org/",
- UNICODE_AWARE, //{2D77A746-00A6-4343-BFC5-F808CDD772EA}
- {0x2d77a746, 0xa6, 0x4343, { 0xbf, 0xc5, 0xf8, 0x8, 0xcd, 0xd7, 0x72, 0xea }}
+ UNICODE_AWARE,
+ //{2D77A746-00A6-4343-BFC5-F808CDD772EA}
+ {0x2d77a746, 0xa6, 0x4343, { 0xbf, 0xc5, 0xf8, 0x8, 0xcd, 0xd7, 0x72, 0xea }}
};
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
@@ -113,8 +113,20 @@ extern "C" __declspec(dllexport) int Load(void) hImportService = CreateServiceFunction(IMPORT_SERVICE, ImportCommand);
- hIcoHandle = IcoLib_Register("import_main", "Import", LPGEN("Import..."), IDI_IMPORT);
+ // icon
+ TCHAR tszFile[MAX_PATH];
+ GetModuleFileName(hInst, tszFile, MAX_PATH);
+
+ SKINICONDESC sid = { sizeof(sid) };
+ sid.flags = SIDF_PATH_TCHAR;
+ sid.ptszDefaultFile = tszFile;
+ sid.pszSection = "Import";
+ sid.pszName = "import_main";
+ sid.pszDescription = LPGEN("Import...");
+ sid.iDefaultIndex = -IDI_IMPORT;
+ hIcoHandle = Skin_AddIcon(&sid);
+ // menu item
CLISTMENUITEM mi = { sizeof(mi) };
mi.icolibItem = hIcoHandle;
mi.pszName = LPGEN("&Import...");
diff --git a/plugins/ListeningTo/listeningto.vcxproj b/plugins/ListeningTo/listeningto.vcxproj index ad28eaf4c4..a6dc936469 100644 --- a/plugins/ListeningTo/listeningto.vcxproj +++ b/plugins/ListeningTo/listeningto.vcxproj @@ -191,7 +191,6 @@ </ItemGroup>
<ItemGroup>
<ClCompile Include="src\listeningto.cpp" />
- <ClCompile Include="..\utils\mir_icons.cpp" />
<ClCompile Include="..\utils\mir_options.cpp" />
<ClCompile Include="src\music.cpp" />
<ClCompile Include="src\options.cpp" />
diff --git a/plugins/ListeningTo/listeningto.vcxproj.filters b/plugins/ListeningTo/listeningto.vcxproj.filters index b00eb09a5a..0f53e25820 100644 --- a/plugins/ListeningTo/listeningto.vcxproj.filters +++ b/plugins/ListeningTo/listeningto.vcxproj.filters @@ -76,9 +76,6 @@ <ClCompile Include="src\listeningto.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\utils\mir_icons.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\utils\mir_options.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index 21326eee11..cbe4a7e9e3 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -303,8 +303,24 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) // add our modules to the KnownModules list
CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0);
- hIcon1 = IcoLib_Register("listening_to_icon", "ListeningTo", "Listening to (enabled)", IDI_LISTENINGTO);
- hIcon2 = IcoLib_Register("listening_off_icon", "ListeningTo", "Listening to (disabled)", IDI_LISTENINGOFF);
+ // icons
+ TCHAR tszFile[MAX_PATH];
+ GetModuleFileName(hInst, tszFile, MAX_PATH);
+
+ SKINICONDESC sid = { sizeof(sid) };
+ sid.flags = SIDF_PATH_TCHAR;
+ sid.ptszDefaultFile = tszFile;
+ sid.pszSection = "ListeningTo";
+
+ sid.pszName = "listening_to_icon";
+ sid.pszDescription = LPGEN("Listening to (enabled)");
+ sid.iDefaultIndex = -IDI_LISTENINGTO;
+ hIcon1 = Skin_AddIcon(&sid);
+
+ sid.pszName = "listening_off_icon";
+ sid.pszDescription = LPGEN("Listening to (disabled)");
+ sid.iDefaultIndex = -IDI_LISTENINGOFF;
+ hIcon2 = Skin_AddIcon(&sid);
// Extra icon support
hExtraIcon = ExtraIcon_Register(MODULE_NAME, "Listening to music", "listening_to_icon");
diff --git a/plugins/MyDetails/src/commons.h b/plugins/MyDetails/src/commons.h index 5d875f8aff..68cfc55bf3 100644 --- a/plugins/MyDetails/src/commons.h +++ b/plugins/MyDetails/src/commons.h @@ -80,7 +80,6 @@ extern long status_msg_dialog_open; #include "../utils/mir_smileys.h"
#include "../utils/mir_memory.h"
#include "../utils/mir_options.h"
-#include "../utils/mir_icons.h"
#define PS_GETMYAVATARMAXSIZE "/GetMyAvatarMaxSize"
diff --git a/plugins/SpellChecker/spellchecker.vcxproj b/plugins/SpellChecker/spellchecker.vcxproj index 5e9d389389..8186b27acd 100644 --- a/plugins/SpellChecker/spellchecker.vcxproj +++ b/plugins/SpellChecker/spellchecker.vcxproj @@ -216,9 +216,6 @@ <ClCompile Include="src\ardialog.cpp" />
<ClCompile Include="src\autoreplace.cpp" />
<ClCompile Include="src\dictionary.cpp" />
- <ClCompile Include="..\utils\mir_icons.cpp">
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- </ClCompile>
<ClCompile Include="..\utils\mir_options.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
diff --git a/plugins/SpellChecker/spellchecker.vcxproj.filters b/plugins/SpellChecker/spellchecker.vcxproj.filters index 257a7bccd2..528e04a102 100644 --- a/plugins/SpellChecker/spellchecker.vcxproj.filters +++ b/plugins/SpellChecker/spellchecker.vcxproj.filters @@ -124,9 +124,6 @@ <ClCompile Include="src\dictionary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\utils\mir_icons.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\utils\mir_options.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/SpellChecker/src/ardialog.cpp b/plugins/SpellChecker/src/ardialog.cpp index 8ef67f06cb..507f74329b 100644 --- a/plugins/SpellChecker/src/ardialog.cpp +++ b/plugins/SpellChecker/src/ardialog.cpp @@ -178,28 +178,25 @@ static void Close(HWND hwndDlg, int ret) static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
-
Data *data = (Data *) lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) data);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_OLD), GWLP_USERDATA, (LONG_PTR) data);
data->old_edit_proc = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_OLD), GWLP_WNDPROC,
- (LONG_PTR) OnlyCharsEditProc);
+ (LONG_PTR) OnlyCharsEditProc);
- HICON hIcon = IcoLib_LoadIcon("spellchecker_enabled");
+ HICON hIcon = Skin_GetIcon("spellchecker_enabled");
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
Skin_ReleaseIcon(hIcon);
SendDlgItemMessage(hwndDlg, IDC_OLD, EM_LIMITTEXT, 256, 0);
SendDlgItemMessage(hwndDlg, IDC_NEW, EM_LIMITTEXT, 256, 0);
- if (!data->find.empty())
- {
+ if (!data->find.empty()) {
scoped_free<TCHAR> tmp = data->dict->autoReplace->filterText(data->find.c_str());
SetDlgItemText(hwndDlg, IDC_OLD, tmp);
}
@@ -208,14 +205,12 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa CheckDlgButton(hwndDlg, IDC_VARIABLES, data->useVariables ? BST_CHECKED : BST_UNCHECKED);
- if (data->findReadOnly)
- {
+ if (data->findReadOnly) {
SendDlgItemMessage(hwndDlg, IDC_OLD, EM_SETREADONLY, TRUE, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_OLD_PS), FALSE);
}
- if (!variables_enabled)
- {
+ if (!variables_enabled) {
ShowWindow(GetDlgItem(hwndDlg, IDC_VARIABLES), FALSE);
ShowWindow(GetDlgItem(hwndDlg, IDC_VAR_HELP), FALSE);
@@ -226,90 +221,74 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa rc_new.right = rc_old.right;
SetWindowPos(GetDlgItem(hwndDlg, IDC_NEW), NULL, 0, 0,
- rc_new.right - rc_new.left, rc_new.bottom - rc_new.top,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER);
+ rc_new.right - rc_new.left, rc_new.bottom - rc_new.top,
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER);
}
- else
- {
+ else {
variables_skin_helpbutton(hwndDlg, IDC_VAR_HELP);
EnableWindow(GetDlgItem(hwndDlg, IDC_VAR_HELP), IsDlgButtonChecked(hwndDlg, IDC_VARIABLES));
}
CenterParent(hwndDlg);
-
- return TRUE;
}
+ return TRUE;
- case WM_COMMAND:
- switch(wParam)
+ case WM_COMMAND:
+ switch(wParam) {
+ case IDOK:
{
- case IDOK:
- {
- Data *data = (Data *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
-
- TCHAR find[256];
- if (data->findReadOnly)
- {
- lstrcpyn(find, data->find.c_str(), SIZEOF(find));
- }
- else
- {
- GetDlgItemText(hwndDlg, IDC_OLD, find, SIZEOF(find));
- lstrtrim(find);
- }
-
- TCHAR replace[256];
- GetDlgItemText(hwndDlg, IDC_NEW, replace, SIZEOF(replace));
- lstrtrim(replace);
-
- if (!data->findReadOnly && find[0] == 0)
- {
- MessageBox(hwndDlg, TranslateT("The wrong word can't be empty!"), TranslateT("Wrong Correction"),
- MB_OK | MB_ICONERROR);
- }
- else if (replace[0] == 0)
- {
- MessageBox(hwndDlg, TranslateT("The correction can't be empty!"), TranslateT("Wrong Correction"),
- MB_OK | MB_ICONERROR);
- }
- else if (_tcscmp(find, replace) == 0)
- {
- MessageBox(hwndDlg, TranslateT("The correction can't be equal to the wrong word!"), TranslateT("Wrong Correction"),
- MB_OK | MB_ICONERROR);
- }
- else
- {
- data->callback(FALSE, data->dict,
- find, replace, IsDlgButtonChecked(hwndDlg, IDC_VARIABLES),
- data->find.c_str(), data->param);
- Close(hwndDlg, 1);
- }
-
- break;
+ Data *data = (Data *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ TCHAR find[256];
+ if (data->findReadOnly)
+ lstrcpyn(find, data->find.c_str(), SIZEOF(find));
+ else {
+ GetDlgItemText(hwndDlg, IDC_OLD, find, SIZEOF(find));
+ lstrtrim(find);
}
- case IDCANCEL:
- {
- Close(hwndDlg, 0);
- break;
+
+ TCHAR replace[256];
+ GetDlgItemText(hwndDlg, IDC_NEW, replace, SIZEOF(replace));
+ lstrtrim(replace);
+
+ if (!data->findReadOnly && find[0] == 0) {
+ MessageBox(hwndDlg, TranslateT("The wrong word can't be empty!"), TranslateT("Wrong Correction"),
+ MB_OK | MB_ICONERROR);
+ }
+ else if (replace[0] == 0) {
+ MessageBox(hwndDlg, TranslateT("The correction can't be empty!"), TranslateT("Wrong Correction"),
+ MB_OK | MB_ICONERROR);
}
- case IDC_VARIABLES:
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_VAR_HELP), IsDlgButtonChecked(hwndDlg, IDC_VARIABLES));
- break;
+ else if (_tcscmp(find, replace) == 0) {
+ MessageBox(hwndDlg, TranslateT("The correction can't be equal to the wrong word!"), TranslateT("Wrong Correction"),
+ MB_OK | MB_ICONERROR);
}
- case IDC_VAR_HELP:
- {
- variables_showhelp(hwndDlg, IDC_NEW, VHF_FULLDLG, NULL, "The wrong word typed by the user");
- break;
+ else {
+ data->callback(FALSE, data->dict,
+ find, replace, IsDlgButtonChecked(hwndDlg, IDC_VARIABLES),
+ data->find.c_str(), data->param);
+ Close(hwndDlg, 1);
}
}
break;
- case WM_CLOSE:
- {
+ case IDCANCEL:
Close(hwndDlg, 0);
break;
+
+ case IDC_VARIABLES:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_VAR_HELP), IsDlgButtonChecked(hwndDlg, IDC_VARIABLES));
+ break;
+
+ case IDC_VAR_HELP:
+ variables_showhelp(hwndDlg, IDC_NEW, VHF_FULLDLG, NULL, "The wrong word typed by the user");
+ break;
}
+ break;
+
+ case WM_CLOSE:
+ Close(hwndDlg, 0);
+ break;
}
return FALSE;
diff --git a/plugins/SpellChecker/src/commons.h b/plugins/SpellChecker/src/commons.h index 834c2ad21e..41d9e6e2e8 100644 --- a/plugins/SpellChecker/src/commons.h +++ b/plugins/SpellChecker/src/commons.h @@ -64,7 +64,6 @@ using namespace std; #include "../utils/mir_memory.h"
#include "../utils/mir_options.h"
-#include "../utils/mir_icons.h"
#include "../utils/tstring.h"
#include "../utils/utf8_helpers.h"
#include "../utils/scope.h"
@@ -137,8 +136,6 @@ struct Dialog vector<WrongWordPopupMenuData> *wrong_words;
};
-HICON IcoLib_LoadIcon(Dictionary *dict, BOOL copy = FALSE);
-
BOOL CenterParent(HWND hwnd);
BOOL CreatePath(const TCHAR *path);
TCHAR *lstrtrim(TCHAR *str);
diff --git a/plugins/SpellChecker/src/dictionary.h b/plugins/SpellChecker/src/dictionary.h index b57aa730bd..3add2d739c 100644 --- a/plugins/SpellChecker/src/dictionary.h +++ b/plugins/SpellChecker/src/dictionary.h @@ -38,6 +38,7 @@ public: TCHAR full_name[256];
TCHAR source[128];
AutoReplaceMap *autoReplace;
+ HANDLE hIcolib;
virtual ~Dictionary() {}
diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp index 09157e2cb3..7b462e072e 100644 --- a/plugins/SpellChecker/src/options.cpp +++ b/plugins/SpellChecker/src/options.cpp @@ -163,9 +163,8 @@ static void DrawItem(HWND hwndDlg, LPDRAWITEMSTRUCT lpdis, Dictionary *dict) rc.left = lpdis->rcItem.left + 2;
// Draw icon
- if (opts.use_flags)
- {
- HICON hFlag = IcoLib_LoadIcon(dict);
+ if (opts.use_flags) {
+ HICON hFlag = Skin_GetIcon( _T2A(dict->language));
rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - ICON_SIZE) / 2;
DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, NULL, DI_NORMAL);
diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp index 25980828c0..e428349c3e 100644 --- a/plugins/SpellChecker/src/spellchecker.cpp +++ b/plugins/SpellChecker/src/spellchecker.cpp @@ -33,21 +33,8 @@ PLUGININFOEX pluginInfo={ __COPYRIGHT, __AUTHORWEB, UNICODE_AWARE, - { 0x36753ae3, 0x840b, 0x4797, { 0x94, 0xa5, 0xfd, 0x9f, 0x58, 0x52, 0xb9, 0x42 } } // {36753AE3-840B-4797-94A5-FD9F5852B942} -}; - -typedef struct -{ - TCHAR* szDescr; - char* szName; - int defIconID; -} IconStruct; - -static IconStruct iconList[] = -{ - { LPGENT("Enabled"), "spellchecker_enabled", IDI_CHECK }, - { LPGENT("Disabled"), "spellchecker_disabled", IDI_NO_CHECK }, -// { LPGENT("Unknown Flag"), "spellchecker_unknown_flag", IDI_UNKNOWN_FLAG }, + // {36753AE3-840B-4797-94A5-FD9F5852B942} + { 0x36753ae3, 0x840b, 0x4797, { 0x94, 0xa5, 0xfd, 0x9f, 0x58, 0x52, 0xb9, 0x42 } } }; #define TIMER_ID 17982 @@ -60,9 +47,6 @@ HINSTANCE hInst; int hLangpack = 0; -HANDLE hHooks[6]; -HANDLE hServices[3]; - HANDLE hDictionariesFolder = NULL; TCHAR *dictionariesFolder; @@ -122,17 +106,6 @@ DEFINE_GUIDXXX(IID_ITextDocument,0x8CC497C0,0xA1DF,0x11CE,0x80,0x98, // Functions //////////////////////////////////////////////////////////////////////////// - -HICON IcoLib_LoadIcon(Dictionary *dict, BOOL copy) -{ - - char lang[32]; - WideCharToMultiByte(CP_ACP, 0, dict->language, -1, lang, sizeof(lang), NULL, NULL); - return IcoLib_LoadIcon(lang, copy); - -} - - extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { hInst = hinstDLL; @@ -146,14 +119,44 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SPELLCHECKER, MIID_LAST }; -extern "C" int __declspec(dllexport) Load(void) +/////////////////////////////////////////////////////////////////////////////////////// + +struct +{ + char* szDescr; + char* szName; + int defIconID; + HANDLE hIcolib; +} +static iconList[] = { + { LPGEN("Enabled"), "spellchecker_enabled", IDI_CHECK }, + { LPGEN("Disabled"), "spellchecker_disabled", IDI_NO_CHECK } +}; +extern "C" int __declspec(dllexport) Load(void) +{ mir_getLP(&pluginInfo); + // icons + TCHAR path[MAX_PATH]; + GetModuleFileName(hInst, path, MAX_PATH); + + SKINICONDESC sid = { sizeof(sid) }; + sid.flags = SIDF_PATH_TCHAR; + sid.pszSection = LPGEN("Spell Checker"); + sid.ptszDefaultFile = path; + + for (int i = 0; i < SIZEOF(iconList); ++i) { + sid.pszDescription = iconList[i].szDescr; + sid.pszName = iconList[i].szName; + sid.iDefaultIndex = -iconList[i].defIconID; + iconList[i].hIcolib = Skin_AddIcon(&sid); + } + // hooks - hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); - hHooks[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); + HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); hCheckedBmp = LoadBitmap(NULL, MAKEINTRESOURCE(OBM_CHECK)); if (GetObject(hCheckedBmp, sizeof(bmpChecked), &bmpChecked) == 0) @@ -179,8 +182,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0); // Folders plugin support - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { + if ( ServiceExists(MS_FOLDERS_REGISTER_PATH)) { hDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Dictionaries"), DICTIONARIES_FOLDER); dictionariesFolder = (TCHAR *) mir_alloc(sizeof(TCHAR) * MAX_PATH); @@ -196,84 +198,59 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) flagsDllFolder = (TCHAR *) mir_alloc(sizeof(TCHAR) * MAX_PATH); FoldersGetCustomPathT(hFlagsDllFolder, flagsDllFolder, MAX_PATH, _T(".")); } - else - { + else { dictionariesFolder = Utils_ReplaceVarsT(DICTIONARIES_FOLDER); customDictionariesFolder = Utils_ReplaceVarsT(CUSTOM_DICTIONARIES_FOLDER); flagsDllFolder = Utils_ReplaceVarsT(FLAGS_DLL_FOLDER); } - TCHAR path[MAX_PATH]; - GetModuleFileName(hInst, path, MAX_PATH); - - SKINICONDESC sid = {0}; - sid.cbSize = sizeof(SKINICONDESC); - sid.flags = SIDF_ALL_TCHAR; - sid.ptszSection = LPGENT("Spell Checker"); - sid.ptszDefaultFile = path; - - for (unsigned i = 0; i < SIZEOF(iconList); ++i) - { - sid.ptszDescription = iconList[i].szDescr; - sid.pszName = iconList[i].szName; - sid.iDefaultIndex = -iconList[i].defIconID; - Skin_AddIcon(&sid); - } - InitOptions(); GetAvaibleDictionaries(languages, dictionariesFolder, customDictionariesFolder); LoadOptions(); - if (opts.use_flags) - { + if (opts.use_flags) { // Load flags dll - TCHAR flag_file[1024]; + TCHAR flag_file[MAX_PATH]; mir_sntprintf(flag_file, SIZEOF(flag_file), _T("%s\\flags_icons.dll"), flagsDllFolder); HMODULE hFlagsDll = LoadLibraryEx(flag_file, NULL, LOAD_LIBRARY_AS_DATAFILE); + TCHAR path[MAX_PATH]; + GetModuleFileName(hInst, path, MAX_PATH); + + SKINICONDESC sid = { sizeof(sid) }; sid.flags = SIDF_ALL_TCHAR | SIDF_SORTED; - sid.ptszSection = _T("Languages/Flags"); + sid.ptszSection = _T("Spellchecker/Flags"); // Get language flags - for(int i = 0; i < languages.getCount(); i++) - { - sid.ptszDescription = languages[i]->full_name; + for(int i = 0; i < languages.getCount(); i++) { + Dictionary *p = languages[i]; + sid.ptszDescription = p->full_name; char lang[32]; - mir_snprintf(lang, SIZEOF(lang), "%S", languages[i]->language); + mir_snprintf(lang, SIZEOF(lang), "spell_lang_%d", i); sid.pszName = lang; - - HICON hFlag = IcoLib_LoadIcon(sid.pszName); - if (hFlag != NULL) - { - // Already registered - Skin_ReleaseIcon(hFlag); - continue; - } - + HICON hFlag; if (hFlagsDll != NULL) - hFlag = (HICON) LoadImage(hFlagsDll, languages[i]->language, IMAGE_ICON, 16, 16, 0); + hFlag = (HICON)LoadImage(hFlagsDll, p->language, IMAGE_ICON, 16, 16, 0); else hFlag = NULL; - if (hFlag != NULL) - { + if (hFlag != NULL) { sid.hDefaultIcon = hFlag; sid.ptszDefaultFile = NULL; sid.iDefaultIndex = 0; } - else - { + else { sid.hDefaultIcon = NULL; sid.ptszDefaultFile = path; sid.iDefaultIndex = - IDI_UNKNOWN_FLAG; } // Oki, lets add to IcoLib, then - Skin_AddIcon(&sid); + p->hIcolib = Skin_AddIcon(&sid); if (hFlag != NULL) DestroyIcon(hFlag); @@ -281,8 +258,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) FreeLibrary(hFlagsDll); } - for (int j = 0; j < languages.getCount(); j++) - { + for (int j = 0; j < languages.getCount(); j++) { Dictionary *dict = languages[j]; TCHAR filename[MAX_PATH]; @@ -293,25 +269,22 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) dict->load(); } - hHooks[2] = HookEvent(ME_SKIN2_ICONSCHANGED, &IconsChanged); - hHooks[3] = HookEvent(ME_MSG_WINDOWEVENT, &MsgWindowEvent); - hHooks[4] = HookEvent(ME_MSG_WINDOWPOPUP, &MsgWindowPopup); - hHooks[5] = HookEvent(ME_MSG_ICONPRESSED, &IconPressed); + HookEvent(ME_SKIN2_ICONSCHANGED, &IconsChanged); + HookEvent(ME_MSG_WINDOWEVENT, &MsgWindowEvent); + HookEvent(ME_MSG_WINDOWPOPUP, &MsgWindowPopup); + HookEvent(ME_MSG_ICONPRESSED, &IconPressed); - hServices[0] = CreateServiceFunction(MS_SPELLCHECKER_ADD_RICHEDIT, AddContactTextBoxService); - hServices[1] = CreateServiceFunction(MS_SPELLCHECKER_REMOVE_RICHEDIT, RemoveContactTextBoxService); - hServices[2] = CreateServiceFunction(MS_SPELLCHECKER_SHOW_POPUP_MENU, ShowPopupMenuService); + CreateServiceFunction(MS_SPELLCHECKER_ADD_RICHEDIT, AddContactTextBoxService); + CreateServiceFunction(MS_SPELLCHECKER_REMOVE_RICHEDIT, RemoveContactTextBoxService); + CreateServiceFunction(MS_SPELLCHECKER_SHOW_POPUP_MENU, ShowPopupMenuService); - if (ServiceExists(MS_MSG_ADDICON)) - { - StatusIconData sid = {0}; - sid.cbSize = sizeof(sid); + if (ServiceExists(MS_MSG_ADDICON)) { + StatusIconData sid = { sizeof(sid) }; sid.szModule = MODULE_NAME; - sid.hIconDisabled = IcoLib_LoadIcon("spellchecker_disabled", TRUE); + sid.hIconDisabled = Skin_GetIcon("spellchecker_disabled"); sid.flags = MBF_HIDDEN; - for (int i = 0; i < languages.getCount(); i++) - { + for (int i = 0; i < languages.getCount(); i++) { sid.dwId = i; char tmp[128]; @@ -319,10 +292,9 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) Translate("Spell Checker"), languages[i]->full_name); sid.szTooltip = tmp; - if (opts.use_flags) - sid.hIcon = IcoLib_LoadIcon(languages[i], TRUE); - else - sid.hIcon = IcoLib_LoadIcon("spellchecker_enabled", TRUE); + HICON hIcon = (opts.use_flags) ? Skin_GetIconByHandle(languages[i]->hIcolib) : Skin_GetIcon("spellchecker_enabled"); + sid.hIcon = CopyIcon(hIcon); + Skin_ReleaseIcon(hIcon); CallService(MS_MSG_ADDICON, 0, (LPARAM) &sid); } @@ -345,17 +317,13 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) int IconsChanged(WPARAM wParam, LPARAM lParam) { - if (ServiceExists(MS_MSG_MODIFYICON)) - { - StatusIconData sid = {0}; - sid.cbSize = sizeof(sid); + if ( ServiceExists(MS_MSG_MODIFYICON)) { + StatusIconData sid = { sizeof(sid) }; sid.szModule = MODULE_NAME; - sid.hIconDisabled = IcoLib_LoadIcon("spellchecker_disabled", TRUE); + sid.hIconDisabled = Skin_GetIcon("spellchecker_disabled"); sid.flags = MBF_HIDDEN; - - for (int i = 0; i < languages.getCount(); i++) - { + for (int i = 0; i < languages.getCount(); i++) { sid.dwId = i; char tmp[128]; @@ -363,10 +331,9 @@ int IconsChanged(WPARAM wParam, LPARAM lParam) Translate("Spell Checker"), languages[i]->full_name); sid.szTooltip = tmp; - if (opts.use_flags) - sid.hIcon = IcoLib_LoadIcon(languages[i], TRUE); - else - sid.hIcon = IcoLib_LoadIcon("spellchecker_enabled", TRUE); + HICON hIcon = (opts.use_flags) ? Skin_GetIconByHandle(languages[i]->hIcolib) : Skin_GetIcon("spellchecker_enabled"); + sid.hIcon = CopyIcon(hIcon); + Skin_ReleaseIcon(hIcon); CallService(MS_MSG_MODIFYICON, 0, (LPARAM) &sid); } @@ -378,19 +345,10 @@ int IconsChanged(WPARAM wParam, LPARAM lParam) int PreShutdown(WPARAM wParam, LPARAM lParam) { - int i; - for(i = 0; i < SIZEOF(hServices); i++) - DestroyServiceFunction(hServices[i]); - - for(i = 0; i < SIZEOF(hHooks); i++) - UnhookEvent(hHooks[i]); - DeInitOptions(); - if (ServiceExists(MS_MSG_REMOVEICON)) - { - StatusIconData sid = {0}; - sid.cbSize = sizeof(sid); + if (ServiceExists(MS_MSG_REMOVEICON)) { + StatusIconData sid = { sizeof(sid) }; sid.szModule = MODULE_NAME; CallService(MS_MSG_REMOVEICON, 0, (LPARAM) &sid); } @@ -398,7 +356,6 @@ int PreShutdown(WPARAM wParam, LPARAM lParam) mir_free(dictionariesFolder); mir_free(customDictionariesFolder); mir_free(flagsDllFolder); - return 0; } @@ -1657,7 +1614,7 @@ void AddMenuForWord(Dialog *dlg, TCHAR *word, CHARRANGE &pos, HMENU hMenu, BOOL if (suggestions.count > 0) { InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); - for (int i = suggestions.count - 1; i >= 0; i--) + for (int i = suggestions.count-1; i >= 0; i--) InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION, base + AUTOREPLACE_MENU_ID_BASE + i, suggestions.words[i]); } @@ -2130,14 +2087,16 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) rc.left += bmpChecked.bmWidth + 2; // Draw icon - HICON hFlag = IcoLib_LoadIcon(dict); + if (dict->hIcolib) { + HICON hFlag = Skin_GetIconByHandle(dict->hIcolib); - rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - ICON_SIZE) / 2; - DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, NULL, DI_NORMAL); + rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - ICON_SIZE) / 2; + DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, NULL, DI_NORMAL); - Skin_ReleaseIcon(hFlag); + Skin_ReleaseIcon(hFlag); - rc.left += ICON_SIZE + 4; + rc.left += ICON_SIZE + 4; + } // Draw text RECT rc_text = { 0, 0, 0xFFFF, 0xFFFF }; diff --git a/plugins/Utils/mir_icons.cpp b/plugins/Utils/mir_icons.cpp deleted file mode 100644 index 9af9f2a3d2..0000000000 --- a/plugins/Utils/mir_icons.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/*
-Copyright (C) 2007-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include <Windows.h>
-
-#include "mir_icons.h"
-
-#include <newpluginapi.h>
-#include <m_system.h>
-#include <m_icolib.h>
-
-extern HINSTANCE hInst;
-
-HICON IcoLib_LoadIcon(const char *iconName, BOOL copy)
-{
- if (iconName == NULL || iconName[0] == 0)
- return NULL;
-
- HICON hIcon = Skin_GetIcon(iconName);
- if (copy && hIcon != NULL) {
- hIcon = CopyIcon(hIcon);
- Skin_ReleaseIcon(hIcon);
- }
- return hIcon;
-}
-
-void IcoLib_ReleaseIcon(const char *iconName)
-{
- Skin_ReleaseIcon(iconName);
-}
-
-void IcoLib_ReleaseIcon(HICON hIcon)
-{
- Skin_ReleaseIcon(hIcon);
-}
-
-HANDLE IcoLib_Register(char *name, char *section, char *description, int id)
-{
- HANDLE hIcon = Skin_GetIconHandle(name);
- if (hIcon != NULL)
- return hIcon;
-
- TCHAR tszFile[MAX_PATH];
- GetModuleFileName(hInst, tszFile, MAX_PATH);
-
- SKINICONDESC sid = {0};
- sid.cbSize = sizeof(SKINICONDESC);
- sid.flags = SIDF_PATH_TCHAR;
- sid.pszName = name;
- sid.pszSection = section;
- sid.pszDescription = description;
- sid.ptszDefaultFile = tszFile;
- sid.iDefaultIndex = -id;
- return Skin_AddIcon(&sid);
-}
diff --git a/plugins/Utils/mir_icons.h b/plugins/Utils/mir_icons.h deleted file mode 100644 index 397e53bc93..0000000000 --- a/plugins/Utils/mir_icons.h +++ /dev/null @@ -1,28 +0,0 @@ -/*
-Copyright (C) 2005-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __MIR_ICONS_H__
-# define __MIR_ICONS_H__
-
-HANDLE IcoLib_Register(char *name, char *section, char *description, int id);
-
-HICON IcoLib_LoadIcon(const char *iconName, BOOL copy = FALSE);
-
-#endif // __MIR_ICONS_H__
|