1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     interface of wxAccelerator* classes 
   4 // Author:      wxWidgets team 
   6 // Licence:     wxWindows license 
   7 ///////////////////////////////////////////////////////////////////////////// 
  10 /** wxAcceleratorEntry flags */ 
  11 enum wxAcceleratorEntryFlags
 
  16     /** hold Alt key down */ 
  19     /** hold Ctrl key down */ 
  22     /** hold Shift key down */ 
  25     /** Command key on OS X; identic to wxACCEL_CTRL on other platforms. */ 
  31     @class wxAcceleratorEntry 
  33     An object used by an application wishing to create an accelerator table 
  34     (see wxAcceleratorTable). 
  39     @see wxAcceleratorTable, wxWindow::SetAcceleratorTable 
  41 class wxAcceleratorEntry
 
  48             A combination of the wxAcceleratorEntryFlags values, which 
  49             indicates which modifier keys are held down. 
  51             The keycode to be detected. See @ref page_keycodes for a full list of keycodes. 
  53             The menu or control command identifier (ID). 
  55             The menu item associated with this accelerator. 
  57     wxAcceleratorEntry(int flags 
= 0, int keyCode 
= 0, int cmd 
= 0, 
  58                        wxMenuItem 
*item 
= NULL
); 
  63     wxAcceleratorEntry(const wxAcceleratorEntry
& entry
); 
  66         Returns the command identifier for the accelerator table entry. 
  68     int GetCommand() const; 
  71         Returns the flags for the accelerator table entry. 
  76         Returns the keycode for the accelerator table entry. 
  78     int GetKeyCode() const; 
  81         Returns the menu item associated with this accelerator entry. 
  83     wxMenuItem 
*GetMenuItem() const; 
  86         Sets the accelerator entry parameters. 
  89             A combination of the wxAcceleratorEntryFlags values, which 
  90             indicates which modifier keys are held down. 
  92             The keycode to be detected. See @ref page_keycodes for a full list of keycodes. 
  94             The menu or control command identifier (ID). 
  96             The menu item associated with this accelerator. 
  98     void Set(int flags
, int keyCode
, int cmd
, wxMenuItem 
*item 
= NULL
); 
 101         Returns @true if this object is correctly initialized. 
 106         Returns a wxString for this accelerator. 
 107         This function formats it using the @c "flags-keycode" format 
 108         where @c flags maybe a hyphen-separed list of @c "shift|alt|ctrl". 
 110     wxString 
ToString() const; 
 113         Parses the given string and sets the accelerator accordingly. 
 116             Should be a string in the form "flags-keycode" 
 118         @return @true if the given string correctly initialized this object 
 119                 (i.e. if IsOk() returns true after this call) 
 121     bool FromString(const wxString
& str
); 
 124     wxAcceleratorEntry
& operator=(const wxAcceleratorEntry
& entry
); 
 125     bool operator==(const wxAcceleratorEntry
& entry
) const; 
 126     bool operator!=(const wxAcceleratorEntry
& entry
) const; 
 131     @class wxAcceleratorTable 
 133     An accelerator table allows the application to specify a table of keyboard 
 134     shortcuts for menu or button commands. 
 136     The object ::wxNullAcceleratorTable is defined to be a table with no data, and 
 137     is the initial accelerator table for a window. 
 142     wxAcceleratorEntry entries[4]; 
 143     entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW); 
 144     entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT); 
 145     entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT); 
 146     entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT); 
 148     wxAcceleratorTable accel(4, entries); 
 149     frame->SetAcceleratorTable(accel); 
 153     An accelerator takes precedence over normal processing and can be a convenient 
 154     way to program some event handling. For example, you can use an accelerator table 
 155     to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning 
 162     ::wxNullAcceleratorTable 
 164     @see wxAcceleratorEntry, wxWindow::SetAcceleratorTable 
 166 class wxAcceleratorTable 
: public wxObject
 
 172     wxAcceleratorTable(); 
 175         Initializes the accelerator table from an array of wxAcceleratorEntry. 
 178             Number of accelerator entries. 
 180             The array of entries. 
 182     wxAcceleratorTable(int n
, const wxAcceleratorEntry entries
[]); 
 185         Loads the accelerator table from a Windows resource (Windows only). 
 190             Name of a Windows accelerator. 
 192     wxAcceleratorTable(const wxString
& resource
); 
 195         Destroys the wxAcceleratorTable object. 
 196         See @ref overview_refcount_destruct for more info. 
 198     virtual ~wxAcceleratorTable(); 
 201         Returns @true if the accelerator table is valid. 
 207 // ============================================================================ 
 208 // Global functions/macros 
 209 // ============================================================================ 
 212     An empty accelerator table. 
 214 wxAcceleratorTable wxNullAcceleratorTable
;