Audacity 3.2.0
Classes | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
ChoiceEditor Class Referencefinal

Modified version of wxGridChoiceEditor using wxChoice instead of wxComboBox. More...

#include <Grid.h>

Inheritance diagram for ChoiceEditor:
[legend]
Collaboration diagram for ChoiceEditor:
[legend]

Classes

class  FocusHandler
 

Public Member Functions

 ChoiceEditor (size_t count=0, const wxString choices[]=NULL)
 
 ChoiceEditor (const wxArrayString &choices)
 
 ~ChoiceEditor ()
 
void Create (wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler) override
 
void SetSize (const wxRect &rect) override
 
void BeginEdit (int row, int col, wxGrid *grid) override
 
bool EndEdit (int row, int col, wxGrid *grid)
 
bool EndEdit (int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval) override
 
void ApplyEdit (int row, int col, wxGrid *grid) override
 
void Reset () override
 
wxGridCellEditor * Clone () const override
 
void SetChoices (const wxArrayString &choices)
 
wxString GetValue () const override
 

Protected Member Functions

wxChoice * Choice () const
 

Private Attributes

ChoiceEditor::FocusHandler mHandler
 
wxArrayString mChoices
 
wxString mOld
 
wxString mValueAsString
 

Detailed Description

Modified version of wxGridChoiceEditor using wxChoice instead of wxComboBox.

Definition at line 125 of file Grid.h.

Constructor & Destructor Documentation

◆ ChoiceEditor() [1/2]

ChoiceEditor::ChoiceEditor ( size_t  count = 0,
const wxString  choices[] = NULL 
)

Definition at line 336 of file Grid.cpp.

337{
338 if (count) {
339 mChoices.reserve(count);
340 for (size_t n = 0; n < count; n++) {
341 mChoices.push_back(choices[n]);
342 }
343 }
344}
wxArrayString mChoices
Definition: Grid.h:179

References mChoices.

Referenced by Clone().

Here is the caller graph for this function:

◆ ChoiceEditor() [2/2]

ChoiceEditor::ChoiceEditor ( const wxArrayString &  choices)

Definition at line 346 of file Grid.cpp.

347{
348 mChoices = choices;
349}

References mChoices.

◆ ~ChoiceEditor()

ChoiceEditor::~ChoiceEditor ( )

Definition at line 351 of file Grid.cpp.

352{
353 if (m_control)
354 mHandler.DisconnectEvent(m_control);
355}
void DisconnectEvent(wxWindow *w)
Definition: Grid.h:169
ChoiceEditor::FocusHandler mHandler

References ChoiceEditor::FocusHandler::DisconnectEvent(), and mHandler.

Here is the call graph for this function:

Member Function Documentation

◆ ApplyEdit()

void ChoiceEditor::ApplyEdit ( int  row,
int  col,
wxGrid *  grid 
)
override

Definition at line 433 of file Grid.cpp.

434{
435 grid->GetTable()->SetValue(row, col, mValueAsString);
436}
wxString mValueAsString
Definition: Grid.h:181

References mValueAsString.

Referenced by EndEdit().

Here is the caller graph for this function:

◆ BeginEdit()

void ChoiceEditor::BeginEdit ( int  row,
int  col,
wxGrid *  grid 
)
override

Definition at line 386 of file Grid.cpp.

387{
388 if (!m_control)
389 return;
390
391 mOld = grid->GetTable()->GetValue(row, col);
392
393 Choice()->Clear();
394 Choice()->Append(mChoices);
395 Choice()->SetSelection( make_iterator_range( mChoices ).index( mOld ) );
396 Choice()->SetFocus();
397}
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:448
wxChoice * Choice() const
Definition: Grid.h:155
wxString mOld
Definition: Grid.h:180

References Choice(), make_iterator_range(), mChoices, and mOld.

Here is the call graph for this function:

◆ Choice()

wxChoice * ChoiceEditor::Choice ( ) const
inlineprotected

Definition at line 155 of file Grid.h.

