Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
PopupMenuTable::Menu Class Reference

#include <PopupMenuTable.h>

Inheritance diagram for PopupMenuTable::Menu:

Public Member Functions

virtual ~Menu ()
 
void Extend (PopupMenuTable *pTable)
 
void DisconnectTable (PopupMenuTable *pTable)
 
void Disconnect ()
 

Private Member Functions

 Menu (wxEvtHandler *pParent_, void *pUserData_)
 

Private Attributes

wxEvtHandler * pParent
 
std::vector< PopupMenuTable * > tables
 
void * pUserData
 

Friends

class PopupMenuTable
 

Detailed Description

Definition at line 61 of file PopupMenuTable.h.

Constructor & Destructor Documentation

PopupMenuTable::Menu::Menu ( wxEvtHandler *  pParent_,
void *  pUserData_ 
)
inlineprivate

Definition at line 66 of file PopupMenuTable.h.

67  : pParent{ pParent_ }, tables{}, pUserData{ pUserData_ } {}
wxEvtHandler * pParent
std::vector< PopupMenuTable * > tables
PopupMenuTable::Menu::~Menu ( )
virtual

Definition at line 14 of file PopupMenuTable.cpp.

References Disconnect().

15 {
16  // Event connections between the parent window and the singleton table
17  // object must be broken when this menu is destroyed.
18  Disconnect();
19 }

Member Function Documentation

void PopupMenuTable::Menu::Disconnect ( )

Definition at line 82 of file PopupMenuTable.cpp.

Referenced by ~Menu().

83 {
84  for ( auto pTable : tables )
85  DisconnectTable(pTable);
86 }
void DisconnectTable(PopupMenuTable *pTable)
std::vector< PopupMenuTable * > tables
void PopupMenuTable::Menu::DisconnectTable ( PopupMenuTable pTable)

Definition at line 67 of file PopupMenuTable.cpp.

References PopupMenuTable::DestroyMenu(), and TranslatableArray< ArrayType >::Get().

68 {
69  for (const PopupMenuTable::Entry *pEntry = &*pTable->Get().begin();
70  pEntry->IsValid(); ++pEntry) {
71  if ( pEntry->IsItem() )
72  pParent->Unbind( wxEVT_COMMAND_MENU_SELECTED,
73  pEntry->func, pTable, pEntry->id );
74  else if ( pEntry->IsSubMenu() )
75  // recur
76  DisconnectTable(pEntry->subTable);
77  }
78 
79  pTable->DestroyMenu();
80 }
virtual void DestroyMenu()=0
wxEvtHandler * pParent
void DisconnectTable(PopupMenuTable *pTable)
const ArrayType & Get()
void PopupMenuTable::Menu::Extend ( PopupMenuTable pTable)

Definition at line 21 of file PopupMenuTable.cpp.

References PopupMenuTable::BuildMenu(), PopupMenuTableEntry::CheckItem, TranslatableArray< ArrayType >::Get(), PopupMenuTable::InitMenu(), PopupMenuTableEntry::Item, PopupMenuTableEntry::RadioItem, PopupMenuTableEntry::Separator, and PopupMenuTableEntry::SubMenu.

Referenced by PopupMenuTable::BuildMenu().

22 {
23  auto connect = [&]( const PopupMenuTable::Entry *pEntry ) {
24  this->pParent->Bind
25  (wxEVT_COMMAND_MENU_SELECTED,
26  pEntry->func, pTable, pEntry->id);
27  };
28 
29  for (const PopupMenuTable::Entry *pEntry = &*pTable->Get().begin();
30  pEntry->IsValid(); ++pEntry) {
31  switch (pEntry->type) {
33  {
34  this->Append(pEntry->id, pEntry->caption);
35  connect( pEntry );
36  break;
37  }
39  {
40  this->AppendRadioItem(pEntry->id, pEntry->caption);
41  connect( pEntry );
42  break;
43  }
45  {
46  this->AppendCheckItem(pEntry->id, pEntry->caption);
47  connect( pEntry );
48  break;
49  }
51  this->AppendSeparator();
52  break;
54  {
55  const auto subTable = pEntry->subTable;
56  auto subMenu = BuildMenu( this->pParent, subTable, pUserData );
57  this->AppendSubMenu( subMenu.release(), pEntry->caption );
58  }
59  default:
60  break;
61  }
62  }
63 
64  pTable->InitMenu(this, pUserData);
65 }
wxEvtHandler * pParent
const ArrayType & Get()
virtual void InitMenu(Menu *pMenu, void *pUserData)=0
static std::unique_ptr< Menu > BuildMenu(wxEvtHandler *pParent, PopupMenuTable *pTable, void *pUserData=NULL)

Friends And Related Function Documentation

friend class PopupMenuTable
friend

Definition at line 64 of file PopupMenuTable.h.

Member Data Documentation

wxEvtHandler* PopupMenuTable::Menu::pParent
private

Definition at line 77 of file PopupMenuTable.h.

void* PopupMenuTable::Menu::pUserData
private

Definition at line 79 of file PopupMenuTable.h.

std::vector<PopupMenuTable*> PopupMenuTable::Menu::tables
private

Definition at line 78 of file PopupMenuTable.h.


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