#Include "inc/wx.bi"

ChDir ExePath

Declare Function App_OnInit APICALL As wxBool
Declare Function App_OnExit APICALL As wxInt

Declare Sub bmpbutton0_cb APICALL

Dim Shared As _wxApp   Ptr App

Dim Shared As _wxBitmapButton Ptr bmpbuttons( 1 )

Function App_OnInit APICALL ( ) As wxBool
  Dim As _wxFrame Ptr Frame = wxFrame_ctor()
  wxFrame_Create(Frame, WX_NULL,, wxString("testfile"), _
                 483, 184, 337, 441, _
                 wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX _
                 Xor wxMAXIMIZE_BOX Xor wxRESIZE_BORDER)

  Dim As _wxPanel Ptr Panel = wxPanel_ctor2(Frame)

  ''' create widget Togglebutton
  Dim As _wxToggleButton Ptr ToggleButton = wxToggleButton_ctor( )
  wxToggleButton_Create(ToggleButton, Panel,,wxString("togglebutton0"), 10,10, 90,30)

  ''' create widget BitmapButton
  Dim As _wxBitmap Ptr Bitmap = wxBitmap_ctor()
  wxBitmap_LoadFile(bitmap, wxString("./media/close.bmp"), wxBITMAP_TYPE_BMP )
  Dim As _wxBitmapButton Ptr BitmapButton = wxBitmapButton_ctor( )
  wxBitmapButton_RegisterVirtual(BitmapButton, Cast(Virtual_OnSetBitmap, @bmpbutton0_cb) )
  bmpbuttons(0) = BitmapButton
  wxBitmapButton_Create(BitmapButton, Panel,,Bitmap, 120,10,,, 2 Or 4)
  wxWindow_SetBackgroundColour(BitmapButton,wxColour_ctorByParts( 255, 255, 255 ) )

  ''' create widget StaticBitmap
  Dim As _wxStaticBitmap Ptr StaticBitmap = wxStaticBitmap_ctor()
  wxBitmap_LoadFile(Bitmap, wxString("./media/close.bmp"), wxBITMAP_TYPE_BMP )
  wxStaticBitmap_Create(StaticBitmap, Panel,,Bitmap,20,60)

  ''' create widget Choice
  Dim As _wxChoice Ptr Choice = wxChoice_ctor()
  Dim As _wxArrayString Ptr ArrayString = wxArrayString_ctor()
  wxArrayString_Add(ArrayString, wxString("Choice0") )
  wxArrayString_Add(ArrayString, wxString("Choice1") )
  wxArrayString_Add(ArrayString, wxString("Choice2") )
  wxChoice_Create(Choice, Panel,, 20,110,,,ArrayString)
  wxChoice_SetColumns(Choice,0)

  ''' create widget combo0
  Dim As _wxCombobox Ptr ComboBox = wxCombobox_ctor()
  wxArrayString_clear(ArrayString)
  wxArrayString_Add(ArrayString, wxString("Combo0") )
  wxArrayString_Add(ArrayString, wxString("Combo1") )
  wxCombobox_Create(ComboBox, Panel,,wxString("ComboBox"), 130, 110,,, ArrayString)

  ''' create widget SpinCtrl
  Dim As _wxSpinCtrl Ptr SpinCtrl = wxSpinCtrl_ctor()
  wxSpinCtrl_Create(SpinCtrl, Panel,, wxString("50"), 20, 160,,,SP_ARROW_KEYS,0, 100)

  ''' create widget TextCtrl
  Dim As _wxTextCtrl Ptr TextCtrl = wxTextCtrl_ctor()
  wxTextCtrl_Create( TextCtrl, Panel,, wxString("any text"), _
                     20, 210, 100, 90, _
                     TE_PROCESS_ENTER Or TE_MULTILINE)
                     
  ''' create widget Gauge
  Dim As _wxGauge Ptr Gauge = wxGauge_ctor()
  wxGauge_Create(Gauge, Panel,, 100, 190, 30)
  wxGauge_SetValue(Gauge, 45)

  ''' create widget RadioBox
  wxArrayString_Clear ArrayString
  wxArrayString_Add(ArrayString, wxString("Radio1") )
  wxArrayString_Add(ArrayString, wxString("Radio2") )
  Dim As _wxRadiobox Ptr RadioBox = wxRadiobox_ctor()
  wxRadiobox_Create(RadioBox, Panel,, wxString("RadioBox"), 180, 150,,,ArrayString)
  wxRadiobox_SetSelection(RadioBox,0)

  ''' create widget ListBox
  wxArrayString_Clear ArrayString
  wxArrayString_Add(ArrayString, wxString("list0") )
  wxArrayString_Add(ArrayString, wxString("list1") )
  wxArrayString_Add(ArrayString, wxString("list2") )
  Dim As _wxListbox Ptr ListBox = wxListbox_ctor()
  wxListbox_Create(ListBox, Panel,, 180, 230,,,ArrayString)
  wxListbox_SetSelection(ListBox, 0, WX_TRUE )

  ''' create widget Slider
  Dim As _wxSlider Ptr Slider = wxSlider_ctor()
  wxSlider_Create(Slider, Panel,,0, 0,100, 20, 340,,, SL_LABELS)
  wxSlider_SetValue(Slider, 45)

  ''' create widget button
  Dim As _wxButton Ptr Button = wxButton_ctor( )
  wxButton_Create(Button, Panel,, wxString("button0"), 160, 350,, 24)

  wxWindow_Show(Frame, 1)
  wxApp_OnInit(App )

  Return 1

End Function

Function App_OnExit APICALL ( ) As wxInt
  Return wxApp_OnExit(App )
End Function

Sub bmpbutton0_cb APICALL ()
  wxBitmapButton_OnSetBitmap( bmpbuttons( 0 ) )
End Sub

'' main
wxImage_InitAllHandlers
App = wxApp_ctor( )
wxApp_RegisterVirtual(App, @App_OnInit, @App_OnExit)
wxApp_Run(0, 0)
End
