summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2012-06-23 20:08:25 +0000
committerAlexey Kulakov <panda75@bk.ru>2012-06-23 20:08:25 +0000
commit5a06912fcbff12795fe781f6480295f7daf0dc8b (patch)
treef65b9b8560ef92c297b2c91297791d38c8c9f8a2 /plugins
parentb3ee1318f6951965f0ae2d05d0121f6d7882e92c (diff)
1/2 of option dialog changes
git-svn-id: http://svn.miranda-ng.org/main/trunk@588 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/TopToolBar/common.h3
-rw-r--r--plugins/TopToolBar/toolbar.cpp118
-rw-r--r--plugins/TopToolBar/topbutton.cpp46
-rw-r--r--plugins/TopToolBar/ttbopt.cpp241
4 files changed, 244 insertions, 164 deletions
diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h
index 61fdbdcd0d..04e3474c47 100644
--- a/plugins/TopToolBar/common.h
+++ b/plugins/TopToolBar/common.h
@@ -41,6 +41,7 @@
#define TTBDEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT)
#define TTBBF_INTERNAL 0x1000000
+#define TTBBF_OPTIONAL 0x2000000
///////////////////////////////////////////////////////////////////////////////
// TopButtonInt class
@@ -86,6 +87,8 @@ int TTBOptInit(WPARAM wParam, LPARAM lParam);
//append string
char __inline *AS(char *str, const char *setting, char *addstr);
+TopButtonInt* CreateButton(TTBButton* but);
+
int ttbOptionsChanged();
int ArrangeButtons();
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp
index 81bacd8916..5999e34ca3 100644
--- a/plugins/TopToolBar/toolbar.cpp
+++ b/plugins/TopToolBar/toolbar.cpp
@@ -65,8 +65,7 @@ void InsertSBut(int i)
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE|TTBBF_ISSBUTTON|TTBBF_INTERNAL;
ttb.wParamDown = i;
- ttb.lParamDown = TTBAddButton(( WPARAM )&ttb, 0);;
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_ALLDATA, ttb.lParamDown), (LPARAM)&ttb);
+ TTBAddButton(( WPARAM )&ttb, 0);
}
void LoadAllSButs()
@@ -100,13 +99,11 @@ void InsertLBut(int i)
TTBButton ttb = { 0 };
ttb.cbSize = sizeof(ttb);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
-// ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL;
ttb.name = LPGEN("Default");
ttb.program = _T("Execute Path");
ttb.wParamDown = i;
- ttb.lParamDown = TTBAddButton(( WPARAM )&ttb, 0);
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_ALLDATA, ttb.lParamDown), (LPARAM)&ttb);
+ TTBAddButton(( WPARAM )&ttb, 0);
}
void LoadAllLButs()
@@ -125,8 +122,7 @@ void InsertSeparator(int i)
ttb.cbSize = sizeof(ttb);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL;
ttb.wParamDown = i;
- ttb.lParamDown = TTBAddButton((WPARAM)&ttb, 0);
- CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_ALLDATA, ttb.lParamDown), (LPARAM)&ttb);
+ TTBAddButton((WPARAM)&ttb, 0);
}
void LoadAllSeparators()
@@ -239,69 +235,51 @@ int RecreateWindows()
return (0);
}
-INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
+TopButtonInt* CreateButton(TTBButton* but)
{
- if (wParam == 0)
- return -1;
-
- if (hwndContactList == 0)
- hwndContactList = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
- //oops clui even now not loaded...sorry no buttons available
- if (hwndContactList == 0)
- return -1;
-
- lockbut();
-
- TTBButton *but = (TTBButton*)wParam;
- if ((but->cbSize != sizeof(TTBButton)) ||
- (!(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name))) {
- ulockbut();
- return -1;
- }
-
TopButtonInt* b = new TopButtonInt;
b->id = nextButtonId++;
-
- if (but->dwFlags & TTBBF_ISLBUTTON) {
- if (but->program != NULL)
- b->program = _tcsdup(but->program);
- b->pszService = _strdup(TTB_LAUNCHSERVICE);
- }
- else {
- b->program = NULL;
- if (but->pszService != NULL)
- b->pszService = _strdup(but->pszService);
- else
- b->pszService = NULL;
- }
-
- if (but->name != NULL)
- b->name = _strdup(but->name);
- else
- b->name = NULL;
b->dwFlags = but->dwFlags;
- if (b->dwFlags & TTBBF_ICONBYHANDLE) {
- if (but->hIconHandleDn)
- b->hIconDn = Skin_GetIconByHandle(but->hIconHandleDn);
- else
- b->hIconDn = 0;
- b->hIconUp = Skin_GetIconByHandle(but->hIconHandleUp);
- }
- else {
- b->hIconDn = but->hIconDn;
- b->hIconUp = but->hIconUp;
- }
-
b->wParamUp = but->wParamUp;
b->lParamUp = but->lParamUp;
b->wParamDown = but->wParamDown;
b->lParamDown = but->lParamDown;
- b->bPushed = (but->dwFlags & TTBBF_PUSHED) ? TRUE : FALSE;
-
if ( !(b->dwFlags & TTBBF_ISSEPARATOR)) {
+ b->bPushed = (but->dwFlags & TTBBF_PUSHED) ? TRUE : FALSE;
+
+ if (but->dwFlags & TTBBF_ISLBUTTON) {
+ if (but->program != NULL)
+ b->program = _tcsdup(but->program);
+ b->pszService = _strdup(TTB_LAUNCHSERVICE);
+ }
+ else {
+ b->program = NULL;
+ if (but->pszService != NULL)
+ b->pszService = _strdup(but->pszService);
+ else
+ b->pszService = NULL;
+ }
+
+ if (but->name != NULL)
+ b->name = _strdup(but->name);
+ else
+ b->name = NULL;
+
+ if (b->dwFlags & TTBBF_ICONBYHANDLE) {
+ if (but->hIconHandleDn)
+ b->hIconDn = Skin_GetIconByHandle(but->hIconHandleDn);
+ else
+ b->hIconDn = 0;
+ b->hIconUp = Skin_GetIconByHandle(but->hIconHandleUp);
+ }
+ else {
+ b->hIconDn = but->hIconDn;
+ b->hIconUp = but->hIconUp;
+ }
+
char buf[256];
sprintf(buf, "%s_up", b->name);
b->hIconUp = LoadIconFromLibrary(buf, b->hIconUp, b->hIconHandleUp);
@@ -310,6 +288,30 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
b->hIconDn = LoadIconFromLibrary(buf, b->hIconDn, b->hIconHandleDn);
}
}
+ return b;
+}
+
+INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
+{
+ if (wParam == 0)
+ return -1;
+
+ if (hwndContactList == 0)
+ hwndContactList = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
+ //oops clui even now not loaded...sorry no buttons available
+ if (hwndContactList == 0)
+ return -1;
+
+ lockbut();
+
+ TTBButton *but = (TTBButton*)wParam;
+ if ((but->cbSize != sizeof(TTBButton)) ||
+ (!(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name))) {
+ ulockbut();
+ return -1;
+ }
+
+ TopButtonInt* b = CreateButton(but);
b->LoadSettings();
Buttons.insert(b);
diff --git a/plugins/TopToolBar/topbutton.cpp b/plugins/TopToolBar/topbutton.cpp
index 3091d429b4..3c216e364a 100644
--- a/plugins/TopToolBar/topbutton.cpp
+++ b/plugins/TopToolBar/topbutton.cpp
@@ -77,33 +77,29 @@ void TopButtonInt::LoadSettings()
dwFlags = dwFlags & (~TTBBF_VISIBLE);
if (dwFlags & TTBBF_ISSEPARATOR) {
- if (wParamDown != 0) {
- char buf1[10];
- _itoa(wParamDown, buf1, 10);
- char buf2[20];
- AS(buf2, "Sep", buf1);
-
- arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount());
- if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
- dwFlags |= TTBBF_VISIBLE;
- }
+ char buf1[10];
+ _itoa(wParamDown, buf1, 10);
+ char buf2[20];
+ AS(buf2, "Sep", buf1);
+
+ arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount());
+ if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
+ dwFlags |= TTBBF_VISIBLE;
}
else if (dwFlags & TTBBF_ISLBUTTON) {
- if (wParamDown != 0) {
- char buf1[10];
- _itoa(wParamDown, buf1, 10);
- char buf2[20];
- AS(buf2, "Launch", buf1);
-
- if (name != NULL) free(name);
- name = DBGetString(0, TTB_OPTDIR, AS(buf, buf2, "_name"));
- if (program != NULL) free(program);
- program = DBGetStringT(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"));
-
- arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount());
- if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
- dwFlags |= TTBBF_VISIBLE;
- }
+ char buf1[10];
+ _itoa(wParamDown, buf1, 10);
+ char buf2[20];
+ AS(buf2, "Launch", buf1);
+
+ if (name != NULL) free(name);
+ name = DBGetString(0, TTB_OPTDIR, AS(buf, buf2, "_name"));
+ if (program != NULL) free(program);
+ program = DBGetStringT(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"));
+
+ arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount());
+ if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
+ dwFlags |= TTBBF_VISIBLE;
}
else {
arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, name, "_Position"), Buttons.getCount());
diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp
index 31fc422ea4..95619172fe 100644
--- a/plugins/TopToolBar/ttbopt.cpp
+++ b/plugins/TopToolBar/ttbopt.cpp
@@ -11,10 +11,47 @@ struct OrderData
HIMAGELIST himlButtonIcons;
};
+HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST il)
+{
+ TVINSERTSTRUCT tvis = { 0 };
+ tvis.hInsertAfter = hItem;
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+
+ int index;
+ TCHAR* tmp;
+
+ if (b->dwFlags & TTBBF_ISSEPARATOR) {
+ tvis.item.pszText = L"------------------";
+ index = -1;
+ }
+ else {
+ if (b->dwFlags & TTBBF_ICONBYHANDLE) {
+ HICON hIcon = Skin_GetIconByHandle(b->hIconHandleUp);
+ index = ImageList_AddIcon(il, hIcon);
+ Skin_ReleaseIcon(hIcon);
+ }
+ else index = ImageList_AddIcon(il, b->hIconUp);
+
+ tmp = mir_a2t( b->name );
+ tvis.item.pszText = TranslateTS(tmp);
+ }
+ tvis.item.iImage = tvis.item.iSelectedImage = index;
+
+ tvis.item.lParam = (LPARAM)b;
+ HTREEITEM hti = TreeView_InsertItem(hTree, &tvis);
+
+ if (!(b->dwFlags & TTBBF_ISSEPARATOR))
+ mir_free(tmp);
+
+ TreeView_SetCheckState(hTree, hti, (b->dwFlags & TTBBF_VISIBLE) ? TRUE : FALSE);
+
+ return hti;
+}
+
int BuildTree(HWND hwndDlg)
{
HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
- OrderData *dat = (struct OrderData*)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), GWLP_USERDATA);
+ OrderData *dat = (struct OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);
dat->himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
TreeView_SetImageList(hTree, dat->himlButtonIcons, TVSIL_NORMAL);
@@ -24,41 +61,9 @@ int BuildTree(HWND hwndDlg)
if (Buttons.getCount() == 0)
return FALSE;
- TVINSERTSTRUCT tvis = { 0 };
- tvis.hInsertAfter = TVI_LAST;
-
- int index;
- TCHAR* tmp;
-
for (int i = 0; i < Buttons.getCount(); i++) {
TopButtonInt *b = Buttons[i];
-
- if (b->dwFlags & TTBBF_ISSEPARATOR) {
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvis.item.iImage = tvis.item.iSelectedImage = -1;
- tvis.item.pszText = L"------------------";
- }
- else {
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- if (b->dwFlags & TTBBF_ICONBYHANDLE) {
- HICON hIcon = Skin_GetIconByHandle(b->hIconHandleUp);
- index = ImageList_AddIcon(dat->himlButtonIcons, hIcon);
- Skin_ReleaseIcon(hIcon);
- }
- else index = ImageList_AddIcon(dat->himlButtonIcons, b->hIconUp);
- tvis.item.iImage = tvis.item.iSelectedImage = index;
-
- tmp = mir_a2t( b->name );
- tvis.item.pszText = TranslateTS(tmp);
- }
-
- tvis.item.lParam = (LPARAM)b;
- HTREEITEM hti = TreeView_InsertItem(hTree, &tvis);
-
- if (!(b->dwFlags & TTBBF_ISSEPARATOR))
- mir_free(tmp);
-
- TreeView_SetCheckState(hTree, hti, (b->dwFlags & TTBBF_VISIBLE) ? TRUE : FALSE);
+ AddLine(hTree, b, TVI_LAST, dat->himlButtonIcons);
}
return (TRUE);
@@ -81,9 +86,8 @@ int SaveTree(HWND hwndDlg)
tvi.hItem = TreeView_GetRoot(hTree);
int count = 0;
- lockbut();
- Buttons.destroy();
+ LIST<TopButtonInt> LocalButtons(TreeView_GetCount(hTree));
while(tvi.hItem != NULL) {
tvi.stateMask = TVIS_STATEIMAGEMASK;
@@ -92,39 +96,78 @@ int SaveTree(HWND hwndDlg)
TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
+// Buttons.remove(btn);
+ int idx = Buttons.indexOf(btn);
+ if (idx != -1)
+ Buttons.remove(idx);
+
if (TreeView_GetCheckState(hTree,tvi.hItem))
btn->dwFlags |= TTBBF_VISIBLE;
else
btn->dwFlags &= ~TTBBF_VISIBLE;
+
+ btn->dwFlags &=~TTBBF_OPTIONAL;
+
btn->arrangedpos = count;
- Buttons.insert(btn);
+ LocalButtons.insert(btn);
tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
count++;
}
+ lockbut();
+ for (int i=0;i<Buttons.getCount();i++)
+ delete Buttons[i];
+ Buttons.destroy();
+
+ Buttons = LocalButtons;
+
+// LocalButtons.destroy();
+
ulockbut();
SaveAllButtonsOptions();
return (TRUE);
}
+int CancelProcess(HWND hwndDlg)
+{
+ HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
+
+ TVITEM tvi = { 0 };
+ tvi.hItem = TreeView_GetRoot(hTree);
+
+ while(tvi.hItem != NULL) {
+ tvi.stateMask = TVIS_STATEIMAGEMASK;
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
+ TreeView_GetItem(hTree, &tvi);
+
+ TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
+
+ if (btn ->dwFlags & TTBBF_OPTIONAL)
+ delete btn;
+
+ tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
+ }
+
+ return (TRUE);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// Options window: main
static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- TopButtonInt* btn;
- HWND tree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
- struct OrderData *dat = (struct OrderData*)GetWindowLongPtr(tree, GWLP_USERDATA);
+ HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
+ struct OrderData *dat = (struct OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
dat = (struct OrderData*)malloc(sizeof(struct OrderData));
- SetWindowLongPtr(tree, GWLP_USERDATA, (LONG)dat);
+ SetWindowLongPtr(hTree, GWLP_USERDATA, (LONG)dat);
dat->dragging = 0;
- SetWindowLongPtr(tree, GWL_STYLE, GetWindowLongPtr(tree, GWL_STYLE)|TVS_NOHSCROLL);
+ SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE)|TVS_NOHSCROLL);
SetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, BUTTHEIGHT, FALSE);
SetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, BUTTWIDTH, FALSE);
@@ -157,18 +200,32 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
//----- Launch buttons -----
if (ctrlid == IDC_LBUTTONSET) {
- TVITEM tvi;
- tvi.hItem = TreeView_GetSelection(tree);
+ TVITEM tvi ={0};
+ tvi.hItem = TreeView_GetSelection(hTree);
if (tvi.hItem == NULL)
break;
tvi.mask = TVIF_PARAM;
- TreeView_GetItem(tree, &tvi);
+ TreeView_GetItem(hTree, &tvi);
- btn = (TopButtonInt*)tvi.lParam;
+ TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
TCHAR buf [256];
// probably, condition not needs
if (btn->dwFlags & TTBBF_ISLBUTTON) {
+ if (!(btn->dwFlags & TTBBF_OPTIONAL)) {
+ // create button
+ TTBButton ttb = { 0 };
+ ttb.cbSize = sizeof(ttb);
+ ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
+ ttb.name = NULL;
+ ttb.program = NULL;
+ btn = CreateButton(&ttb);
+
+ tvi.lParam = (LPARAM)btn;
+ TreeView_SetItem(hTree, &tvi);
+ }
+
if (btn->name) free(btn->name);
GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255);
btn->name = _strdup( _T2A(buf));
@@ -179,13 +236,28 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
tvi.mask = TVIF_TEXT;
tvi.pszText = mir_a2t( btn->name );
- TreeView_SetItem(tree, &tvi);
+ TreeView_SetItem(hTree, &tvi);
}
break;
}
if (ctrlid == IDC_ADDLBUTTON) {
- InsertLBut(0);
+ // create button
+ TTBButton ttb = { 0 };
+ ttb.cbSize = sizeof(ttb);
+ ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
+ ttb.name = LPGEN("Default");
+ ttb.program = _T("Execute Path");
+ TopButtonInt* b = CreateButton(&ttb);
+
+ // get selection for insert
+ TVITEM tvi = {0};
+ tvi.hItem = TreeView_GetSelection(hTree);
+
+ // insert item
+ AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons);
+
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
@@ -193,36 +265,43 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
//----- Separators -----
if (ctrlid == IDC_ADDSEP) {
- InsertSeparator(0);
+ // create button
+ TTBButton ttb = { 0 };
+ ttb.cbSize = sizeof(ttb);
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL;
+ TopButtonInt* b = CreateButton(&ttb);
+
+ // get selection for insert
+ TVITEM tvi = {0};
+ tvi.hItem = TreeView_GetSelection(hTree);
+
+ // insert item
+ AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons);
+
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
if (ctrlid == IDC_REMOVEBUTTON) {
TVITEM tvi = {0};
- tvi.hItem = TreeView_GetSelection(tree);
+ tvi.hItem = TreeView_GetSelection(hTree);
if (tvi.hItem == NULL)
break;
tvi.mask = TVIF_PARAM;
- TreeView_GetItem(tree, &tvi);
+ TreeView_GetItem(hTree, &tvi);
- btn = (TopButtonInt*)tvi.lParam;
+ TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
// if button enabled for separator and launch only, no need condition
// except possible service button introducing
if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) {
- int idx = Buttons.indexOf(btn);
- if (idx != -1) {
- TreeView_DeleteItem(tree,tvi.hItem);
+ // delete if was added in options
+ if (btn->dwFlags & TTBBF_OPTIONAL)
+ delete btn;
- Buttons.remove(idx);
- delete btn;
+ TreeView_DeleteItem(hTree,tvi.hItem);
- ArrangeButtons();
- ulockbut();
-// OptionsPageRebuild();
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
}
@@ -255,7 +334,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
SetCapture(hwndDlg);
dat->dragging = 1;
dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
- TreeView_SelectItem(tree, dat->hDragItem);
+ TreeView_SelectItem(hTree, dat->hDragItem);
break;
case NM_CLICK:
@@ -267,7 +346,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti))
if (hti.flags & TVHT_ONITEMSTATEICON) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- TreeView_SelectItem(tree, hti.hItem);
+ TreeView_SelectItem(hTree, hti.hItem);
}
}
break;
@@ -275,7 +354,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case TVN_SELCHANGEDA:
case TVN_SELCHANGEDW:
{
- HTREEITEM hti = TreeView_GetSelection(tree);
+ HTREEITEM hti = TreeView_GetSelection(hTree);
if (hti == NULL)
break;
@@ -321,17 +400,17 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
hti.pt.x = (short)LOWORD(lParam);
hti.pt.y = (short)HIWORD(lParam);
ClientToScreen(hwndDlg, &hti.pt);
- ScreenToClient(tree, &hti.pt);
- TreeView_HitTest(tree, &hti);
+ ScreenToClient(hTree, &hti.pt);
+ TreeView_HitTest(hTree, &hti);
if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
- hti.pt.y -= TreeView_GetItemHeight(tree)/2;
- TreeView_HitTest(tree, &hti);
- TreeView_SetInsertMark(tree, hti.hItem, 1);
+ hti.pt.y -= TreeView_GetItemHeight(hTree)/2;
+ TreeView_HitTest(hTree, &hti);
+ TreeView_SetInsertMark(hTree, hti.hItem, 1);
}
else {
- if (hti.flags & TVHT_ABOVE) SendMessage(tree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
- if (hti.flags & TVHT_BELOW) SendMessage(tree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
- TreeView_SetInsertMark(tree, NULL, 0);
+ if (hti.flags & TVHT_ABOVE) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
+ if (hti.flags & TVHT_BELOW) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
+ TreeView_SetInsertMark(hTree, NULL, 0);
}
}
break;
@@ -346,7 +425,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case WM_LBUTTONUP:
if (dat->dragging) {
- TreeView_SetInsertMark(tree, NULL, 0);
+ TreeView_SetInsertMark(hTree, NULL, 0);
dat->dragging = 0;
ReleaseCapture();
@@ -354,16 +433,16 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
hti.pt.x = (short)LOWORD(lParam);
hti.pt.y = (short)HIWORD(lParam);
ClientToScreen(hwndDlg, &hti.pt);
- ScreenToClient(tree, &hti.pt);
- hti.pt.y -= TreeView_GetItemHeight(tree)/2;
- TreeView_HitTest(tree, &hti);
+ ScreenToClient(hTree, &hti.pt);
+ hti.pt.y -= TreeView_GetItemHeight(hTree)/2;
+ TreeView_HitTest(hTree, &hti);
if (dat->hDragItem == hti.hItem)
break;
TVITEM tvi;
tvi.mask = TVIF_HANDLE|TVIF_PARAM;
tvi.hItem = hti.hItem;
- TreeView_GetItem(tree, &tvi);
+ TreeView_GetItem(hTree, &tvi);
if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) {
TVINSERTSTRUCT tvis;
TCHAR name[128];
@@ -372,12 +451,12 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
tvis.item.pszText = name;
tvis.item.cchTextMax = SIZEOF(name);
tvis.item.hItem = dat->hDragItem;
- TreeView_GetItem(tree, &tvis.item);
+ TreeView_GetItem(hTree, &tvis.item);
- TreeView_DeleteItem(tree, dat->hDragItem);
+ TreeView_DeleteItem(hTree, dat->hDragItem);
tvis.hParent = NULL;
tvis.hInsertAfter = hti.hItem;
- TreeView_SelectItem(tree, TreeView_InsertItem(tree, &tvis));
+ TreeView_SelectItem(hTree, TreeView_InsertItem(hTree, &tvis));
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}