summaryrefslogtreecommitdiff
path: root/src/modules/skin
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-13 16:55:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-13 16:55:17 +0000
commitcbe3cb21f5bca61a03bbd4ae811ee906e09b3f4f (patch)
tree4854fb66f4d59940efa3c1590237915851074dbf /src/modules/skin
parent351bcbec48ed77af5f8efcc4d5198707922c5d86 (diff)
- miranda32.exe now does nothing bug extends PATH to %miranda_root%\libs and loads mir_app.dll;
- everything that was in miranda32.exe (including resources) moved to mir_app.dll; - exports from mir_app.dll now available for using directly, without perversions; - src/stdplug.h deleted; git-svn-id: http://svn.miranda-ng.org/main/trunk@14143 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/skin')
-rw-r--r--src/modules/skin/hotkey_opts.cpp1048
-rw-r--r--src/modules/skin/hotkeys.cpp412
-rw-r--r--src/modules/skin/skin.h75
-rw-r--r--src/modules/skin/skinicons.cpp505
-rw-r--r--src/modules/skin/sounds.cpp470
5 files changed, 0 insertions, 2510 deletions
diff --git a/src/modules/skin/hotkey_opts.cpp b/src/modules/skin/hotkey_opts.cpp
deleted file mode 100644
index c385293210..0000000000
--- a/src/modules/skin/hotkey_opts.cpp
+++ /dev/null
@@ -1,1048 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-12 Miranda IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program 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 General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "..\..\core\commonheaders.h"
-
-#include <m_hotkeys.h>
-#include "skin.h"
-
-static TCHAR* sttHokeyVkToName(WORD vkKey)
-{
- static TCHAR buf[256] = { 0 };
- DWORD code = MapVirtualKey(vkKey, 0) << 16;
-
- switch (vkKey) {
- case 0:
- case VK_CONTROL:
- case VK_SHIFT:
- case VK_MENU:
- case VK_LWIN:
- case VK_RWIN:
- case VK_PAUSE:
- case VK_CANCEL:
- case VK_NUMLOCK:
- case VK_CAPITAL:
- case VK_SCROLL:
- return _T("");
- case VK_BROWSER_BACK:
- return TranslateT("Browser: Back");
- case VK_BROWSER_FORWARD:
- return TranslateT("Browser: Forward");
- case VK_BROWSER_REFRESH:
- return TranslateT("Browser: Refresh");
- case VK_BROWSER_STOP:
- return TranslateT("Browser: Stop");
- case VK_BROWSER_SEARCH:
- return TranslateT("Browser: Search");
- case VK_BROWSER_FAVORITES:
- return TranslateT("Browser: Fav");
- case VK_BROWSER_HOME:
- return TranslateT("Browser: Home");
- case VK_VOLUME_MUTE:
- return TranslateT("Mute");
- case VK_VOLUME_DOWN:
- return TranslateT("Vol-");
- case VK_VOLUME_UP:
- return TranslateT("Vol+");
- case VK_MEDIA_NEXT_TRACK:
- return TranslateT("Media: Next Track");
- case VK_MEDIA_PREV_TRACK:
- return TranslateT("Media: Prev. Track");
- case VK_MEDIA_STOP:
- return TranslateT("Media: Stop");
- case VK_MEDIA_PLAY_PAUSE:
- return TranslateT("Media: Play/Pause");
- case VK_LAUNCH_MAIL:
- return TranslateT("Mail");
- case VK_LAUNCH_MEDIA_SELECT:
- return TranslateT("Media: Select");
- case VK_LAUNCH_APP1:
- return TranslateT("App 1");
- case VK_LAUNCH_APP2:
- return TranslateT("App 2");
-
- case VK_DIVIDE:
- case VK_INSERT:
- case VK_HOME:
- case VK_PRIOR:
- case VK_DELETE:
- case VK_END:
- case VK_NEXT:
- case VK_LEFT:
- case VK_RIGHT:
- case VK_UP:
- case VK_DOWN:
- code |= (1UL << 24);
- }
-
- GetKeyNameText(code, buf, 256);
- return buf;
-}
-
-void HotkeyToName(TCHAR *buf, int size, BYTE shift, BYTE key)
-{
- mir_sntprintf(buf, size, _T("%s%s%s%s%s"),
- (shift & HOTKEYF_CONTROL) ? TranslateT("Ctrl + ") : _T(""),
- (shift & HOTKEYF_ALT) ? TranslateT("Alt + ") : _T(""),
- (shift & HOTKEYF_SHIFT) ? TranslateT("Shift + ") : _T(""),
- (shift & HOTKEYF_EXT) ? TranslateT("Win + ") : _T(""),
- sttHokeyVkToName(key));
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Hotkey control
-
-static LRESULT CALLBACK sttHotkeyEditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- THotkeyBoxData *data = (THotkeyBoxData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- BOOL bKeyDown = FALSE;
- if (!data) return 0;
-
- switch (msg) {
- case HKM_GETHOTKEY:
- return data->key ? MAKEWORD(data->key, data->shift) : 0;
-
- case HKM_SETHOTKEY:
- {
- TCHAR buf[256] = { 0 };
- data->key = (BYTE)LOWORD(wParam);
- data->shift = (BYTE)HIWORD(wParam);
- HotkeyToName(buf, SIZEOF(buf), data->shift, data->key);
- SetWindowText(hwnd, buf);
- }
- return 0;
-
- case WM_GETDLGCODE:
- return DLGC_WANTALLKEYS;
-
- case WM_KILLFOCUS:
- break;
-
- case WM_CHAR:
- case WM_SYSCHAR:
- case WM_PASTE:
- case WM_CONTEXTMENU:
- return TRUE;
-
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- bKeyDown = TRUE;
-
- case WM_KEYUP:
- case WM_SYSKEYUP:
- {
- TCHAR buf[256] = { 0 };
-
- BYTE shift = 0;
- BYTE key = wParam;
- TCHAR *name = sttHokeyVkToName(key);
- if (!*name || !bKeyDown)
- key = 0;
-
- if (GetAsyncKeyState(VK_CONTROL)) shift |= HOTKEYF_CONTROL;
- if (GetAsyncKeyState(VK_MENU)) shift |= HOTKEYF_ALT;
- if (GetAsyncKeyState(VK_SHIFT)) shift |= HOTKEYF_SHIFT;
- if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) shift |= HOTKEYF_EXT;
-
- if (bKeyDown || !data->key) {
- data->shift = shift;
- data->key = key;
- }
-
- HotkeyToName(buf, SIZEOF(buf), data->shift, data->key);
- SetWindowText(hwnd, buf);
-
- if (bKeyDown && data->key)
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKELONG(GetWindowLongPtr(hwnd, GWL_ID), 0), (LPARAM)hwnd);
- }
- return TRUE;
-
- case WM_DESTROY:
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- mir_free(data);
- }
-
- return mir_callNextSubclass(hwnd, sttHotkeyEditProc, msg, wParam, lParam);
-}
-
-void HotkeyEditCreate(HWND hwnd)
-{
- THotkeyBoxData *data = (THotkeyBoxData *)mir_alloc(sizeof(THotkeyBoxData));
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (ULONG_PTR)data);
- mir_subclassWindow(hwnd, sttHotkeyEditProc);
-}
-
-void HotkeyEditDestroy(HWND hwnd)
-{
- THotkeyBoxData *data = (THotkeyBoxData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- mir_free(data);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Options
-
-enum { COL_NAME, COL_TYPE, COL_KEY, COL_RESET, COL_ADDREMOVE };
-
-static void sttOptionsSetupItem(HWND hwndList, int idx, THotkeyItem *item)
-{
- TCHAR buf[256];
- LVITEM lvi = { 0 };
- lvi.iItem = idx;
-
- if (!item->rootHotkey) {
- lvi.mask = LVIF_TEXT | LVIF_IMAGE;
- lvi.iSubItem = COL_NAME;
- lvi.pszText = item->getDescr();
- lvi.iImage = item->OptType;
- ListView_SetItem(hwndList, &lvi);
-
- ListView_SetCheckState(hwndList, lvi.iItem, item->Enabled);
- }
-
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = COL_KEY;
- HotkeyToName(buf, SIZEOF(buf), HIBYTE(item->OptHotkey), LOBYTE(item->OptHotkey));
- lvi.pszText = buf;
- ListView_SetItem(hwndList, &lvi);
-
- if (item->rootHotkey) {
- lvi.mask = LVIF_IMAGE;
- lvi.iSubItem = COL_TYPE;
- lvi.iImage = item->OptType;
- ListView_SetItem(hwndList, &lvi);
- }
-
- lvi.mask = LVIF_IMAGE;
- lvi.iSubItem = COL_RESET;
- lvi.iImage = (item->Hotkey != item->OptHotkey) ? 5 : -1;
- ListView_SetItem(hwndList, &lvi);
-
- lvi.mask = LVIF_IMAGE | LVIF_TEXT;
- lvi.iSubItem = COL_ADDREMOVE;
- if (item->rootHotkey) {
- lvi.iImage = 4;
- lvi.pszText = TranslateT("Remove shortcut");
- }
- else {
- lvi.iImage = 3;
- lvi.pszText = TranslateT("Add another shortcut");
- }
- ListView_SetItem(hwndList, &lvi);
-}
-
-static void sttOptionsDeleteHotkey(HWND hwndList, int idx, THotkeyItem *item)
-{
- item->OptDeleted = TRUE;
- ListView_DeleteItem(hwndList, idx);
- if (item->rootHotkey)
- item->rootHotkey->OptChanged = TRUE;
-}
-
-static int CALLBACK sttOptionsSortList(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
-{
- TCHAR title1[256] = { 0 }, title2[256] = { 0 };
- THotkeyItem *item1 = NULL, *item2 = NULL;
- LVITEM lvi = { 0 };
- int res;
-
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iItem = lParam1;
- lvi.pszText = title1;
- lvi.cchTextMax = SIZEOF(title1);
- if (ListView_GetItem((HWND)lParamSort, &lvi))
- item1 = (THotkeyItem *)lvi.lParam;
-
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iItem = lParam2;
- lvi.pszText = title2;
- lvi.cchTextMax = SIZEOF(title2);
- if (ListView_GetItem((HWND)lParamSort, &lvi))
- item2 = (THotkeyItem *)lvi.lParam;
-
- if (!item1 && !item2)
- return mir_tstrcmp(title1, title2);
-
- if (!item1 && item2) {
- if (res = mir_tstrcmp(title1, item2->getSection()))
- return res;
- return -1;
- }
-
- if (!item2 && item1) {
- if (res = mir_tstrcmp(item1->getSection(), title2))
- return res;
- return 1;
- }
- /* item1 != NULL && item2 != NULL */
-
- if (res = mir_tstrcmp(item1->getSection(), item2->getSection())) return res;
- if (res = mir_tstrcmp(item1->getDescr(), item2->getDescr())) return res;
- if (!item1->rootHotkey && item2->rootHotkey) return -1;
- if (item1->rootHotkey && !item2->rootHotkey) return 1;
- return 0;
-}
-
-static void sttOptionsAddHotkey(HWND hwndList, THotkeyItem *item)
-{
- char buf[256];
- mir_snprintf(buf, "mir_hotkey_%d_%d", g_pid, g_hkid++);
-
- THotkeyItem *newItem = (THotkeyItem *)mir_alloc(sizeof(THotkeyItem));
- newItem->pszName = NULL;
- newItem->pszService = item->pszService ? mir_strdup(item->pszService) : NULL;
- newItem->ptszSection = mir_tstrdup(item->ptszSection);
- newItem->ptszDescription = mir_tstrdup(item->ptszDescription);
- newItem->lParam = item->lParam;
- newItem->idHotkey = GlobalAddAtomA(buf);
- newItem->rootHotkey = item;
- newItem->Hotkey = newItem->DefHotkey = newItem->OptHotkey = 0;
- newItem->type = newItem->OptType = item->OptType;
- newItem->Enabled = newItem->OptEnabled = TRUE;
- newItem->OptChanged = newItem->OptDeleted = FALSE;
- newItem->OptNew = TRUE;
- hotkeys.insert(newItem);
-
- SendMessage(hwndList, WM_SETREDRAW, FALSE, 0);
-
- LVITEM lvi = { 0 };
- lvi.mask |= LVIF_PARAM;
- lvi.lParam = (LPARAM)newItem;
- sttOptionsSetupItem(hwndList, ListView_InsertItem(hwndList, &lvi), newItem);
- ListView_SortItemsEx(hwndList, sttOptionsSortList, (LPARAM)hwndList);
-
- SendMessage(hwndList, WM_SETREDRAW, TRUE, 0);
- RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE);
-
- item->OptChanged = TRUE;
-}
-
-static void sttOptionsSetChanged(THotkeyItem *item)
-{
- item->OptChanged = TRUE;
- if (item->rootHotkey)
- item->rootHotkey->OptChanged = TRUE;
-}
-
-static void sttOptionsSaveItem(THotkeyItem *item)
-{
- int i;
- char buf[MAXMODULELABELLENGTH];
-
- if (item->rootHotkey) return;
- if (!item->OptChanged) return;
-
- item->Hotkey = item->OptHotkey;
- item->type = item->OptType;
- item->Enabled = item->OptEnabled;
-
- db_set_w(NULL, DBMODULENAME, item->pszName, item->Hotkey);
- db_set_b(NULL, DBMODULENAME "Off", item->pszName, (BYTE)!item->Enabled);
- if (item->type != HKT_MANUAL)
- db_set_b(NULL, DBMODULENAME "Types", item->pszName, (BYTE)item->type);
-
- item->nSubHotkeys = 0;
- for (i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *subItem = hotkeys[i];
- if (subItem->rootHotkey == item) {
- subItem->Hotkey = subItem->OptHotkey;
- subItem->type = subItem->OptType;
-
- mir_snprintf(buf, "%s$%d", item->pszName, item->nSubHotkeys);
- db_set_w(NULL, DBMODULENAME, buf, subItem->Hotkey);
- if (subItem->type != HKT_MANUAL)
- db_set_b(NULL, DBMODULENAME "Types", buf, (BYTE)subItem->type);
-
- ++item->nSubHotkeys;
- }
- }
-
- mir_snprintf(buf, "%s$count", item->pszName);
- db_set_dw(NULL, DBMODULENAME, buf, item->nSubHotkeys);
-}
-
-static void sttBuildHotkeyList(HWND hwndList)
-{
- int i, nItems = 0;
- ListView_DeleteAllItems(hwndList);
-
- for (i = 0; i < hotkeys.getCount(); i++) {
- LVITEM lvi = { 0 };
- THotkeyItem *item = hotkeys[i];
-
- if (item->OptDeleted)
- continue;
-
- if (!i || mir_tstrcmp(item->ptszSection, hotkeys[i - 1]->ptszSection)) {
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iItem = nItems++;
- lvi.iSubItem = 0;
- lvi.lParam = 0;
- lvi.pszText = item->getSection();
- ListView_InsertItem(hwndList, &lvi);
- ListView_SetCheckState(hwndList, lvi.iItem, TRUE);
-
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = 1;
- lvi.pszText = item->ptszSection;
- ListView_SetItem(hwndList, &lvi);
-
- lvi.iSubItem = 0;
- }
-
- lvi.mask = LVIF_PARAM | LVIF_INDENT;
- lvi.iIndent = 1;
- lvi.iItem = nItems++;
- lvi.lParam = (LPARAM)item;
- ListView_InsertItem(hwndList, &lvi);
- sttOptionsSetupItem(hwndList, nItems - 1, item);
- }
-
- ListView_SortItemsEx(hwndList, sttOptionsSortList, (LPARAM)hwndList);
-}
-
-static void sttOptionsStartEdit(HWND hwndDlg, HWND hwndHotkey)
-{
- LVITEM lvi;
- THotkeyItem *item;
- int iItem = ListView_GetNextItem(hwndHotkey, -1, LVNI_SELECTED);
- if (iItem < 0) return;
-
- lvi.mask = LVIF_PARAM;
- lvi.iItem = iItem;
- ListView_GetItem(hwndHotkey, &lvi);
-
- if (item = (THotkeyItem *)lvi.lParam) {
- RECT rc;
- ListView_GetSubItemRect(hwndHotkey, iItem, COL_KEY, LVIR_BOUNDS, &rc);
- MapWindowPoints(hwndHotkey, hwndDlg, (LPPOINT)&rc, 2);
- SendDlgItemMessage(hwndDlg, IDC_HOTKEY, HKM_SETHOTKEY, MAKELONG(LOBYTE(item->OptHotkey), HIBYTE(item->OptHotkey)), 0);
-
- SetWindowPos(hwndHotkey, HWND_BOTTOM, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
- SetWindowPos(GetDlgItem(hwndDlg, IDC_HOTKEY), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
- RedrawWindow(GetDlgItem(hwndDlg, IDC_HOTKEY), NULL, NULL, RDW_INVALIDATE);
-
- SetFocus(GetDlgItem(hwndDlg, IDC_HOTKEY));
- RedrawWindow(GetDlgItem(hwndDlg, IDC_HOTKEY), NULL, NULL, RDW_INVALIDATE);
- }
-}
-
-static void sttOptionsDrawTextChunk(HDC hdc, TCHAR *text, RECT *rc)
-{
- DrawText(hdc, text, -1, rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
-
- SIZE sz;
- GetTextExtentPoint32(hdc, text, (int)mir_tstrlen(text), &sz);
- rc->left += sz.cx;
-}
-
-static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- static BOOL initialized = FALSE;
- static int colWidth = 0;
- static WORD currentLanguage = 0;
-
- HWND hwndHotkey = GetDlgItem(hwndDlg, IDC_LV_HOTKEYS);
-
- switch (msg) {
- case WM_INITDIALOG:
- initialized = FALSE;
-
- TranslateDialogDefault(hwndDlg);
-
- HotkeyEditCreate(GetDlgItem(hwndDlg, IDC_HOTKEY));
- {
- HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 3, 1);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOWS);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_MIRANDA);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOW);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ADDCONTACT);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_DELETE);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNDO);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPOPEN);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPSHUT);
- ListView_SetImageList(hwndHotkey, hIml, LVSIL_SMALL);
- }
- ListView_SetExtendedListViewStyle(hwndHotkey, LVS_EX_CHECKBOXES | LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP);
- {
- RECT rc;
- GetClientRect(hwndHotkey, &rc);
- colWidth = rc.right - GetSystemMetrics(SM_CXHTHUMB) - 3 * GetSystemMetrics(SM_CXSMICON) - 5;
-
- LVCOLUMN lvc;
- lvc.mask = LVCF_WIDTH;
- lvc.cx = colWidth * 2 / 3;
- ListView_InsertColumn(hwndHotkey, COL_NAME, &lvc);
- lvc.cx = GetSystemMetrics(SM_CXSMICON);
- ListView_InsertColumn(hwndHotkey, COL_TYPE, &lvc);
- lvc.cx = colWidth / 3;
- ListView_InsertColumn(hwndHotkey, COL_KEY, &lvc);
- lvc.cx = GetSystemMetrics(SM_CXSMICON);
- ListView_InsertColumn(hwndHotkey, COL_RESET, &lvc);
- lvc.cx = GetSystemMetrics(SM_CXSMICON);
- ListView_InsertColumn(hwndHotkey, COL_ADDREMOVE, &lvc);
-
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *item = hotkeys[i];
-
- item->OptChanged = FALSE;
- item->OptDeleted = item->OptNew = FALSE;
- item->OptEnabled = item->Enabled;
- item->OptHotkey = item->Hotkey;
- item->OptType = item->type;
- }
-
- currentLanguage = LOWORD(GetKeyboardLayout(0));
- sttBuildHotkeyList(hwndHotkey);
- }
- SetTimer(hwndDlg, 1024, 1000, NULL);
- initialized = TRUE;
- {
- /* load group states */
- int count = ListView_GetItemCount(hwndHotkey);
- TCHAR buf[128];
- LVITEM lvi = { 0 };
- lvi.pszText = buf;
- lvi.cchTextMax = SIZEOF(buf);
- for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) {
- char *szSetting;
-
- lvi.mask = LVIF_PARAM;
- lvi.iSubItem = 0;
- ListView_GetItem(hwndHotkey, &lvi);
- if (lvi.lParam) continue;
-
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = 1;
- ListView_GetItem(hwndHotkey, &lvi);
-
- szSetting = mir_t2a(lvi.pszText);
-
- ListView_SetCheckState(hwndHotkey, lvi.iItem,
- db_get_b(NULL, DBMODULENAME "UI", szSetting, TRUE));
-
- mir_free(szSetting);
- }
- }
-
- g_hwndHkOptions = hwndDlg;
- break;
-
- case WM_TIMER:
- if (initialized) {
- WORD newLanguage = LOWORD(GetKeyboardLayout(0));
- if (newLanguage == currentLanguage)
- break;
-
- int count = ListView_GetItemCount(hwndHotkey);
-
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) {
- ListView_GetItem(hwndHotkey, &lvi);
- if (lvi.lParam)
- sttOptionsSetupItem(hwndHotkey, lvi.iItem, (THotkeyItem *)lvi.lParam);
- }
- currentLanguage = newLanguage;
- }
- break;
-
- case WM_HOTKEYUNREGISTERED:
- {
- int count = ListView_GetItemCount(hwndHotkey);
-
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) {
- ListView_GetItem(hwndHotkey, &lvi);
- if (!lvi.lParam) continue;
-
- if (((THotkeyItem *)lvi.lParam)->UnregisterHotkey) {
- ListView_DeleteItem(hwndHotkey, lvi.iItem);
- --lvi.iItem;
- --count;
- }
- }
- }
- break;
-
- case WM_DRAWITEM:
- {
- LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
- RECT rc = lpdis->rcItem;
- int prefix = 65;
- int width = (lpdis->rcItem.right - lpdis->rcItem.left - prefix) / 3;
- rc.left += 5;
-
- HIMAGELIST hIml = ListView_GetImageList(hwndHotkey, LVSIL_SMALL);
- if (lpdis->CtlID == IDC_CANVAS2) {
- sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Scope:"), &rc);
-
- rc.left = prefix;
- ImageList_Draw(hIml, 0, lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, ILD_TRANSPARENT);
- rc.left += 20;
- sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("System"), &rc);
-
- rc.left = prefix + width;
- ImageList_Draw(hIml, 1, lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, ILD_TRANSPARENT);
- rc.left += 20;
- sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Miranda"), &rc);
-
- rc.left = prefix + width * 2;
- ImageList_Draw(hIml, 2, lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, ILD_TRANSPARENT);
- rc.left += 20;
- sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Window"), &rc);
- return TRUE;
- }
-
- if (lpdis->CtlID == IDC_CANVAS) {
- sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Actions:"), &rc);
-
- rc.left = prefix;
- ImageList_Draw(hIml, 5, lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, ILD_TRANSPARENT);
- rc.left += 20;
- sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Undo"), &rc);
-
- rc.left = prefix + width * 1;
- ImageList_Draw(hIml, 3, lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, ILD_TRANSPARENT);
- rc.left += 20;
- sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Add binding"), &rc);
-
- rc.left = prefix + width * 2;
- ImageList_Draw(hIml, 4, lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, ILD_TRANSPARENT);
- rc.left += 20;
- sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Remove"), &rc);
- return TRUE;
- }
- }
- break;
-
- case WM_COMMAND:
- if ((LOWORD(wParam) == IDC_HOTKEY) && ((HIWORD(wParam) == EN_KILLFOCUS) || (HIWORD(wParam) == 0))) {
- LVITEM lvi;
- THotkeyItem *item;
- WORD wHotkey = (WORD)SendDlgItemMessage(hwndDlg, IDC_HOTKEY, HKM_GETHOTKEY, 0, 0);
-
- ShowWindow(GetDlgItem(hwndDlg, IDC_HOTKEY), SW_HIDE);
- SetFocus(hwndHotkey);
- if (!wHotkey || (wHotkey == VK_ESCAPE) || (HIWORD(wParam) != 0))
- break;
-
- lvi.mask = LVIF_PARAM;
- lvi.iItem = ListView_GetNextItem(hwndHotkey, -1, LVNI_SELECTED);
- if (lvi.iItem >= 0) {
- ListView_GetItem(hwndHotkey, &lvi);
- if (item = (THotkeyItem *)lvi.lParam) {
- item->OptHotkey = wHotkey;
-
- sttOptionsSetupItem(hwndHotkey, lvi.iItem, item);
- sttOptionsSetChanged(item);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- }
- break;
-
- case WM_CONTEXTMENU:
- if (GetWindowLongPtr((HWND)wParam, GWL_ID) == IDC_LV_HOTKEYS) {
- HWND hwndList = (HWND)wParam;
- POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
- LVITEM lvi = { 0 };
- THotkeyItem *item = NULL;
-
- lvi.iItem = ListView_GetNextItem(hwndHotkey, -1, LVNI_SELECTED);
- if (lvi.iItem < 0) return FALSE;
-
- lvi.mask = LVIF_PARAM;
- ListView_GetItem(hwndList, &lvi);
- if (!(item = (THotkeyItem *)lvi.lParam)) return FALSE;
-
- if ((pt.x == -1) && (pt.y == -1)) {
- RECT rc;
- ListView_GetItemRect(hwndList, lvi.iItem, &rc, LVIR_LABEL);
- pt.x = rc.left;
- pt.y = rc.bottom;
- ClientToScreen(hwndList, &pt);
- }
-
- enum { MI_CANCEL, MI_CHANGE, MI_SYSTEM, MI_LOCAL, MI_ADD, MI_REMOVE, MI_REVERT };
-
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STATE;
- mii.fState = MFS_DEFAULT;
-
- HMENU hMenu = CreatePopupMenu();
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)MI_CHANGE, TranslateT("Modify"));
- SetMenuItemInfo(hMenu, (UINT_PTR)MI_CHANGE, FALSE, &mii);
- if (item->type != HKT_MANUAL) {
- AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
- AppendMenu(hMenu, MF_STRING |
- ((item->OptType == HKT_GLOBAL) ? MF_CHECKED : 0),
- (UINT_PTR)MI_SYSTEM, TranslateT("System scope"));
- AppendMenu(hMenu, MF_STRING |
- ((item->OptType == HKT_LOCAL) ? MF_CHECKED : 0),
- (UINT_PTR)MI_LOCAL, TranslateT("Miranda scope"));
- }
- AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
- if (!item->rootHotkey)
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)MI_ADD, TranslateT("Add binding"));
- else
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)MI_REMOVE, TranslateT("Remove"));
- if (item->Hotkey != item->OptHotkey) {
- AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)MI_REVERT, TranslateT("Undo"));
- }
-
- switch (TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) {
- case MI_CHANGE:
- sttOptionsStartEdit(hwndDlg, hwndHotkey);
- break;
- case MI_SYSTEM:
- item->OptType = HKT_GLOBAL;
- sttOptionsSetupItem(hwndList, lvi.iItem, item);
- sttOptionsSetChanged(item);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case MI_LOCAL:
- item->OptType = HKT_LOCAL;
- sttOptionsSetupItem(hwndList, lvi.iItem, item);
- sttOptionsSetChanged(item);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case MI_ADD:
- initialized = FALSE;
- sttOptionsAddHotkey(hwndList, item);
- initialized = FALSE;
- break;
- case MI_REMOVE:
- sttOptionsDeleteHotkey(hwndList, lvi.iItem, item);
- break;
- case MI_REVERT:
- item->OptHotkey = item->Hotkey;
- sttOptionsSetupItem(hwndList, lvi.iItem, item);
- break;
- }
- DestroyMenu(hMenu);
- break;
- }
- break;
-
- case WM_NOTIFY:
- {
- LPNMHDR lpnmhdr = (LPNMHDR)lParam;
- switch (lpnmhdr->idFrom) {
- case 0:
- {
- int i;
-
- if ((lpnmhdr->code != PSN_APPLY) && (lpnmhdr->code != PSN_RESET))
- break;
-
- UnregisterHotkeys();
-
- for (i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *item = hotkeys[i];
- if (item->OptNew && item->OptDeleted ||
- item->rootHotkey && !item->OptHotkey ||
- (lpnmhdr->code == PSN_APPLY) && item->OptDeleted ||
- (lpnmhdr->code == PSN_RESET) && item->OptNew) {
- FreeHotkey(item);
- hotkeys.remove(i--);
- }
- }
-
- if (lpnmhdr->code == PSN_APPLY) {
- LVITEM lvi = { 0 };
- int count = ListView_GetItemCount(hwndHotkey);
-
- for (i = 0; i < hotkeys.getCount(); i++)
- sttOptionsSaveItem(hotkeys[i]);
-
- lvi.mask = LVIF_IMAGE;
- lvi.iSubItem = COL_RESET;
- lvi.iImage = -1;
- for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem)
- ListView_SetItem(hwndHotkey, &lvi);
- }
-
- RegisterHotkeys();
-
- NotifyEventHooks(hEvChanged, 0, 0);
- }
- break;
-
- case IDC_LV_HOTKEYS:
- switch (lpnmhdr->code) {
- case NM_CLICK:
- {
- THotkeyItem *item = NULL;
- LPNMITEMACTIVATE lpnmia = (LPNMITEMACTIVATE)lParam;
- LVHITTESTINFO lvhti = { 0 };
- LVITEM lvi = { 0 };
-
- lvi.mask = LVIF_PARAM | LVIF_IMAGE;
- lvi.iItem = lpnmia->iItem;
- ListView_GetItem(lpnmia->hdr.hwndFrom, &lvi);
- item = (THotkeyItem *)lvi.lParam;
-
- lvhti.pt = lpnmia->ptAction;
- lvhti.iItem = lpnmia->iItem;
- lvhti.iSubItem = lpnmia->iSubItem;
- ListView_HitTest(lpnmia->hdr.hwndFrom, &lvhti);
-
- if (item &&
- (!item->rootHotkey && (lpnmia->iSubItem == COL_NAME) && ((lvhti.flags & LVHT_ONITEM) == LVHT_ONITEMICON) ||
- item->rootHotkey && (lpnmia->iSubItem == COL_TYPE)) &&
- ((item->OptType == HKT_GLOBAL) || (item->OptType == HKT_LOCAL))) {
- item->OptType = (item->OptType == HKT_GLOBAL) ? HKT_LOCAL : HKT_GLOBAL;
- sttOptionsSetupItem(lpnmia->hdr.hwndFrom, lpnmia->iItem, item);
- sttOptionsSetChanged(item);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- else if (item && (lpnmia->iSubItem == COL_RESET)) {
- item->OptHotkey = item->Hotkey;
- sttOptionsSetupItem(lpnmia->hdr.hwndFrom, lpnmia->iItem, item);
- }
- else if (item && (lpnmia->iSubItem == COL_ADDREMOVE)) {
- if (item->rootHotkey)
- sttOptionsDeleteHotkey(lpnmia->hdr.hwndFrom, lpnmia->iItem, item);
- else {
- initialized = FALSE;
- sttOptionsAddHotkey(lpnmia->hdr.hwndFrom, item);
- initialized = TRUE;
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- break;
-
- case LVN_KEYDOWN:
- {
- LPNMLVKEYDOWN param = (LPNMLVKEYDOWN)lParam;
- if (param->wVKey == VK_SUBTRACT || param->wVKey == VK_LEFT || param->wVKey == VK_ADD || param->wVKey == VK_RIGHT) {
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- lvi.iItem = ListView_GetNextItem(lpnmhdr->hwndFrom, -1, LVNI_SELECTED);
- if (lvi.iItem < 0)
- break;
-
- ListView_GetItem(lpnmhdr->hwndFrom, &lvi);
- if (lvi.lParam)
- break;
-
- if (param->wVKey == VK_ADD || param->wVKey == VK_RIGHT) {
- ListView_SetCheckState(lpnmhdr->hwndFrom, lvi.iItem, TRUE);
- }
- else {
- ListView_SetCheckState(lpnmhdr->hwndFrom, lvi.iItem, FALSE);
- }
- }
- else if (param->wVKey == VK_F2)
- sttOptionsStartEdit(hwndDlg, hwndHotkey);
- }
- break;
-
- case LVN_ITEMACTIVATE:
- {
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- lvi.iItem = ListView_GetNextItem(lpnmhdr->hwndFrom, -1, LVNI_SELECTED);
- if (lvi.iItem < 0) break;
- ListView_GetItem(lpnmhdr->hwndFrom, &lvi);
-
- if (lvi.lParam)
- sttOptionsStartEdit(hwndDlg, hwndHotkey);
- else
- ListView_SetCheckState(lpnmhdr->hwndFrom, lvi.iItem, !ListView_GetCheckState(lpnmhdr->hwndFrom, lvi.iItem));
- }
- break;
-
- case LVN_ITEMCHANGED:
- {
- LPNMLISTVIEW param = (LPNMLISTVIEW)lParam;
- THotkeyItem *item = (THotkeyItem *)param->lParam;
- if (!initialized || (param->uNewState >> 12 == param->uOldState >> 12))
- break;
-
- if (item && !item->rootHotkey) {
- item->OptEnabled = ListView_GetCheckState(lpnmhdr->hwndFrom, param->iItem) ? 1 : 0;
- sttOptionsSetChanged(item);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- else if (!item) {
- TCHAR buf[256];
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT;
- lvi.iItem = param->iItem;
- lvi.pszText = buf;
- lvi.cchTextMax = SIZEOF(buf);
- ListView_GetItem(lpnmhdr->hwndFrom, &lvi);
-
- if (param->uNewState >> 12 == 1) {
- int count = ListView_GetItemCount(lpnmhdr->hwndFrom);
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) {
- THotkeyItem *item;
- ListView_GetItem(lpnmhdr->hwndFrom, &lvi);
- item = (THotkeyItem *)lvi.lParam;
- if (!item) continue;
- if (!mir_tstrcmp(item->getSection(), buf)) {
- ListView_DeleteItem(lpnmhdr->hwndFrom, lvi.iItem);
- --lvi.iItem;
- --count;
- }
- }
- }
- else if (param->uNewState >> 12 == 2) {
- int i, nItems = ListView_GetItemCount(lpnmhdr->hwndFrom);
- initialized = FALSE;
- for (i = 0; i < hotkeys.getCount(); i++) {
- LVITEM lvi = { 0 };
- THotkeyItem *item = hotkeys[i];
-
- if (item->OptDeleted)
- continue;
- if (mir_tstrcmp(buf, item->getSection()))
- continue;
-
- lvi.mask = LVIF_PARAM | LVIF_INDENT;
- lvi.iIndent = 1;
- lvi.iItem = nItems++;
- lvi.lParam = (LPARAM)item;
- ListView_InsertItem(lpnmhdr->hwndFrom, &lvi);
- sttOptionsSetupItem(lpnmhdr->hwndFrom, nItems - 1, item);
- }
- ListView_SortItemsEx(lpnmhdr->hwndFrom, sttOptionsSortList, (LPARAM)lpnmhdr->hwndFrom);
- initialized = TRUE;
- }
- }
- break;
- }
- case NM_CUSTOMDRAW:
- {
- NMLVCUSTOMDRAW *param = (NMLVCUSTOMDRAW *)lParam;
- switch (param->nmcd.dwDrawStage) {
- case CDDS_PREPAINT:
- case CDDS_ITEMPREPAINT:
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
- return TRUE;
-
- case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
- {
- THotkeyItem *item;
- TCHAR buf[256];
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iItem = param->nmcd.dwItemSpec;
- lvi.pszText = buf;
- lvi.cchTextMax = SIZEOF(buf);
- ListView_GetItem(lpnmhdr->hwndFrom, &lvi);
-
- item = (THotkeyItem *)lvi.lParam;
- if (!item) {
- RECT rc;
- HFONT hfnt;
-
- ListView_GetSubItemRect(lpnmhdr->hwndFrom, param->nmcd.dwItemSpec, param->iSubItem, LVIR_BOUNDS, &rc);
- FillRect(param->nmcd.hdc, &rc, GetSysColorBrush(param->nmcd.uItemState&CDIS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW));
- SetTextColor(param->nmcd.hdc, GetSysColor(param->nmcd.uItemState&CDIS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
-
- if (param->iSubItem == 0) {
- rc.left += 3;
- HIMAGELIST hIml = ListView_GetImageList(hwndHotkey, LVSIL_SMALL);
- ImageList_Draw(hIml,
- ListView_GetCheckState(hwndHotkey, lvi.iItem) ? 6 : 7,
- param->nmcd.hdc, rc.left, (rc.top + rc.bottom - 16) / 2, ILD_TRANSPARENT);
- rc.left += 18;
- hfnt = (HFONT)SelectObject(param->nmcd.hdc, (HFONT)SendMessage(GetParent(hwndDlg), PSM_GETBOLDFONT, 0, 0));
- DrawText(param->nmcd.hdc, buf, -1, &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
- SelectObject(param->nmcd.hdc, hfnt);
- }
-
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- return TRUE;
- }
-
- if (item->rootHotkey && (param->iSubItem == 0)) {
- RECT rc;
- ListView_GetSubItemRect(lpnmhdr->hwndFrom, param->nmcd.dwItemSpec, param->iSubItem, LVIR_BOUNDS, &rc);
- FillRect(param->nmcd.hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- return TRUE;
- }
- break;
- }
- }
- break;
- }
- break;
- }
- }
- }
- break;
-
- case WM_DESTROY:
- {
- int count = ListView_GetItemCount(hwndHotkey);
-
- g_hwndHkOptions = NULL;
-
- KillTimer(hwndDlg, 1024);
-
- TCHAR buf[128];
- LVITEM lvi = { 0 };
- lvi.pszText = buf;
- lvi.cchTextMax = SIZEOF(buf);
- for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) {
- lvi.mask = LVIF_PARAM;
- lvi.iSubItem = 0;
- ListView_GetItem(hwndHotkey, &lvi);
- if (lvi.lParam) continue;
-
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = 1;
- ListView_GetItem(hwndHotkey, &lvi);
-
- db_set_b(NULL, DBMODULENAME "UI", _T2A(lvi.pszText), ListView_GetCheckState(hwndHotkey, lvi.iItem));
- }
- }
- }
-
- return FALSE;
-}
-
-int HotkeyOptionsInit(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
- odp.flags = ODPF_BOLDGROUPS;
- odp.position = -180000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_HOTKEYS);
- odp.pszTitle = LPGEN("Hotkeys");
- odp.pszGroup = LPGEN("Customize");
- odp.pfnDlgProc = sttOptionsDlgProc;
- Options_AddPage(wParam, &odp);
- return 0;
-}
diff --git a/src/modules/skin/hotkeys.cpp b/src/modules/skin/hotkeys.cpp
deleted file mode 100644
index f74f91f4b9..0000000000
--- a/src/modules/skin/hotkeys.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-12 Miranda IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program 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 General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "..\..\core\commonheaders.h"
-
-#include <m_hotkeys.h>
-#include "skin.h"
-
-static int sttCompareHotkeys(const THotkeyItem *p1, const THotkeyItem *p2)
-{
- int res;
- if (res = mir_tstrcmp(p1->ptszSection, p2->ptszSection))
- return res;
- if (res = mir_tstrcmp(p1->ptszDescription, p2->ptszDescription))
- return res;
- if (!p1->rootHotkey && p2->rootHotkey)
- return -1;
- if (p1->rootHotkey && !p2->rootHotkey)
- return 1;
- return 0;
-}
-
-LIST<THotkeyItem> hotkeys(10, sttCompareHotkeys);
-DWORD g_pid = 0, g_hkid = 1;
-HWND g_hwndHotkeyHost = NULL, g_hwndHkOptions = NULL;
-HANDLE hEvChanged = 0;
-
-static BOOL bModuleInitialized = FALSE;
-static HHOOK hhkKeyboard = NULL;
-
-WORD GetHotkeyValue(INT_PTR idHotkey)
-{
- for (int i = 0; i < hotkeys.getCount(); i++)
- if (hotkeys[i]->idHotkey == idHotkey)
- return hotkeys[i]->Enabled ? hotkeys[i]->Hotkey : 0;
-
- return 0;
-}
-
-static void sttWordToModAndVk(WORD w, BYTE *mod, BYTE *vk)
-{
- *mod = 0;
- if (HIBYTE(w) & HOTKEYF_CONTROL) *mod |= MOD_CONTROL;
- if (HIBYTE(w) & HOTKEYF_SHIFT) *mod |= MOD_SHIFT;
- if (HIBYTE(w) & HOTKEYF_ALT) *mod |= MOD_ALT;
- if (HIBYTE(w) & HOTKEYF_EXT) *mod |= MOD_WIN;
- *vk = LOBYTE(w);
-}
-
-static LRESULT CALLBACK sttHotkeyHostWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (msg == WM_HOTKEY) {
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *item = hotkeys[i];
- if (item->type != HKT_GLOBAL || !item->Enabled)
- continue;
-
- if (item->pszService && (wParam == item->idHotkey)) {
- CallService(item->pszService, 0, item->lParam);
- break;
- }
- }
-
- return FALSE;
- }
-
- return DefWindowProc(hwnd, msg, wParam, lParam);
-}
-
-static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam)
-{
- if (code == HC_ACTION && !(HIWORD(lParam) & KF_UP)) {
- BYTE mod = 0, vk = wParam;
-
- if (vk) {
- if (GetAsyncKeyState(VK_CONTROL)) mod |= MOD_CONTROL;
- if (GetAsyncKeyState(VK_MENU)) mod |= MOD_ALT;
- if (GetAsyncKeyState(VK_SHIFT)) mod |= MOD_SHIFT;
- if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN;
-
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *item = hotkeys[i];
- if (item->type != HKT_LOCAL || !item->Enabled)
- continue;
-
- BYTE hkMod, hkVk;
- sttWordToModAndVk(item->Hotkey, &hkMod, &hkVk);
- if (!hkVk) continue;
- if (item->pszService && vk == hkVk && mod == hkMod) {
- CallService(item->pszService, 0, item->lParam);
- return TRUE;
- }
- }
- }
- }
-
- return CallNextHookEx(hhkKeyboard, code, wParam, lParam);
-}
-
-static INT_PTR svcHotkeySubclass(WPARAM wParam, LPARAM)
-{
- HotkeyEditCreate((HWND)wParam);
- return 0;
-}
-
-static INT_PTR svcHotkeyUnsubclass(WPARAM wParam, LPARAM)
-{
- HotkeyEditDestroy((HWND)wParam);
- return 0;
-}
-
-static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam)
-{
- HOTKEYDESC *desc = (HOTKEYDESC *)lParam;
- if (desc->cbSize != sizeof(HOTKEYDESC))
- return 0;
-
- THotkeyItem *item = (THotkeyItem*)mir_alloc(sizeof(THotkeyItem));
- DWORD dwFlags = (desc->cbSize >= sizeof(HOTKEYDESC)) ? desc->dwFlags : 0;
- if (dwFlags & HKD_UNICODE) {
- item->ptszSection = mir_tstrdup(desc->ptszSection);
- item->ptszDescription = mir_tstrdup(desc->ptszDescription);
- }
- else {
- item->ptszSection = mir_a2u(desc->pszSection);
- item->ptszDescription = mir_a2u(desc->pszDescription);
- }
-
- item->hLangpack = (int)wParam;
- item->allowSubHotkeys = TRUE;
- item->rootHotkey = NULL;
- item->nSubHotkeys = 0;
-
- if (item->rootHotkey = hotkeys.find(item)) {
- if (item->rootHotkey->allowSubHotkeys) {
- char nameBuf[MAXMODULELABELLENGTH];
- mir_snprintf(nameBuf, SIZEOF(nameBuf), "%s$%d", item->rootHotkey->pszName, item->rootHotkey->nSubHotkeys);
- item->pszName = mir_strdup(nameBuf);
- item->Enabled = TRUE;
-
- item->rootHotkey->nSubHotkeys++;
- }
- else {
- mir_free(item->ptszSection);
- mir_free(item->ptszDescription);
- mir_free(item);
- return 0;
- }
- }
- else {
- item->pszName = mir_strdup(desc->pszName);
- item->Enabled = !db_get_b(NULL, DBMODULENAME "Off", item->pszName, 0);
- }
-
- item->pszService = desc->pszService ? mir_strdup(desc->pszService) : 0;
- item->DefHotkey = desc->DefHotKey & ~HKF_MIRANDA_LOCAL;
- item->Hotkey = db_get_w(NULL, DBMODULENAME, item->pszName, item->DefHotkey);
- item->type = item->pszService ?
- (THotkeyType)db_get_b(NULL, DBMODULENAME "Types", item->pszName,
- (desc->DefHotKey & HKF_MIRANDA_LOCAL) ? HKT_LOCAL : HKT_GLOBAL) : HKT_MANUAL;
- item->lParam = desc->lParam;
-
- char buf[256];
- mir_snprintf(buf, "mir_hotkey_%d_%d", g_pid, g_hkid++);
- item->idHotkey = GlobalAddAtomA(buf);
- if (item->type == HKT_GLOBAL) {
- if (item->Enabled) {
- BYTE mod, vk;
- sttWordToModAndVk(item->Hotkey, &mod, &vk);
- if (vk) RegisterHotKey(g_hwndHotkeyHost, item->idHotkey, mod, vk);
- }
- }
-
- hotkeys.insert(item);
-
- if (!item->rootHotkey) {
- /* try to load alternatives from db */
- int count, i;
- mir_snprintf(buf, "%s$count", item->pszName);
- count = (int)db_get_dw(NULL, DBMODULENAME, buf, -1);
- for (i = 0; i < count; i++) {
- mir_snprintf(buf, "%s$%d", item->pszName, i);
- if (!db_get_w(NULL, DBMODULENAME, buf, 0))
- continue;
-
- svcHotkeyRegister(wParam, lParam);
- }
- item->allowSubHotkeys = count < 0;
- }
- else {
- mir_free(item->pszName);
- item->pszName = NULL;
- }
-
- return item->idHotkey;
-}
-
-static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam)
-{
- int i;
- char *pszName = (char *)lParam;
- char pszNamePrefix[MAXMODULELABELLENGTH];
- size_t cbNamePrefix;
- mir_snprintf(pszNamePrefix, SIZEOF(pszNamePrefix), "%s$", pszName);
- cbNamePrefix = mir_strlen(pszNamePrefix);
-
- for (i = 0; i < hotkeys.getCount(); i++) {
- char *pszCurrentName = hotkeys[i]->rootHotkey ?
- hotkeys[i]->rootHotkey->pszName :
- hotkeys[i]->pszName;
- if (!pszCurrentName) continue;
-
- hotkeys[i]->UnregisterHotkey =
- !mir_strcmp(pszCurrentName, pszName) ||
- !strncmp(pszCurrentName, pszNamePrefix, cbNamePrefix);
- }
-
- if (g_hwndHkOptions)
- SendMessage(g_hwndHkOptions, WM_HOTKEYUNREGISTERED, 0, 0);
-
- for (i = 0; i < hotkeys.getCount(); i++)
- if (hotkeys[i]->UnregisterHotkey) {
- FreeHotkey(hotkeys[i]);
- List_Remove((SortedList *)&hotkeys, i);
- --i;
- }
-
- return 0;
-}
-
-static INT_PTR svcHotkeyCheck(WPARAM wParam, LPARAM lParam)
-{
- MSG *msg = (MSG *)wParam;
- TCHAR *pszSection = mir_a2t((char *)lParam);
-
- if ((msg->message == WM_KEYDOWN) || (msg->message == WM_SYSKEYDOWN)) {
- int i;
- BYTE mod = 0, vk = msg->wParam;
-
- if (vk) {
- if (GetAsyncKeyState(VK_CONTROL)) mod |= MOD_CONTROL;
- if (GetAsyncKeyState(VK_MENU)) mod |= MOD_ALT;
- if (GetAsyncKeyState(VK_SHIFT)) mod |= MOD_SHIFT;
- if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN;
-
- for (i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *item = hotkeys[i];
- BYTE hkMod, hkVk;
- if ((item->type != HKT_MANUAL) || mir_tstrcmp(pszSection, item->ptszSection)) continue;
- sttWordToModAndVk(item->Hotkey, &hkMod, &hkVk);
- if (!hkVk) continue;
- if (!item->Enabled) continue;
- if ((vk == hkVk) && (mod == hkMod)) {
- mir_free(pszSection);
- return item->lParam;
- }
- }
- }
- }
-
- mir_free(pszSection);
- return 0;
-}
-
-void FreeHotkey(THotkeyItem *item)
-{
- if (item->type == HKT_GLOBAL && item->Enabled)
- UnregisterHotKey(g_hwndHotkeyHost, item->idHotkey);
- GlobalDeleteAtom(item->idHotkey);
- mir_free(item->pszName);
- mir_free(item->pszService);
- mir_free(item->ptszDescription);
- mir_free(item->ptszSection);
- mir_free(item);
-}
-
-void RegisterHotkeys()
-{
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *item = hotkeys[i];
- UnregisterHotKey(g_hwndHotkeyHost, item->idHotkey);
- if (item->type != HKT_GLOBAL) continue;
- if (item->Enabled) {
- BYTE mod, vk;
- sttWordToModAndVk(item->Hotkey, &mod, &vk);
- if (vk) RegisterHotKey(g_hwndHotkeyHost, item->idHotkey, mod, vk);
- }
- }
-}
-
-void KillModuleHotkeys(int hLangpack)
-{
- for (int i = hotkeys.getCount() - 1; i >= 0; i--) {
- THotkeyItem *item = hotkeys[i];
- if (item->hLangpack == hLangpack) {
- FreeHotkey(item);
- hotkeys.remove(i);
- }
- }
-}
-
-void UnregisterHotkeys()
-{
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *item = hotkeys[i];
- if (item->type == HKT_GLOBAL && item->Enabled)
- UnregisterHotKey(g_hwndHotkeyHost, item->idHotkey);
- }
-}
-
-static int sttModulesLoaded(WPARAM, LPARAM)
-{
- HookEvent(ME_OPT_INITIALISE, HotkeyOptionsInit);
- return 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Hotkey manager
-
-static const char* oldSettings[] = { "ShowHide", "ReadMsg", "NetSearch", "ShowOptions" };
-static const char* newSettings[] = { "ShowHide", "ReadMessage", "SearchInWeb", "ShowOptions" };
-
-int LoadSkinHotkeys(void)
-{
- WNDCLASSEX wcl = { 0 };
-
- bModuleInitialized = TRUE;
-
- wcl.cbSize = sizeof(wcl);
- wcl.lpfnWndProc = sttHotkeyHostWndProc;
- wcl.style = 0;
- wcl.cbClsExtra = 0;
- wcl.cbWndExtra = 0;
- wcl.hInstance = hInst;
- wcl.hIcon = NULL;
- wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
- wcl.lpszMenuName = NULL;
- wcl.lpszClassName = _T("MirandaHotkeyHostWnd");
- wcl.hIconSm = NULL;
- RegisterClassEx(&wcl);
-
- g_pid = GetCurrentProcessId();
-
- g_hwndHotkeyHost = CreateWindow(_T("MirandaHotkeyHostWnd"), NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hInst, NULL);
- SetWindowPos(g_hwndHotkeyHost, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_HIDEWINDOW);
-
- hhkKeyboard = SetWindowsHookEx(WH_KEYBOARD, sttKeyboardProc, NULL, hMainThreadId);
-
- hEvChanged = CreateHookableEvent(ME_HOTKEYS_CHANGED);
-
- CreateServiceFunction("CoreHotkeys/Register", svcHotkeyRegister);
- CreateServiceFunction(MS_HOTKEY_UNREGISTER, svcHotkeyUnregister);
- CreateServiceFunction(MS_HOTKEY_SUBCLASS, svcHotkeySubclass);
- CreateServiceFunction(MS_HOTKEY_UNSUBCLASS, svcHotkeyUnsubclass);
- CreateServiceFunction(MS_HOTKEY_CHECK, svcHotkeyCheck);
-
- HookEvent(ME_SYSTEM_MODULESLOADED, sttModulesLoaded);
-
- for (int i = 0; i < SIZEOF(oldSettings); i++) {
- char szSetting[100];
- mir_snprintf(szSetting, "HK%s", oldSettings[i]);
-
- WORD key;
- if ((key = db_get_w(NULL, "Clist", szSetting, 0))) {
- db_unset(NULL, "Clist", szSetting);
- db_set_w(NULL, DBMODULENAME, newSettings[i], key);
- }
-
- mir_snprintf(szSetting, "HKEn%s", oldSettings[i]);
- if ((key = db_get_b(NULL, "Clist", szSetting, 0))) {
- db_unset(NULL, "Clist", szSetting);
- db_set_b(NULL, DBMODULENAME "Off", newSettings[i], (BYTE)(key == 0));
- }
- }
-
- return 0;
-}
-
-void UnloadSkinHotkeys(void)
-{
- if (!bModuleInitialized)
- return;
-
- DestroyHookableEvent(hEvChanged);
- UnhookWindowsHookEx(hhkKeyboard);
-
- for (int i = 0; i < hotkeys.getCount(); i++)
- FreeHotkey(hotkeys[i]);
-
- DestroyWindow(g_hwndHotkeyHost);
-}
diff --git a/src/modules/skin/skin.h b/src/modules/skin/skin.h
deleted file mode 100644
index d0e6eae726..0000000000
--- a/src/modules/skin/skin.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-12 Miranda IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program 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 General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#define DBMODULENAME "SkinHotKeys"
-
-#define WM_HOTKEYUNREGISTERED (WM_USER+721)
-
-typedef enum { HKT_GLOBAL, HKT_LOCAL, HKT_MANUAL, HKT_COUNT } THotkeyType;
-
-struct THotkeyBoxData
-{
- BYTE shift;
- BYTE key;
-};
-
-struct THotkeyItem
-{
- THotkeyType type;
- char *pszService, *pszName; // pszName is valid _only_ for "root" hotkeys
- TCHAR *ptszSection, *ptszDescription;
- LPARAM lParam;
- WORD DefHotkey, Hotkey;
- bool Enabled;
- int hLangpack;
- ATOM idHotkey;
-
- THotkeyItem *rootHotkey;
- int nSubHotkeys;
- bool allowSubHotkeys;
-
- bool OptChanged, OptDeleted, OptNew;
- WORD OptHotkey;
- THotkeyType OptType;
- bool OptEnabled;
-
- bool UnregisterHotkey; // valid only during WM_APP message in options UI, used to remove unregistered hotkeys from options
-
- __inline TCHAR* getSection() const { return TranslateTH(hLangpack, ptszSection); }
- __inline TCHAR* getDescr() const { return TranslateTH(hLangpack, ptszDescription); }
-};
-
-extern LIST<THotkeyItem> hotkeys;
-extern HWND g_hwndHkOptions, g_hwndHotkeyHost;
-extern DWORD g_pid, g_hkid;
-extern HANDLE hEvChanged;
-
-int HotkeyOptionsInit(WPARAM, LPARAM);
-
-void FreeHotkey(THotkeyItem *item);
-void RegisterHotkeys();
-void UnregisterHotkeys();
-
-void HotkeyEditCreate(HWND hwnd);
-void HotkeyEditDestroy(HWND hwnd);
diff --git a/src/modules/skin/skinicons.cpp b/src/modules/skin/skinicons.cpp
deleted file mode 100644
index 1b8b9de3be..0000000000
--- a/src/modules/skin/skinicons.cpp
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-12 Miranda IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program 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 General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "..\..\core\commonheaders.h"
-#include <io.h>
-
-struct StandardIconDescription
-{
- int id;
- LPCSTR description;
- int resource_id;
- int pf2;
- LPCSTR section;
- HANDLE hIcolib;
-};
-
-static struct StandardIconDescription mainIcons[] =
-{
- { SKINICON_OTHER_MIRANDA, LPGEN("Miranda NG"), -IDI_MIRANDA }, // 0
- { SKINICON_EVENT_MESSAGE, LPGEN("Message"), -IDI_RECVMSG }, // 1
- { SKINICON_EVENT_URL, LPGEN("URL"), -IDI_URL }, // 2
- { SKINICON_EVENT_FILE, LPGEN("File"), -IDI_FILE }, // 3
- { SKINICON_OTHER_USERONLINE, LPGEN("User online"), -IDI_USERONLINE }, // 4
- { SKINICON_OTHER_GROUPOPEN, LPGEN("Group (open)"), -IDI_GROUPOPEN }, // 5
- { SKINICON_OTHER_GROUPSHUT, LPGEN("Group (closed)"), -IDI_GROUPSHUT }, // 6
- { SKINICON_OTHER_CONNECTING, LPGEN("Connecting"), -IDI_LOAD }, // 7
- { SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact"), -IDI_ADDCONTACT }, // 8
- { SKINICON_OTHER_USERDETAILS, LPGEN("User details"), -IDI_USERDETAILS }, // 9
- { SKINICON_OTHER_HISTORY, LPGEN("History"), -IDI_HISTORY }, // 10
- { SKINICON_OTHER_DOWNARROW, LPGEN("Down arrow"), -IDI_DOWNARROW }, // 11
- { SKINICON_OTHER_FINDUSER, LPGEN("Find user"), -IDI_FINDUSER }, // 12
- { SKINICON_OTHER_OPTIONS, LPGEN("Options"), -IDI_OPTIONS }, // 13
- { SKINICON_OTHER_SENDEMAIL, LPGEN("Send e-mail"), -IDI_SENDEMAIL }, // 14
- { SKINICON_OTHER_DELETE, LPGEN("Delete"), -IDI_DELETE }, // 15
- { SKINICON_OTHER_RENAME, LPGEN("Rename"), -IDI_RENAME }, // 16
- { SKINICON_OTHER_SMS, LPGEN("SMS"), -IDI_SMS }, // 17
- { SKINICON_OTHER_SEARCHALL, LPGEN("Search all"), -IDI_SEARCHALL }, // 18
- { SKINICON_OTHER_TICK, LPGEN("Tick"), -IDI_TICK }, // 19
- { SKINICON_OTHER_NOTICK, LPGEN("No tick"), -IDI_NOTICK }, // 20
- { SKINICON_OTHER_HELP, LPGEN("Help"), -IDI_HELP }, // 21
- { SKINICON_OTHER_MIRANDAWEB, LPGEN("Miranda website"), -IDI_MIRANDAWEBSITE }, // 22
- { SKINICON_OTHER_TYPING, LPGEN("Typing"), -IDI_TYPING }, // 23
- { SKINICON_OTHER_SMALLDOT, LPGEN("Small dot"), -IDI_SMALLDOT }, // 24
- { SKINICON_OTHER_FILLEDBLOB, LPGEN("Filled blob"), -IDI_FILLEDBLOB }, // 25
- { SKINICON_OTHER_EMPTYBLOB, LPGEN("Empty blob"), -IDI_EMPTYBLOB }, // 26
- { SKINICON_OTHER_UNICODE, LPGEN("Unicode plugin"), -IDI_UNICODE }, // 27
- { SKINICON_OTHER_ANSI, LPGEN("ANSI plugin"), -IDI_ANSI }, // 28
- { SKINICON_OTHER_LOADED, LPGEN("Running plugin"), -IDI_LOADED }, // 29
- { SKINICON_OTHER_NOTLOADED, LPGEN("Unloaded plugin"), -IDI_NOTLOADED }, // 30
- { SKINICON_OTHER_UNDO, LPGEN("Undo"), -IDI_UNDO }, // 31
- { SKINICON_OTHER_WINDOW, LPGEN("Window"), -IDI_WINDOW }, // 32
- { SKINICON_OTHER_WINDOWS, LPGEN("System"), -IDI_WINDOWS }, // 33
- { SKINICON_OTHER_ACCMGR, LPGEN("Accounts"), -IDI_ACCMGR }, // 34
- { SKINICON_OTHER_SHOWHIDE, LPGEN("Show/Hide"), -IDI_SHOWHIDE }, // 35
- { SKINICON_OTHER_EXIT, LPGEN("Exit"), -IDI_EXIT }, // 36
- { SKINICON_OTHER_MAINMENU, LPGEN("Main menu"), -IDI_MAINMENU }, // 37
- { SKINICON_OTHER_STATUS, LPGEN("Status"), -IDI_ONLINE }, // 38
- { SKINICON_CHAT_JOIN, LPGEN("Join chat"), -IDI_JOINCHAT }, // 39
- { SKINICON_CHAT_LEAVE, LPGEN("Leave chat"), -IDI_LEAVECHAT }, // 40
- { SKINICON_OTHER_GROUP, LPGEN("Move to group"), -IDI_MOVETOGROUP }, // 41
- { SKINICON_OTHER_ON, LPGEN("On"), -IDI_ON }, // 42
- { SKINICON_OTHER_OFF, LPGEN("Off"), -IDI_OFF }, // 43
- { SKINICON_OTHER_LOADEDGRAY, LPGEN("Running core plugin"), -IDI_LOADED_GRAY }, // 44
- { SKINICON_OTHER_NOTLOADEDGRAY, LPGEN("Non-loadable plugin"), -IDI_NOTLOADED_GRAY }, // 45
- { SKINICON_OTHER_FRAME, LPGEN("Frames"), -IDI_FRAME }, // 46
- { SKINICON_AUTH_ADD, LPGEN("Add to list"), -IDI_AUTH_ADD }, // 47
- { SKINICON_AUTH_REQUEST, LPGEN("Request authorization"), -IDI_AUTH_REQUEST }, // 48
- { SKINICON_AUTH_GRANT, LPGEN("Grant authorization"), -IDI_AUTH_GRANT }, // 49
- { SKINICON_AUTH_REVOKE, LPGEN("Revoke authorization"), -IDI_AUTH_REVOKE }, // 50
- { SKINICON_FATAL, LPGEN("Fatal error"), -IDI_MFATAL },
- { SKINICON_ERROR, LPGEN("Error"), -IDI_MERROR },
- { SKINICON_WARNING, LPGEN("Warning"), -IDI_MWARNING },
- { SKINICON_INFORMATION, LPGEN("Information"), -IDI_MINFO },
-
- { SKINICON_OTHER_VISIBLE_ALL, LPGEN("Always visible"), -IDI_ALWAYSVIS, 0, LPGEN("Contact list") },
- { SKINICON_OTHER_INVISIBLE_ALL, LPGEN("Always invisible"), -IDI_NEVERVIS, 0, LPGEN("Contact list") },
- { SKINICON_OTHER_STATUS_LOCKED, LPGEN("Locked status"), -IDI_STATUS_LOCKED, 0, LPGEN("Status icons") },
-};
-
-static struct StandardIconDescription statusIcons[] =
-{
- { ID_STATUS_OFFLINE, LPGEN("Offline"), -IDI_OFFLINE, 0xFFFFFFFF },
- { ID_STATUS_ONLINE, LPGEN("Online"), -IDI_ONLINE, PF2_ONLINE },
- { ID_STATUS_AWAY, LPGEN("Away"), -IDI_AWAY, PF2_SHORTAWAY },
- { ID_STATUS_NA, LPGEN("NA"), -IDI_NA, PF2_LONGAWAY },
- { ID_STATUS_OCCUPIED, LPGEN("Occupied"), -IDI_OCCUPIED, PF2_LIGHTDND },
- { ID_STATUS_DND, LPGEN("DND"), -IDI_DND, PF2_HEAVYDND },
- { ID_STATUS_FREECHAT, LPGEN("Free for chat"), -IDI_FREE4CHAT, PF2_FREECHAT },
- { ID_STATUS_INVISIBLE, LPGEN("Invisible"), -IDI_INVISIBLE, PF2_INVISIBLE },
- { ID_STATUS_ONTHEPHONE, LPGEN("On the phone"), -IDI_ONTHEPHONE, PF2_ONTHEPHONE },
- { ID_STATUS_OUTTOLUNCH, LPGEN("Out to lunch"), -IDI_OUTTOLUNCH, PF2_OUTTOLUNCH }
-};
-
-const char mainIconsFmt[] = "core_main_";
-const char statusIconsFmt[] = "core_status_";
-const char protoIconsFmt[] = LPGEN("%s icons");
-
-#define PROTOCOLS_PREFIX LPGEN("Status icons")
-#define GLOBAL_PROTO_NAME "*"
-
-// load small icon (shared) it's not need to be destroyed
-
-static HICON LoadSmallIconShared(HINSTANCE hInstance, LPCTSTR lpIconName)
-{
- int cx = GetSystemMetrics(SM_CXSMICON);
- return (HICON)LoadImage(hInstance, lpIconName, IMAGE_ICON, cx, cx, LR_DEFAULTCOLOR | LR_SHARED);
-}
-
-// load small icon (not shared) it IS NEED to be destroyed
-static HICON LoadSmallIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
-{
- HICON hIcon = NULL; // icon handle
- int index = -(int)lpIconName;
- TCHAR filename[MAX_PATH] = {0};
- GetModuleFileName(hInstance, filename, MAX_PATH);
- ExtractIconEx(filename, index, NULL, &hIcon, 1);
- return hIcon;
-}
-
-// load small icon from hInstance
-HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared)
-{
- HICON hResIcon = bShared ? LoadSmallIcon(hInstance, lpIconName) : LoadSmallIconShared(hInstance, lpIconName);
- if (!hResIcon) { //Icon not found in hInstance lets try to load it from core
- HINSTANCE hCoreInstance = hInst;
- if (hCoreInstance != hInstance)
- hResIcon = bShared ? LoadSmallIcon(hCoreInstance, lpIconName) : LoadSmallIconShared(hCoreInstance, lpIconName);
- }
- return hResIcon;
-}
-
-int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource)
-{
- HICON hTempIcon = LoadIconEx(hInst, szResource, 0);
- int res = ImageList_AddIcon(hIml, hTempIcon);
- Safe_DestroyIcon(hTempIcon);
- return res;
-}
-
-int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId)
-{
- HICON hIcon = LoadSkinIcon(iconId);
- int res = ImageList_AddIcon(hIml, hIcon);
- IcoLib_ReleaseIcon(hIcon, 0);
- return res;
-}
-
-int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char *szProto, int iconId)
-{
- HICON hIcon = LoadSkinProtoIcon(szProto, iconId);
- int res = ImageList_AddIcon(hIml, hIcon);
- IcoLib_ReleaseIcon(hIcon, 0);
- return res;
-}
-
-int ImageList_ReplaceIcon_NotShared(HIMAGELIST hIml, int iIndex, HINSTANCE hInstance, LPCTSTR szResource)
-{
- HICON hTempIcon = LoadIconEx(hInstance, szResource, 0);
- int res = ImageList_ReplaceIcon(hIml, iIndex, hTempIcon);
- Safe_DestroyIcon(hTempIcon);
- return res;
-}
-
-int ImageList_ReplaceIcon_IconLibLoaded(HIMAGELIST hIml, int nIndex, HICON hIcon)
-{
- int res = ImageList_ReplaceIcon(hIml, nIndex, hIcon);
- IcoLib_ReleaseIcon(hIcon, 0);
- return res;
-}
-
-void Window_SetIcon_IcoLib(HWND hWnd, int iconId)
-{
- SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinIcon(iconId, true));
- SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinIcon(iconId));
-}
-
-void Window_SetProtoIcon_IcoLib(HWND hWnd, const char *szProto, int iconId)
-{
- SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinProtoIcon(szProto, iconId, true));
- SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinProtoIcon(szProto, iconId));
-}
-
-void Window_FreeIcon_IcoLib(HWND hWnd)
-{
- IcoLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_BIG, 0), NULL);
- IcoLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0), NULL);
-}
-
-void Button_SetIcon_IcoLib(HWND hwndDlg, int itemId, int iconId, const char* tooltip)
-{
- HWND hWnd = GetDlgItem(hwndDlg, itemId);
- SendMessage(hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadSkinIcon(iconId));
- SendMessage(hWnd, BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(hWnd, BUTTONADDTOOLTIP, (WPARAM)tooltip, 0);
-}
-
-void Button_FreeIcon_IcoLib(HWND hwndDlg, int itemId)
-{
- HICON hIcon = (HICON)SendDlgItemMessage(hwndDlg, itemId, BM_SETIMAGE, IMAGE_ICON, 0);
- IcoLib_ReleaseIcon(hIcon, 0);
-}
-
-//
-// wParam = szProto
-// lParam = status
-//
-HICON LoadSkinProtoIcon(const char *szProto, int status, bool big)
-{
- char iconName[MAX_PATH];
- INT_PTR caps2;
- if (szProto == NULL)
- caps2 = -1;
- else if ((caps2 = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_2, 0)) == CALLSERVICE_NOTFOUND)
- caps2 = 0;
-
- if (IsStatusConnecting(status)) {
- mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, 7);
- return IcoLib_GetIcon(iconName, big);
- }
-
- int statusIndx = -1;
- for (int i=0; i < SIZEOF(statusIcons); i++) {
- if (statusIcons[i].id == status) {
- statusIndx = i;
- break;
- } }
-
- if (statusIndx == -1)
- return NULL;
-
- if (!szProto) {
- // Only return a protocol specific icon if there is only one protocol
- // Otherwise return the global icon. This affects the global status menu mainly.
- if (accounts.getCount() == 1) {
- // format: core_status_%proto%statusindex
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
-
- HICON hIcon = IcoLib_GetIcon(iconName, big);
- if (hIcon)
- return hIcon;
- }
-
- // format: core_status_%s%d
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx);
- return IcoLib_GetIcon(iconName, big);
- }
-
- // format: core_status_%s%d
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
- HICON hIcon = IcoLib_GetIcon(iconName, big);
- if (hIcon == NULL && (caps2 == 0 || (caps2 & statusIcons[statusIndx].pf2))) {
- PROTOACCOUNT *pa = Proto_GetAccount(szProto);
- if (pa) {
- TCHAR szPath[MAX_PATH], szFullPath[MAX_PATH], *str;
- GetModuleFileName(hInst, szPath, MAX_PATH);
-
- //
- // Queried protocol isn't in list, adding
- //
- TCHAR tszSection[MAX_PATH];
- mir_sntprintf(tszSection, SIZEOF(tszSection), _T(PROTOCOLS_PREFIX)_T("/%s"), pa->tszAccountName);
-
- SKINICONDESC sid = { 0 };
- sid.section.t = tszSection;
- sid.flags = SIDF_ALL_TCHAR;
-
- str = _tcsrchr(szPath, '\\');
- if (str != NULL)
- *str = 0;
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Icons\\proto_%S.dll"), szPath, pa->szProtoName);
- if (GetFileAttributes(szFullPath) != INVALID_FILE_ATTRIBUTES)
- sid.defaultFile.t = szFullPath;
- else {
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Plugins\\%S.dll"), szPath, szProto);
- if (int(ExtractIconEx(szFullPath, statusIcons[statusIndx].resource_id, NULL, &hIcon, 1)) > 0) {
- DestroyIcon(hIcon);
- sid.defaultFile.t = szFullPath;
- hIcon = NULL;
- }
-
- if (sid.defaultFile.a == NULL) {
- if (str != NULL)
- *str = '\\';
- sid.defaultFile.t = szPath;
- } }
-
- //
- // Add global icons to list
- //
-
- int lowidx, highidx;
- if (caps2 == 0)
- lowidx = statusIndx, highidx = statusIndx+1;
- else
- lowidx = 0, highidx = SIZEOF(statusIcons);
-
- for (int i = lowidx; i < highidx; i++)
- if (caps2 == 0 || (caps2 & statusIcons[i].pf2)) {
- // format: core_%s%d
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, i);
- sid.pszName = iconName;
- sid.description.t = cli.pfnGetStatusModeDescription(statusIcons[i].id, 0);
- sid.iDefaultIndex = statusIcons[i].resource_id;
- IcoLib_AddNewIcon(0, &sid);
- }
- }
-
- // format: core_status_%s%d
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
- hIcon = IcoLib_GetIcon(iconName, big);
- if (hIcon)
- return hIcon;
- }
-
- if (hIcon == NULL) {
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx);
- hIcon = IcoLib_GetIcon(iconName, big);
- }
-
- return hIcon;
-}
-
-HANDLE GetSkinIconHandle(int idx)
-{
- for (int i=0; i < SIZEOF(mainIcons); i++)
- if (idx == mainIcons[i].id)
- return mainIcons[i].hIcolib;
-
- return NULL;
-}
-
-char* GetSkinIconName(int idx)
-{
- static char szIconName[100];
-
- for (int i=0; i < SIZEOF(mainIcons); i++) {
- if (idx != mainIcons[i].id)
- continue;
-
- mir_snprintf(szIconName, SIZEOF(szIconName), "%s%d", mainIconsFmt, i);
- return szIconName;
- }
- return NULL;
-}
-
-HICON LoadSkinIcon(int idx, bool big)
-{
- //
- // Query for global status icons
- //
- if (idx < SKINICON_EVENT_MESSAGE) {
- if (idx >= SIZEOF(statusIcons))
- return NULL;
-
- return LoadSkinProtoIcon(NULL, statusIcons[ idx ].id, big);
- }
-
- return IcoLib_GetIconByHandle(GetSkinIconHandle(idx), big);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Initializes the icon skin module
-
-static void convertOneProtocol(char *moduleName, char *iconName)
-{
- char *pm = moduleName + mir_strlen(moduleName);
- char *pi = iconName + mir_strlen(iconName);
-
- for (int i=0; i < SIZEOF(statusIcons); i++) {
- _itoa(statusIcons[i].id, pm, 10);
-
- DBVARIANT dbv;
- if (!db_get_ts(NULL, "Icons", moduleName, &dbv)) {
- _itoa(i, pi, 10);
-
- db_set_ts(NULL, "SkinIcons", iconName, dbv.ptszVal);
- db_free(&dbv);
-
- db_unset(NULL, "Icons", moduleName);
-} } }
-
-static INT_PTR sttLoadSkinIcon(WPARAM wParam, LPARAM lParam)
-{
- switch (lParam) {
- case 0: return (INT_PTR)LoadSkinIcon(wParam);
- case 1: return (INT_PTR)GetSkinIconHandle(wParam);
- case 2: return (INT_PTR)LoadSkinIcon(wParam, true);
- case 3: return (INT_PTR)GetSkinIconName(wParam);
- }
-
- return 0;
-}
-
-static INT_PTR sttLoadSkinProtoIcon(WPARAM wParam, LPARAM lParam)
-{
- return (INT_PTR)LoadSkinProtoIcon((char*)wParam, (int)lParam, false);
-}
-
-static INT_PTR sttLoadSkinProtoIconBig(WPARAM wParam, LPARAM lParam)
-{
- return (INT_PTR)LoadSkinProtoIcon((char*)wParam, (int)lParam, true);
-}
-
-int LoadSkinIcons(void)
-{
- int i, j = 0;
- char iconName[MAX_PATH], moduleName[MAX_PATH];
- DBVARIANT dbv;
-
- //
- // Perform "1st-time running import"
-
- for (i=0; i < SIZEOF(mainIcons); i++) {
- _itoa(mainIcons[i].id, moduleName, 10);
- if (db_get_ts(NULL, "Icons", moduleName, &dbv))
- break;
-
- mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, i);
-
- db_set_ts(NULL, "SkinIcons", iconName, dbv.ptszVal);
- db_free(&dbv);
-
- db_unset(NULL, "Icons", moduleName);
- }
-
- for (;;) {
- // get the next protocol name
- moduleName[0] = 'p';
- moduleName[1] = 0;
- _itoa(j++, moduleName+1, 100);
- if (db_get_ts(NULL, "Icons", moduleName, &dbv))
- break;
-
- db_unset(NULL, "Icons", moduleName);
-
- // make old skinicons' prefix
- mir_snprintf(moduleName, SIZEOF(moduleName), "%S", dbv.ptszVal);
- // make IcoLib's prefix
- mir_snprintf(iconName, SIZEOF(iconName), "%s%S", statusIconsFmt, dbv.ptszVal);
-
- convertOneProtocol(moduleName, iconName);
- db_free(&dbv);
- }
- moduleName[0] = 0;
- strncpy_s(iconName, "core_status_" GLOBAL_PROTO_NAME, _TRUNCATE);
- convertOneProtocol(moduleName, iconName);
-
- CreateServiceFunction(MS_SKIN_LOADICON, sttLoadSkinIcon);
- CreateServiceFunction(MS_SKIN_LOADPROTOICON, sttLoadSkinProtoIcon);
- CreateServiceFunction(MS_SKIN_LOADPROTOICONBIG, sttLoadSkinProtoIconBig);
-
- TCHAR modulePath[MAX_PATH];
- GetModuleFileName(NULL, modulePath, SIZEOF(modulePath));
-
- SKINICONDESC sid = { 0 };
- sid.defaultFile.t = modulePath;
- sid.flags = SIDF_PATH_TCHAR;
- sid.pszName = iconName;
-
- //
- // Add main icons to list
- //
- for (i=0; i < SIZEOF(mainIcons); i++) {
- mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, i);
- sid.section.a = mainIcons[i].section == NULL ? LPGEN("Main icons") : (char*)mainIcons[i].section;
- sid.description.a = (char*)mainIcons[i].description;
- sid.iDefaultIndex = mainIcons[i].resource_id;
- mainIcons[i].hIcolib = IcoLib_AddNewIcon(0, &sid);
- }
- //
- // Add global icons to list
- //
- sid.section.a = PROTOCOLS_PREFIX "/" LPGEN("Global");
- //
- // Asterisk is used, to avoid conflict with proto-plugins
- // 'coz users can't rename it to name with '*'
- for (i=0; i < SIZEOF(statusIcons); i++) {
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, i);
- sid.pszName = iconName;
- sid.description.a = (char*)statusIcons[i].description;
- sid.iDefaultIndex = statusIcons[i].resource_id;
- statusIcons[i].hIcolib = IcoLib_AddNewIcon(0, &sid);
- }
- return 0;
-}
diff --git a/src/modules/skin/sounds.cpp b/src/modules/skin/sounds.cpp
deleted file mode 100644
index 1b95f807ed..0000000000
--- a/src/modules/skin/sounds.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-12 Miranda IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program 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 General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "..\..\core\commonheaders.h"
-
-struct SoundItem
-{
- char* name;
- TCHAR* ptszSection;
- TCHAR* ptszDescription;
- TCHAR* ptszTempFile;
- int hLangpack;
-
- __inline TCHAR* getSection() const { return TranslateTH(hLangpack, ptszSection); }
- __inline TCHAR* getDescr() const { return TranslateTH(hLangpack, ptszDescription); }
-
- __inline void clear(void)
- {
- mir_free(name);
- mir_free(ptszSection);
- mir_free(ptszDescription);
- mir_free(ptszTempFile);
- }
-};
-
-static int CompareSounds(const SoundItem* p1, const SoundItem* p2)
-{
- return mir_strcmp(p1->name, p2->name);
-}
-
-static OBJLIST<SoundItem> arSounds(10, CompareSounds);
-
-///////////////////////////////////////////////////////////////////////////////
-
-void KillModuleSounds(int hLangpack)
-{
- for (int i = arSounds.getCount()-1; i >= 0; i--) {
- SoundItem& p = arSounds[i];
- if (p.hLangpack == hLangpack) {
- p.clear();
- arSounds.remove(i);
- }
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static BOOL bModuleInitialized = FALSE;
-static HANDLE hPlayEvent = NULL;
-
-static INT_PTR ServiceSkinAddNewSound(WPARAM wParam, LPARAM lParam)
-{
- SKINSOUNDDESCEX *ssd = (SKINSOUNDDESCEX*)lParam;
- if (ssd->cbSize != sizeof(SKINSOUNDDESCEX) || ssd->pszName == NULL || ssd->pszDescription == NULL)
- return 1;
-
- SoundItem* item = new SoundItem; // due to OBJLIST
- item->name = mir_strdup(ssd->pszName);
- item->ptszTempFile = NULL;
- item->hLangpack = (int)wParam;
- arSounds.insert(item);
-
- TCHAR* ptszDefaultFile;
- if (ssd->dwFlags & SSDF_UNICODE) {
- item->ptszDescription = mir_tstrdup(ssd->ptszDescription);
- item->ptszSection = mir_tstrdup((ssd->pszSection != NULL) ? ssd->ptszSection : _T("Other"));
- ptszDefaultFile = mir_tstrdup(ssd->ptszDefaultFile);
- }
- else {
- item->ptszDescription = mir_a2t(ssd->pszDescription);
- item->ptszSection = mir_a2t((ssd->pszSection != NULL) ? ssd->pszSection : "Other");
- ptszDefaultFile = mir_a2t(ssd->pszDefaultFile);
- }
-
- if (ptszDefaultFile) {
- DBVARIANT dbv;
- if (db_get_s(NULL, "SkinSounds", item->name, &dbv))
- db_set_ts(NULL, "SkinSounds", item->name, ptszDefaultFile);
- else
- db_free(&dbv);
- mir_free(ptszDefaultFile);
- }
-
- return 0;
-}
-
-static int SkinPlaySoundDefault(WPARAM wParam, LPARAM lParam)
-{
- TCHAR* pszFile = (TCHAR*) lParam;
- if (pszFile && (db_get_b(NULL, "Skin", "UseSound", 0) || (int)wParam == 1))
- PlaySound(pszFile, NULL, SND_ASYNC | SND_FILENAME | SND_NOSTOP);
-
- return 0;
-}
-
-static INT_PTR ServiceSkinPlaySoundFile(WPARAM, LPARAM lParam)
-{
- TCHAR *ptszFileName = (TCHAR*)lParam;
- if (ptszFileName == NULL)
- return 1;
-
- TCHAR tszFull[MAX_PATH];
- PathToAbsoluteT(ptszFileName, tszFull);
- NotifyEventHooks(hPlayEvent, 0, (LPARAM)tszFull);
- return 0;
-}
-
-static INT_PTR ServiceSkinPlaySound(WPARAM, LPARAM lParam)
-{
- char* pszSoundName = (char*)lParam;
- if (pszSoundName == NULL)
- return 1;
-
- SoundItem tmp = { pszSoundName };
- int idx = arSounds.getIndex( &tmp );
- if (idx == -1)
- return 1;
-
- if ( db_get_b(NULL, "SkinSoundsOff", pszSoundName, 0))
- return 1;
-
- DBVARIANT dbv;
- if ( db_get_ts(NULL, "SkinSounds", pszSoundName, &dbv) == 0) {
- ServiceSkinPlaySoundFile(0, (LPARAM)dbv.ptszVal);
- db_free(&dbv);
- return 0;
- }
- return 1;
-}
-
-#define DM_REBUILD_STREE (WM_USER+1)
-#define DM_HIDEPANE (WM_USER+2)
-#define DM_SHOWPANE (WM_USER+3)
-#define DM_CHECKENABLED (WM_USER+4)
-
-INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- static HWND hwndTree = NULL;
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- hwndTree = GetDlgItem(hwndDlg, IDC_SOUNDTREE);
- SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
- SendMessage(hwndDlg, DM_HIDEPANE, 0, 0);
- SendMessage(hwndDlg, DM_REBUILD_STREE, 0, 0);
- TreeView_SetItemState(hwndTree, 0, TVIS_SELECTED, TVIS_SELECTED);
- CheckDlgButton(hwndDlg, IDC_ENABLESOUNDS, db_get_b(NULL, "Skin", "UseSound", 0) ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndDlg, DM_CHECKENABLED, 0, 0);
- return TRUE;
-
- case DM_REBUILD_STREE:
- TreeView_SelectItem(hwndTree, NULL);
- ShowWindow(hwndTree, SW_HIDE);
- TreeView_DeleteAllItems(hwndTree);
- {
- TVINSERTSTRUCT tvis;
- tvis.hParent = NULL;
- tvis.hInsertAfter = TVI_SORT;
- tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
- tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED;
- for (int i=0; i < arSounds.getCount(); i++) {
- tvis.item.stateMask = TVIS_EXPANDED;
- tvis.item.state = TVIS_EXPANDED;
- tvis.hParent = FindNamedTreeItemAtRoot(hwndTree, arSounds[i].getSection());
- if (tvis.hParent == NULL) {
- tvis.item.lParam = -1;
- tvis.item.pszText = arSounds[i].getSection();
- tvis.hParent = tvis.item.hItem = TreeView_InsertItem(hwndTree, &tvis);
- tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.state = INDEXTOSTATEIMAGEMASK(0);
- TreeView_SetItem(hwndTree, &tvis.item);
- }
- tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.state = INDEXTOSTATEIMAGEMASK(!db_get_b(NULL, "SkinSoundsOff", arSounds[i].name, 0)?2:1);
- tvis.item.lParam = i;
- tvis.item.pszText = arSounds[i].getDescr();
- TreeView_InsertItem(hwndTree, &tvis);
- } }
- {
- TVITEM tvi;
- tvi.hItem = TreeView_GetRoot(hwndTree);
- while (tvi.hItem != NULL) {
- tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
- TreeView_GetItem(hwndTree, &tvi);
- if (tvi.lParam == -1)
- TreeView_SetItemState(hwndTree, tvi.hItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK);
-
- tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
- } }
-
- ShowWindow(hwndTree, SW_SHOW);
- break;
-
- case DM_HIDEPANE:
- ShowWindow( GetDlgItem(hwndDlg, IDC_SGROUP), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NAME), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NAMEVAL), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_SLOC), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_LOCATION), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_CHANGE), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_PREVIEW), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_GETMORE), SW_HIDE);
- break;
-
- case DM_SHOWPANE:
- ShowWindow( GetDlgItem(hwndDlg, IDC_SGROUP), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NAME), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NAMEVAL), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_SLOC), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_LOCATION), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_CHANGE), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_PREVIEW), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_GETMORE), SW_SHOW);
- break;
-
- case DM_CHECKENABLED:
- EnableWindow( GetDlgItem(hwndDlg, IDC_SOUNDTREE), IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS));
- if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS))
- SendMessage(hwndDlg, DM_HIDEPANE, 0, 0);
- else if (TreeView_GetSelection(hwndTree) && TreeView_GetParent(hwndTree, TreeView_GetSelection(hwndTree)))
- SendMessage(hwndDlg, DM_SHOWPANE, 0, 0);
- break;
-
- case WM_COMMAND:
- if (LOWORD(wParam) == IDC_ENABLESOUNDS)
- SendMessage(hwndDlg, DM_CHECKENABLED, 0, 0);
-
- if (LOWORD(wParam) == IDC_PREVIEW) {
- HTREEITEM hti = TreeView_GetSelection(hwndTree);
- if (hti == NULL)
- break;
-
- TVITEM tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT;
- tvi.hItem = hti;
- if (TreeView_GetItem(hwndTree, &tvi) == FALSE)
- break;
- if (tvi.lParam == -1)
- break;
-
- if (arSounds[tvi.lParam].ptszTempFile)
- NotifyEventHooks(hPlayEvent, 1, (LPARAM)arSounds[tvi.lParam].ptszTempFile);
- else {
- DBVARIANT dbv;
- if (!db_get_ts(NULL, "SkinSounds", arSounds[tvi.lParam].name, &dbv)) {
- TCHAR szPathFull[MAX_PATH];
- PathToAbsoluteT(dbv.ptszVal, szPathFull);
- NotifyEventHooks(hPlayEvent, 1, (LPARAM)szPathFull);
- db_free(&dbv);
- }
- }
- break;
- }
-
- if (LOWORD(wParam) == IDC_CHANGE) {
- HTREEITEM hti = TreeView_GetSelection(hwndTree);
- if (hti == NULL)
- break;
-
- TVITEM tvi = { 0 };
- tvi.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM|TVIF_TEXT;
- tvi.hItem = hti;
- if (TreeView_GetItem(hwndTree, &tvi) == FALSE)
- break;
- if (tvi.lParam == -1)
- break;
-
- SoundItem& snd = arSounds[tvi.lParam];
-
- TCHAR str[MAX_PATH], strFull[MAX_PATH], strdir[MAX_PATH], filter[MAX_PATH];
- if (snd.ptszTempFile)
- _tcsncpy_s(strFull, snd.ptszTempFile, _TRUNCATE);
- else {
- if (db_get_b(NULL, "SkinSoundsOff", snd.name, 0) == 0) {
- DBVARIANT dbv;
- if (db_get_ts(NULL, "SkinSounds", snd.name, &dbv) == 0) {
- PathToAbsoluteT(dbv.ptszVal, strdir);
- db_free(&dbv);
- } } }
-
- _tcsncpy_s(strFull, (snd.ptszTempFile ? snd.ptszTempFile : _T("")), _TRUNCATE);
- PathToAbsoluteT(strFull, strdir);
-
- OPENFILENAME ofn;
- memset(&ofn, 0, sizeof(ofn));
- if (GetModuleHandle(_T("bass_interface.dll")))
- mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%s (*)%c*%c"), TranslateT("Sound files"), 0, 0, TranslateT("All files"), 0, 0);
- else
- mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav)%c*.wav%c%s (*)%c*%c"), TranslateT("WAV files"), 0, 0, TranslateT("All files"), 0, 0);
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = GetParent(hwndDlg);
- ofn.hInstance = NULL;
- ofn.lpstrFilter = filter;
-
- TCHAR* slash = _tcsrchr(strdir, '\\');
- if (slash) {
- *slash = 0;
- ofn.lpstrInitialDir = strdir;
- }
-
- str[0] = 0;
- ofn.lpstrFile = str;
- ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER|OFN_LONGNAMES|OFN_NOCHANGEDIR;
- ofn.nMaxFile = SIZEOF(str);
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.lpstrDefExt = _T("wav");
- if (!GetOpenFileName(&ofn))
- break;
-
- PathToRelativeT(str, strFull);
- snd.ptszTempFile = mir_tstrdup(strFull);
- SetDlgItemText(hwndDlg, IDC_LOCATION, strFull);
- }
- if (LOWORD(wParam) == IDC_GETMORE) {
- CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)"http://miranda-ng.org/addons/category/14");
- break;
- }
- if (LOWORD(wParam) == IDC_LOCATION)
- break;
-
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
- if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- db_set_b(NULL, "Skin", "UseSound", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS));
-
- for (int i=0; i < arSounds.getCount(); i++)
- if (arSounds[i].ptszTempFile)
- db_set_ts(NULL, "SkinSounds", arSounds[i].name, arSounds[i].ptszTempFile);
-
- TVITEM tvi, tvic;
- tvi.hItem = TreeView_GetRoot(hwndTree);
- while (tvi.hItem != NULL) {
- tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
- TreeView_GetItem(hwndTree, &tvi);
- if (tvi.lParam == -1) {
- tvic.hItem = TreeView_GetChild(hwndTree, tvi.hItem);
- while (tvic.hItem != NULL) {
- tvic.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
- TreeView_GetItem(hwndTree, &tvic);
- if (((tvic.state & TVIS_STATEIMAGEMASK) >> 12 == 2))
- db_unset(NULL, "SkinSoundsOff", arSounds[tvic.lParam].name);
- else
- db_set_b(NULL, "SkinSoundsOff", arSounds[tvic.lParam].name, 1);
- tvic.hItem = TreeView_GetNextSibling(hwndTree, tvic.hItem);
- } }
-
- tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
- }
- return TRUE;
- }
- break;
-
- case IDC_SOUNDTREE:
- switch(((NMHDR*)lParam)->code) {
- case TVN_SELCHANGED:
- {
- NMTREEVIEW *pnmtv = (NMTREEVIEW*)lParam;
- TVITEM tvi = pnmtv->itemNew;
-
- if (tvi.lParam == -1)
- SendMessage(hwndDlg, DM_HIDEPANE, 0, 0);
- else {
- TCHAR buf[256];
- mir_sntprintf(buf, _T("%s: %s"), arSounds[tvi.lParam].getSection(), arSounds[tvi.lParam].getDescr());
- SetDlgItemText(hwndDlg, IDC_NAMEVAL, buf);
- if (arSounds[tvi.lParam].ptszTempFile)
- SetDlgItemText(hwndDlg, IDC_LOCATION, arSounds[tvi.lParam].ptszTempFile);
- else {
- DBVARIANT dbv;
- if (!db_get_ts(NULL, "SkinSounds", arSounds[tvi.lParam].name, &dbv)) {
- SetDlgItemText(hwndDlg, IDC_LOCATION, dbv.ptszVal);
- db_free(&dbv);
- }
- else SetDlgItemText(hwndDlg, IDC_LOCATION, TranslateT("<not specified>"));
- }
- SendMessage(hwndDlg, DM_SHOWPANE, 0, 0);
- }
- }
- break;
- case TVN_KEYDOWN:
- {
- NMTVKEYDOWN* ptkd = (NMTVKEYDOWN*)lParam;
- if (ptkd && ptkd->wVKey == VK_SPACE && TreeView_GetSelection(ptkd->hdr.hwndFrom))
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
- case NM_CLICK:
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
- if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti))
- if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMSTATEICON))
- if (TreeView_GetParent(hwndTree, hti.hItem) != NULL)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
- }
- }
- break;
-
- case WM_DESTROY:
- ImageList_Destroy(TreeView_GetImageList(hwndTree, TVSIL_STATE));
- break;
- }
- return FALSE;
-}
-
-static int SkinOptionsInit(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.position = -200000000;
- odp.hInstance = hInst;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SOUND);
- odp.pszTitle = LPGEN("Sounds");
- odp.pfnDlgProc = DlgProcSoundOpts;
- odp.flags = ODPF_BOLDGROUPS;
- Options_AddPage(wParam, &odp);
- return 0;
-}
-
-static int SkinSystemModulesLoaded(WPARAM, LPARAM)
-{
- HookEvent(ME_OPT_INITIALISE, SkinOptionsInit);
- return 0;
-}
-
-int LoadSkinSounds(void)
-{
- bModuleInitialized = TRUE;
-
- CreateServiceFunction("Skin/Sounds/AddNew", ServiceSkinAddNewSound);
- CreateServiceFunction(MS_SKIN_PLAYSOUND, ServiceSkinPlaySound);
- CreateServiceFunction(MS_SKIN_PLAYSOUNDFILE, ServiceSkinPlaySoundFile);
- HookEvent(ME_SYSTEM_MODULESLOADED, SkinSystemModulesLoaded);
- hPlayEvent = CreateHookableEvent(ME_SKIN_PLAYINGSOUND);
- SetHookDefaultForHookableEvent(hPlayEvent, SkinPlaySoundDefault);
- return 0;
-}
-
-void UnloadSkinSounds(void)
-{
- for (int i=0; i < arSounds.getCount(); i++)
- arSounds[i].clear();
-}