NCBI C++ ToolKit
Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
CUICommandRegistry Class Reference

Search Toolkit Book for CUICommandRegistry

CUICommandRegistry is a centralized registry where all application commands should be registered. More...

#include <gui/widgets/wx/ui_command.hpp>

+ Collaboration diagram for CUICommandRegistry:

Public Member Functions

 CUICommandRegistry (TCmdID start_id)
 
virtual ~CUICommandRegistry ()
 
int RegisterCommand (CUICommand *cmd)
 assumes ownership of the given object returns a command id (useful when registry is used for auto id assignment) More...
 
int RegisterCommand (TCmdID cmd_id, string menu_label, string label, string icon_alias, string hint=kEmptyStr, string description=kEmptyStr, string help_id=kEmptyStr, wxItemKind kind=wxITEM_NORMAL)
 create a CUICommand and registers it More...
 
const CUICommandFindCommandByID (TCmdID cmd_id) const
 returns CUICommand object or NULL More...
 
const CUICommandFindCommandByName (string name) const
 It is expensive function so use it wisely. More...
 
Accelerators support

add a new accelerators to the local table

void AddAccelerator (const wxAcceleratorEntry &entry)
 
void ApplyAccelerators (wxWindow *frame)
 apply accumulated accelerators to the specifed frame More...
 
Menu and ToolBar support
wxMenuItem * AppendMenuItem (wxMenu &menu, TCmdID cmd_id) const
 
wxMenuItem * AppendMenuItem (wxMenu &menu, TCmdID cmd_id, wxItemKind kind) const
 
void AppendMenuItems (wxMenu &menu, const TCmdID *cmd_ids, int count) const
 
void AppendMenuItems (wxMenu &menu, const vector< TCmdID > cmd_ids) const
 
wxMenu * CreateMenu (const SwxMenuItemRec *items)
 create a menu from a static definition (see WX_*_MENU macros) More...
 
void AppendTool (wxToolBar &tool_bar, TCmdID cmd_id)
 
void AppendTool (wxAuiToolBar &tool_bar, TCmdID cmd_id)
 

Static Public Member Functions

static CUICommandRegistryGetInstance ()
 the main instance associated with the application More...
 

Protected Types

typedef std::unordered_map< int, CUICommand * > TIDToCommand
 

Protected Attributes

TCmdID m_NextID
 
TIDToCommand m_IDToCommand
 
vector< wxAcceleratorEntry > m_AccelEntries
 

Static Protected Attributes

static CUICommandRegistry sm_TheRegistry
 CUICommandRegistry. More...
 

Private Member Functions

 CUICommandRegistry (const CUICommandRegistry &)
 
CUICommandRegistryoperator= (const CUICommandRegistry &)
 

Detailed Description

CUICommandRegistry is a centralized registry where all application commands should be registered.

The purpose of the registry is to provide completed, consistent and non-redundant information on application commands, their labels, tooltips, icons and other attributes. Application components shall use CUICommandRegistry for constructing menus, toolbars and other command-based UI components. Components adding new commands to the application shall register them in CUICommandRegistry.

Definition at line 145 of file ui_command.hpp.

Member Typedef Documentation

◆ TIDToCommand

typedef std::unordered_map<int, CUICommand*> CUICommandRegistry::TIDToCommand
protected

Definition at line 200 of file ui_command.hpp.

Constructor & Destructor Documentation

◆ CUICommandRegistry() [1/2]

CUICommandRegistry::CUICommandRegistry ( TCmdID  start_id)

Definition at line 182 of file ui_command.cpp.

◆ ~CUICommandRegistry()

CUICommandRegistry::~CUICommandRegistry ( )
virtual

Definition at line 189 of file ui_command.cpp.

References m_IDToCommand, and NON_CONST_ITERATE.

◆ CUICommandRegistry() [2/2]

CUICommandRegistry::CUICommandRegistry ( const CUICommandRegistry )
private

Member Function Documentation

◆ AddAccelerator()

void CUICommandRegistry::AddAccelerator ( const wxAcceleratorEntry &  entry)

◆ AppendMenuItem() [1/2]

wxMenuItem * CUICommandRegistry::AppendMenuItem ( wxMenu &  menu,
TCmdID  cmd_id 
) const

◆ AppendMenuItem() [2/2]

wxMenuItem * CUICommandRegistry::AppendMenuItem ( wxMenu &  menu,
TCmdID  cmd_id,
wxItemKind  kind 
) const

