28#include <wx/checkbox.h>
39 m_background( aBackground )
78 if(
m_size != wxDefaultSize )
83 dc.SetFont( attr.GetFont() );
84 dc.GetTextExtent(
"WWW", &bestSize.x, &bestSize.y );
91 const wxRect& aRect,
int aRow,
int aCol,
bool isSelected )
96 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
99 COLOR4D color( aGrid.GetTable()->GetValue( aRow, aCol ) );
100 wxSize size = (
m_size == wxDefaultSize ) ? aRect.GetSize() :
m_size;
104 wxPoint origin = rect.GetTopLeft();
106 if(
m_size != wxDefaultSize )
108 int x = std::max( 0, ( aRect.GetWidth() -
m_size.x ) / 2 );
109 int y = std::max( 0, ( aRect.GetHeight() -
m_size.y ) / 2 );
110 origin += wxPoint( x, y );
113 aDC.DrawBitmap( bitmap, origin,
true );
143 wxEvtHandler* aEventHandler )
146 m_control =
new wxTextCtrl( aParent, wxID_ANY, wxEmptyString );
148 wxGridCellEditor::Create( aParent, aId, aEventHandler );
174 wxGridEvent event(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, row, col );
176 m_grid->GetEventHandler()->ProcessEvent( event );
180 m_grid->HideCellEditControl();
185 const wxString& oldval, wxString *newval )
196 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)
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.
bool SetFromWxString(const wxString &aColorString)
Set color values by parsing a string using wxColour::Set().
wxString ToCSSString() const
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)