aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/examples/demo/ex_canvas_paint.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2016-05-09 10:20:06 +0200
committerDan Gudmundsson <[email protected]>2016-05-09 10:20:06 +0200
commit4de491e9c563c49b5d5c88756c5ba00eb0dff66c (patch)
tree95fabe050ce3ccb6022845a85b2342b05985e2e0 /lib/wx/examples/demo/ex_canvas_paint.erl
parentb3a7924f657828585bdc517e4c8a03785478e584 (diff)
parenta563c17bdea478952b619984571207c63862c7f8 (diff)
downloadotp-4de491e9c563c49b5d5c88756c5ba00eb0dff66c.tar.gz
otp-4de491e9c563c49b5d5c88756c5ba00eb0dff66c.tar.bz2
otp-4de491e9c563c49b5d5c88756c5ba00eb0dff66c.zip
Merge branch 'dgud/wx/compatible-with-wxW-3.1'
* dgud/wx/compatible-with-wxW-3.1: Test cuddle, increase sleep wx: Fix warnings in example Fix argv types wx: Remove non implemented wxGauge functions
Diffstat (limited to 'lib/wx/examples/demo/ex_canvas_paint.erl')
-rw-r--r--lib/wx/examples/demo/ex_canvas_paint.erl16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/wx/examples/demo/ex_canvas_paint.erl b/lib/wx/examples/demo/ex_canvas_paint.erl
index aa510f5342..75eb840b04 100644
--- a/lib/wx/examples/demo/ex_canvas_paint.erl
+++ b/lib/wx/examples/demo/ex_canvas_paint.erl
@@ -157,10 +157,15 @@ handle_event(#wx{event = #wxMouse{type = motion, x = X, y = Y}},
{noreply, State#state{old_pos = {X,Y}}};
%% Resize event
handle_event(#wx{event = #wxSize{size = {W,H}}}, State = #state{bitmap=Prev}) ->
- wxBitmap:destroy(Prev),
- Bitmap = wxBitmap:new(W,H),
- draw(State#state.canvas, Bitmap, fun(DC) -> wxDC:clear(DC) end),
- {noreply, State#state{bitmap=Bitmap}};
+ case W > 0 andalso H > 0 of
+ true ->
+ wxBitmap:destroy(Prev),
+ Bitmap = wxBitmap:new(W,H),
+ draw(State#state.canvas, Bitmap, fun(DC) -> wxDC:clear(DC) end),
+ {noreply, State#state{bitmap=Bitmap}};
+ false ->
+ {noreply, State}
+ end;
handle_event(#wx{event = #wxMouse{type = left_dclick,x = X,y = Y}}, State = #state{}) ->
wxPanel:connect(State#state.canvas, motion),
{noreply, State#state{old_pos = {X,Y}}};
@@ -235,11 +240,10 @@ draw(Canvas, Bitmap, Fun) ->
CDC = wxClientDC:new(Canvas),
Fun(MemoryDC),
-
wxDC:blit(CDC, {0,0},
{wxBitmap:getWidth(Bitmap), wxBitmap:getHeight(Bitmap)},
MemoryDC, {0,0}),
-
+
wxClientDC:destroy(CDC),
wxMemoryDC:destroy(MemoryDC).