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

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

Inheritance diagram for Slic3r::GUI::GridCellFilamentsEditor:
Collaboration diagram for Slic3r::GUI::GridCellFilamentsEditor:

Public Member Functions

 GridCellFilamentsEditor (size_t count=0, const wxString choices[]=NULL, bool allowOthers=false, std::vector< wxBitmap * > *bitmaps=NULL)
 GridCellFilamentsEditor (const wxArrayString &choices, bool allowOthers=false, std::vector< wxBitmap * > *bitmaps=NULL)
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 (GridCellFilamentsEditor)

Protected Attributes

std::vector< wxBitmap * > * m_icons

Private Attributes

int m_cached_value {-1}

Detailed Description

Constructor & Destructor Documentation

◆ GridCellFilamentsEditor() [1/2]

Slic3r::GUI::GridCellFilamentsEditor::GridCellFilamentsEditor ( size_t count = 0,
const wxString choices[] = NULL,
bool allowOthers = false,
std::vector< wxBitmap * > * bitmaps = NULL )
171 : wxGridCellChoiceEditor(count, choices, allowOthers), m_icons(bitmaps)
172{
173}
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246
std::vector< wxBitmap * > * m_icons
Definition GUI_ObjectTable.hpp:122

References count, and m_icons.

Referenced by Clone(), and wxDECLARE_NO_COPY_CLASS().

Here is the caller graph for this function:

◆ GridCellFilamentsEditor() [2/2]

Slic3r::GUI::GridCellFilamentsEditor::GridCellFilamentsEditor ( const wxArrayString & choices,
bool allowOthers = false,
std::vector< wxBitmap * > * bitmaps = NULL )
163 : wxGridCellChoiceEditor(choices, allowOthers), m_icons(bitmaps)
164{
165}

References m_icons.

Member Function Documentation

◆ BeginEdit()

void Slic3r::GUI::GridCellFilamentsEditor::BeginEdit ( int row,
int col,
wxGrid * grid )
virtual
242{
243 wxGridCellEditorEvtHandler* evtHandler = NULL;
244 if (m_control)
245 {
246 // This event handler is needed to properly dismiss the editor when the popup is closed
247 m_control->Bind(wxEVT_COMBOBOX_CLOSEUP, &GridCellFilamentsEditor::OnComboCloseUp, this);
248 evtHandler = static_cast<wxGridCellEditorEvtHandler*>(m_control->GetEventHandler());
249 }
250
251 // Don't immediately end if we get a kill focus event within BeginEdit
252 if (evtHandler)
253 evtHandler->SetInSetFocus(true);
254
255 //m_value = grid->GetTable()->GetValue(row, col);
256 ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
257 ObjectGridTable::ObjectGridCol* grid_col = table->get_grid_col(col);
258 ObjectGridTable::ObjectGridRow* grid_row = table->get_grid_row(row - 1);
259 ConfigOption& option = (*grid_row)[(ObjectGridTable::GridColType)col];
260 ConfigOptionInt& option_value = dynamic_cast<ConfigOptionInt&>(option);
261 if ((option_value.value - 1) < grid_col->choice_count) {
262 //return grid_col->choices[(option_value.value > 0)?option_value.value - 1: 0];
263 int index = (option_value.value > 0) ? option_value.value - 1 : 0;
264 m_value = grid_col->choices[index];
265 //return grid_col->choices[index];
266 }
267 //m_value = grid->GetTable()->GetValue(row, col);
268
269 //Reset(); // this updates combo box to correspond to m_value
270 int pos = Combo()->FindString(m_value);
271 if (pos == wxNOT_FOUND) pos = 0;
272 Combo()->SetSelection(pos);
273
274 Combo()->SetFocus();
275
276#ifdef __WXOSX_COCOA__
277 // This is a work around for the combobox being simply dismissed when a
278 // choice is made in it under OS X. The bug is almost certainly due to a
279 // problem in focus events generation logic but it's not obvious to fix and
280 // for now this at least allows to use wxGrid.
281 //Combo()->Popup();
282#endif
283
284 if (evtHandler)
285 {
286 // When dropping down the menu, a kill focus event
287 // happens after this point, so we can't reset the flag yet.
288#if !defined(__WXGTK20__)
289 //evtHandler->SetInSetFocus(false);
290#endif
291 }
292}
void SetSelection(int n) override
Definition ComboBox.cpp:102
void OnComboCloseUp(wxCommandEvent &evt)
Definition GUI_ObjectTable.cpp:236
::ComboBox * Combo() const
Definition GUI_ObjectTable.hpp:119
GridColType
Definition GUI_ObjectTable.hpp:294
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 Slic3r::GUI::ObjectGridTable::ObjectGridCol::choice_count, Slic3r::GUI::ObjectGridTable::ObjectGridCol::choices, Combo(), Slic3r::GUI::ObjectGridTable::get_grid_col(), Slic3r::GUI::ObjectGridTable::get_grid_row(), Slic3r::grid(), OnComboCloseUp(), and ComboBox::SetSelection().

