24#include <wx/checkbox.h>
74 if(
m_size != wxDefaultSize )
79 dc.SetFont( attr.GetFont() );
80 dc.GetTextExtent(
"WWW", &bestSize.x, &bestSize.y );
87 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
92 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
95 COLOR4D color( aGrid.GetTable()->GetValue( aRow, aCol ) );
96 wxSize size = (
m_size == wxDefaultSize ) ? aRect.GetSize() :
m_size;
100 wxPoint origin = rect.GetTopLeft();
102 if(
m_size != wxDefaultSize )
104 int x = std::max( 0, ( aRect.GetWidth() -
m_size.x ) / 2 );
105 int y = std::max( 0, ( aRect.GetHeight() -
m_size.y ) / 2 );
106 origin += wxPoint( x, y );
109 aDC.DrawBitmap( bitmap, origin,
true );
139 wxEvtHandler* aEventHandler )
142 m_control =
new wxTextCtrl( aParent, wxID_ANY, wxEmptyString );
144 wxGridCellEditor::Create( aParent, aId, aEventHandler );
156 m_value.SetFromWxString(
grid->GetTable()->GetValue( row, col ) );
170 wxGridEvent event(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, row, col );
172 m_grid->GetEventHandler()->ProcessEvent( event );
176 m_grid->HideCellEditControl();
181 const wxString& oldval, wxString *newval )
192 aGrid->GetTable()->SetValue( aRow, aCol,
GetValue() );
static wxBitmap MakeBitmap(const KIGFX::COLOR4D &aColor, const KIGFX::COLOR4D &aBackground, const wxSize &aSize, const wxSize &aCheckerboardSize, const KIGFX::COLOR4D &aCheckerboardBackground, const std::vector< int > &aMargins={ 0, 0, 0, 0 })
KIGFX::COLOR4D GetColor()
~GRID_CELL_COLOR_RENDERER() override
wxSize m_checkerboardSize
KIGFX::COLOR4D m_background
GRID_CELL_COLOR_RENDERER(wxWindow *aParent=nullptr, SWATCH_SIZE aSize=SWATCH_EXPAND, const KIGFX::COLOR4D &aBackground=KIGFX::COLOR4D::UNSPECIFIED)
wxSize GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
KIGFX::COLOR4D m_checkerboardBg
wxGridCellRenderer * Clone() const override
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
GRID_CELL_COLOR_SELECTOR(wxWindow *aParent, wxGrid *aGrid)
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
bool EndEdit(int, int, const wxGrid *, const wxString &, wxString *newval) override
wxGridCellEditor * Clone() const override
wxString GetValue() const override
A color representation with 4 components: red, green, blue, alpha.
static const wxSize SWATCH_SIZE_LARGE_DU(24, 16)
static const wxSize SWATCH_SIZE_MEDIUM_DU(24, 10)
static const wxSize CHECKERBOARD_SIZE_DU(3, 3)
static const wxSize SWATCH_SIZE_SMALL_DU(8, 6)