Audacity 3.2.0
Public Member Functions | Private Member Functions | Friends | List of all members
PluginDataViewCtrl Class Referencefinal

#include <PluginDataViewCtrl.h>

Inheritance diagram for PluginDataViewCtrl:
[legend]
Collaboration diagram for PluginDataViewCtrl:
[legend]

Public Member Functions

template<typename... Args>
 PluginDataViewCtrl (Args &&... args)
 

Private Member Functions

void Init ()
 
void OnCharEvent (wxKeyEvent &evt)
 

Friends

class PluginsDataViewCtrlAx
 
class PluginDataViewRenderer
 

Detailed Description

Definition at line 5 of file PluginDataViewCtrl.h.

Constructor & Destructor Documentation

◆ PluginDataViewCtrl()

template<typename... Args>
PluginDataViewCtrl::PluginDataViewCtrl ( Args &&...  args)
inline

Definition at line 13 of file PluginDataViewCtrl.h.

14 : wxDataViewCtrl(std::forward<Args>(args)...)
15 {
16 Init();
17 }

References Init().

Here is the call graph for this function:

Member Function Documentation

◆ Init()

void PluginDataViewCtrl::Init ( )
private

Definition at line 450 of file PluginDataViewCtrl.cpp.

451{
452#if defined(wxHAS_GENERIC_DATAVIEWCTRL)
453 //Do not allow wxDataViewMainWindow handle TAB key...
454 GetChildren()[0]->Bind(wxEVT_CHAR_HOOK, &PluginDataViewCtrl::OnTableCharHook, this);
455#elif defined(__WXOSX__)
456 //Implements group toggle behaviour when multiple
457 //lines are selected and Enter key pressed.
458 Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [=](wxDataViewEvent& evt) {
459 evt.Skip();
460 const auto item = evt.GetItem();
461 if(!item.IsOk())
462 return;
463
464 const auto model = GetModel();
465 if(model == nullptr)
466 return;
467
468 wxVariant value;
469 model->GetValue(value, item, PluginDataModel::ColumnState);
470 if(value.IsNull())
471 return;
472
473 value = !value.GetBool();
474
475 wxDataViewItemArray sel;
476 GetSelections(sel);
477 if(!sel.empty())
478 {
479 for(const auto& item : sel)
480 model->ChangeValue(value, item, PluginDataModel::ColumnState);
481 }
482 else
483 model->ChangeValue(value, item, PluginDataModel::ColumnState);
484 evt.Skip(false);
485 });
486#endif
487 AppendColumn(safenew wxDataViewColumn(
490 wxDVC_DEFAULT_WIDTH,
491 wxALIGN_NOT,
492 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE)
493 );
494 AppendColumn(safenew wxDataViewColumn(
497 wxDVC_DEFAULT_WIDTH,
498 wxALIGN_NOT,
499 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE)
500 );
501 AppendColumn(safenew wxDataViewColumn(
504 wxDVC_DEFAULT_WIDTH,
505 wxALIGN_NOT,
506 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE)
507 );
508 AppendColumn(safenew wxDataViewColumn(
509 _("Enabled"),
512 wxDVC_DEFAULT_WIDTH,
513 wxALIGN_CENTER,
514 wxDATAVIEW_COL_SORTABLE
515 ));
516}
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:10

References _, PluginDataModel::ColumnName, PluginDataModel::ColumnPath, PluginDataModel::ColumnState, PluginDataModel::ColumnType, and safenew.

Referenced by PluginDataViewCtrl().

Here is the caller graph for this function:

◆ OnCharEvent()

void PluginDataViewCtrl::OnCharEvent ( wxKeyEvent &  evt)
private

Definition at line 518 of file PluginDataViewCtrl.cpp.

519{
520 evt.Skip();
521#if defined(wxHAS_GENERIC_DATAVIEWCTRL)
522 //
523 if(evt.GetKeyCode() == WXK_CONTROL_A &&
524 evt.GetModifiers() | WXK_COMMAND)
525 {
526 SelectAll();
527 evt.Skip(false);
528 return;
529 }
530 if(evt.GetKeyCode() == WXK_SPACE ||
531 evt.GetKeyCode() == WXK_RETURN ||
532 evt.GetKeyCode() == WXK_NUMPAD_ENTER)
533 {
534 return;
535 }
536
537 const auto ch = evt.GetUnicodeKey();
538 if(ch == WXK_NONE)
539 return;
540
541 auto item = GetCurrentItem();
542 if(!item.IsOk())
543 return;
544
545 //if item.IsOk(), then there is at least 1 item in the table
546 const auto searchStartRow = GetRowByItem(item);
547 auto row = searchStartRow + 1;
548 while(true)
549 {
550 item = GetItemByRow(row);
551
552 if(!item.IsOk())
553 {
554 if(row > searchStartRow)
555 {
556 //start from the beginning, until we reach
557 //searchStartRow again
558 row = 0;
559 continue;
560 }
561 break;
562 }
563
564 wxVariant data;
565 GetModel()->GetValue(data, item, PluginDataModel::ColumnName);
566 const auto name = data.GetString();
567 if(!name.empty() && name.Left(1).IsSameAs(ch, false))
568 {
569 wxDataViewItemArray sel;
570 sel.push_back(item);
571 SetSelections(sel);
572 SetCurrentItem(sel[0]);
573 EnsureVisible(sel[0]);
574 break;
575 }
576 if(row == searchStartRow)
577 break;
578 ++row;
579 }
580 evt.Skip(false);
581#else
582 evt.Skip();
583#endif
584}
wxString name
Definition: TagsEditor.cpp:166

References PluginDataModel::ColumnName, RefreshCode::EnsureVisible, and name.

Friends And Related Function Documentation

◆ PluginDataViewRenderer

friend class PluginDataViewRenderer
friend

Definition at line 8 of file PluginDataViewCtrl.h.

◆ PluginsDataViewCtrlAx

friend class PluginsDataViewCtrlAx
friend

Definition at line 7 of file PluginDataViewCtrl.h.


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