]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_accel.i
85f441e0b60a94e90475399f5d92939ad58d017d
[wxWidgets.git] / wxPython / src / _accel.i
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
33 enum {
34 wxACCEL_ALT,
35 wxACCEL_CTRL,
36 wxACCEL_SHIFT,
37 wxACCEL_NORMAL,
38 wxACCEL_CMD,
39 };
40
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
47 :see: `wx.AcceleratorTable`", "");
48
49 class wxAcceleratorEntry {
50 public:
51 DocCtorStr(
52 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmdID = 0/*, wxMenuItem *menuitem = NULL*/),
53 "Construct a wx.AcceleratorEntry.",
54 "
55 :param flags: A bitmask of wx.ACCEL_ALT, wx.ACCEL_SHIFT,
56 wx.ACCEL_CTRL, wx.ACCEL_CMD, or wx.ACCEL_NORMAL
57 used to specify which modifier keys are held down.
58 :param keyCode: The keycode to be detected
59 :param cmdID: The menu or control command ID to use for the
60 accellerator event.
61 ");
62 ~wxAcceleratorEntry();
63
64 DocDeclStr(
65 void , Set(int flags, int keyCode, int cmd/*, wxMenuItem *menuItem = NULL*/),
66 "(Re)set the attributes of a wx.AcceleratorEntry.
67 :see `__init__`", "");
68
69
70 // void SetMenuItem(wxMenuItem *item);
71 // wxMenuItem *GetMenuItem() const;
72
73 DocDeclStr(
74 int , GetFlags(),
75 "Get the AcceleratorEntry's flags.", "");
76
77 DocDeclStr(
78 int , GetKeyCode(),
79 "Get the AcceleratorEntry's keycode.", "");
80
81 DocDeclStr(
82 int , GetCommand(),
83 "Get the AcceleratorEntry's command ID.", "");
84
85 DocDeclStr(
86 bool , IsOk() const,
87 "", "");
88
89
90 DocDeclStr(
91 wxString , ToString() const,
92 "Returns a string representation for the this accelerator. The string
93 is formatted using the <flags>-<keycode> format where <flags> maybe a
94 hyphen-separed list of \"shift|alt|ctrl\"
95 ", "");
96
97
98 DocDeclStr(
99 bool , FromString(const wxString &str),
100 "Returns true if the given string correctly initialized this object.", "");
101
102
103 %property(Command, GetCommand, doc="See `GetCommand`");
104 %property(Flags, GetFlags, doc="See `GetFlags`");
105 %property(KeyCode, GetKeyCode, doc="See `GetKeyCode`");
106
107 };
108
109
110
111
112
113 DocStr(wxAcceleratorTable,
114 "An accelerator table allows the application to specify a table of
115 keyboard shortcuts for menus or other commands. On Windows, menu or
116 button commands are supported; on GTK, only menu commands are
117 supported.", "
118
119 The object ``wx.NullAcceleratorTable`` is defined to be a table with
120 no data, and is the initial accelerator table for a window.
121
122 An accelerator takes precedence over normal processing and can be a
123 convenient way to program some event handling. For example, you can
124 use an accelerator table to make a hotkey generate an event no matter
125 which window within a frame has the focus.
126
127 For example::
128
129 aTable = wx.AcceleratorTable([(wx.ACCEL_ALT, ord('X'), exitID),
130 (wx.ACCEL_CTRL, ord('H'), helpID),
131 (wx.ACCEL_CTRL, ord('F'), findID),
132 (wx.ACCEL_NORMAL, wx.WXK_F3, findnextID)
133 ])
134 self.SetAcceleratorTable(aTable)
135
136
137 :see: `wx.AcceleratorEntry`, `wx.Window.SetAcceleratorTable`
138 ");
139
140 class wxAcceleratorTable : public wxObject {
141 public:
142 DocAStr(wxAcceleratorTable,
143 "__init__(entries) -> AcceleratorTable",
144 "Construct an AcceleratorTable from a list of `wx.AcceleratorEntry`
145 items or or of 3-tuples (flags, keyCode, cmdID)
146
147 :see: `wx.AcceleratorEntry`", "");
148 wxAcceleratorTable(int n, const wxAcceleratorEntry* entries);
149 ~wxAcceleratorTable();
150
151 bool Ok() const;
152 };
153
154
155
156 %immutable;
157 const wxAcceleratorTable wxNullAcceleratorTable;
158 %mutable;
159
160
161 wxAcceleratorEntry *wxGetAccelFromString(const wxString& label);
162
163 //---------------------------------------------------------------------------