Use bitmap bundles in GRID_CELL_ICON_RENDERER.
This commit is contained in:
@@ -154,7 +154,7 @@ wxSize GRID_CELL_ICON_TEXT_RENDERER::GetBestSize( wxGrid& grid, wxGridCellAttr&
|
||||
}
|
||||
|
||||
|
||||
GRID_CELL_ICON_RENDERER::GRID_CELL_ICON_RENDERER( const wxBitmap& icon ) :
|
||||
GRID_CELL_ICON_RENDERER::GRID_CELL_ICON_RENDERER( const wxBitmapBundle& icon ) :
|
||||
m_icon( icon )
|
||||
{
|
||||
}
|
||||
@@ -172,9 +172,12 @@ void GRID_CELL_ICON_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC&
|
||||
// Draw icon
|
||||
if( m_icon.IsOk() )
|
||||
{
|
||||
aDC.DrawBitmap( m_icon,
|
||||
rect.GetLeft() + ( rect.GetWidth() - m_icon.GetWidth() ) / 2,
|
||||
rect.GetTop() + ( rect.GetHeight() - m_icon.GetHeight() ) / 2,
|
||||
wxSize logicSize = aGrid.FromDIP( m_icon.GetDefaultSize() );
|
||||
wxSize physSize = aGrid.ToPhys( logicSize );
|
||||
|
||||
aDC.DrawBitmap( m_icon.GetBitmap( physSize ),
|
||||
rect.GetLeft() + ( rect.GetWidth() - logicSize.GetWidth() ) / 2,
|
||||
rect.GetTop() + ( rect.GetHeight() - logicSize.GetHeight() ) / 2,
|
||||
true );
|
||||
}
|
||||
}
|
||||
@@ -183,7 +186,10 @@ void GRID_CELL_ICON_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC&
|
||||
wxSize GRID_CELL_ICON_RENDERER::GetBestSize( wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
|
||||
int row, int col )
|
||||
{
|
||||
return wxSize( m_icon.GetWidth() + 6, m_icon.GetHeight() + 4 );
|
||||
wxSize size = m_icon.GetDefaultSize();
|
||||
size.IncBy( 6, 4 );
|
||||
|
||||
return grid.FromDIP( size );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
class KICOMMON_API GRID_CELL_ICON_RENDERER : public wxGridCellRenderer
|
||||
{
|
||||
public:
|
||||
GRID_CELL_ICON_RENDERER( const wxBitmap& icon );
|
||||
GRID_CELL_ICON_RENDERER( const wxBitmapBundle& aIcon );
|
||||
|
||||
void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
|
||||
const wxRect& aRect, int aRow, int aCol, bool isSelected ) override;
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
wxGridCellRenderer* Clone() const override;
|
||||
|
||||
private:
|
||||
wxBitmap m_icon;
|
||||
wxBitmapBundle m_icon;
|
||||
};
|
||||
|
||||
//---- Grid helpers: custom wxGridCellRenderer that renders just an icon from wxArtprovider -
|
||||
|
||||
@@ -39,7 +39,7 @@ DIALOG_MULTICHANNEL_REPEAT_LAYOUT::DIALOG_MULTICHANNEL_REPEAT_LAYOUT( PCB_BASE_F
|
||||
m_parentTool( aParentTool )
|
||||
{
|
||||
m_board = aFrame->GetBoard();
|
||||
m_detailsIcon = KiBitmap( BITMAPS::help, 16 );
|
||||
m_detailsIcon = KiBitmapBundleDef( BITMAPS::help, 16 );
|
||||
|
||||
m_raGrid->PushEventHandler( new GRID_TRICKS( static_cast<WX_GRID*>( m_raGrid ) ) );
|
||||
m_raGrid->ClearGrid();
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#define __DIALOG_MULTICHANNEL_REPEAT_LAYOUT__
|
||||
|
||||
#include <vector>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/bmpbndl.h>
|
||||
#include <board.h>
|
||||
#include <widgets/unit_binder.h>
|
||||
|
||||
@@ -60,9 +60,9 @@ private:
|
||||
void OnGridCellLeftClick( wxGridEvent& aEvent );
|
||||
|
||||
std::vector<TABLE_ENTRY> m_targetRAs;
|
||||
MULTICHANNEL_TOOL* m_parentTool;
|
||||
BOARD* m_board;
|
||||
wxBitmap m_detailsIcon;
|
||||
MULTICHANNEL_TOOL* m_parentTool;
|
||||
BOARD* m_board;
|
||||
wxBitmapBundle m_detailsIcon;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -445,8 +445,7 @@ private:
|
||||
// Set the color swatch
|
||||
wxBitmapBundle swatch = m_layerPresentation.CreateLayerPairIcon( layerPair.GetLayerA(), layerPair.GetLayerB() );
|
||||
|
||||
m_grid.SetCellRenderer( aRow, (int) COLNUMS::SWATCH,
|
||||
new GRID_CELL_ICON_RENDERER( swatch.GetBitmap( swatch.GetDefaultSize() ) ) );
|
||||
m_grid.SetCellRenderer( aRow, (int) COLNUMS::SWATCH, new GRID_CELL_ICON_RENDERER( swatch ) );
|
||||
|
||||
m_grid.SetReadOnly( aRow, (int) COLNUMS::SWATCH );
|
||||
m_grid.SetReadOnly( aRow, (int) COLNUMS::LAYERNAMES );
|
||||
|
||||
Reference in New Issue
Block a user