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

Username:   Password: 
 RegisterRegister   
 Is there a way I can change the button's colour?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hosamhelal




PostPosted: Sat Jan 15, 2005 2:16 pm   Post subject: Is there a way I can change the button's colour?

For GUI Buttons; they are always gray, but is there a way i can change the colours to like....mmm...blue or green or purple. or any other colour? I am using V 4.05 Turing Smile Please someone, thanks!
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sat Jan 15, 2005 3:17 pm   Post subject: (No subject)

var exitbutton : int := GUI.CreateButton(940,20,0,"Exit",leave)

exitbutton is the variable for the button, 940 and 20 are the location of x and y. The number right after y (20 in this case) is the colour of the button. Exit is the label, and leave is the procedure that pressing the button will take you to.

I hope thats a good enough explanation, I'm fairly new to Turing. If you need more help, type GUI.CreateButton and press "F9", that will take you to the help section for that command.

oh, and in case you don't know - the colours in turing are:


    0 black
    1 blue
    2 green
    3 cyan
    4 red
    5 magenta
    6 brown
    7 white
    8 dark gray
    9 light blue
    10 light green
    11 light cyan
    12 light red
    13 light magenta
    14 yellow
    15 bright white
TheXploder




PostPosted: Sat Jan 15, 2005 3:38 pm   Post subject: (No subject)

or, you could make your own buttons, I made a procedure that makes buttons like in VB and you can change the colour of them... its better to make your own buttons they don't take much to make, and its unlimited.

This draws the button:

code:

% Selection Box ----------------------------------------------------
proc drawSelecLineY (x, y, buttonxsize, buttonysize : int)
    for i : 4 .. buttonysize - 4 by 2
        drawdot (x, y + i, 1)
    end for
end drawSelecLineY

proc drawSelecLineX (x, y, buttonxsize, buttonysize : int)
    for i : 4 .. buttonxsize - 4 by 2
        drawdot (x + i, y, 1)
    end for
end drawSelecLineX

proc drawSelectionBox (x, y, buttonxsize, buttonysize : int)
    drawSelecLineY (x + 4, y, buttonxsize, buttonysize)
    drawSelecLineY (x - 4 + buttonxsize, y, buttonxsize, buttonysize)
    drawSelecLineX (x, y + 4, buttonxsize, buttonysize)
    drawSelecLineX (x, y - 4 + buttonxsize, buttonxsize, buttonysize)
end drawSelectionBox
% -------------------------------------------------------------------

% Draw Released Button ----------------------------------------------------------------
proc objReButton (x, y, buttonxsize, buttonysize, clr : int)
    drawline (x, y, x + buttonxsize, y, 15)
    drawline (x + buttonxsize, y, x + buttonxsize, y + buttonysize, 15)
    drawline (x + 1, y + 1, x - 1 + buttonxsize, y + 1, 22)
    drawline (x + buttonxsize - 1, y + 1, x - 1 + buttonxsize, y + buttonysize - 1, 22)
    drawfillbox (x + 2, y + 2, x - 2 + buttonxsize, y - 2 + buttonysize, clr)
    drawline (x + 1, y + buttonysize - 1, x - 2 + buttonxsize, y + buttonysize - 1, 30)
    drawline (x + 1, y + buttonysize - 1, x - buttonxsize + 1 + buttonxsize, y + 2, 30)
    drawline (x, y + buttonysize, x - 1 + buttonxsize, y + buttonysize, 31)
    drawline (x, y + buttonysize, x - buttonxsize + buttonxsize, y + 1, 31)
end objReButton
% -------------------------------------------------------------------------------------

% Draw Pressed Button ------------------------------------------------------
proc objPrButton (x, y, buttonxsize, buttonysize, clr : int)
    drawfillbox (x + 2, y + 2, x - 2 + buttonxsize, y - 2 + buttonysize, clr)
    drawbox (x, y, x + buttonxsize, y + buttonysize, 7)
    drawbox (x + 1, y + 1, x - 1 + buttonxsize, y - 1 + buttonysize, 22)
end objPrButton
% --------------------------------------------------------------------------

% Draw Button(x, y, width, height, colour : int, [released/pressed], [selected/deselected] : srting)
proc drawbutton (x, y, buttonxsize, buttonysize, clr : int, press, select : string)
    if press = "released" and select = "selected" then
        objReButton (x, y, buttonxsize, buttonysize, clr)
        drawSelectionBox (x, y, buttonxsize, buttonysize)
    elsif press = "released" and select = "deselected" then
        objReButton (x, y, buttonxsize, buttonysize, clr)
    elsif press = "pressed" and select = "selected" then
        objPrButton (x, y, buttonxsize, buttonysize, clr)
        drawSelectionBox (x, y, buttonxsize, buttonysize)
    elsif press = "pressed" and select = "deselected" then
        objPrButton (x, y, buttonxsize, buttonysize, clr)
    end if
end drawbutton

% All Possibilities -------------------------------------------
drawbutton (1, 1, 50, 50, brightblue, "released", "deselected")
drawbutton (1, 51, 50, 50, brightblue, "pressed", "deselected")
drawbutton (1, 102, 50, 50, brightblue, "released", "selected")
drawbutton (1, 153, 50, 50, brightblue, "pressed", "selected")
%--------------------------------------------------------------
MysticVegeta




PostPosted: Sat Jan 15, 2005 7:00 pm   Post subject: Re: Is there a way I can change the button's colour?

hosamhelal wrote:
For GUI Buttons; they are always gray, but is there a way i can change the colours to like....mmm...blue or green or purple. or any other colour? I am using V 4.05 Turing Smile Please someone, thanks!

or maybe after declaring a button, you can go like this ->
code:

var main :int:== GUI.CreateButtonFull (200, 200, 0, "START!", mainMenu, 0, KEY_ENTER, false)
GUI.Setcolor(main, brightred)
hosamhelal




PostPosted: Sat Jan 15, 2005 10:34 pm   Post subject: Doenst work!

It says procedure set colour is not in the export list of 'GUI'
Cervantes




PostPosted: Sat Jan 15, 2005 11:26 pm   Post subject: (No subject)

It's
code:

GUI.SetColour

not
code:

GUI.Setcolour
hosamhelal




PostPosted: Sun Jan 16, 2005 12:00 am   Post subject: (No subject)

Thanks
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  [ 7 Posts ]
Jump to:   


Style:  
Search: