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

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

Inheritance diagram for Slic3r::GUI::GridCellChoiceEditor:
Collaboration diagram for Slic3r::GUI::GridCellChoiceEditor:

Public Member Functions

 GridCellChoiceEditor (size_t count=0, const wxString choices[]=NULL)
 GridCellChoiceEditor (const wxArrayString &choices)
virtual void Create (wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler) wxOVERRIDE
virtual void SetSize (const wxRect &rect) wxOVERRIDE
virtual wxGridCellEditor * Clone () const 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 wxGridActivationResult TryActivate (int row, int col, wxGrid *grid, const wxGridActivationSource &actSource) wxOVERRIDE
virtual void DoActivate (int row, int col, wxGrid *grid) wxOVERRIDE

Protected Member Functions

::ComboBox * Combo () const
void OnComboCloseUp (wxCommandEvent &evt)
 wxDECLARE_NO_COPY_CLASS (GridCellChoiceEditor)

Private Attributes

int m_cached_value {-1}

Detailed Description

Constructor & Destructor Documentation

◆ GridCellChoiceEditor() [1/2]

Slic3r::GUI::GridCellChoiceEditor::GridCellChoiceEditor ( size_t count = 0,
const wxString choices[] = NULL )
420 : wxGridCellChoiceEditor(count, choices)
421{}
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246

References count.

Referenced by Clone(), and wxDECLARE_NO_COPY_CLASS().

Here is the caller graph for this function:

◆ GridCellChoiceEditor() [2/2]

Slic3r::GUI::GridCellChoiceEditor::GridCellChoiceEditor ( const wxArrayString & choices)
416 : wxGridCellChoiceEditor(choices)
417{}

Member Function Documentation

◆ BeginEdit()

void Slic3r::GUI::GridCellChoiceEditor::BeginEdit ( int row,
int col,
wxGrid * grid )
virtual
455{
456 wxGridCellEditorEvtHandler *evtHandler = NULL;
457 if (m_control) {
458 // This event handler is needed to properly dismiss the editor when the popup is closed
459 m_control->Bind(wxEVT_COMBOBOX_CLOSEUP, &GridCellChoiceEditor::OnComboCloseUp, this);
460 evtHandler = static_cast<wxGridCellEditorEvtHandler*>(m_control->GetEventHandler());
461 }
462
463 // Don't immediately end if we get a kill focus event within BeginEdit
464 if (evtHandler) evtHandler->SetInSetFocus(true);
465
466 m_value = grid->GetTable()->GetValue(row, col);
467
468 // Reset(); // this updates combo box to correspond to m_value
469 int pos = Combo()->FindString(m_value);
470 if (pos == wxNOT_FOUND) pos = 0;
471 Combo()->SetSelection(pos);
472
473 Combo()->SetFocus();
474
475#ifdef __WXOSX_COCOA__
476 // This is a work around for the combobox being simply dismissed when a
477 // choice is made in it under OS X. The bug is almost certainly due to a
478 // problem in focus events generation logic but it's not obvious to fix and
479 // for now this at least allows to use wxGrid.
480 //Combo()->Popup();
481#endif
482
483 if (evtHandler)
484 {
485 // When dropping down the menu, a kill focus event
486 // happens after this point, so we can't reset the flag yet.
487#if !defined(__WXGTK20__)
488 //evtHandler->SetInSetFocus(false);
489#endif
490 }
491}
void SetSelection(int n) override
Definition ComboBox.cpp:102
::ComboBox * Combo() const
Definition GUI_ObjectTable.hpp:168
void OnComboCloseUp(wxCommandEvent &evt)
Definition GUI_ObjectTable.cpp:452
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16
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 Combo(), Slic3r::grid(), OnComboCloseUp(), and ComboBox::SetSelection().

Here is the call graph for this function:

◆ Clone()

wxGridCellEditor * Slic3r::GUI::GridCellChoiceEditor::Clone ( ) const
virtual
424{
426 editor->m_allowOthers = m_allowOthers;
427 editor->m_choices = m_choices;
428
429 return editor;
430}
GridCellChoiceEditor(size_t count=0, const wxString choices[]=NULL)
Definition GUI_ObjectTable.cpp:419

References GridCellChoiceEditor().

Here is the call graph for this function:

◆ Combo()

::ComboBox * Slic3r::GUI::GridCellChoiceEditor::Combo ( ) const
inlineprotected
168{ return (::ComboBox *) m_control; }

Referenced by BeginEdit(), and EndEdit().

Here is the caller graph for this function:

◆ Create()

