aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/examples/demo/demo.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wx/examples/demo/demo.erl')
-rw-r--r--lib/wx/examples/demo/demo.erl24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/wx/examples/demo/demo.erl b/lib/wx/examples/demo/demo.erl
index 99c28b3177..8fb70ad7b0 100644
--- a/lib/wx/examples/demo/demo.erl
+++ b/lib/wx/examples/demo/demo.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2016. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2017. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -60,11 +60,15 @@ start_link() ->
start_link(Debug) ->
wx_object:start_link(?MODULE, Debug, []).
+format(#state{log=Log}, Str, Args) ->
+ wxTextCtrl:appendText(Log, io_lib:format(Str, Args)),
+ ok;
format(Config,Str,Args) ->
Log = proplists:get_value(log, Config),
wxTextCtrl:appendText(Log, io_lib:format(Str, Args)),
ok.
+
-define(DEBUG_NONE, 101).
-define(DEBUG_VERBOSE, 102).
-define(DEBUG_TRACE, 103).
@@ -97,7 +101,11 @@ init(Options) ->
wxFrame:connect(Frame, close_window),
_SB = wxFrame:createStatusBar(Frame,[]),
-
+
+ %% Setup on toplevel because stc seems to steal this on linux
+ wxFrame:dragAcceptFiles(Frame, true),
+ wxFrame:connect(Frame, drop_files),
+
%% T Uppersplitter
%% O Left | Right
%% P Widgets|Code | Demo
@@ -201,15 +209,15 @@ handle_info({'EXIT',_, shutdown}, State) ->
handle_info({'EXIT',_, normal}, State) ->
{noreply,State};
handle_info(Msg, State) ->
- io:format("Got Info ~p~n",[Msg]),
+ format(State, "Got Info ~p~n",[Msg]),
{noreply,State}.
handle_call(Msg, _From, State) ->
- io:format("Got Call ~p~n",[Msg]),
+ format(State, "Got Call ~p~n",[Msg]),
{reply,ok,State}.
handle_cast(Msg, State) ->
- io:format("Got cast ~p~n",[Msg]),
+ format(State, "Got cast ~p~n",[Msg]),
{noreply,State}.
%% Async Events are handled in handle_event as in handle_info
@@ -235,6 +243,9 @@ handle_event(#wx{id = Id,
%% If you are going to printout mainly text it is easier if
%% you generate HTML code and use a wxHtmlEasyPrint
%% instead of using DCs
+
+ %% Printpreview doesn't work in >2.9 without this
+ wxIdleEvent:setMode(?wxIDLE_PROCESS_ALL),
Module = "ex_" ++ wxListBox:getStringSelection(State#state.selector) ++ ".erl",
HEP = wxHtmlEasyPrinting:new([{name, "Print"},
{parentWindow, State#state.win}]),
@@ -286,7 +297,7 @@ handle_event(#wx{event=#wxClose{}}, State = #state{win=Frame}) ->
ok = wxFrame:setStatusText(Frame, "Closing...",[]),
{stop, normal, State};
handle_event(Ev,State) ->
- io:format("~p Got event ~p ~n",[?MODULE, Ev]),
+ format(State, "~p Got event ~p ~n",[?MODULE, Ev]),
{noreply, State}.
code_change(_, _, State) ->
@@ -364,6 +375,7 @@ code_area(Parent) ->
?stc:setVisiblePolicy(Ed, Policy, 3),
%% ?stc:connect(Ed, stc_doubleclick),
+ %% ?stc:connect(Ed, std_do_drop, fun(Ev, Obj) -> io:format("Ev ~p ~p~n",[Ev,Obj]) end),
?stc:setReadOnly(Ed, true),
Ed.