KiCad PCB EDA Suite
GRID_CELL_COLOR_SELECTOR Class Reference

#include <grid_color_swatch_helpers.h>

Inheritance diagram for GRID_CELL_COLOR_SELECTOR:

Public Member Functions

 GRID_CELL_COLOR_SELECTOR (wxWindow *aParent, wxGrid *aGrid)
 
wxGridCellEditor * Clone () const override
 
void Create (wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
 
wxString GetValue () const override
 
void BeginEdit (int aRow, int aCol, wxGrid *aGrid) override
 
bool EndEdit (int, int, const wxGrid *, const wxString &, wxString *newval) override
 
void ApplyEdit (int aRow, int aCol, wxGrid *aGrid) override
 
void Reset () override
 

Protected Member Functions

 wxDECLARE_NO_COPY_CLASS (GRID_CELL_COLOR_SELECTOR)
 

Protected Attributes

wxWindow * m_parent
 
wxGrid * m_grid
 
KIGFX::COLOR4D m_value
 

Detailed Description

Definition at line 68 of file grid_color_swatch_helpers.h.

Constructor & Destructor Documentation

◆ GRID_CELL_COLOR_SELECTOR()

GRID_CELL_COLOR_SELECTOR::GRID_CELL_COLOR_SELECTOR ( wxWindow *  aParent,
wxGrid *  aGrid 
)

Definition at line 121 of file grid_color_swatch_helpers.cpp.

121  :
122  m_parent( aParent ),
123  m_grid( aGrid ),
124  m_value( COLOR4D::UNSPECIFIED )
125 {
126 }

References UNSPECIFIED.

Referenced by Clone().

Member Function Documentation

◆ ApplyEdit()

void GRID_CELL_COLOR_SELECTOR::ApplyEdit ( int  aRow,
int  aCol,
wxGrid *  aGrid 
)
override

Definition at line 178 of file grid_color_swatch_helpers.cpp.

179 {
180  aGrid->GetTable()->SetValue( aRow, aCol, GetValue() );
181 }
wxString GetValue() const override

References GetValue().

◆ BeginEdit()

void GRID_CELL_COLOR_SELECTOR::BeginEdit ( int  aRow,
int  aCol,
wxGrid *  aGrid 
)
override

Definition at line 151 of file grid_color_swatch_helpers.cpp.

152 {
153  m_value.SetFromWxString( grid->GetTable()->GetValue( row, col ) );
154 
155  DIALOG_COLOR_PICKER dialog( m_parent, m_value, false );
156 
157  if( dialog.ShowModal() == wxID_OK )
158  m_value = dialog.GetColor();
159 
160  m_grid->GetTable()->SetValue( row, col, GetValue() );
161 
162  // That's it; we're all done
163  m_grid->HideCellEditControl();
164  m_grid->ForceRefresh();
165 }
wxString GetValue() const override

References DIALOG_COLOR_PICKER::GetColor(), GetValue(), m_grid, m_parent, and m_value.

◆ Clone()

wxGridCellEditor * GRID_CELL_COLOR_SELECTOR::Clone ( ) const
override

Definition at line 129 of file grid_color_swatch_helpers.cpp.

130 {
132 }
GRID_CELL_COLOR_SELECTOR(wxWindow *aParent, wxGrid *aGrid)

References GRID_CELL_COLOR_SELECTOR(), m_grid, and m_parent.

◆ Create()

void GRID_CELL_COLOR_SELECTOR::Create ( wxWindow *  aParent,
wxWindowID  aId,
wxEvtHandler *  aEventHandler 
)
override

Definition at line 135 of file grid_color_swatch_helpers.cpp.

137 {
138  // wxWidgets needs a control to hold on to the event handler
139  m_control = new wxCheckBox( aParent, wxID_ANY, wxEmptyString );
140 
141  wxGridCellEditor::Create( aParent, aId, aEventHandler );
142 }

◆ EndEdit()

bool GRID_CELL_COLOR_SELECTOR::EndEdit ( int  row,
int  col,
const wxGrid *  grid,
const wxString &  oldval,
wxString *  newval 
)
override

Definition at line 168 of file grid_color_swatch_helpers.cpp.

170 {
171  if ( newval )
172  *newval = GetValue();
173 
174  return true;
175 }
wxString GetValue() const override

References GetValue().

◆ GetValue()

wxString GRID_CELL_COLOR_SELECTOR::GetValue ( ) const
override

Definition at line 145 of file grid_color_swatch_helpers.cpp.

146 {
147  return m_value.ToWxString( wxC2S_CSS_SYNTAX );
148 }

References m_value.

Referenced by ApplyEdit(), BeginEdit(), and EndEdit().

◆ Reset()

void GRID_CELL_COLOR_SELECTOR::Reset ( )
override

Definition at line 184 of file grid_color_swatch_helpers.cpp.

185 {
186 }

◆ wxDECLARE_NO_COPY_CLASS()

GRID_CELL_COLOR_SELECTOR::wxDECLARE_NO_COPY_CLASS ( GRID_CELL_COLOR_SELECTOR  )
protected

Member Data Documentation

◆ m_grid

wxGrid* GRID_CELL_COLOR_SELECTOR::m_grid
protected

Definition at line 85 of file grid_color_swatch_helpers.h.

Referenced by BeginEdit(), and Clone().

◆ m_parent

wxWindow* GRID_CELL_COLOR_SELECTOR::m_parent
protected

Definition at line 84 of file grid_color_swatch_helpers.h.

Referenced by BeginEdit(), and Clone().

◆ m_value

KIGFX::COLOR4D GRID_CELL_COLOR_SELECTOR::m_value
protected

Definition at line 86 of file grid_color_swatch_helpers.h.

Referenced by BeginEdit(), and GetValue().


The documentation for this class was generated from the following files: