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 123 of file grid_color_swatch_helpers.cpp.

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

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 180 of file grid_color_swatch_helpers.cpp.

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

References GetValue().

◆ BeginEdit()

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

Definition at line 153 of file grid_color_swatch_helpers.cpp.

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

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

◆ Clone()

wxGridCellEditor * GRID_CELL_COLOR_SELECTOR::Clone ( ) const
override

Definition at line 131 of file grid_color_swatch_helpers.cpp.

132 {
134 }
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 137 of file grid_color_swatch_helpers.cpp.

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

◆ EndEdit()

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

Definition at line 170 of file grid_color_swatch_helpers.cpp.

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

References GetValue().

◆ GetValue()

wxString GRID_CELL_COLOR_SELECTOR::GetValue ( ) const
override

Definition at line 147 of file grid_color_swatch_helpers.cpp.

148 {
149  return m_value.ToWxString( wxC2S_CSS_SYNTAX );
150 }

References m_value.

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

◆ Reset()

void GRID_CELL_COLOR_SELECTOR::Reset ( )
override

Definition at line 186 of file grid_color_swatch_helpers.cpp.

187 {
188 }

◆ 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: