22#include <wx/artprov.h>
24#include <wx/textctrl.h>
32 const wxArrayString& names ) :
40 wxSize aPreferredIconSize ) :
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,
185 wxSize size =
m_icon.GetDefaultSize();
188 return grid.FromDIP( size );
207 m_bitmap = wxArtProvider::GetBitmapBundle( wxArtProvider::GetMessageBoxIconId(
m_status ), wxART_BUTTON );
212 m_bitmap = wxArtProvider::GetBitmapBundle( wxArtProvider::GetMessageBoxIconId( wxICON_INFORMATION ),
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,
245 wxSize size =
m_bitmap.GetDefaultSize();
248 return grid.FromDIP( size );
259 const wxArrayString& names ) :
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#if defined( __WXMAC__ )
292 Combo()->Bind( wxEVT_COMBOBOX_CLOSEUP,
293 [
this]( wxCommandEvent& aEvent )
295 wxEvtHandler* handler = m_control->GetEventHandler();
298 if( handler != m_control )
299 static_cast<wxGridCellEditorEvtHandler*
>( handler )->SetInSetFocus(
false );
305 wxGridCellEditor::Create(aParent, aId, aEventHandler);
311 return Combo()->GetValue();
317 wxRect
rect( aRect );
320#if !defined( __WXMSW__ ) && !defined( __WXGTK__ )
322 Combo()->SetButtonPosition( 0, 0, wxRIGHT, 2 );
325#if defined( __WXMAC__ )
329 Combo()->SetSize(
rect, wxSIZE_ALLOW_MINUS_ONE );
335 auto evtHandler =
static_cast<wxGridCellEditorEvtHandler*
>( m_control->GetEventHandler() );
338 evtHandler->SetInSetFocus(
true );
340 m_value = aGrid->GetTable()->GetValue( aRow, aCol );
345#ifdef __WXOSX_COCOA__
355#if !defined( __WXGTK__ ) && !defined( __WXMAC__ )
356 evtHandler->SetInSetFocus(
false );
364 const wxString value =
Combo()->GetValue();
380 aGrid->GetTable()->SetValue( aRow, aCol,
m_value );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
wxGridCellRenderer * Clone() const override
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
wxSize GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
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
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
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
DATABASE_CONNECTION dc(odbcBackend(cs))
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)