summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-07 21:13:29 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-07 21:13:29 +0000
commit71217fff8d304b8047742e1f8f4612329a2f6044 (patch)
tree022d810958ea6ab39e13eb7fbb4469ae40723716
parent7e78293fcbabc945a8a9e5bcaab121fbbf697c4c (diff)
contact details dialog -> CDlgBase
git-svn-id: http://svn.miranda-ng.org/main/trunk@13481 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--src/modules/clist/clistmod.cpp3
-rw-r--r--src/modules/clist/contacts.cpp230
-rw-r--r--src/resource.rc2
3 files changed, 116 insertions, 119 deletions
diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp
index 8c5ef09b82..75d5014d63 100644
--- a/src/modules/clist/clistmod.cpp
+++ b/src/modules/clist/clistmod.cpp
@@ -25,8 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
#include "clc.h"
-INT_PTR AddMainMenuItem(WPARAM wParam, LPARAM lParam);
-INT_PTR AddContactMenuItem(WPARAM wParam, LPARAM lParam);
INT_PTR ContactChangeGroup(WPARAM wParam, LPARAM lParam);
int InitCListEvents(void);
void UninitCListEvents(void);
@@ -38,7 +36,6 @@ INT_PTR InvalidateDisplayName(WPARAM wParam, LPARAM lParam);
int InitGroupServices(void);
void LoadCluiServices();
INT_PTR Docking_IsDocked(WPARAM wParam, LPARAM lParam);
-void FreeDisplayNameCache(void);
int LoadCLUIModule(void);
int InitClistHotKeys(void);
diff --git a/src/modules/clist/contacts.cpp b/src/modules/clist/contacts.cpp
index 57a4ed5860..711d69dbc5 100644
--- a/src/modules/clist/contacts.cpp
+++ b/src/modules/clist/contacts.cpp
@@ -371,139 +371,139 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) {
return 1;
}
-struct ContactOptionsData {
+class CContactOptsDlg : public CDlgBase
+{
int dragging;
HTREEITEM hDragItem;
-};
-static INT_PTR CALLBACK ContactOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
-{
- struct ContactOptionsData *dat = (struct ContactOptionsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- dat = (struct ContactOptionsData*)mir_alloc(sizeof(struct ContactOptionsData));
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
- dat->dragging = 0;
- SetWindowLongPtr( GetDlgItem(hwndDlg, IDC_NAMEORDER), GWL_STYLE, GetWindowLongPtr( GetDlgItem(hwndDlg, IDC_NAMEORDER), GWL_STYLE)|TVS_NOHSCROLL);
- {
- TVINSERTSTRUCT tvis;
- tvis.hParent = NULL;
- tvis.hInsertAfter = TVI_LAST;
- tvis.item.mask = TVIF_TEXT|TVIF_PARAM;
- for (int i=0; i < SIZEOF(nameOrderDescr); i++) {
- tvis.item.lParam = nameOrder[i];
- tvis.item.pszText = TranslateTS(nameOrderDescr[ nameOrder[i]]);
- TreeView_InsertItem( GetDlgItem(hwndDlg, IDC_NAMEORDER), &tvis);
- }
+ CCtrlTreeView m_nameOrder;
+
+public:
+ CContactOptsDlg() :
+ CDlgBase(hInst, IDD_OPT_CONTACT),
+ m_nameOrder(this, IDC_NAMEORDER)
+ {
+ m_nameOrder.OnBeginDrag = Callback(this, &CContactOptsDlg::OnBeginDrag);
+ }
+
+ virtual void OnInitDialog()
+ {
+ dragging = 0;
+
+ TVINSERTSTRUCT tvis;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_TEXT | TVIF_PARAM;
+ for (int i = 0; i < SIZEOF(nameOrderDescr); i++) {
+ tvis.item.lParam = nameOrder[i];
+ tvis.item.pszText = TranslateTS(nameOrderDescr[nameOrder[i]]);
+ m_nameOrder.InsertItem(&tvis);
+ }
+ }
+
+ virtual void OnApply()
+ {
+ TVITEMEX tvi;
+ tvi.hItem = m_nameOrder.GetRoot();
+ int i = 0;
+ while (tvi.hItem != NULL) {
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE;
+ m_nameOrder.GetItem(&tvi);
+ nameOrder[i++] = (BYTE)tvi.lParam;
+ tvi.hItem = m_nameOrder.GetNextSibling(tvi.hItem);
}
- return TRUE;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- TVITEM tvi;
- tvi.hItem = TreeView_GetRoot( GetDlgItem(hwndDlg, IDC_NAMEORDER));
- int i=0;
- while (tvi.hItem != NULL) {
- tvi.mask = TVIF_PARAM | TVIF_HANDLE;
- TreeView_GetItem( GetDlgItem(hwndDlg, IDC_NAMEORDER), &tvi);
- nameOrder[i++] = (BYTE)tvi.lParam;
- tvi.hItem = TreeView_GetNextSibling( GetDlgItem(hwndDlg, IDC_NAMEORDER), tvi.hItem);
+ db_set_blob(NULL, "Contact", "NameOrder", nameOrder, SIZEOF(nameOrderDescr));
+ CallService(MS_CLIST_INVALIDATEDISPLAYNAME, (WPARAM)INVALID_HANDLE_VALUE, 0);
+ }
+
+ void OnBeginDrag(CCtrlTreeView::TEventInfo *evt)
+ {
+ LPNMTREEVIEW pNotify = evt->nmtv;
+ if (pNotify->itemNew.lParam == 0 || pNotify->itemNew.lParam == SIZEOF(nameOrderDescr) - 1)
+ return;
+
+ SetCapture(m_hwnd);
+ dragging = 1;
+ hDragItem = pNotify->itemNew.hItem;
+ m_nameOrder.SelectItem(hDragItem);
+ }
+
+ virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ switch (msg) {
+ case WM_MOUSEMOVE:
+ if (dragging) {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(m_hwnd, &hti.pt);
+ ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
+ m_nameOrder.HitTest(&hti);
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
+ hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
+ m_nameOrder.HitTest(&hti);
+ m_nameOrder.SetInsertMark(hti.hItem, 1);
+ }
+ else {
+ if (hti.flags & TVHT_ABOVE) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
+ if (hti.flags & TVHT_BELOW) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
+ m_nameOrder.SetInsertMark(NULL, 0);
}
- db_set_blob(NULL, "Contact", "NameOrder", nameOrder, SIZEOF(nameOrderDescr));
- CallService(MS_CLIST_INVALIDATEDISPLAYNAME, (WPARAM)INVALID_HANDLE_VALUE, 0);
}
break;
- case IDC_NAMEORDER:
- if (((LPNMHDR)lParam)->code == TVN_BEGINDRAG) {
- LPNMTREEVIEWA notify = (LPNMTREEVIEWA)lParam;
- if (notify->itemNew.lParam == 0 || notify->itemNew.lParam == SIZEOF(nameOrderDescr)-1)
+ case WM_LBUTTONUP:
+ if (dragging) {
+ m_nameOrder.SetInsertMark(NULL, 0);
+ dragging = 0;
+ ReleaseCapture();
+
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(m_hwnd, &hti.pt);
+ ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
+ hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
+ m_nameOrder.HitTest(&hti);
+ if (hDragItem == hti.hItem)
break;
- SetCapture(hwndDlg);
- dat->dragging = 1;
- dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
- TreeView_SelectItem( GetDlgItem(hwndDlg, IDC_NAMEORDER), dat->hDragItem);
- }
- }
- break;
-
- case WM_MOUSEMOVE:
- if (dat->dragging) {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(hwndDlg, &hti.pt);
- ScreenToClient( GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti.pt);
- TreeView_HitTest( GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti);
- if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) {
- hti.pt.y-=TreeView_GetItemHeight( GetDlgItem(hwndDlg, IDC_NAMEORDER))/2;
- TreeView_HitTest( GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti);
- TreeView_SetInsertMark( GetDlgItem(hwndDlg, IDC_NAMEORDER), hti.hItem, 1);
- }
- else {
- if (hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg, IDC_NAMEORDER, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
- if (hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg, IDC_NAMEORDER, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
- TreeView_SetInsertMark( GetDlgItem(hwndDlg, IDC_NAMEORDER), NULL, 0);
- }
- }
- break;
-
- case WM_LBUTTONUP:
- if (dat->dragging) {
- TreeView_SetInsertMark( GetDlgItem(hwndDlg, IDC_NAMEORDER), NULL, 0);
- dat->dragging = 0;
- ReleaseCapture();
-
- TVHITTESTINFO hti;
- TVITEM tvi;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(hwndDlg, &hti.pt);
- ScreenToClient( GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti.pt);
- hti.pt.y-=TreeView_GetItemHeight( GetDlgItem(hwndDlg, IDC_NAMEORDER))/2;
- TreeView_HitTest( GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti);
- if (dat->hDragItem == hti.hItem) break;
- tvi.mask = TVIF_HANDLE|TVIF_PARAM;
- tvi.hItem = hti.hItem;
- TreeView_GetItem( GetDlgItem(hwndDlg, IDC_NAMEORDER), &tvi);
- if (tvi.lParam == SIZEOF(nameOrderDescr)-1) break;
- if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) {
- TVINSERTSTRUCT tvis;
- TCHAR name[128];
- tvis.item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_PARAM;
- tvis.item.stateMask = 0xFFFFFFFF;
- tvis.item.pszText = name;
- tvis.item.cchTextMax = SIZEOF(name);
- tvis.item.hItem = dat->hDragItem;
- TreeView_GetItem( GetDlgItem(hwndDlg, IDC_NAMEORDER), &tvis.item);
- TreeView_DeleteItem( GetDlgItem(hwndDlg, IDC_NAMEORDER), dat->hDragItem);
- tvis.hParent = NULL;
- tvis.hInsertAfter = hti.hItem;
- TreeView_SelectItem( GetDlgItem(hwndDlg, IDC_NAMEORDER), TreeView_InsertItem( GetDlgItem(hwndDlg, IDC_NAMEORDER), &tvis));
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = hti.hItem;
+ m_nameOrder.GetItem(&tvi);
+ if (tvi.lParam == SIZEOF(nameOrderDescr) - 1)
+ break;
+
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
+ TCHAR name[128];
+ TVINSERTSTRUCT tvis = { 0 };
+ tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_PARAM;
+ tvis.itemex.stateMask = 0xFFFFFFFF;
+ tvis.itemex.pszText = name;
+ tvis.itemex.cchTextMax = SIZEOF(name);
+ tvis.itemex.hItem = hDragItem;
+ m_nameOrder.GetItem(&tvis.itemex);
+ m_nameOrder.DeleteItem(hDragItem);
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = hti.hItem;
+ m_nameOrder.SelectItem(m_nameOrder.InsertItem(&tvis));
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
+ }
}
+ break;
}
- break;
-
- case WM_DESTROY:
- mir_free(dat);
- break;
+ return CDlgBase::DlgProc(msg, wParam, lParam);
}
- return FALSE;
-}
+};
static int ContactOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -1000000000;
- odp.hInstance = hInst;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CONTACT);
odp.pszGroup = LPGEN("Contact list");
odp.pszTitle = LPGEN("Contact names");
- odp.pfnDlgProc = ContactOpts;
+ odp.pDialog = new CContactOptsDlg();
odp.flags = ODPF_BOLDGROUPS;
Options_AddPage(wParam, &odp);
return 0;
@@ -511,7 +511,7 @@ static int ContactOptInit(WPARAM wParam, LPARAM)
int LoadContactsModule(void)
{
- for (BYTE i=0; i < NAMEORDERCOUNT; i++)
+ for (BYTE i = 0; i < NAMEORDERCOUNT; i++)
nameOrder[i] = i;
DBVARIANT dbv;
diff --git a/src/resource.rc b/src/resource.rc
index 370834160b..55f77c2695 100644
--- a/src/resource.rc
+++ b/src/resource.rc
@@ -82,7 +82,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Contact display options",IDC_STATIC,7,7,299,228
CTEXT "Instead of displaying contacts by their nickname,\ndrag to choose another order:",IDC_STATIC,64,39,181,32
- CONTROL "Tree1",IDC_NAMEORDER,"SysTreeView32",TVS_NOTOOLTIPS | TVS_FULLROWSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,65,78,182,93
+ CONTROL "Tree1",IDC_NAMEORDER,"SysTreeView32",TVS_NOHSCROLL | TVS_NOTOOLTIPS | TVS_FULLROWSELECT | WS_BORDER | WS_TABSTOP,65,78,182,93
END
IDD_PROFILEMANAGER DIALOGEX 0, 0, 219, 211