; _______________________________________________________________________________________
;|                                                                                       |
;| Portable GUI application in assembler.                                                |
;|_______________________________________________________________________________________|
;
;  Description: The main file of very simple example demonstrating how to write portable
;               GUI applications using FreshLib.
;
;  Target OS: Any
;
;  Dependencies: FreshLib - see includes in the source.
;_________________________________________________________________________________________

include '%lib%/compiler/executable.inc'
_BinaryType GUI


include '%lib%/macros/allmacros.inc'
include '%lib%/equates/allequates.inc'


_CodeSection

options.FastEnter         = 0           ; enter/leave or push ebp/pop ebp approach to the procedures.
options.ShowSkipped       = 0           ; shows the procedures skiped because of no use.
options.ShowSizes         = 1           ; enable/disable work of DispSize macro.
options.DebugMode         = 0           ; enable/disable macroses of simpledebug library.



include '%lib%/simpledebug/debug.asm'
include '%lib%/GUI/SysEvents.asm'
include '%lib%/timers/timers.asm'
include '%lib%/system/process.asm'
include '%lib%/system/memory.asm'
include '%lib%/data/arrays.asm'
include '%lib%/data/strlib.asm'
include '%lib%/graphics/context.asm'
include '%lib%/graphics/text.asm'
include '%lib%/graphics/draw.asm'
include '%lib%/graphics/images.asm'
include '%lib%/graphics/backbuffer.asm'
include '%lib%/graphics/giflib.asm'
include '%lib%/graphics/fonts.asm'

include '%lib%/GUI/GUI.asm'
include '%lib%/mouse/mouse.asm'



iglobal
  frmMainForm:
        ObjTemplate  tfParent or tfEnd, Form, frmMain, \
                     x, 100,        \
                     y, 50,         \
                     width, 320,    \
                     height, 240,   \
                     Visible, TRUE, \
                     Caption, 'FreshLib portable application.'

           ObjTemplate tfEnd, Button, btnTest,  \
                       x, 50, y, 50,            \
                       width, 128, height, 24,   \
                       Visible, TRUE,           \
                       TextAlign, dtfAlignCenter or dtfAlignMiddle, \
                       IconPosition, AlignLeft,                     \
                       OnClick, procOnClick,                        \
                       Caption, 'Do something'
endg


proc procOnClick, .self, .button
begin
; On click handler for the button.
        return
endp



; Main Program
start:
        InitializeAll

        stdcall Create, CApplication
        jc      .terminate

        mov     [Application], ebx

        stdcall CreateFromTemplate, frmMainForm, 0
        mov     ecx, [Application]
        mov     [ecx+TApplication.MainWindow], frmMain

        stdcall Run

.terminate:
        push    eax
        FinalizeAll

        stdcall Terminate       ; from the stack

; end of main program

_ImportSection
include '%lib%/imports/allimports.asm'

_DataSection
IncludeAllGlobals

