Advertisement
Guest User

Untitled

a guest
Jun 11th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.95 KB | None | 0 0
  1. -module(dl2).
  2. -export([start/0]).
  3. -include_lib("wx/include/wx.hrl").
  4.  
  5. start() ->
  6.     Wx = wx:new(),
  7.     Frame = wxFrame:new(Wx, -1, "Line", [{size, {280, 180}}]),
  8.     Panel = wxPanel:new(Frame),
  9.  
  10.     OnPaint = fun(_Evt, _Obj) ->
  11. %%          io:format("now: ~p~n event: ~p~n object: ~p~n",[now(),_Evt,_Obj]),
  12.             Paint = wxPaintDC:new(Panel),
  13.             Pen = wxPen:new(),
  14. %%  To change the color or width of the line un-comment these next two lines                    
  15. %%          wxPen:setWidth(Pen, 3),
  16. %%          wxPen:setColour(Pen, ?wxRED),
  17.             wxDC:setPen(Paint, Pen),
  18.             wxDC:drawLine(Paint, {50, 60}, {190,60}),
  19.             wxPaintDC:destroy(Paint)
  20.       end,
  21.  
  22.     wxFrame:connect(Panel, paint, [{callback, OnPaint}]),
  23.     wxFrame:connect(Panel, close_window), % works
  24.     % wxFrame:connect(Frame, close_window), %Frame, instead, doesn't work, why not?      
  25.     wxFrame:center(Frame),
  26.     wxFrame:show(Frame).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement