本文整理汇总了C++中ItemPtr::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemPtr::getObject方法的具体用法?C++ ItemPtr::getObject怎么用?C++ ItemPtr::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemPtr
的用法示例。
在下文中一共展示了ItemPtr::getObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
void Item::add( ItemPtr item )
{
if( isAncestor( item.getObject() ) )
throw 1;
subitems_.push_back( item );
item->addParent( this );
}
示例2: insertMenuItem
void Menu::insertMenuItem( HMENU hmenu, int index, ItemPtr item )
{
MENUITEMINFO info = { sizeof( info ), MIIM_STRING | MIIM_ID | MIIM_DATA, 0, 0,
item->commandID(), NULL, NULL, NULL, (DWORD)item.getObject(), "menu"
};
InsertMenuItem( hmenu, index, MF_BYPOSITION, &info );
}
示例3: getImageIndex
int Toolbar::getImageIndex( ItemPtr item )
{
if( imageIndices_.find( item.getObject() ) == imageIndices_.end() )
{
COLORREF transparency = RGB( 192, 192, 192 );
if( item->exist( "transparency" ) )
{
std::string color = (*item)[ "transparency" ];
if( std::count( color.begin(), color.end(), ',' ) == 2 )
{
BYTE r = atoi( color.c_str() );
BYTE g = atoi( color.c_str() + color.find( ',' ) + 1 );
std::string::size_type next = color.find( ',' ) + 1;
BYTE b = atoi( color.c_str() + color.find( ',', next ) + 1 );
transparency = RGB( r, g, b );
}
}
BitmapPtr bitmap = Manager::instance().bitmaps().get( (*item)["imageNormal"], transparency );
result_ = ImageList_Add( normalImageList_, (*bitmap), NULL );
if( item->exist( "imageHot" ) )
ImageList_Add( hotImageList_,
*Manager::instance().bitmaps().get( (*item)["imageHot"], transparency ), NULL );
else
ImageList_Add( hotImageList_,
*Manager::instance().bitmaps().get( (*item)["imageNormal"], transparency, "HOVER" ), NULL );
if( item->exist( "imageDisabled" ) )
ImageList_Add( disabledImageList_,
*Manager::instance().bitmaps().get( (*item)["imageDisabled"], transparency ), NULL );
else
ImageList_Add( disabledImageList_,
*Manager::instance().bitmaps().get( (*item)["imageNormal"], transparency, "DISABLED" ), NULL );
imageIndices_[ item.getObject() ] = result_;
}
return imageIndices_[ item.getObject() ];
}
示例4: updateChoice
void Menu::updateChoice( HMENU hmenu, int& index, ItemPtr item, const MENUITEMINFO& info )
{
static const unsigned int MAX_MENU_TEXT = 1024;
char txtBuf[ MAX_MENU_TEXT + 1 ];
unsigned int subItemIndex = 0;
while( index < GetMenuItemCount( hmenu ) )
{
MENUITEMINFO info = { sizeof( info ),
MIIM_BITMAP | MIIM_CHECKMARKS | MIIM_DATA | MIIM_FTYPE | MIIM_ID |
MIIM_STATE | MIIM_STRING | MIIM_SUBMENU
};
info.cch = MAX_MENU_TEXT;
info.dwTypeData = txtBuf;
GetMenuItemInfo( hmenu, index, TRUE, &info );
if( info.dwItemData != (DWORD)item.getObject() )
break;
if( subItemIndex < item->num() )
{
ItemPtr subItem = ( *item )[ subItemIndex ];
if( !info.dwTypeData || buildMenuText( subItem ) != (LPCTSTR)info.dwTypeData )
insertMenuItem( hmenu, index, item );
ModifyMenu( hmenu, index, MF_BYPOSITION | MF_STRING, subItem->commandID(),
buildMenuText( subItem ).c_str() );
EnableMenuItem( hmenu, index, MF_BYPOSITION | ( item->update() ? MF_ENABLED : MF_GRAYED ) );
CheckMenuItem( hmenu, index, MF_BYPOSITION | ( subItem->update() ? MF_CHECKED : MF_UNCHECKED ) );
++index;
++subItemIndex;
}
else
DeleteMenu( hmenu, index, MF_BYPOSITION );
}
while( subItemIndex < item->num() )
{
ItemPtr subItem = ( *item )[ subItemIndex ];
insertMenuItem( hmenu, index, item );
ModifyMenu( hmenu, index, MF_BYPOSITION | MF_STRING, subItem->commandID(),
buildMenuText( subItem ).c_str() );
EnableMenuItem( hmenu, index, MF_BYPOSITION | ( item->update() ? MF_ENABLED : MF_GRAYED ) );
CheckMenuItem( hmenu, index, MF_BYPOSITION | ( subItem->update() ? MF_CHECKED : MF_UNCHECKED ) );
++subItemIndex;
}
--index;
}
示例5: updateToggle
void Toolbar::updateToggle( unsigned int& index, ItemPtr item, TBBUTTONINFO& info )
{
if( ( info.fsStyle & BTNS_CHECK ) == 0 || // not a toggle button
info.idCommand != item->commandID() ) // not for me
{
TBBUTTON button;
memset( &button, 0, sizeof(button) );
button.iBitmap = getImageIndex( item );
button.idCommand = item->commandID();
button.fsState = TBSTATE_ENABLED;
button.fsStyle = BTNS_CHECK;
button.dwData = (DWORD)item.getObject();
button.iString = -1;
sendMessage( TB_INSERTBUTTON, index, (LPARAM)&button );
}
TBBUTTONINFO buttonInfo = { sizeof( buttonInfo ), TBIF_TEXT | TBIF_BYINDEX | TBIF_STATE };
std::string tooltip = item->description(); // auto tooltip
if( item->shortcutKey().size() )
{
tooltip += " (";
tooltip += item->shortcutKey();
tooltip += ')';
}
buttonInfo.pszText = &tooltip[0];
LPARAM enabled = item->update() && isEnabled() ? TBSTATE_ENABLED : 0;
LPARAM checked = ( *item )[ 0 ]->update() ? 0 : TBSTATE_CHECKED;
if( !enabled )
checked = 0;
buttonInfo.fsState = (BYTE)( enabled | checked );
if ( sendMessage( WM_CGUITOOLBAR_USE_WRAP, 0, 0 ) &&
( info.fsState & TBSTATE_WRAP ) )
buttonInfo.fsState |= TBSTATE_WRAP;
if( forceChanged_ || info.pszText != tooltip || info.fsState != buttonInfo.fsState )
sendMessage( TB_SETBUTTONINFO, index, (LPARAM)&buttonInfo );
}