Definition at line 308 of file ui_command.cpp.

References _ASSERT, cmd, ERR_POST, FindCommandByID(), and NULL.

◆ AppendMenuItems() [1/2]

void CUICommandRegistry::AppendMenuItems ( wxMenu &  menu,
const TCmdID cmd_ids,
int  count 
) const

Definition at line 330 of file ui_command.cpp.

References AppendMenuItem(), count, and i.

Referenced by CProjectTreePanel::x_GetContextMenu().

◆ AppendMenuItems() [2/2]

void CUICommandRegistry::AppendMenuItems ( wxMenu &  menu,
const vector< TCmdID cmd_ids 
) const

Definition at line 339 of file ui_command.cpp.

References AppendMenuItem(), and i.

◆ AppendTool() [1/2]

void CUICommandRegistry::AppendTool ( wxAuiToolBar &  tool_bar,
TCmdID  cmd_id 
)

Definition at line 475 of file ui_command.cpp.

References _ASSERT, cmd, ERR_POST, m_IDToCommand, ToWxString(), and wxT.

◆ AppendTool() [2/2]

void CUICommandRegistry::AppendTool ( wxToolBar &  tool_bar,
TCmdID  cmd_id 
)

◆ ApplyAccelerators()

void CUICommandRegistry::ApplyAccelerators ( wxWindow *  frame)

apply accumulated accelerators to the specifed frame

Definition at line 281 of file ui_command.cpp.

References _ASSERT, entries, ERR_POST, int, m_AccelEntries, and n.

Referenced by CFloatingFrame::CFloatingFrame(), and CViewManagerService::x_RegisterExtensionFactories().

◆ CreateMenu()

wxMenu * CUICommandRegistry::CreateMenu ( const SwxMenuItemRec items)

create a menu from a static definition (see WX_*_MENU macros)

creates hierarchy of wxMenuItem objects from the array of SwxMenuItemRec descriptors

Definition at line 349 of file ui_command.cpp.

References _ASSERT, AppendMenuItem(), SwxMenuItemRec::eCheckItem, SwxMenuItemRec::eDefaultItem, SwxMenuItemRec::eNormalItem, SwxMenuItemRec::eRadioItem, SwxMenuItemRec::eSeparator, SStaticPair< FirstType, SecondType >::first, SwxMenuItemRec::IsMenuEnd(), SwxMenuItemRec::IsSubMenu(), SwxMenuItemRec::IsSubMenuEnd(), SwxMenuItemRec::m_CommandID, SwxMenuItemRec::m_Label, SwxMenuItemRec::m_Type, NULL, RunningInsideNCBI(), SStaticPair< FirstType, SecondType >::second, ToWxString(), and wxID_ANY.

Referenced by CBioseqEditor::CreateBioseqMenu(), CBioseqEditor::CreateContextMenu(), CreateContextMenuBackbone(), CAlignmentAssistant::CreateControls(), CEditSequence::CreateControls(), CwxGridTableAdapter::CreateMenu(), CFlatFileViewContext::CreateMenu(), CDesktopViewContext::CreateMenu(), CFastaViewContext::CreateMenu(), CFrameworkDemoGUI::GetMenu(), IMenuContributor::GetMenu(), CWindowManager::GetMenu(), CPhyloTreeWidget::OnContextMenu(), CDataMiningPanel::OnContextMenu(), CProjectTreePanel::OnContextMenu(), CCrossAlnWidget::OnContextMenu(), CHitMatrixWidget::OnContextMenu(), CTextItemPanel::OnContextMenu(), CTooltipFrame::OnContextMenu(), CFlatFileViewContext::OnEditBioseq(), CSeqTextWidget::OnShowPopup(), CProjectView::x_CreateContextMenuBackbone(), CSeqTableGridPanel::x_CreateMenu(), CMultiAlignView::x_CreateMenuBarMenu(), CAlnMultiWidget::x_CreatePopupMenu(), and CSeqGraphicWidget::x_CreatePopupMenu().

◆ FindCommandByID()

const CUICommand * CUICommandRegistry::FindCommandByID ( TCmdID  cmd_id) const

returns CUICommand object or NULL

Definition at line 257 of file ui_command.cpp.

References m_IDToCommand, and NULL.

Referenced by AppendMenuItem().

◆ FindCommandByName()

const CUICommand * CUICommandRegistry::FindCommandByName ( string  name) const

It is expensive function so use it wisely.

Definition at line 263 of file ui_command.cpp.

