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)
 
void BeginEdit (int row, int col, wxGrid *grid)
 
bool EndEdit (int row, int col, wxGrid *grid)
 
bool EndEdit (int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval)
 
void ApplyEdit (int row, int col, wxGrid *grid)
 
void Reset ()
 
wxGridCellEditor * Clone () const override
 
void SetChoices (const wxArrayString &choices)
 
wxString GetValue () const
 

Protected Member Functions

wxChoice * Choice () const
 

Private Attributes

ChoiceEditor::FocusHandler mHandler
 
wxArrayString mChoices
 
wxString mOld
 
wxString mValueAsString
 

Detailed Description

Definition at line 126 of file Grid.h.

Constructor & Destructor Documentation

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

Definition at line 256 of file Grid.cpp.

References mChoices.

Referenced by Clone().

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

Definition at line 266 of file Grid.cpp.

References mChoices.

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

Definition at line 271 of file Grid.cpp.

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

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

Member Function Documentation

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

Definition at line 353 of file Grid.cpp.

References mValueAsString.

Referenced by EndEdit().

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

Definition at line 306 of file Grid.cpp.

References Choice(), mChoices, and mOld.

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

Definition at line 160 of file Grid.h.

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

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

Definition at line 278 of file Grid.cpp.

References ChoiceEditor(), mChoices, and safenew.

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

Definition at line 283 of file Grid.cpp.

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

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

Definition at line 319 of file Grid.cpp.

References ApplyEdit(), and mOld.

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

Definition at line 368 of file Grid.cpp.

References Choice(), and mChoices.

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

Definition at line 358 of file Grid.cpp.

References Choice(), mChoices, and mOld.

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

Definition at line 363 of file Grid.cpp.

References mChoices.

Referenced by LabelDialog::TransferDataToWindow().

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

Definition at line 295 of file Grid.cpp.

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

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: