diff --git a/common/widgets/bitmap_toggle.cpp b/common/widgets/bitmap_toggle.cpp index 8f6519b739..402955d55f 100644 --- a/common/widgets/bitmap_toggle.cpp +++ b/common/widgets/bitmap_toggle.cpp @@ -31,8 +31,9 @@ wxDEFINE_EVENT( TOGGLE_CHANGED, wxCommandEvent ); -BITMAP_TOGGLE::BITMAP_TOGGLE( wxWindow *aParent, wxWindowID aId, const wxBitmap& aCheckedBitmap, - const wxBitmap& aUncheckedBitmap, bool aChecked ) : +BITMAP_TOGGLE::BITMAP_TOGGLE( wxWindow *aParent, wxWindowID aId, + const wxBitmapBundle& aCheckedBitmap, + const wxBitmapBundle& aUncheckedBitmap, bool aChecked ) : wxPanel( aParent, aId ), m_checked( aChecked ), m_unchecked_bitmap( aUncheckedBitmap ), @@ -42,9 +43,9 @@ BITMAP_TOGGLE::BITMAP_TOGGLE( wxWindow *aParent, wxWindowID aId, const wxBitmap& wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL ); SetSizer( sizer ); - const wxBitmap& bitmap = aChecked ? m_checked_bitmap : m_unchecked_bitmap; + const wxBitmapBundle& bundle = aChecked ? m_checked_bitmap : m_unchecked_bitmap; - m_bitmap = new wxStaticBitmap( this, aId, bitmap, wxDefaultPosition ); + m_bitmap = new wxStaticBitmap( this, aId, bundle, wxDefaultPosition ); sizer->Add( m_bitmap, 0, 0 ); diff --git a/common/widgets/grid_bitmap_toggle.cpp b/common/widgets/grid_bitmap_toggle.cpp index 143b4ad271..eab77e584e 100644 --- a/common/widgets/grid_bitmap_toggle.cpp +++ b/common/widgets/grid_bitmap_toggle.cpp @@ -24,8 +24,8 @@ #include -GRID_BITMAP_TOGGLE_RENDERER::GRID_BITMAP_TOGGLE_RENDERER( const wxBitmap& aCheckedBitmap, - const wxBitmap& aUncheckedBitmap ) : +GRID_BITMAP_TOGGLE_RENDERER::GRID_BITMAP_TOGGLE_RENDERER( const wxBitmapBundle& aCheckedBitmap, + const wxBitmapBundle& aUncheckedBitmap ) : wxGridCellRenderer(), m_bitmapChecked( aCheckedBitmap ), m_bitmapUnchecked( aUncheckedBitmap ) @@ -48,10 +48,11 @@ void GRID_BITMAP_TOGGLE_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wx wxGridCellRenderer::Draw( aGrid, aAttr, aDc, aRect, aRow, aCol, aIsSelected ); bool checked = aGrid.GetCellValue( aRow, aCol ) == "1"; - const wxBitmap& bitmap = checked ? m_bitmapChecked : m_bitmapUnchecked; + const wxBitmapBundle& bundle = checked ? m_bitmapChecked : m_bitmapUnchecked; + wxBitmap bitmap = bundle.GetBitmapFor( &aGrid ); - int x = std::max( 0, ( aRect.GetWidth() - m_bitmapChecked.GetWidth() ) / 2 ); - int y = std::max( 0, ( aRect.GetHeight() - m_bitmapChecked.GetHeight() ) / 2 ); + int x = std::max( 0, ( aRect.GetWidth() - bitmap.GetWidth() ) / 2 ); + int y = std::max( 0, ( aRect.GetHeight() - bitmap.GetHeight() ) / 2 ); aDc.DrawBitmap( bitmap, aRect.GetTopLeft() + wxPoint( x, y ) ); } @@ -60,5 +61,5 @@ void GRID_BITMAP_TOGGLE_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wx wxSize GRID_BITMAP_TOGGLE_RENDERER::GetBestSize( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDc, int aRow, int aCol) { - return m_bitmapChecked.GetSize(); + return m_bitmapChecked.GetPreferredBitmapSizeFor( &aGrid ); } diff --git a/include/widgets/bitmap_toggle.h b/include/widgets/bitmap_toggle.h index 55c4a99a2d..e19d54cc39 100644 --- a/include/widgets/bitmap_toggle.h +++ b/include/widgets/bitmap_toggle.h @@ -26,6 +26,7 @@ #define _BITMAP_TOGGLE_H #include +#include #include #include @@ -45,8 +46,8 @@ class BITMAP_TOGGLE : public wxPanel public: BITMAP_TOGGLE() {} - BITMAP_TOGGLE( wxWindow* aParent, wxWindowID aId, const wxBitmap& aCheckedBitmap, - const wxBitmap& aUncheckedBitmap, bool aChecked = false ); + BITMAP_TOGGLE( wxWindow* aParent, wxWindowID aId, const wxBitmapBundle& aCheckedBitmap, + const wxBitmapBundle& aUncheckedBitmap, bool aChecked = false ); ///< Set the checkbox state void SetValue( bool aValue ); @@ -68,8 +69,8 @@ private: bool m_checked; wxStaticBitmap* m_bitmap; - wxBitmap m_unchecked_bitmap; - wxBitmap m_checked_bitmap; + wxBitmapBundle m_unchecked_bitmap; + wxBitmapBundle m_checked_bitmap; wxLongLong m_debounce; // Timestamp for debouncing events }; diff --git a/include/widgets/grid_bitmap_toggle.h b/include/widgets/grid_bitmap_toggle.h index f57a40e170..a99f545bcb 100644 --- a/include/widgets/grid_bitmap_toggle.h +++ b/include/widgets/grid_bitmap_toggle.h @@ -21,7 +21,7 @@ #ifndef KICAD_GRID_BITMAP_TOGGLE_H #define KICAD_GRID_BITMAP_TOGGLE_H -#include +#include #include @@ -31,8 +31,8 @@ class GRID_BITMAP_TOGGLE_RENDERER : public wxGridCellRenderer { public: - GRID_BITMAP_TOGGLE_RENDERER( const wxBitmap& aCheckedBitmap, - const wxBitmap& aUncheckedBitmap ); + GRID_BITMAP_TOGGLE_RENDERER( const wxBitmapBundle& aCheckedBitmap, + const wxBitmapBundle& aUncheckedBitmap ); ~GRID_BITMAP_TOGGLE_RENDERER() {} @@ -45,9 +45,9 @@ public: int aRow, int aCol) override; private: - wxBitmap m_bitmapChecked; + wxBitmapBundle m_bitmapChecked; - wxBitmap m_bitmapUnchecked; + wxBitmapBundle m_bitmapUnchecked; }; #endif // KICAD_GRID_BITMAP_TOGGLE_H diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 5b9705e3ee..06befbe778 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -523,8 +523,8 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo m_frame->GetToolManager()->RunAction( PCB_ACTIONS::flipBoard ); } ); - m_toggleGridRenderer = new GRID_BITMAP_TOGGLE_RENDERER( KiBitmap( BITMAPS::visibility ), - KiBitmap( BITMAPS::visibility_off ) ); + m_toggleGridRenderer = new GRID_BITMAP_TOGGLE_RENDERER( + KiBitmapBundle( BITMAPS::visibility ), KiBitmapBundle( BITMAPS::visibility_off ) ); m_netsGrid->RegisterDataType( wxT( "bool" ), m_toggleGridRenderer, new wxGridCellBoolEditor ); @@ -550,7 +550,7 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo wxSize size = ConvertDialogToPixels( SWATCH_SIZE_SMALL_DU ); m_netsGrid->SetColSize( NET_GRID_TABLE::COL_COLOR, size.x + cellPadding ); - size = KiBitmap( BITMAPS::visibility ).GetSize(); + size = KiBitmapBundle( BITMAPS::visibility ).GetPreferredBitmapSizeFor( this ); m_netsGrid->SetColSize( NET_GRID_TABLE::COL_VISIBILITY, size.x + cellPadding ); m_netsGrid->SetDefaultCellFont( font ); @@ -1554,10 +1554,9 @@ void APPEARANCE_CONTROLS::rebuildLayers() swatch->SetToolTip( _( "Double click or middle click for color change, " "right click for menu" ) ); - BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( panel, layer, - KiBitmap( BITMAPS::visibility ), - KiBitmap( BITMAPS::visibility_off ), - aSetting->visible ); + BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( + panel, layer, KiBitmapBundle( BITMAPS::visibility ), + KiBitmapBundle( BITMAPS::visibility_off ), aSetting->visible ); btn_visible->SetToolTip( _( "Show or hide this layer" ) ); wxStaticText* label = new wxStaticText( panel, layer, aSetting->label ); @@ -2159,10 +2158,9 @@ void APPEARANCE_CONTROLS::rebuildObjects() sizer->AddSpacer( swatchWidth ); } - BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( m_windowObjects, layer, - KiBitmap( BITMAPS::visibility ), - KiBitmap( BITMAPS::visibility_off ), - aSetting->visible ); + BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( + m_windowObjects, layer, KiBitmapBundle( BITMAPS::visibility ), + KiBitmapBundle( BITMAPS::visibility_off ), aSetting->visible ); wxString tip; tip.Printf( _( "Show or hide %s" ), aSetting->label.Lower() ); @@ -2392,10 +2390,9 @@ void APPEARANCE_CONTROLS::rebuildNets() if( isDefaultClass ) setting->ctl_color->Hide(); - setting->ctl_visibility = new BITMAP_TOGGLE( setting->ctl_panel, aId, - KiBitmap( BITMAPS::visibility ), - KiBitmap( BITMAPS::visibility_off ), - !hiddenClasses.count( name ) ); + setting->ctl_visibility = new BITMAP_TOGGLE( + setting->ctl_panel, aId, KiBitmapBundle( BITMAPS::visibility ), + KiBitmapBundle( BITMAPS::visibility_off ), !hiddenClasses.count( name ) ); wxString tip; tip.Printf( _( "Show or hide ratsnest for nets in %s" ), name );