diff options
author | Dan Gudmundsson <[email protected]> | 2013-01-15 09:18:49 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2013-01-15 09:18:49 +0100 |
commit | 0e044f3525d22de4c4c471f601de50ad3acda304 (patch) | |
tree | dfbbcc31814b0890fcb7774a48cf43322b29ac94 /lib/wx/examples/demo/ex_graphicsContext.erl | |
parent | fdd0b38e2c85d897a240e5f8f79e268c6540dbfd (diff) | |
parent | c384a91846f7d0aff189fb51d1d502330d7abef4 (diff) | |
download | otp-0e044f3525d22de4c4c471f601de50ad3acda304.tar.gz otp-0e044f3525d22de4c4c471f601de50ad3acda304.tar.bz2 otp-0e044f3525d22de4c4c471f601de50ad3acda304.zip |
Merge branch 'dgud/wx/fix-wx-2.9-compat/OTP-10407'
* dgud/wx/fix-wx-2.9-compat/OTP-10407: (26 commits)
wx: Fix comments
wx: Workaround wx-2.9 bugs
wx: Mac fixes
wx: Fix demo and tests
wx: Allow 64 bits compilation on mac, requires wxWidgets-2.9
appmon: Move runtime part to runtime_tools app
reltool: fix wxWidgets-2.9 compability
debugger: Fix 2.9 compat
observer: Fix check for graphics contexts
Observer: Fix distribution dialog
observer: Fix font sizes
wx: Fix the demo
wx: Fix loading icons and cursors in Windows
wx: Remove unnecessary casts
wx: Fix changed getfunctions
wx: Depricate wxCursor new functions
wx: Fix int to enum
wx: Include correct m4 file in 2.9
wx: Update examples so they work with both wxWidgets 2.8 and 2.9
wx: Modify tests so they work on wxWidgets-2.9
...
Diffstat (limited to 'lib/wx/examples/demo/ex_graphicsContext.erl')
-rw-r--r-- | lib/wx/examples/demo/ex_graphicsContext.erl | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/lib/wx/examples/demo/ex_graphicsContext.erl b/lib/wx/examples/demo/ex_graphicsContext.erl index c356500d99..59bfe7ff64 100644 --- a/lib/wx/examples/demo/ex_graphicsContext.erl +++ b/lib/wx/examples/demo/ex_graphicsContext.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 @@ -25,8 +25,8 @@ %% wx_object callbacks -export([init/1, terminate/2, code_change/3, - handle_info/2, handle_call/3, -handle_cast/2, handle_event/2, handle_sync_event/3]). + handle_info/2, handle_call/3,handle_cast/2, + handle_event/2, handle_sync_event/3]). -include_lib("wx/include/wx.hrl"). @@ -57,11 +57,9 @@ do_init(Config) -> [{label, "wxGrapicsContext"}]), Win = wxPanel:new(Panel, []), - Pen = wxPen:new(), - Brush = wxBrush:new(?wxBLACK), - Font = wxFont:new(), - wxFont:setWeight(Font, ?wxBOLD), - + Pen = ?wxBLACK_PEN, + Brush = wxBrush:new({30, 175, 23, 127}), + Font = ?wxITALIC_FONT, wxPanel:connect(Win, paint, [callback]), %% Add to sizers @@ -94,6 +92,10 @@ handle_info(Msg, State) -> demo:format(State#state.config, "Got Info ~p\n", [Msg]), {noreply, State}. +handle_call(shutdown, _From, State=#state{parent=Panel}) -> + 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}. @@ -112,36 +114,26 @@ terminate(_Reason, _State) -> %% Local functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -draw(Win, Pen0, _Brush0, Font0) -> +draw(Win, Pen, Brush, Font) -> try Canvas = wxGraphicsContext:create(Win), - Pen = wxGraphicsContext:createPen(Canvas, Pen0), wxGraphicsContext:setPen(Canvas, Pen), - Brush = wxGraphicsContext:createLinearGradientBrush(Canvas, 0.0,0.0, 30.0,30.0, - {200,50,50,50}, - {200,50,50,200}), wxGraphicsContext:setBrush(Canvas, Brush), - Font = wxGraphicsContext:createFont(Canvas, Font0), - wxGraphicsContext:setFont(Canvas, Font), + wxGraphicsContext:setFont(Canvas, Font, {0, 0, 50}), wxGraphicsContext:drawRoundedRectangle(Canvas, 35.0,35.0, 100.0, 50.0, 10.0), - wxGraphicsContext:drawText(Canvas, "Welcome", 60.0, 55.0), + wxGraphicsContext:drawText(Canvas, "This text should be antialised", 60.0, 55.0), Path = wxGraphicsContext:createPath(Canvas), wxGraphicsPath:addCircle(Path, 0.0, 0.0, 40.0), wxGraphicsPath:closeSubpath(Path), - wxGraphicsContext:translate(Canvas, 100.0, 100.0), - - Brush2 = wxGraphicsContext:createLinearGradientBrush(Canvas, 0.0,0.0, 30.0,30.0, - {50,200,50,50}, - {50,50,200,50}), - wxGraphicsContext:setBrush(Canvas, Brush2), + wxGraphicsContext:translate(Canvas, 100.0, 250.0), - F = fun(_) -> + F = fun(N) -> wxGraphicsContext:scale(Canvas, 1.1, 1.1), - wxGraphicsContext:translate(Canvas, 3.0,3.0), + wxGraphicsContext:translate(Canvas, 15.0,-1.0*N), wxGraphicsContext:drawPath(Canvas, Path) end, - wx:foreach(F, lists:seq(1,5)), + wx:foreach(F, lists:seq(1,10)), ok catch _:{not_supported, _} -> Err = "wxGraphicsContext not available in this build of wxwidgets", |