本文整理汇总了C++中wxBitmap::Ok方法的典型用法代码示例。如果您正苦于以下问题:C++ wxBitmap::Ok方法的具体用法?C++ wxBitmap::Ok怎么用?C++ wxBitmap::Ok使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxBitmap
的用法示例。
在下文中一共展示了wxBitmap::Ok方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
m_needParent = TRUE;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{
wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
return false;
}
m_bitmap = bitmap;
wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm));
m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
if (bitmap.Ok())
SetBitmap(bitmap);
PostCreation(size);
m_parent->DoAddChild( this );
return true;
}
示例2: CreateBitmapDisabled
wxBitmap wxCustomButton::CreateBitmapDisabled(const wxBitmap &bitmap) const
{
wxCHECK_MSG(bitmap.Ok(), wxNullBitmap, wxT("invalid bitmap"));
unsigned char br = GetBackgroundColour().Red();
unsigned char bg = GetBackgroundColour().Green();
unsigned char bb = GetBackgroundColour().Blue();
wxImage image = bitmap.ConvertToImage();
int pos, width = image.GetWidth(), height = image.GetHeight();
unsigned char *img_data = image.GetData();
for (int j=0; j<height; j++)
{
for (int i=j%2; i<width; i+=2)
{
pos = (j*width+i)*3;
img_data[pos ] = br;
img_data[pos+1] = bg;
img_data[pos+2] = bb;
}
}
return wxBitmap(image);
}
示例3: Replace
bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap, const wxBitmap &mask )
{
wxObjectList::compatibility_iterator node = m_images.Item( index );
wxCHECK_MSG( node, false, wxT("wrong index in image list") );
wxBitmap* newBitmap = (bitmap.IsKindOf(CLASSINFO(wxIcon))) ?
#if defined(__VISAGECPP__)
//just can't do this in VisualAge now, with all this new Bitmap-Icon stuff
//so construct it from a bitmap object until I can figure this nonsense out. (DW)
new wxBitmap(bitmap)
#else
new wxBitmap( (const wxIcon&) bitmap )
#endif
: new wxBitmap(bitmap) ;
if (index == (int) m_images.GetCount() - 1)
{
delete node->GetData();
m_images.Erase( node );
m_images.Append( newBitmap );
}
else
{
wxObjectList::compatibility_iterator next = node->GetNext();
delete node->GetData();
m_images.Erase( node );
m_images.Insert( next, newBitmap );
}
if (mask.Ok())
newBitmap->SetMask(new wxMask(mask));
return true;
}
示例4: Add
int wxGenericImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask )
{
wxBitmap bmp(bitmap);
if (mask.Ok())
bmp.SetMask(new wxMask(mask));
return Add(bmp);
}
示例5: OnAddBitmap
bool wxBitmapComboBox::OnAddBitmap(const wxBitmap& bitmap)
{
if ( bitmap.Ok() )
{
int width = bitmap.GetWidth();
int height = bitmap.GetHeight();
if ( m_usedImgSize.x <= 0 )
{
//
// If size not yet determined, get it from this image.
m_usedImgSize.x = width;
m_usedImgSize.y = height;
InvalidateBestSize();
wxSize newSz = GetBestSize();
wxSize sz = GetSize();
if ( newSz.y > sz.y )
SetSize(sz.x, newSz.y);
else
DetermineIndent();
}
wxCHECK_MSG(width == m_usedImgSize.x && height == m_usedImgSize.y,
false,
wxT("you can only add images of same size"));
}
return true;
}
示例6: Create
bool wxCustomButton::Create(wxWindow* parent, wxWindowID id,
const wxString& label, const wxBitmap &bitmap,
const wxPoint& pos, const wxSize& size_,
long style, const wxValidator& val,
const wxString& name)
{
m_labelString = label;
if (bitmap.Ok()) m_bmpLabel = bitmap;
wxSize bestSize = DoGetBestSize_(parent);
wxSize size(size_.x<0 ? bestSize.x:size_.x, size_.y<0 ? bestSize.y:size_.y);
//SetInitialSize(size);
if (!wxControl::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name))
return false;
wxControl::SetBackgroundColour(parent->GetBackgroundColour());
wxControl::SetForegroundColour(parent->GetForegroundColour());
wxControl::SetFont(parent->GetFont());
if (!SetButtonStyle(style)) return false;
//SetBestSize(size);
CalcLayout(true);
return true;
}
示例7: Create
bool wxCustomButton::Create(wxWindow* parent, wxWindowID id,
const wxString& label, const wxBitmap &bitmap,
const wxPoint& pos, const wxSize& size,
long style, const wxValidator& val,
const wxString& name)
{
if (!wxControl::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name))
return FALSE;
wxControl::SetLabel(label);
wxControl::SetBackgroundColour(parent->GetBackgroundColour());
wxControl::SetForegroundColour(parent->GetForegroundColour());
wxControl::SetFont(parent->GetFont());
if (bitmap.Ok()) m_bmpLabel = bitmap;
if (!SetButtonStyle(style)) return FALSE;
wxSize bestSize = DoGetBestSize();
SetSize(wxSize(size.x<0 ? bestSize.x:size.x, size.y<0 ? bestSize.y:size.y));
#if (wxMINOR_VERSION<8)
SetBestSize(GetSize());
#else
SetInitialSize(GetSize());
#endif
CalcLayout(TRUE);
return TRUE;
}
示例8: Create
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
const wxBitmap& bitmap,
const wxPoint& pos,
const wxSize& s,
long style,
const wxString& name)
{
SetName(name);
wxSize size = s ;
if ( bitmap.Ok() )
{
if ( size.x == -1 )
size.x = bitmap.GetWidth() ;
if ( size.y == -1 )
size.y = bitmap.GetHeight() ;
}
m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ;
m_bitmap = bitmap;
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowStyle = style;
bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
SetBestSize( size ) ;
return ret;
}
示例9: DoDrawSubBitmap
void wxDC::DoDrawSubBitmap(const wxBitmap &bmp,
wxCoord x, wxCoord y, wxCoord w, wxCoord h,
wxCoord destx, wxCoord desty, int rop, bool useMask)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
// NB: we could also support XOR here (via DSBLIT_XOR)
// and possibly others via SetSrc/DstBlendFunction()
wxCHECK_RET( rop == wxCOPY, _T("only wxCOPY function supported") );
if ( bmp.GetDepth() == 1 )
{
// Mono bitmaps are handled in special way -- all 1s are drawn in
// foreground colours, all 0s in background colour.
wxFAIL_MSG( _T("drawing mono bitmaps not implemented") );
return;
}
if ( useMask && bmp.GetMask() )
{
// FIXME_DFB: see MGL sources for a way to do it, but it's not directly
// applicable because DirectFB doesn't implement ROPs; OTOH,
// it has blitting modes that can be useful; finally, see
// DFB's SetSrcBlendFunction() and SetSrcColorKey()
wxFAIL_MSG( _T("drawing bitmaps with masks not implemented") );
return;
}
DoBlitFromSurface(bmp.GetDirectFBSurface(),
x, y,
w, h,
destx, desty);
}
示例10: SetItemBitmap
void CBOINCBitmapChoice::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) {
MenuHandle mhandle = (MenuHandle) m_macPopUpMenuHandle;
unsigned int index = n + 1;
if ( mhandle == NULL || index == 0)
return ;
if ( bitmap.Ok() )
{
CGImageRef imageRef = (CGImageRef)( bitmap.CGImageCreate() ) ;
SetMenuItemIconHandle( mhandle , index ,
kMenuCGImageRefType , (Handle) imageRef ) ;
#if 0// wxUSE_BMPBUTTON
ControlButtonContentInfo info ;
wxMacCreateBitmapButton( &info , bitmap ) ;
if ( info.contentType != kControlNoContent )
{
if ( info.contentType == kControlContentIconRef )
SetMenuItemIconHandle( mhandle , index ,
kMenuIconRefType , (Handle) info.u.iconRef ) ;
else if ( info.contentType == kControlContentCGImageRef )
SetMenuItemIconHandle( mhandle , index ,
kMenuCGImageRefType , (Handle) info.u.imageRef ) ;
}
wxMacReleaseBitmapButton( &info ) ;
#endif
}
}
示例11: MenuDropButton
MenuDropButton( wxWindow *parent, wxWindowID id, long style) : wxCustomButton()
{
if (!s_dropdownBitmap.Ok())
s_dropdownBitmap = wxBitmap(down_arrow_xpm_data);
Create( parent, id, wxEmptyString, s_dropdownBitmap, wxDefaultPosition,
wxSize(wxMENUBUTTON_DROP_WIDTH, wxMENUBUTTON_DROP_HEIGHT), style);
}
示例12: SetItemBitmap
void CBOINCBitmapChoice::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) {
wxMenuItem *item = m_popUpMenu->FindItemByPosition(n);
if ( item && bitmap.Ok() )
{
item->SetBitmap(bitmap);
}
}
示例13: SelectObject
void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
{
if ( bitmap.Ok() )
{
m_selected = bitmap;
SetMGLDC(m_selected.CreateTmpDC(), TRUE);
}
}
示例14: CreateBitmapDisabled
wxBitmap wxCustomButton::CreateBitmapDisabled(const wxBitmap &bitmap) const
{
wxCHECK_MSG(bitmap.Ok(), wxNullBitmap, wxT("invalid bitmap"));
unsigned char br = GetBackgroundColour().Red();
unsigned char bg = GetBackgroundColour().Green();
unsigned char bb = GetBackgroundColour().Blue();
wxImage image = bitmap.ConvertToImage();
int pos, width = image.GetWidth(), height = image.GetHeight();
unsigned char *img_data = image.GetData();
for (int j=0; j<height; j++)
{
for (int i=j%2; i<width; i+=2)
{
pos = (j*width+i)*3;
img_data[pos ] = br;
img_data[pos+1] = bg;
img_data[pos+2] = bb;
}
}
return wxBitmap(image);
/* // FIXME why bother creating focused wxCustomButton's bitmap
wxImage imgFoc = bitmap.ConvertToImage();
bool mask = false;
unsigned char mr=0, mg=0, mb=0;
if (img.HasMask())
{
mask = true;
mr = imgDis.GetMaskRed();
mg = imgDis.GetMaskGreen();
mb = imgDis.GetMaskBlue();
}
unsigned char *r, *g, *b;
unsigned char *focData = imgFoc.GetData();
r = imgFoc.GetData();
g = imgFoc.GetData() + 1;
b = imgFoc.GetData() + 2;
for (int j=0; j<h; j++)
{
for (int i=0; i<w; i++)
{
if ((!mask || ((*r!=mr)&&(*b!=mb)&&(*g!=mg))) &&
((*r<236)&&(*b<236)&&(*g<236)))
{
*r += 20; *g += 20; *b += 20;
}
r += 3; g += 3; b += 3;
}
}
m_bmpFocus = wxBitmap(imgFoc);
*/
}
示例15: Create
void wxGenericBrush::Create( const wxBitmap &stipple )
{
UnRef();
wxCHECK_RET(stipple.Ok(), wxT("Invalid bitmap in wxGenericBrush::Create"));
int style = stipple.GetMask() ? wxSTIPPLE_MASK_OPAQUE : wxSTIPPLE;
m_refData = new wxGenericBrushRefData(wxNullGenericColour, style);
M_GBRUSHDATA->m_stipple = stipple;
}