Audacity  2.2.2
Public Member Functions | Private Attributes | List of all members
ComboEditor Class Referencefinal
Inheritance diagram for ComboEditor:

Public Member Functions

 ComboEditor (const wxArrayString &choices, bool allowOthers=false)
 
void PaintBackground (wxDC &, const wxRect &WXUNUSED(rectCell), const wxGridCellAttr &WXUNUSED(attr)) override
 
void SetParameters (const wxString &params) override
 
void SetSize (const wxRect &rectOrig) override
 
virtual void StartingKey (wxKeyEvent &event) override
 
wxGridCellEditor * Clone () const override
 

Private Attributes

wxArrayString m_choices
 
bool m_allowOthers
 

Detailed Description

Definition at line 584 of file Tags.cpp.

Constructor & Destructor Documentation

ComboEditor::ComboEditor ( const wxArrayString &  choices,
bool  allowOthers = false 
)
inline

Definition at line 587 of file Tags.cpp.

588  : wxGridCellChoiceEditor(choices, allowOthers)
589  , m_choices{ choices }
590  , m_allowOthers{ allowOthers }
591  {
592  }
bool m_allowOthers
Definition: Tags.cpp:682
wxArrayString m_choices
Definition: Tags.cpp:681

Member Function Documentation

wxGridCellEditor* ComboEditor::Clone ( ) const
inlineoverride

Definition at line 675 of file Tags.cpp.

References m_allowOthers, m_choices, and safenew.

676  {
678  }
#define safenew
Definition: Audacity.h:223
bool m_allowOthers
Definition: Tags.cpp:682
wxArrayString m_choices
Definition: Tags.cpp:681
void ComboEditor::PaintBackground ( wxDC &  ,
const wxRect &  WXUNUSEDrectCell,
const wxGridCellAttr &  WXUNUSEDattr 
)
inlineoverride

Definition at line 594 of file Tags.cpp.

595  {
596  // Ignore it (a must on the Mac as the erasure causes problems.)
597  }
void ComboEditor::SetParameters ( const wxString &  params)
inlineoverride

Definition at line 599 of file Tags.cpp.

References m_choices.

600  {
601  wxGridCellChoiceEditor::SetParameters(params);
602 
603  // Refresh the wxComboBox with NEW values
604  if (Combo()) {
605  Combo()->Clear();
606  Combo()->Append(m_choices);
607  }
608  }
wxArrayString m_choices
Definition: Tags.cpp:681
EffectDistortion::Params params
Definition: Distortion.cpp:95
void ComboEditor::SetSize ( const wxRect &  rectOrig)
inlineoverride

Definition at line 610 of file Tags.cpp.

611  {
612  wxRect rect(rectOrig);
613  wxRect r = Combo()->GetRect();
614 
615  // Center the combo box in or over the cell
616  rect.y -= (r.GetHeight() - rect.GetHeight()) / 2;
617  rect.height = r.GetHeight();
618 
619  wxGridCellChoiceEditor::SetSize(rect);
620  }
virtual void ComboEditor::StartingKey ( wxKeyEvent &  event)
inlineoverridevirtual

Definition at line 624 of file Tags.cpp.

625  {
626  // Lifted from wxGridCellTextEditor and adapted to combo.
627 
628  // [Below is comment from wxWidgets code]
629  // Since this is now happening in the EVT_CHAR event EmulateKeyPress is no
630  // longer an appropriate way to get the character into the text control.
631  // Do it ourselves instead. We know that if we get this far that we have
632  // a valid character, so not a whole lot of testing needs to be done.
633 
634  //The only difference to wxGridCellTextEditor.
635  //wxTextCtrl* tc = (wxTextCtrl *)m_control;
636  wxComboBox * tc = Combo();
637  int ch;
638 
639  bool isPrintable;
640 
641  #if wxUSE_UNICODE
642  ch = event.GetUnicodeKey();
643  if ( ch != WXK_NONE )
644  isPrintable = true;
645  else
646  #endif // wxUSE_UNICODE
647  {
648  ch = event.GetKeyCode();
649  isPrintable = ch >= WXK_SPACE && ch < WXK_START;
650  }
651 
652  switch (ch)
653  {
654  case WXK_DELETE:
655  // Delete the initial character when starting to edit with DELETE.
656  tc->Remove(0, 1);
657  break;
658 
659  case WXK_BACK:
660  // Delete the last character when starting to edit with BACKSPACE.
661  {
662  const long pos = tc->GetLastPosition();
663  tc->Remove(pos - 1, pos);
664  }
665  break;
666 
667  default:
668  if ( isPrintable )
669  tc->WriteText(static_cast<wxChar>(ch));
670  break;
671  }
672  }

Member Data Documentation

bool ComboEditor::m_allowOthers
private

Definition at line 682 of file Tags.cpp.

Referenced by Clone().

wxArrayString ComboEditor::m_choices
private

Definition at line 681 of file Tags.cpp.

Referenced by Clone(), and SetParameters().


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