|
From: <zou...@us...> - 2008-02-17 22:27:18
|
Revision: 1014
http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1014&view=rev
Author: zouzou123gen
Date: 2008-02-17 14:27:10 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
menu changes: simplify parent args, use the wrapper in draw functions; fix a GDB-specific crash
Modified Paths:
--------------
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMenu.h
dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp
dcplusplus/trunk/win32/ADLSearchFrame.cpp
dcplusplus/trunk/win32/DirectoryListingFrame.cpp
dcplusplus/trunk/win32/FavHubsFrame.cpp
dcplusplus/trunk/win32/FinishedFrameBase.h
dcplusplus/trunk/win32/HubFrame.cpp
dcplusplus/trunk/win32/MDIChildFrame.h
dcplusplus/trunk/win32/MainWindow.cpp
dcplusplus/trunk/win32/PrivateFrame.cpp
dcplusplus/trunk/win32/PublicHubsFrame.cpp
dcplusplus/trunk/win32/QueueFrame.cpp
dcplusplus/trunk/win32/SearchFrame.cpp
dcplusplus/trunk/win32/ShellContextMenu.cpp
dcplusplus/trunk/win32/ShellContextMenu.h
dcplusplus/trunk/win32/SpyFrame.cpp
dcplusplus/trunk/win32/TransferView.cpp
dcplusplus/trunk/win32/UsersFrame.cpp
dcplusplus/trunk/win32/WaitingUsersFrame.cpp
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMenu.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMenu.h 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMenu.h 2008-02-17 22:27:10 UTC (rev 1014)
@@ -73,46 +73,6 @@
*/
typedef std::tr1::shared_ptr< MenuItemData > MenuItemDataPtr;
-namespace private_
-{
- // ////////////////////////////////////////////////////////////////////////
- // Menu item data wrapper, used internally
- // MENUITEMINFO's dwItemData *should* point to it
- // ////////////////////////////////////////////////////////////////////////
- struct ItemDataWrapper
- {
- // The menu item belongs to
- // For some messages (e.g. WM_MEASUREITEM),
- // Windows doesn't specify it, so
- // we need to keep this
- HMENU menu;
-
- // Item index in the menu
- // This is needed, because ID's for items
- // are not unique (although Windows claims)
- // e.g. we can have an item with ID 0,
- // that is either separator or popup menu
- int index;
-
- // Specifies if item is menu title
- bool isMenuTitleItem;
-
- // Contains item data
- MenuItemDataPtr data;
-
- // Wrapper Constructor
- ItemDataWrapper( HMENU owner, int itemIndex, MenuItemDataPtr itemData, bool isTitleItem = false )
- : menu( owner )
- , index( itemIndex )
- , isMenuTitleItem( isTitleItem )
- , data( itemData )
- {}
-
- ~ItemDataWrapper()
- {}
- };
-}
-
/// Struct for coloring different areas of WidgetMenu
/** Contains the different color settings of the WidgetMenu <br>
* Default values to constructor makes menu look roughly like MSVC++7.1 menus
@@ -164,15 +124,8 @@
* Class for creating a Menu Control which then can be attached to e.g. a
* WidgetWindow. <br>
* Note for Desktop version only! <br>
-* After you have created a menu you must call WidgetMenu::attach() to make it
-* "attach" to the WidgetWindow you want it to belong to. <br>
-* Do not be fooled, a WidgetMenu is a much more advanced menu type then the
-* "normal" WidgetMenu and contains support for visualizations far beyond the
-* capabilities of the WidgetMenu. <br>
-* If you need those truly awesome visual menu effects use this menu control instead
-* of the WidgetMenu.
*/
-class WidgetMenu : public boost::enable_shared_from_this< WidgetMenu >
+class WidgetMenu : public boost::enable_shared_from_this< WidgetMenu >, boost::noncopyable
{
// friends
friend class WidgetCreator< WidgetMenu >;
@@ -244,8 +197,8 @@
return itsHandle;
}
- HWND getParent() const {
- return itsParent ? itsParent->handle() : 0;
+ Widget* getParent() const {
+ return itsParent;
}
/// Actually creates the menu
@@ -400,7 +353,7 @@
* < li >TPM_VERPOSANIMATION : Animates the menu from top to bottom< /li >
* < /ul >
*/
- unsigned trackPopupMenu( Widget * mainWindow, const ScreenCoordinate& sc, unsigned flags = 0 );
+ unsigned trackPopupMenu( const ScreenCoordinate& sc, unsigned flags = 0 );
/// Sets menu title
/** A WidgetMenu can have a title, this function sets that title
@@ -475,24 +428,59 @@
/// Constructor Taking pointer to parent
explicit WidgetMenu( SmartWin::Widget * parent );
+ // ////////////////////////////////////////////////////////////////////////
+ // Menu item data wrapper, used internally
+ // MENUITEMINFO's dwItemData *should* point to it
+ // ////////////////////////////////////////////////////////////////////////
+ struct ItemDataWrapper
+ {
+ // The menu item belongs to
+ // For some messages (e.g. WM_MEASUREITEM),
+ // Windows doesn't specify it, so
+ // we need to keep this
+ const WidgetMenu* menu;
+
+ // Item index in the menu
+ // This is needed, because ID's for items
+ // are not unique (although Windows claims)
+ // e.g. we can have an item with ID 0,
+ // that is either separator or popup menu
+ int index;
+
+ // Specifies if item is menu title
+ bool isMenuTitleItem;
+
+ // Contains item data
+ MenuItemDataPtr data;
+
+ // Wrapper Constructor
+ ItemDataWrapper( const WidgetMenu* menu_, int itemIndex, MenuItemDataPtr itemData, bool isTitleItem = false )
+ : menu( menu_ )
+ , index( itemIndex )
+ , isMenuTitleItem( isTitleItem )
+ , data( itemData )
+ {}
+
+ ~ItemDataWrapper()
+ {}
+ };
+
// This is used during menu destruction
- static void destroyItemDataWrapper( private_::ItemDataWrapper * wrapper );
+ static void destroyItemDataWrapper( ItemDataWrapper * wrapper );
// True is menu is "system menu" (icon in top left of window)
bool isSysMenu;
+ // its sub menus
+ std::vector< ObjectType > itsChildren;
// work around for gcc
std::vector< ObjectType > & itsChildrenRef;
+ // its item data
+ std::vector < ItemDataWrapper * > itsItemData;
// work around for gcc
- std::vector < private_::ItemDataWrapper * > & itsItemDataRef;
+ std::vector < ItemDataWrapper * > & itsItemDataRef;
- // its sub menus
- std::vector< ObjectType > itsChildren;
-
- // its item data
- std::vector < private_::ItemDataWrapper * > itsItemData;
-
HMENU itsHandle;
Widget* itsParent;
@@ -514,13 +502,11 @@
typedef std::map<unsigned, Widget::CallbackType> CallbackMap;
CallbackMap callbacks;
- void addCommands(Widget* widget);
+ void addCommands();
// Returns item index in the menu item list
// If no item with specified id is found, - 1 is returned
int getItemIndex( unsigned int id );
-
- WidgetMenu( const WidgetMenu & ); // Never implemented intentionally
};
// end namespace SmartWin
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -49,6 +49,7 @@
itsParent(parent),
drawSidebar(false)
{
+ xAssert(itsParent != NULL, _T("A WidgetMenu must have a parent"));
}
void WidgetMenu::create(const Seed& cs)
@@ -84,15 +85,15 @@
void WidgetMenu::attach()
{
- addCommands(itsParent);
- if ( ::SetMenu( getParent(), this->itsHandle ) == FALSE )
+ addCommands();
+ if ( ::SetMenu( itsParent->handle(), itsHandle ) == FALSE )
throw xCeption( _T( "Couldn't attach menu to the parent window" ) );
}
WidgetMenu::ObjectType WidgetMenu::appendPopup( const SmartUtil::tstring & text, MenuItemDataPtr itemData )
{
// create popup menu pointer
- ObjectType retVal ( new WidgetMenu(this->itsParent) );
+ ObjectType retVal ( new WidgetMenu(itsParent) );
retVal->create( Seed(ownerDrawn, itsColorInfo) );
// init structure for new item
@@ -110,21 +111,21 @@
info.hSubMenu = retVal->handle();
// get position to insert
- int position = ::GetMenuItemCount( this->itsHandle );
+ int position = ::GetMenuItemCount( itsHandle );
- private_::ItemDataWrapper * wrapper;
+ ItemDataWrapper * wrapper = NULL;
if(ownerDrawn) {
info.fMask |= MIIM_DATA | MIIM_FTYPE;
info.fType = MFT_OWNERDRAW;
// create item data
- wrapper = new private_::ItemDataWrapper( this->itsHandle, position, itemData );
- info.dwItemData = reinterpret_cast< UINT_PTR >( wrapper );
+ wrapper = new ItemDataWrapper( this, position, itemData );
+ info.dwItemData = reinterpret_cast< ULONG_PTR >( wrapper );
}
// append to this menu at the end
- if ( ::InsertMenuItem( this->itsHandle, position, TRUE, & info ) )
+ if ( ::InsertMenuItem( itsHandle, position, TRUE, & info ) )
{
if(ownerDrawn)
itsItemData.push_back( wrapper );
@@ -137,10 +138,10 @@
WidgetMenu::ObjectType WidgetMenu::getSystemMenu()
{
// get system menu for the utmost parent
- HMENU handle = ::GetSystemMenu( this->getParent(), FALSE );
+ HMENU handle = ::GetSystemMenu( itsParent->handle(), FALSE );
// create pointer to system menu
- ObjectType sysMenu( new WidgetMenu( this->getParent() ) );
+ ObjectType sysMenu( new WidgetMenu( itsParent->handle() ) );
// create(take) system menu
sysMenu->isSysMenu = true;
@@ -154,22 +155,22 @@
}
#endif
-void WidgetMenu::addCommands(Widget* widget) {
+void WidgetMenu::addCommands() {
for(CallbackMap::iterator i = callbacks.begin(); i != callbacks.end(); ++i) {
- widget->setCallback(Message(WM_COMMAND, i->first), i->second);
+ itsParent->setCallback(Message(WM_COMMAND, i->first), i->second);
}
for(std::vector< ObjectType >::iterator i = itsChildren.begin(); i != itsChildren.end(); ++i) {
- (*i)->addCommands(widget);
+ (*i)->addCommands();
}
}
int WidgetMenu::getItemIndex( unsigned int id )
{
int index = 0;
- const int itemCount = ::GetMenuItemCount( this->itsHandle );
+ const int itemCount = ::GetMenuItemCount( itsHandle );
for ( index = 0; index < itemCount; ++index )
- if ( ::GetMenuItemID( this->itsHandle, index ) == id ) // exit the loop if found
+ if ( ::GetMenuItemID( itsHandle, index ) == id ) // exit the loop if found
return index;
return - 1;
@@ -193,7 +194,7 @@
std::for_each( itsItemDataRef.begin(), itsItemDataRef.end(), destroyItemDataWrapper );
}
-void WidgetMenu::destroyItemDataWrapper( private_::ItemDataWrapper * wrapper )
+void WidgetMenu::destroyItemDataWrapper( ItemDataWrapper * wrapper )
{
if ( 0 != wrapper )
delete wrapper;
@@ -270,12 +271,12 @@
// set flag
mi.fMask = MIIM_STRING;
- if ( ::GetMenuItemInfo( this->itsHandle, id, byPosition, & mi ) == FALSE )
+ if ( ::GetMenuItemInfo( itsHandle, id, byPosition, & mi ) == FALSE )
throw xCeption( _T( "Couldn't get item info in WidgetMenu::getText" ) );
boost::scoped_array< TCHAR > buffer( new TCHAR[++mi.cch] );
mi.dwTypeData = buffer.get();
- if ( ::GetMenuItemInfo( this->itsHandle, id, byPosition, & mi ) == FALSE )
+ if ( ::GetMenuItemInfo( itsHandle, id, byPosition, & mi ) == FALSE )
throw xCeption( _T( "Couldn't get item info in WidgetMenu::getText" ) );
return mi.dwTypeData;
}
@@ -288,7 +289,7 @@
mi.fMask = MIIM_STRING;
mi.dwTypeData = (TCHAR*) text.c_str();
- if ( ::SetMenuItemInfo( this->itsHandle, id, FALSE, & mi ) == FALSE )
+ if ( ::SetMenuItemInfo( itsHandle, id, FALSE, & mi ) == FALSE )
throw xCeption( _T( "Couldn't set item info in WidgetMenu::setText" ) );
}
@@ -320,13 +321,13 @@
// created info for title item
MenuItemDataPtr data( new MenuItemData( itsTitleFont ) );
- private_::ItemDataWrapper * wrapper = new private_::ItemDataWrapper( this->itsHandle, 0, data, true );
+ ItemDataWrapper * wrapper = new ItemDataWrapper( this, 0, data, true );
// set item data
- info.dwItemData = ( ULONG_PTR ) wrapper;
+ info.dwItemData = reinterpret_cast< ULONG_PTR >( wrapper );
- if ( ( !hasTitle && ::InsertMenuItem( this->itsHandle, 0, TRUE, & info ) ) ||
- ( hasTitle && ::SetMenuItemInfo( this->itsHandle, 0, TRUE, & info ) ) )
+ if ( ( !hasTitle && ::InsertMenuItem( itsHandle, 0, TRUE, & info ) ) ||
+ ( hasTitle && ::SetMenuItemInfo( itsHandle, 0, TRUE, & info ) ) )
{
size_t i = 0;
@@ -345,18 +346,18 @@
if ( ( id != 0 ) || ( drawInfo->CtlType != ODT_MENU ) ) // if not intended for us
return false;
+ // get item data wrapper
+ ItemDataWrapper * wrapper = reinterpret_cast< ItemDataWrapper * >( drawInfo->itemData );
+ xAssert( wrapper != 0, _T( "Unsupported menu item in drawItem()" ) );
+
// setup colors
- MenuColorInfo colorInfo = this->itsColorInfo;
+ MenuColorInfo colorInfo = wrapper->menu->itsColorInfo;
COLORREF colorMenuBar = colorInfo.colorMenuBar;
COLORREF colorMenuDraw = colorInfo.colorMenu; // color for drawing menu
COLORREF colorFillHighlighted = ColorUtilities::lightenColor( colorInfo.colorHighlight, 0.7 );
- // get item data wrapper
- private_::ItemDataWrapper * wrapper = reinterpret_cast< private_::ItemDataWrapper * >( drawInfo->itemData );
- xAssert( wrapper != 0, _T( "Unsupported menu item in drawItem()" ) );
-
// if processing menu bar
- const bool isMenuBar = ::GetMenu( getParent() ) == wrapper->menu;
+ const bool isMenuBar = ::GetMenu( wrapper->menu->getParent()->handle() ) == wrapper->menu->handle();
// change menu draw color for menubars
if ( isMenuBar )
@@ -370,7 +371,7 @@
// set flags
info.fMask = MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_DATA | MIIM_STATE | MIIM_STRING;
- if ( ::GetMenuItemInfo( wrapper->menu, wrapper->index, TRUE, & info ) == FALSE )
+ if ( ::GetMenuItemInfo( wrapper->menu->handle(), wrapper->index, TRUE, & info ) == FALSE )
throw xCeption ( _T( "Couldn't get menu item info in drawItem()" ) );
// check if item is owner drawn
@@ -411,7 +412,7 @@
drawInfo->rcItem.bottom - drawInfo->rcItem.top ); // height
// setup buffered canvas
- BufferedCanvas< FreeCanvas > canvas( reinterpret_cast<HWND>(wrapper->menu), drawInfo->hDC );
+ BufferedCanvas< FreeCanvas > canvas( reinterpret_cast<HWND>(wrapper->menu->handle()), drawInfo->hDC );
// this will conain adjusted sidebar width
int sidebarWidth = 0;
@@ -425,10 +426,10 @@
HFONT titleFont = NULL;
// get title font info and adjust item rectangle
- if ( this->drawSidebar )
+ if ( wrapper->menu->drawSidebar )
{
// get title font
- FontPtr font = this->itsTitleFont;
+ FontPtr font = wrapper->menu->itsTitleFont;
// get logical info for title font
::GetObject( font->handle(), sizeof( LOGFONT ), & lf );
@@ -444,7 +445,7 @@
memset( & textSize, 0, sizeof( SIZE ) );
HGDIOBJ oldFont = ::SelectObject( canvas.handle(), titleFont );
- ::GetTextExtentPoint32( canvas.handle(), this->itsTitle.c_str(), ( int ) this->itsTitle.size(), & textSize );
+ ::GetTextExtentPoint32( canvas.handle(), wrapper->menu->itsTitle.c_str(), ( int ) wrapper->menu->itsTitle.size(), & textSize );
::SelectObject( canvas.handle(), oldFont );
// set sidebar width to text height
@@ -456,7 +457,7 @@
}
// draw sidebar with menu title
- if ( ( drawInfo->itemAction & ODA_DRAWENTIRE ) && ( this->drawSidebar ) && !this->itsTitle.empty() )
+ if ( ( drawInfo->itemAction & ODA_DRAWENTIRE ) && ( wrapper->menu->drawSidebar ) && !wrapper->menu->itsTitle.empty() )
{
// select title font and color
HGDIOBJ oldFont = ::SelectObject ( canvas.handle(), titleFont );
@@ -479,7 +480,7 @@
// draw title
textRectangle.pos.y += 10;
- canvas.drawText( this->itsTitle, textRectangle, DT_BOTTOM | DT_SINGLELINE );
+ canvas.drawText( wrapper->menu->itsTitle, textRectangle, DT_BOTTOM | DT_SINGLELINE );
// clear
canvas.setTextColor( oldColor );
@@ -561,7 +562,7 @@
// get item text
const int length = info.cch + 1;
std::vector< TCHAR > buffer( length );
- int count = ::GetMenuString( wrapper->menu, wrapper->index, & buffer[0], length, MF_BYPOSITION );
+ int count = ::GetMenuString( wrapper->menu->handle(), wrapper->index, & buffer[0], length, MF_BYPOSITION );
SmartUtil::tstring itemText( buffer.begin(), buffer.begin() + count );
// index will contain accelerator position
@@ -583,7 +584,7 @@
canvas.setTextColor( isGrayed ? ::GetSysColor( COLOR_GRAYTEXT ) : wrapper->isMenuTitleItem ? colorInfo.colorTitleText : data->TextColor );
// Select item font
- FontPtr font((static_cast<int>(::GetMenuDefaultItem(wrapper->menu, TRUE, GMDI_USEDISABLED)) == wrapper->index) ? itsTitleFont : data->Font);
+ FontPtr font((static_cast<int>(::GetMenuDefaultItem(wrapper->menu->handle(), TRUE, GMDI_USEDISABLED)) == wrapper->index) ? itsTitleFont : data->Font);
HGDIOBJ oldFont = ::SelectObject( canvas.handle(), font->handle() );
@@ -690,7 +691,7 @@
}
// blast buffer into screen
- if ( ( drawInfo->itemAction & ODA_DRAWENTIRE ) && this->drawSidebar ) // adjustment for sidebar
+ if ( ( drawInfo->itemAction & ODA_DRAWENTIRE ) && wrapper->menu->drawSidebar ) // adjustment for sidebar
{
itemRectangle.pos.x -= sidebarWidth;
itemRectangle.size.x += sidebarWidth;
@@ -704,8 +705,8 @@
if ( measureInfo->CtlType != ODT_MENU ) // if not intended for us
return false;
- // get data wrapper
- private_::ItemDataWrapper * wrapper = reinterpret_cast< private_::ItemDataWrapper * >( measureInfo->itemData );
+ // get item data wrapper
+ ItemDataWrapper * wrapper = reinterpret_cast< ItemDataWrapper * >( measureInfo->itemData );
xAssert( wrapper != 0, _T( "Unsupported menu item type in measureItem()" ) );
// this will contain item size
@@ -721,7 +722,7 @@
info.fMask = MIIM_FTYPE | MIIM_DATA | MIIM_CHECKMARKS | MIIM_STRING;
// try to get item info
- if ( ::GetMenuItemInfo( wrapper->menu, wrapper->index, TRUE, & info ) == FALSE )
+ if ( ::GetMenuItemInfo( wrapper->menu->handle(), wrapper->index, TRUE, & info ) == FALSE )
throw xCeption ( _T( "Couldn't get item info in measureItem()" ) );
// check if item is owner drawn
@@ -736,11 +737,11 @@
}
// are we processing menu bar ?
- const bool isMenuBar = ::GetMenu( getParent() ) == wrapper->menu;
+ const bool isMenuBar = ::GetMenu( wrapper->menu->getParent()->handle() ) == wrapper->menu->handle();
// compute text width and height by simulating write to dc
// get its DC
- HDC hdc = ::GetDC( getParent() );
+ HDC hdc = ::GetDC( wrapper->menu->getParent()->handle() );
// get the item data
MenuItemDataPtr data = wrapper->data;
@@ -749,7 +750,7 @@
// get item text
const int length = info.cch + 1;
std::vector< TCHAR > buffer ( length );
- int count = ::GetMenuString( wrapper->menu, wrapper->index, & buffer[0], length, MF_BYPOSITION );
+ int count = ::GetMenuString( wrapper->menu->handle(), wrapper->index, & buffer[0], length, MF_BYPOSITION );
SmartUtil::tstring itemText ( buffer.begin(), buffer.begin() + count );
// now get text extents
@@ -761,7 +762,7 @@
::SelectObject( hdc, oldFont );
// release DC
- ::ReleaseDC( reinterpret_cast<HWND>(wrapper->menu), hdc );
+ ::ReleaseDC( reinterpret_cast<HWND>(wrapper->menu->handle()), hdc );
// adjust item size
itemWidth = textSize.cx + borderGap;
@@ -808,17 +809,17 @@
}
// adjust width for system menu items
- if ( this->isSysMenu )
+ if ( wrapper->menu->isSysMenu )
itemWidth = (std::max)( ( UINT ) minSysMenuItemWidth, itemWidth );
// adjust width for sidebar
- if ( this->drawSidebar )
+ if ( wrapper->menu->drawSidebar )
{
// get title text extents
SIZE textSize;
memset( & textSize, 0, sizeof( SIZE ) );
- ::GetTextExtentPoint32( hdc, this->itsTitle.c_str(), ( int ) this->itsTitle.size(), & textSize );
+ ::GetTextExtentPoint32( hdc, wrapper->menu->itsTitle.c_str(), ( int ) wrapper->menu->itsTitle.size(), & textSize );
itemWidth += textSize.cy;
}
@@ -840,34 +841,34 @@
itemInfo.fType = MFT_SEPARATOR;
// get position to insert
- int position = ::GetMenuItemCount( this->itsHandle );
+ int position = ::GetMenuItemCount( itsHandle );
- private_::ItemDataWrapper * wrapper;
+ ItemDataWrapper * wrapper = NULL;
if(ownerDrawn) {
itemInfo.fMask |= MIIM_DATA;
itemInfo.fType |= MFT_OWNERDRAW;
// create item data wrapper
- wrapper = new private_::ItemDataWrapper( this->itsHandle, position, MenuItemDataPtr( new MenuItemData() ) );
+ wrapper = new ItemDataWrapper( this, position, MenuItemDataPtr( new MenuItemData() ) );
itemInfo.dwItemData = reinterpret_cast< ULONG_PTR >( wrapper );
}
- if ( ::InsertMenuItem( this->itsHandle, position, TRUE, & itemInfo ) && ownerDrawn )
+ if ( ::InsertMenuItem( itsHandle, position, TRUE, & itemInfo ) && ownerDrawn )
itsItemDataRef.push_back( wrapper );
}
void WidgetMenu::removeItem( unsigned itemIndex )
{
// has sub menus ?
- HMENU popup = ::GetSubMenu( this->itsHandle, itemIndex );
+ HMENU popup = ::GetSubMenu( itsHandle, itemIndex );
// try to remove item
- if ( ::RemoveMenu( this->itsHandle, itemIndex, MF_BYPOSITION ) == TRUE )
+ if ( ::RemoveMenu( itsHandle, itemIndex, MF_BYPOSITION ) == TRUE )
{
size_t i = 0;
if(ownerDrawn) {
- private_::ItemDataWrapper * wrapper = 0;
+ ItemDataWrapper * wrapper = 0;
int itemRemoved = -1;
for ( i = 0; i < itsItemDataRef.size(); ++i )
@@ -913,7 +914,7 @@
int WidgetMenu::getCount()
{
- int count = ::GetMenuItemCount( this->itsHandle );
+ int count = ::GetMenuItemCount( itsHandle );
if( count == -1 )
throw xCeption( _T( "Couldn't get item count in getCount()" ) );
return count;
@@ -941,26 +942,26 @@
// set position to insert
bool itemExists = index != - 1;
- index = itemExists ? index : ::GetMenuItemCount( this->itsHandle );
+ index = itemExists ? index : ::GetMenuItemCount( itsHandle );
- private_::ItemDataWrapper * wrapper;
+ ItemDataWrapper * wrapper = NULL;
if(ownerDrawn) {
info.fMask |= MIIM_DATA | MIIM_FTYPE;
info.fType = MFT_OWNERDRAW;
// set item data
- wrapper = new private_::ItemDataWrapper( this->itsHandle, index, itemData );
+ wrapper = new ItemDataWrapper( this, index, itemData );
info.dwItemData = reinterpret_cast< ULONG_PTR >( wrapper );
}
- if ( ( !itemExists && ::InsertMenuItem( this->itsHandle, id, FALSE, & info ) == TRUE ) ||
- ( itemExists && ::SetMenuItemInfo( this->itsHandle, id, FALSE, & info ) == TRUE ) )
+ if ( ( !itemExists && ::InsertMenuItem( itsHandle, id, FALSE, & info ) == TRUE ) ||
+ ( itemExists && ::SetMenuItemInfo( itsHandle, id, FALSE, & info ) == TRUE ) )
{
if(ownerDrawn)
itsItemDataRef.push_back( wrapper );
}
else
- throw xCeption( _T( "Couldn't insert/update item in the WidgetMenu::appendItem" ) );
+ throw xCeption( _T( "Couldn't insert/update item in WidgetMenu::appendItem" ) );
}
void WidgetMenu::appendItem(unsigned int id, const SmartUtil::tstring & text, BitmapPtr image)
@@ -971,10 +972,9 @@
appendItem(id, text, itemData);
}
-unsigned WidgetMenu::trackPopupMenu( Widget * mainWindow, const ScreenCoordinate& sc, unsigned flags )
+unsigned WidgetMenu::trackPopupMenu( const ScreenCoordinate& sc, unsigned flags )
{
- xAssert( mainWindow != 0, _T( "Widget can't be null while trying to display Popup Menu" ) );
- addCommands(mainWindow);
+ addCommands();
long x = sc.getPoint().x, y = sc.getPoint().y;
@@ -985,7 +985,7 @@
y = HIWORD( pos );
}
- int retVal = ::TrackPopupMenu(this->itsHandle, flags, x, y, 0, mainWindow->handle(), 0 );
+ int retVal = ::TrackPopupMenu(itsHandle, flags, x, y, 0, itsParent->handle(), 0 );
return retVal;
}
Modified: dcplusplus/trunk/win32/ADLSearchFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/ADLSearchFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/ADLSearchFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -296,7 +296,7 @@
contextMenu->setItemEnabled(IDC_EDIT, false, status);
contextMenu->setItemEnabled(IDC_REMOVE, false, status);
- contextMenu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/DirectoryListingFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -411,7 +411,7 @@
WidgetMenuPtr menu = createMenu(cs);
CShellContextMenu shellMenu;
shellMenu.SetPath(Text::utf8ToWide(path));
- shellMenu.ShowContextMenu(menu, this, pt);
+ shellMenu.ShowContextMenu(menu, pt);
return true;
}
}
@@ -421,7 +421,7 @@
contextMenu = makeMultiMenu();
}
usingDirMenu = false;
- contextMenu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
return false;
@@ -437,7 +437,7 @@
if(dirs->getSelection()) {
WidgetMenuPtr contextMenu = makeDirMenu();
usingDirMenu = true;
- contextMenu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/FavHubsFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/FavHubsFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/FavHubsFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -292,7 +292,7 @@
menu->setItemEnabled(IDC_MOVE_DOWN, false, status);
menu->setItemEnabled(IDC_REMOVE, false, status);
- menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/FinishedFrameBase.h
===================================================================
--- dcplusplus/trunk/win32/FinishedFrameBase.h 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/FinishedFrameBase.h 2008-02-17 22:27:10 UTC (rev 1014)
@@ -230,7 +230,7 @@
pShellMenu->appendItem(IDC_REMOVE_ALL, T_("Remove &all"), std::tr1::bind(&ThisType::handleRemoveAll, this));
pShellMenu->appendSeparatorItem();
- UINT idCommand = shellMenu.ShowContextMenu(pShellMenu, static_cast<T*>(this), pt);
+ UINT idCommand = shellMenu.ShowContextMenu(pShellMenu, pt);
if(idCommand != 0)
this->postMessage(WM_COMMAND, idCommand);
return true;
@@ -245,7 +245,7 @@
contextMenu->appendItem(IDC_REMOVE, T_("&Remove"), std::tr1::bind(&ThisType::handleRemove, this));
contextMenu->appendItem(IDC_REMOVE_ALL, T_("Remove &all"), std::tr1::bind(&ThisType::handleRemoveAll, this));
contextMenu->setDefaultItem(IDC_OPEN_FILE);
- contextMenu->trackPopupMenu(static_cast<T*>(this), pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
return false;
Modified: dcplusplus/trunk/win32/HubFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/HubFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/HubFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -1154,7 +1154,7 @@
inTabMenu = false;
- menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
return false;
@@ -1178,7 +1178,7 @@
inTabMenu = true;
- menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/MDIChildFrame.h
===================================================================
--- dcplusplus/trunk/win32/MDIChildFrame.h 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/MDIChildFrame.h 2008-02-17 22:27:10 UTC (rev 1014)
@@ -189,7 +189,7 @@
SmartWin::WidgetMenu::ObjectType menu = createMenu(WinUtil::Seeds::menu);
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);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/MainWindow.cpp
===================================================================
--- dcplusplus/trunk/win32/MainWindow.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/MainWindow.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -1004,7 +1004,7 @@
trayMenu->setDefaultItem(0,TRUE);
::GetCursorPos(&pt.getPoint());
::SetForegroundWindow(handle());
- trayMenu->trackPopupMenu(this, pt, TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON);
+ trayMenu->trackPopupMenu(pt, TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON);
postMessage(WM_NULL);
} else if(lParam == WM_MOUSEMOVE && ((lastMove + 1000) < GET_TICK()) ) {
NOTIFYICONDATA nid;
Modified: dcplusplus/trunk/win32/PrivateFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/PrivateFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/PrivateFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -387,7 +387,7 @@
menu->appendSeparatorItem();
menu->appendItem(IDC_CLOSE_WINDOW, T_("&Close"), std::tr1::bind(&PrivateFrame::close, this, true), SmartWin::BitmapPtr(new SmartWin::Bitmap(IDB_EXIT)));
- menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/PublicHubsFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/PublicHubsFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/PublicHubsFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -449,7 +449,7 @@
menu->appendItem(IDC_ADD, T_("Add To &Favorites"), std::tr1::bind(&PublicHubsFrame::handleAdd, this), SmartWin::BitmapPtr(new SmartWin::Bitmap(IDB_FAVORITE_HUBS)));
menu->appendItem(IDC_COPY_HUB, T_("Copy &address to clipboard"), std::tr1::bind(&PublicHubsFrame::handleCopyHub, this));
menu->setDefaultItem(IDC_CONNECT);
- menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
return false;
Modified: dcplusplus/trunk/win32/QueueFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/QueueFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/QueueFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -1068,7 +1068,7 @@
} else {
contextMenu = makeMultiMenu();
}
- contextMenu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
@@ -1085,7 +1085,7 @@
if(dirs->getSelection()) {
usingDirMenu = true;
WidgetMenuPtr contextMenu = makeDirMenu();
- contextMenu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/SearchFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/SearchFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/SearchFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -635,7 +635,7 @@
}
WidgetMenuPtr contextMenu = makeMenu();
- contextMenu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
return false;
Modified: dcplusplus/trunk/win32/ShellContextMenu.cpp
===================================================================
--- dcplusplus/trunk/win32/ShellContextMenu.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/ShellContextMenu.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -101,7 +101,7 @@
bDelete = true; // indicates that m_psfFolder should be deleted by CShellContextMenu
}
-UINT CShellContextMenu::ShowContextMenu(SmartWin::WidgetMenu::ObjectType& menu, SmartWin::Widget * parent, const SmartWin::ScreenCoordinate& pt)
+UINT CShellContextMenu::ShowContextMenu(SmartWin::WidgetMenu::ObjectType& menu, const SmartWin::ScreenCoordinate& pt)
{
int iMenuType = 0; // to know which version of IContextMenu is supported
LPCONTEXTMENU pContextMenu; // common pointer to IContextMenu and higher version interface
@@ -116,7 +116,7 @@
WNDPROC OldWndProc;
if(iMenuType > 1) // only attach if its version 2 or 3
{
- OldWndProc = (WNDPROC) SetWindowLong(parent->handle(), GWL_WNDPROC, (DWORD) HookWndProc);
+ OldWndProc = (WNDPROC) SetWindowLong(menu->getParent()->handle(), GWL_WNDPROC, (DWORD) HookWndProc);
if(iMenuType == 2)
g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
else // version 3
@@ -125,10 +125,10 @@
else
OldWndProc = NULL;
- UINT idCommand = menu->trackPopupMenu(parent, pt, TPM_RETURNCMD | TPM_LEFTALIGN);
+ UINT idCommand = menu->trackPopupMenu(pt, TPM_RETURNCMD | TPM_LEFTALIGN);
if(OldWndProc) // unattach
- SetWindowLong(parent->handle(), GWL_WNDPROC, (DWORD) OldWndProc);
+ SetWindowLong(menu->getParent()->handle(), GWL_WNDPROC, (DWORD) OldWndProc);
if(idCommand >= ID_SHELLCONTEXTMENU_MIN && idCommand <= ID_SHELLCONTEXTMENU_MAX)
{
Modified: dcplusplus/trunk/win32/ShellContextMenu.h
===================================================================
--- dcplusplus/trunk/win32/ShellContextMenu.h 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/ShellContextMenu.h 2008-02-17 22:27:10 UTC (rev 1014)
@@ -35,7 +35,7 @@
void SetPath(const wstring& strPath);
- UINT ShowContextMenu(SmartWin::WidgetMenu::ObjectType& menu, SmartWin::Widget * parent, const SmartWin::ScreenCoordinate& pt);
+ UINT ShowContextMenu(SmartWin::WidgetMenu::ObjectType& menu, const SmartWin::ScreenCoordinate& pt);
private:
bool bDelete;
Modified: dcplusplus/trunk/win32/SpyFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/SpyFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/SpyFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -188,7 +188,7 @@
WidgetMenuPtr contextMenu = createMenu(WinUtil::Seeds::menu);
contextMenu->appendItem<WidgetMenu::SimpleDispatcher>(IDC_SEARCH, T_("&Search"), std::tr1::bind(&SpyFrame::handleSearch, this, searches->getText(searches->getSelectedIndex(), COLUMN_STRING)), SmartWin::BitmapPtr(new SmartWin::Bitmap(IDB_SEARCH)));
- contextMenu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
return false;
Modified: dcplusplus/trunk/win32/TransferView.cpp
===================================================================
--- dcplusplus/trunk/win32/TransferView.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/TransferView.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -210,7 +210,7 @@
/// @todo Fix multiple selection menu...
ConnectionInfo* ii = connections->getSelectedData();
WidgetMenuPtr contextMenu = makeContextMenu(ii);
- contextMenu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
@@ -226,7 +226,7 @@
WidgetMenuPtr menu = createMenu(WinUtil::Seeds::menu);
DownloadInfo* di = downloads->getSelectedData();
WinUtil::addHashItems(menu, di->tth, di->columns[DOWNLOAD_COLUMN_FILE]);
- menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/UsersFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/UsersFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/UsersFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -186,7 +186,7 @@
menu->appendItem(IDC_EDIT, T_("&Properties"), std::tr1::bind(&UsersFrame::handleProperties, this));
menu->appendItem(IDC_REMOVE, T_("&Remove"), std::tr1::bind(&UsersFrame::handleRemove, this));
- menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
Modified: dcplusplus/trunk/win32/WaitingUsersFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/WaitingUsersFrame.cpp 2008-02-17 22:03:38 UTC (rev 1013)
+++ dcplusplus/trunk/win32/WaitingUsersFrame.cpp 2008-02-17 22:27:10 UTC (rev 1014)
@@ -83,7 +83,7 @@
menu->appendItem(IDC_GRANTSLOT, T_("Grant &extra slot"), std::tr1::bind(&WaitingUsersFrame::onGrantSlot, this));
menu->appendItem(IDC_ADD_TO_FAVORITES, T_("Add To &Favorites"), std::tr1::bind(&WaitingUsersFrame::onAddToFavorites, this));
menu->appendItem(IDC_PRIVATEMESSAGE, T_("&Send private message"), std::tr1::bind(&WaitingUsersFrame::onPrivateMessage, this));
- menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
+ menu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|