OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GridCellTextEditor Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GUI_ObjectTable.hpp>

Inheritance diagram for Slic3r::GUI::GridCellTextEditor:
Collaboration diagram for Slic3r::GUI::GridCellTextEditor:

Public Member Functions

 GridCellTextEditor ()
 ~GridCellTextEditor ()
virtual void Create (wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler) wxOVERRIDE
void StartingKey (wxKeyEvent &event) wxOVERRIDE
virtual void SetSize (const wxRect &rect) wxOVERRIDE
virtual void BeginEdit (int row, int col, wxGrid *grid) wxOVERRIDE
virtual bool EndEdit (int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval) wxOVERRIDE
virtual void ApplyEdit (int row, int col, wxGrid *grid) wxOVERRIDE

Protected Member Functions

::TextInput * Text () const
 wxDECLARE_NO_COPY_CLASS (GridCellTextEditor)

Private Attributes

wxString m_value

Detailed Description

Constructor & Destructor Documentation

◆ GridCellTextEditor()

Slic3r::GUI::GridCellTextEditor::GridCellTextEditor ( )
3528: wxGridCellTextEditor() {}

Referenced by wxDECLARE_NO_COPY_CLASS().

Here is the caller graph for this function:

◆ ~GridCellTextEditor()

Slic3r::GUI::GridCellTextEditor::~GridCellTextEditor ( )
3530{}

Member Function Documentation

◆ ApplyEdit()

void Slic3r::GUI::GridCellTextEditor::ApplyEdit ( int row,
int col,
wxGrid * grid )
virtual
3597{
3598 grid->GetTable()->SetValue(row, col, m_value);
3599 m_value.clear();
3600}
wxString m_value
Definition GUI_ObjectTable.hpp:89
std::vector< ArithmeticOnly< T > > grid(const T &start, const T &stop, const T &stride)
A set of equidistant values starting from 'start' (inclusive), ending in the closest multiple of 'str...
Definition MTUtils.hpp:127

References Slic3r::grid(), and m_value.

Here is the call graph for this function:

◆ BeginEdit()

void Slic3r::GUI::GridCellTextEditor::BeginEdit ( int row,
int col,
wxGrid * grid )
virtual
3544{
3545 ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
3546 ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
3547 ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
3548
3549 auto val = table->GetValue(row, col);
3550
3551 ObjectGrid* ogrid = dynamic_cast<ObjectGrid*>(grid);
3552
3553
3554 if (!ogrid->input_string.empty()) {
3555 Text()->GetTextCtrl()->SetValue(ogrid->input_string);
3556 }
3557 else {
3558 Text()->GetTextCtrl()->SetValue(val);
3559 }
3560 Text()->SetFocus();
3561 Text()->GetTextCtrl()->SetInsertionPointEnd();
3562
3563
3564 m_control->Bind(wxEVT_TEXT_ENTER, [grid](wxCommandEvent &e) {
3565 grid->HideCellEditControl();
3566 grid->SaveEditControlValue();
3567 e.Skip();
3568 });
3569
3570 m_control->Bind(wxEVT_CHAR_HOOK, [grid](wxKeyEvent &e) {
3571 if (e.GetKeyCode() == WXK_ESCAPE) {
3572 grid->HideCellEditControl();
3573 grid->SaveEditControlValue();
3574 }
3575 e.Skip();
3576 });
3577}
::TextInput * Text() const
Definition GUI_ObjectTable.hpp:85
wxTextCtrl * GetTextCtrl()
Definition TextInput.hpp:76

References Slic3r::GUI::ObjectGridTable::get_grid_col(), Slic3r::GUI::ObjectGridTable::get_grid_row(), TextInput::GetTextCtrl(), Slic3r::GUI::ObjectGridTable::GetValue(), Slic3r::grid(), Slic3r::GUI::ObjectGrid::input_string, and Text().

Here is the call graph for this function:

◆ Create()

void Slic3r::GUI::GridCellTextEditor::Create ( wxWindow * parent,
wxWindowID id,
wxEvtHandler * evtHandler )
virtual
3533{
3534 ::TextInput *text_input = new ::TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxSize(-1, -1), wxTE_PROCESS_ENTER);
3535 m_control = text_input;
3536 wxGridCellEditor::Create(parent, id, evtHandler);
3537}

◆ EndEdit()

bool Slic3r::GUI::GridCellTextEditor::EndEdit ( int row,
int col,
const wxGrid * grid,
const wxString & oldval,
wxString * newval )
virtual
3580{
3581 ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
3582 ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
3583 ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
3584
3585 wxCHECK_MSG(m_control, false, "wxGridCellTextEditor must be created first!");
3586
3587 const wxString value = Text()->GetTextCtrl()->GetValue();
3588 if (value == m_value) return false;
3589
3590 m_value = value;
3591
3592 if (newval) *newval = m_value;
3593 return true;
3594}

References Slic3r::GUI::ObjectGridTable::get_grid_col(), Slic3r::GUI::ObjectGridTable::get_grid_row(), TextInput::GetTextCtrl(), Slic3r::grid(), m_value, and Text().

Here is the call graph for this function:

◆ SetSize()

void Slic3r::GUI::GridCellTextEditor::SetSize ( const wxRect & rect)
virtual
3541{ wxGridCellTextEditor::SetSize(rect); }

◆ StartingKey()

void Slic3r::GUI::GridCellTextEditor::StartingKey ( wxKeyEvent & event)
3539{}

◆ Text()

::TextInput * Slic3r::GUI::GridCellTextEditor::Text ( ) const
inlineprotected
85{ return (::TextInput *) m_control; }

Referenced by BeginEdit(), and EndEdit().

Here is the caller graph for this function:

◆ wxDECLARE_NO_COPY_CLASS()

Slic3r::GUI::GridCellTextEditor::wxDECLARE_NO_COPY_CLASS ( GridCellTextEditor )
protected

References GridCellTextEditor().

Here is the call graph for this function:

Member Data Documentation

◆ m_value

wxString Slic3r::GUI::GridCellTextEditor::m_value
private

Referenced by ApplyEdit(), and EndEdit().


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