2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: accel.h
|
2008-03-09 13:42:34 -04:00
|
|
|
// Purpose: interface of wxAccelerator* classes
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-03-09 13:42:34 -04:00
|
|
|
|
|
|
|
/** wxAcceleratorEntry flags */
|
|
|
|
enum wxAcceleratorEntryFlags
|
|
|
|
{
|
|
|
|
/** no modifiers */
|
|
|
|
wxACCEL_NORMAL,
|
|
|
|
|
|
|
|
/** hold Alt key down */
|
|
|
|
wxACCEL_ALT,
|
|
|
|
|
|
|
|
/** hold Ctrl key down */
|
|
|
|
wxACCEL_CTRL,
|
|
|
|
|
|
|
|
/** hold Shift key down */
|
|
|
|
wxACCEL_SHIFT,
|
|
|
|
|
|
|
|
/** Command key on OS X; identic to wxACCEL_CTRL on other platforms. */
|
|
|
|
wxACCEL_CMD
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxAcceleratorEntry
|
|
|
|
@wxheader{accel.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-09 13:42:34 -04:00
|
|
|
An object used by an application wishing to create an accelerator table
|
|
|
|
(see wxAcceleratorTable).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-03-10 11:19:31 -04:00
|
|
|
@category{misc}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:19:31 -04:00
|
|
|
@see wxAcceleratorTable, wxWindow::SetAcceleratorTable
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxAcceleratorEntry
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
2008-03-09 13:42:34 -04:00
|
|
|
/**
|
|
|
|
Default ctor.
|
|
|
|
*/
|
|
|
|
wxAcceleratorEntry();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructor.
|
2008-03-09 13:42:34 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param flags
|
2008-03-09 13:42:34 -04:00
|
|
|
A combination of the wxAcceleratorEntryFlags values, which
|
|
|
|
indicates which modifier keys are held down.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param keyCode
|
2008-03-09 13:42:34 -04:00
|
|
|
The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param cmd
|
2008-03-09 08:33:59 -04:00
|
|
|
The menu or control command identifier.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxAcceleratorEntry(int flags, int keyCode, int cmd);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the command identifier for the accelerator table entry.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetCommand() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the flags for the accelerator table entry.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetFlags() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the keycode for the accelerator table entry.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetKeyCode() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the accelerator entry parameters.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param flags
|
2008-03-09 13:42:34 -04:00
|
|
|
A combination of the wxAcceleratorEntryFlags values, which
|
|
|
|
indicates which modifier keys are held down.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param keyCode
|
2008-03-09 13:42:34 -04:00
|
|
|
The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param cmd
|
2008-03-09 08:33:59 -04:00
|
|
|
The menu or control command identifier.
|
2008-03-09 13:42:34 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void Set(int flags, int keyCode, int cmd);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxAcceleratorTable
|
|
|
|
@wxheader{accel.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
An accelerator table allows the application to specify a table of keyboard
|
2008-03-18 12:21:15 -04:00
|
|
|
shortcuts for menu or button commands.
|
2008-03-09 13:42:34 -04:00
|
|
|
|
2008-03-10 11:19:31 -04:00
|
|
|
The object ::wxNullAcceleratorTable is defined to be a table with no data, and
|
2008-03-09 13:42:34 -04:00
|
|
|
is the initial accelerator table for a window.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
@code
|
|
|
|
wxAcceleratorEntry entries[4];
|
|
|
|
entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
|
|
|
|
entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
|
|
|
|
entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
|
|
|
|
entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
|
|
|
|
|
|
|
|
wxAcceleratorTable accel(4, entries);
|
|
|
|
frame->SetAcceleratorTable(accel);
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-09 13:42:34 -04:00
|
|
|
@remarks
|
|
|
|
An accelerator takes precedence over normal processing and can be a convenient
|
|
|
|
way to program some event handling. For example, you can use an accelerator table
|
|
|
|
to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
|
2008-03-20 09:19:55 -04:00
|
|
|
'OK'.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{misc}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@stdobjects
|
2008-03-10 11:19:31 -04:00
|
|
|
::wxNullAcceleratorTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:19:31 -04:00
|
|
|
@see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxAcceleratorTable : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-03-09 13:42:34 -04:00
|
|
|
Default ctor.
|
|
|
|
*/
|
|
|
|
wxAcceleratorTable();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes the accelerator table from an array of wxAcceleratorEntry.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param n
|
2008-03-09 08:33:59 -04:00
|
|
|
Number of accelerator entries.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param entries
|
2008-03-09 08:33:59 -04:00
|
|
|
The array of entries.
|
2008-03-09 13:42:34 -04:00
|
|
|
*/
|
|
|
|
wxAcceleratorTable(int n, wxAcceleratorEntry entries[]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Loads the accelerator table from a Windows resource (Windows only).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param resource
|
2008-03-09 08:33:59 -04:00
|
|
|
Name of a Windows accelerator.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxAcceleratorTable(const wxString& resource);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destroys the wxAcceleratorTable object.
|
2008-03-09 13:42:34 -04:00
|
|
|
See @ref overview_refcount_destruct for more info.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
~wxAcceleratorTable();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the accelerator table is valid.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-09 13:42:34 -04:00
|
|
|
Assignment operator, using @ref overview_refcount "reference counting".
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param accel
|
2008-03-09 08:33:59 -04:00
|
|
|
Accelerator table to assign.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxAcceleratorTable operator =(const wxAcceleratorTable& accel);
|
|
|
|
};
|
2008-03-09 13:42:34 -04:00
|
|
|
|
2008-03-14 11:35:10 -04:00
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2008-03-09 13:42:34 -04:00
|
|
|
/**
|
|
|
|
An empty accelerator table.
|
|
|
|
*/
|
|
|
|
wxAcceleratorTable wxNullAcceleratorTable;
|