From 05d2434a2ccfe94ea7c7db50189ff440b1517fbe Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Thu, 8 Nov 2012 08:00:20 +0100 Subject: wx: Update examples so they work with both wxWidgets 2.8 and 2.9 --- lib/wx/examples/demo/ex_aui.erl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/wx/examples/demo/ex_aui.erl') diff --git a/lib/wx/examples/demo/ex_aui.erl b/lib/wx/examples/demo/ex_aui.erl index 50f077638d..dc7416a116 100644 --- a/lib/wx/examples/demo/ex_aui.erl +++ b/lib/wx/examples/demo/ex_aui.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2011. All Rights Reserved. +%% Copyright Ericsson AB 2009-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -32,7 +32,8 @@ -record(state, { parent, - config + config, + aui }). start(Config) -> @@ -47,12 +48,10 @@ init(Config) -> do_init(Config) -> Parent = proplists:get_value(parent, Config), Panel = wxPanel:new(Parent, []), - %% Setup sizers MainSizer = wxBoxSizer:new(?wxVERTICAL), - Manager = wxAuiManager:new([{managed_wnd, Panel} - ]), + Manager = wxAuiManager:new([{managed_wnd, Panel}]), Pane = ?pi:new(), ?pi:closeButton(Pane), @@ -79,8 +78,8 @@ do_init(Config) -> wxAuiManager:connect(Manager, aui_pane_button, [{skip,true}]), wxAuiManager:connect(Manager, aui_pane_maximize, [{skip,true}]), wxAuiManager:update(Manager), - - {Panel, #state{parent=Panel, config=Config}}. + process_flag(trap_exit, true), + {Panel, #state{parent=Panel, config=Config, aui=Manager}}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Callbacks handled as normal gen_server callbacks @@ -134,11 +133,13 @@ handle_event(Ev = #wx{}, State) -> io:format("~p\n", [Ev]), {noreply, State}. - code_change(_, _, State) -> {stop, ignore, State}. -terminate(_Reason, _State) -> +terminate(_Reason, #state{aui=Manager, parent=Panel}) -> + wxAuiManager:unInit(Manager), + wxAuiManager:destroy(Manager), + wxPanel:destroy(Panel), ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- cgit v1.2.3 From ae412569d12eff642b5eaaf55915ea8cda9dce0b Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Fri, 14 Dec 2012 14:45:50 +0100 Subject: wx: Fix the demo Changing demo, didn't close the previous choosen demo, which looked really bad on Windows. --- lib/wx/examples/demo/ex_aui.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/wx/examples/demo/ex_aui.erl') diff --git a/lib/wx/examples/demo/ex_aui.erl b/lib/wx/examples/demo/ex_aui.erl index dc7416a116..70372caad8 100644 --- a/lib/wx/examples/demo/ex_aui.erl +++ b/lib/wx/examples/demo/ex_aui.erl @@ -87,6 +87,12 @@ handle_info(Msg, State) -> demo:format(State#state.config, "Got Info ~p\n", [Msg]), {noreply, State}. +handle_call(shutdown, _From, State=#state{parent=Panel, aui=Manager}) -> + wxAuiManager:unInit(Manager), + wxAuiManager:destroy(Manager), + wxPanel:destroy(Panel), + {stop, normal, ok, State}; + handle_call(Msg, _From, State) -> demo:format(State#state.config, "Got Call ~p\n", [Msg]), {reply,{error, nyi}, State}. @@ -136,10 +142,7 @@ handle_event(Ev = #wx{}, State) -> code_change(_, _, State) -> {stop, ignore, State}. -terminate(_Reason, #state{aui=Manager, parent=Panel}) -> - wxAuiManager:unInit(Manager), - wxAuiManager:destroy(Manager), - wxPanel:destroy(Panel), +terminate(_Reason, _) -> ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- cgit v1.2.3