An Example

Ok - now it gets complicated ;)

The simplest way to learn is by example - so here is a simple bit of code that will run through the basics of setting up XLnt, adding some stuff, and entering the loop. Code is in Bold, comments are non-bold.

;Simple XLnt example

;First we Include the XLnt file

Include "XLnt-GUI.bb"

;Now we settup our GFX display

Graphics 800,600,16,1

;Now we call our GFX setup function

GUI_GFXSETUP()

;Thats it, we are now ready to access the XLnt Functions

;Lets add a Window

;We'll call it "mywin"

mywin.WINDOW=GUI_WINDOW(10,10,100,100,"A Window")

;This will setup a window at position 10,10 and with dimensions 100x100

;Now that we've got a window we can add some gadgets to it...so lets add one

quit.GADGET=GUI_BUTTUN(mywin,50,50,60,"Quit",1,"Quit This Program")

;We've just added a button at 50,50 which is 60 pixels wide and has the caption "Quit"

;Notice the .WINDOW and .GADGET ? This is because XLnt uses TYPES so don't forget these

;We've finished setting up this window now, so we can open it and display it on-screen

GUI_OPENWIN(mywin)

;Now we can drop through to our main loop....

Repeat

  ;First we sort out the GFX Buffers

  Flip:SetBuffer BackBuffer():Cls

  ;Now we call the important GUI Function

  ;This updates the gui and checks for user input

  GUI()

  ;Now we check what Events occured during the last GUI Update

  Select EVENT$

      Case "GUI_GADHIT"

         ;A Gadget was clicked, so now we need to find out which one it was

         If GUI_GADHIT=quit

            ;Our quit button was clicked, so set the done flag to true

            DONE=true

         Endif

      Case "MENU"

         ;A menu item was clicked - well, it might have been if we added any ;P

      Case "KILLWIN"

         ;A Kill Window button was clicked

         If GUI_ACTIVEWIN=mywin

             DONE=true

         Endif

  End Select

Until DONE=True

;We are done with the program, so we can free our GUI stuff

GUI_END()

END

 

That wasn't too difficult now was it?It doesn't do much, but thats about as complicated as it gets :) If you want to see some more complex examples then take a look at the examples folder in the download.