]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/accel.h
1. wxTimer change - now generates EVT_TIMER()
[wxWidgets.git] / include / wx / msw / accel.h
... / ...
CommitLineData
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
21class 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
43class WXDLLEXPORT wxAcceleratorEntry
44{
45public:
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
70class WXDLLEXPORT wxAcceleratorTable : public wxObject
71{
72DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
73public:
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 inline wxAcceleratorTable(const wxAcceleratorTable& accel) { Ref(accel); }
80 inline wxAcceleratorTable(const wxAcceleratorTable* accel) { if (accel) Ref(*accel); }
81
82 ~wxAcceleratorTable();
83
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; }
87
88 bool Ok() const;
89 void SetHACCEL(WXHACCEL hAccel);
90 WXHACCEL GetHACCEL() const;
91
92 // translate the accelerator, return TRUE if done
93 bool Translate(wxWindow *window, WXMSG *msg) const;
94};
95
96WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
97
98#endif
99 // _WX_ACCEL_H_