-module(widgettest).

-export([go/0]).

go() ->
	I = gs:start(),
	W = gs:window(I, [{title, "Widget Test"}]),
	{CSPid, CS} = mywidgets:color_selection(W, [{data, {53, 220, 185}}]),
	Quit = gs:button(W, [{label, {text, "Quit"}}, {data, quit}, {y, gs:read(CS, height)} ]),
	gs:config(W, [{height, gs:read(Quit, height) + gs:read(Quit, y)}, {map, true}]),
	event_loop(W, Quit).

event_loop(W, Quit) ->
	receive
		{gs,_,destroy,_,_} ->
			exit(normal);
		{gs,_,click,quit,_} ->
			exit(normal);
		{_,_,color,_,[Color|_]} ->
			gs:config(Quit, [{bg, Color}]),
			event_loop(W, Quit);
		Other ->
			event_loop(W, Quit)
	end.