References ITERATE, m_IDToCommand, and NULL.

◆ GetInstance()

CUICommandRegistry & CUICommandRegistry::GetInstance ( void  )
static

the main instance associated with the application

Definition at line 176 of file ui_command.cpp.

References sm_TheRegistry.

Referenced by AddCommandsForScopedObjects(), CDiagConsoleList::AppendMenuItems(), CwxTableListCtrl::AppendMenuItems(), CFloatingFrame::CFloatingFrame(), CBioseqEditor::CreateBioseqMenu(), CBioseqEditor::CreateContextMenu(), CreateContextMenuBackbone(), CAlignmentAssistant::CreateControls(), CEditSequence::CreateControls(), CUpdateSeqPanel::CreateControls(), CAlignMultipleDemoDlg::CreateControls(), CwxGridTableAdapter::CreateMenu(), CFlatFileViewContext::CreateMenu(), CDesktopViewContext::CreateMenu(), CFastaViewContext::CreateMenu(), CwxGridTableAdapter::CwxGridTableAdapter(), CDockManager::GetDockPanelMenu(), CFrameworkDemoGUI::GetMenu(), IMenuContributor::GetMenu(), CWindowManager::GetMenu(), CNetBLASTUIDataSource::GetMenu(), CLBLASTUIDataSource::GetMenu(), CBamUIDataSource::GetMenu(), CGenBankUIDataSource::GetMenu(), CWorkbench::GetUICommandRegistry(), CWorkbench::Init(), CCrossAlnDemoDlg::Init(), CPhyloTreeDemoDlg::Init(), CSeqGraphicDemoDlg::Init(), CSeqTextDemoDlg::Init(), CGraphOverlay::LH_OnItemRightClick(), CPhyloTreeWidget::OnContextMenu(), CCrossAlnWidget::OnContextMenu(), CHitMatrixWidget::OnContextMenu(), CTextItemPanel::OnContextMenu(), CMinPanelContainer::OnContextMenu(), CTooltipFrame::OnContextMenu(), CFlatFileViewContext::OnEditBioseq(), CGraphicPanel::OnHelpClick(), CSeqTextWidget::OnShowPopup(), CStickyTooltipHandler::RegisterCommands(), CSeqTableGridPanel::x_CreateMenu(), CProjectViewToolBatFactory::x_CreateNavigationToolbar(), CAlnMultiWidget::x_CreatePopupMenu(), CSeqGraphicWidget::x_CreatePopupMenu(), CProjectViewToolBatFactory::x_CreateSelectionToolbar(), CGraphicPanel::x_CreateToolbar(), CProjectTreePanel::x_GetContextMenu(), CAlignPackage::x_RegisterCommands(), CSeqPackage::x_RegisterCommands(), and CSeqTableGridPanel::x_SetUpMenu().

◆ operator=()

CUICommandRegistry& CUICommandRegistry::operator= ( const CUICommandRegistry )
private

◆ RegisterCommand() [1/2]

int CUICommandRegistry::RegisterCommand ( CUICommand cmd)

◆ RegisterCommand() [2/2]

int CUICommandRegistry::RegisterCommand ( TCmdID  cmd_id,
string  menu_label,
string  label,
string  icon_alias,
string  hint = kEmptyStr,
string  description = kEmptyStr,
string  help_id = kEmptyStr,
wxItemKind  kind = wxITEM_NORMAL 
)

create a CUICommand and registers it

Definition at line 238 of file ui_command.cpp.

References cmd, eCmdInvalid, label, and RegisterCommand().

Member Data Documentation

◆ m_AccelEntries

vector<wxAcceleratorEntry> CUICommandRegistry::m_AccelEntries
protected

Definition at line 208 of file ui_command.hpp.

Referenced by AddAccelerator(), and ApplyAccelerators().

◆ m_IDToCommand

TIDToCommand CUICommandRegistry::m_IDToCommand
protected

◆ m_NextID

TCmdID CUICommandRegistry::m_NextID
protected

Definition at line 204 of file ui_command.hpp.

Referenced by RegisterCommand().

◆ sm_TheRegistry

CUICommandRegistry CUICommandRegistry::sm_TheRegistry
staticprotected

CUICommandRegistry.

Definition at line 202 of file ui_command.hpp.

Referenced by GetInstance().


The documentation for this class was generated from the following files:
Modified on Wed Sep 04 15:00:42 2024 by modify_doxy.py rev. 669887