155{ return (wxChoice *)m_control; }

Referenced by BeginEdit(), GetValue(), and Reset().

Here is the caller graph for this function:

◆ Clone()

wxGridCellEditor * ChoiceEditor::Clone ( ) const
override

Definition at line 358 of file Grid.cpp.

359{
361}
#define safenew
Definition: MemoryX.h:10
ChoiceEditor(size_t count=0, const wxString choices[]=NULL)
Definition: Grid.cpp:336

References ChoiceEditor(), mChoices, and safenew.

Here is the call graph for this function:

◆ Create()

void ChoiceEditor::Create ( wxWindow *  parent,
wxWindowID  id,
wxEvtHandler *  evtHandler 
)
override

Definition at line 363 of file Grid.cpp.

364{
365 m_control = safenew wxChoice(parent,
366 id,
367 wxDefaultPosition,
368 wxDefaultSize,
369 mChoices);
370
371 wxGridCellEditor::Create(parent, id, evtHandler);
372 mHandler.ConnectEvent(m_control);
373}
void ConnectEvent(wxWindow *w)
Definition: Grid.h:163

References ChoiceEditor::FocusHandler::ConnectEvent(), mChoices, mHandler, and safenew.

Here is the call graph for this function:

◆ EndEdit() [1/2]

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

◆ EndEdit() [2/2]

bool ChoiceEditor::EndEdit ( int  row,
int  col,
wxGrid *  grid 
)

Definition at line 399 of file Grid.cpp.

400{
401 wxString newvalue;
402 bool changed = EndEdit(row, col, grid, mOld, &newvalue);
403 if (changed) {
404 ApplyEdit(row, col, grid);
405 }
406 return changed;
407}
bool EndEdit(int row, int col, wxGrid *grid)
Definition: Grid.cpp:399
void ApplyEdit(int row, int col, wxGrid *grid) override
Definition: Grid.cpp:433

References ApplyEdit(), EndEdit(), and mOld.

Referenced by EndEdit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetValue()

wxString ChoiceEditor::GetValue ( ) const
override

Definition at line 448 of file Grid.cpp.

449{
450 return mChoices[Choice()->GetSelection()];
451}

References Choice(), and mChoices.

Here is the call graph for this function:

◆ Reset()

void ChoiceEditor::Reset ( )
override

Definition at line 438 of file Grid.cpp.

439{
440 Choice()->SetSelection( make_iterator_range( mChoices ).index( mOld ) );
441}

References Choice(), make_iterator_range(), mChoices, and mOld.

Here is the call graph for this function:

◆ SetChoices()

void ChoiceEditor::SetChoices ( const wxArrayString &  choices)

Definition at line 443 of file Grid.cpp.

444{
445 mChoices = choices;
446}

References mChoices.

Referenced by LabelDialog::TransferDataToWindow().

Here is the caller graph for this function:

◆ SetSize()

void ChoiceEditor::SetSize ( const wxRect &  rect)
override

Definition at line 375 of file Grid.cpp.

376{
377 wxSize size = m_control->GetSize();
378
379 // Always center...looks bad otherwise
380 int x = rect.x + ((rect.width / 2) - (size.x / 2)) + 1;
381 int y = rect.y + ((rect.height / 2) - (size.y / 2)) + 1;
382
383 m_control->Move(x, y);
384}

References size.

Member Data Documentation

◆ mChoices

wxArrayString ChoiceEditor::mChoices
private

Definition at line 179 of file Grid.h.

Referenced by BeginEdit(), ChoiceEditor(), Clone(), Create(), GetValue(), Reset(), and SetChoices().

◆ mHandler

ChoiceEditor::FocusHandler ChoiceEditor::mHandler
private

Referenced by Create(), and ~ChoiceEditor().

◆ mOld

wxString ChoiceEditor::mOld
private

Definition at line 180 of file Grid.h.

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

◆ mValueAsString

wxString ChoiceEditor::mValueAsString
private

Definition at line 181 of file Grid.h.

Referenced by ApplyEdit().


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