Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
ComboEditor Class Referencefinal
Inheritance diagram for ComboEditor:
[legend]
Collaboration diagram for ComboEditor:
[legend]

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 38 of file TagsEditor.cpp.

Constructor & Destructor Documentation

◆ ComboEditor()

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

Definition at line 41 of file TagsEditor.cpp.

42 : wxGridCellChoiceEditor(choices, allowOthers)
43 , m_choices{ choices }
44 , m_allowOthers{ allowOthers }
45 {
46 }
wxArrayString m_choices
Definition: TagsEditor.cpp:135
bool m_allowOthers
Definition: TagsEditor.cpp:136

Member Function Documentation

◆ Clone()

wxGridCellEditor * ComboEditor::Clone ( ) const
inlineoverride

Definition at line 129 of file TagsEditor.cpp.

130 {
132 }
#define safenew
Definition: MemoryX.h:10

References m_allowOthers, m_choices, and safenew.

◆ PaintBackground()

void ComboEditor::PaintBackground ( wxDC &  ,
const wxRect &  WXUNUSEDrectCell,
const wxGridCellAttr &  WXUNUSEDattr 
)
inlineoverride

Definition at line 48 of file TagsEditor.cpp.

49 {
50 // Ignore it (a must on the Mac as the erasure causes problems.)
51 }

◆ SetParameters()

void ComboEditor::SetParameters ( const wxString &  params)
inlineoverride

Definition at line 53 of file TagsEditor.cpp.

54 {
55 wxGridCellChoiceEditor::SetParameters(params);
56
57 // Refresh the wxComboBox with NEW values
58 if (Combo()) {
59 Combo()->Clear();
60 Combo()->Append(m_choices);
61 }
62 }
EffectDistortion::Params params
Definition: Distortion.cpp:83

References m_choices, and params.

◆ SetSize()

void ComboEditor::SetSize ( const wxRect &  rectOrig)
inlineoverride

Definition at line 64 of file TagsEditor.cpp.

65 {
66 wxRect rect(rectOrig);
67 wxRect r = Combo()->GetRect();
68
69 // Center the combo box in or over the cell
70 rect.y -= (r.GetHeight() - rect.GetHeight()) / 2;
71 rect.height = r.GetHeight();
72
73 wxGridCellChoiceEditor::SetSize(rect);
74 }

◆ StartingKey()

virtual void ComboEditor::StartingKey ( wxKeyEvent &  event)
inlineoverridevirtual

Definition at line 78 of file TagsEditor.cpp.

79 {
80 // Lifted from wxGridCellTextEditor and adapted to combo.
81
82 // [Below is comment from wxWidgets code]
83 // Since this is now happening in the EVT_CHAR event EmulateKeyPress is no
84 // longer an appropriate way to get the character into the text control.
85 // Do it ourselves instead. We know that if we get this far that we have
86 // a valid character, so not a whole lot of testing needs to be done.
87
88 //The only difference to wxGridCellTextEditor.
89 //wxTextCtrl* tc = (wxTextCtrl *)m_control;
90 wxComboBox * tc = Combo();
91 int ch;
92
93 bool isPrintable;
94
95 #if wxUSE_UNICODE
96 ch = event.GetUnicodeKey();
97 if ( ch != WXK_NONE )
98 isPrintable = true;
99 else
100 #endif // wxUSE_UNICODE
101 {
102 ch = event.GetKeyCode();
103 isPrintable = ch >= WXK_SPACE && ch < WXK_START;
104 }
105
106 switch (ch)
107 {
108 case WXK_DELETE:
109 // Delete the initial character when starting to edit with DELETE.
110 tc->Remove(0, 1);
111 break;
112
113 case WXK_BACK:
114 // Delete the last character when starting to edit with BACKSPACE.
115 {
116 const long pos = tc->GetLastPosition();
117 tc->Remove(pos - 1, pos);
118 }
119 break;
120
121 default:
122 if ( isPrintable )
123 tc->WriteText(static_cast<wxChar>(ch));
124 break;
125 }
126 }

Member Data Documentation

◆ m_allowOthers

bool ComboEditor::m_allowOthers
private

Definition at line 136 of file TagsEditor.cpp.

Referenced by Clone().

◆ m_choices

wxArrayString ComboEditor::m_choices
private

Definition at line 135 of file TagsEditor.cpp.

Referenced by Clone(), and SetParameters().


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