本文整理汇总了C++中wxBitmap::IsOk方法的典型用法代码示例。如果您正苦于以下问题:C++ wxBitmap::IsOk方法的具体用法?C++ wxBitmap::IsOk怎么用?C++ wxBitmap::IsOk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxBitmap
的用法示例。
在下文中一共展示了wxBitmap::IsOk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pict_dc
void BM2CMP_FRAME::OnPaint( wxPaintEvent& event )
{
#ifdef __WXMAC__
// Otherwise fails due: using wxPaintDC without being in a native paint event
wxClientDC pict_dc( m_InitialPicturePanel );
wxClientDC greyscale_dc( m_GreyscalePicturePanel );
wxClientDC nb_dc( m_BNPicturePanel );
#else
wxPaintDC pict_dc( m_InitialPicturePanel );
wxPaintDC greyscale_dc( m_GreyscalePicturePanel );
wxPaintDC nb_dc( m_BNPicturePanel );
#endif
m_InitialPicturePanel->PrepareDC( pict_dc );
m_GreyscalePicturePanel->PrepareDC( greyscale_dc );
m_BNPicturePanel->PrepareDC( nb_dc );
// OSX crashes with empty bitmaps (on initial refreshes)
if(m_Pict_Bitmap.IsOk() && m_Greyscale_Bitmap.IsOk() && m_BN_Bitmap.IsOk())
{
pict_dc.DrawBitmap( m_Pict_Bitmap, 0, 0, false );
greyscale_dc.DrawBitmap( m_Greyscale_Bitmap, 0, 0, false );
nb_dc.DrawBitmap( m_BN_Bitmap, 0, 0, false );
}
}
示例2: DrawButtonLabel
void wxControlRenderer::DrawButtonLabel(const wxBitmap& bitmap,
wxCoord marginX, wxCoord marginY)
{
m_dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
m_dc.SetFont(m_window->GetFont());
m_dc.SetTextForeground(m_window->GetForegroundColour());
wxString label = m_window->GetLabel();
if ( !label.empty() || bitmap.IsOk() )
{
wxRect rectLabel = m_rect;
if ( bitmap.IsOk() )
{
rectLabel.Inflate(-marginX, -marginY);
}
wxControl *ctrl = wxStaticCast(m_window, wxControl);
m_renderer->DrawButtonLabel(m_dc,
label,
bitmap,
rectLabel,
m_window->GetStateFlags(),
ctrl->GetAlignment(),
ctrl->GetAccelIndex());
}
}
示例3: 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.IsOk() ? bitmap : wxBitmap(bogus_xpm));
m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
if (bitmap.IsOk())
SetBitmap(bitmap);
PostCreation(size);
m_parent->DoAddChild( this );
return true;
}
示例4: DoSetBackgroundBitmap
void wxPanel::DoSetBackgroundBitmap(const wxBitmap& bmp)
{
delete m_backgroundBrush;
m_backgroundBrush = bmp.IsOk() ? new wxBrush(bmp) : NULL;
// Our transparent children should use our background if we have it,
// otherwise try to restore m_inheritBgCol to some reasonable value: true
// if we also have non-default background colour or false otherwise.
m_inheritBgCol = bmp.IsOk() || UseBgCol();
}
示例5: RescaleBitmap
wxBitmap RescaleBitmap(const wxBitmap& bitmap, const wxSize& size, bool hq)
{
wxASSERT(bitmap.IsOk());
if (!bitmap.IsOk())
return wxNullBitmap;
wxImage image = bitmap.ConvertToImage();
image.Rescale(size.x, size.y, hq ? wxIMAGE_QUALITY_HIGH : wxIMAGE_QUALITY_NORMAL);
return image;
}
示例6: AdjustBitmapSize
wxBitmap AdjustBitmapSize(const wxBitmap& bitmap, const wxSize& size, const wxPoint& origin)
{
wxASSERT(bitmap.IsOk());
if (!bitmap.IsOk())
return wxNullBitmap;
wxImage image=bitmap.ConvertToImage();
image.Resize(size, origin);
return image;
}
示例7: MakeTransparent
void wxSpeedButton::MakeTransparent(wxBitmap &inBitmap) {
int h;
int r,g,b;
wxImage img;
wxBitmap *bmp;
// not a good image?
if (! inBitmap.IsOk()) return;
// already have a mask?
img = inBitmap.ConvertToImage();
if (img.HasMask()) return;
// get the colors of the lower-left corner of the image
h = img.GetHeight();
r = img.GetRed(0, h-1);
b = img.GetBlue(0, h-1);
g = img.GetGreen(0, h-1);
// make a mask from those colors
img.SetMaskColour(r, g, b);
// store it back in the bitmap
bmp = new wxBitmap(img);
inBitmap = *bmp;
}
示例8: OnAddBitmap
bool wxBitmapComboBoxBase::OnAddBitmap(const wxBitmap& bitmap)
{
if ( bitmap.IsOk() )
{
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;
// Adjust control size to vertically fit the bitmap
wxWindow* ctrl = GetControl();
ctrl->InvalidateBestSize();
wxSize newSz = ctrl->GetBestSize();
wxSize sz = ctrl->GetSize();
if ( newSz.y > sz.y )
ctrl->SetSize(sz.x, newSz.y);
else
DetermineIndent();
}
wxCHECK_MSG( width == m_usedImgSize.x && height == m_usedImgSize.y,
false,
"you can only add images of same size" );
return true;
}
return false;
}
示例9: DoCalcButtonHeight
int OutputViewControlBarButton::DoCalcButtonHeight(wxWindow *win, const wxString &text, const wxBitmap &bmp, int spacer)
{
int text_height(0);
int bmp_height (0);
int height (0);
wxUnusedVar(text);
// Calculate the text height
int xx;
wxString stam(wxT("Tp"));
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
win->GetTextExtent(stam, &xx, &text_height, NULL, NULL, &font);
// bitmap
if ( bmp.IsOk() ) {
bmp_height += bmp.GetHeight();
}
height += spacer;
text_height > bmp_height ? height += text_height : height += bmp_height;
height += spacer;
return height;
}
示例10: DoCalcButtonWidth
int OutputViewControlBarButton::DoCalcButtonWidth(wxWindow *win, const wxString &text, const wxBitmap &bmp, int spacer)
{
int text_width(0);
int width (0);
// Calculate the text width
if (text.IsEmpty() == false) {
int yy;
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
win->GetTextExtent(text, &text_width, &yy, NULL, NULL, &font);
}
// spacer
width += spacer;
// bitmap
if ( bmp.IsOk() ) {
width += bmp.GetWidth();
width += spacer;
}
// text
if ( text_width ) {
width += text_width;
width += spacer;
}
return width;
}
示例11: DoDrawBitmap
void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask )
{
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
wxCHECK_RET( bmp.IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
int w = bmp.GetScaledWidth();
int h = bmp.GetScaledHeight();
if ( bmp.GetDepth() == 1 )
{
m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
m_graphicContext->SetBrush(m_textBackgroundColour);
m_graphicContext->DrawRectangle( x, y, w, h );
m_graphicContext->SetBrush(m_textForegroundColour);
m_graphicContext->DrawBitmap( bmp, x, y, w, h );
m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush));
m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen));
}
else // not a monochrome bitmap, handle it normally
{
// make a copy in case we need to remove its mask, if we don't modify
// it the copy is cheap as bitmaps are reference-counted
wxBitmap bmpCopy(bmp);
if ( !useMask && bmp.GetMask() )
bmpCopy.SetMask(NULL);
m_graphicContext->DrawBitmap( bmpCopy, x, y, w, h );
}
CalcBoundingBox(x, y);
CalcBoundingBox(x + w, y + h);
}
示例12: MSWMustUseOwnerDrawn
bool wxMenuItem::MSWMustUseOwnerDrawn()
{
// MIIM_BITMAP only works under WinME/2000+ so we always use owner
// drawn item under the previous versions and we also have to use
// them in any case if the item has custom colours or font
static const wxWinVersion winver = wxGetWinVersion();
bool mustUseOwnerDrawn = winver < wxWinVersion_98 ||
GetTextColour().IsOk() ||
GetBackgroundColour().IsOk() ||
GetFont().IsOk();
// Windows XP or earlier don't display menu bitmaps bigger than
// standard size correctly (they're truncated), so we must use
// owner-drawn items to show them correctly there. OTOH Win7
// doesn't seem to have any problems with even very large bitmaps
// so don't use owner-drawn items unnecessarily there (Vista wasn't
// actually tested but I assume it works as 7 rather than as XP).
if ( !mustUseOwnerDrawn && winver < wxWinVersion_Vista )
{
const wxBitmap& bmpUnchecked = GetBitmap(false),
bmpChecked = GetBitmap(true);
if ( (bmpUnchecked.IsOk() && IsGreaterThanStdSize(bmpUnchecked)) ||
(bmpChecked.IsOk() && IsGreaterThanStdSize(bmpChecked)) )
{
mustUseOwnerDrawn = true;
}
}
return mustUseOwnerDrawn;
}
示例13: Replace
bool wxImageList::Replace( int index, const wxBitmap &bitmap, const wxBitmap &mask )
{
wxList::compatibility_iterator node = m_images.Item( index );
wxCHECK_MSG( node, false, wxT("wrong index in image list") );
wxBitmap* newBitmap = new wxBitmap(bitmap);
if (index == (int) m_images.GetCount() - 1)
{
delete node->GetData();
m_images.Erase( node );
m_images.Append( newBitmap );
}
else
{
wxList::compatibility_iterator next = node->GetNext();
delete node->GetData();
m_images.Erase( node );
m_images.Insert( next, newBitmap );
}
if (mask.IsOk())
newBitmap->SetMask(new wxMask(mask));
return true;
}
示例14: AddTool
void CDragBar::AddTool(int id, const wxBitmap& bmp, const wxString& tooltip /*= wxEmptyString*/,
const wxBitmap& bmpDisabled /*= wxNullBitmap*/)
{
//all bitmaps must be same size
if (m_bmpWidth == 0)
m_bmpWidth = bmp.GetWidth();
else {
wxASSERT(m_bmpWidth == bmp.GetWidth());
}
if (m_bmpHeight == 0)
m_bmpHeight = bmp.GetHeight();
else {
wxASSERT(m_bmpHeight == bmp.GetHeight());
}
if (bmpDisabled.IsOk()) {
wxASSERT(m_bmpWidth == bmpDisabled.GetWidth());
wxASSERT(m_bmpHeight == bmpDisabled.GetHeight());
}
DragBarItem item;
item.id = id;
item.bmp = bmp;
item.bmpDisabled = bmpDisabled;
item.tooltip = tooltip;
item.enabled = true;
m_items.push_back( item );
}
示例15: Add
int wxGenericImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask )
{
wxBitmap bmp(bitmap);
if (mask.IsOk())
bmp.SetMask(new wxMask(mask));
return Add(bmp);
}