summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-10 12:33:30 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-10 12:33:30 +0000
commita993efb0503615efb7a3bcdce1ce91575448e789 (patch)
tree9a48d68b77bb01a61cf28e5e8c546f142ab0e49a /plugins
parent679f5352ac3ff2b3f098a502042d3359d2240415 (diff)
- tooltips for TopToolbar buttons
- replaceStr/replaceStrW moved to mir_core git-svn-id: http://svn.miranda-ng.org/main/trunk@886 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Clist_modern/modern_newrowopts.cpp2
-rw-r--r--plugins/TopToolBar/common.h12
-rw-r--r--plugins/TopToolBar/toolbar.cpp61
-rw-r--r--plugins/TopToolBar/topbutton.cpp54
-rw-r--r--plugins/TopToolBar/ttbopt.cpp22
5 files changed, 71 insertions, 80 deletions
diff --git a/plugins/Clist_modern/modern_newrowopts.cpp b/plugins/Clist_modern/modern_newrowopts.cpp
index fabbbf6adb..b44ea0dbe3 100644
--- a/plugins/Clist_modern/modern_newrowopts.cpp
+++ b/plugins/Clist_modern/modern_newrowopts.cpp
@@ -74,7 +74,7 @@ BOOL RemoveChildNode(NodeList * FromList, DWORD index)
NodeList *work = &(FromList->childNodes[index]);
for (size_t i=0; i < work->AllocatedChilds; i++)
if (work->childNodes[i].AllocatedChilds)
- RemoveChildNode(work->childNodes,i);
+ RemoveChildNode(work->childNodes, (DWORD)i);
if (work->AllocatedChilds) {
mir_free_and_nil(work->childNodes);
diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h
index 82060ac458..82fad3485f 100644
--- a/plugins/TopToolBar/common.h
+++ b/plugins/TopToolBar/common.h
@@ -69,18 +69,18 @@ struct TopButtonInt
HICON hIconUp, hIconDn;
HANDLE hIconHandleUp, hIconHandleDn;
- char *pszService;
- TCHAR *program;
- char *name;
- TCHAR *tooltip;
+ char *pszService;
+ TCHAR *ptszProgram;
+ char *pszName;
+ TCHAR *ptszTooltip;
LPARAM lParamUp;
WPARAM wParamUp;
LPARAM lParamDown;
WPARAM wParamDown;
- int hLangpack;
- char *szTooltipUp, *szTooltipDn;
+ int hLangpack;
+ TCHAR *ptszTooltipUp, *ptszTooltipDn;
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp
index 5e0e2a02f7..48957e9171 100644
--- a/plugins/TopToolBar/toolbar.cpp
+++ b/plugins/TopToolBar/toolbar.cpp
@@ -77,7 +77,7 @@ INT_PTR LaunchService(WPARAM wParam, LPARAM lParam)
STARTUPINFO si = {0};
si.cb = sizeof(si);
- if ( CreateProcess(NULL, Buttons[lParam]->program, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
+ if ( CreateProcess(NULL, Buttons[lParam]->ptszProgram, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
@@ -188,7 +188,7 @@ static bool nameexists(const char *name)
return false;
for (int i = 0; i < Buttons.getCount(); i++)
- if ( !lstrcmpA(Buttons[i]->name, name))
+ if ( !lstrcmpA(Buttons[i]->pszName, name))
return true;
return false;
@@ -219,11 +219,11 @@ static void ReloadIcons()
char buf[256];
if (b->hIconHandleUp) {
- sprintf(buf, "%s_up", b->name);
+ sprintf(buf, "%s_up", b->pszName);
b->hIconUp = LoadIconFromLibrary(buf, b->hIconUp, b->hIconHandleUp);
}
if (b->hIconHandleDn) {
- sprintf(buf, "%s_dn", b->name);
+ sprintf(buf, "%s_dn", b->pszName);
b->hIconDn = LoadIconFromLibrary(buf, b->hIconDn, b->hIconHandleDn);
}
}
@@ -245,22 +245,15 @@ TopButtonInt* CreateButton(TTBButton* but)
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);
+ b->ptszProgram = mir_tstrdup(but->program);
+ b->pszService = mir_strdup(TTB_LAUNCHSERVICE);
}
else {
- b->program = NULL;
- if (but->pszService != NULL)
- b->pszService = _strdup(but->pszService);
- else
- b->pszService = NULL;
+ b->ptszProgram = NULL;
+ b->pszService = mir_strdup(but->pszService);
}
- if (but->name != NULL)
- b->name = _strdup(but->name);
- else
- b->name = NULL;
+ b->pszName = mir_strdup(but->name);
if (b->dwFlags & TTBBF_ICONBYHANDLE) {
b->hIconUp = Skin_GetIconByHandle(b->hIconHandleUp = but->hIconHandleUp);
@@ -271,17 +264,17 @@ TopButtonInt* CreateButton(TTBButton* but)
}
else {
char buf[256];
- mir_snprintf(buf, SIZEOF(buf), (b->hIconDn) ? "%s_up" : "%s", b->name);
+ mir_snprintf(buf, SIZEOF(buf), (b->hIconDn) ? "%s_up" : "%s", b->pszName);
b->hIconUp = LoadIconFromLibrary(buf, but->hIconUp, b->hIconHandleUp);
if (b->hIconDn) {
- mir_snprintf(buf, SIZEOF(buf), "%s_dn", b->name);
+ mir_snprintf(buf, SIZEOF(buf), "%s_dn", b->pszName);
b->hIconDn = LoadIconFromLibrary(buf, but->hIconDn, b->hIconHandleDn);
}
}
if (but->cbSize > OLD_TBBUTTON_SIZE) {
- b->szTooltipUp = but->pszTooltipUp;
- b->szTooltipDn = but->pszTooltipDn;
+ b->ptszTooltipUp = mir_a2t(but->pszTooltipUp);
+ b->ptszTooltipDn = mir_a2t(but->pszTooltipDn);
}
}
return b;
@@ -418,7 +411,7 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam)
break;
case TTBO_TIPNAME:
- retval = (INT_PTR)b->tooltip;
+ retval = (INT_PTR)b->ptszTooltip;
break;
case TTBO_ALLDATA:
@@ -440,9 +433,9 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam)
lpTTB->wParamDown = b->wParamDown;
if (b->dwFlags & TTBBF_ISLBUTTON)
- lpTTB->program = _tcsdup(b->program);
+ replaceStrT(lpTTB->program, b->ptszProgram);
else
- lpTTB->pszService = _strdup(b->pszService);
+ replaceStr(lpTTB->pszService, b->pszService);
retval = ( INT_PTR )lpTTB;
}
@@ -486,10 +479,8 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
if (lParam == 0)
break;
- if (b->tooltip != NULL)
- free(b->tooltip);
- b->tooltip = _tcsdup( TranslateTS( _A2T((LPCSTR)lParam)));
- SendMessage(b->hwnd,BUTTONADDTOOLTIP,(WPARAM)b->tooltip,BATF_UNICODE);
+ replaceStrT(b->ptszTooltip, TranslateTS( _A2T((LPCSTR)lParam)));
+ SendMessage(b->hwnd,BUTTONADDTOOLTIP,(WPARAM)b->ptszTooltip,BATF_UNICODE);
retval = 1;
break;
@@ -518,18 +509,10 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
b->SaveSettings(0,0);
}
- if (b->dwFlags & TTBBF_ISLBUTTON) {
- if (b->program != NULL)
- free(b->program);
- b->program = _tcsdup(lpTTB->program);
-// don't save program changing in use buttons
-// changed = 1; // for launch buttons from user, not options (options don't share handles)
- }
- else {
- if (b->pszService != NULL)
- free(b->pszService);
- b->pszService = _strdup(lpTTB->pszService);
- }
+ if (b->dwFlags & TTBBF_ISLBUTTON)
+ replaceStrT(b->ptszProgram, lpTTB->program);
+ else
+ replaceStr(b->pszService, lpTTB->pszService);
b->lParamUp = lpTTB->lParamUp;
b->wParamUp = lpTTB->wParamUp;
diff --git a/plugins/TopToolBar/topbutton.cpp b/plugins/TopToolBar/topbutton.cpp
index 9a1cbe0200..5bcab82017 100644
--- a/plugins/TopToolBar/topbutton.cpp
+++ b/plugins/TopToolBar/topbutton.cpp
@@ -8,16 +8,15 @@ static int maxid = 10000;
TopButtonInt::~TopButtonInt()
{
if (dwFlags & TTBBF_ISLBUTTON) {
- if (program != NULL)
- free(program);
+ mir_free(ptszProgram);
}
else if (pszService != NULL)
- free(pszService);
+ mir_free(pszService);
- if (name != NULL)
- free(name);
- if (tooltip != NULL)
- free(tooltip);
+ mir_free(pszName);
+ mir_free(ptszTooltip);
+ mir_free(ptszTooltipDn);
+ mir_free(ptszTooltipUp);
}
DWORD TopButtonInt::CheckFlags(DWORD Flags)
@@ -34,7 +33,7 @@ DWORD TopButtonInt::CheckFlags(DWORD Flags)
if ( BitChanged(TTBBF_SHOWTOOLTIP)) {
dwFlags ^= TTBBF_SHOWTOOLTIP;
SendMessage(hwnd,BUTTONADDTOOLTIP,
- (WPARAM)((dwFlags & TTBBF_SHOWTOOLTIP)?tooltip:L""),BATF_UNICODE);
+ (WPARAM)((dwFlags & TTBBF_SHOWTOOLTIP) ? ptszTooltip : _T("")), BATF_TCHAR);
}
// next settings changing visual side, requires additional actions
if ( BitChanged(TTBBF_VISIBLE)) {
@@ -96,18 +95,19 @@ void TopButtonInt::LoadSettings()
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"));
+ mir_free(pszName);
+ pszName = DBGetString(0, TTB_OPTDIR, AS(buf, buf2, "_name"));
+
+ mir_free(ptszProgram);
+ ptszProgram = 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());
- if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, name, "_Visible"), oldv) > 0 )
+ arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), Buttons.getCount());
+ if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), oldv) > 0 )
dwFlags |= TTBBF_VISIBLE;
}
@@ -134,14 +134,14 @@ void TopButtonInt::SaveSettings(int *SepCnt, int *LaunchCnt)
char buf2[20];
AS(buf2, "Launch", buf1);
- DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, buf2, "_name"), name);
- DBWriteContactSettingTString(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"), program);
+ DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, buf2, "_name"), pszName);
+ DBWriteContactSettingTString(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"), ptszProgram);
DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos);
DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), dwFlags & TTBBF_VISIBLE);
}
else {
- DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, name, "_Position"), arrangedpos);
- DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, name, "_Visible"), dwFlags & TTBBF_VISIBLE);
+ DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), arrangedpos);
+ DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), dwFlags & TTBBF_VISIBLE);
}
}
@@ -160,9 +160,19 @@ void TopButtonInt::SetBitmap()
if (GetWindowLongPtr(hwnd, GWL_STYLE) & SS_ICON)
SetWindowLongPtr(hwnd, GWL_STYLE, curstyle | SS_ICON);
- HICON bicon = (hIconDn)?hIconDn:hIconUp;
-
- SendMessage(hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((bPushed)?(bicon):(hIconUp)));
- SendMessage(hwnd, BM_SETCHECK, bPushed?BST_CHECKED:BST_UNCHECKED ,0);
+ TCHAR* pTooltip;
+ if (bPushed) {
+ SendMessage(hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((hIconDn) ? hIconDn : hIconUp));
+ SendMessage(hwnd, BM_SETCHECK, BST_CHECKED, 0);
+
+ pTooltip = (ptszTooltipDn) ? ptszTooltipDn : ptszTooltipUp;
+ }
+ else {
+ SendMessage(hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIconUp);
+ SendMessage(hwnd, BM_SETCHECK, BST_UNCHECKED, 0);
+ pTooltip = ptszTooltipUp;
+ }
+ if (pTooltip)
+ SendMessage(hwnd, BUTTONADDTOOLTIP, (WPARAM)TranslateTH(hLangpack, pTooltip), BATF_TCHAR);
}
}
diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp
index 2662a44eef..5fd2edef80 100644
--- a/plugins/TopToolBar/ttbopt.cpp
+++ b/plugins/TopToolBar/ttbopt.cpp
@@ -32,7 +32,7 @@ static HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST
}
else index = ImageList_AddIcon(il, b->hIconUp);
- tmp = mir_a2t( b->name );
+ tmp = mir_a2t( b->pszName );
tvis.item.pszText = TranslateTS(tmp);
}
tvis.item.iImage = tvis.item.iSelectedImage = index;
@@ -273,17 +273,15 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
TreeView_SetItem(hTree, &tvi);
}
- if (btn->name) free(btn->name);
GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255);
- btn->name = _strdup( _T2A(buf));
-
- if (btn->program) free(btn->program);
- GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255);
- btn->program = _tcsdup(buf);
+ replaceStr(btn->pszName, _T2A(buf));
tvi.mask = TVIF_TEXT;
- tvi.pszText = mir_a2t( btn->name );
+ tvi.pszText = buf;
TreeView_SetItem(hTree, &tvi);
+
+ GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255);
+ replaceStrT(btn->ptszProgram, buf);
}
break;
}
@@ -415,13 +413,13 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), enable);
- if (btn->name != NULL)
- SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->name);
+ if (btn->pszName != NULL)
+ SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->pszName);
else
SetDlgItemTextA(hwndDlg, IDC_ENAME, "");
- if (btn->program != NULL)
- SetDlgItemText(hwndDlg, IDC_EPATH, btn->program);
+ if (btn->ptszProgram != NULL)
+ SetDlgItemText(hwndDlg, IDC_EPATH, btn->ptszProgram);
else
SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
}