本文整理汇总了C++中ItemPtr::exist方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemPtr::exist方法的具体用法?C++ ItemPtr::exist怎么用?C++ ItemPtr::exist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemPtr
的用法示例。
在下文中一共展示了ItemPtr::exist方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateSeparator
void Toolbar::updateSeparator( unsigned int& index, ItemPtr item, TBBUTTONINFO& info )
{
int width = item->exist( "width" ) ? atoi( (*item)[ "width" ].c_str() ) :
6;
if( ( info.fsStyle & BTNS_SEP ) == 0 // not a separator
|| info.lParam != 0 // a place-holder separator
|| info.iImage != width ) // width, will be configurable in future
{
TBBUTTON button;
memset( &button, 0, sizeof(button) );
button.iBitmap = width; // width of the separatar, could be configurable in future
button.idCommand = 0;
button.fsState = 0;
button.fsStyle = BTNS_SEP;
button.dwData = 0;
button.iString = -1;
sendMessage( TB_INSERTBUTTON, index, (LPARAM)&button );
}
TBBUTTONINFO buttonInfo = { sizeof( buttonInfo ), TBIF_BYINDEX | TBIF_STATE };
buttonInfo.fsState = 0;
if ( sendMessage( WM_CGUITOOLBAR_USE_WRAP, 0, 0 ) &&
( info.fsState & TBSTATE_WRAP ) )
buttonInfo.fsState |= TBSTATE_WRAP;
if( forceChanged_ || info.fsState != buttonInfo.fsState )
sendMessage( TB_SETBUTTONINFO, index, (LPARAM)&buttonInfo );
}
示例2: 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() ];
}
示例3: updateExpandedChoice
void Toolbar::updateExpandedChoice( unsigned int& index, ItemPtr item, TBBUTTONINFO& info )
{
struct PatchDisplayName
{
std::string operator()( std::string name )
{
std::string::iterator iter = name.begin();
while( iter != name.end() )
{
if( *iter == '&' )
name.erase( iter );
else
++iter;
}
return name;
}
}
PatchDisplayName;
HWND combobox = (HWND)info.lParam;
if( ( info.fsStyle & BTNS_SEP ) == 0 || // not a place holder
info.lParam == 0 ) // do not contain a combo box
{
int width = item->exist( "width" ) ? atoi( (*item)[ "width" ].c_str() ) :
150;
combobox = CreateWindow( "COMBOBOX", "",
CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE,
0, 0, width, 1,
toolbar_, NULL, GetModuleHandle( NULL ), NULL );
SendMessage( combobox, WM_SETFONT,
SendMessage( toolbar_, WM_GETFONT, 0, 0 ),
FALSE );
TBBUTTON button;
memset( &button, 0, sizeof(button) );
button.iBitmap = width; // width of the combobox, MUST be configurable in future
button.idCommand = 0;
button.fsState = 0;
button.fsStyle = BTNS_SEP;
button.dwData = (DWORD)combobox;
button.iString = -1;
sendMessage( TB_INSERTBUTTON, index, (LPARAM)&button );
}
{// set the position & size
RECT rectButton, rectWin;
sendMessage( TB_GETITEMRECT, index, (LPARAM)&rectButton );
GetWindowRect( combobox, &rectWin );
ScreenToClient( toolbar_, (POINT*)&rectWin );
MoveWindow( combobox, rectButton.left, rectButton.top,
rectButton.right - rectButton.left, ( rectButton.bottom - rectButton.top ) * 20, TRUE );
}
int comboIndex = 0;
unsigned int subitemIndex = 0;
while( comboIndex < SendMessage( combobox, CB_GETCOUNT, 0, 0 ) &&
subitemIndex < item->num() )
{
ItemPtr subitem = (*item)[ subitemIndex ];
char* buffer = (char*)_alloca( SendMessage( combobox, CB_GETLBTEXTLEN, comboIndex, 0 ) + 1 );
SendMessage( combobox, CB_GETLBTEXT, comboIndex, (LPARAM)buffer );
if( SendMessage( combobox, CB_GETITEMDATA, comboIndex, 0 ) != subitem->commandID() ||
buffer != subitem->displayName() )
{
SendMessage( combobox, CB_INSERTSTRING, comboIndex,
(LPARAM)PatchDisplayName( subitem->displayName() ).c_str() );
SendMessage( combobox, CB_SETITEMDATA, comboIndex, subitem->commandID() );
}
if( subitem->update() && !SendMessage( combobox, CB_GETDROPPEDSTATE, 0, 0 ) )
SendMessage( combobox, CB_SETCURSEL, comboIndex, 0 );
++comboIndex;
++subitemIndex;
}
while( comboIndex < SendMessage( combobox, CB_GETCOUNT, 0, 0 ) )
SendMessage( combobox, CB_DELETESTRING, comboIndex, 0 );
while( subitemIndex < item->num() )
{
ItemPtr subitem = (*item)[ subitemIndex ];
SendMessage( combobox, CB_INSERTSTRING, comboIndex,
(LPARAM)PatchDisplayName( subitem->displayName() ).c_str() );
SendMessage( combobox, CB_SETITEMDATA, comboIndex, subitem->commandID() );
if( subitem->update() && !SendMessage( combobox, CB_GETDROPPEDSTATE, 0, 0 ) )
SendMessage( combobox, CB_SETCURSEL, comboIndex, 0 );
++comboIndex;
++subitemIndex;
}
EnableWindow( combobox, item->update() && item->num() && isEnabled() );
}