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; }
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); }
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; }
int wxGenericImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask ) { wxBitmap bmp(bitmap); if (mask.Ok()) bmp.SetMask(new wxMask(mask)); return Add(bmp); }
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; }
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; }
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; }
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; }
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); }
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 } }
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); }
void CBOINCBitmapChoice::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) { wxMenuItem *item = m_popUpMenu->FindItemByPosition(n); if ( item && bitmap.Ok() ) { item->SetBitmap(bitmap); } }
void wxMemoryDC::SelectObject(const wxBitmap& bitmap) { if ( bitmap.Ok() ) { m_selected = bitmap; SetMGLDC(m_selected.CreateTmpDC(), TRUE); } }
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); */ }
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; }
void SetPixmap(const wxBitmap& bitmap) { if (bitmap.Ok()) { GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap() : (GdkBitmap *)NULL; gtk_pixmap_set( GTK_PIXMAP(m_pixmap), bitmap.GetPixmap(), mask ); } }
void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask) { wxCHECK_RET( Ok(), wxT("invalid dc") ); wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") ); DoDrawSubBitmap(bmp, 0, 0, bmp.GetWidth(), bmp.GetHeight(), x, y, m_logicalFunction, useMask); }
void wxPen::SetStipple(const wxBitmap& stipple) { wxCHECK_RET( stipple.Ok(), wxT("invalid bitmap") ); wxCHECK_RET( stipple.GetWidth() == 8 && stipple.GetHeight() == 8, wxT("stipple bitmap must be 8x8") ); AllocExclusive(); M_PENDATA->m_stipple = stipple; wxBitmapToPixPattern(stipple, &(M_PENDATA->m_pixPattern), NULL); }
bool wxBitmapButton::ChangeBitmap(const wxBitmap& bmp) { wxBitmap bitmap = bmp.Ok() ? bmp : m_bmpNormal; if ( bitmap.IsSameAs(m_bitmap) ) return false; m_bitmap = bitmap; return true; }
bool wxWizard::ResizeBitmap(wxBitmap& bmp) { if (!GetBitmapPlacement()) return false; if (bmp.Ok()) { wxSize pageSize = m_sizerPage->GetSize(); if (pageSize == wxSize(0,0)) pageSize = GetPageSize(); int bitmapWidth = wxMax(bmp.GetWidth(), GetMinimumBitmapWidth()); int bitmapHeight = pageSize.y; if (!m_statbmp->GetBitmap().Ok() || m_statbmp->GetBitmap().GetHeight() != bitmapHeight) { wxBitmap bitmap(bitmapWidth, bitmapHeight); { wxMemoryDC dc; dc.SelectObject(bitmap); dc.SetBackground(wxBrush(m_bitmapBackgroundColour)); dc.Clear(); if (GetBitmapPlacement() & wxWIZARD_TILE) { TileBitmap(wxRect(0, 0, bitmapWidth, bitmapHeight), dc, bmp); } else { int x, y; if (GetBitmapPlacement() & wxWIZARD_HALIGN_LEFT) x = 0; else if (GetBitmapPlacement() & wxWIZARD_HALIGN_RIGHT) x = bitmapWidth - bmp.GetWidth(); else x = (bitmapWidth - bmp.GetWidth())/2; if (GetBitmapPlacement() & wxWIZARD_VALIGN_TOP) y = 0; else if (GetBitmapPlacement() & wxWIZARD_VALIGN_BOTTOM) y = bitmapHeight - bmp.GetHeight(); else y = (bitmapHeight - bmp.GetHeight())/2; dc.DrawBitmap(bmp, x, y, true); dc.SelectObject(wxNullBitmap); } } bmp = bitmap; } } return true; }
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, wxDefaultValidator, name ) ) return false; m_messageBitmap = bitmap; m_messageBitmapOriginal = bitmap; Widget parentWidget = (Widget) parent->GetClientWidget(); m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("staticBitmap", #if wxUSE_GADGETS xmLabelGadgetClass, parentWidget, #else xmLabelWidgetClass, parentWidget, #endif XmNalignment, XmALIGNMENT_BEGINNING, NULL); ChangeBackgroundColour (); DoSetBitmap(); ChangeFont(false); wxSize actualSize(size); // work around the cases where the bitmap is a wxNull(Icon/Bitmap) if (actualSize.x == -1) actualSize.x = bitmap.Ok() ? bitmap.GetWidth() : 1; if (actualSize.y == -1) actualSize.y = bitmap.Ok() ? bitmap.GetHeight() : 1; AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, actualSize.x, actualSize.y); return true; }
bool wxDIB::Create(const wxBitmap& bmp) { wxCHECK_MSG( bmp.Ok(), false, wxT("wxDIB::Create(): invalid bitmap") ); if ( !Create(GetHbitmapOf(bmp)) ) return false; m_hasAlpha = bmp.HasAlpha(); return true; }
void wxSpeedButton::GetGlyphSize(wxBitmap &inGlyph, int &outWidth, int &outHeight) { if (inGlyph.Ok()) { outWidth = inGlyph.GetWidth(); outHeight = inGlyph.GetHeight(); } else { outWidth = 0; outHeight = 0; }; }
void wxStdRenderer::DrawRadioButton(wxDC& dc, const wxString& label, const wxBitmap& bitmap, const wxRect& rect, int flags, wxAlignment align, int indexAccel) { wxBitmap bmp(bitmap.Ok() ? bitmap : GetRadioBitmap(flags)); DrawCheckOrRadioButton(dc, label, bmp, rect, flags, align, indexAccel); }
wxPen::wxPen(const wxBitmap& stipple, int width) { wxCHECK_RET( stipple.Ok(), wxT("invalid bitmap") ); wxCHECK_RET( stipple.GetWidth() == 8 && stipple.GetHeight() == 8, wxT("stipple bitmap must be 8x8") ); m_refData = new wxPenRefData(); M_PENDATA->m_width = width; M_PENDATA->m_style = wxPENSTYLE_STIPPLE; M_PENDATA->m_stipple = stipple; wxBitmapToPixPattern(stipple, &(M_PENDATA->m_pixPattern), NULL); }
void wxStdRenderer::DrawCheckButton(wxDC& dc, const wxString& label, const wxBitmap& bitmap, const wxRect& rect, int flags, wxAlignment align, int indexAccel) { if (bitmap.Ok()) DrawCheckOrRadioButton(dc, label, bitmap, rect, flags, align, indexAccel); else DrawCheckOrRadioButton(dc, label, GetCheckBitmap(flags), rect, flags, align, indexAccel); }
void wxPrinterDCImpl::DoDrawBitmap( const wxBitmap& rBmp, wxCoord WXUNUSED(vX), wxCoord WXUNUSED(vY), bool WXUNUSED(bUseMask)) { wxCHECK_RET( rBmp.Ok(), wxT("invalid bitmap in wxPrinterDC::DrawBitmap") ); // int nWidth = rBmp.GetWidth(); // int nHeight = rBmp.GetHeight(); // TODO: } // end of wxPrinterDC::DoDrawBitmap
void wxMemoryDC::DoSelect(const wxBitmap& bitmap) { m_bmp = bitmap; if ( !bitmap.Ok() ) { // select the bitmap out of the DC m_surface = NULL; return; } // init the DC for drawing to this bitmap DFBInit(bitmap.GetDirectFBSurface()); }
void wxPrinterDC::DoDrawBitmap( const wxBitmap& rBmp , wxCoord vX , wxCoord vY , bool bUseMask ) { wxCHECK_RET( rBmp.Ok(), _T("invalid bitmap in wxPrinterDC::DrawBitmap") ); // int nWidth = rBmp.GetWidth(); // int nHeight = rBmp.GetHeight(); // TODO: } // end of wxPrinterDC::DoDrawBitmap
void wxGCDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool WXUNUSED(useMask) ) { wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") ); wxCHECK_RET( bmp.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") ); if ( bmp.GetDepth() == 1 ) { m_graphicContext->SetPen(*wxTRANSPARENT_PEN); m_graphicContext->SetBrush( wxBrush( m_textBackgroundColour , wxSOLID ) ); m_graphicContext->DrawRectangle( x , y , bmp.GetWidth() , bmp.GetHeight() ); m_graphicContext->SetBrush( wxBrush( m_textForegroundColour , wxSOLID ) ); m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() ); m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush)); m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen)); } else m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() ); }