Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 5 buttons with text in them
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chroncile




PostPosted: Wed Dec 03, 2008 7:03 pm   Post subject: 5 buttons with text in them

I don't know how to do this and it's due tomorrow.
This is what it says:

Quote:


Create a screen using pixel graphics that displays 5 boxes, in 5 different colours. Within each box you should have words to indicate what will appear when you click on that box. E.g. OVAL, CIRCLE, STAR MAPLE LEAF. Ask the user to click on a box. Once the user clicks on a box you should clear the screen and draw a picture of the shape that they clicked on.


I have no idea how to do that, please someone help me. Our teacher expects us to learn by our selves. How are we suppose to do that without anyone teaching us?!
Sad
Sponsor
Sponsor
Sponsor
sponsor
corriep




PostPosted: Wed Dec 03, 2008 7:16 pm   Post subject: RE:5 buttons with text in them

Try searching Turing's Help (F10)

look up Mouse.Where, and whatdotcolor

and if you have no idea how to do the text and boxes, look up drawfillbox and Font.Draw


thats all I can give you without giving you the answer
chroncile




PostPosted: Wed Dec 03, 2008 7:55 pm   Post subject: RE:5 buttons with text in them

This is the example the teacher gave us:

Turing:
setscreen ("graphics:vga")

% VARIABLE TABLE
% x - int - the x coordinate that the user clicked on
% y - int - the y coordinate that the user clicked on
% bnum - int - the button that you select on the mouse
% bud - int - whether the button is pressed (1) or released (0)

var x, y, bnum, bud : int

% draw three boxes
drawfillbox (100, 200, 200, 220, 1)
drawfillbox (100, 240, 200, 260, 2)
drawfillbox (100, 280, 200, 300, 14)

% prompt the user to click on a box
put "Please click the mouse inside a box"

% waits for the user to use the mouse and obtains the x,y location where the
% mouse is clicked down
buttonwait ("down", x, y, bnum, bud)

% checks to see which box the user selected and performs the specific request
if x >= 100 and x <= 200 and y >= 200 and y <= 220 then % box 1 selected
    colour (1)
    put "Thank you for clicking inside the blue box"
elsif x >= 100 and x <= 200 and y >= 240 and y <= 260 then      % box 2 selected
    colour (2)
    put "Thank you for clicking inside the green box"
elsif x >= 100 and x <= 200 and y >= 280 and y <= 300 then      % box 3 selected
    colour (14)
    put "Thank you for clicking inside the yellow box"
else                                        % no box selected
    colour (4) 
    put "YOU DID NOT CLICK INSIDE A BOX"
end if


I'm getting an idea from this, but how can I put in text in the box without have the box's colour erased?

Mod Edit: Remember to use syntax tags! Smile
code:
[syntax="Turing"]Code Here[/syntax]
A.J




PostPosted: Wed Dec 03, 2008 9:29 pm   Post subject: Re: 5 buttons with text in them

hmmmmmmmmmm...look up GUI buttons in turing.

but since ur teacher's example didn't use GUI.....oh well

here's an example of sample buttons:

Turing:

import GUI % imports the Graphics User Interface

/* The procedures that are run when the buttons are pressed */
proc blueButtonCommand
    put "You pushed the blue button"
    delay (500)
    cls
    GUI.Refresh
end blueButtonCommand

proc greenButtonCommand
    put "You pushed the green button"
    delay (500)
    cls
    GUI.Refresh
end greenButtonCommand


/* Creates the Buttons and Sets the colors for the buttons */

var blueButton : int := GUI.CreateButtonFull (maxx div 2 - 50, maxy div 2, 0, "Button",
    blueButtonCommand, blue, '^B', true)

GUI.SetColor (blueButton, brightblue)

var greenButton : int := GUI.CreateButtonFull (maxx div 2 + 50, maxy div 2, 0, "Button",
    greenButtonCommand, green, '^G', true)

GUI.SetColor (greenButton, brightgreen)

var quitButton : int := GUI.CreateButton (maxx div 2, maxy div 2 - 50, 0, "Quit", GUI.Quit)

GUI.SetColor (quitButton, brightred)

/* The loop that processes the pressing of the buttons. It exits when the "Quit" button is pressed */
loop
    exit when GUI.ProcessEvent
end loop


if u need any help, please ask me (as I have a tendency to be unclear Very Happy)
chroncile




PostPosted: Wed Dec 03, 2008 9:33 pm   Post subject: RE:5 buttons with text in them

It doesn't work, it says " 'SetColor' is not on the export list of 'GUI' "
corriep




PostPosted: Thu Dec 04, 2008 7:30 am   Post subject: RE:5 buttons with text in them

try setting colorback to whatever the box color is and use the locate command
Parker




PostPosted: Thu Dec 04, 2008 8:23 am   Post subject: Re: 5 buttons with text in them

Just did this quick...

Turing:
View.Set("graphics, offscreenonly")
var x, y, b : int %vars for the mouse where code
var buttonfnt : int
buttonfnt := Font.New ("Arial:18:underline")

loop
    drawfillbox (220, 240, 420, 340, 40)
    Font.Draw ("Maple leaf", 264, 282, buttonfnt, 255)
View.Update
    Mouse.Where (x, y, b)

    if b = 1 then %mouse click
        if x > 220 and x < 420 and y > 240 and y < 340 then         % click inside rectangle
            exit
        end if
    end if
end loop

cls
drawfillmapleleaf(100,100,500,400,40)


Hope that will help, just make a few more buttons doing somewhat the same thing.
Insectoid




PostPosted: Thu Dec 04, 2008 12:15 pm   Post subject: RE:5 buttons with text in them

Yeah, it is easier and looks nicer to make your own buttons. If you know how to make a button work, it is far easier. You know exactly what is going on with it, while with the GUI you need to look up all the functions that never work the way you want them to, and it looks like crap to boot!
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: