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 ); } }
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()); } }
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; }
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(); }
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; }
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; }
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; }
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; }
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; }
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; }
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); }
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; }
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; }
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 ); }
int wxGenericImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask ) { wxBitmap bmp(bitmap); if (mask.IsOk()) bmp.SetMask(new wxMask(mask)); return Add(bmp); }
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(wxCLASSINFO(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.IsOk()) newBitmap->SetMask(new wxMask(mask)); return true; }
void setImage(wxString path) { m_image_path = path; if(path.EndsWith(wxT(".icns"))) { wxExecute(wxT("sips -s format png '") + path + wxT("' --out /tmp/tmpicon.png"), wxEXEC_SYNC); path = wxT("/tmp/tmpicon.png"); } m_image.LoadFile(path, wxBITMAP_TYPE_ANY); if(m_image.IsOk()) { if(m_image.GetWidth() > 50 or m_image.GetHeight() > 50) { wxImage tmp = m_image.ConvertToImage(); tmp.Rescale(50, 50, wxIMAGE_QUALITY_HIGH); m_image = wxBitmap(tmp); } const int w = m_image.GetWidth(); const int h = m_image.GetHeight(); SetMinSize(wxSize(w + 20, h + 20)); SetMaxSize(wxSize(w + 20, h + 20)); Refresh(); // repaint needed to see change } else { wxMessageBox(_("Failed to load image")); } }
void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) { if ( bitmap.IsOk() ) { if ( m_bitmapSize.x < 0 ) { m_bitmapSize.x = bitmap.GetWidth(); m_bitmapSize.y = bitmap.GetHeight(); } GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); GtkTreeModel *model = gtk_combo_box_get_model( combobox ); GtkTreeIter iter; if ( gtk_tree_model_iter_nth_child( model, &iter, NULL, n ) ) { GValue value0 = { 0, }; g_value_init( &value0, G_TYPE_OBJECT ); g_value_set_object( &value0, bitmap.GetPixbuf() ); gtk_list_store_set_value( GTK_LIST_STORE(model), &iter, m_bitmapCellIndex, &value0 ); g_value_unset( &value0 ); } } }
void wxAnyButton::GTKDoShowBitmap(const wxBitmap& bitmap) { wxASSERT_MSG( bitmap.IsOk(), "invalid bitmap" ); GtkWidget *image; if ( DontShowLabel() ) { image = gtk_bin_get_child(GTK_BIN(m_widget)); } else // have both label and bitmap { #ifdef __WXGTK26__ if ( !gtk_check_version(2,6,0) ) { image = gtk_button_get_image(GTK_BUTTON(m_widget)); } else #endif // __WXGTK26__ { // buttons with both label and bitmap are only supported with GTK+ // 2.6 so far // // it shouldn't be difficult to implement them ourselves for the // previous GTK+ versions by stuffing a container with a label and // an image inside GtkButton but there doesn't seem to be much // point in doing this for ancient GTK+ versions return; } } wxCHECK_RET( image && GTK_IS_IMAGE(image), "must have image widget" ); gtk_image_set_from_pixbuf(GTK_IMAGE(image), bitmap.GetPixbuf()); }
void wxRibbonAUIArtProvider::GetBarTabWidth( wxDC& dc, wxWindow* WXUNUSED(wnd), const wxString& label, const wxBitmap& bitmap, int* ideal, int* small_begin_need_separator, int* small_must_have_separator, int* minimum) { int width = 0; int min = 0; if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.IsEmpty()) { dc.SetFont(m_tab_active_label_font); width += dc.GetTextExtent(label).GetWidth(); min += wxMin(30, width); // enough for a few chars if(bitmap.IsOk()) { // gap between label and bitmap width += 4; min += 2; } } if((m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) && bitmap.IsOk()) { width += bitmap.GetWidth(); min += bitmap.GetWidth(); } if(ideal != NULL) { *ideal = width + 16; } if(small_begin_need_separator != NULL) { *small_begin_need_separator = min; } if(small_must_have_separator != NULL) { *small_must_have_separator = min; } if(minimum != NULL) { *minimum = min; } }
wxSize wxAuiMSWTabArt::GetTabSize(wxDC& dc, wxWindow* wnd, const wxString& caption, const wxBitmap& bitmap, bool active, int close_button_state, int* x_extent) { if ( !IsThemed() ) return wxAuiGenericTabArt::GetTabSize(dc, wnd, caption, bitmap, active, close_button_state, x_extent); if ( !m_closeBtnSize.IsFullySpecified() ) InitSizes(wnd, dc); wxCoord textWidth, textHeight, tmp; dc.SetFont(wnd->GetFont()); dc.GetTextExtent(caption, &textWidth, &tmp); dc.GetTextExtent("ABCDEFXj", &tmp, &textHeight); wxCoord tabWidth = wxMax(m_tabSize.x, textWidth); wxCoord tabHeight = wxMax(m_tabSize.y, textHeight); // if the close button is showing, add space for it if ( close_button_state != wxAUI_BUTTON_STATE_HIDDEN ) { tabWidth += m_closeBtnSize.x; tabHeight = wxMax(tabHeight, m_closeBtnSize.y); } // if there's a bitmap, add space for it if ( bitmap.IsOk() ) { tabWidth += bitmap.GetWidth() + wnd->FromDIP(3); // bitmap padding tabHeight = wxMax(tabHeight, bitmap.GetHeight() + wnd->FromDIP(2)); } // add padding tabWidth += wnd->FromDIP(12); tabHeight += wnd->FromDIP(3); if ( m_flags & wxAUI_NB_TAB_FIXED_WIDTH ) { tabWidth = m_fixedTabWidth; } else { int minTabWidth = wnd->FromDIP(46); if (tabWidth < minTabWidth) tabWidth = minTabWidth; } *x_extent = tabWidth; if (tabHeight > m_maxTabHeight) m_maxTabHeight = tabHeight; return wxSize(tabWidth, tabHeight); }
void wxMemoryDC::DoSelect(const wxBitmap& bitmap) { if ( bitmap.IsOk() ) { m_selected = bitmap; SetMGLDC(m_selected.CreateTmpDC(), TRUE); } }
void paintEvent(wxPaintEvent& evt) { wxPaintDC dc(this); if(m_image.IsOk()) { dc.DrawBitmap(m_image, 10, 10, false); } }
wxSize clAuiMainNotebookTabArt::GetTabSize(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxString& caption, const wxBitmap& bitmap, bool active, int close_button_state, int* x_extent) { static wxCoord measured_texty(wxNOT_FOUND); wxCoord measured_textx; wxCoord tmp; wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); if(active) { f.SetWeight(wxFONTWEIGHT_BOLD); } dc.SetFont(f); dc.GetTextExtent(caption, &measured_textx, &tmp); // do it once if(measured_texty == wxNOT_FOUND) dc.GetTextExtent(wxT("ABCDEFXj"), &tmp, &measured_texty); // add padding around the text wxCoord tab_width = measured_textx; wxCoord tab_height = measured_texty; if(tab_height < 16) tab_height = 16; // if the close button is showing, add space for it if(close_button_state != wxAUI_BUTTON_STATE_HIDDEN) tab_width += X_DIAMETER + 3; // if there's a bitmap, add space for it // NOTE: we only support 16 pixels bitmap (or smaller) // so there is no need to adjust the tab height! tab_height += TAB_HEIGHT_SPACER; if(bitmap.IsOk()) { tab_width += bitmap.GetWidth(); tab_width += 3; // right side bitmap padding } // add padding #ifdef __WXMAC__ tab_width += 16; #else tab_width += 16; #endif if(m_flags & wxAUI_NB_TAB_FIXED_WIDTH) { tab_width = 80; } *x_extent = tab_width; return wxSize(tab_width, tab_height); }
bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap) { wxCHECK_MSG( bitmap.IsOk(), false, wxT("Invalid bitmap") ); wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") ); m_bitmap = bitmap; return true; }
// See also: wxButton::DoSetBitmap and wxBitmapButton::DoSetBitmap void DynamicBitmap::SetBitmap( const wxBitmap& bitmap, wxButtonBase::State state ) { if ( bitmap.IsOk() ) { DoSetBitmap( bitmap, state ); switch ( state ) { default: // nothing special to do but include the default clause to // suppress gcc warnings //HELIUM_ASSERT(); break; case wxButtonBase::State_Normal: m_WasStateSetByUser[wxButtonBase::State_Normal] = true; #if wxUSE_IMAGE if ( !m_WasStateSetByUser[wxButtonBase::State_Disabled] ) { wxImage disabledImage( bitmap.ConvertToImage().ConvertToGreyscale() ); DoSetBitmap( disabledImage, wxButtonBase::State_Disabled ); } #endif // wxUSE_IMAGE break; case wxButtonBase::State_Current: m_WasStateSetByUser[wxButtonBase::State_Current] = true; break; case wxButtonBase::State_Pressed: m_WasStateSetByUser[wxButtonBase::State_Pressed] = true; break; case wxButtonBase::State_Disabled: m_WasStateSetByUser[wxButtonBase::State_Disabled] = true; break; case wxButtonBase::State_Focused: m_WasStateSetByUser[wxButtonBase::State_Focused] = true; // if the focus bitmap is specified but current one isn't, use // the focus bitmap for hovering as well if this is consistent // with the current Windows version look and feel // // rationale: this is compatible with the old wxGTK behaviour // and also makes it much easier to do "the right thing" for // all platforms (some of them, such as Windows XP, have "hot" // buttons while others don't) if ( !m_WasStateSetByUser[wxButtonBase::State_Current] ) { DoSetBitmap( bitmap, wxButtonBase::State_Current ); } break; } } }
void FrameNotification::create( wxString const& title, wxString const& message, wxBitmap const& bitmap, int maxWidth) { //SetMaxSize(wxSize(maxWidth, -1)); //Création du titre et du message. _staticTextTitle = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize); _staticTextTitle->SetLabelMarkup("<big><b>"+title+"</b></big>"); _staticTextMessage = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize); _staticTextMessage->SetLabelMarkup(message); //Création de la statice line. _staticLine = new wxStaticLine(this); //Créations du wxStaticBitmap _staticBitmap = nullptr; if(bitmap.IsOk()) { _staticBitmap = new wxStaticBitmap(this, wxID_ANY, bitmap); maxWidth -= _staticBitmap->GetSize().GetWidth()+SIZE_BORDER; } //Wrap le TextMessage //_staticTextMessage->Wrap(maxWidth-5*SIZE_BORDER); //Mise en forme titre et du message avec un sizer. wxSizer* sizerNotification = new wxBoxSizer(wxVERTICAL); sizerNotification->Add(_staticTextTitle, 0, wxEXPAND|wxLEFT, 2*SIZE_BORDER); sizerNotification->Add(_staticLine, 0, wxEXPAND|wxTOP|wxBOTTOM, SIZE_BORDER); sizerNotification->Add(_staticTextMessage, 0, wxEXPAND|wxLEFT, 4*SIZE_BORDER); //Mise en forme du GUI avec un sizer. wxSizer* sizerMain = new wxBoxSizer(wxHORIZONTAL); if(_staticBitmap != nullptr) sizerMain->Add(_staticBitmap, 0, wxALIGN_CENTER| wxLEFT|wxBOTTOM|wxTOP, SIZE_BORDER); sizerMain->Add(sizerNotification, 0, wxRIGHT|wxBOTTOM|wxTOP, SIZE_BORDER); SetSizerAndFit(sizerMain); SetMaxClientSize(GetSize()); //Modification de des couleurs SetBackgroundColour(ManNotification::get().getColourBackground()); SetForegroundColour(ManNotification::get().getColourText()); //Bind Bind(wxEVT_TIMER, &FrameNotification::onTimeout, this); _staticTextTitle->Bind(wxEVT_LEFT_DOWN, &FrameNotification::onLeftDown, this); _staticLine->Bind(wxEVT_LEFT_DOWN, &FrameNotification::onLeftDown, this); _staticTextMessage->Bind(wxEVT_LEFT_DOWN, &FrameNotification::onLeftDown, this); if(_staticBitmap) _staticBitmap->Bind(wxEVT_LEFT_DOWN, &FrameNotification::onLeftDown, this); Bind(wxEVT_LEFT_DOWN, &FrameNotification::onLeftDown, this); }
int Notebook::DoGetBmpIdx(const wxBitmap& bmp) { int idx = wxNOT_FOUND; if(bmp.IsOk()) { if(m_imgList == NULL) { SetImageList(new wxImageList(bmp.GetWidth(), bmp.GetHeight(), true)); } idx = m_imgList->Add(bmp); } return idx; }
bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) { if (!bitmap.IsOk()) return false; if (m_qtBitmap) delete m_qtBitmap; m_qtBitmap = new QBitmap(bitmap.GetHandle()->createMaskFromColor(colour.GetHandle())); return true; }
wxSize clAuiTabArt::GetTabSize(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxString& caption, const wxBitmap& bitmap, bool WXUNUSED(active), int close_button_state, int* x_extent) { static wxCoord measured_texty(wxNOT_FOUND); wxCoord measured_textx; wxCoord tmp; dc.SetFont(m_measuring_font); dc.GetTextExtent(caption, &measured_textx, &tmp); // do it once if(measured_texty == wxNOT_FOUND) dc.GetTextExtent(wxT("ABCDEFXj"), &tmp, &measured_texty); // add padding around the text wxCoord tab_width = measured_textx; wxCoord tab_height = measured_texty; // if the close button is showing, add space for it if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) tab_width += m_active_close_bmp.GetWidth() + 3; // if there's a bitmap, add space for it if (bitmap.IsOk()) { tab_width += bitmap.GetWidth(); tab_width += 3; // right side bitmap padding tab_height = wxMax(tab_height, bitmap.GetHeight()); tab_height += 10; } else { tab_height += 10; } // add padding #ifdef __WXMAC__ tab_width += 16; #else tab_width += 16; #endif if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH) { tab_width = m_fixed_tab_width; } *x_extent = tab_width; return wxSize(tab_width, tab_height); }