summaryrefslogtreecommitdiff
path: root/plugins/TopToolBar/topbutton.cpp
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/TopToolBar/topbutton.cpp
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/TopToolBar/topbutton.cpp')
-rw-r--r--plugins/TopToolBar/topbutton.cpp54
1 files changed, 32 insertions, 22 deletions
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);
}
}