Introduction
Features
Command Reference
Tutorials
Examples

Colour Schemes
Extras

Online
The Structure of a BlitzUI application

 Part One - Introduction
Although BlitzUI isn't too strict on the order you do things, it's important to get two or three things done the right way. As long as you initialise BlitzUI before trying to do anything with it and destroy it when you're done with it anything else can go in any order between Initialising and Destroying.

 Part Two - Initialising BlitzUI
There are two steps to take to initialise BlitzUI... the first is to include it in your application.

Include "blitzui.bb"

Once you've done that you can call the Initialise( ) function which (apart from initialise the environment) loads all the fonts and mouse cursors, so if you want to use your own fonts this is where you need to look.

Initialise( )

That's all the code you need to use BlitzUI.. you don't even need to set a graphics mode.

 Part Three - Displaying BlitzUI
Some tutorials get more complicated as they get further towards the end.. this isn't one of them. Displaying BlitzUI is just as simple as initialising it.

UpdateGUI( )

Just put that in your main application/game loop to display all the windows and controls that you have created. If it's a 3D application/game just make sure it goes after the RenderWorld command or you won't see anything.

To display the mouse simply add:

DrawMouse( )

somewhere after UpdateGUI( ). If you want to change the mouse cursor at any point put:

app\MCurrent = MyLoadedImage

Be sure to put that after UpdateGUI( ) and before DrawMouse( ) or the default mouse cursor will override your one.

 Part Four - Handling Events
There's no set way to handle events in BlitzUI, mainly because different applications will need their own way of doing it. For example: an application will most likely want a set structure for handling and parsing all events that occur... a game however, will probably want to retrieve its own events when it needs them from different places all over the code. Anyone who has experience with API coding will recognise the following methods immediately. Lets start with the structured approach...

Select app\Event
    Case EVENT_WINDOW
        Select app\WindowEvent
            Case mywindow

        End Select
    Case EVENT_MENU
        Select app\MenuEvent
            Case mymenuitem

        End Select
    Case EVENT_GADGET
        Select app\GadgetEvent
            Case mygadget

        End Select
End Select

Thats the main event handling structure you would use... the best place for it is after UpdateGUI( ) and before DrawMouse( ).

The Case mywindow, Case mymenuitem and Case mygadget are simply examples of how you would use the structure... in your own apps you would replace those with your own window handles, your own menu handles and your own gadget handles (gadget is just another name for control).

The other method is to use SendMessage( ) whenever you want to retrieve event data. It's hard to give a good example since there are so many uses for SendMessage( ) but say you wanted to get the value of a slider which determines the current music volume of your game:

If KeyHit( 28 )
    MusicVolume = SendMessage( myslider, "SM_GETVALUE" )
EndId

How much easier can you get then that? Literally all you have to do to create a setting for music volume is create a slider and then use SendMessage( ) whenever you need to get the value of it.

 Part Five - Destroying BlitzUI
Ok, so you've initialised BlitzUI, you've created all the controls etc. and you've drawn it all on the screen... there's just one last thing you need to do right at the end of the program, which is to call:

Destroy( )

The chances are you have a section of your code that's set aside for ending the program.. whether it's as simple as "End" or as thorough as freeing everything from memory you should have something somewhere. This is where you need to call the Destroy( ) command. What this does is to free all the fonts, mouse cursors and images etc that were created and used by BlitzUI.