void Slic3r::GUI::GridCellChoiceEditor::Create ( wxWindow * parent,
wxWindowID id,
wxEvtHandler * evtHandler )
virtual
433{
434 int style = wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxBORDER_NONE;
435
436 if (!m_allowOthers) style |= wxCB_READONLY;
437 ::ComboBox *bitmap_combo = new ComboBox(parent, id, wxEmptyString, wxDefaultPosition, wxSize(100, -1), 0, nullptr, wxCB_READONLY);
438 bitmap_combo->SetFont(::Label::Body_12);
439 int array_count = m_choices.GetCount();
440 for (int i = 0; i < array_count; i++) {
441 bitmap_combo->Append(m_choices[i]);
442 }
443 m_control = bitmap_combo;
444 wxGridCellEditor::Create(parent, id, evtHandler);
445}
#define style
Definition WipeTowerDialog.cpp:101
int Append(const wxString &item, const wxBitmap &bitmap=wxNullBitmap, int item_style=0)
Definition ComboBox.cpp:227
virtual bool SetFont(wxFont const &font) override
Definition ComboBox.cpp:219
static wxFont Body_12
Definition Label.hpp:55

References ComboBox::Append(), Label::Body_12, ComboBox::SetFont(), and style.

Here is the call graph for this function:

◆ DoActivate()

void Slic3r::GUI::GridCellChoiceEditor::DoActivate ( int row,
int col,
wxGrid * grid )
virtual
538{
539 if (m_cached_value != -1) {
540 ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
541 ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
542 ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
543 if (m_cached_value <= grid_col->choice_count) {
544 wxString choice = grid_col->choices[m_cached_value - 1];
545 table->SetValue(row, col, choice);
546 // Combo()->SetValue(choice);
547 }
548 m_cached_value = -1;
549 }
550}
int m_cached_value
Definition GUI_ObjectTable.hpp:173

References Slic3r::GUI::ObjectGridTable::ObjectGridCol::choices, Slic3r::GUI::ObjectGridTable::get_grid_col(), Slic3r::GUI::ObjectGridTable::get_grid_row(), Slic3r::grid(), m_cached_value, and Slic3r::GUI::ObjectGridTable::SetValue().

Here is the call graph for this function:

◆ EndEdit()

bool Slic3r::GUI::GridCellChoiceEditor::EndEdit ( int row,
int col,
const wxGrid * grid,
const wxString & oldval,
wxString * newval )
virtual
494{
495 const wxString value = Combo()->GetValue();
496 if (value == m_value) return false;
497
498 m_value = value;
499
500 if (newval) *newval = value;
501
502 return true;
503}
wxString GetValue() const
Definition ComboBox.cpp:140

References Combo(), ComboBox::GetValue(), and Slic3r::grid().

Here is the call graph for this function:

◆ OnComboCloseUp()

void Slic3r::GUI::GridCellChoiceEditor::OnComboCloseUp ( wxCommandEvent & evt)
protected
452{ wxGridCellChoiceEditor::OnComboCloseUp(evt); }

Referenced by BeginEdit().

Here is the caller graph for this function:

◆ SetSize()

void Slic3r::GUI::GridCellChoiceEditor::SetSize ( const wxRect & rect)
virtual
448{
449 wxGridCellChoiceEditor::SetSize(rect);
450}

◆ TryActivate()

wxGridActivationResult Slic3r::GUI::GridCellChoiceEditor::TryActivate ( int row,
int col,
wxGrid * grid,
const wxGridActivationSource & actSource )
virtual
506{
507 ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
508 ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
509 ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
510
511 if (actSource.GetOrigin() == wxGridActivationSource::Key) {
512 const wxKeyEvent &key_event = actSource.GetKeyEvent();
513 int keyCode = key_event.GetKeyCode();
514 wxString choice;
515
516 int digital_value = keyCode - '0';
517 if ((digital_value >= 1) && (digital_value <= 9))
518 m_cached_value = digital_value;
519 else
520 m_cached_value = -1;
521
522 if (m_cached_value != -1) {
523 if (m_cached_value <= grid_col->choice_count) {
524 choice = grid_col->choices[m_cached_value - 1];
525 return wxGridActivationResult::DoChange(choice);
526 } else {
527 return wxGridActivationResult::DoNothing();
528 }
529 } else
530 return wxGridActivationResult::DoNothing();
531 } else {
532 m_cached_value = -1;
533 return wxGridActivationResult::DoEdit();
534 }
535}

References Slic3r::GUI::ObjectGridTable::ObjectGridCol::choices, Slic3r::GUI::ObjectGridTable::get_grid_col(), Slic3r::GUI::ObjectGridTable::get_grid_row(), Slic3r::grid(), and m_cached_value.

Here is the call graph for this function:

◆ wxDECLARE_NO_COPY_CLASS()

Slic3r::GUI::GridCellChoiceEditor::wxDECLARE_NO_COPY_CLASS ( GridCellChoiceEditor )
protected

References GridCellChoiceEditor().

Here is the call graph for this function:

Member Data Documentation

◆ m_cached_value

int Slic3r::GUI::GridCellChoiceEditor::m_cached_value {-1}
private
173{-1};

Referenced by DoActivate(), and TryActivate().


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