''
'' wx-c sizers example, by dumbledore
''
#Include Once "inc/wx.bi"

'' globals
Dim Shared As _wxApp Ptr app
Dim Shared As _wxSizer Ptr sizer

''
Sub sizer_OnDispose APICALL( )

End Sub

''
Sub sizer_OnRecalcSizes  APICALL ( )
  wxBoxSizer_RecalcSizes( sizer )
End Sub

''
Function App_OnInit APICALL ( ) As wxBool
  '' create the main window
  Dim As _wxFrame Ptr frame = wxFrame_ctor( )
  wxFrame_Create( frame,,1,wxString("Welcome to WX-C"),,,,, _
                 wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX, WX_NULL )

  '' create a box sizer and set as the new layout
  sizer = wxBoxSizer_ctor( wxVERTICAL ) 
  wxBoxSizer_RegisterVirtual( sizer, @sizer_OnRecalcSizes )
  wxBoxSizer_RegisterDisposable( sizer, @sizer_OnDispose )
  wxWindow_SetAutoLayout( frame, WX_TRUE )

  '' create button 1 and add to sizer
  Dim As _wxButton Ptr button1 = wxButton_ctor( )
  wxButton_Create( button1, frame, 1, wxString("Button1"))
  wxSizer_AddWindow( sizer, button1)

  '' create button 2 and add to sizer
  Dim As _wxButton Ptr button2 = wxButton_ctor( )
  wxButton_Create( button2, frame, 2, wxString("Button2"))
  wxSizer_AddWindow( sizer, button2)

  ''
  wxWindow_SetSizerAndFit( frame, sizer, 0 )

  ''
  wxWindow_CenterOnScreen( frame, wxBOTH )

  wxWindow_Show(frame)

  Function = wxApp_OnInit( app )
End Function
''
Function App_OnExit APICALL ( ) As wxInt
  return wxApp_OnExit( app )
End Function

'' main
app = wxApp_ctor
wxApp_RegisterVirtual( app, @App_OnInit, @App_OnExit )
wxApp_Run
 
