How To Draw A Panel

This how to introduce you to the User Interface functionality of SwinGame by demonstrate how to draw a basic panel on to the screen.

howtodrawapanel

Level

Beginner

Read these first

About Gui's

Details

To create a panel in your program it is mandatory to input the x, y, w, h and region data into a text file that will be stored in the Resources\panels folder. A snip set of the text file will be display below.

// Panel data: 
x: 5 
y: 5 
w: 600 
h: 300 
// Region data 
// Format: r: x, y, w, h, kind 
r: 10, 10, 80, 20, Label, Label1, courierSmall, l, Hello World  

Once the text file has been configured then the panel can be load through your program by using LoadPanel function. ShowPanel need to be call so that the panel will be set to display on screen, to draw the panel on screen DrawPanels procedure will be call. This DrawPanels will draw the entire panels that have been called by ShowPanel to the screen.

To demonstrate the above scenarios a screenshot will be display on the right showing the program created from the code below.

Source Code Widget

  • program HowToDrawAPanel;
    uses SwinGame,sgTypes,sgUserInterface;
    
    procedure Main();
    var
        p : Panel;
    begin
        OpenGraphicsWindow('How To Draw A Panel' ,800 ,600 );
        LoadDefaultColors();
        p := LoadPanel('panelwithlabel.txt' );
        ShowPanel(p );
        ClearScreen(ColorWhite );
        GUISetBackgroundColor(ColorBlack );
        DrawInterface();
        RefreshScreen();
        Delay(10000 );
        ReleaseAllResources();
    end;
    begin
        Main();
    end.
    Download Now"
  • #include 
    #include "SwinGame.h"
    int main() 
    {
        panel  p;
        open_graphics_window("How To Draw A Panel" ,800 ,600 );
        load_default_colors();
        p = load_panel("panelwithlabel.txt" ) ;
        show_panel(p );
        clear_screen(color_white );
        guiset_background_color(color_black );
        draw_interface();
        refresh_screen();
        delay(10000 );
        release_all_resources();
        return 0;
    }
    
    Download Now"
  • Source Code Coming Soon

  • Source Code Coming Soon

  • Source Code Coming Soon


Possibilities

Suggested projects will appear here.