summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin10/lib/mir_core.libbin332978 -> 333380 bytes
-rw-r--r--bin10/lib/mir_core64.libbin334850 -> 335266 bytes
-rw-r--r--bin12/lib/mir_core.libbin332978 -> 333380 bytes
-rw-r--r--bin12/lib/mir_core64.libbin334850 -> 335266 bytes
-rw-r--r--include/m_gui.h2
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/ui_utils.cpp295
-rw-r--r--src/modules/clist/genmenuopt.cpp1186
9 files changed, 629 insertions, 856 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index bdba1abafd..79f1dde7d1 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index 999d4f4d8a..d1cfb15264 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib
index b8da425695..19f99c3631 100644
--- a/bin12/lib/mir_core.lib
+++ b/bin12/lib/mir_core.lib
Binary files differ
diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib
index 999d4f4d8a..a69d7c77e1 100644
--- a/bin12/lib/mir_core64.lib
+++ b/bin12/lib/mir_core64.lib
Binary files differ
diff --git a/include/m_gui.h b/include/m_gui.h
index e86bf71acc..718c388cbc 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -859,6 +859,8 @@ class MIR_CORE_EXPORT CCtrlTreeView : public CCtrlBase
{
typedef CCtrlBase CSuper;
+ HTREEITEM MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter);
+
public:
CCtrlTreeView(CDlgBase *dlg, int ctrlId);
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index d59ce8407b..489473cc41 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1090,3 +1090,4 @@ Proto_RegisterModule @1074 NONAME
?SelectRange@CCtrlTreeView@@QAEXPAU_TREEITEM@@0@Z @1091 NONAME
?Unselect@CCtrlTreeView@@QAEXPAU_TREEITEM@@@Z @1092 NONAME
?UnselectAll@CCtrlTreeView@@QAEXXZ @1093 NONAME
+?MoveItemAbove@CCtrlTreeView@@AAEPAU_TREEITEM@@PAU2@0@Z @1094 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 67bbf17e90..cd8e726c37 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1090,3 +1090,4 @@ Proto_RegisterModule @1074 NONAME
?SelectRange@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@0@Z @1091 NONAME
?Unselect@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@@Z @1092 NONAME
?UnselectAll@CCtrlTreeView@@QEAAXXZ @1093 NONAME
+?MoveItemAbove@CCtrlTreeView@@AEAAPEAU_TREEITEM@@PEAU2@0@Z @1094 NONAME
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp
index 24f2cc5d6d..e2270d0fcb 100644
--- a/src/mir_core/src/ui_utils.cpp
+++ b/src/mir_core/src/ui_utils.cpp
@@ -41,8 +41,8 @@ static LIST<CCtrlBase> arControls(10, CompareControls);
#pragma comment(lib, "uxtheme")
-CDlgBase::CDlgBase(HINSTANCE hInst, int idDialog) :
- m_controls(1, CCtrlBase::cmp)
+CDlgBase::CDlgBase(HINSTANCE hInst, int idDialog)
+ : m_controls(1, CCtrlBase::cmp)
{
m_hInst = hInst;
m_idDialog = idDialog;
@@ -91,7 +91,7 @@ void CDlgBase::SetCaption(const TCHAR *ptszCaption)
int CDlgBase::Resizer(UTILRESIZECONTROL*)
{
- return RD_ANCHORX_LEFT|RD_ANCHORY_TOP;
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
@@ -150,12 +150,11 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (idCode == BN_CLICKED &&
((idCtrl == IDOK) && (m_autoClose & CLOSE_ON_OK) ||
- (idCtrl == IDCANCEL) && (m_autoClose & CLOSE_ON_CANCEL)))
- {
+ (idCtrl == IDCANCEL) && (m_autoClose & CLOSE_ON_CANCEL))) {
PostMessage(m_hwnd, WM_CLOSE, 0, 0);
}
- return FALSE;
}
+ return FALSE;
case WM_NOTIFY:
{
@@ -174,8 +173,8 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (CCtrlBase *ctrl = FindControl(pnmh->idFrom))
return ctrl->OnNotify(idCtrl, pnmh);
- return FALSE;
}
+ return FALSE;
case WM_SIZE:
if (m_forceResizable || (GetWindowLongPtr(m_hwnd, GWL_STYLE) & WS_SIZEBOX)) {
@@ -228,7 +227,7 @@ INT_PTR CALLBACK CDlgBase::GlobalDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA
if (msg == WM_INITDIALOG) {
wnd = (CDlgBase*)lParam;
wnd->m_hwnd = hwnd;
-
+
mir_cslock lck(csDialogs);
arDialogs.insert(wnd);
}
@@ -255,7 +254,7 @@ void CDlgBase::AddControl(CCtrlBase *ctrl)
void CDlgBase::NotifyControls(void (CCtrlBase::*fn)())
{
- for (int i=0; i < m_controls.getCount(); i++)
+ for (int i = 0; i < m_controls.getCount(); i++)
(m_controls[i]->*fn)();
}
@@ -275,10 +274,9 @@ CDlgBase* CDlgBase::Find(HWND hwnd)
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlCombo class
-CCtrlCombo::CCtrlCombo(CDlgBase* dlg, int ctrlId) :
- CCtrlData(dlg, ctrlId)
-{
-}
+CCtrlCombo::CCtrlCombo(CDlgBase* dlg, int ctrlId)
+ : CCtrlData(dlg, ctrlId)
+{}
BOOL CCtrlCombo::OnCommand(HWND, WORD, WORD idCode)
{
@@ -415,9 +413,8 @@ void CCtrlCombo::ShowDropdown(bool show)
// CCtrlListBox class
CCtrlListBox::CCtrlListBox(CDlgBase* dlg, int ctrlId) :
- CCtrlBase(dlg, ctrlId)
-{
-}
+CCtrlBase(dlg, ctrlId)
+{}
BOOL CCtrlListBox::OnCommand(HWND, WORD, WORD idCode)
{
@@ -524,10 +521,9 @@ void CCtrlListBox::SetSel(int index, bool sel)
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlCheck class
-CCtrlCheck::CCtrlCheck(CDlgBase* dlg, int ctrlId) :
- CCtrlData(dlg, ctrlId)
-{
-}
+CCtrlCheck::CCtrlCheck(CDlgBase* dlg, int ctrlId)
+ : CCtrlData(dlg, ctrlId)
+{}
BOOL CCtrlCheck::OnCommand(HWND, WORD, WORD)
{
@@ -558,10 +554,9 @@ void CCtrlCheck::SetState(int state)
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlEdit class
-CCtrlEdit::CCtrlEdit(CDlgBase* dlg, int ctrlId) :
- CCtrlData(dlg, ctrlId)
-{
-}
+CCtrlEdit::CCtrlEdit(CDlgBase* dlg, int ctrlId)
+ : CCtrlData(dlg, ctrlId)
+{}
BOOL CCtrlEdit::OnCommand(HWND, WORD, WORD idCode)
{
@@ -596,11 +591,10 @@ void CCtrlEdit::OnReset()
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlData class
-CCtrlData::CCtrlData(CDlgBase *wnd, int idCtrl) :
- CCtrlBase(wnd, idCtrl),
+CCtrlData::CCtrlData(CDlgBase *wnd, int idCtrl)
+ : CCtrlBase(wnd, idCtrl),
m_dbLink(NULL)
-{
-}
+{}
CCtrlData::~CCtrlData()
{
@@ -627,19 +621,17 @@ void CCtrlData::CreateDbLink(const char* szModuleName, const char* szSetting, TC
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlMButton
-CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, HICON hIcon, const char* tooltip) :
- CCtrlButton(dlg, ctrlId),
+CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, HICON hIcon, const char* tooltip)
+ : CCtrlButton(dlg, ctrlId),
m_hIcon(hIcon),
m_toolTip(tooltip)
-{
-}
+{}
-CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, int iCoreIcon, const char* tooltip) :
- CCtrlButton(dlg, ctrlId),
+CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, int iCoreIcon, const char* tooltip)
+ : CCtrlButton(dlg, ctrlId),
m_hIcon(::LoadSkinnedIcon(iCoreIcon)),
m_toolTip(tooltip)
-{
-}
+{}
CCtrlMButton::~CCtrlMButton()
{
@@ -668,10 +660,9 @@ void CCtrlMButton::MakePush()
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlButton
-CCtrlButton::CCtrlButton(CDlgBase* wnd, int idCtrl) :
- CCtrlBase(wnd, idCtrl)
-{
-}
+CCtrlButton::CCtrlButton(CDlgBase* wnd, int idCtrl)
+ : CCtrlBase(wnd, idCtrl)
+{}
BOOL CCtrlButton::OnCommand(HWND, WORD, WORD idCode)
{
@@ -683,11 +674,10 @@ BOOL CCtrlButton::OnCommand(HWND, WORD, WORD idCode)
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlHyperlink
-CCtrlHyperlink::CCtrlHyperlink(CDlgBase* wnd, int idCtrl, const char* url) :
- CCtrlBase(wnd, idCtrl),
+CCtrlHyperlink::CCtrlHyperlink(CDlgBase* wnd, int idCtrl, const char* url)
+ : CCtrlBase(wnd, idCtrl),
m_url(url)
-{
-}
+{}
BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD)
{
@@ -697,10 +687,9 @@ BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD)
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlClc
-CCtrlClc::CCtrlClc(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId)
-{
-}
+CCtrlClc::CCtrlClc(CDlgBase* dlg, int ctrlId)
+ : CCtrlBase(dlg, ctrlId)
+{}
BOOL CCtrlClc::OnNotify(int, NMHDR *pnmh)
{
@@ -910,10 +899,9 @@ void CCtrlClc::SetTextColor(int iFontId, COLORREF clText)
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlListView
-CCtrlListView::CCtrlListView(CDlgBase* dlg, int ctrlId) :
- CCtrlBase(dlg, ctrlId)
-{
-}
+CCtrlListView::CCtrlListView(CDlgBase* dlg, int ctrlId)
+ : CCtrlBase(dlg, ctrlId)
+{}
BOOL CCtrlListView::OnNotify(int, NMHDR *pnmh)
{
@@ -933,7 +921,6 @@ BOOL CCtrlListView::OnNotify(int, NMHDR *pnmh)
case LVN_GETDISPINFO: OnGetDispInfo(&evt); return TRUE;
case LVN_GETINFOTIP: OnGetInfoTip(&evt); return TRUE;
case LVN_HOTTRACK: OnHotTrack(&evt); return TRUE;
- //case LVN_INCREMENTALSEARCH: OnIncrementalSearch(&evt); return TRUE;
case LVN_INSERTITEM: OnInsertItem(&evt); return TRUE;
case LVN_ITEMACTIVATE: OnItemActivate(&evt); return TRUE;
case LVN_ITEMCHANGED: OnItemChanged(&evt); return TRUE;
@@ -971,7 +958,7 @@ void CCtrlListView::AddColumn(int iSubItem, TCHAR *name, int cx)
void CCtrlListView::AddGroup(int iGroupId, TCHAR *name)
{
- LVGROUP lvg = {0};
+ LVGROUP lvg = { 0 };
lvg.cbSize = sizeof(lvg);
lvg.mask = LVGF_HEADER | LVGF_GROUPID;
lvg.pszHeader = name;
@@ -982,7 +969,7 @@ void CCtrlListView::AddGroup(int iGroupId, TCHAR *name)
int CCtrlListView::AddItem(TCHAR *text, int iIcon, LPARAM lParam, int iGroupId)
{
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE;
lvi.iSubItem = 0;
lvi.pszText = text;
@@ -998,7 +985,7 @@ int CCtrlListView::AddItem(TCHAR *text, int iIcon, LPARAM lParam, int iGroupId)
void CCtrlListView::SetItem(int iItem, int iSubItem, TCHAR *text, int iIcon)
{
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_TEXT;
lvi.iItem = iItem;
lvi.iSubItem = iSubItem;
@@ -1013,7 +1000,7 @@ void CCtrlListView::SetItem(int iItem, int iSubItem, TCHAR *text, int iIcon)
LPARAM CCtrlListView::GetItemData(int iItem)
{
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM;
lvi.iItem = iItem;
GetItem(&lvi);
@@ -1364,11 +1351,10 @@ BOOL CCtrlListView::Update(int iItem)
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlTreeView
-CCtrlTreeView::CCtrlTreeView(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId),
+CCtrlTreeView::CCtrlTreeView(CDlgBase* dlg, int ctrlId)
+ : CCtrlBase(dlg, ctrlId),
m_dwFlags(0)
-{
-}
+{}
void CCtrlTreeView::SetFlags(uint32_t dwFlags)
{
@@ -1393,6 +1379,45 @@ void CCtrlTreeView::OnInit()
Subclass();
}
+HTREEITEM CCtrlTreeView::MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter)
+{
+ TVITEMEX tvi = { 0 };
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
+ tvi.hItem = hItem;
+ if (!GetItem(&tvi))
+ return NULL;
+
+ if (hItem == NULL || hInsertAfter == NULL)
+ return NULL;
+
+ if (hItem == hInsertAfter)
+ return hItem;
+
+ TCHAR name[128];
+ TVINSERTSTRUCT tvis = { 0 };
+ tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ tvis.itemex.pszText = name;
+ tvis.itemex.cchTextMax = SIZEOF(name);
+ tvis.itemex.hItem = hItem;
+ tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
+ if (!GetItem(&tvis.itemex))
+ return NULL;
+
+ // the pointed lParam will be freed inside TVN_DELETEITEM
+ // so lets substitute it with 0
+ LPARAM saveOldData = tvis.itemex.lParam;
+ tvis.itemex.lParam = 0;
+ SetItem(&tvis.itemex);
+
+ // now current item contain lParam = 0 we can delete it. the memory will be kept.
+ DeleteItem(hItem);
+
+ tvis.itemex.lParam = saveOldData;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = hInsertAfter;
+ return InsertItem(&tvis);
+}
+
LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
TVHITTESTINFO hti;
@@ -1437,37 +1462,27 @@ LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
else if (hti.flags & TVHT_BELOW)
hti.hItem = TVI_LAST;
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
- tvi.hItem = m_hDragItem;
- GetItem(&tvi);
- if ((hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || hti.hItem == TVI_FIRST) {
- TCHAR name[128];
- TVINSERTSTRUCT tvis = { 0 };
- tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvis.itemex.stateMask = 0xFFFFFFFF;
- tvis.itemex.pszText = name;
- tvis.itemex.cchTextMax = SIZEOF(name);
- tvis.itemex.hItem = m_hDragItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
- GetItem(&tvis.itemex);
-
- // the pointed lParam will be freed inside TVN_DELETEITEM
- // so lets substitute it with 0
- LPARAM saveOldData = tvis.itemex.lParam;
- tvis.itemex.lParam = 0;
- SetItem(&tvis.itemex);
-
- // now current item contain lParam = 0 we can delete it. the memory will be kept.
- tvis.itemex.lParam = saveOldData;
- DeleteItem(m_hDragItem);
-
- tvis.hParent = NULL;
- tvis.hInsertAfter = hti.hItem;
- SelectItem(InsertItem(&tvis));
+ HTREEITEM FirstItem = NULL;
+ if (m_bMultiSelect) {
+ LIST<_TREEITEM> arItems(10);
+ GetSelected(arItems);
- NotifyChange();
+ // Proceed moving
+ HTREEITEM insertAfter = hti.hItem;
+ for (int i = 0; i < arItems.getCount(); i++) {
+ if (!insertAfter)
+ break;
+
+ insertAfter = MoveItemAbove(arItems[i], insertAfter);
+ if (!i)
+ FirstItem = insertAfter;
+ }
}
+ else FirstItem = MoveItemAbove(m_hDragItem, hti.hItem);
+ if (FirstItem)
+ SelectItem(FirstItem);
+
+ NotifyChange();
}
break;
@@ -1482,11 +1497,12 @@ LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
- if (!(wParam & (MK_CONTROL | MK_SHIFT)) || !(hti.flags & (TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMRIGHT))) {
- UnselectAll();
- TreeView_SelectItem(m_hwnd, hti.hItem);
- break;
- }
+ if (!m_bDndEnabled)
+ if (!(wParam & (MK_CONTROL | MK_SHIFT)) || !(hti.flags & (TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMRIGHT))) {
+ UnselectAll();
+ TreeView_SelectItem(m_hwnd, hti.hItem);
+ break;
+ }
if (wParam & MK_CONTROL) {
LIST<_TREEITEM> selected(1);
@@ -1524,7 +1540,7 @@ LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
Select(selected);
SelectRange(hItem, hti.hItem);
}
- return 0;
+ break;
}
return CSuper::CustomWndProc(msg, wParam, lParam);
@@ -1553,19 +1569,19 @@ BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh)
// user-defined can clear the event code to disable dragging
if (m_bDndEnabled && pnmh->code) {
- ::SetCapture(m_hwnd);
- m_bDragging = true;
- m_hDragItem = evt.nmtv->itemNew.hItem;
- SelectItem(m_hDragItem);
- }
+ ::SetCapture(m_hwnd);
+ m_bDragging = true;
+ m_hDragItem = evt.nmtv->itemNew.hItem;
+ SelectItem(m_hDragItem);
+ }
return TRUE;
case TVN_KEYDOWN:
if (evt.nmtvkey->wVKey == VK_SPACE) {
if (m_bCheckBox)
- InvertCheck(GetSelection());
+ InvertCheck(GetSelection());
NotifyChange();
- }
+ }
OnKeyDown(&evt);
return TRUE;
@@ -1575,14 +1591,14 @@ BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh)
TVHITTESTINFO hti;
hti.pt.x = (short)LOWORD(GetMessagePos());
hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(pnmh->hwndFrom, &hti.pt);
- if (HitTest(&hti)) {
- if (m_bCheckBox && (hti.flags & TVHT_ONITEMICON) || !m_bCheckBox && (hti.flags & TVHT_ONITEMSTATEICON)) {
- if (m_bCheckBox)
- InvertCheck(hti.hItem);
+ ScreenToClient(pnmh->hwndFrom, &hti.pt);
+ if (HitTest(&hti)) {
+ if (m_bCheckBox && (hti.flags & TVHT_ONITEMICON) || !m_bCheckBox && (hti.flags & TVHT_ONITEMSTATEICON)) {
+ if (m_bCheckBox)
+ InvertCheck(hti.hItem);
NotifyChange();
}
- }
+ }
}
return FALSE;
@@ -1590,14 +1606,14 @@ BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh)
void CCtrlTreeView::InvertCheck(HTREEITEM hItem)
{
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
- tvi.hItem = hItem;
- if (!GetItem(&tvi))
- return;
-
- tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
- SetItem(&tvi);
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+ tvi.hItem = hItem;
+ if (!GetItem(&tvi))
+ return;
+
+ tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
+ SetItem(&tvi);
}
void CCtrlTreeView::TranslateItem(HTREEITEM hItem)
@@ -1635,7 +1651,7 @@ void CCtrlTreeView::TranslateTree()
HTREEITEM CCtrlTreeView::FindNamedItem(HTREEITEM hItem, const TCHAR *name)
{
- TVITEMEX tvi = {0};
+ TVITEMEX tvi = { 0 };
TCHAR str[MAX_PATH];
if (hItem)
@@ -1664,7 +1680,7 @@ HTREEITEM CCtrlTreeView::FindNamedItem(HTREEITEM hItem, const TCHAR *name)
void CCtrlTreeView::GetItem(HTREEITEM hItem, TVITEMEX *tvi)
{
memset(tvi, 0, sizeof(*tvi));
- tvi->mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_IMAGE|TVIF_INTEGRAL|TVIF_PARAM|TVIF_SELECTEDIMAGE|TVIF_STATE;
+ tvi->mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_INTEGRAL | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_STATE;
tvi->hItem = hItem;
GetItem(tvi);
}
@@ -1672,7 +1688,7 @@ void CCtrlTreeView::GetItem(HTREEITEM hItem, TVITEMEX *tvi)
void CCtrlTreeView::GetItem(HTREEITEM hItem, TVITEMEX *tvi, TCHAR *szText, int iTextLength)
{
memset(tvi, 0, sizeof(*tvi));
- tvi->mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_IMAGE|TVIF_INTEGRAL|TVIF_PARAM|TVIF_SELECTEDIMAGE|TVIF_STATE|TVIF_TEXT;
+ tvi->mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_INTEGRAL | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_STATE | TVIF_TEXT;
tvi->hItem = hItem;
tvi->pszText = szText;
tvi->cchTextMax = iTextLength;
@@ -1728,9 +1744,7 @@ void CCtrlTreeView::UnselectAll()
void CCtrlTreeView::SelectRange(HTREEITEM hStart, HTREEITEM hEnd)
{
- int start = 0;
- int end = 0;
- int i = 0;
+ int start = 0, end = 0, i = 0;
HTREEITEM hItem = TreeView_GetRoot(m_hwnd);
while (hItem) {
if (hItem == hStart)
@@ -2025,10 +2039,11 @@ void CCtrlTreeView::SortChildrenCB(TVSORTCB *cb, BOOL fRecurse)
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlPages
-CCtrlPages::CCtrlPages(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId), m_hIml(NULL), m_pActivePage(NULL)
-{
-}
+CCtrlPages::CCtrlPages(CDlgBase* dlg, int ctrlId)
+ : CCtrlBase(dlg, ctrlId),
+ m_hIml(NULL),
+ m_pActivePage(NULL)
+{}
void CCtrlPages::OnInit()
{
@@ -2082,11 +2097,14 @@ void CCtrlPages::AttachDialog(int iPage, CDlgBase *pDlg)
info->m_pDlg->Close();
info->m_pDlg = pDlg;
- //SetParent(info->m_pDlg->GetHwnd(), m_hwnd);
+ if (pDlg->GetHwnd() == NULL) {
+ pDlg->SetParent(m_hwnd);
+ pDlg->Create();
+ }
if (iPage == TabCtrl_GetCurSel(m_hwnd)) {
- m_pActivePage = info->m_pDlg;
- ShowPage(info->m_pDlg);
+ m_pActivePage = pDlg;
+ ShowPage(pDlg);
}
}
}
@@ -2098,14 +2116,14 @@ void CCtrlPages::ShowPage(CDlgBase *pDlg)
RECT rc;
GetClientRect(m_hwnd, &rc);
TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
- MapWindowPoints(m_hwnd, ::GetParent(m_hwnd), (LPPOINT)&rc, 2);
- SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
+
+ EnableThemeDialogTexture(pDlg->GetHwnd(), ETDT_ENABLETAB);
+ SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
void CCtrlPages::ActivatePage(int iPage)
{
TabCtrl_SetCurSel(m_hwnd, iPage);
- //ShowPage(iPage);
}
BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
@@ -2205,8 +2223,7 @@ void CCtrlBase::OnApply()
}
void CCtrlBase::OnReset()
-{
-}
+{}
void CCtrlBase::Enable(int bIsEnable)
{
@@ -2222,7 +2239,7 @@ void CCtrlBase::NotifyChange()
{
if (!m_parentWnd || m_parentWnd->IsInitialized())
m_bChanged = true;
-
+
if (m_parentWnd) {
m_parentWnd->OnChange(this);
if (m_parentWnd->IsInitialized())
@@ -2405,8 +2422,7 @@ CProtoIntDlgBase::CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, bool sh
m_proto_interface(proto),
m_show_label(show_label),
m_hwndStatus(NULL)
-{
-}
+{}
void CProtoIntDlgBase::CreateLink(CCtrlData& ctrl, char *szSetting, BYTE type, DWORD iValue)
{
@@ -2490,7 +2506,8 @@ INT_PTR CProtoIntDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
void CProtoIntDlgBase::UpdateProtoTitle(const TCHAR *szText)
{
- if (!m_show_label) return;
+ if (!m_show_label)
+ return;
int curLength;
const TCHAR *curText;
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp
index 6463a68ddb..31f80cc40c 100644
--- a/src/modules/clist/genmenuopt.cpp
+++ b/src/modules/clist/genmenuopt.cpp
@@ -1,722 +1,474 @@
-/*
-
-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 "genmenu.h"
-
-#define STR_SEPARATOR _T("-----------------------------------")
-
-extern bool bIconsDisabled;
-extern int DefaultImageListColorDepth;
-void RebuildProtoMenus(int);
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-struct MenuItemOptData : public MZeroedObject
-{
- ~MenuItemOptData() {}
-
- int pos;
-
- ptrT name;
- ptrT defname;
- ptrA uniqname;
-
- bool bShow, bIsSelected;
- int id;
-
- PMO_IntMenuItem pimi;
-};
-
-static int SortMenuItems(const MenuItemOptData *p1, const MenuItemOptData *p2)
-{
- if (p1->pos < p2->pos) return -1;
- if (p1->pos > p2->pos) return 1;
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-class CGenMenuOptionsPage : public CDlgBase
-{
- int m_bDragging;
- int iInitMenuValue;
-
- HTREEITEM m_hDragItem;
-
- void SaveTree()
- {
- int MenuObjectId;
- if (!GetCurrentMenuObjectID(MenuObjectId))
- return;
-
- TCHAR idstr[100];
-
- TVITEMEX tvi;
- tvi.hItem = m_menuItems.GetRoot();
- tvi.cchTextMax = SIZEOF(idstr);
- tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE;
- tvi.pszText = idstr;
-
- int count = 0;
- int menupos = GetMenuObjbyId(MenuObjectId);
- if (menupos == -1)
- return;
-
- TIntMenuObject *pimo = g_menus[menupos];
-
- char MenuNameItems[256];
- mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName);
- int runtimepos = 100;
-
- while (tvi.hItem != NULL) {
- m_menuItems.GetItem(&tvi);
- MenuItemOptData *iod = (MenuItemOptData*)tvi.lParam;
- if (iod->pimi) {
- char menuItemName[256], DBString[300];
- GetMenuItemName(iod->pimi, menuItemName, sizeof(menuItemName));
-
- mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName);
- db_set_b(NULL, MenuNameItems, DBString, tvi.iImage != 0);
-
- mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName);
- db_set_dw(NULL, MenuNameItems, DBString, runtimepos);
-
- mir_snprintf(DBString, SIZEOF(DBString), "%s_name", menuItemName);
- if (iod->name != NULL && iod->defname != NULL &&
- mir_tstrcmp(iod->name, iod->defname) != 0)
- db_set_ts(NULL, MenuNameItems, DBString, iod->name);
- else
- db_unset(NULL, MenuNameItems, DBString);
-
- runtimepos += 100;
- }
-
- if (iod->name && !_tcscmp(iod->name, STR_SEPARATOR) && tvi.iImage)
- runtimepos += SEPARATORPOSITIONINTERVAL;
-
- tvi.hItem = m_menuItems.GetNextSibling(tvi.hItem);
- count++;
- }
- }
-
- void FreeTreeData()
- {
- HTREEITEM hItem = m_menuItems.GetRoot();
- while (hItem != NULL) {
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hItem;
- m_menuItems.GetItem(&tvi);
- delete (MenuItemOptData *)tvi.lParam;
-
- tvi.lParam = 0;
- m_menuItems.SetItem(&tvi);
-
- hItem = m_menuItems.GetNextSibling(hItem);
- }
- }
-
- void RebuildCurrent()
- {
- int MenuObjectID;
- if (GetCurrentMenuObjectID(MenuObjectID))
- BuildTree(MenuObjectID, true);
- }
-
- bool BuildTree(int MenuObjectId, bool bReread)
- {
- char buf[256];
-
- FreeTreeData();
- m_menuItems.DeleteAllItems();
-
- int menupos = GetMenuObjbyId(MenuObjectId);
- if (menupos == -1)
- return false;
-
- TIntMenuObject* pimo = g_menus[menupos];
- if (pimo->m_items.first == NULL)
- return false;
-
- char menuItemName[256], MenuNameItems[256];
- mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName);
-
- LIST<MenuItemOptData> arItems(10, SortMenuItems);
-
- for (PMO_IntMenuItem p = pimo->m_items.first; p != NULL; p = p->next) {
- if (p->mi.root != (HGENMENU)-1 && p->mi.root != NULL)
- continue;
-
- MenuItemOptData *PD = new MenuItemOptData();
- GetMenuItemName(p, menuItemName, sizeof(menuItemName));
- {
- DBVARIANT dbv;
- mir_snprintf(buf, SIZEOF(buf), "%s_name", menuItemName);
-
- if (!db_get_ts(NULL, MenuNameItems, buf, &dbv)) {
- PD->name = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- else PD->name = mir_tstrdup(GetMenuItemText(p));
- }
-
- PD->pimi = p;
- PD->defname = mir_tstrdup(GetMenuItemText(p));
-
- mir_snprintf(buf, SIZEOF(buf), "%s_visible", menuItemName);
- PD->bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0;
-
- if (bReread) {
- mir_snprintf(buf, SIZEOF(buf), "%s_pos", menuItemName);
- PD->pos = db_get_dw(NULL, MenuNameItems, buf, 1);
- }
- else PD->pos = (PD->pimi) ? PD->pimi->originalPosition : 0;
-
- PD->id = p->iCommand;
-
- 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;
-
- 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++) {
- MenuItemOptData *PD = arItems[i];
- if (PD->pos - lastpos >= SEPARATORPOSITIONINTERVAL) {
- MenuItemOptData *sep = new MenuItemOptData();
- sep->id = -1;
- sep->name = mir_tstrdup(STR_SEPARATOR);
- sep->pos = PD->pos - 1;
-
- 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)PD;
- tvis.item.pszText = PD->name;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow;
-
- HTREEITEM hti = m_menuItems.InsertItem(&tvis);
- if (bIsFirst) {
- m_menuItems.SelectItem(hti);
- bIsFirst = false;
- }
-
- lastpos = PD->pos;
- }
-
- m_menuItems.SendMsg(WM_SETREDRAW, TRUE, 0);
-
- ShowWindow(m_warning.GetHwnd(), (pimo->m_bUseUserDefinedItems) ? SW_HIDE : SW_SHOW);
- m_menuItems.Enable(pimo->m_bUseUserDefinedItems);
- m_btnInsert.Enable(pimo->m_bUseUserDefinedItems);
- return 1;
- }
-
- bool GetCurrentMenuObjectID(int &result)
- {
- int iItem = m_menuObjects.GetCurSel();
- if (iItem == -1)
- return false;
-
- result = (int)m_menuObjects.GetItemData(iItem);
- return true;
- }
-
- HTREEITEM MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter)
- {
- TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
- tvi.hItem = hItem;
- if (!m_menuItems.GetItem(&tvi))
- return NULL;
-
- if (hItem && hInsertAfter) {
- TCHAR name[128];
- if (hItem == hInsertAfter)
- return hItem;
-
- TVINSERTSTRUCT tvis = { 0 };
- tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvis.itemex.stateMask = 0xFFFFFFFF;
- tvis.itemex.pszText = name;
- tvis.itemex.cchTextMax = SIZEOF(name);
- tvis.itemex.hItem = hItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
- if (!m_menuItems.GetItem(&tvis.itemex))
- return NULL;
-
- m_menuItems.DeleteItem(hItem);
-
- tvis.hParent = NULL;
- tvis.hInsertAfter = hInsertAfter;
- return m_menuItems.InsertItem(&tvis);
- }
- return NULL;
- }
-
- CCtrlListBox m_menuObjects;
- CCtrlTreeView m_menuItems;
- CCtrlCheck m_radio1, m_radio2, m_disableIcons;
- CCtrlEdit m_customName, m_service;
- CCtrlButton m_btnInsert, m_btnReset, m_btnSet, m_btnDefault;
- CCtrlBase m_warning;
-
-public:
- CGenMenuOptionsPage() :
- CDlgBase(hInst, IDD_OPT_GENMENU),
- m_menuItems(this, IDC_MENUITEMS),
- m_menuObjects(this, IDC_MENUOBJECTS),
- m_radio1(this, IDC_RADIO1),
- m_radio2(this, IDC_RADIO2),
- m_disableIcons(this, IDC_DISABLEMENUICONS),
- m_btnInsert(this, IDC_INSERTSEPARATOR),
- m_btnReset(this, IDC_RESETMENU),
- m_btnSet(this, IDC_GENMENU_SET),
- m_btnDefault(this, IDC_GENMENU_DEFAULT),
- m_customName(this, IDC_GENMENU_CUSTOMNAME),
- m_service(this, IDC_GENMENU_SERVICE),
- m_warning(this, IDC_NOTSUPPORTWARNING)
- {
- m_btnSet.OnClick = Callback(this, &CGenMenuOptionsPage::btnSet_Clicked);
- m_btnReset.OnClick = Callback(this, &CGenMenuOptionsPage::btnReset_Clicked);
- m_btnInsert.OnClick = Callback(this, &CGenMenuOptionsPage::btnInsert_Clicked);
- m_btnDefault.OnClick = Callback(this, &CGenMenuOptionsPage::btnDefault_Clicked);
-
- m_menuObjects.OnSelChange = Callback(this, &CGenMenuOptionsPage::onMenuObjectChanged);
-
- m_menuItems.SetFlags(MTREE_CHECKBOX);
- m_menuItems.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuItemChanged);
- m_menuItems.OnBeginDrag = Callback(this, &CGenMenuOptionsPage::onMenuItemBeginDrag);
- }
-
- //---- init dialog -------------------------------------------
- virtual void OnInitDialog()
- {
- m_bDragging = 0;
- iInitMenuValue = db_get_b(NULL, "CList", "MoveProtoMenus", TRUE);
-
- HIMAGELIST himlCheckBoxes = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
- ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_NOTICK);
- ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_TICK);
- m_menuItems.SetImageList(himlCheckBoxes, TVSIL_NORMAL);
-
- if (iInitMenuValue)
- m_radio2.SetState(true);
- else
- m_radio1.SetState(true);
-
- m_disableIcons.SetState(bIconsDisabled ? BST_UNCHECKED : BST_CHECKED);
-
- //---- init menu object list --------------------------------------
- for (int i = 0; i < g_menus.getCount(); i++) {
- TIntMenuObject *p = g_menus[i];
- if (p->id != (int)hStatusMenuObject && p->m_bUseUserDefinedItems)
- m_menuObjects.AddString(TranslateTS(p->ptszDisplayName), p->id);
- }
-
- m_menuObjects.SetCurSel(0);
- RebuildCurrent();
- }
-
- virtual void OnApply()
- {
- bIconsDisabled = m_disableIcons.GetState() == 0;
- db_set_b(NULL, "CList", "DisableMenuIcons", bIconsDisabled);
- SaveTree();
-
- int iNewMenuValue = !m_radio1.GetState();
- if (iNewMenuValue != iInitMenuValue) {
+/*
+
+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 "genmenu.h"
+
+#define STR_SEPARATOR _T("-----------------------------------")
+
+extern bool bIconsDisabled;
+extern int DefaultImageListColorDepth;
+void RebuildProtoMenus(int);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct MenuItemOptData : public MZeroedObject
+{
+ ~MenuItemOptData() {}
+
+ int pos;
+
+ ptrT name;
+ ptrT defname;
+ ptrA uniqname;
+
+ bool bShow;
+ int id;
+
+ PMO_IntMenuItem pimi;
+};
+
+static int SortMenuItems(const MenuItemOptData *p1, const MenuItemOptData *p2)
+{
+ if (p1->pos < p2->pos) return -1;
+ if (p1->pos > p2->pos) return 1;
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+class CGenMenuOptionsPage : public CDlgBase
+{
+ int iInitMenuValue;
+
+ void SaveTree()
+ {
+ int MenuObjectId;
+ if (!GetCurrentMenuObjectID(MenuObjectId))
+ return;
+
+ TCHAR idstr[100];
+
+ TVITEMEX tvi;
+ tvi.hItem = m_menuItems.GetRoot();
+ tvi.cchTextMax = SIZEOF(idstr);
+ tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE;
+ tvi.pszText = idstr;
+
+ int count = 0;
+ int menupos = GetMenuObjbyId(MenuObjectId);
+ if (menupos == -1)
+ return;
+
+ TIntMenuObject *pimo = g_menus[menupos];
+
+ char MenuNameItems[256];
+ mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName);
+ int runtimepos = 100;
+
+ while (tvi.hItem != NULL) {
+ m_menuItems.GetItem(&tvi);
+ MenuItemOptData *iod = (MenuItemOptData*)tvi.lParam;
+ if (iod->pimi) {
+ char menuItemName[256], DBString[300];
+ GetMenuItemName(iod->pimi, menuItemName, sizeof(menuItemName));
+
+ mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName);
+ db_set_b(NULL, MenuNameItems, DBString, tvi.iImage != 0);
+
+ mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName);
+ db_set_dw(NULL, MenuNameItems, DBString, runtimepos);
+
+ mir_snprintf(DBString, SIZEOF(DBString), "%s_name", menuItemName);
+ if (iod->name != NULL && iod->defname != NULL &&
+ mir_tstrcmp(iod->name, iod->defname) != 0)
+ db_set_ts(NULL, MenuNameItems, DBString, iod->name);
+ else
+ db_unset(NULL, MenuNameItems, DBString);
+
+ runtimepos += 100;
+ }
+
+ if (iod->name && !_tcscmp(iod->name, STR_SEPARATOR) && tvi.iImage)
+ runtimepos += SEPARATORPOSITIONINTERVAL;
+
+ tvi.hItem = m_menuItems.GetNextSibling(tvi.hItem);
+ count++;
+ }
+ }
+
+ void FreeTreeData()
+ {
+ HTREEITEM hItem = m_menuItems.GetRoot();
+ while (hItem != NULL) {
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = hItem;
+ m_menuItems.GetItem(&tvi);
+ delete (MenuItemOptData *)tvi.lParam;
+
+ tvi.lParam = 0;
+ m_menuItems.SetItem(&tvi);
+
+ hItem = m_menuItems.GetNextSibling(hItem);
+ }
+ }
+
+ void RebuildCurrent()
+ {
+ int MenuObjectID;
+ if (GetCurrentMenuObjectID(MenuObjectID))
+ BuildTree(MenuObjectID, true);
+ }
+
+ bool BuildTree(int MenuObjectId, bool bReread)
+ {
+ char buf[256];
+
+ FreeTreeData();
+ m_menuItems.DeleteAllItems();
+
+ int menupos = GetMenuObjbyId(MenuObjectId);
+ if (menupos == -1)
+ return false;
+
+ TIntMenuObject* pimo = g_menus[menupos];
+ if (pimo->m_items.first == NULL)
+ return false;
+
+ char menuItemName[256], MenuNameItems[256];
+ mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName);
+
+ LIST<MenuItemOptData> arItems(10, SortMenuItems);
+
+ for (PMO_IntMenuItem p = pimo->m_items.first; p != NULL; p = p->next) {
+ if (p->mi.root != (HGENMENU)-1 && p->mi.root != NULL)
+ continue;
+
+ MenuItemOptData *PD = new MenuItemOptData();
+ GetMenuItemName(p, menuItemName, sizeof(menuItemName));
+ {
+ DBVARIANT dbv;
+ mir_snprintf(buf, SIZEOF(buf), "%s_name", menuItemName);
+
+ if (!db_get_ts(NULL, MenuNameItems, buf, &dbv)) {
+ PD->name = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else PD->name = mir_tstrdup(GetMenuItemText(p));
+ }
+
+ PD->pimi = p;
+ PD->defname = mir_tstrdup(GetMenuItemText(p));
+
+ mir_snprintf(buf, SIZEOF(buf), "%s_visible", menuItemName);
+ PD->bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0;
+
+ if (bReread) {
+ mir_snprintf(buf, SIZEOF(buf), "%s_pos", menuItemName);
+ PD->pos = db_get_dw(NULL, MenuNameItems, buf, 1);
+ }
+ else PD->pos = (PD->pimi) ? PD->pimi->originalPosition : 0;
+
+ PD->id = p->iCommand;
+
+ 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;
+
+ 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++) {
+ MenuItemOptData *PD = arItems[i];
+ if (PD->pos - lastpos >= SEPARATORPOSITIONINTERVAL) {
+ MenuItemOptData *sep = new MenuItemOptData();
+ sep->id = -1;
+ sep->name = mir_tstrdup(STR_SEPARATOR);
+ sep->pos = PD->pos - 1;
+
+ 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)PD;
+ tvis.item.pszText = PD->name;
+ tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow;
+
+ HTREEITEM hti = m_menuItems.InsertItem(&tvis);
+ if (bIsFirst) {
+ m_menuItems.SelectItem(hti);
+ bIsFirst = false;
+ }
+
+ lastpos = PD->pos;
+ }
+
+ m_menuItems.SendMsg(WM_SETREDRAW, TRUE, 0);
+
+ ShowWindow(m_warning.GetHwnd(), (pimo->m_bUseUserDefinedItems) ? SW_HIDE : SW_SHOW);
+ m_menuItems.Enable(pimo->m_bUseUserDefinedItems);
+ m_btnInsert.Enable(pimo->m_bUseUserDefinedItems);
+ return 1;
+ }
+
+ bool GetCurrentMenuObjectID(int &result)
+ {
+ int iItem = m_menuObjects.GetCurSel();
+ if (iItem == -1)
+ return false;
+
+ result = (int)m_menuObjects.GetItemData(iItem);
+ return true;
+ }
+
+ CCtrlListBox m_menuObjects;
+ CCtrlTreeView m_menuItems;
+ CCtrlCheck m_radio1, m_radio2, m_enableIcons;
+ CCtrlEdit m_customName, m_service;
+ CCtrlButton m_btnInsert, m_btnReset, m_btnSet, m_btnDefault;
+ CCtrlBase m_warning;
+
+public:
+ CGenMenuOptionsPage() :
+ CDlgBase(hInst, IDD_OPT_GENMENU),
+ m_menuItems(this, IDC_MENUITEMS),
+ m_menuObjects(this, IDC_MENUOBJECTS),
+ m_radio1(this, IDC_RADIO1),
+ m_radio2(this, IDC_RADIO2),
+ m_enableIcons(this, IDC_DISABLEMENUICONS),
+ m_btnInsert(this, IDC_INSERTSEPARATOR),
+ m_btnReset(this, IDC_RESETMENU),
+ m_btnSet(this, IDC_GENMENU_SET),
+ m_btnDefault(this, IDC_GENMENU_DEFAULT),
+ m_customName(this, IDC_GENMENU_CUSTOMNAME),
+ m_service(this, IDC_GENMENU_SERVICE),
+ m_warning(this, IDC_NOTSUPPORTWARNING)
+ {
+ m_btnSet.OnClick = Callback(this, &CGenMenuOptionsPage::btnSet_Clicked);
+ m_btnReset.OnClick = Callback(this, &CGenMenuOptionsPage::btnReset_Clicked);
+ m_btnInsert.OnClick = Callback(this, &CGenMenuOptionsPage::btnInsert_Clicked);
+ m_btnDefault.OnClick = Callback(this, &CGenMenuOptionsPage::btnDefault_Clicked);
+
+ m_menuObjects.OnSelChange = Callback(this, &CGenMenuOptionsPage::onMenuObjectChanged);
+
+ m_menuItems.SetFlags(MTREE_CHECKBOX | MTREE_DND | MTREE_MULTISELECT);
+ m_menuItems.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuItemChanged);
+ }
+
+ //---- init dialog -------------------------------------------
+ virtual void OnInitDialog()
+ {
+ iInitMenuValue = db_get_b(NULL, "CList", "MoveProtoMenus", TRUE);
+
+ HIMAGELIST himlCheckBoxes = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
+ ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_NOTICK);
+ ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_TICK);
+ m_menuItems.SetImageList(himlCheckBoxes, TVSIL_NORMAL);
+
+ if (iInitMenuValue)
+ m_radio2.SetState(true);
+ else
+ m_radio1.SetState(true);
+
+ m_enableIcons.SetState(!bIconsDisabled);
+
+ //---- init menu object list --------------------------------------
+ for (int i = 0; i < g_menus.getCount(); i++) {
+ TIntMenuObject *p = g_menus[i];
+ if (p->id != (int)hStatusMenuObject && p->m_bUseUserDefinedItems)
+ m_menuObjects.AddString(TranslateTS(p->ptszDisplayName), p->id);
+ }
+
+ m_menuObjects.SetCurSel(0);
+ RebuildCurrent();
+ }
+
+ virtual void OnApply()
+ {
+ bIconsDisabled = m_enableIcons.GetState() == 0;
+ db_set_b(NULL, "CList", "DisableMenuIcons", bIconsDisabled);
+ SaveTree();
+
+ int iNewMenuValue = !m_radio1.GetState();
+ if (iNewMenuValue != iInitMenuValue) {
db_set_b(NULL, "CList", "MoveProtoMenus", iNewMenuValue);
-
- RebuildProtoMenus(iNewMenuValue);
- iInitMenuValue = iNewMenuValue;
- }
- RebuildCurrent();
- }
-
- virtual void OnDestroy()
- {
- ImageList_Destroy(m_menuItems.GetImageList(TVSIL_NORMAL));
- FreeTreeData();
- }
-
- void btnInsert_Clicked(CCtrlButton*)
- {
- HTREEITEM hti = m_menuItems.GetSelection();
- if (hti == NULL)
- return;
-
- TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT;
- tvi.hItem = hti;
- if (!m_menuItems.GetItem(&tvi))
- return;
-
- MenuItemOptData *PD = new MenuItemOptData();
- PD->id = -1;
- PD->name = mir_tstrdup(STR_SEPARATOR);
- 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 = 1;
- tvis.hInsertAfter = hti;
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- m_menuItems.InsertItem(&tvis);
-
+
+ RebuildProtoMenus(iNewMenuValue);
+ iInitMenuValue = iNewMenuValue;
+ }
+ RebuildCurrent();
+ }
+
+ virtual void OnDestroy()
+ {
+ ImageList_Destroy(m_menuItems.GetImageList(TVSIL_NORMAL));
+ FreeTreeData();
+ }
+
+ void btnInsert_Clicked(CCtrlButton*)
+ {
+ HTREEITEM hti = m_menuItems.GetSelection();
+ if (hti == NULL)
+ return;
+
+ TVITEMEX tvi = { 0 };
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT;
+ tvi.hItem = hti;
+ if (!m_menuItems.GetItem(&tvi))
+ return;
+
+ MenuItemOptData *PD = new MenuItemOptData();
+ PD->id = -1;
+ PD->name = mir_tstrdup(STR_SEPARATOR);
+ 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 = 1;
+ tvis.hInsertAfter = hti;
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ m_menuItems.InsertItem(&tvis);
+
NotifyChange();
- }
-
- void btnReset_Clicked(CCtrlButton*)
- {
- int MenuObjectID;
- if (GetCurrentMenuObjectID(MenuObjectID)) {
- BuildTree(MenuObjectID, false);
+ }
+
+ void btnReset_Clicked(CCtrlButton*)
+ {
+ int MenuObjectID;
+ if (GetCurrentMenuObjectID(MenuObjectID)) {
+ BuildTree(MenuObjectID, false);
NotifyChange();
- }
- }
-
- void btnDefault_Clicked(CCtrlButton*)
- {
- HTREEITEM hti = m_menuItems.GetSelection();
- if (hti == NULL)
- return;
-
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
- tvi.hItem = hti;
- m_menuItems.GetItem(&tvi);
-
- MenuItemOptData *iod = (MenuItemOptData *)tvi.lParam;
- if (iod->name && _tcsstr(iod->name, STR_SEPARATOR))
- return;
-
- iod->name = mir_tstrdup(iod->defname);
-
- SaveTree();
- RebuildCurrent();
+ }
+ }
+
+ void btnDefault_Clicked(CCtrlButton*)
+ {
+ HTREEITEM hti = m_menuItems.GetSelection();
+ if (hti == NULL)
+ return;
+
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+ tvi.hItem = hti;
+ m_menuItems.GetItem(&tvi);
+
+ MenuItemOptData *iod = (MenuItemOptData *)tvi.lParam;
+ if (iod->name && _tcsstr(iod->name, STR_SEPARATOR))
+ return;
+
+ iod->name = mir_tstrdup(iod->defname);
+
+ SaveTree();
+ RebuildCurrent();
NotifyChange();
- }
-
- void btnSet_Clicked(CCtrlButton*)
- {
- HTREEITEM hti = m_menuItems.GetSelection();
- if (hti == NULL)
- return;
-
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
- tvi.hItem = hti;
- m_menuItems.GetItem(&tvi);
-
- MenuItemOptData *iod = (MenuItemOptData *)tvi.lParam;
- if (iod->name && _tcsstr(iod->name, STR_SEPARATOR))
- return;
-
- iod->name = m_customName.GetText();
-
- SaveTree();
- RebuildCurrent();
+ }
+
+ void btnSet_Clicked(CCtrlButton*)
+ {
+ HTREEITEM hti = m_menuItems.GetSelection();
+ if (hti == NULL)
+ return;
+
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+ tvi.hItem = hti;
+ m_menuItems.GetItem(&tvi);
+
+ MenuItemOptData *iod = (MenuItemOptData *)tvi.lParam;
+ if (iod->name && _tcsstr(iod->name, STR_SEPARATOR))
+ return;
+
+ iod->name = m_customName.GetText();
+
+ SaveTree();
+ RebuildCurrent();
NotifyChange();
- }
-
- void onMenuObjectChanged(void*)
- {
- m_initialized = false;
- RebuildCurrent();
- m_initialized = true;
- }
-
- void onMenuItemChanged(void*)
- {
- m_customName.SetTextA("");
- m_service.SetTextA("");
-
- m_btnDefault.Enable(false);
- m_btnSet.Enable(false);
- m_customName.Enable(false);
-
- HTREEITEM hti = m_menuItems.GetSelection();
- if (hti == NULL)
- return;
-
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
- tvi.hItem = hti;
- m_menuItems.GetItem(&tvi);
- if (tvi.lParam == 0)
- return;
-
- MenuItemOptData *iod = (MenuItemOptData *)tvi.lParam;
- if (iod->name && _tcsstr(iod->name, STR_SEPARATOR))
- return;
-
- m_customName.SetText(iod->name);
-
- if (iod->pimi->submenu.first == NULL && iod->uniqname)
- m_service.SetTextA(iod->uniqname);
-
- m_btnDefault.Enable(mir_tstrcmp(iod->name, iod->defname) != 0);
- m_btnSet.Enable(true);
- m_customName.Enable(true);
- }
-
- void onMenuItemBeginDrag(CCtrlTreeView::TEventInfo *evt)
- {
- SetCapture(m_hwnd);
- m_bDragging = true;
- m_hDragItem = evt->nmtv->itemNew.hItem;
- m_menuItems.SelectItem(m_hDragItem);
- }
-
- int onMenuItemDraw(LPNMTVCUSTOMDRAW pNMTVCD)
- {
- if (pNMTVCD == NULL)
- return -1;
-
- switch (pNMTVCD->nmcd.dwDrawStage) {
- case CDDS_PREPAINT:
- return CDRF_NOTIFYITEMDRAW;
-
- case CDDS_ITEMPREPAINT:
- HTREEITEM hItem = (HTREEITEM)pNMTVCD->nmcd.dwItemSpec;
- TCHAR buf[255];
-
- TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIS_SELECTED | TVIF_TEXT | TVIF_IMAGE;
- tvi.stateMask = TVIS_SELECTED;
- tvi.hItem = hItem;
- tvi.pszText = buf;
- tvi.cchTextMax = SIZEOF(buf);
- m_menuItems.GetItem(&tvi);
- if (((MenuItemOptData *)tvi.lParam)->bIsSelected) {
- pNMTVCD->clrTextBk = GetSysColor(COLOR_HIGHLIGHT);
- pNMTVCD->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT);
- }
- else {
- pNMTVCD->clrTextBk = GetSysColor(COLOR_WINDOW);
- pNMTVCD->clrText = GetSysColor(COLOR_WINDOWTEXT);
- }
-
- /* At this point, you can change the background colors for the item
- and any subitems and return CDRF_NEWFONT. If the list-view control
- is in report mode, you can simply return CDRF_NOTIFYSUBITEMREDRAW
- to customize the item's subitems individually */
- int res = CDRF_NEWFONT;
- if (tvi.iImage == -1) {
- SIZE sz;
- GetTextExtentPoint32(pNMTVCD->nmcd.hdc, tvi.pszText, (int)mir_tstrlen(tvi.pszText), &sz);
-
- RECT rc;
- if (sz.cx + 3 > pNMTVCD->nmcd.rc.right - pNMTVCD->nmcd.rc.left)
- rc = pNMTVCD->nmcd.rc;
- else
- SetRect(&rc, pNMTVCD->nmcd.rc.left, pNMTVCD->nmcd.rc.top, pNMTVCD->nmcd.rc.left + sz.cx + 3, pNMTVCD->nmcd.rc.bottom);
-
- HBRUSH br = CreateSolidBrush(pNMTVCD->clrTextBk);
- SetTextColor(pNMTVCD->nmcd.hdc, pNMTVCD->clrText);
- SetBkColor(pNMTVCD->nmcd.hdc, pNMTVCD->clrTextBk);
- FillRect(pNMTVCD->nmcd.hdc, &rc, br);
- DeleteObject(br);
- DrawText(pNMTVCD->nmcd.hdc, tvi.pszText, -1, &pNMTVCD->nmcd.rc, DT_LEFT | DT_VCENTER | DT_NOPREFIX);
-
- res |= CDRF_SKIPDEFAULT;
- }
- return res;
- }
-
- return 0;
- }
-
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
- {
- TVHITTESTINFO hti;
-
- switch (msg) {
- case WM_MOUSEMOVE:
- if (!m_bDragging)
- break;
-
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(m_hwnd, &hti.pt);
- ScreenToClient(m_menuItems.GetHwnd(), &hti.pt);
- m_menuItems.HitTest(&hti);
- if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
- HTREEITEM it = hti.hItem;
- hti.pt.y -= m_menuItems.GetItemHeight() / 2;
- m_menuItems.HitTest(&hti);
- if (!(hti.flags & TVHT_ABOVE))
- m_menuItems.SetInsertMark(hti.hItem, 1);
- else
- m_menuItems.SetInsertMark(it, 0);
- }
- else {
- if (hti.flags & TVHT_ABOVE)
- m_menuItems.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
- if (hti.flags & TVHT_BELOW)
- m_menuItems.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
- m_menuItems.SetInsertMark(NULL, 0);
- }
- break;
-
- case WM_LBUTTONUP:
- if (!m_bDragging)
- break;
-
- m_menuItems.SetInsertMark(NULL, 0);
- m_bDragging = false;
- ReleaseCapture();
-
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(m_hwnd, &hti.pt);
- ScreenToClient(m_menuItems.GetHwnd(), &hti.pt);
- hti.pt.y -= m_menuItems.GetItemHeight() / 2;
- m_menuItems.HitTest(&hti);
- if (hti.flags & TVHT_ABOVE)
- hti.hItem = TVI_FIRST;
- if (m_hDragItem == hti.hItem)
- break;
-
- m_hDragItem = NULL;
- if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
- HTREEITEM FirstItem = NULL;
- if (m_menuItems.GetCount()) {
- LIST<void> arItems(10);
-
- HTREEITEM hit = m_menuItems.GetRoot();
- if (hit) {
- do {
- TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hit;
- m_menuItems.GetItem(&tvi);
- if (((MenuItemOptData *)tvi.lParam)->bIsSelected)
- arItems.insert(tvi.hItem);
- } while (hit = m_menuItems.GetNextSibling(hit));
- }
-
- // Proceed moving
- HTREEITEM insertAfter = hti.hItem;
- for (int i = 0; i < arItems.getCount(); i++) {
- if (!insertAfter)
- break;
-
- insertAfter = MoveItemAbove((HTREEITEM)arItems[i], insertAfter);
- if (!i)
- FirstItem = insertAfter;
- }
- }
-
- if (FirstItem)
- m_menuItems.SelectItem(FirstItem);
- NotifyChange();
- SaveTree();
- }
- break;
-
- case WM_NOTIFY:
- LPNMHDR phdr = (LPNMHDR)lParam;
- if (phdr->idFrom == IDC_MENUITEMS) {
- switch (phdr->code) {
- case NM_CUSTOMDRAW:
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, onMenuItemDraw((LPNMTVCUSTOMDRAW)phdr));
- return TRUE;
-
- case NM_CLICK:
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(phdr->hwndFrom, &hti.pt);
- if (!m_menuItems.HitTest(&hti))
- break;
-
- /*--------MultiSelection----------*/
- if (hti.flags & TVHT_ONITEMLABEL) {
- /// LabelClicked Set/unset selection
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hti.hItem;
- m_menuItems.GetItem(&tvi);
- if (GetKeyState(VK_CONTROL) & 0x8000) {
- MenuItemOptData *iod = (MenuItemOptData*)tvi.lParam;
- iod->bIsSelected = !iod->bIsSelected;
- m_menuItems.SetItem(&tvi);
- }
- else if (GetKeyState(VK_SHIFT) & 0x8000) {
- ; // shifted click
- }
- else {
- // reset all selection except current
- HTREEITEM hit = m_menuItems.GetRoot();
- if (!hit)
- break;
-
- do {
- TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hit;
- m_menuItems.GetItem(&tvi);
-
- MenuItemOptData *iod = (MenuItemOptData*)tvi.lParam;
- iod->bIsSelected = (hti.hItem == hit);
- m_menuItems.SetItem(&tvi);
- } while (hit = m_menuItems.GetNextSibling(hit));
- }
- }
- }
- }
- break;
- }
- return CDlgBase::DlgProc(msg, wParam, lParam);
- }
-};
-
-int GenMenuOptInit(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.position = -1000000000;
- odp.pszTitle = LPGEN("Menus");
- odp.pszGroup = LPGEN("Customize");
- odp.flags = ODPF_BOLDGROUPS;
- odp.pDialog = new CGenMenuOptionsPage();
- Options_AddPage(wParam, &odp);
-
- return ProtocolOrderOptInit(wParam, 0);
-}
+ }
+
+ void onMenuObjectChanged(void*)
+ {
+ m_initialized = false;
+ RebuildCurrent();
+ m_initialized = true;
+ }
+
+ void onMenuItemChanged(void*)
+ {
+ m_customName.SetTextA("");
+ m_service.SetTextA("");
+
+ m_btnDefault.Enable(false);
+ m_btnSet.Enable(false);
+ m_customName.Enable(false);
+
+ HTREEITEM hti = m_menuItems.GetSelection();
+ if (hti == NULL)
+ return;
+
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+ tvi.hItem = hti;
+ m_menuItems.GetItem(&tvi);
+ if (tvi.lParam == 0)
+ return;
+
+ MenuItemOptData *iod = (MenuItemOptData *)tvi.lParam;
+ if (iod->name && _tcsstr(iod->name, STR_SEPARATOR))
+ return;
+
+ m_customName.SetText(iod->name);
+
+ if (iod->pimi->submenu.first == NULL && iod->uniqname)
+ m_service.SetTextA(iod->uniqname);
+
+ m_btnDefault.Enable(mir_tstrcmp(iod->name, iod->defname) != 0);
+ m_btnSet.Enable(true);
+ m_customName.Enable(true);
+ }
+};
+
+int GenMenuOptInit(WPARAM wParam, LPARAM)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.position = -1000000000;
+ odp.pszTitle = LPGEN("Menus");
+ odp.pszGroup = LPGEN("Customize");
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pDialog = new CGenMenuOptionsPage();
+ Options_AddPage(wParam, &odp);
+
+ return ProtocolOrderOptInit(wParam, 0);
+}