linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #03841
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2483: terminate toolbar strings with 2 nulls
------------------------------------------------------------
revno: 2483
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2011-04-08 18:37:08 +0200
message:
terminate toolbar strings with 2 nulls
modified:
dwt/src/util/GDI.cpp
dwt/src/widgets/ToolBar.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dwt/src/util/GDI.cpp'
--- dwt/src/util/GDI.cpp 2011-04-07 14:57:29 +0000
+++ dwt/src/util/GDI.cpp 2011-04-08 16:37:08 +0000
@@ -56,9 +56,7 @@
}
const float& dpiFactor() {
- static float factor = 0;
- if(!factor)
- factor = static_cast<float>(UpdateCanvas(reinterpret_cast<HWND>(0)).getDeviceCaps(LOGPIXELSX)) / 96.0;
+ static float factor = static_cast<float>(UpdateCanvas(reinterpret_cast<HWND>(0)).getDeviceCaps(LOGPIXELSX)) / 96.0;
return factor;
}
=== modified file 'dwt/src/widgets/ToolBar.cpp'
--- dwt/src/widgets/ToolBar.cpp 2011-03-18 21:48:06 +0000
+++ dwt/src/widgets/ToolBar.cpp 2011-04-08 16:37:08 +0000
@@ -103,28 +103,21 @@
void ToolBar::addButton(const std::string& id, int image, const tstring& text, bool showText,
unsigned helpId, const Dispatcher::F& f, const DropDownFunction& dropDownF)
{
- TBBUTTON tb = { 0 };
- tb.iBitmap = image;
- tb.idCommand = id_offset + buttons.size();
- tb.fsState = TBSTATE_ENABLED;
- tb.fsStyle = BTNS_AUTOSIZE;
+ TBBUTTON tb = { image, id_offset + buttons.size(), TBSTATE_ENABLED, BTNS_AUTOSIZE };
if(dropDownF)
tb.fsStyle |= f ? BTNS_DROPDOWN : BTNS_WHOLEDROPDOWN;
- if(showText)
+ if(showText) {
tb.fsStyle |= BTNS_SHOWTEXT;
+ tstring str = text;
+ str.push_back('\0'); // terminated by 2 nulls
+ tb.iString = sendMessage(TB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
+ } else {
+ static tstring emptyString;
+ tb.iString = reinterpret_cast<INT_PTR>(emptyString.c_str());
+ }
Button button = { tb, id, text, helpId, f, dropDownF };
buttons.push_back(button);
-
- Button& b = buttons.back();
- if(hasStyle(CCS_ADJUSTABLE)) {
- /* in a customizable toolbar, shift + drag gets messed up when we add text here; so resort
- to an empty string. not a problem for tooltips since we manually handle TBN_GETINFOTIP. */
- static tstring emptyString;
- b.button.iString = reinterpret_cast<INT_PTR>(emptyString.c_str());
- } else {
- b.button.iString = sendMessage(TB_ADDSTRING, 0, reinterpret_cast<LPARAM>(b.text.c_str()));
- }
}
std::vector<std::string> ToolBar::getLayout() const {