52 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
54 wxString value = aGrid.GetCellValue( aRow, aCol );
60 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
63 int leftCut = aDC.FromDIP( 4 );
68 ?
m_icon.GetPreferredBitmapSizeAtScale( aDC.GetContentScaleFactor() )
74 bitmap.SetScaleFactor(
scale );
76 aDC.DrawBitmap( bitmap,
77 rect.GetLeft() + leftCut,
78 rect.GetTop() + ( rect.GetHeight() - bitmap.GetLogicalHeight() ) / 2,
81 leftCut += bitmap.GetLogicalWidth();
87 int position =
m_names.Index( value );
89 if( position < (
int)
m_icons.size() && position != wxNOT_FOUND )
93 wxBitmap bitmap = bundle.GetBitmap(
94 bundle.GetPreferredBitmapSizeAtScale( aDC.GetContentScaleFactor() ) );
96 aDC.DrawBitmap( bitmap,
97 rect.GetLeft() + leftCut,
98 rect.GetTop() + ( rect.GetHeight() - bitmap.GetLogicalHeight() ) / 2,
101 leftCut += bitmap.GetLogicalWidth();
107 wxBitmap bitmap = bundle.GetBitmap(
108 bundle.GetPreferredBitmapSizeAtScale( aDC.GetContentScaleFactor() ) );
110 leftCut += bitmap.GetLogicalWidth();
114 leftCut += aDC.FromDIP( 4 );
117 rect.width -= leftCut;
120 SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
121 aGrid.DrawTextRectangle( aDC, value, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
134 ?
m_icon.GetPreferredBitmapSizeAtScale( dc.GetContentScaleFactor() )
139 int bmpIdx = ( row < (int)
m_icons.size() && row >= 0 ) ? row : 0;
142 bitmap = bundle.GetBitmap(
143 bundle.GetPreferredBitmapSizeAtScale( dc.GetContentScaleFactor() ) );
144 bitmapSize = wxSize( bitmap.GetLogicalWidth(), -1 );
147 wxString
text =
grid.GetCellValue( row, col );
148 wxSize size = wxGridCellStringRenderer::DoGetBestSize( attr, dc,
text );
150 size.x += bitmapSize.x + dc.FromDIP( 8 );
151 size.y = std::max( size.y, bitmapSize.y + dc.FromDIP( 2 ) );
164 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
170 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
175 wxSize logicSize = aGrid.FromDIP(
m_icon.GetDefaultSize() );
176 wxSize physSize = aGrid.ToPhys( logicSize );
178 aDC.DrawBitmap(
m_icon.GetBitmap( physSize ),
179 rect.GetLeft() + ( rect.GetWidth() - logicSize.GetWidth() ) / 2,
180 rect.GetTop() + ( rect.GetHeight() - logicSize.GetHeight() ) / 2,
223 const wxRect& aRect,
int aRow,
int aCol,
230 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
235 wxSize logicSize = aGrid.FromDIP(
m_bitmap.GetDefaultSize() );
236 wxSize physSize = aGrid.ToPhys( logicSize );
238 aDC.DrawBitmap(
m_bitmap.GetBitmap( physSize ),
239 rect.GetLeft() + ( rect.GetWidth() - logicSize.GetWidth() ) / 2,
240 rect.GetTop() + ( rect.GetHeight() - logicSize.GetHeight() ) / 2,
277 wxEvtHandler* aEventHandler )
279 m_control =
new wxBitmapComboBox( aParent, aId, wxEmptyString, wxDefaultPosition,
280 wxDefaultSize, 0,
nullptr,
281 wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB |
284 for(
unsigned i = 0; i <
m_names.size(); ++i )
294 wxGridCellEditor::Create(aParent, aId, aEventHandler);
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
GRID_CELL_ICON_TEXT_RENDERER(const std::vector< BITMAPS > &icons, const wxArrayString &names)
Construct a renderer that maps a list of icons from the bitmap system to a list of strings.
std::vector< BITMAPS > m_icons
wxSize GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override