1wx(3) Erlang Module Definition wx(3)
2
3
4
6 wx - A port of wxWidgets.
7
9 A port of wxWidgets.
10
11 This is the base api of wxWidgets. This module contains functions for
12 starting and stopping the wx-server, as well as other utility func‐
13 tions.
14
15 wxWidgets is object oriented, and not functional. Thus, in wxErlang a
16 module represents a class, and the object created by this class has an
17 own type, wxCLASS(). This module represents the base class, and all
18 other wxMODULE's are sub-classes of this class.
19
20 Objects of a class are created with wxCLASS:new(...) and destroyed with
21 wxCLASS:destroy(). Member functions are called with wxCLASS:member(Ob‐
22 ject, ...) instead of as in C++ Object.member(...).
23
24 Sub class modules inherit (non static) functions from their parents.
25 The inherited functions are not documented in the sub-classes.
26
27 This erlang port of wxWidgets tries to be a one-to-one mapping with the
28 original wxWidgets library. Some things are different though, as the
29 optional arguments use property lists and can be in any order. The main
30 difference is the event handling which is different from the original
31 library. See wxEvtHandler.
32
33 The following classes are implemented directly as erlang types:
34 wxPoint={x,y},wxSize={w,h},wxRect={x,y,w,h},wxColour={r,g,b [,a]},
35 wxString=unicode:chardata(), wxGBPosition={r,c},wxGBSpan={rs,cs},wx‐
36 GridCellCoords={r,c}.
37
38 wxWidgets uses a process specific environment, which is created by
39 wx:new/0. To be able to use the environment from other processes, call
40 get_env/0 to retrieve the environment and set_env/1 to assign the envi‐
41 ronment in the other process.
42
43 Global (classless) functions are located in the wx_misc module.
44
46 wx_colour() = {R::byte(), G::byte(), B::byte()} | wx_colour4():
47
48
49 wx_colour4() = {R::byte(), G::byte(), B::byte(), A::byte()}:
50
51
52 wx_datetime() = {{Year::integer(), Month::integer(), Day::integer()},
53 {Hour::integer(), Minute::integer(), Second::integer()}}:
54
55
56 In Local Timezone
57
58 wx_enum() = integer():
59
60
61 Constant defined in wx.hrl
62
63 wx_env() = #wx_env{}:
64
65
66 Opaque process environment
67
68 wx_memory() = binary() | #wx_mem{}:
69
70
71 Opaque memory reference
72
73 wx_object() = #wx_ref{}:
74
75
76 Opaque object reference
77
78 wx_wxHtmlLinkInfo() = #wxHtmlLinkInfo{href=unicode:chardata(), tar‐
79 get=unicode:chardata()}:
80
81
82 wx_wxMouseState() = #wxMouseState{x=integer(), y=integer(), left‐
83 Down=boolean(), middleDown=boolean(), rightDown=boolean(), con‐
84 trolDown=boolean(), shiftDown=boolean(), altDown=boolean(), metaD‐
85 own=boolean(), cmdDown=boolean()}:
86
87
88 See #wxMouseState{} defined in wx.hrl
89
91 parent_class(X1) -> term()
92
93 new() -> wx_object()
94
95 Starts a wx server.
96
97 new(Options::[Option]) -> wx_object()
98
99 Types:
100
101 Option = {debug, list() | atom()} | {silent_start, boolean()}
102
103 Starts a wx server. Option may be {debug, Level}, see debug/1.
104 Or {silent_start, Bool}, which causes error messages at startup
105 to be suppressed. The latter can be used as a silent test of
106 whether wx is properly installed or not.
107
108 destroy() -> ok
109
110 Stops a wx server.
111
112 get_env() -> wx_env()
113
114 Gets this process's current wx environment. Can be sent to other
115 processes to allow them use this process wx environment.
116
117 See also: set_env/1.
118
119 set_env(Wx_env::wx_env()) -> ok
120
121 Sets the process wx environment, allows this process to use an‐
122 other process wx environment.
123
124 subscribe_events() -> ok
125
126 Adds the calling process to the list of of processes that are
127 listening to wx application events.
128
129 At the moment these are all MacOSX specific events corresponding
130 to MacNewFile() and friends from wxWidgets wxApp:
131
132 * {new_file, ""}
133
134 * {open_file, Filename}
135
136 * {print_file, Filename}
137
138 * {open_url, Url}
139
140 * {reopen_app, ""}
141
142 The call always returns ok but will have sent any already re‐
143 ceived events to the calling process.
144
145 null() -> wx_object()
146
147 Returns the null object
148
149 is_null(Wx_ref::wx_object()) -> boolean()
150
151 Returns true if object is null, false otherwise
152
153 equal(Wx_ref::wx_object(), X2::wx_object()) -> boolean()
154
155 Returns true if both arguments references the same object, false
156 otherwise
157
158 getObjectType(Wx_ref::wx_object()) -> atom()
159
160 Returns the object type
161
162 typeCast(Old::wx_object(), NewType::atom()) -> wx_object()
163
164 Casts the object to class NewType. It is needed when using func‐
165 tions like wxWindow:findWindow/2, which returns a generic wxOb‐
166 ject type.
167
168 batch(Fun::function()) -> term()
169
170 Batches all wx commands used in the fun. Improves performance of
171 the command processing by grabbing the wxWidgets thread so that
172 no event processing will be done before the complete batch of
173 commands is invoked.
174
175 See also: foldl/3, foldr/3, foreach/2, map/2.
176
177 foreach(Fun::function(), List::list()) -> ok
178
179 Behaves like lists:foreach/2 but batches wx commands. See
180 batch/1.
181
182 map(Fun::function(), List::list()) -> list()
183
184 Behaves like lists:map/2 but batches wx commands. See batch/1.
185
186 foldl(Fun::function(), Acc::term(), List::list()) -> term()
187
188 Behaves like lists:foldl/3 but batches wx commands. See batch/1.
189
190 foldr(Fun::function(), Acc::term(), List::list()) -> term()
191
192 Behaves like lists:foldr/3 but batches wx commands. See batch/1.
193
194 create_memory(Size::integer()) -> wx_memory()
195
196 Creates a memory area (of Size in bytes) which can be used by an
197 external library (i.e. opengl). It is up to the client to keep a
198 reference to this object so it does not get garbage collected by
199 erlang while still in use by the external library.
200
201 This is far from erlang's intentional usage and can crash the
202 erlang emulator. Use it carefully.
203
204 get_memory_bin(Wx_mem::wx_memory()) -> binary()
205
206 Returns the memory area as a binary.
207
208 retain_memory(Wx_mem::wx_memory()) -> ok
209
210 Saves the memory from deletion until release_memory/1 is called.
211 If release_memory/1 is not called the memory will not be garbage
212 collected.
213
214 release_memory(Wx_mem::wx_memory()) -> ok
215
216 debug(Debug::Level | [Level]) -> ok
217
218 Types:
219
220 Level = none | verbose | trace | driver | integer()
221
222 Sets debug level. If debug level is 'verbose' or 'trace' each
223 call is printed on console. If Level is 'driver' each allocated
224 object and deletion is printed on the console.
225
226 demo() -> ok | {error, atom()}
227
228 Starts a wxErlang demo if examples directory exists and is com‐
229 piled
230
232 <>
233
234
235
236 wx 2.3.1 wx(3)