From: <zou...@us...> - 2008-02-11 11:00:40
|
Revision: 1001 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1001&view=rev Author: zouzou123gen Date: 2008-02-10 11:19:16 -0800 (Sun, 10 Feb 2008) Log Message: ----------- fix ampersands in tab menu titles, revert some changes of r996 Modified Paths: -------------- dcplusplus/trunk/smartwin/SmartUtil/StringUtils.cpp dcplusplus/trunk/smartwin/SmartUtil/StringUtils.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h dcplusplus/trunk/smartwin/source/widgets/WidgetTabSheet.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/MDIChildFrame.h dcplusplus/trunk/win32/PrivateFrame.cpp Modified: dcplusplus/trunk/smartwin/SmartUtil/StringUtils.cpp =================================================================== --- dcplusplus/trunk/smartwin/SmartUtil/StringUtils.cpp 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/smartwin/SmartUtil/StringUtils.cpp 2008-02-10 19:19:16 UTC (rev 1001) @@ -3,12 +3,6 @@ #include "UtilSystemHeaders.h" namespace SmartUtil { - tstring cutText(tstring str, unsigned int maxLength) { - if(str.length() > maxLength) - str = str.substr(0, maxLength - 3) + _T("..."); - return str; - } - tstring escapeMenu(tstring str) { tstring::size_type i = 0; while( (i = str.find(_T('&'), i)) != tstring::npos) { Modified: dcplusplus/trunk/smartwin/SmartUtil/StringUtils.h =================================================================== --- dcplusplus/trunk/smartwin/SmartUtil/StringUtils.h 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/smartwin/SmartUtil/StringUtils.h 2008-02-10 19:19:16 UTC (rev 1001) @@ -4,7 +4,6 @@ #include "tstring.h" namespace SmartUtil { -tstring cutText(tstring str, unsigned int maxLength); tstring escapeMenu(tstring str); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h 2008-02-10 19:19:16 UTC (rev 1001) @@ -130,12 +130,9 @@ // Commented in AspectSelection int getSelectedIndex() const; - /// Returns the text of the currently selected tab - /** Use this function to retrieve the header text of the currently selected tab. - */ - SmartUtil::tstring getSelectedHeader() const; + SmartUtil::tstring getText(unsigned idx) const; - void setHeader(unsigned idx, const SmartUtil::tstring& text); + void setText(unsigned idx, const SmartUtil::tstring& text); /// Setting the event handler for the "selection changing" event /** The event handler must have the signature "bool foo( WidgetTabSheet * Widget, @@ -322,10 +319,10 @@ TabCtrl_SetCurSel( this->handle(), idx ); } -inline void WidgetTabSheet::setHeader( unsigned index, const SmartUtil::tstring& header ) +inline void WidgetTabSheet::setText( unsigned index, const SmartUtil::tstring& text ) { TCITEM item = { TCIF_TEXT }; - item.pszText = const_cast < TCHAR * >( header.c_str() ); + item.pszText = const_cast < TCHAR * >( text.c_str() ); TabCtrl_SetItem(this->handle(), index, &item); } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2008-02-10 19:19:16 UTC (rev 1001) @@ -44,6 +44,8 @@ WidgetChildWindow* getActive(); void setActive(WidgetChildWindow* w) { setActive(findTab(w)); } + SmartUtil::tstring getTabText(WidgetChildWindow* w); + void onTitleChanged(const std::tr1::function<void (const SmartUtil::tstring&)>& f) { titleChangedFunction = f; } @@ -60,8 +62,6 @@ void create( const Seed & cs = Seed() ); - enum { MAX_TITLE_LENGTH = 20 }; - protected: friend class WidgetCreator<WidgetTabView>; @@ -70,6 +70,8 @@ virtual ~WidgetTabView() { } private: + enum { MAX_TITLE_LENGTH = 20 }; + struct TabInfo { TabInfo(WidgetChildWindow* w_) : w(w_) { } WidgetChildWindow* w; Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabSheet.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTabSheet.cpp 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabSheet.cpp 2008-02-10 19:19:16 UTC (rev 1001) @@ -59,19 +59,17 @@ TabCtrl_SetImageList(handle(), imageList->handle()); } -inline SmartUtil::tstring WidgetTabSheet::getSelectedHeader() const +SmartUtil::tstring WidgetTabSheet::getText(unsigned idx) const { - TCITEM item; - item.mask = TCIF_TEXT; + TCITEM item = { TCIF_TEXT }; TCHAR buffer[200]; item.cchTextMax = 198; item.pszText = buffer; - if ( !TabCtrl_GetItem( this->handle(), getSelectedIndex(), & item ) ) + if ( !TabCtrl_GetItem( this->handle(), idx, & item ) ) { - throw xCeption( _T( "Couldn't retrieve text of currently selected TabSheet item." ) ); + throw xCeption( _T( "Couldn't retrieve text in WidgetTabSheet::getText." ) ); } return buffer; } - } Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-02-10 19:19:16 UTC (rev 1001) @@ -92,6 +92,13 @@ titleChangedFunction(SmartUtil::tstring()); } +SmartUtil::tstring WidgetTabView::getTabText(WidgetChildWindow* w) { + int i = findTab(w); + if(i != -1) + return tab->getText(i); + return SmartUtil::tstring(); +} + void WidgetTabView::onTabContextMenu(WidgetChildWindow* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f) { TabInfo* ti = getTabInfo(w); if(ti) { @@ -174,7 +181,7 @@ bool WidgetTabView::handleTextChanging(WidgetChildWindow* w, const SmartUtil::tstring& newText) { int i = findTab(w); if(i != -1) { - tab->setHeader(i, formatTitle(newText)); + tab->setText(i, formatTitle(newText)); layout(); if((i == active) && titleChangedFunction) @@ -184,7 +191,9 @@ } SmartUtil::tstring WidgetTabView::formatTitle(SmartUtil::tstring title) { - return SmartUtil::escapeMenu(SmartUtil::cutText(title, MAX_TITLE_LENGTH)); + if(title.length() > MAX_TITLE_LENGTH) + title = title.substr(0, MAX_TITLE_LENGTH - 3) + _T("..."); + return SmartUtil::escapeMenu(title); } bool WidgetTabView::handleSized(const WidgetSizedEventResult& sz) { Modified: dcplusplus/trunk/win32/HubFrame.cpp =================================================================== --- dcplusplus/trunk/win32/HubFrame.cpp 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/win32/HubFrame.cpp 2008-02-10 19:19:16 UTC (rev 1001) @@ -1168,7 +1168,7 @@ bool HubFrame::handleTabContextMenu(const SmartWin::ScreenCoordinate& pt) { WidgetMenuExtendedPtr menu = createExtendedMenu(WinUtil::Seeds::menuExtended); - menu->setTitle(SmartUtil::cutText(getText(), SmartWin::WidgetTabView::MAX_TITLE_LENGTH)); + menu->setTitle(getParent()->getTabText(this)); if(!FavoriteManager::getInstance()->isFavoriteHub(url)) { menu->appendItem(IDC_ADD_TO_FAVORITES, T_("Add To &Favorites"), std::tr1::bind(&HubFrame::addAsFavorite, this), SmartWin::BitmapPtr(new SmartWin::Bitmap(IDB_FAVORITE_HUBS))); Modified: dcplusplus/trunk/win32/MDIChildFrame.h =================================================================== --- dcplusplus/trunk/win32/MDIChildFrame.h 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/win32/MDIChildFrame.h 2008-02-10 19:19:16 UTC (rev 1001) @@ -187,7 +187,7 @@ bool handleContextMenu(const SmartWin::ScreenCoordinate& pt) { SmartWin::WidgetMenuExtended::ObjectType menu = createExtendedMenu(WinUtil::Seeds::menuExtended); - menu->setTitle(SmartUtil::cutText(getText(), SmartWin::WidgetTabView::MAX_TITLE_LENGTH)); + menu->setTitle(getParent()->getTabText(this)); menu->appendItem(IDC_CLOSE_WINDOW, T_("&Close"), std::tr1::bind(&ThisType::close, this, true), SmartWin::BitmapPtr(new SmartWin::Bitmap(IDB_EXIT))); menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON); return true; Modified: dcplusplus/trunk/win32/PrivateFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PrivateFrame.cpp 2008-02-10 00:32:56 UTC (rev 1000) +++ dcplusplus/trunk/win32/PrivateFrame.cpp 2008-02-10 19:19:16 UTC (rev 1001) @@ -375,7 +375,7 @@ bool PrivateFrame::handleTabContextMenu(const SmartWin::ScreenCoordinate& pt) { WidgetMenuExtendedPtr menu = createExtendedMenu(WinUtil::Seeds::menuExtended); - menu->setTitle(SmartUtil::cutText(getText(), SmartWin::WidgetTabView::MAX_TITLE_LENGTH)); + menu->setTitle(getParent()->getTabText(this)); menu->appendItem(IDC_GETLIST, T_("&Get file list"), std::tr1::bind(&PrivateFrame::handleGetList, this)); menu->appendItem(IDC_MATCH_QUEUE, T_("&Match queue"), std::tr1::bind(&PrivateFrame::handleMatchQueue, this)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |