26#include <wx/artprov.h>
28#include <wx/textctrl.h>
35 const wxArrayString& names ) :
43 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
45 wxString value = aGrid.GetCellValue( aRow, aCol );
51 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
56 int position =
m_names.Index( value );
57 int leftCut = aDC.FromDIP( 4 );
59 if( position < (
int)
m_icons.size() && position != wxNOT_FOUND )
63 wxBitmap bitmap = bundle.GetBitmap(
64 bundle.GetPreferredBitmapSizeAtScale( aDC.GetContentScaleFactor() ) );
66 aDC.DrawBitmap( bitmap,
67 rect.GetLeft() + leftCut,
68 rect.GetTop() + ( rect.GetHeight() - bitmap.GetLogicalHeight() ) / 2,
71 leftCut += bitmap.GetLogicalWidth();
77 wxBitmap bitmap = bundle.GetBitmap(
78 bundle.GetPreferredBitmapSizeAtScale( aDC.GetContentScaleFactor() ) );
80 leftCut += bitmap.GetLogicalWidth();
83 leftCut += aDC.FromDIP( 4 );
86 rect.width -= leftCut;
89 SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
90 aGrid.DrawTextRectangle( aDC, value, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
96 int bmpIdx = ( row < (int)
m_icons.size() && row >= 0 ) ? row : 0;
100 bundle.GetBitmap( bundle.GetPreferredBitmapSizeAtScale( dc.GetContentScaleFactor() ) );
102 wxString
text =
grid.GetCellValue( row, col );
103 wxSize size = wxGridCellStringRenderer::DoGetBestSize( attr, dc,
text );
105 size.x += bitmap.GetLogicalWidth() + dc.FromDIP( 8 );
118 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
124 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
130 rect.GetLeft() + ( rect.GetWidth() -
m_icon.GetWidth() ) / 2,
131 rect.GetTop() + ( rect.GetHeight() -
m_icon.GetHeight() ) / 2,
140 return wxSize(
m_icon.GetWidth() + 6,
m_icon.GetHeight() + 4 );
159 m_bitmap = wxArtProvider::GetBitmap( wxArtProvider::GetMessageBoxIconId(
m_status ),
165 m_bitmap = wxArtProvider::GetBitmap( wxArtProvider::GetMessageBoxIconId( wxICON_INFORMATION ),
172 const wxRect& aRect,
int aRow,
int aCol,
179 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
185 rect.GetLeft() + ( rect.GetWidth() -
m_bitmap.GetWidth() ) / 2,
186 rect.GetTop() + ( rect.GetHeight() -
m_bitmap.GetHeight() ) / 2,
206 const wxArrayString& names ) :
220 wxEvtHandler* aEventHandler )
222 m_control =
new wxBitmapComboBox( aParent, aId, wxEmptyString, wxDefaultPosition,
223 wxDefaultSize, 0,
nullptr,
224 wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxBORDER_NONE );
226 for(
unsigned i = 0; i <
m_names.size(); ++i )
230 if( i <
m_icons.size() &&
m_icons[ i ] != BITMAPS::INVALID_BITMAP )
236 wxGridCellEditor::Create(aParent, aId, aEventHandler);
242 return Combo()->GetValue();
248 wxRect rect( aRect );
251#if !defined( __WXMSW__ ) && !defined( __WXGTK__ )
253 Combo()->SetButtonPosition( 0, 0, wxRIGHT, 2 );
256#if defined( __WXMAC__ )
260 Combo()->SetSize( rect, wxSIZE_ALLOW_MINUS_ONE );
266 auto evtHandler =
static_cast<wxGridCellEditorEvtHandler*
>( m_control->GetEventHandler() );
269 evtHandler->SetInSetFocus(
true );
271 m_value = aGrid->GetTable()->GetValue( aRow, aCol );
276#ifdef __WXOSX_COCOA__
286#if !defined(__WXGTK__)
287 evtHandler->SetInSetFocus(
false );
295 const wxString value =
Combo()->GetValue();
311 aGrid->GetTable()->SetValue( aRow, aCol,
m_value );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
wxGridCellRenderer * Clone() const override
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
GRID_CELL_ICON_RENDERER(const wxBitmap &icon)
wxSize GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
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)
std::vector< BITMAPS > m_icons
wxSize GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
wxSize GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
wxGridCellRenderer * Clone() const override
GRID_CELL_STATUS_ICON_RENDERER(int aStatus)
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override