Here is the call graph for this function:

◆ Clone()

wxGridCellEditor * Slic3r::GUI::GridCellFilamentsEditor::Clone ( ) const
virtual
176{
178 editor->m_allowOthers = m_allowOthers;
179 editor->m_choices = m_choices;
180 editor->m_icons = m_icons;
181
182 return editor;
183}
GridCellFilamentsEditor(size_t count=0, const wxString choices[]=NULL, bool allowOthers=false, std::vector< wxBitmap * > *bitmaps=NULL)
Definition GUI_ObjectTable.cpp:167

References GridCellFilamentsEditor(), and m_icons.

Here is the call graph for this function:

◆ Combo()

::ComboBox * Slic3r::GUI::GridCellFilamentsEditor::Combo ( ) const
inlineprotected
119{ return (::ComboBox *)m_control; }

Referenced by BeginEdit(), and EndEdit().

Here is the caller graph for this function:

◆ Create()

void Slic3r::GUI::GridCellFilamentsEditor::Create ( wxWindow * parent,
wxWindowID id,
wxEvtHandler * evtHandler )
virtual
188{
189 int style = wxTE_PROCESS_ENTER |
190 wxTE_PROCESS_TAB |
191 wxBORDER_NONE;
192
193 if ( !m_allowOthers )
194 style |= wxCB_READONLY;
195 ::ComboBox *bitmap_combo = new ComboBox(parent, id, wxEmptyString,
196 wxDefaultPosition, wxSize(((*m_icons)[0])->GetWidth() + 10, -1), 0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY);
197 if (m_icons) {
198 int array_count = m_choices.GetCount();
199 int icon_count = m_icons->size();
200 for (int i = 0; i < array_count; i++)
201 {
202 wxBitmap* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
203 bitmap_combo->Append(m_choices[i], *bitmap);
204 }
205 }
206 m_control = bitmap_combo;
207 wxGridCellEditor::Create(parent, id, evtHandler);
208
209 /* bitmap_combo->GetDropDown().Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& e) {
210 const wxString value = Combo()->GetValue();
211 if (value == m_value)
212 return false;
213
214 m_value = value;
215 return true;
216 e.Skip();
217 });*/
218}
#define CB_NO_TEXT
Definition ComboBox.hpp:18
#define CB_NO_DROP_ICON
Definition ComboBox.hpp:17
#define style
Definition WipeTowerDialog.cpp:101
int Append(const wxString &item, const wxBitmap &bitmap=wxNullBitmap, int item_style=0)
Definition ComboBox.cpp:227

References ComboBox::Append(), CB_NO_DROP_ICON, CB_NO_TEXT, m_icons, and style.

Here is the call graph for this function:

◆ DoActivate()

