]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _accel.i | |
3 | // Purpose: SWIG interface for wxAcceleratorTable | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 03-July-1997 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | ||
18 | %typemap(in) (int n, const wxAcceleratorEntry* entries) { | |
19 | $2 = wxAcceleratorEntry_LIST_helper($input); | |
20 | if ($2) $1 = PyList_Size($input); | |
21 | else $1 = 0; | |
22 | } | |
23 | ||
24 | %typemap(freearg) wxAcceleratorEntry* entries { | |
25 | delete [] $1; | |
26 | } | |
27 | ||
28 | ||
29 | ||
30 | //--------------------------------------------------------------------------- | |
31 | %newgroup; | |
32 | ||
1cc14cea RD |
33 | enum { |
34 | wxACCEL_ALT, | |
35 | wxACCEL_CTRL, | |
36 | wxACCEL_SHIFT, | |
37 | wxACCEL_NORMAL, | |
38 | wxACCEL_CMD, | |
39 | }; | |
40 | ||
dce2bd22 RD |
41 | DocStr(wxAcceleratorEntry, |
42 | "A class used to define items in an `wx.AcceleratorTable`. wxPython | |
43 | programs can choose to use wx.AcceleratorEntry objects, but using a | |
44 | list of 3-tuple of integers (flags, keyCode, cmdID) usually works just | |
45 | as well. See `__init__` for details of the tuple values. | |
46 | ||
d07d2bc9 | 47 | :see: `wx.AcceleratorTable`", ""); |
d14a1e28 RD |
48 | |
49 | class wxAcceleratorEntry { | |
50 | public: | |
dce2bd22 RD |
51 | DocCtorStr( |
52 | wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmdID = 0/*, wxMenuItem *menuitem = NULL*/), | |
d07d2bc9 RD |
53 | "Construct a wx.AcceleratorEntry.", |
54 | " | |
55 | :param flags: A bitmask of wx.ACCEL_ALT, wx.ACCEL_SHIFT, | |
1cc14cea RD |
56 | wx.ACCEL_CTRL, wx.ACCEL_CMD, or wx.ACCEL_NORMAL |
57 | used to specify which modifier keys are held down. | |
d07d2bc9 RD |
58 | :param keyCode: The keycode to be detected |
59 | :param cmdID: The menu or control command ID to use for the | |
dce2bd22 RD |
60 | accellerator event. |
61 | "); | |
d14a1e28 RD |
62 | ~wxAcceleratorEntry(); |
63 | ||
dce2bd22 RD |
64 | DocDeclStr( |
65 | void , Set(int flags, int keyCode, int cmd/*, wxMenuItem *menuItem = NULL*/), | |
66 | "(Re)set the attributes of a wx.AcceleratorEntry. | |
d07d2bc9 | 67 | :see `__init__`", ""); |
dce2bd22 RD |
68 | |
69 | ||
70 | // void SetMenuItem(wxMenuItem *item); | |
71 | // wxMenuItem *GetMenuItem() const; | |
72 | ||
42e2bbb9 RD |
73 | %newobject Create; |
74 | DocDeclStr( | |
75 | static wxAcceleratorEntry *, Create(const wxString& str), | |
76 | "Create accelerator corresponding to the specified string, or None if | |
77 | it coulnd't be parsed.", ""); | |
78 | ||
dce2bd22 RD |
79 | DocDeclStr( |
80 | int , GetFlags(), | |
d07d2bc9 | 81 | "Get the AcceleratorEntry's flags.", ""); |
dce2bd22 RD |
82 | |
83 | DocDeclStr( | |
84 | int , GetKeyCode(), | |
d07d2bc9 | 85 | "Get the AcceleratorEntry's keycode.", ""); |
dce2bd22 RD |
86 | |
87 | DocDeclStr( | |
88 | int , GetCommand(), | |
d07d2bc9 | 89 | "Get the AcceleratorEntry's command ID.", ""); |
e81b607b RD |
90 | |
91 | DocDeclStr( | |
92 | bool , IsOk() const, | |
93 | "", ""); | |
94 | ||
95 | ||
96 | DocDeclStr( | |
97 | wxString , ToString() const, | |
98 | "Returns a string representation for the this accelerator. The string | |
99 | is formatted using the <flags>-<keycode> format where <flags> maybe a | |
100 | hyphen-separed list of \"shift|alt|ctrl\" | |
101 | ", ""); | |
102 | ||
0eae5d09 | 103 | |
e81b607b RD |
104 | DocDeclStr( |
105 | bool , FromString(const wxString &str), | |
106 | "Returns true if the given string correctly initialized this object.", ""); | |
107 | ||
108 | ||
0eae5d09 RD |
109 | %property(Command, GetCommand, doc="See `GetCommand`"); |
110 | %property(Flags, GetFlags, doc="See `GetFlags`"); | |
111 | %property(KeyCode, GetKeyCode, doc="See `GetKeyCode`"); | |
112 | ||
dce2bd22 RD |
113 | }; |
114 | ||
d14a1e28 | 115 | |
d14a1e28 | 116 | |
d14a1e28 RD |
117 | |
118 | ||
dce2bd22 RD |
119 | DocStr(wxAcceleratorTable, |
120 | "An accelerator table allows the application to specify a table of | |
121 | keyboard shortcuts for menus or other commands. On Windows, menu or | |
122 | button commands are supported; on GTK, only menu commands are | |
d07d2bc9 | 123 | supported.", " |
dce2bd22 RD |
124 | |
125 | The object ``wx.NullAcceleratorTable`` is defined to be a table with | |
126 | no data, and is the initial accelerator table for a window. | |
127 | ||
128 | An accelerator takes precedence over normal processing and can be a | |
129 | convenient way to program some event handling. For example, you can | |
130 | use an accelerator table to make a hotkey generate an event no matter | |
131 | which window within a frame has the focus. | |
132 | ||
1cc14cea | 133 | For example:: |
dce2bd22 RD |
134 | |
135 | aTable = wx.AcceleratorTable([(wx.ACCEL_ALT, ord('X'), exitID), | |
136 | (wx.ACCEL_CTRL, ord('H'), helpID), | |
137 | (wx.ACCEL_CTRL, ord('F'), findID), | |
138 | (wx.ACCEL_NORMAL, wx.WXK_F3, findnextID) | |
139 | ]) | |
140 | self.SetAcceleratorTable(aTable) | |
141 | ||
142 | ||
143 | :see: `wx.AcceleratorEntry`, `wx.Window.SetAcceleratorTable` | |
144 | "); | |
145 | ||
d14a1e28 RD |
146 | class wxAcceleratorTable : public wxObject { |
147 | public: | |
1e0c8722 RD |
148 | DocAStr(wxAcceleratorTable, |
149 | "__init__(entries) -> AcceleratorTable", | |
dce2bd22 RD |
150 | "Construct an AcceleratorTable from a list of `wx.AcceleratorEntry` |
151 | items or or of 3-tuples (flags, keyCode, cmdID) | |
152 | ||
d07d2bc9 | 153 | :see: `wx.AcceleratorEntry`", ""); |
d14a1e28 RD |
154 | wxAcceleratorTable(int n, const wxAcceleratorEntry* entries); |
155 | ~wxAcceleratorTable(); | |
156 | ||
6c2dd16f RD |
157 | bool IsOk() const; |
158 | %pythoncode { Ok = IsOk } | |
d14a1e28 RD |
159 | }; |
160 | ||
dce2bd22 | 161 | |
d14a1e28 RD |
162 | |
163 | %immutable; | |
d14a1e28 RD |
164 | const wxAcceleratorTable wxNullAcceleratorTable; |
165 | %mutable; | |
166 | ||
167 | ||
168 | wxAcceleratorEntry *wxGetAccelFromString(const wxString& label); | |
169 | ||
170 | //--------------------------------------------------------------------------- |