summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-12 21:28:06 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-12 21:28:06 +0000
commita4f715971c8c0f5be8f8fcc8678c7dd57cab0f8e (patch)
tree4bca82393f90685c3c9b3a0420745cf24bd84e28 /src/modules
parentb3742e87f4003a80c13ece74264397b6c137096b (diff)
- CCtrlData::OnChange moved to CCtrlBase, because almost all controls can send change notifications;
- checkbox manager for CCtrlTreeView moved into the core, to remove Windows-dependent code from plugins; - MTREE_CHECKBOX & MTREE_DND flags introduced to turn on predefined behaviors of a tree control - typo fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@13564 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/clist/contacts.cpp108
-rw-r--r--src/modules/clist/genmenuopt.cpp89
-rw-r--r--src/modules/clist/protocolorder.cpp39
3 files changed, 92 insertions, 144 deletions
diff --git a/src/modules/clist/contacts.cpp b/src/modules/clist/contacts.cpp
index d370239c84..204dc3221c 100644
--- a/src/modules/clist/contacts.cpp
+++ b/src/modules/clist/contacts.cpp
@@ -433,66 +433,68 @@ public:
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
+ TVHITTESTINFO hti;
+
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);
+ if (!dragging)
+ break;
+
+ 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);
- 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);
- }
+ 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);
}
break;
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;
-
- 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));
- NotifyChange();
- }
+ if (!dragging)
+ break;
+
+ m_nameOrder.SetInsertMark(NULL, 0);
+ dragging = 0;
+ ReleaseCapture();
+
+ 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;
+
+ 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));
+ NotifyChange();
}
break;
}
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp
index 054ac75072..60f8b6962f 100644
--- a/src/modules/clist/genmenuopt.cpp
+++ b/src/modules/clist/genmenuopt.cpp
@@ -41,7 +41,7 @@ struct MenuItemOptData : public MZeroedObject
ptrT defname;
ptrA uniqname;
- bool bShow, bIsSelected;
+ bool bIsSelected;
int id;
PMO_IntMenuItem pimi;
@@ -65,7 +65,7 @@ class CGenMenuOptionsPage : public CDlgBase
TVITEMEX tvi;
tvi.hItem = m_menuItems.GetRoot();
tvi.cchTextMax = SIZEOF(idstr);
- tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
+ tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE;
tvi.pszText = idstr;
int count = 0;
@@ -87,7 +87,7 @@ class CGenMenuOptionsPage : public CDlgBase
GetMenuItemName(iod->pimi, menuItemName, sizeof(menuItemName));
mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName);
- db_set_b(NULL, MenuNameItems, DBString, iod->bShow);
+ db_set_b(NULL, MenuNameItems, DBString, tvi.iImage != 0);
mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName);
db_set_dw(NULL, MenuNameItems, DBString, runtimepos);
@@ -102,7 +102,7 @@ class CGenMenuOptionsPage : public CDlgBase
runtimepos += 100;
}
- if (iod->name && !_tcscmp(iod->name, STR_SEPARATOR) && iod->bShow)
+ if (iod->name && !_tcscmp(iod->name, STR_SEPARATOR) && tvi.iImage)
runtimepos += SEPARATORPOSITIONINTERVAL;
tvi.hItem = m_menuItems.GetNextSibling(tvi.hItem);
@@ -152,7 +152,14 @@ class CGenMenuOptionsPage : public CDlgBase
char menuItemName[256], MenuNameItems[256];
mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName);
- LIST<MenuItemOptData> arItems(20, NumericKeySortT);
+ m_menuItems.SendMsg(WM_SETREDRAW, FALSE, 0);
+ int lastpos = 0;
+ bool bIsFirst = TRUE;
+
+ TVINSERTSTRUCT tvis;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
for (PMO_IntMenuItem p = pimo->m_items.first; p != NULL; p = p->next) {
if (p->mi.root != (HGENMENU)-1 && p->mi.root != NULL)
@@ -175,7 +182,7 @@ class CGenMenuOptionsPage : public CDlgBase
PD->defname = mir_tstrdup(GetMenuItemText(p));
mir_snprintf(buf, SIZEOF(buf), "%s_visible", menuItemName);
- PD->bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0;
+ int bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0;
if (bReread) {
mir_snprintf(buf, SIZEOF(buf), "%s_pos", menuItemName);
@@ -188,35 +195,21 @@ class CGenMenuOptionsPage : public CDlgBase
if (p->UniqName)
PD->uniqname = mir_strdup(p->UniqName);
- arItems.insert(PD);
- }
-
- m_menuItems.SendMsg(WM_SETREDRAW, FALSE, 0);
- int lastpos = 0;
- bool bIsFirst = TRUE;
+ if (PD->pos - lastpos >= SEPARATORPOSITIONINTERVAL) {
+ MenuItemOptData *sep = new MenuItemOptData();
+ sep->id = -1;
+ sep->name = mir_tstrdup(STR_SEPARATOR);
+ sep->pos = PD->pos - 1;
- TVINSERTSTRUCT tvis;
- tvis.hParent = NULL;
- tvis.hInsertAfter = TVI_LAST;
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- for (int i = 0; i < arItems.getCount(); i++) {
- auto p = arItems[i];
- if (p->pos - lastpos >= SEPARATORPOSITIONINTERVAL) {
- MenuItemOptData *PD = new MenuItemOptData();
- PD->id = -1;
- PD->name = mir_tstrdup(STR_SEPARATOR);
- PD->pos = p->pos - 1;
- PD->bShow = true;
-
- tvis.item.lParam = (LPARAM)PD;
- tvis.item.pszText = PD->name;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow;
+ tvis.item.lParam = (LPARAM)sep;
+ tvis.item.pszText = sep->name;
+ tvis.item.iImage = tvis.item.iSelectedImage = 1;
m_menuItems.InsertItem(&tvis);
}
- tvis.item.lParam = (LPARAM)p;
- tvis.item.pszText = p->name;
- tvis.item.iImage = tvis.item.iSelectedImage = p->bShow;
+ tvis.item.lParam = (LPARAM)PD;
+ tvis.item.pszText = PD->name;
+ tvis.item.iImage = tvis.item.iSelectedImage = bShow;
HTREEITEM hti = m_menuItems.InsertItem(&tvis);
if (bIsFirst) {
@@ -224,7 +217,7 @@ class CGenMenuOptionsPage : public CDlgBase
bIsFirst = false;
}
- lastpos = p->pos;
+ lastpos = PD->pos;
}
m_menuItems.SendMsg(WM_SETREDRAW, TRUE, 0);
@@ -252,7 +245,7 @@ class CGenMenuOptionsPage : public CDlgBase
HTREEITEM MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter)
{
TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
tvi.hItem = hItem;
if (!m_menuItems.GetItem(&tvi))
return NULL;
@@ -268,7 +261,7 @@ class CGenMenuOptionsPage : public CDlgBase
tvis.itemex.pszText = name;
tvis.itemex.cchTextMax = SIZEOF(name);
tvis.itemex.hItem = hItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = ((MenuItemOptData*)tvi.lParam)->bShow;
+ tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
if (!m_menuItems.GetItem(&tvis.itemex))
return NULL;
@@ -309,7 +302,8 @@ public:
m_btnDefault.OnClick = Callback(this, &CGenMenuOptionsPage::btnDefault_Clicked);
m_menuObjects.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuObjectChanged);
-
+
+ m_menuItems.SetFlags(MTREE_CHECKBOX);
m_menuItems.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuItemChanged);
m_menuItems.OnBeginDrag = Callback(this, &CGenMenuOptionsPage::onMenuItemBeginDrag);
}
@@ -386,13 +380,12 @@ public:
MenuItemOptData *PD = new MenuItemOptData();
PD->id = -1;
PD->name = mir_tstrdup(STR_SEPARATOR);
- PD->bShow = true;
PD->pos = ((MenuItemOptData *)tvi.lParam)->pos - 1;
TVINSERTSTRUCT tvis = { 0 };
tvis.item.lParam = (LPARAM)(PD);
tvis.item.pszText = PD->name;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow;
+ tvis.item.iImage = tvis.item.iSelectedImage = 1;
tvis.hInsertAfter = hti;
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
m_menuItems.InsertItem(&tvis);
@@ -559,20 +552,6 @@ public:
return 0;
}
- void OnClickCheckbox(HTREEITEM hItem)
- {
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
- tvi.hItem = hItem;
- m_menuItems.GetItem(&tvi);
-
- tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
- ((MenuItemOptData *)tvi.lParam)->bShow = tvi.iImage != 0;
- m_menuItems.SetItem(&tvi);
-
- NotifyChange();
- }
-
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
TVHITTESTINFO hti;
@@ -669,11 +648,6 @@ public:
SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, onMenuItemDraw((LPNMTVCUSTOMDRAW)phdr));
return TRUE;
- case TVN_KEYDOWN:
- if (((LPNMLVKEYDOWN)phdr)->wVKey == VK_SPACE)
- OnClickCheckbox(m_menuItems.GetSelection());
- break;
-
case NM_CLICK:
TVHITTESTINFO hti;
hti.pt.x = (short)LOWORD(GetMessagePos());
@@ -682,9 +656,6 @@ public:
if (!m_menuItems.HitTest(&hti))
break;
- if (hti.flags & TVHT_ONITEMICON)
- OnClickCheckbox(hti.hItem);
-
/*--------MultiSelection----------*/
if (hti.flags & TVHT_ONITEMLABEL) {
/// LabelClicked Set/unset selection
diff --git a/src/modules/clist/protocolorder.cpp b/src/modules/clist/protocolorder.cpp
index bab4380b61..a454793de3 100644
--- a/src/modules/clist/protocolorder.cpp
+++ b/src/modules/clist/protocolorder.cpp
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct ProtocolData
{
char *RealName;
- int show, enabled;
+ int enabled;
};
int isProtoSuitable(PROTO_INTERFACE* ppi)
@@ -125,11 +125,10 @@ class CProtocolOrderOpts : public CDlgBase
ProtocolData *PD = (ProtocolData*)mir_alloc(sizeof(ProtocolData));
PD->RealName = pa->szModuleName;
PD->enabled = Proto_IsAccountEnabled(pa) && isProtoSuitable(pa->ppro);
- PD->show = PD->enabled ? pa->bIsVisible : 100;
tvis.item.lParam = (LPARAM)PD;
tvis.item.pszText = pa->tszAccountName;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->show;
+ tvis.item.iImage = tvis.item.iSelectedImage = PD->enabled ? pa->bIsVisible : 100;
m_order.InsertItem(&tvis);
}
}
@@ -150,6 +149,7 @@ public:
{
m_btnReset.OnClick = Callback(this, &CProtocolOrderOpts::onReset_Click);
+ m_order.SetFlags(MTREE_CHECKBOX);
m_order.OnBeginDrag = Callback(this, &CProtocolOrderOpts::onOrder_BeginDrag);
m_order.OnDeleteItem = Callback(this, &CProtocolOrderOpts::onOrder_DeleteItem);
}
@@ -170,7 +170,7 @@ public:
TVITEMEX tvi;
tvi.hItem = m_order.GetRoot();
- tvi.mask = TVIF_PARAM | TVIF_HANDLE;
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE;
while (tvi.hItem != NULL) {
m_order.GetItem(&tvi);
@@ -182,7 +182,7 @@ public:
idx++;
pa->iOrder = idx++;
if (ppd->enabled)
- pa->bIsVisible = ppd->show != 0;
+ pa->bIsVisible = tvi.iImage != 0;
}
}
@@ -230,31 +230,6 @@ public:
TVHITTESTINFO hti;
switch (msg) {
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
- case NM_CLICK:
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
- if (m_order.HitTest(&hti)) {
- if (hti.flags & TVHT_ONITEMICON) {
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi.hItem = hti.hItem;
- m_order.GetItem(&tvi);
-
- ProtocolData *pData = (ProtocolData*)tvi.lParam;
- if (pData->enabled) {
- tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
- pData->show = tvi.iImage;
- m_order.SetItem(&tvi);
- NotifyChange();
- }
- }
- }
- }
- break;
-
case WM_MOUSEMOVE:
if (!m_bDragging)
break;
@@ -300,7 +275,7 @@ public:
hti.hItem = TVI_FIRST;
TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
tvi.hItem = m_hDragItem;
m_order.GetItem(&tvi);
if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
@@ -311,7 +286,7 @@ public:
tvis.itemex.pszText = name;
tvis.itemex.cchTextMax = SIZEOF(name);
tvis.itemex.hItem = m_hDragItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = ((ProtocolData *)tvi.lParam)->show;
+ tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
m_order.GetItem(&tvis.itemex);
// the pointed lParam will be freed inside TVN_DELETEITEM