1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxAcceleratorTable class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "accel.h"
19 #include "wx/object.h"
21 class WXDLLEXPORT wxAcceleratorTable
;
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
28 #define wxACCEL_ALT 0x01
31 #define wxACCEL_CTRL 0x02
33 // Hold Shift key down
34 #define wxACCEL_SHIFT 0x04
37 #define wxACCEL_NORMAL 0x00
39 // ----------------------------------------------------------------------------
40 // an entry in wxAcceleratorTable corresponds to one accelerator
41 // ----------------------------------------------------------------------------
43 class WXDLLEXPORT wxAcceleratorEntry
46 wxAcceleratorEntry(int flags
= 0, int keyCode
= 0, int cmd
= 0)
48 Set(flags
, keyCode
, cmd
);
51 void Set(int flags
, int keyCode
, int cmd
)
53 m_flags
= flags
; m_keyCode
= keyCode
; m_command
= cmd
;
56 int GetFlags() const { return m_flags
; }
57 int GetKeyCode() const { return m_keyCode
; }
58 int GetCommand() const { return m_command
; }
62 int m_keyCode
; // ASCII or virtual keycode
63 int m_command
; // Command id to generate
66 // ----------------------------------------------------------------------------
67 // the accel table has all accelerators for a given window or menu
68 // ----------------------------------------------------------------------------
70 class WXDLLEXPORT wxAcceleratorTable
: public wxObject
72 DECLARE_DYNAMIC_CLASS(wxAcceleratorTable
)
75 wxAcceleratorTable(const wxString
& resource
); // Load from .rc resource
76 wxAcceleratorTable(int n
, const wxAcceleratorEntry entries
[]); // Load from array
79 inline wxAcceleratorTable(const wxAcceleratorTable
& accel
) { Ref(accel
); }
80 inline wxAcceleratorTable(const wxAcceleratorTable
* accel
) { if (accel
) Ref(*accel
); }
82 ~wxAcceleratorTable();
84 inline wxAcceleratorTable
& operator = (const wxAcceleratorTable
& accel
) { if ( *this != accel
) Ref(accel
); return *this; }
85 inline bool operator == (const wxAcceleratorTable
& accel
) const { return m_refData
== accel
.m_refData
; }
86 inline bool operator != (const wxAcceleratorTable
& accel
) const { return m_refData
!= accel
.m_refData
; }
89 void SetHACCEL(WXHACCEL hAccel
);
90 WXHACCEL
GetHACCEL() const;
92 // translate the accelerator, return TRUE if done
93 bool Translate(wxWindow
*window
, WXMSG
*msg
) const;
96 WXDLLEXPORT_DATA(extern wxAcceleratorTable
) wxNullAcceleratorTable
;