Help with GUI

Blitz3D Forums/Blitz3D Programming/Help with GUI

xmlspy(Posted 2004) [#1]
.


xmlspy(Posted 2004) [#2]
.


Matty(Posted 2004) [#3]
Write a function which does the following:
And simply call the function each time you wish to create
a button.

Ie NewButton("ButtonUp.jpg","ButtonOver.jpg",0,0,1,1) as an example..

Function NewButton(ImageName1$,ImageName2$,X#,Y#,Scalex#,ScaleY#)

Button.button_type=new button_type



Button\image1=LoadImage(ImageName1$)
Button\image2=LoadImage(ImageName2$)
Button\x#=x
Button\y#=y
Button\scalex#=ScaleX
Button\scaley#=ScaleY
Button\width#=ImageWidth(Button\image1)
Button\height#=ImageHeight(Button\image1


end function


xmlspy(Posted 2004) [#4]
.


N(Posted 2004) [#5]
Just some pseudo code...


Global B_Norm = Normal Image
Global B_Over = Mouse-over Image
Global B_Down = Mouse-click Image

Type Button
     Parent.Object
     Caption
     Identifier     ;used in a Select:Case:End Select to update it
     X,Y,Width,Height
End Type

Function AddButton.Button(P.Object,Image
     If Not (All the parameters are true values) Then Return Null
     B = New Button
     ;Assign all the same values to the new object
     Return B
End Function

Function UpdateButtons()
     Local B.Button
     For B = Each Button
          Select B.Identifier
               Case Button type 1
                    ;update accordingly
                    if (within(mousex(),mousey(),b.width,b.height)) then
                         if (mousedown(1) or mousehit(1) then
                              ;draw the click image
                         else
                              ;draw the mouse-over image
                         endif
                    else
                         ;draw the normal image
                    endif

               Case Button type 2
                    ;repeat but with slightly different stuff
          End Select
     Next
     Return True
End Function


That's basically how I did my old GUI... except that 'code' doesn't work.


Rook Zimbabwe(Posted 2005) [#6]
Thanks XMLspy I was wondering how to do this!


xmlspy(Posted 2005) [#7]
.


Rook Zimbabwe(Posted 2005) [#8]
Noel... gonna try and implement yours... will scream for help if I need the Dread Pirate Cower... ;)

RZ


N(Posted 2005) [#9]
Good lord, that code I wrote is horrible...


Rook Zimbabwe(Posted 2005) [#10]
yes but it can be saved... we can rebuild it... make it better... stronger... faster... The Six Million Dollar Button Code.... dunh dunh da nah...

RZ