linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #01683
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2197: fix scrambled tab menu titles
------------------------------------------------------------
revno: 2197
committer: poy <poy@xxxxxxxxxx>
branch nick: repo
timestamp: Sat 2010-08-07 18:35:11 +0200
message:
fix scrambled tab menu titles
modified:
dwt/include/dwt/widgets/TabView.h
dwt/src/widgets/Menu.cpp
dwt/src/widgets/TabView.cpp
win32/MDIChildFrame.h
--
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/include/dwt/widgets/TabView.h'
--- dwt/include/dwt/widgets/TabView.h 2010-08-06 22:46:00 +0000
+++ dwt/include/dwt/widgets/TabView.h 2010-08-07 16:35:11 +0000
@@ -102,8 +102,6 @@
IconPtr getIcon(ContainerPtr w) const;
void setIcon(ContainerPtr w, const IconPtr& icon);
- tstring getText(ContainerPtr w) const;
-
void onTitleChanged(const TitleChangedFunction& f) {
titleChangedFunction = f;
}
@@ -203,7 +201,6 @@
void swapWidgets(ContainerPtr oldW, ContainerPtr newW);
IconPtr getIcon(unsigned index) const;
- tstring getText(unsigned idx) const;
void setText(unsigned idx, const tstring& text);
void redraw(unsigned index);
void draw(Canvas& canvas, unsigned index, Rectangle&& rect, bool isSelected);
=== modified file 'dwt/src/widgets/Menu.cpp'
--- dwt/src/widgets/Menu.cpp 2010-07-10 14:36:48 +0000
+++ dwt/src/widgets/Menu.cpp 2010-08-07 16:35:11 +0000
@@ -41,6 +41,7 @@
#include <dwt/resources/Pen.h>
#include <dwt/DWTException.h>
#include <dwt/util/check.h>
+#include <dwt/util/StringUtils.h>
#include <dwt/util/win32/Version.h>
#include <dwt/dwt_vsstyle.h>
@@ -380,7 +381,7 @@
const bool hasTitle = !itsTitle.empty();
// set the new title
- itsTitle = title;
+ itsTitle = util::escapeMenu(title);
if(!drawSidebar) {
// init struct for title info
@@ -610,6 +611,8 @@
drawTextFormat |= DT_HIDEPREFIX;
unsigned drawAccelFormat = drawTextFormat | DT_RIGHT;
drawTextFormat |= (popup && !wrapper->isTitle) ? DT_LEFT : DT_CENTER;
+ if(wrapper->isTitle)
+ drawTextFormat |= DT_WORD_ELLIPSIS;
if(theme) {
drawThemeText(canvas, part, state, text, drawTextFormat, textRectangle);
@@ -729,7 +732,8 @@
wrapper->isTitle ? itsTitleFont :
wrapper->isDefault ? boldFont :
font);
- itemWidth = textSize.x;
+ if(!wrapper->isTitle) // the title will adjust its hor size per others and add ellipsis if needed
+ itemWidth = textSize.x;
itemHeight = textSize.y;
// find item icon
=== modified file 'dwt/src/widgets/TabView.cpp'
--- dwt/src/widgets/TabView.cpp 2010-08-07 14:25:29 +0000
+++ dwt/src/widgets/TabView.cpp 2010-08-07 16:35:11 +0000
@@ -241,13 +241,6 @@
return IconPtr();
}
-tstring TabView::getText(ContainerPtr w) const {
- int i = findTab(w);
- if(i != -1)
- return getText(i);
- return tstring();
-}
-
void TabView::onTabContextMenu(ContainerPtr w, const ContextMenuFunction& f) {
TabInfo* ti = getTabInfo(w);
if(ti) {
@@ -793,19 +786,6 @@
}
}
-tstring TabView::getText(unsigned idx) const
-{
- TCITEM item = { TCIF_TEXT };
- TCHAR buffer[1024];
- item.cchTextMax = (sizeof(buffer) / sizeof(TCHAR)) - 1 ;
- item.pszText = buffer;
- if ( !TabCtrl_GetItem( this->handle(), idx, & item ) )
- {
- throw Win32Exception("Couldn't retrieve text in TabView::getText.");
- }
- return buffer;
-}
-
void TabView::redraw(unsigned index) {
RECT rect;
if(TabCtrl_GetItemRect(handle(), index, &rect)) {
=== modified file 'win32/MDIChildFrame.h'
--- win32/MDIChildFrame.h 2010-07-10 14:36:48 +0000
+++ win32/MDIChildFrame.h 2010-08-07 16:35:11 +0000
@@ -214,7 +214,7 @@
bool handleContextMenu(const dwt::ScreenCoordinate& pt) {
dwt::Menu::ObjectType menu = addChild(WinUtil::Seeds::menu);
- menu->setTitle(getParent()->getText(this), getParent()->getIcon(this));
+ menu->setTitle(getText(), getParent()->getIcon(this));
tabMenuImpl(menu);
menu->appendItem(T_("&Close"), std::bind(&ThisType::close, this, true), WinUtil::menuIcon(IDI_EXIT));