Audacity  2.2.2
Public Member Functions | Protected Member Functions | List of all members
Grid Class Referencefinal

Supplies an accessible grid based on wxGrid. More...

#include <Grid.h>

Inheritance diagram for Grid:

Public Member Functions

 Grid (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS|wxBORDER, const wxString &name=wxPanelNameStr)
 
 ~Grid ()
 

Protected Member Functions

void OnSetFocus (wxFocusEvent &event)
 
void OnSelectCell (wxGridEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 

Detailed Description

Supplies an accessible grid based on wxGrid.

Definition at line 194 of file Grid.h.

Constructor & Destructor Documentation

Grid::Grid ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxWANTS_CHARS | wxBORDER,
const wxString &  name = wxPanelNameStr 
)

Definition at line 382 of file Grid.cpp.

References NumericConverter::FREQUENCY, GRID_VALUE_CHOICE, GRID_VALUE_FREQUENCY, GRID_VALUE_TIME, safenew, and NumericConverter::TIME.

388 : wxGrid(parent, id, pos, size, style | wxWANTS_CHARS, name)
389 {
390 #if wxUSE_ACCESSIBILITY
391  GetGridWindow()->SetAccessible(mAx = safenew GridAx(this));
392 #endif
393 
394  // RegisterDataType takes ownership of renderer and editor
395 
396  RegisterDataType(GRID_VALUE_TIME,
399  { NumericTextCtrl::TIME, wxT("seconds"), 44100.0 });
400 
401  RegisterDataType(GRID_VALUE_FREQUENCY,
404  { NumericTextCtrl::FREQUENCY, wxT("Hz"), 44100.0 });
405 
406  RegisterDataType(GRID_VALUE_CHOICE,
407  safenew wxGridCellStringRenderer,
409 }
#define GRID_VALUE_TIME
Definition: Grid.h:38
#define GRID_VALUE_CHOICE
Definition: Grid.h:123
#define safenew
Definition: Audacity.h:223
#define GRID_VALUE_FREQUENCY
Definition: Grid.h:39
const wxChar * name
Definition: Distortion.cpp:94
Grid::~Grid ( )

Definition at line 411 of file Grid.cpp.

412 {
413 #if wxUSE_ACCESSIBILITY
414  int cnt = mChildren.size();
415  while (cnt--) {
416  // PRL: I found this loop destroying right-to-left.
417  // Is the sequence of destruction important?
418  mChildren.pop_back();
419  }
420 #endif
421 }

Member Function Documentation

void Grid::OnKeyDown ( wxKeyEvent &  event)
protected

Definition at line 441 of file Grid.cpp.

442 {
443  switch (event.GetKeyCode())
444  {
445  case WXK_LEFT:
446  case WXK_RIGHT:
447  {
448  int rows = GetNumberRows();
449  int cols = GetNumberCols();
450  int crow = GetGridCursorRow();
451  int ccol = GetGridCursorCol();
452 
453  if (event.GetKeyCode() == WXK_LEFT) {
454  if (crow == 0 && ccol == 0) {
455  // do nothing
456  }
457  else if (ccol == 0) {
458  SetGridCursor(crow - 1, cols - 1);
459  }
460  else {
461  SetGridCursor(crow, ccol - 1);
462  }
463  }
464  else {
465  if (crow == rows - 1 && ccol == cols - 1) {
466  // do nothing
467  }
468  else if (ccol == cols - 1) {
469  SetGridCursor(crow + 1, 0);
470  }
471  else {
472  SetGridCursor(crow, ccol + 1);
473  }
474  }
475 
476 #if wxUSE_ACCESSIBILITY
477  // Make sure the NEW cell is made available to the screen reader
478  mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
479 #endif
480  }
481  break;
482 
483  case WXK_TAB:
484  {
485  int rows = GetNumberRows();
486  int cols = GetNumberCols();
487  int crow = GetGridCursorRow();
488  int ccol = GetGridCursorCol();
489 
490  if (event.ControlDown()) {
491  int flags = wxNavigationKeyEvent::FromTab |
492  ( event.ShiftDown() ?
493  wxNavigationKeyEvent::IsBackward :
494  wxNavigationKeyEvent::IsForward );
495  Navigate(flags);
496  return;
497  }
498  else if (event.ShiftDown()) {
499  if (crow == 0 && ccol == 0) {
500  Navigate(wxNavigationKeyEvent::FromTab | wxNavigationKeyEvent::IsBackward);
501  return;
502  }
503  else if (ccol == 0) {
504  SetGridCursor(crow - 1, cols - 1);
505  }
506  else {
507  SetGridCursor(crow, ccol - 1);
508  }
509  }
510  else {
511  if (crow == rows - 1 && ccol == cols - 1) {
512  Navigate(wxNavigationKeyEvent::FromTab | wxNavigationKeyEvent::IsForward);
513  return;
514  }
515  else if (ccol == cols - 1) {
516  SetGridCursor(crow + 1, 0);
517  }
518  else {
519  SetGridCursor(crow, ccol + 1);
520  }
521  }
522  MakeCellVisible(GetGridCursorRow(), GetGridCursorCol());
523 
524 #if wxUSE_ACCESSIBILITY
525  // Make sure the NEW cell is made available to the screen reader
526  mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
527 #endif
528  }
529  break;
530 
531  case WXK_RETURN:
532  case WXK_NUMPAD_ENTER:
533  {
534  if (!IsCellEditControlShown()) {
535  wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
536  wxWindow *def = tlw->GetDefaultItem();
537  if (def && def->IsEnabled()) {
538  wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
539  def->GetId());
540  GetParent()->GetEventHandler()->ProcessEvent(cevent);
541  }
542  }
543  else {
544  wxGrid::OnKeyDown(event);
545 
546  // This looks strange, but what it does is selects the cell when
547  // enter is pressed after editing. Without it, Jaws and Window-Eyes
548  // do not speak the NEW cell contents (the one below the edited one).
549  SetGridCursor(GetGridCursorRow(), GetGridCursorCol());
550  }
551  break;
552  }
553 
554  default:
555  wxGrid::OnKeyDown(event);
556  break;
557  }
558 }
void Grid::OnSelectCell ( wxGridEvent &  event)
protected

Definition at line 432 of file Grid.cpp.

433 {
434  event.Skip();
435 
436 #if wxUSE_ACCESSIBILITY
437  mAx->SetCurrentCell(event.GetRow(), event.GetCol());
438 #endif
439 }
void Grid::OnSetFocus ( wxFocusEvent &  event)
protected

Definition at line 423 of file Grid.cpp.

424 {
425  event.Skip();
426 
427 #if wxUSE_ACCESSIBILITY
428  mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
429 #endif
430 }

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