Audacity  2.2.2
Classes | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
ChoiceEditor Class Referencefinal

#include <Grid.h>

Inheritance diagram for ChoiceEditor:

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

Definition at line 128 of file Grid.h.

Constructor & Destructor Documentation

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

Definition at line 255 of file Grid.cpp.

References mChoices.

Referenced by Clone().

256 {
257  if (count) {
258  mChoices.Alloc(count);
259  for (size_t n = 0; n < count; n++) {
260  mChoices.Add(choices[n]);
261  }
262  }
263 }
wxArrayString mChoices
Definition: Grid.h:182
ChoiceEditor::ChoiceEditor ( const wxArrayString &  choices)

Definition at line 265 of file Grid.cpp.

References mChoices.

266 {
267  mChoices = choices;
268 }
wxArrayString mChoices
Definition: Grid.h:182
ChoiceEditor::~ChoiceEditor ( )

Definition at line 270 of file Grid.cpp.

References ChoiceEditor::FocusHandler::DisconnectEvent(), and mHandler.

271 {
272  if (m_control)
273  mHandler.DisconnectEvent(m_control);
274 }
void DisconnectEvent(wxWindow *w)
Definition: Grid.h:172
ChoiceEditor::FocusHandler mHandler

Member Function Documentation

void ChoiceEditor::ApplyEdit ( int  row,
int  col,
wxGrid *  grid 
)
override

Definition at line 352 of file Grid.cpp.

References mValueAsString.

Referenced by EndEdit().

353 {
354  grid->GetTable()->SetValue(row, col, mValueAsString);
355 }
wxString mValueAsString
Definition: Grid.h:184
void ChoiceEditor::BeginEdit ( int  row,
int  col,
wxGrid *  grid 
)
override

Definition at line 305 of file Grid.cpp.

References Choice(), mChoices, and mOld.

306 {
307  if (!m_control)
308  return;
309 
310  mOld = grid->GetTable()->GetValue(row, col);
311 
312  Choice()->Clear();
313  Choice()->Append(mChoices);
314  Choice()->SetSelection(mChoices.Index(mOld));
315  Choice()->SetFocus();
316 }
wxArrayString mChoices
Definition: Grid.h:182
wxChoice * Choice() const
Definition: Grid.h:158
wxString mOld
Definition: Grid.h:183
wxChoice* ChoiceEditor::Choice ( ) const
inlineprotected

Definition at line 158 of file Grid.h.

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

158 { return (wxChoice *)m_control; }
wxGridCellEditor * ChoiceEditor::Clone ( ) const
override

Definition at line 277 of file Grid.cpp.

References ChoiceEditor(), mChoices, and safenew.

278 {
279  return safenew ChoiceEditor(mChoices);
280 }
wxArrayString mChoices
Definition: Grid.h:182
#define safenew
Definition: Audacity.h:230
ChoiceEditor(size_t count=0, const wxString choices[]=NULL)
Definition: Grid.cpp:255
void ChoiceEditor::Create ( wxWindow *  parent,
wxWindowID  id,
wxEvtHandler *  evtHandler 
)
override

Definition at line 282 of file Grid.cpp.

References ChoiceEditor::FocusHandler::ConnectEvent(), mChoices, mHandler, and safenew.

283 {
284  m_control = safenew wxChoice(parent,
285  id,
286  wxDefaultPosition,
287  wxDefaultSize,
288  mChoices);
289 
290  wxGridCellEditor::Create(parent, id, evtHandler);
291  mHandler.ConnectEvent(m_control);
292 }
ChoiceEditor::FocusHandler mHandler
wxArrayString mChoices
Definition: Grid.h:182
#define safenew
Definition: Audacity.h:230
void ConnectEvent(wxWindow *w)
Definition: Grid.h:166
bool ChoiceEditor::EndEdit ( int  row,
int  col,
wxGrid *  grid 
)

Definition at line 318 of file Grid.cpp.

References ApplyEdit(), and mOld.

319 {
320  wxString newvalue;
321  bool changed = EndEdit(row, col, grid, mOld, &newvalue);
322  if (changed) {
323  ApplyEdit(row, col, grid);
324  }
325  return changed;
326 }
bool EndEdit(int row, int col, wxGrid *grid)
Definition: Grid.cpp:318
void ApplyEdit(int row, int col, wxGrid *grid) override
Definition: Grid.cpp:352
wxString mOld
Definition: Grid.h:183
bool ChoiceEditor::EndEdit ( int  row,
int  col,
const wxGrid *  grid,
const wxString &  oldval,
wxString *  newval 
)
override
wxString ChoiceEditor::GetValue ( ) const
override

Definition at line 367 of file Grid.cpp.

References Choice(), and mChoices.

368 {
369  return mChoices[Choice()->GetSelection()];
370 }
wxArrayString mChoices
Definition: Grid.h:182
wxChoice * Choice() const
Definition: Grid.h:158
void ChoiceEditor::Reset ( )
override

Definition at line 357 of file Grid.cpp.

References Choice(), mChoices, and mOld.

358 {
359  Choice()->SetSelection(mChoices.Index(mOld));
360 }
wxArrayString mChoices
Definition: Grid.h:182
wxChoice * Choice() const
Definition: Grid.h:158
wxString mOld
Definition: Grid.h:183
void ChoiceEditor::SetChoices ( const wxArrayString &  choices)

Definition at line 362 of file Grid.cpp.

References mChoices.

Referenced by LabelDialog::TransferDataToWindow().

363 {
364  mChoices = choices;
365 }
wxArrayString mChoices
Definition: Grid.h:182
void ChoiceEditor::SetSize ( const wxRect &  rect)
override

Definition at line 294 of file Grid.cpp.

295 {
296  wxSize size = m_control->GetSize();
297 
298  // Always center...looks bad otherwise
299  int x = rect.x + ((rect.width / 2) - (size.x / 2)) + 1;
300  int y = rect.y + ((rect.height / 2) - (size.y / 2)) + 1;
301 
302  m_control->Move(x, y);
303 }

Member Data Documentation

wxArrayString ChoiceEditor::mChoices
private

Definition at line 182 of file Grid.h.

Referenced by BeginEdit(), ChoiceEditor(), Clone(), Create(), GetValue(), Reset(), and SetChoices().

ChoiceEditor::FocusHandler ChoiceEditor::mHandler
private

Referenced by Create(), and ~ChoiceEditor().

wxString ChoiceEditor::mOld
private

Definition at line 183 of file Grid.h.

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

wxString ChoiceEditor::mValueAsString
private

Definition at line 184 of file Grid.h.

Referenced by ApplyEdit().


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