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 335 of file Grid.cpp.

336{
337 if (count) {
338 mChoices.reserve(count);
339 for (size_t n = 0; n < count; n++) {
340 mChoices.push_back(choices[n]);
341 }
342 }
343}
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 345 of file Grid.cpp.

346{
347 mChoices = choices;
348}

References mChoices.

◆ ~ChoiceEditor()

ChoiceEditor::~ChoiceEditor ( )

Definition at line 350 of file Grid.cpp.

351{
352 if (m_control)
353 mHandler.DisconnectEvent(m_control);
354}
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 432 of file Grid.cpp.

433{
434 grid->GetTable()->SetValue(row, col, mValueAsString);
435}
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 385 of file Grid.cpp.

386{
387 if (!m_control)
388 return;
389
390 mOld = grid->GetTable()->GetValue(row, col);
391
392 Choice()->Clear();
393 Choice()->Append(mChoices);
394 Choice()->SetSelection( make_iterator_range( mChoices ).index( mOld ) );
395 Choice()->SetFocus();
396}
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: IteratorX.h:210
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 357 of file Grid.cpp.

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

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 362 of file Grid.cpp.

363{
364 m_control = safenew wxChoice(parent,
365 id,
366 wxDefaultPosition,
367 wxDefaultSize,
368 mChoices);
369
370 wxGridCellEditor::Create(parent, id, evtHandler);
371 mHandler.ConnectEvent(m_control);
372}
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 398 of file Grid.cpp.

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

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 447 of file Grid.cpp.

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

References Choice(), and mChoices.

Here is the call graph for this function:

◆ Reset()

void ChoiceEditor::Reset ( )
override

Definition at line 437 of file Grid.cpp.

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

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 442 of file Grid.cpp.

443{
444 mChoices = choices;
445}

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 374 of file Grid.cpp.

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

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: