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

Constructor & Destructor Documentation

◆ ComboEditor()

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

Definition at line 42 of file TagsEditor.cpp.

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

Member Function Documentation

◆ Clone()

wxGridCellEditor * ComboEditor::Clone ( ) const
inlineoverride

Definition at line 130 of file TagsEditor.cpp.

131 {
133 }
#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 49 of file TagsEditor.cpp.

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

◆ SetParameters()

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

Definition at line 54 of file TagsEditor.cpp.

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

References m_choices, and params.

◆ SetSize()

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

Definition at line 65 of file TagsEditor.cpp.

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

◆ StartingKey()

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

Definition at line 79 of file TagsEditor.cpp.

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

Member Data Documentation

◆ m_allowOthers

bool ComboEditor::m_allowOthers
private

Definition at line 137 of file TagsEditor.cpp.

Referenced by Clone().

◆ m_choices

wxArrayString ComboEditor::m_choices
private

Definition at line 136 of file TagsEditor.cpp.

Referenced by Clone(), and SetParameters().


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