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 119 of file Grid.h.

Constructor & Destructor Documentation

◆ ChoiceEditor() [1/2]

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

Definition at line 345 of file Grid.cpp.

346{
347 if (count) {
348 mChoices.reserve(count);
349 for (size_t n = 0; n < count; n++) {
350 mChoices.push_back(choices[n]);
351 }
352 }
353}
wxArrayString mChoices
Definition: Grid.h:174

References mChoices.

Referenced by Clone().

Here is the caller graph for this function:

◆ ChoiceEditor() [2/2]

ChoiceEditor::ChoiceEditor ( const wxArrayString &  choices)

Definition at line 355 of file Grid.cpp.

356{
357 mChoices = choices;
358}

References mChoices.

◆ ~ChoiceEditor()

ChoiceEditor::~ChoiceEditor ( )

Definition at line 360 of file Grid.cpp.

361{
362 if (m_control)
363 mHandler.DisconnectEvent(m_control);
364}
void DisconnectEvent(wxWindow *w)
Definition: Grid.h:164
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 442 of file Grid.cpp.

443{
444 grid->GetTable()->SetValue(row, col, mValueAsString);
445}
wxString mValueAsString
Definition: Grid.h:176

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

396{
397 if (!m_control)
398 return;
399
400 mOld = grid->GetTable()->GetValue(row, col);
401
402 Choice()->Clear();
403 Choice()->Append(mChoices);
404 Choice()->SetSelection( make_iterator_range( mChoices ).index( mOld ) );
405 Choice()->SetFocus();
406}
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:431
wxChoice * Choice() const
Definition: Grid.h:150
wxString mOld
Definition: Grid.h:175

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 150 of file Grid.h.

150{ 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 367 of file Grid.cpp.

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

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

373{
374 m_control = safenew wxChoice(parent,
375 id,
376 wxDefaultPosition,
377 wxDefaultSize,
378 mChoices);
379
380 wxGridCellEditor::Create(parent, id, evtHandler);
381 mHandler.ConnectEvent(m_control);
382}
void ConnectEvent(wxWindow *w)
Definition: Grid.h:158

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

409{
410 wxString newvalue;
411 bool changed = EndEdit(row, col, grid, mOld, &newvalue);
412 if (changed) {
413 ApplyEdit(row, col, grid);
414 }
415 return changed;
416}
bool EndEdit(int row, int col, wxGrid *grid)
Definition: Grid.cpp:408
void ApplyEdit(int row, int col, wxGrid *grid) override
Definition: Grid.cpp:442

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

458{
459 return mChoices[Choice()->GetSelection()];
460}

References Choice(), and mChoices.

Here is the call graph for this function:

◆ Reset()

void ChoiceEditor::Reset ( )
override

Definition at line 447 of file Grid.cpp.

448{
449 Choice()->SetSelection( make_iterator_range( mChoices ).index( mOld ) );
450}

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

453{
454 mChoices = choices;
455}

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

385{
386 wxSize size = m_control->GetSize();
387
388 // Always center...looks bad otherwise
389 int x = rect.x + ((rect.width / 2) - (size.x / 2)) + 1;
390 int y = rect.y + ((rect.height / 2) - (size.y / 2)) + 1;
391
392 m_control->Move(x, y);
393}

References size.

Member Data Documentation

◆ mChoices

wxArrayString ChoiceEditor::mChoices
private

Definition at line 174 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 175 of file Grid.h.

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

◆ mValueAsString

wxString ChoiceEditor::mValueAsString
private

Definition at line 176 of file Grid.h.

Referenced by ApplyEdit().


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