aboutsummaryrefslogtreecommitdiffstats
path: root/lib/gs/examples/rubber.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-06-27 11:48:03 +0200
committerBjörn Gustavsson <[email protected]>2016-06-27 11:49:57 +0200
commit6931dce17580d097351dd7be09ce7c9ed3f72827 (patch)
tree2456845e95ed0112c2f08ed8ab6e867686b91d7a /lib/gs/examples/rubber.erl
parentdfccd57cb2b69fc3ab01acd0ccbfc894a8403358 (diff)
downloadotp-6931dce17580d097351dd7be09ce7c9ed3f72827.tar.gz
otp-6931dce17580d097351dd7be09ce7c9ed3f72827.tar.bz2
otp-6931dce17580d097351dd7be09ce7c9ed3f72827.zip
Remove the gs application
The gs application ws deprecated in R15B01.
Diffstat (limited to 'lib/gs/examples/rubber.erl')
-rw-r--r--lib/gs/examples/rubber.erl113
1 files changed, 0 insertions, 113 deletions
diff --git a/lib/gs/examples/rubber.erl b/lib/gs/examples/rubber.erl
deleted file mode 100644
index 129359dd03..0000000000
--- a/lib/gs/examples/rubber.erl
+++ /dev/null
@@ -1,113 +0,0 @@
-%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2016. 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.
-%% You may obtain a copy of the License at
-%%
-%% http://www.apache.org/licenses/LICENSE-2.0
-%%
-%% Unless required by applicable law or agreed to in writing, software
-%% distributed under the License is distributed on an "AS IS" BASIS,
-%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-%% See the License for the specific language governing permissions and
-%% limitations under the License.
-%%
-%% %CopyrightEnd%
-%%
-
-%%
-%% ------------------------------------------------------------
-%% A rubberbanding example in Erlang
-%% ------------------------------------------------------------
-
--module(rubber).
--compile([{nowarn_deprecated_function,{gs,button,2}},
- {nowarn_deprecated_function,{gs,canvas,2}},
- {nowarn_deprecated_function,{gs,config,2}},
- {nowarn_deprecated_function,{gs,create,3}},
- {nowarn_deprecated_function,{gs,destroy,1}},
- {nowarn_deprecated_function,{gs,radiobutton,2}},
- {nowarn_deprecated_function,{gs,start,0}},
- {nowarn_deprecated_function,{gs,window,2}}]).
-
--export([start/0, init/0]).
-
-start() ->
- spawn(rubber,init,[]).
-
-init() ->
- I=gs:start(),
- Win = gs:window(I,[{title,"Rubberbanding in Erlang"},
- {width,300},{height,200}]),
- C= gs:canvas(Win,[{width,300},{height,200},{bg,green}]),
- gs:radiobutton(Win,[{width,100},{label,{text,"Oval"}},{align,w},
- {data,oval},{y,0},{select,true}]),
- gs:radiobutton(Win,[{width,100},{label,{text,"Rectangle"}},{align,w},
- {data,rectangle},{y,30}]),
- gs:radiobutton(Win,[{width,100},{label,{text,"Line"}},{align,w},
- {data,line},{y,60}]),
- gs:button(Win,[{label,{text,"Quit"}},{data,quit},{y,90}]),
- gs:config(Win,[{motion,true},{buttonpress,true},{buttonrelease,true}]),
- gs:config(Win,{map,true}),
- loop(C,nil,oval,0,0).
-
-
-loop(Win,Obj,Objtype,X1,Y1) ->
- receive
- {gs,_,motion,_,[X2,Y2]} ->
- flush(Win,Obj,Objtype,X1,Y1,X2,Y2);
- {gs,_,buttonpress,_,[1,X2,Y2]} ->
- down(Win,Obj,Objtype,X2,Y2);
- {gs,_,buttonrelease,_,[1,X2,Y2]} ->
- up(Win,Obj,Objtype,X1,Y1,X2,Y2);
- {gs,_,click,quit,_} ->
- exit(normal);
- {gs,_,click,Newtype,_} ->
- loop(Win,Obj,Newtype,X1,Y1);
- {gs,_,destroy,_,_} ->
- exit(normal);
- Other ->
- io:format("Other:~w~n",[Other]),
- loop(Win,Obj,Objtype,X1,Y1)
- end.
-
-
-down(Win,nil,oval,X1,Y1) ->
- Obj = gs:create(oval,Win,[{coords,[{X1,Y1},{X1+1,Y1+1}]},{fill,red}]),
- loop(Win,Obj,oval,X1,Y1);
-down(Win,nil,line,X1,Y1) ->
- Obj = gs:create(line,Win,[{coords,[{X1,Y1},{X1+1,Y1+1}]},{width,3},{fg,black}]),
- loop(Win,Obj,line,X1,Y1);
-down(Win,nil,Objtype,X1,Y1) ->
- Obj = gs:create(Objtype,Win,[{coords,[{X1,Y1},{X1+1,Y1+1}]},{bw,2},{fg,blue}]),
- loop(Win,Obj,Objtype,X1,Y1);
-down(Win,Obj,Objtype,X1,Y1) ->
- gs:destroy(Obj),
- down(Win,nil,Objtype,X1,Y1).
-
-up(Win,nil,Objtype,_X1,_Y1,X2,Y2) ->
- loop(Win,nil,Objtype,X2,Y2);
-up(Win,Obj,Objtype,X1,Y1,X2,Y2) ->
- gs:config(Obj,{coords,[{X1,Y1},{X2,Y2}]}),
- loop(Win,nil,Objtype,X2,Y2).
-
-
-move(Win,nil,Objtype,X1,Y1,_X2,_Y2) ->
- loop(Win,nil,Objtype,X1,Y1);
-move(Win,Obj,Objtype,X1,Y1,X2,Y2) ->
- gs:config(Obj,{coords,[{X1,Y1},{X2,Y2}]}),
- loop(Win,Obj,Objtype,X1,Y1).
-
-
-flush(Win,Obj,Objtype,X1,Y1,X2,Y2) ->
- receive
- {gs,_,motion,_,[XX2,YY2]} ->
- flush(Win,Obj,Objtype,X1,Y1,XX2,YY2)
- after
- 0 -> move(Win,Obj,Objtype,X1,Y1,X2,Y2)
- end.
-
-%% ------------------------------------------------------------