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 193 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, NumericConverter::HertzFormat(), safenew, NumericConverter::SecondsFormat(), 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,
400  NumericConverter::SecondsFormat(), 44100.0 });
401 
402  RegisterDataType(GRID_VALUE_FREQUENCY,
406  NumericConverter::HertzFormat(), 44100.0 });
407 
408  RegisterDataType(GRID_VALUE_CHOICE,
409  safenew wxGridCellStringRenderer,
411 }
#define GRID_VALUE_TIME
Definition: Grid.h:41
#define GRID_VALUE_CHOICE
Definition: Grid.h:126
#define safenew
Definition: Audacity.h:230
#define GRID_VALUE_FREQUENCY
Definition: Grid.h:42
static NumericFormatId SecondsFormat()
const wxChar * name
Definition: Distortion.cpp:94
static NumericFormatId HertzFormat()
Grid::~Grid ( )

Definition at line 413 of file Grid.cpp.

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

Member Function Documentation

void Grid::OnKeyDown ( wxKeyEvent &  event)
protected

Definition at line 443 of file Grid.cpp.

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

Definition at line 434 of file Grid.cpp.

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

Definition at line 425 of file Grid.cpp.

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

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