#Include "wx-c 0.9.2/wx.bi"

Declare Function App_OnInit WXCALL ( ) As wxBool
Declare Function App_OnExit WXCALL ( ) As wxInt

Declare Sub menuhandler WXCALL ( ByVal event As wxEvent Ptr, ByVal iListener As Long )

Dim Shared As wxApp Ptr wx_app
Dim Shared As wxFrame Ptr wx_frame
Dim Shared As wxPanel Ptr wx_panel
Dim Shared As wxCheckBox Ptr checkbox0

Function App_OnInit WXCALL ( ) As wxBool
    
    wx_frame = wxFrame_ctor( )
    wxFrame_Create( wx_frame, WX_NULL, -1, wxString_ctorUTF8("Menutest"), 483, 184, 167, 124, wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX Xor wxMAXIMIZE_BOX Xor wxRESIZE_BORDER, WX_NULL )
    wx_panel = wxPanel_ctor2( wx_frame, -1, -1, -1, -1, -1, 0, WX_NULL )
    
    ''
    '' create widget checkbox0
    ''
    checkbox0 = wxCheckBox_ctor( )
    wxCheckBox_Create( checkbox0, wx_panel, -1, wxString_ctorUTF8("checkbox0"), 40, 30, -1, -1, 0, 0, 0 )
    wxCheckBox_SetValue( checkbox0, 0 )
    
    
    '' create menues
    Dim As wxMenuBar Ptr wx_menubar
    wx_menubar = wxMenuBar_ctor( )
    
    '' menu " + menu->name + "
    Dim As wxMenu Ptr wx_menu0
    wx_menu0 = wxMenu_ctor( wxString_ctorUTF8(""), 0 )
    wxMenuBase_Append( wx_menu0, 1, wxString_ctorUTF8("Check it"), wxString_ctorUTF8("Check it"), 0 )
    wxMenuBase_AppendSeparator( wx_menu0 )
    wxMenuBase_Append( wx_menu0, 2, wxString_ctorUTF8("Exit"), wxString_ctorUTF8("Exit"), 0 )
    wxMenuBar_Append( wx_menubar, wx_menu0, wxString_ctorUTF8("&Do") )
    '' menu " + menu->name + "
    Dim As wxMenu Ptr wx_menu1
    wx_menu1 = wxMenu_ctor( wxString_ctorUTF8(""), 0 )
    wxMenuBase_Append( wx_menu1, 3, wxString_ctorUTF8("Uncheck it"), wxString_ctorUTF8("Uncheck it"), 0 )
    wxMenuBar_Append( wx_menubar, wx_menu1, wxString_ctorUTF8("&Undo") )
    wxFrame_SetMenuBar(wx_frame, wx_menubar)
    
    wxEvtHandler_Proxy( wx_frame, Cast(EventListener, @menuhandler) )
    wxEvtHandler_Connect( wx_frame, wxEvent_EVT_COMMAND_MENU_SELECTED( ), -1, -1, 0 )
    
    wxWindow_Show( wx_frame, 1 )
    wxApp_OnInit( wx_app )
    Return 1
    
End Function

Function App_OnExit WXCALL ( ) As wxInt
    
    Return wxApp_OnExit( wx_app )
    
End Function

Sub menuhandler WXCALL ( ByVal event As wxEvent Ptr, ByVal iListener As Long )
    
    Select Case wxEvent_GetId( event )
        Case 1
            '' stuff for selecting item Check it from menu &Do goes here
            wxCheckBox_SetValue( checkbox0, WX_TRUE )
        Case 2
            '' stuff for selecting item Exit from menu &Do goes here
            End
        Case 3
            '' stuff for selecting item Uncheck it from menu &Undo goes here
            wxCheckBox_SetValue( checkbox0, WX_FALSE )
    End Select
    
End Sub


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