4
%% Copyright Ericsson AB 2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
19
%%%-------------------------------------------------------------------
21
%%% Author : Matthew Harrison <harryhuk at users.sourceforge.net>
22
%%% Description : _really_ minimal example of a wxerlang app
23
%%% implemented with wx_object behaviour
25
%%% Created : 18 Sep 2008 by Matthew Harrison <harryhuk at users.sourceforge.net>
26
%%% Dan rewrote it to show wx_object behaviour
27
%%%-------------------------------------------------------------------
29
-include_lib("wx/include/wx.hrl").
34
-behavoiur(wx_object).
36
-record(state, {win}).
39
wx_object:start_link(?MODULE, [], []).
41
%% Init is called in the new process.
44
Frame = wxFrame:new(wx:null(),
46
"Hello World", % window title
49
wxFrame:createStatusBar(Frame,[]),
51
%% if we don't handle this ourselves, wxwidgets will close the window
52
%% when the user clicks the frame's close button, but the event loop still runs
53
wxFrame:connect(Frame, close_window),
55
ok = wxFrame:setStatusText(Frame, "Hello World!",[]),
57
{Frame, #state{win=Frame}}.
60
%% Handled as in normal gen_server callbacks
61
handle_info(Msg, State) ->
62
io:format("Got Info ~p~n",[Msg]),
65
handle_call(Msg, _From, State) ->
66
io:format("Got Call ~p~n",[Msg]),
69
%% Async Events are handled in handle_event as in handle_info
70
handle_event(#wx{event=#wxClose{}}, State = #state{win=Frame}) ->
71
io:format("~p Closing window ~n",[self()]),
72
ok = wxFrame:setStatusText(Frame, "Closing...",[]),
73
wxWindow:destroy(Frame),
74
{stop, normal, State}.
76
code_change(_, _, State) ->
77
{stop, not_yet_implemented, State}.
79
terminate(_Reason, _State) ->