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 590 of file Tags.cpp.

Constructor & Destructor Documentation

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

Definition at line 593 of file Tags.cpp.

594  : wxGridCellChoiceEditor(choices, allowOthers)
595  , m_choices{ choices }
596  , m_allowOthers{ allowOthers }
597  {
598  }
bool m_allowOthers
Definition: Tags.cpp:688
wxArrayString m_choices
Definition: Tags.cpp:687

Member Function Documentation

wxGridCellEditor* ComboEditor::Clone ( ) const
inlineoverride

Definition at line 681 of file Tags.cpp.

References m_allowOthers, m_choices, and safenew.

682  {
684  }
#define safenew
Definition: Audacity.h:230
bool m_allowOthers
Definition: Tags.cpp:688
wxArrayString m_choices
Definition: Tags.cpp:687
void ComboEditor::PaintBackground ( wxDC &  ,
const wxRect &  WXUNUSEDrectCell,
const wxGridCellAttr &  WXUNUSEDattr 
)
inlineoverride

Definition at line 600 of file Tags.cpp.

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

Definition at line 605 of file Tags.cpp.

References m_choices.

606  {
607  wxGridCellChoiceEditor::SetParameters(params);
608 
609  // Refresh the wxComboBox with NEW values
610  if (Combo()) {
611  Combo()->Clear();
612  Combo()->Append(m_choices);
613  }
614  }
wxArrayString m_choices
Definition: Tags.cpp:687
EffectDistortion::Params params
Definition: Distortion.cpp:95
void ComboEditor::SetSize ( const wxRect &  rectOrig)
inlineoverride

Definition at line 616 of file Tags.cpp.

617  {
618  wxRect rect(rectOrig);
619  wxRect r = Combo()->GetRect();
620 
621  // Center the combo box in or over the cell
622  rect.y -= (r.GetHeight() - rect.GetHeight()) / 2;
623  rect.height = r.GetHeight();
624 
625  wxGridCellChoiceEditor::SetSize(rect);
626  }
virtual void ComboEditor::StartingKey ( wxKeyEvent &  event)
inlineoverridevirtual

Definition at line 630 of file Tags.cpp.

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

Member Data Documentation

bool ComboEditor::m_allowOthers
private

Definition at line 688 of file Tags.cpp.

Referenced by Clone().

wxArrayString ComboEditor::m_choices
private

Definition at line 687 of file Tags.cpp.

Referenced by Clone(), and SetParameters().


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