diff options
Diffstat (limited to 'plugins/Clist_modern/src/modern_viewmodebar.cpp')
-rw-r--r-- | plugins/Clist_modern/src/modern_viewmodebar.cpp | 213 |
1 files changed, 98 insertions, 115 deletions
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index f1a7d13b88..68f5ca0aca 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -706,28 +706,25 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP switch(msg) {
case WM_INITDIALOG:
+ xpt_EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
+ himlViewModes = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 12, 0);
{
- int i=0;
- TCITEM tci;
- RECT rcClient;
- CLCINFOITEM cii = {0};
- HICON hIcon;
-
- xpt_EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
-
- himlViewModes = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 12, 0);
+ int i;
for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
- hIcon = LoadSkinnedProtoIcon(NULL, i);
+ HICON hIcon = LoadSkinnedProtoIcon(NULL, i);
ImageList_AddIcon(himlViewModes, hIcon);
Skin_ReleaseIcon(hIcon);
}
- hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_SMALLDOT), IMAGE_ICON, 16, 16, 0);
+ HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_SMALLDOT), IMAGE_ICON, 16, 16, 0);
nullImage = ImageList_AddIcon(himlViewModes, hIcon);
DestroyIcon(hIcon);
+
+ RECT rcClient;
GetClientRect(hwndDlg, &rcClient);
- tci.mask = TCIF_PARAM|TCIF_TEXT;
+ TCITEM tci;
+ tci.mask = TCIF_PARAM | TCIF_TEXT;
tci.lParam = 0;
tci.pszText = TranslateT("Sticky contacts");
SendMessage(GetDlgItem(hwndDlg, IDC_TAB), TCM_INSERTITEM, 0, (LPARAM)&tci);
@@ -754,7 +751,8 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETINDENT,10,0);
for (i=0;i <= FONTID_MAX;i++)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETTEXTCOLOR,i,GetSysColor(COLOR_WINDOWTEXT));
- cii.cbSize = sizeof(cii);
+
+ CLCINFOITEM cii = { sizeof(cii) };
cii.hParentGroup = 0;
cii.pszText = TranslateT("*** All contacts ***");
hInfoItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
@@ -762,10 +760,8 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP int index = 0;
- if ( g_CluiData.current_viewmode[0] != '\0' )
- {
- TCHAR * temp = mir_utf8decodeW( g_CluiData.current_viewmode );
-
+ if (g_CluiData.current_viewmode[0] != '\0') {
+ TCHAR *temp = mir_utf8decodeW( g_CluiData.current_viewmode );
if (temp) {
index = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_FINDSTRING, -1, (LPARAM)temp );
mir_free(temp);
@@ -774,8 +770,7 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP index = 0;
}
- if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, index, 0) != LB_ERR)
- {
+ if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, index, 0) != LB_ERR) {
clvm_curItem = index;
UpdateFilters();
}
@@ -791,8 +786,9 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP //EnableWindow(GetDlgItem(hwndDlg, IDC_VARIABLES), ServiceExists(MS_VARS_FORMATSTRING));
SendDlgItemMessage(hwndDlg, IDC_AUTOCLEARSPIN, UDM_SETRANGE, 0, MAKELONG(1000, 0));
SetWindowText(hwndDlg, TranslateT("Configure view modes"));
- return TRUE;
}
+ return TRUE;
+
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_PROTOGROUPOP:
@@ -802,12 +798,15 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (HIWORD(wParam) == CBN_SELCHANGE)
EnableWindow(GetDlgItem(hwndDlg, IDC_APPLY), TRUE);
break;
+
case IDC_USEGROUPS:
EnableWindow(GetDlgItem(hwndDlg, IDC_APPLY), TRUE);
break;
+
case IDC_AUTOCLEAR:
EnableWindow(GetDlgItem(hwndDlg, IDC_APPLY), TRUE);
break;
+
case IDC_LASTMSG:
{
int bUseLastMsg = IsDlgButtonChecked(hwndDlg, IDC_LASTMSG);
@@ -815,48 +814,43 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP EnableWindow(GetDlgItem(hwndDlg, IDC_LASTMESSAGEUNIT), bUseLastMsg);
EnableWindow(GetDlgItem(hwndDlg, IDC_LASTMSGVALUE), bUseLastMsg);
EnableWindow(GetDlgItem(hwndDlg, IDC_APPLY), TRUE);
- break;
}
+ break;
+
case IDC_AUTOCLEARVAL:
case IDC_LASTMSGVALUE:
if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam)
EnableWindow(GetDlgItem(hwndDlg, IDC_APPLY), TRUE);
break;
- case IDC_DELETEVIEWMODE:
- {
- if (MessageBox(0, TranslateT("Really delete this view mode? This cannot be undone"), TranslateT("Delete a view mode"), MB_YESNO | MB_ICONQUESTION) == IDYES)
- {
- int iLen = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXTLEN, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0);
- if (iLen)
- {
- //TODO: UNICODE
- TCHAR *szTempBuf = ( TCHAR* )malloc((iLen + 1)*sizeof(TCHAR));
- char *szBuf = NULL;
- if (szTempBuf)
- {
- SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), (LPARAM)szTempBuf);
- szBuf = mir_utf8encodeT(szTempBuf);
- DeleteViewMode( szBuf );
-
- SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0);
- if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR)
- {
- clvm_curItem = 0;
- UpdateFilters();
- }
- else
- clvm_curItem = -1;
-
- if (szBuf && szBuf != (char*)szTempBuf) mir_free(szBuf);
- if (szTempBuf) free(szTempBuf);
- szTempBuf = NULL;
- szBuf = NULL;
+ case IDC_DELETEVIEWMODE:
+ if (MessageBox(0, TranslateT("Really delete this view mode? This cannot be undone"), TranslateT("Delete a view mode"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
+ int iLen = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXTLEN, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0);
+ if (iLen) {
+ //TODO: UNICODE
+ TCHAR *szTempBuf = ( TCHAR* )malloc((iLen + 1)*sizeof(TCHAR));
+ char *szBuf = NULL;
+ if (szTempBuf) {
+ SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), (LPARAM)szTempBuf);
+ szBuf = mir_utf8encodeT(szTempBuf);
+ DeleteViewMode( szBuf );
+
+ SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0);
+ if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) {
+ clvm_curItem = 0;
+ UpdateFilters();
}
+ else clvm_curItem = -1;
+
+ if (szBuf && szBuf != (char*)szTempBuf) mir_free(szBuf);
+ if (szTempBuf) free(szTempBuf);
+ szTempBuf = NULL;
+ szBuf = NULL;
}
}
- break;
}
+ break;
+
case IDC_ADDVIEWMODE:
{
TCHAR szBuf[256];
@@ -864,17 +858,14 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetDlgItemText(hwndDlg, IDC_NEWVIEMODE, szBuf, 256);
szBuf[255] = 0;
- if (lstrlen(szBuf) > 0)
- {
+ if (lstrlen(szBuf) > 0) {
char *szUTF8Buf = mir_utf8encodeT(szBuf);
if (db_get_dw(NULL, CLVM_MODULE, szUTF8Buf, -1) != -1)
MessageBox(0, TranslateT("A view mode with this name does alredy exist"), TranslateT("Duplicate name"), MB_OK);
- else
- {
+ else {
int iNewItem = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_INSERTSTRING, -1, (LPARAM)szBuf);
- if (iNewItem != LB_ERR)
- {
+ if (iNewItem != LB_ERR) {
SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, (WPARAM)iNewItem, 0);
SaveViewMode(szUTF8Buf, _T(""), "", 0, -1, 0, 0, 0, 0);
clvm_curItem = iNewItem;
@@ -892,12 +883,9 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
case IDC_CLEARALL:
{
- HANDLE hItem;
HANDLE hContact = db_find_first();
-
- while(hContact)
- {
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ while(hContact) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 0);
hContact = db_find_next(hContact);
@@ -915,10 +903,11 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP DestroyWindow(hwndDlg);
break;
}
+
if (LOWORD(wParam) == IDC_NEWVIEMODE && HIWORD(wParam) == EN_CHANGE)
EnableWindow(GetDlgItem(hwndDlg, IDC_ADDVIEWMODE), TRUE);
- if (LOWORD(wParam) == IDC_VIEWMODES && HIWORD(wParam) == LBN_SELCHANGE)
- {
+
+ if (LOWORD(wParam) == IDC_VIEWMODES && HIWORD(wParam) == LBN_SELCHANGE) {
SaveState();
clvm_curItem = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0);
UpdateFilters();
@@ -926,56 +915,50 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP //SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
+
case WM_NOTIFY:
- {
- switch (((LPNMHDR) lParam)->idFrom) {
- case IDC_GROUPS:
- case IDC_STATUSMODES:
- case IDC_PROTOCOLS:
- case IDC_CLIST:
- if (((LPNMHDR) lParam)->code == NM_CLICK || ((LPNMHDR) lParam)->code == CLN_CHECKCHANGED)
- EnableWindow(GetDlgItem(hwndDlg, IDC_APPLY), TRUE);
-
- switch (((LPNMHDR)lParam)->code) {
- case NM_CLICK:
- {
- HANDLE hItem;
- NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
- DWORD hitFlags;
- int iImage;
-
- if (nm->iColumn == -1)
- break;
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg,IDC_CLIST,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));
- if (hItem == NULL) break;
-
- if ( !(hitFlags&CLCHT_ONITEMEXTRA))
- break;
- iImage = SendDlgItemMessage(hwndDlg,IDC_CLIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(nm->iColumn,0));
- if (iImage == nullImage)
- iImage = nm->iColumn;
- else if (iImage != EMPTY_EXTRA_ICON)
- iImage = nullImage;
- SetIconsForColumn(GetDlgItem(hwndDlg,IDC_CLIST),hItem,hInfoItem,nm->iColumn,iImage);
- //SetListGroupIcons(GetDlgItem(hwndDlg,IDC_CLIST),(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETNEXTITEM,CLGN_ROOT,0),hInfoItem,NULL);
- break;
- }
- }
- break;
+ switch (((LPNMHDR) lParam)->idFrom) {
+ case IDC_GROUPS:
+ case IDC_STATUSMODES:
+ case IDC_PROTOCOLS:
+ case IDC_CLIST:
+ if (((LPNMHDR) lParam)->code == NM_CLICK || ((LPNMHDR) lParam)->code == CLN_CHECKCHANGED)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_APPLY), TRUE);
- case IDC_TAB:
- if (((LPNMHDR) lParam)->code == TCN_SELCHANGE) {
- int id = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB));
- if (id == 0)
- ShowPage(hwndDlg, 0);
- else
- ShowPage(hwndDlg, 1);
+ if (((LPNMHDR)lParam)->code == NM_CLICK) {
+ NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
+ if (nm->iColumn == -1)
+ break;
+
+ DWORD hitFlags;
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg,IDC_CLIST,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));
+ if (hItem == NULL)
break;
- }
+ if ( !(hitFlags & CLCHT_ONITEMEXTRA))
+ break;
+
+ int iImage = SendDlgItemMessage(hwndDlg,IDC_CLIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(nm->iColumn,0));
+ if (iImage == nullImage)
+ iImage = nm->iColumn;
+ else if (iImage != EMPTY_EXTRA_ICON)
+ iImage = nullImage;
+ SetIconsForColumn(GetDlgItem(hwndDlg,IDC_CLIST),hItem,hInfoItem,nm->iColumn,iImage);
}
break;
+
+ case IDC_TAB:
+ if (((LPNMHDR) lParam)->code == TCN_SELCHANGE) {
+ int id = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB));
+ if (id == 0)
+ ShowPage(hwndDlg, 0);
+ else
+ ShowPage(hwndDlg, 1);
+ break;
+ }
}
+ break;
+
case WM_DESTROY:
ImageList_RemoveAll(himlViewModes);
ImageList_Destroy(himlViewModes);
@@ -994,8 +977,7 @@ static int FillMenuCallback(char *szSetting) if (szSetting[0] == (char)13)
return 1;
- TCHAR * temp;
- mir_utf8decode(szSetting,&temp);
+ TCHAR *temp = mir_utf8decodeT(szSetting);
if (temp) {
AppendMenu(hViewModeMenu, MFT_STRING, menuCounter++, temp);
mir_free(temp);
@@ -1033,7 +1015,7 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM MakeButtonSkinned(hwndSelector);
SendMessage(hwndSelector, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select a view mode"), BATF_TCHAR);
SendMessage(hwndSelector, BUTTONSETMARGINS,0 ,(LPARAM) &rcMargins);
- SendMessage(hwndSelector, BUTTONSETID,0 ,(LPARAM) "ViewMode.Select" );
+ SendMessage(hwndSelector, BUTTONSETID,0 ,(LPARAM) "ViewMode.Select");
SendMessage(hwndSelector, WM_SETFONT,0 ,(LPARAM) FONTID_VIEMODES+1 );
SendMessage(hwndSelector, BUTTONSETASFLATBTN, TRUE, 0 );
SendMessage(hwndSelector, MBM_UPDATETRANSPARENTFLAG, 0, 2);
@@ -1044,7 +1026,7 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM hwnd, (HMENU) IDC_CONFIGUREMODES, g_hInst, NULL);
MakeButtonSkinned(hwndButton);
SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Setup view modes"), BATF_TCHAR);
- SendMessage(hwndButton, BUTTONSETID,0 ,(LPARAM) "ViewMode.Setup" );
+ SendMessage(hwndButton, BUTTONSETID,0 ,(LPARAM) "ViewMode.Setup");
SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0 );
SendMessage(hwndButton, MBM_UPDATETRANSPARENTFLAG, 0, 2);
@@ -1052,14 +1034,16 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM hwnd, (HMENU) IDC_RESETMODES, g_hInst, NULL);
MakeButtonSkinned(hwndButton);
SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear view mode and return to default display"), BATF_TCHAR);
- SendMessage(hwndButton, BUTTONSETID,0 ,(LPARAM) "ViewMode.Clear" );
+ SendMessage(hwndButton, BUTTONSETID,0 ,(LPARAM) "ViewMode.Clear");
SendMessage(hwnd, WM_USER + 100, 0, 0);
SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0 );
SendMessage(hwndButton, MBM_UPDATETRANSPARENTFLAG, 0, 2);
- return FALSE;
}
+ return FALSE;
+
case WM_NCCALCSIZE:
return 18;// FrameNCCalcSize(hwnd, DefWindowProc, wParam, lParam, hasTitleBar);
+
case WM_SIZE:
{
RECT rcCLVMFrame;
@@ -1083,7 +1067,6 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM (LPARAM) RegisterIcolibIconHandle("CLN_CLVM_set", "Contact List",Translate("Setup view modes"), NULL, 0, g_hInst, IDI_SETVIEW ));
{
- // int bSkinned = db_get_b(NULL, "CLCExt", "bskinned", 0);
for (int i=0; _buttons[i] != 0; i++) {
SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, TRUE, 0);
SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN + 10, 0, 0);
@@ -1222,7 +1205,7 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM }
case IDC_RESETMODES:
clvm_reset_command:
- ApplyViewMode( "" );
+ ApplyViewMode("");
break;
case IDC_CONFIGUREMODES:
|