1wx_object(3)               Erlang Module Definition               wx_object(3)
2
3
4

NAME

6       wx_object - wx_object - Generic wx object behaviour.
7

DESCRIPTION

9       wx_object - Generic wx object behaviour
10
11       This  is  a  behaviour  module  that  can be used for "sub classing" wx
12       objects. It works like a regular gen_server module and creates a server
13       per object.
14
15       NOTE: Currently no form of inheritance is implemented.
16
17       The user module should export:
18
19       init(Args) should return
20       {wxObject,  State}  | {wxObject, State, Timeout} | ignore | {stop, Rea‐
21       son}
22
23       Asynchronous window event handling:
24       handle_event(#wx{}, State) should return
25       {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
26
27       The user module can export the following callback functions:
28
29       handle_call(Msg, {From, Tag}, State) should return
30       {reply, Reply, State} | {reply,  Reply,  State,  Timeout}  |  {noreply,
31       State} | {noreply, State, Timeout} | {stop, Reason, Reply, State}
32
33       handle_cast(Msg, State) should return
34       {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
35
36       If  the  above  are not exported but called, the wx_object process will
37       crash. The user module can also export:
38
39       Info is message e.g. {'EXIT', P, R}, {nodedown, N}, ...
40       handle_info(Info, State) should return , ...
41       {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
42
43       If a message is sent to the wx_object process when handle_info  is  not
44       exported, the message will be dropped and ignored.
45
46       When  stop is returned in one of the functions above with Reason = nor‐
47       mal | shutdown | Term, terminate(State) is called.  It  lets  the  user
48       module  clean  up,  it  is always called when server terminates or when
49       wx_object() in the driver is deleted. If the Parent process  terminates
50       the Module:terminate/2 function is called.
51       terminate(Reason, State)
52
53       Example:
54
55         -module(myDialog).
56         -export([new/2, show/1, destroy/1]).  %% API
57         -export([init/1, handle_call/3, handle_event/2,
58                  handle_info/2, code_change/3, terminate/2]).
59                  new/2, showModal/1, destroy/1]).  %% Callbacks
60
61         %% Client API
62         new(Parent, Msg) ->
63            wx_object:start(?MODULE, [Parent,Id], []).
64
65         show(Dialog) ->
66            wx_object:call(Dialog, show_modal).
67
68         destroy(Dialog) ->
69            wx_object:call(Dialog, destroy).
70
71         %% Server Implementation ala gen_server
72         init([Parent, Str]) ->
73            Dialog = wxDialog:new(Parent, 42, "Testing", []),
74            ...
75            wxDialog:connect(Dialog, command_button_clicked),
76            {Dialog, MyState}.
77
78         handle_call(show, _From, State) ->
79            wxDialog:show(State#state.win),
80            {reply, ok, State};
81         ...
82         handle_event(#wx{}, State) ->
83            io:format("Users clicked button~n",[]),
84            {noreply, State};
85         ...
86

EXPORTS

88       start(Name,  Mod,  Args,  Options)  ->  wxWindow:wxWindow()  |  {error,
89       term()}
90
91              Types:
92
93                 Name = {local, atom()}
94                 Mod = atom()
95                 Args = term()
96                 Flag = trace | log | {logfile, string()} | statistics | debug
97                 Options = [{timeout, timeout()} | {debug, [Flag]}]
98
99              Starts a generic wx_object server and invokes Mod:init(Args)  in
100              the new process.
101
102       start_link(Mod, Args, Options) -> wxWindow:wxWindow() | {error, term()}
103
104              Types:
105
106                 Mod = atom()
107                 Args = term()
108                 Flag = trace | log | {logfile, string()} | statistics | debug
109                 Options = [{timeout, timeout()} | {debug, [Flag]}]
110
111              Starts  a generic wx_object server and invokes Mod:init(Args) in
112              the new process.
113
114       start_link(Name, Mod, Args, Options) -> wxWindow:wxWindow()  |  {error,
115       term()}
116
117              Types:
118
119                 Name = {local, atom()}
120                 Mod = atom()
121                 Args = term()
122                 Flag = trace | log | {logfile, string()} | statistics | debug
123                 Options = [{timeout, timeout()} | {debug, [Flag]}]
124
125              Starts  a generic wx_object server and invokes Mod:init(Args) in
126              the new process.
127
128       stop(Obj) -> ok
129
130              Types:
131
132                 Obj = wx:wx_object() | atom() | pid()
133
134              Stops a generic wx_object server with reason  'normal'.  Invokes
135              terminate(Reason,State)  in the server. The call waits until the
136              process is terminated. If the process does not exist, an  excep‐
137              tion is raised.
138
139       stop(Obj, Reason, Timeout) -> ok
140
141              Types:
142
143                 Obj = wx:wx_object() | atom() | pid()
144                 Reason = term()
145                 Timeout = timeout()
146
147              Stops  a generic wx_object server with the given Reason. Invokes
148              terminate(Reason,State) in the server. The call waits until  the
149              process  is terminated. If the call times out, or if the process
150              does not exist, an exception is raised.
151
152       call(Obj, Request) -> term()
153
154              Types:
155
156                 Obj = wx:wx_object() | atom() | pid()
157                 Request = term()
158
159              Make a call to a wx_object server. The call waits until it  gets
160              a  result.  Invokes  handle_call(Request,  From,  State)  in the
161              server
162
163       call(Obj, Request, Timeout) -> term()
164
165              Types:
166
167                 Obj = wx:wx_object() | atom() | pid()
168                 Request = term()
169                 Timeout = integer()
170
171              Make a call to a wx_object server with a timeout.  Invokes  han‐
172              dle_call(Request, From, State) in server
173
174       cast(Obj, Request) -> ok
175
176              Types:
177
178                 Obj = wx:wx_object() | atom() | pid()
179                 Request = term()
180
181              Make  a cast to a wx_object server. Invokes handle_cast(Request,
182              State) in the server
183
184       get_pid(Obj) -> pid()
185
186              Types:
187
188                 Obj = wx:wx_object() | atom() | pid()
189
190              Get the pid of the object handle.
191
192       set_pid(Obj, Pid::pid()) -> wx:wx_object()
193
194              Types:
195
196                 Obj = wx:wx_object() | atom() | pid()
197
198              Sets the controlling process of the object handle.
199
200       reply(X1::{pid(), Tag::term()}, Reply::term()) -> pid()
201
202              Get the pid of the object handle.
203

AUTHORS

205       <>
206
207
208
209                                   wx 1.8.3                       wx_object(3)
Impressum