<div dir="ltr"><div>Q1: </div><div>Where is connect and arguments descrbed in the event handler,<br></div><div>which most of the classes inherits from: </div><div>See wx.hrl and in <a href="http://erlang.org/doc/man/wxEvtHandler.html">http://erlang.org/doc/man/wxEvtHandler.html</a></div><div><br></div><div>Then you will have to read which class sends which events..</div><div><br></div><div>Q2: The erlang documentation (or lack there of) does not have the intention of learning </div><div>you how to write gui's with wxWidgets only the differences in the erlang wrapper.</div><div>So you will have to look for that information elsewhere, I have tried to write examples</div><div>and you can also look at the observer code for inspiration.</div><div><br></div><div>I have not read the book it is old but may still be good, I'm not a wxWidgets expert</div><div>I just wrote the erlang wrapper. </div><div><br></div><div>On Sat, Jul 1, 2017 at 5:19 PM Joe Armstrong <<a href="mailto:erlang@gmail.com">erlang@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello.<br>
<br>
I want to make a very simple graphics example in wxErlang<br>
I want to make a "window" containing a rectangle<br>
<br>Nothing else - this should *not* use the wx_object behaviour but the<br>
raw wx interface.<br>
<br></blockquote><div>See below</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I want to understand one thing at a time and not use abstractions layered on top<br>
of the raw interfaces<br></blockquote><div> </div><div>The abstraction cheats, wx have special code for helping with the abstraction, so it's</div><div>useful but here is what you want in 40 lines:</div><div><br></div><div><div><div><font face="monospace">-module(joe).<br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">-export([run/0]).</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">-include_lib("wx/include/wx.hrl").</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">run() -></font></div><div><font face="monospace"> %% Start wx application</font></div><div><font face="monospace"> _ = wx:new(),</font></div><div><font face="monospace"> %% Create the OS window (called frame)</font></div><div><font face="monospace"> NoParent = wx:null(), % This is the top level window, we have no parent</font></div><div><font face="monospace"> NoId = ?wxID_ANY, % We can set an id for every widget,</font></div><div><font face="monospace"> % we don't need a specific id here</font></div><div><font face="monospace"> Frame = wxFrame:new(NoParent, NoId, "Hello Joe"),</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> %% Create a widget as background and drawing area belonging to the frame.</font></div><div><font face="monospace"> Panel = wxPanel:new(Frame),</font></div><div><font face="monospace"> White = {255,255,255},</font></div><div><font face="monospace"> wxWindow:setBackgroundColour(Panel, White),</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> %% Create a sizer, the sizer handles widgets placement and size</font></div><div><font face="monospace"> Sizer = wxBoxSizer:new(?wxVERTICAL),</font></div><div><font face="monospace"> wxSizer:add(Sizer, Panel, [{proportion, 1}, {flag, ?wxEXPAND}]),</font></div><div><font face="monospace"> wxFrame:setSizer(Frame, Sizer),</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> %% Listen to events</font></div><div><font face="monospace"> wxPanel:connect(Panel, paint, [{callback, fun redraw/2}]),</font></div><div><font face="monospace"> wxFrame:connect(Frame, close_window, [{skip, true}]),</font></div><div><font face="monospace"> %% {skip, true} will let the event be handled by the default handler</font></div><div><font face="monospace"> %% which will close the window</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> %% Show the frame</font></div><div><font face="monospace"> wxFrame:show(Frame),</font></div><div><font face="monospace"> loop(),</font></div><div><font face="monospace"> ok.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">loop() -></font></div><div><font face="monospace"> receive</font></div><div><font face="monospace"> #wx{event=#wxClose{}} -></font></div><div><font face="monospace"> ok;</font></div><div><font face="monospace"> Msg -></font></div><div><font face="monospace"> io:format("~p:~p: Got ~p~n",[?MODULE, ?FUNCTION_NAME, Msg]),</font></div><div><font face="monospace"> loop()</font></div><div><font face="monospace"> end.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">%% This is called in a spawned process, so don't deadlock by</font></div><div><font face="monospace">%% calling the process above while that waits in calls to wx.</font></div><div><font face="monospace">redraw(#wx{obj=Panel}, _wxPaintEvent) -></font></div><div><font face="monospace"> %% Create a drawing context on the Panel</font></div><div><font face="monospace"> DC = wxPaintDC:new(Panel),</font></div><div><font face="monospace"> %% You can draw on the DC (old way) with the functions in wxDC module</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> %% Or use a Graphics Contexts to have antialising and nicer graphics</font></div><div><font face="monospace"> GC = wxGraphicsContext:create(DC),</font></div><div><font face="monospace"> wxGraphicsContext:setBrush(GC, ?wxRED_BRUSH),</font></div><div><font face="monospace"> wxGraphicsContext:setFont(GC, ?wxITALIC_FONT, {255,255,255}),</font></div><div><font face="monospace"> {W,H} = wxPanel:getSize(Panel),</font></div><div><font face="monospace"> wxGraphicsContext:drawRoundedRectangle(GC, 35.0,35.0, W-70.0, H-70.0, 10.0),</font></div><div><font face="monospace"> wxGraphicsContext:drawText(GC, "Hello Joe", 60.0, 55.0),</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> %% Nothing is drawn until you destroy your drawing contexts</font></div><div><font face="monospace"> wxGraphicsObject:destroy(GC),</font></div><div><font face="monospace"> wxPaintDC:destroy(DC),</font></div><div><font face="monospace"> ok.</font></div></div><br class="inbox-inbox-Apple-interchange-newline"></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div>