void Slic3r::GUI::GridCellFilamentsEditor::DoActivate ( int row,
int col,
wxGrid * grid )
virtual
348{
349 if (m_cached_value != -1) {
350 ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
351 ObjectGridTable::ObjectGridCol* grid_col = table->get_grid_col(col);
352 ObjectGridTable::ObjectGridRow* grid_row = table->get_grid_row(row - 1);
353 if (m_cached_value <= grid_col->choice_count) {
354 wxString choice = grid_col->choices[m_cached_value-1];
355 table->SetValue(row, col, choice);
356 //Combo()->SetValue(choice);
357 }
358 m_cached_value = -1;
359 }
360}
int m_cached_value
Definition GUI_ObjectTable.hpp:126

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::GridCellFilamentsEditor::EndEdit ( int row,
int col,
const wxGrid * grid,
const wxString & oldval,
wxString * newval )
virtual
299{
300 const wxString value = Combo()->GetValue();
301 if ( value == m_value )
302 return false;
303
304 m_value = value;
305
306 if ( newval )
307 *newval = value;
308
309 return true;
310}
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::GridCellFilamentsEditor::OnComboCloseUp ( wxCommandEvent & evt)
protected
237{
238 wxGridCellChoiceEditor::OnComboCloseUp(evt);
239}

Referenced by BeginEdit().

Here is the caller graph for this function:

◆ SetSize()

void Slic3r::GUI::GridCellFilamentsEditor::SetSize ( const wxRect & rect)
virtual
221{
222 wxGridCellChoiceEditor::SetSize(rect);
223 /*wxASSERT_MSG(m_control,
224 wxT("The wxGridCellChoiceEditor must be created first!"));
225
226 // Use normal wxChoice size, except for extending it to fill the cell
227 // width: we can't be smaller because this could make the control unusable
228 // and we don't want to be taller because this looks unusual and weird.
229 wxSize size = m_control->GetBestSize();
230 if ( size.x < rect.width )
231 size.x = rect.width;
232
233 DoPositionEditor(size, rect);*/
234}

◆ TryActivate()

wxGridActivationResult Slic3r::GUI::GridCellFilamentsEditor::TryActivate ( int row,
int col,
wxGrid * grid,
const wxGridActivationSource & actSource )
virtual
313{
314 ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
315 ObjectGridTable::ObjectGridCol* grid_col = table->get_grid_col(col);
316 ObjectGridTable::ObjectGridRow* grid_row = table->get_grid_row(row - 1);
317
318 if ( actSource.GetOrigin() == wxGridActivationSource::Key ) {
319 const wxKeyEvent& key_event = actSource.GetKeyEvent();
320 int keyCode = key_event.GetKeyCode();
321 wxString choice;
322
323 int digital_value = keyCode - '0';
324 if ((digital_value >= 1) && (digital_value <= 9))
325 m_cached_value = digital_value;
326 else
327 m_cached_value = -1;
328
329 if (m_cached_value != -1) {
330 if (m_cached_value <= grid_col->choice_count) {
331 choice = grid_col->choices[m_cached_value-1];
332 return wxGridActivationResult::DoChange(choice);
333 }
334 else {
335 return wxGridActivationResult::DoNothing();
336 }
337 }
338 else
339 return wxGridActivationResult::DoNothing();
340 }
341 else {
342 m_cached_value = -1;
343 return wxGridActivationResult::DoEdit();
344 }
345}

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::GridCellFilamentsEditor::wxDECLARE_NO_COPY_CLASS ( GridCellFilamentsEditor )
protected

References GridCellFilamentsEditor().

Here is the call graph for this function:

Member Data Documentation

◆ m_cached_value

int Slic3r::GUI::GridCellFilamentsEditor::m_cached_value {-1}
private
126{-1};

Referenced by DoActivate(), and TryActivate().

◆ m_icons

std::vector<wxBitmap*>* Slic3r::GUI::GridCellFilamentsEditor::m_icons
protected

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