Turing "Paint" with GUI, can't select multiple buttons...
Author |
Message |
Skeltas
|
Posted: Thu Dec 27, 2007 6:00 pm Post subject: Turing "Paint" with GUI, can't select multiple buttons... |
|
|
Hey all, this is what I have so far. It's (hopefully) going to be a program reminicient of Paint in Windows.
Turing: |
var x, y, b : int := - 1
var mx, my, dummy1, dummy2 : int
procedure startpaint
loop
mousewhere (x, y, b )
if b = 1 then
drawfilloval (x, y, 20, 20, black)
end if
if y < 50 then
buttonwait ("down", mx, my, dummy1, dummy2 )
end if
end loop
end startpaint
procedure exitpaint
GUI.Quit
end exitpaint
Draw.Line (0, 35, maxx, 35, black)
var startbutton : int := GUI.CreateButton (maxx div 5, 3, 60, "Start", startpaint )
var exitbutton : int := GUI.CreateButton (maxx div 2, 3, 60, "Exit", exitpaint )
loop
exit when GUI.ProcessEvent
end loop
|
The problem, as far as I can tell, is that I can't select my "Quit" button while the "Start" button is in progress, because of the loop structure in my procedure.
Is there a way to have both a constant draw, as well as a logical 'breakoff' point so that I can hit "Quit"?
Also, is there a better way of doing the draw? I'm modeling it after the MouseTrails program in the Turing package, but does anyone have any other ideas?
Thanks for your time |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Thu Dec 27, 2007 6:55 pm Post subject: RE:Turing "Paint" with GUI, can\'t select multiple buttons... |
|
|
You would need to either get rid of all the loops, or place exit when GUI.ProcessEvent inside all the other loops, for the GUI to remain active at all times.
Actually it's more of
Turing: |
if GUI.ProcessEvent then
% Quit has been called, prepare to exit
% do whatever needed
end if
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Skeltas
|
Posted: Thu Dec 27, 2007 7:18 pm Post subject: Re: Turing "Paint" with GUI, can't select multiple buttons... |
|
|
Well, the problem lies within the fact that I want the GUI active and non-active at the same time.
At this moment, due to procedure "startpaint", when I move to hit the "Quit" button, a paint circle appears instead of the Quit button being selected.
I'm guessing I'll have to add a restriction below a certain point to quit the "Paint" action, right? |
|
|
|
|
|
Tony
|
Posted: Thu Dec 27, 2007 8:35 pm Post subject: RE:Turing "Paint" with GUI, can\'t select multiple buttons... |
|
|
maybe to reduce confusion, you could disable all the buttons before starting startpaint, and enable them again when that procedure ends. This way the user can visually see that hitting Quit will not do anything while the loop is running. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Skeltas
|
Posted: Thu Dec 27, 2007 8:48 pm Post subject: Re: Turing "Paint" with GUI, can't select multiple buttons... |
|
|
I like that idea a lot actually, and I'll definately use it
How do you recommend I switch between 'Start on' and 'Start off'?
How could I make it so that the user can decide when to end it? |
|
|
|
|
|
Saad
|
Posted: Thu Dec 27, 2007 9:41 pm Post subject: RE:Turing "Paint" with GUI, can\'t select multiple buttons... |
|
|
What you could do is have each button set a different mode which is stored in a global variable, and process everything in a big loop. And have certain procedures called when certain modes are active, and at the end of the loop process all GUI events which change the mode of the program |
|
|
|
|
|
Skeltas
|
Posted: Thu Dec 27, 2007 9:48 pm Post subject: Re: Turing "Paint" with GUI, can't select multiple buttons... |
|
|
I'm sorta new to programming (I learnt it this year, and 'learnt' is a loose word with my teacher)...
The bones of my program is quoted near the beginning, what key changes would I need to make to accomplish what you said?
(It sounds very doable and workable) =D |
|
|
|
|
|
Saad
|
Posted: Thu Dec 27, 2007 10:06 pm Post subject: RE:Turing "Paint" with GUI, can\'t select multiple buttons... |
|
|
It should only need a new variable, and some changes on how you process stuff
I'll give you a general structure:
code: |
var MODE : string
%% Main Loop
loop
if Start is pressed then MODE = "Run"
if Quit is pressed then MODE = "Quit"
if MODE = "Run" then
Do your mouse draw part but don't put it in a loop
elsif MODE = "Quit" then
exit the loop
end if
end loop
|
This code was not meant to be actuall code, but rather just a general form |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Skeltas
|
Posted: Thu Dec 27, 2007 11:30 pm Post subject: RE:Turing "Paint" with GUI, can\'t select multiple buttons... |
|
|
All right, thanks for the psuedocode
I have what I need now, I'll see if I can work out the rest on my own.
Thanks! |
|
|
|
|
|
|
|