48 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
50 wxString value = aGrid.GetCellValue( aRow, aCol );
56 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
59 int leftCut = aDC.FromDIP( 4 );
64 ?
m_icon.GetPreferredBitmapSizeAtScale( aDC.GetContentScaleFactor() )
70 bitmap.SetScaleFactor(
scale );
72 aDC.DrawBitmap( bitmap,
73 rect.GetLeft() + leftCut,
74 rect.GetTop() + ( rect.GetHeight() - bitmap.GetLogicalHeight() ) / 2,
77 leftCut += bitmap.GetLogicalWidth();
83 int position =
m_names.Index( value );
85 if( position < (
int)
m_icons.size() && position != wxNOT_FOUND )
89 wxBitmap bitmap = bundle.GetBitmap(
90 bundle.GetPreferredBitmapSizeAtScale( aDC.GetContentScaleFactor() ) );
92 aDC.DrawBitmap( bitmap,
93 rect.GetLeft() + leftCut,
94 rect.GetTop() + ( rect.GetHeight() - bitmap.GetLogicalHeight() ) / 2,
97 leftCut += bitmap.GetLogicalWidth();
103 wxBitmap bitmap = bundle.GetBitmap(
104 bundle.GetPreferredBitmapSizeAtScale( aDC.GetContentScaleFactor() ) );
106 leftCut += bitmap.GetLogicalWidth();
110 leftCut += aDC.FromDIP( 4 );
113 rect.width -= leftCut;
116 SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
117 aGrid.DrawTextRectangle( aDC, value, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
130 ?
m_icon.GetPreferredBitmapSizeAtScale( dc.GetContentScaleFactor() )
135 int bmpIdx = ( row < (int)
m_icons.size() && row >= 0 ) ? row : 0;
138 bitmap = bundle.GetBitmap(
139 bundle.GetPreferredBitmapSizeAtScale( dc.GetContentScaleFactor() ) );
140 bitmapSize = wxSize( bitmap.GetLogicalWidth(), -1 );
143 wxString
text =
grid.GetCellValue( row, col );
144 wxSize size = wxGridCellStringRenderer::DoGetBestSize( attr, dc,
text );
146 size.x += bitmapSize.x + dc.FromDIP( 8 );
147 size.y = std::max( size.y, bitmapSize.y + dc.FromDIP( 2 ) );
160 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
166 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
171 wxSize logicSize = aGrid.FromDIP(
m_icon.GetDefaultSize() );
172 wxSize physSize = aGrid.ToPhys( logicSize );
174 aDC.DrawBitmap(
m_icon.GetBitmap( physSize ),
175 rect.GetLeft() + ( rect.GetWidth() - logicSize.GetWidth() ) / 2,
176 rect.GetTop() + ( rect.GetHeight() - logicSize.GetHeight() ) / 2,
219 const wxRect& aRect,
int aRow,
int aCol,
226 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
231 wxSize logicSize = aGrid.FromDIP(
m_bitmap.GetDefaultSize() );
232 wxSize physSize = aGrid.ToPhys( logicSize );
234 aDC.DrawBitmap(
m_bitmap.GetBitmap( physSize ),
235 rect.GetLeft() + ( rect.GetWidth() - logicSize.GetWidth() ) / 2,
236 rect.GetTop() + ( rect.GetHeight() - logicSize.GetHeight() ) / 2,
273 wxEvtHandler* aEventHandler )
275 m_control =
new wxBitmapComboBox( aParent, aId, wxEmptyString, wxDefaultPosition,
276 wxDefaultSize, 0,
nullptr,
277 wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB |
280 for(
unsigned i = 0; i <
m_names.size(); ++i )
290 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