]>
Commit | Line | Data |
---|---|---|
110f3205 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: accel.h | |
3 | // Purpose: wxAcceleratorTable class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 31/7/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
c50f1fb9 | 9 | // Licence: wxWindows licence |
110f3205 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_ACCEL_H_ | |
13 | #define _WX_ACCEL_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
c50f1fb9 | 16 | #pragma interface "accel.h" |
110f3205 JS |
17 | #endif |
18 | ||
19 | #include "wx/object.h" | |
20 | ||
21 | class WXDLLEXPORT wxAcceleratorTable; | |
22 | ||
c50f1fb9 VZ |
23 | // ---------------------------------------------------------------------------- |
24 | // constants | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
110f3205 JS |
27 | // Hold Ctrl key down |
28 | #define wxACCEL_ALT 0x01 | |
29 | ||
30 | // Hold Ctrl key down | |
31 | #define wxACCEL_CTRL 0x02 | |
32 | ||
33 | // Hold Shift key down | |
34 | #define wxACCEL_SHIFT 0x04 | |
35 | ||
7a11869d JS |
36 | // Hold no other key |
37 | #define wxACCEL_NORMAL 0x00 | |
38 | ||
c50f1fb9 VZ |
39 | // ---------------------------------------------------------------------------- |
40 | // an entry in wxAcceleratorTable corresponds to one accelerator | |
41 | // ---------------------------------------------------------------------------- | |
42 | ||
110f3205 JS |
43 | class WXDLLEXPORT wxAcceleratorEntry |
44 | { | |
45 | public: | |
46 | wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0) | |
47 | { | |
c50f1fb9 | 48 | Set(flags, keyCode, cmd); |
110f3205 JS |
49 | } |
50 | ||
c50f1fb9 VZ |
51 | void Set(int flags, int keyCode, int cmd) |
52 | { | |
53 | m_flags = flags; m_keyCode = keyCode; m_command = cmd; | |
54 | } | |
110f3205 | 55 | |
c50f1fb9 VZ |
56 | int GetFlags() const { return m_flags; } |
57 | int GetKeyCode() const { return m_keyCode; } | |
58 | int GetCommand() const { return m_command; } | |
110f3205 | 59 | |
c50f1fb9 VZ |
60 | //private: |
61 | int m_flags; | |
62 | int m_keyCode; // ASCII or virtual keycode | |
63 | int m_command; // Command id to generate | |
110f3205 JS |
64 | }; |
65 | ||
c50f1fb9 VZ |
66 | // ---------------------------------------------------------------------------- |
67 | // the accel table has all accelerators for a given window or menu | |
68 | // ---------------------------------------------------------------------------- | |
69 | ||
70 | class WXDLLEXPORT wxAcceleratorTable : public wxObject | |
110f3205 JS |
71 | { |
72 | DECLARE_DYNAMIC_CLASS(wxAcceleratorTable) | |
73 | public: | |
74 | wxAcceleratorTable(); | |
75 | wxAcceleratorTable(const wxString& resource); // Load from .rc resource | |
10310d83 | 76 | wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]); // Load from array |
110f3205 JS |
77 | |
78 | // Copy constructors | |
c50f1fb9 VZ |
79 | wxAcceleratorTable(const wxAcceleratorTable& accel) |
80 | { Ref(accel); } | |
110f3205 JS |
81 | |
82 | ~wxAcceleratorTable(); | |
83 | ||
c50f1fb9 VZ |
84 | wxAcceleratorTable& operator = (const wxAcceleratorTable& accel) |
85 | { if ( *this != accel ) Ref(accel); return *this; } | |
110f3205 | 86 | |
c50f1fb9 VZ |
87 | bool operator == (const wxAcceleratorTable& accel) const |
88 | { return m_refData == accel.m_refData; } | |
89 | bool operator != (const wxAcceleratorTable& accel) const | |
90 | { return m_refData != accel.m_refData; } | |
91 | ||
92 | bool Ok() const; | |
110f3205 JS |
93 | void SetHACCEL(WXHACCEL hAccel); |
94 | WXHACCEL GetHACCEL() const; | |
c50f1fb9 VZ |
95 | |
96 | // translate the accelerator, return TRUE if done | |
97 | bool Translate(wxWindow *window, WXMSG *msg) const; | |
110f3205 JS |
98 | }; |
99 | ||
100 | WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable; | |
101 | ||
102 | #endif | |
103 | // _WX_ACCEL_H_ |