void wxGTKCairoDCImpl::DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask) { wxCHECK_RET(IsOk(), "invalid DC"); cairo_t* cr = NULL; if (m_graphicContext) cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext()); if (cr) { cairo_save(cr); bitmap.Draw(cr, x, y, useMask, &m_textForegroundColour, &m_textBackgroundColour); cairo_restore(cr); } }
void wxDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) { wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); wxMemoryDC memDC; memDC.SelectObjectAsSource(bitmap); #if 0 // Not sure if we need this. The mask should leave the masked areas as per // the original background of this DC. if (useMask) { // There might be transparent areas, so make these the same colour as this // DC memDC.SetBackground(* GetBackground()); memDC.Clear(); } #endif // 0 Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask); memDC.SelectObject(wxNullBitmap); }
bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString &name ) { m_needParent = true; m_acceptsFocus = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxBitmapButton creation failed") ); return false; } m_bitmaps[State_Normal] = bitmap; m_widget = gtk_button_new(); if (style & wxNO_BORDER) gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); if (bitmap.IsOk()) { OnSetBitmap(); } gtk_signal_connect_after( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "enter", GTK_SIGNAL_FUNC(gtk_bmpbutton_enter_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "leave", GTK_SIGNAL_FUNC(gtk_bmpbutton_leave_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "pressed", GTK_SIGNAL_FUNC(gtk_bmpbutton_press_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "released", GTK_SIGNAL_FUNC(gtk_bmpbutton_release_callback), (gpointer*)this ); m_parent->DoAddChild( this ); PostCreation(size); return true; }
bool wxRegion::Union(const wxBitmap& bmp, const wxColour& transColour, int tolerance) { #if (!defined(__WXMSW__) || wxUSE_WXDIB) wxImage image = bmp.ConvertToImage(); return DoRegionUnion(*this, image, transColour.Red(), transColour.Green(), transColour.Blue(), tolerance); #else return false; #endif }
wxSize clAuiSimpleTabArt::GetTabSize(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxString& caption, const wxBitmap& bitmap, bool WXUNUSED(active), int close_button_state, int* x_extent) { wxCoord measured_textx, measured_texty; dc.SetFont(m_measuring_font); dc.GetTextExtent(caption, &measured_textx, &measured_texty); wxCoord base_height = measured_texty; wxCoord base_width = measured_textx; if(bitmap.IsOk()) { if(bitmap.GetHeight() > base_height) base_height = bitmap.GetHeight(); base_width += bitmap.GetWidth() + 2; } wxCoord tab_height = base_height + 6; wxCoord tab_width = base_width + tab_height + 5; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) tab_width += m_active_close_bmp.GetWidth(); if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH) { tab_width = m_fixed_tab_width; } *x_extent = tab_width - (tab_height/2) - 1; return wxSize(tab_width, tab_height); }
int wxGenericImageList::Add( const wxBitmap &bitmap ) { wxASSERT_MSG( (bitmap.GetWidth() >= m_width && bitmap.GetHeight() == m_height) || (m_width == 0 && m_height == 0), wxT("invalid bitmap size in wxImageList: this might work ") wxT("on this platform but definitely won't under Windows.") ); const int index = int(m_images.GetCount()); if (bitmap.IsKindOf(wxCLASSINFO(wxIcon))) { m_images.Append( new wxIcon( (const wxIcon&) bitmap ) ); } else { // Mimic behaviour of Windows ImageList_Add that automatically breaks up the added // bitmap into sub-images of the correct size if (m_width > 0 && bitmap.GetWidth() > m_width && bitmap.GetHeight() >= m_height) { int numImages = bitmap.GetWidth() / m_width; for (int subIndex = 0; subIndex < numImages; subIndex++) { wxRect rect(m_width * subIndex, 0, m_width, m_height); wxBitmap tmpBmp = bitmap.GetSubBitmap(rect); m_images.Append( new wxBitmap(tmpBmp) ); } } else { m_images.Append( new wxBitmap(bitmap) ); } } if (m_width == 0 && m_height == 0) { m_width = bitmap.GetWidth(); m_height = bitmap.GetHeight(); } return index; }
static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int WXUNUSED(x), int WXUNUSED(y)) { wxMemoryDC dcMem; #ifdef USE_PALETTE_IN_SPLASH bool hiColour = (wxDisplayDepth() >= 16) ; if (bitmap.GetPalette() && !hiColour) { dcMem.SetPalette(* bitmap.GetPalette()); } #endif // USE_PALETTE_IN_SPLASH dcMem.SelectObjectAsSource(bitmap); dc.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0); dcMem.SelectObject(wxNullBitmap); #ifdef USE_PALETTE_IN_SPLASH if (bitmap.GetPalette() && !hiColour) { dcMem.SetPalette(wxNullPalette); } #endif // USE_PALETTE_IN_SPLASH }
bool wxSVGBitmapFileHandler::ProcessBitmap(const wxBitmap& bmp, wxCoord x, wxCoord y, wxOutputStream& stream) const { static int sub_images = 0; if ( wxImage::FindHandler(wxBITMAP_TYPE_PNG) == NULL ) wxImage::AddHandler(new wxPNGHandler); // find a suitable file name wxString sPNG; do { sPNG = wxString::Format("image%d.png", sub_images++); } while (wxFile::Exists(sPNG)); if ( !bmp.SaveFile(sPNG, wxBITMAP_TYPE_PNG) ) return false; // reference the bitmap from the SVG doc using only filename & ext sPNG = sPNG.AfterLast(wxFileName::GetPathSeparator()); // reference the bitmap from the SVG doc wxString s; s += wxString::Format(" <image x=\"%d\" y=\"%d\" width=\"%dpx\" height=\"%dpx\"", x, y, bmp.GetWidth(), bmp.GetHeight()); s += wxString::Format(" xlink:href=\"%s\"/>\n", sPNG); // write to the SVG file const wxCharBuffer buf = s.utf8_str(); stream.Write(buf, strlen((const char *)buf)); return stream.IsOk(); }
void BitmapTestCase::setUp() { m_bmp.Create(10, 10); wxMemoryDC dc(m_bmp);; dc.SetBackground(*wxWHITE); dc.Clear(); dc.SetBrush(*wxBLACK_BRUSH); dc.DrawRectangle(4, 4, 2, 2); dc.SetPen(*wxRED_PEN); dc.DrawLine(0, 0, 10, 10); dc.DrawLine(10, 0, 0, 10); }
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 Image::LoadImage(const wxBitmap &bitmap) { // Convert the bitmap to a png image we can use as m_compressedImage wxImage image = bitmap.ConvertToImage(); wxMemoryOutputStream stream; image.SaveFile(stream,wxBITMAP_TYPE_PNG); m_compressedImage.AppendData(stream.GetOutputStreamBuffer()->GetBufferStart(), stream.GetOutputStreamBuffer()->GetBufferSize()); // Set the info about the image. m_extension = wxT("png"); m_originalWidth = image.GetWidth(); m_originalHeight = image.GetHeight(); m_scaledBitmap.Create (1,1); }
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; }
OutputViewControlBarButton::OutputViewControlBarButton(wxWindow* win, const wxString& title, const wxBitmap& bmp, long style) : wxPanel(win) , m_state(Button_Normal) , m_text (title) , m_bmp (bmp) , m_style (style) { if ( title.IsEmpty() && bmp.IsOk() == false ) return; SetSizeHints(DoCalcButtonWidth( this, m_style & Button_UseText ? m_text : wxT(""), m_bmp, m_style & Button_UseXSpacer ? BUTTON_SPACER_X : 1), DoCalcButtonHeight(this, wxEmptyString, m_bmp, BUTTON_SPACER_Y)); }
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() ); }
wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, EDA_BASE_FRAME* aWindow ) { const int scale = get_scale_factor( aWindow ); if( scale == 4) { return wxBitmap( aBitmap ); } else { wxImage image = aBitmap.ConvertToImage(); image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4, wxIMAGE_QUALITY_BILINEAR ); return wxBitmap( image ); } }
bool BitmapFromWindow(wxWindow *window, wxBitmap& bitmap) { bool ret; wxMemoryDC mdc; wxClientDC cdc(window); const wxSize& size=window->GetClientSize(); window->Raise(); wxTheApp->Yield(); bitmap.Create(size.x, size.y); mdc.SelectObject(bitmap); ret=mdc.Blit(0, 0, size.x, size.y, &cdc, 0, 0); mdc.SelectObject(wxNullBitmap); return ret; }
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxString &lbl, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name) { wxString label(lbl); if (label.empty() && wxIsStockID(id)) label = wxGetStockLabel(id); long ctrl_style = style & ~wxBU_ALIGN_MASK; ctrl_style = ctrl_style & ~wxALIGN_MASK; if((style & wxBU_RIGHT) == wxBU_RIGHT) ctrl_style |= wxALIGN_RIGHT; else if((style & wxBU_LEFT) == wxBU_LEFT) ctrl_style |= wxALIGN_LEFT; else ctrl_style |= wxALIGN_CENTRE_HORIZONTAL; if((style & wxBU_TOP) == wxBU_TOP) ctrl_style |= wxALIGN_TOP; else if((style & wxBU_BOTTOM) == wxBU_BOTTOM) ctrl_style |= wxALIGN_BOTTOM; else ctrl_style |= wxALIGN_CENTRE_VERTICAL; if ( !wxControl::Create(parent, id, pos, size, ctrl_style, validator, name) ) return false; SetLabel(label); if (bitmap.IsOk()) SetBitmap(bitmap); // SetInitialSize called by SetBitmap() else SetInitialSize(size); CreateInputHandler(wxINP_HANDLER_BUTTON); return true; }
wxBitmap OverlayTool::DoAddBitmap(const wxBitmap& bmp, const wxColour& colour) const { wxMemoryDC dcMem; wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxBitmap bitmap(16, 16, 32); dcMem.SelectObject(bitmap); // Draw white background dcMem.SetPen( wxPen(col) ); dcMem.SetBrush( wxBrush(col) ); dcMem.DrawRectangle(wxPoint(0, 0), wxSize(16, 16)); // Draw the base icon dcMem.DrawBitmap(bmp.ConvertToDisabled(), wxPoint(0, 0), true); wxColour c2 = DrawingUtils::LightColour(colour, 3.0); dcMem.GradientFillLinear(wxRect(wxPoint(0, 1), wxSize(2, 14)), colour, c2, wxSOUTH); //// Draw a small 2 pixel vertical line //wxBitmap coverBmp(16, 16, 32); //{ // wxAlphaPixelData pixData(coverBmp); // // // Set the fill pixels // int red = colour.Red(); // int green = colour.Green(); // int blue = colour.Blue(); // wxAlphaPixelData::Iterator p(pixData); // for (int y=0; y<16; y++) { // p.MoveTo(pixData, 0, y); // for (int x=0; x<16; x++) { // p.Red() = red; // p.Green() = green; // p.Blue() = blue; // p.Alpha() = 90; // ++p; // } // } //} // //dcMem.DrawBitmap(coverBmp, wxPoint(0, 0)); dcMem.SelectObject(wxNullBitmap); return bitmap; }
bool DropDownBase::Create( wxWindow* parent, wxWindowID id, 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|style,val,name)) return false; if (!s_dropdownBitmap.Ok()) s_dropdownBitmap = wxBitmap(down_arrow_xpm_data); m_dropdownButton = new wxCustomButton(this, IDD_DROPDOWN_BUTTON, s_dropdownBitmap, wxDefaultPosition, wxSize(DROPDOWN_DROP_WIDTH, wxDefaultCoord), wxCUSTBUT_BUTTON); return true; }
void wxMemoryDC::DoSelect( const wxBitmap& bitmap) { // select old bitmap out of the device context if ( m_oldBitmap ) { ::SelectObject(GetHdc(), (HBITMAP) m_oldBitmap); if ( m_selectedBitmap.Ok() ) { #ifdef __WXDEBUG__ m_selectedBitmap.SetSelectedInto(NULL); #endif m_selectedBitmap = wxNullBitmap; } } // check for whether the bitmap is already selected into a device context #ifdef __WXDEBUG__ wxASSERT_MSG( !bitmap.GetSelectedInto() || (bitmap.GetSelectedInto() == this), wxT("Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)") ); #endif m_selectedBitmap = bitmap; WXHBITMAP hBmp = m_selectedBitmap.GetHBITMAP(); if ( !hBmp ) return; #ifdef __WXDEBUG__ m_selectedBitmap.SetSelectedInto(this); #endif hBmp = (WXHBITMAP)::SelectObject(GetHdc(), (HBITMAP)hBmp); if ( !hBmp ) { wxLogLastError(wxT("SelectObject(memDC, bitmap)")); wxFAIL_MSG(wxT("Couldn't select a bitmap into wxMemoryDC")); } else if ( !m_oldBitmap ) { m_oldBitmap = hBmp; } }
bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name) { if ( !wxToggleButton::Create(parent, id, wxEmptyString, pos, size, style | wxBU_NOTEXT | wxBU_EXACTFIT, validator, name) ) return false; if ( bitmap.IsOk() ) { SetBitmapLabel(bitmap); // we need to adjust the size after setting the bitmap as it may be too // big for the default button size SetInitialSize(size); } return true; }
wxBitmap Style::SetBitmapBrightnessAbs( wxBitmap& bitmap, double level ) { wxImage image = bitmap.ConvertToImage(); int gimg_width = image.GetWidth(); int gimg_height = image.GetHeight(); for( int iy = 0; iy < gimg_height; iy++ ) { for( int ix = 0; ix < gimg_width; ix++ ) { if( !image.IsTransparent( ix, iy, 30 ) ) { wxImage::RGBValue rgb( image.GetRed( ix, iy ), image.GetGreen( ix, iy ), image.GetBlue( ix, iy ) ); wxImage::HSVValue hsv = wxImage::RGBtoHSV( rgb ); hsv.value = hsv.value * level; wxImage::RGBValue nrgb = wxImage::HSVtoRGB( hsv ); image.SetRGB( ix, iy, nrgb.red, nrgb.green, nrgb.blue ); } } } return wxBitmap( image ); }
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) { if ( !wxBitmapButtonBase::Create( parent, id, pos, size, style, validator, name )) return false; // Show the initial bitmap and resize accordingly: if ( bitmap.IsOk() ) { wxBitmapButtonBase::SetBitmapLabel(bitmap); // we need to adjust the size after setting the bitmap as it may be too // big for the default button size SetInitialSize(size); } return true; }
bool SpriteObject::GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail) const { #if !defined(GD_NO_WX_GUI) //Generate a thumbnail from the first animation if ( !HasNoAnimations() && !GetAnimation(0).HasNoDirections() && !GetAnimation(0).GetDirection(0).HasNoSprites() ) { gd::String imageName = GetAnimation(0).GetDirection(0).GetSprite(0).GetImageName(); if ( project.GetResourcesManager().HasResource(imageName) && wxFileExists(project.GetResourcesManager().GetResource(imageName).GetAbsoluteFile(project)) ) { thumbnail = wxBitmap( project.GetResourcesManager().GetResource(imageName).GetAbsoluteFile(project), wxBITMAP_TYPE_ANY); wxImage thumbImage = thumbnail.ConvertToImage(); thumbnail = wxBitmap(thumbImage.Scale(24, 24)); return true; } } #endif return false; }
bool wxEffectsImpl::TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap) { int w = bitmap.GetWidth(); int h = bitmap.GetHeight(); wxMemoryDC dcMem; #if wxUSE_PALETTE static bool hiColour = (wxDisplayDepth() >= 16) ; if (bitmap.GetPalette() && !hiColour) { dc.SetPalette(* bitmap.GetPalette()); dcMem.SetPalette(* bitmap.GetPalette()); } #endif // wxUSE_PALETTE dcMem.SelectObjectAsSource(bitmap); int i, j; for (i = rect.x; i < rect.x + rect.width; i += w) { for (j = rect.y; j < rect.y + rect.height; j+= h) dc.Blit(i, j, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0); } dcMem.SelectObject(wxNullBitmap); #if wxUSE_PALETTE if (bitmap.GetPalette() && !hiColour) { dc.SetPalette(wxNullPalette); dcMem.SetPalette(wxNullPalette); } #endif // wxUSE_PALETTE return true; }
/** * Get the shield icon for UAC. * * This method returns the small shield icon for UAC * on Vista and above. To be able to run this app also on * previous Windows versions, the function pointer to * SHGetStockIconInfo is obtained via GetProcAddress * (i.e. no link-time dependency). */ bool Win32Utils::getShieldIcon(wxBitmap &shieldBM) { HMODULE hShellDLL; HRESULT hr; bool isOK = true; HRESULT (CALLBACK* pfnSHGetStockIconInfo)(SHSTOCKICONID siid, UINT uFlags, SHSTOCKICONINFO *psii); hShellDLL = ::LoadLibraryW(L"shell32.dll"); if(hShellDLL == NULL) return false; (*(FARPROC*)&pfnSHGetStockIconInfo) = ::GetProcAddress(hShellDLL, "SHGetStockIconInfo"); if(pfnSHGetStockIconInfo) { SHSTOCKICONINFO stockInfo; stockInfo.cbSize = sizeof(SHSTOCKICONINFO); hr = pfnSHGetStockIconInfo(SIID_SHIELD, SHGSI_ICON | SHGSI_SMALLICON, &stockInfo); if(hr == S_OK) { wxIcon uacShieldIcon; #if wxCHECK_VERSION(2, 9, 0) uacShieldIcon.CreateFromHICON(stockInfo.hIcon); #endif shieldBM.CopyFromIcon(uacShieldIcon); ::DestroyIcon(stockInfo.hIcon); } else isOK = false; } else isOK = false; ::FreeLibrary(hShellDLL); return isOK; }
void SetBitmap( const wxBitmap& bitmap ) { MenuItemIndex i = FindMenuItemIndex() ; if ( i > 0 ) { if ( bitmap.IsOk() ) { #if wxUSE_BMPBUTTON ControlButtonContentInfo info ; wxMacCreateBitmapButton( &info , bitmap ) ; if ( info.contentType != kControlNoContent ) { if ( info.contentType == kControlContentIconRef ) SetMenuItemIconHandle( m_parentMenuRef, i , kMenuIconRefType , (Handle) info.u.iconRef ) ; else if ( info.contentType == kControlContentCGImageRef ) SetMenuItemIconHandle( m_parentMenuRef, i , kMenuCGImageRefType , (Handle) info.u.imageRef ) ; } wxMacReleaseBitmapButton( &info ) ; #endif } } }
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxStaticBitmap creation failed") ); return false; } m_bitmap = bitmap; m_widget = gtk_image_new(); g_object_ref(m_widget); if (bitmap.Ok()) SetBitmap(bitmap); PostCreation(size); m_parent->DoAddChild( this ); return true; }
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style, validator, name) ) return false; if ( bitmap.IsOk() ) SetBitmapLabel(bitmap); if ( !size.IsFullySpecified() ) { // As our bitmap has just changed, our best size has changed as well so // reset the initial size using the new value. SetInitialSize(size); } return true; }
wxImage ReplaceChannelStatusColour(wxBitmap img, const wxColour& colour) { wxImage ret = img.ConvertToImage(); wxImage::HSVValue origcolour = wxImage::RGBtoHSV(wxImage::RGBValue(colour.Red(), colour.Green(), colour.Blue())); double bright = origcolour.value - 0.1 * origcolour.value; bright = LSL::Util::Clamp(bright, 0.0, 1.0); wxImage::HSVValue hsvdarker1(origcolour.hue, origcolour.saturation, bright); bright = origcolour.value - 0.5 * origcolour.value; bright = LSL::Util::Clamp(bright, 0.0, 1.0); wxImage::HSVValue hsvdarker2(origcolour.hue, origcolour.saturation, bright); wxImage::RGBValue rgbdarker1 = wxImage::HSVtoRGB(hsvdarker1); wxImage::RGBValue rgbdarker2 = wxImage::HSVtoRGB(hsvdarker2); ret.Replace(164, 147, 0, rgbdarker2.red, rgbdarker2.green, rgbdarker2.blue); ret.Replace(255, 228, 0, rgbdarker1.red, rgbdarker1.green, rgbdarker1.blue); ret.Replace(255, 253, 234, colour.Red(), colour.Green(), colour.Blue()); return ret; }