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

Const CHILDREN = 4

'' globals
Dim Shared As _wxApp            Ptr app
Dim Shared As _wxMDIParentFrame Ptr mdiparent


'' obligatory callback when creating parent MDI frames
Function mdiparent_OnCreateClient APICALL () As _wxMDIClientWindow Ptr
  Function = wxMDIParentFrame_OnCreateClient( mdiparent )
End Function

''
Sub init_frames( )
  '' create the parent MDI frame
  mdiparent = wxMDIParentFrame_ctor( )
  wxMDIParentFrame_RegisterVirtual( mdiparent, @mdiparent_OnCreateClient )
  wxMDIParentFrame_Create(mdiparent,,,wxString("parent"),,, _
                          500, 500,wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX Or wxVSCROLL Or wxHSCROLL)
  '' now the child ones
  Dim As _wxMDIChildFrame Ptr childframe
  Dim As Integer i
  For i = 1 To CHILDREN
    childframe = wxMDIChildFrame_ctor( )
    wxMDIChildFrame_Create(childframe, mdiparent,i, wxString("child_" & i), _
                           10*i, 10*i, 120, 100, wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX, wxString("wxMDIChildFrame") )
  Next
End Sub

''
Sub init_menus( )
  Dim As _wxMenu Ptr menu = wxMenu_ctor( wxString(""), 0 )
  wxMenuBase_Append( menu, -1, wxString("&Nothing"), wxString("This does squat."), 0 )
  Dim As _wxMenuBar Ptr mbar = wxMenuBar_ctor( )
  wxMenuBar_Append( mbar, menu, wxString("&File") )
  wxFrame_SetMenuBar( mdiparent, mbar )
End Sub

''
Function App_OnInit APICALL() As wxBool
  ''
  init_frames()
  ''
  init_menus()
  ''
  wxWindow_Show(mdiparent)
  
  return 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
 
