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 );
52 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
57 int position =
m_names.Index( value );
59 if( position < (
int)
m_icons.size() && position != wxNOT_FOUND )
62 aDC.DrawBitmap( bitmap, rect.GetLeft() + 3, rect.GetTop() + 2,
true );
70 rect.SetLeft( rect.GetLeft() + bitmap.GetWidth() + 7 );
71 SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
72 aGrid.DrawTextRectangle( aDC, value, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
79 wxString
text =
grid.GetCellValue( row, col );
80 wxSize size = wxGridCellStringRenderer::DoGetBestSize( attr, dc,
text );
82 size.x += bitmap.GetWidth() + 6;
95 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
101 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
107 rect.GetLeft() + ( rect.GetWidth() -
m_icon.GetWidth() ) / 2,
108 rect.GetTop() + ( rect.GetHeight() -
m_icon.GetHeight() ) / 2,
117 return wxSize(
m_icon.GetWidth() + 6,
m_icon.GetHeight() + 4 );
136 m_bitmap = wxArtProvider::GetBitmap( wxArtProvider::GetMessageBoxIconId(
m_status ),
142 m_bitmap = wxArtProvider::GetBitmap( wxArtProvider::GetMessageBoxIconId( wxICON_INFORMATION ),
149 const wxRect& aRect,
int aRow,
int aCol,
156 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
162 rect.GetLeft() + ( rect.GetWidth() -
m_bitmap.GetWidth() ) / 2,
163 rect.GetTop() + ( rect.GetHeight() -
m_bitmap.GetHeight() ) / 2,
183 const wxArrayString& names ) :
197 wxEvtHandler* aEventHandler )
199 m_control =
new wxBitmapComboBox( aParent, aId, wxEmptyString, wxDefaultPosition,
200 wxDefaultSize, 0,
nullptr,
201 wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxBORDER_NONE );
203 for(
unsigned i = 0; i <
m_names.size(); ++i )
207 if( i <
m_icons.size() &&
m_icons[ i ] != BITMAPS::INVALID_BITMAP )
213 wxGridCellEditor::Create(aParent, aId, aEventHandler);
219 return Combo()->GetValue();
225 wxRect rect( aRect );
228#if !defined( __WXMSW__ ) && !defined( __WXGTK__ )
230 Combo()->SetButtonPosition( 0, 0, wxRIGHT, 2 );
233#if defined( __WXMAC__ )
237 Combo()->SetSize( rect, wxSIZE_ALLOW_MINUS_ONE );
243 auto evtHandler =
static_cast<wxGridCellEditorEvtHandler*
>( m_control->GetEventHandler() );
246 evtHandler->SetInSetFocus(
true );
248 m_value = aGrid->GetTable()->GetValue( aRow, aCol );
253#ifdef __WXOSX_COCOA__
263#if !defined(__WXGTK__)
264 evtHandler->SetInSetFocus(
false );
272 const wxString value =
Combo()->GetValue();
288 aGrid->GetTable()->SetValue( aRow, aCol,
m_value );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
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