NCBI C++ ToolKit
commands.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: commands.cpp 43842 2019-09-09 21:57:24Z evgeniev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
39 
40 #include <wx/defs.h>
41 #include <wx/accel.h>
42 
44 
45 
47 {
48  // Register standard wxWidgets commands ///////////////////////////////////
49 
50  //cmd_reg.RegisterCommand(wxID_, "", "", "", "");
51 
52  CUICommand* cmd = 0;
53 
54  // File
55  cmd_reg.RegisterCommand(wxID_PRINT, "&Print...", "Print", "menu::print", "Print current view");
56  cmd_reg.RegisterCommand(wxID_EXIT, "E&xit\tAlt+X", "Exit", "", "Exit application");
57 
58  // Edit
59  cmd = new CUICommand(wxID_UNDO, "&Undo\tCtrl+Z", "Undo", "menu::undo", "Undo the last editing command");
60  cmd->AddAccelerator(wxACCEL_CTRL, 'Z');
61  cmd_reg.RegisterCommand(cmd);
62 
63  cmd = new CUICommand(wxID_REDO, "&Redo\tCtrl+Y", "Redo", "menu::redo", "Redo the last editing command");
64  cmd->AddAccelerator(wxACCEL_CTRL, 'Y');
65  cmd_reg.RegisterCommand(cmd);
66 
67  cmd_reg.RegisterCommand(wxID_REMOVE, "&Remove", "Remove", "", "Remove selected items");
68 
69  // On mac the 'delete' key works as the backspace key, and this is the usual key
70  // for deleting items such as deleting a file from the list.
71 #ifdef __WXMAC__
72  cmd_reg.RegisterCommand(wxID_DELETE, "&Delete\tCtrl+Back", "Delete", "menu::delete", "Delete selected items");
73 #else
74  cmd_reg.RegisterCommand(wxID_DELETE, "&Delete\tCtrl+Del", "Delete", "menu::delete", "Delete selected items");
75 #endif
76 
77  cmd_reg.RegisterCommand(wxID_FIND, "&Find...\tCtrl+F", "Find...", "", "Find");
78 
79  cmd = new CUICommand(wxID_SELECTALL, "Select A&ll\tCtrl+A", "Select All", "", "Select All");
80  cmd->AddAccelerator(wxACCEL_CTRL, 'A');
81  cmd_reg.RegisterCommand(cmd);
82 
83  cmd_reg.RegisterCommand(wxID_CLEAR, "Cle&ar", "Clear", "", "Clear selection");
84 
85  // Clipboard command
86  cmd = new CUICommand(wxID_CUT, "Cu&t\tCtrl+X", "Cut", "menu::cut", "Cut selection to Clipboard");
87  cmd->AddAccelerator(wxACCEL_SHIFT, WXK_DELETE);
88  cmd_reg.RegisterCommand(cmd);
89 
90  cmd = new CUICommand(wxID_COPY, "&Copy\tCtrl+C", "Copy", "menu::copy", "Copy selection to Clipboard");
91  cmd->AddAccelerator(wxACCEL_CTRL, WXK_INSERT);
92  cmd->AddAccelerator(wxACCEL_CTRL, 'C');
93  cmd_reg.RegisterCommand(cmd);
94 
95  cmd = new CUICommand(wxID_PASTE, "&Paste\tCtrl+V", "Paste", "menu::paste", "Paste from Clipboard");
96  cmd->AddAccelerator(wxACCEL_SHIFT, WXK_INSERT);
97  cmd_reg.RegisterCommand(cmd);
98 
99  cmd_reg.RegisterCommand(wxID_PROPERTIES, "&Properties...", "Properties...",
100  "menu::properties", "Show Properties dialog");
101 
102  // Help
103  cmd_reg.RegisterCommand(wxID_HELP_SEARCH, "&Search", "Search", "", "Search in Help");
104  cmd_reg.RegisterCommand(wxID_HELP_CONTENTS, "&Contents", "Contents", "", "Show Help contents");
105  cmd_reg.RegisterCommand(wxID_HELP_INDEX, "&Index", "Index", "", "Show Help Index");
106 
107  // Register standard GUI NCBI commands /////////////////////////////////////////////////
108  cmd_reg.RegisterCommand(eCmdZoomIn, "Zoom In\tCtrl++", "Zoom In", "menu::zoom_in", "Zoom In");
109  cmd_reg.RegisterCommand(eCmdZoomOut, "Zoom Out\tCtrl+-", "Zoom Out", "menu::zoom_out", "Zoom Out");
110 
111  cmd = new CUICommand(eCmdZoomAll, "Zoom All", "Zoom All", "menu::zoom_all", "Zoom All");
112  cmd_reg.RegisterCommand(cmd);
113 
114  cmd_reg.RegisterCommand(eCmdZoomSel, "Zoom to Selection", "Zoom to Selection",
115  "menu::zoom_sel", "Zoom to Selection");
116  cmd_reg.RegisterCommand(eCmdZoomSelObjects, "Zoom to Selected Objects", "Zoom to Selected Objects",
117  "", "Zoom to Selected Objects");
118  cmd_reg.RegisterCommand(eCmdZoomSeq, "Zoom to Sequence", "Zoom to Sequence",
119  "menu::zoom_seq", "Zoom to Sequence");
120  cmd_reg.RegisterCommand(eCmdZoomObjects, "Zoom to Data", "Zoom to Data",
121  "", "Adjust views so that all data objects are visible");
122 
123  cmd_reg.RegisterCommand(eCmdZoomInX, "Zoom In X", "Zoom In X", "", "Zoom In horizontally");
124  cmd_reg.RegisterCommand(eCmdZoomOutX, "Zoom Out X", "Zoom Out X", "", "Zoom Out horizontally");
125  cmd_reg.RegisterCommand(eCmdZoomAllX, "Zoom All X", "Zoom All X", "", "Zoom All horizontally");
126 
127  cmd_reg.RegisterCommand(eCmdZoomInY, "Zoom In Y", "Zoom In Y", "", "Zoom In vertically");
128  cmd_reg.RegisterCommand(eCmdZoomOutY, "Zoom Out Y", "Zoom Out Y", "", "Zoom Out vertically");
129  cmd_reg.RegisterCommand(eCmdZoomAllY, "Zoom All Y", "Zoom All Y", "", "Zoom All vertically");
130 
131  // command ids for using in context menus only
132  cmd_reg.RegisterCommand(eCmdZoomInMouse, "Zoom In", "Zoom In", "menu::zoom_in", "Zoom In");
133  cmd_reg.RegisterCommand(eCmdZoomOutMouse, "Zoom Out", "Zoom Out", "menu::zoom_out", "Zoom Out");
134 
135  cmd_reg.RegisterCommand(eCmdSetEqualScale, "Make Proportional", "Make Proportional",
136  "", "Adjust view so that horizontal and vertical scales are sequal");
137 
138  cmd_reg.RegisterCommand(eCmdSettings, "Settings...", "Settings", "", "Shows \"Settings\" dialog");
139  cmd_reg.RegisterCommand(eCmdConfigureTracks, "Tracks...", "Tracks...", "menu::configure", "Shows \"Configure Tracks\" dialog");
140 
141  cmd_reg.RegisterCommand(eCmdWebHelpApp, "All Help Topics", "All Help Topics", "", "Launch Application Help");
142  cmd_reg.RegisterCommand(eCmdSubmissionsWebHelp, "NCBI GenBank Submissions", "NCBI GenBank Submissions", "", "Launch NCBI GenBank Submissions Help");
143  cmd_reg.RegisterCommand(eCmdWebHelpGSVNavigation, "Graphical View Navigation", "Graphical View Navigation", "", "Launch Graphical View Navigation Help");
144  cmd_reg.RegisterCommand(eCmdWebHelpGSVInteractionGuide, "Interaction Guide", "Interaction Guide", "", "Launch Interaction Guide Help");
145  cmd_reg.RegisterCommand(eCmdWebHelpGSVLegends, "Graphical Legends", "Graphical Legends", "", "Launch Graphical Legends Help");
146 
147  cmd_reg.RegisterCommand(eCmdResetSelection, "Reset Selection", "Reset Selection",
148  "", "Resets current selection");
149 
150  /// Register Mavigation commands
151  cmd_reg.RegisterCommand(eCmdBack, "Back", "Back", "menu::back", "Go Back");
152  cmd_reg.RegisterCommand(eCmdForward, "Forward", "Forward", "menu::forward", "Go Forward");
153 
155  "Go to Sequence Position/Range...", "Go to Sequence Position or Range", "", "");
156 
157  /// Window Manager commands
158  cmd_reg.RegisterCommand(eCmdSetClientColor, "Change Color...", "Change Color", "", "");
159  cmd_reg.RegisterCommand(eCmdShowWindowsDlg, "&Windows...", "View List Dialog", "menu::viewer_item", "Shows View List Dialog");
160 
161  cmd_reg.RegisterCommand(eCmdCloseDockPanel, "Close", "Close", "menu::win_close", "");
162  cmd_reg.RegisterCommand(eCmdMoveToMainTab, "&Reset", "Reset", "", "");
163  cmd_reg.RegisterCommand(eCmdWindowFloat, "&Float", "Float", "", "");
164  cmd_reg.RegisterCommand(eCmdWindowMinimize, "&Minimize", "Minimize", "menu::win_minimize", "");
165  cmd_reg.RegisterCommand(eCmdWindowRestore, "&Restore", "Restore", "menu::win_restore", "");
166 
167  cmd_reg.RegisterCommand(eCmdSaveImages, "Save Images...", "Save Images...",
168  "", "Saves the current view as one or more images");
169  cmd_reg.RegisterCommand(eCmdSavePdf, "Save As PDF...", "Save As PDF...", "", "Saves the current view as a PDF file");
170  cmd_reg.RegisterCommand(eCmdSaveSvg, "Save As SVG...", "Save As SVG...", "", "Saves the current view as a Scalable Vector Graphics (.SVG) file");
171 
172  provider.RegisterFileAlias(wxT("menu::print"), wxT("print.png"));
173 
174  provider.RegisterFileAlias(wxT("menu::zoom_in"), wxT("zoom_in.png"));
175  provider.RegisterFileAlias(wxT("menu::zoom_out"), wxT("zoom_out.png"));
176  provider.RegisterFileAlias(wxT("menu::zoom_all"), wxT("zoom_all.png"));
177  provider.RegisterFileAlias(wxT("menu::zoom_seq"), wxT("zoom_seq.png"));
178  provider.RegisterFileAlias(wxT("menu::zoom_sel"), wxT("zoom_sel.png"));
179 
180  provider.RegisterFileAlias(wxT("menu::configure"), wxT("configure.png"));
181 
182  provider.RegisterFileAlias(wxT("menu::undo"), wxT("undo.png"));
183  provider.RegisterFileAlias(wxT("menu::redo"), wxT("redo.png"));
184 
185  provider.RegisterFileAlias(wxT("menu::cut"), wxT("cut.png"));
186  provider.RegisterFileAlias(wxT("menu::copy"), wxT("copy.png"));
187  provider.RegisterFileAlias(wxT("menu::paste"), wxT("paste.png"));
188  provider.RegisterFileAlias(wxT("menu::properties"), wxT("properties.png"));
189 
190  provider.RegisterFileAlias(wxT("menu::back"), wxT("back.png"));
191  provider.RegisterFileAlias(wxT("menu::forward"), wxT("forward.png"));
192 
193  provider.RegisterFileAlias(wxT("menu::win_minimize"), wxT("wm_menu_minimize.png"));
194  provider.RegisterFileAlias(wxT("menu::win_restore"), wxT("wm_menu_restore.png"));
195  provider.RegisterFileAlias(wxT("menu::win_close"), wxT("wm_menu_close.png"));
196 
197  provider.RegisterFileAlias(wxT("menu::viewer_item"), wxT("viewer_item.png"));
198 }
199 
200 
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
int RegisterCommand(CUICommand *cmd)
assumes ownership of the given object returns a command id (useful when registry is used for auto id ...
Definition: ui_command.cpp:198
CUICommand.
Definition: ui_command.hpp:79
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
@ eCmdWindowFloat
Definition: dock_panel.hpp:56
@ eCmdCloseDockPanel
Definition: dock_panel.hpp:54
@ eCmdMoveToMainTab
Definition: dock_panel.hpp:55
@ eCmdWindowMinimize
Definition: dock_panel.hpp:57
@ eCmdWindowRestore
Definition: dock_panel.hpp:58
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
@ eCmdZoomOutX
Definition: command.hpp:78
@ eCmdConfigureTracks
Definition: command.hpp:86
@ eCmdZoomAllX
Definition: command.hpp:79
@ eCmdZoomInMouse
Definition: command.hpp:71
@ eCmdSettings
Definition: command.hpp:85
@ eCmdForward
Definition: command.hpp:101
@ eCmdResetSelection
Definition: command.hpp:97
@ eCmdZoomOutMouse
Definition: command.hpp:72
@ eCmdSubmissionsWebHelp
Definition: command.hpp:91
@ eCmdZoomOutY
Definition: command.hpp:81
@ eCmdSaveSvg
Definition: command.hpp:108
@ eCmdZoomInX
Definition: command.hpp:77
@ eCmdSaveImages
Definition: command.hpp:106
@ eCmdWebHelpGSVLegends
Definition: command.hpp:94
@ eCmdZoomIn
empty command
Definition: command.hpp:68
@ eCmdWebHelpApp
Definition: command.hpp:90
@ eCmdSavePdf
Definition: command.hpp:107
@ eCmdSeqGoto
goto sequence position
Definition: command.hpp:104
@ eCmdZoomAllY
Definition: command.hpp:82
@ eCmdZoomSelObjects
Definition: command.hpp:76
@ eCmdZoomOut
Definition: command.hpp:69
@ eCmdSetEqualScale
Definition: command.hpp:83
@ eCmdZoomSeq
Zoom to Selection.
Definition: command.hpp:74
@ eCmdZoomInY
Definition: command.hpp:80
@ eCmdWebHelpGSVInteractionGuide
Definition: command.hpp:93
@ eCmdZoomAll
Definition: command.hpp:70
@ eCmdBack
Navigation commands.
Definition: command.hpp:100
@ eCmdZoomObjects
Zoom to Sequence.
Definition: command.hpp:75
@ eCmdWebHelpGSVNavigation
Definition: command.hpp:92
@ eCmdZoomSel
Definition: command.hpp:73
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
@ eCmdSetClientColor
@ eCmdShowWindowsDlg
#define wxT(x)
Definition: muParser.cpp:41
void WidgetsWx_RegisterCommands(CUICommandRegistry &cmd_reg, wxFileArtProvider &provider)
Register standard commands defined in this file and wxWidgets headers.
Definition: commands.cpp:46
Modified on Tue May 21 10:59:55 2024 by modify_doxy.py rev. 669887