]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/accel.h
wxListCtrlCompare typedef now is defined correctly (was missing CALLBACK)
[wxWidgets.git] / include / wx / msw / accel.h
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_ACCEL_H_
13 #define _WX_ACCEL_H_
14
15 #ifdef __GNUG__
16 #pragma interface "accel.h"
17 #endif
18
19 #include "wx/object.h"
20
21 class WXDLLEXPORT wxAcceleratorTable;
22
23 // ----------------------------------------------------------------------------
24 // constants
25 // ----------------------------------------------------------------------------
26
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
36 // Hold no other key
37 #define wxACCEL_NORMAL 0x00
38
39 // ----------------------------------------------------------------------------
40 // an entry in wxAcceleratorTable corresponds to one accelerator
41 // ----------------------------------------------------------------------------
42
43 class WXDLLEXPORT wxAcceleratorEntry
44 {
45 public:
46 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0)
47 {
48 Set(flags, keyCode, cmd);
49 }
50
51 void Set(int flags, int keyCode, int cmd)
52 {
53 m_flags = flags; m_keyCode = keyCode; m_command = cmd;
54 }
55
56 int GetFlags() const { return m_flags; }
57 int GetKeyCode() const { return m_keyCode; }
58 int GetCommand() const { return m_command; }
59
60 //private:
61 int m_flags;
62 int m_keyCode; // ASCII or virtual keycode
63 int m_command; // Command id to generate
64 };
65
66 // ----------------------------------------------------------------------------
67 // the accel table has all accelerators for a given window or menu
68 // ----------------------------------------------------------------------------
69
70 class WXDLLEXPORT wxAcceleratorTable : public wxObject
71 {
72 DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
73 public:
74 wxAcceleratorTable();
75 wxAcceleratorTable(const wxString& resource); // Load from .rc resource
76 wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]); // Load from array
77
78 // Copy constructors
79 wxAcceleratorTable(const wxAcceleratorTable& accel)
80 { Ref(accel); }
81
82 ~wxAcceleratorTable();
83
84 wxAcceleratorTable& operator = (const wxAcceleratorTable& accel)
85 { if ( *this != accel ) Ref(accel); return *this; }
86
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;
93 void SetHACCEL(WXHACCEL hAccel);
94 WXHACCEL GetHACCEL() const;
95
96 // translate the accelerator, return TRUE if done
97 bool Translate(wxWindow *window, WXMSG *msg) const;
98 };
99
100 WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
101
102 #endif
103 // _WX_ACCEL_H_