include "%lib%/freshlib.inc"

@BinaryType GUI

LIB_MODE  equ OLD

include "%lib%/freshlib.asm"

include "../gui/realobjects.inc"
include "../gui/realobjects.asm"



object TObject
  .FOnCreate  dd ?
  .FOnDestroy dd ?

  param .OnCreate, .FOnCreate, .FOnCreate
  param .OnDestroy, .FOnDestroy, .FOnDestroy

  method .Create
  method .Destroy
endobj



object TWindow, TObject
  ._width dd ?
  ._height dd ?

  param  .width, ._width, .SetWidth
  param  .height, ._height, .SetHeight

  method .SetWidth, .value
  method .SetHeight, .value

  method .Show
  method .Hide
  method .Move, .x, .y
  method .Resize, .width, .height

  method .Create
  method .Destroy
endobj



method TWindow.Show
begin
        return
endp


method TWindow.Hide
begin
        return
endp


method TWindow.Move, .x, .y
begin
        return
endp


method TWindow.Resize, .width, .height
begin
        return
endp


method TObject.Create
begin
        return
endp



method TObject.Destroy
begin
        get     eax, [.self], TObject.OnDestroy
        test    eax, eax
        jz      .event_ok

        stdcall eax, [.self]

.event_ok:

        stdcall FreeMem, [.self]
        return
endp



method TWindow.Create
begin
        pexec   [.self], TWindow.Create

        return
endp


method TWindow.Destroy
begin
        ; more code here

        ; inherited at last

        pexec   [.self], TWindow.Destroy
        return
endp






method TWindow.SetWidth, .value
begin

        return
endp




method TWindow.SetHeight, .value
begin

        return
endp






start:
        int3
        create TWindow
        mov    esi, eax

        get ecx, esi, TWindow:width
        set esi, TWindow:width, 1024

        exec esi, TWindow.Show
        exec esi, TWindow.Resize, 480, 240



;vtables.TWindow  +

;call __methods.TWindowDestroy



