''

#Include Once "inc/Visual_WX-C_Designer.bi"

''
'' globals
''
	Dim Shared As TLIST widgetlist, menulist
	
	Dim Shared As wxPanel Ptr projpn
	Dim Shared As VWX_Widget Ptr selected
	Dim Shared As wxApp Ptr wx_app
	Dim Shared As wxFrame Ptr wx_frame, proj
	Dim Shared As Integer curtool, gridsize = 10, boxsize, boxsel = -1
	Dim Shared As Any Ptr mylist
	Dim Shared As wxButton Ptr delbut, updbut, evntbut, delbuttoo
	Dim Shared As wxTextCtrl Ptr toolText 'holds current tool as a text
	
	Dim Shared As AppProperties app
	
	Dim Shared As ZString Ptr events( 197 ) => { _
		StrPtr( "wxEvent_EVT_COMMAND_BUTTON_CLICKED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_CHECKBOX_CLICKED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_CHOICE_SELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LISTBOX_SELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LISTBOX_DOUBLECLICKED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_CHECKLISTBOX_TOGGLED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TEXT_UPDATED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TEXT_ENTER" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TEXT_URL" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TEXT_MAXLEN" ), _
		StrPtr( "wxEvent_EVT_COMMAND_MENU_SELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_SLIDER_UPDATED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_RADIOBOX_SELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_RADIOBUTTON_SELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_SCROLLBAR_UPDATED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_VLBOX_SELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_COMBOBOX_SELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TOOL_RCLICKED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TOOL_ENTER" ), _
		StrPtr( "wxEvent_EVT_COMMAND_SPINCTRL_UPDATED" ), _
		StrPtr( "wxEvent_EVT_SOCKET" ), _
		StrPtr( "wxEvent_EVT_TIMER" ), _
		StrPtr( "wxEvent_EVT_LEFT_DOWN" ), _
		StrPtr( "wxEvent_EVT_LEFT_UP" ), _
		StrPtr( "wxEvent_EVT_MIDDLE_DOWN" ), _
		StrPtr( "wxEvent_EVT_MIDDLE_UP" ), _
		StrPtr( "wxEvent_EVT_RIGHT_DOWN" ), _
		StrPtr( "wxEvent_EVT_RIGHT_UP" ), _
		StrPtr( "wxEvent_EVT_MOTION" ), _
		StrPtr( "wxEvent_EVT_ENTER_WINDOW" ), _
		StrPtr( "wxEvent_EVT_LEAVE_WINDOW" ), _
		StrPtr( "wxEvent_EVT_LEFT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_MIDDLE_DCLICK" ), _
		StrPtr( "wxEvent_EVT_RIGHT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_SET_FOCUS" ), _
		StrPtr( "wxEvent_EVT_KILL_FOCUS" ), _
		StrPtr( "wxEvent_EVT_CHILD_FOCUS" ), _
		StrPtr( "wxEvent_EVT_MOUSEWHEEL" ), _
		StrPtr( "wxEvent_EVT_NC_LEFT_DOWN" ), _
		StrPtr( "wxEvent_EVT_NC_LEFT_UP" ), _
		StrPtr( "wxEvent_EVT_NC_MIDDLE_DOWN" ), _
		StrPtr( "wxEvent_EVT_NC_MIDDLE_UP" ), _
		StrPtr( "wxEvent_EVT_NC_RIGHT_DOWN" ), _
		StrPtr( "wxEvent_EVT_NC_RIGHT_UP" ), _
		StrPtr( "wxEvent_EVT_NC_MOTION" ), _
		StrPtr( "wxEvent_EVT_NC_ENTER_WINDOW" ), _
		StrPtr( "wxEvent_EVT_NC_LEAVE_WINDOW" ), _
		StrPtr( "wxEvent_EVT_NC_LEFT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_NC_MIDDLE_DCLICK" ), _
		StrPtr( "wxEvent_EVT_NC_RIGHT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_CHAR" ), _
		StrPtr( "wxEvent_EVT_CHAR_HOOK" ), _
		StrPtr( "wxEvent_EVT_NAVIGATION_KEY" ), _
		StrPtr( "wxEvent_EVT_KEY_DOWN" ), _
		StrPtr( "wxEvent_EVT_KEY_UP" ), _
		StrPtr( "wxEvent_EVT_SET_CURSOR" ), _
		StrPtr( "wxEvent_EVT_SCROLL_TOP" ), _
		StrPtr( "wxEvent_EVT_SCROLL_BOTTOM" ), _
		StrPtr( "wxEvent_EVT_SCROLL_LINEUP" ), _
		StrPtr( "wxEvent_EVT_SCROLL_LINEDOWN" ), _
		StrPtr( "wxEvent_EVT_SCROLL_PAGEUP" ), _
		StrPtr( "wxEvent_EVT_SCROLL_PAGEDOWN" ), _
		StrPtr( "wxEvent_EVT_SCROLL_THUMBTRACK" ), _
		StrPtr( "wxEvent_EVT_SCROLL_THUMBRELEASE" ), _
		StrPtr( "wxEvent_EVT_SCROLL_ENDSCROLL" ), _
		StrPtr( "wxEvent_EVT_SCROLLWIN_TOP" ), _
		StrPtr( "wxEvent_EVT_SCROLLWIN_BOTTOM" ), _
		StrPtr( "wxEvent_EVT_SCROLLWIN_LINEUP" ), _
		StrPtr( "wxEvent_EVT_SCROLLWIN_LINEDOWN" ), _
		StrPtr( "wxEvent_EVT_SCROLLWIN_PAGEUP" ), _
		StrPtr( "wxEvent_EVT_SCROLLWIN_PAGEDOWN" ), _
		StrPtr( "wxEvent_EVT_SCROLLWIN_THUMBTRACK" ), _
		StrPtr( "wxEvent_EVT_SCROLLWIN_THUMBRELEASE" ), _
		StrPtr( "wxEvent_EVT_SIZE" ), _
		StrPtr( "wxEvent_EVT_MOVE" ), _
		StrPtr( "wxEvent_EVT_CLOSE_WINDOW" ), _
		StrPtr( "wxEvent_EVT_END_SESSION" ), _
		StrPtr( "wxEvent_EVT_QUERY_END_SESSION" ), _
		StrPtr( "wxEvent_EVT_ACTIVATE_APP" ), _
		StrPtr( "wxEvent_EVT_POWER" ), _
		StrPtr( "wxEvent_EVT_ACTIVATE" ), _
		StrPtr( "wxEvent_EVT_CREATE" ), _
		StrPtr( "wxEvent_EVT_DESTROY" ), _
		StrPtr( "wxEvent_EVT_SHOW" ), _
		StrPtr( "wxEvent_EVT_ICONIZE" ), _
		StrPtr( "wxEvent_EVT_MAXIMIZE" ), _
		StrPtr( "wxEvent_EVT_MOUSE_CAPTURE_CHANGED" ), _
		StrPtr( "wxEvent_EVT_PAINT" ), _
		StrPtr( "wxEvent_EVT_ERASE_BACKGROUND" ), _
		StrPtr( "wxEvent_EVT_NC_PAINT" ), _
		StrPtr( "wxEvent_EVT_PAINT_ICON" ), _
		StrPtr( "wxEvent_EVT_MENU_OPEN" ), _
		StrPtr( "wxEvent_EVT_MENU_CLOSE" ), _
		StrPtr( "wxEvent_EVT_MENU_HIGHLIGHT" ), _
		StrPtr( "wxEvent_EVT_CONTEXT_MENU" ), _
		StrPtr( "wxEvent_EVT_SYS_COLOUR_CHANGED" ), _
		StrPtr( "wxEvent_EVT_DISPLAY_CHANGED" ), _
		StrPtr( "wxEvent_EVT_SETTING_CHANGED" ), _
		StrPtr( "wxEvent_EVT_QUERY_NEW_PALETTE" ), _
		StrPtr( "wxEvent_EVT_PALETTE_CHANGED" ), _
		StrPtr( "wxEvent_EVT_JOY_BUTTON_DOWN" ), _
		StrPtr( "wxEvent_EVT_JOY_BUTTON_UP" ), _
		StrPtr( "wxEvent_EVT_JOY_MOVE" ), _
		StrPtr( "wxEvent_EVT_JOY_ZMOVE" ), _
		StrPtr( "wxEvent_EVT_DROP_FILES" ), _
		StrPtr( "wxEvent_EVT_DRAW_ITEM" ), _
		StrPtr( "wxEvent_EVT_MEASURE_ITEM" ), _
		StrPtr( "wxEvent_EVT_COMPARE_ITEM" ), _
		StrPtr( "wxEvent_EVT_INIT_DIALOG" ), _
		StrPtr( "wxEvent_EVT_IDLE" ), _
		StrPtr( "wxEvent_EVT_UPDATE_UI" ), _
		StrPtr( "wxEvent_EVT_SIZING" ), _
		StrPtr( "wxEvent_EVT_MOVING" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LEFT_CLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LEFT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_RIGHT_CLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_RIGHT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_SET_FOCUS" ), _
		StrPtr( "wxEvent_EVT_COMMAND_KILL_FOCUS" ), _
		StrPtr( "wxEvent_EVT_COMMAND_ENTER" ), _
		StrPtr( "wxEvent_EVT_HELP" ), _
		StrPtr( "wxEvent_EVT_DETAILED_HELP" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TOGGLEBUTTON_CLICKED" ), _
		StrPtr( "wxEvent_EVT_OBJECTDELETED" ), _
		StrPtr( "wxEvent_EVT_CALENDAR_SEL_CHANGED" ), _
		StrPtr( "wxEvent_EVT_CALENDAR_DAY_CHANGED" ), _
		StrPtr( "wxEvent_EVT_CALENDAR_MONTH_CHANGED" ), _
		StrPtr( "wxEvent_EVT_CALENDAR_YEAR_CHANGED" ), _
		StrPtr( "wxEvent_EVT_CALENDAR_DOUBLECLICKED" ), _
		StrPtr( "wxEvent_EVT_CALENDAR_WEEKDAY_CLICKED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_FIND" ), _
		StrPtr( "wxEvent_EVT_COMMAND_FIND_NEXT" ), _
		StrPtr( "wxEvent_EVT_COMMAND_FIND_REPLACE" ), _
		StrPtr( "wxEvent_EVT_COMMAND_FIND_REPLACE_ALL" ), _
		StrPtr( "wxEvent_EVT_COMMAND_FIND_CLOSE" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_BEGIN_DRAG" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_BEGIN_RDRAG" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_BEGIN_LABEL_EDIT" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_END_LABEL_EDIT" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_DELETE_ITEM" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_GET_INFO" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_SET_INFO" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_ITEM_EXPANDED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_ITEM_EXPANDING" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_ITEM_COLLAPSED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_ITEM_COLLAPSING" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_SEL_CHANGED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_SEL_CHANGING" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_KEY_DOWN" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_ITEM_ACTIVATED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_ITEM_RIGHT_CLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_ITEM_MIDDLE_CLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_TREE_END_DRAG" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_BEGIN_DRAG" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_BEGIN_RDRAG" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_BEGIN_LABEL_EDIT" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_END_LABEL_EDIT" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_DELETE_ITEM" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_DELETE_ALL_ITEMS" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_GET_INFO" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_SET_INFO" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_ITEM_SELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_ITEM_DESELECTED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_ITEM_ACTIVATED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_ITEM_FOCUSED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_ITEM_MIDDLE_CLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_ITEM_RIGHT_CLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_KEY_DOWN" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_INSERT_ITEM" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_COL_CLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_COL_RIGHT_CLICK" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_COL_BEGIN_DRAG" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_COL_DRAGGING" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_COL_END_DRAG" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LIST_CACHE_HINT" ), _
		StrPtr( "wxEvent_EVT_COMMAND_NOTEBOOK_PAGE_CHANGED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_NOTEBOOK_PAGE_CHANGING" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LISTBOOK_PAGE_CHANGED" ), _
		StrPtr( "wxEvent_EVT_COMMAND_LISTBOOK_PAGE_CHANGING" ), _
		StrPtr( "wxEvent_EVT_GRID_CELL_LEFT_CLICK" ), _
		StrPtr( "wxEvent_EVT_GRID_CELL_RIGHT_CLICK" ), _
		StrPtr( "wxEvent_EVT_GRID_CELL_LEFT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_GRID_CELL_RIGHT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_GRID_LABEL_LEFT_CLICK" ), _
		StrPtr( "wxEvent_EVT_GRID_LABEL_RIGHT_CLICK" ), _
		StrPtr( "wxEvent_EVT_GRID_LABEL_LEFT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_GRID_LABEL_RIGHT_DCLICK" ), _
		StrPtr( "wxEvent_EVT_GRID_ROW_SIZE" ), _
		StrPtr( "wxEvent_EVT_GRID_COL_SIZE" ), _
		StrPtr( "wxEvent_EVT_GRID_RANGE_SELECT" ), _
		StrPtr( "wxEvent_EVT_GRID_CELL_CHANGE" ), _
		StrPtr( "wxEvent_EVT_GRID_SELECT_CELL" ), _
		StrPtr( "wxEvent_EVT_GRID_EDITOR_SHOWN" ), _
		StrPtr( "wxEvent_EVT_GRID_EDITOR_HIDDEN" ), _
		StrPtr( "wxEvent_EVT_GRID_EDITOR_CREATED" ), _
		StrPtr( "wxEvent_EVT_SASH_DRAGGED" ), _
		StrPtr( "wxEvent_EVT_QUERY_LAYOUT_INFO" ), _
		StrPtr( "wxEvent_EVT_CALCULATE_LAYOUT" ) _
	}
	
	Dim Shared As Byte gridon = FALSE
	Dim Shared As wxWindowDC Ptr grid
	Dim Shared As wxImage Ptr gridparts( 3 )
	Dim Shared As wxMenu Ptr gridmenu, menu2, menu3
	Dim Shared As wxCheckbox Ptr menu_on, toolbar_on
	'ReDim Shared As wxBitmapButton Ptr bitbuttons( /'1 To 24'/ ) 'ubound is count( tools ) + 4 boxes
	Dim Shared As wxBitmapButton Ptr boxes(0 To VXW_BOXES - 1)


''
'' Initializer for the main window wx_frame
''
Sub init_mainwin( )
	
	wxWindow_SetAutoLayout( wx_frame, TRUE)
	wxWindow_CenterOnScreen( wx_frame, wxBOTH )
	
	Dim sizer As wxSize Ptr
	sizer = wxSize( -1, -1 )
	wxWindow_GetPosition( wx_frame, sizer )
	wxWindow_Move( wx_frame, wxSize_GetWidth( sizer ) * 2, wxSize_GetHeight( sizer ), 0 )
	wxWindow_SetBackgroundColour( wx_frame, wxSystemSettings_GetColour(15) )
	
	wxEvtHandler_proxy( wx_frame, Cast(EventListener, @event_mainframe) )
	wxEvtHandler_Connect( wx_frame, wxEvent_EVT_CLOSE_WINDOW(), mainframe, -1, 0 )
	wxWindow_Show( wx_frame, 1 )
End Sub

''
'' Initializer for application window proj
''
Sub init_projwin( )	
	
	wxWindow_SetBackgroundColour( proj, wxSystemSettings_GetColour(15) )
	wxWindow_CenterOnScreen( proj, wxBOTH)
	wxEvtHandler_proxy( proj, Cast(EventListener, @menu_change) )
	'wxEvtHandler_proxy( proj, Cast(EventListener, @event_projframe) )
	'wxEvtHandler_Connect( proj, wxEvent_EVT_LEFT_UP(), projframe, -1, 0 )
	'wxEvtHandler_Connect( proj, wxEvent_EVT_MOTION(), -1, -1, 0 )
	wxEvtHandler_Connect( proj, wxEvent_EVT_MOVE(), -1, -1, 0 )
	'wxEvtHandler_Connect( proj, wxEvent_EVT_SET_FOCUS(), -1, -1, 0 )
	wxEvtHandler_Connect( proj, wxEvent_EVT_CHAR(), -1, -1, 0 )
	wxEvtHandler_Connect( proj, wxEvent_EVT_SIZE(), -1, -1, 0 )
	wxEvtHandler_Connect( proj, wxEvent_EVT_COMMAND_MENU_SELECTED(), -1, -1, 0 )
	
	wxEvtHandler_proxy( projpn, Cast(EventListener, @event_projframe) )
	wxEvtHandler_Connect( projpn, wxEvent_EVT_ERASE_BACKGROUND(), -1, -1, 0 ) 'catch this event so the grid doesn't get erased
	wxEvtHandler_Connect( projpn, wxEvent_EVT_LEFT_UP(), -1, -1, 0 )
	wxEvtHandler_Connect( projpn, wxEvent_EVT_LEFT_DOWN(), -1, -1, 0 )
	wxEvtHandler_Connect( projpn, wxEvent_EVT_MOTION(), -1, -1, 0 )	
	wxEvtHandler_Connect( projpn, wxEvent_EVT_SET_FOCUS(), -1, -1, 0 )
	wxEvtHandler_Connect( projpn, wxEvent_EVT_CHAR(), -1, -1, 0 )
	wxEvtHandler_Connect( projpn, wxEvent_EVT_PAINT(), -1, -1, 0 )
	
	'wxWindow_SetAutoLayout( proj, TRUE )
	
	wxWindow_Show( proj, 1 )
	
	gridsize = 10
	boxsize = 10
	
End Sub

''
'' Initialzier for everything
''
Sub App_OnInit ()
	
	app.title = "My WX-C Project"
	app.fileName = "My_WX-C_Project.bas"
	'app.icon = "" 'event_mainframe()
	'app.savePath = "" 'event_mainframe()
	'app.relativePath = "" 'event_mainframe()
	'app.additionalOutput = FALSE 'event_mainframe()
	
	wxImage_InitAllHandlers( )
	
	wx_frame = wxFrame( )
	
	'Mainframe
	wxFrame_Create( wx_frame, 0, mainframe, "WX-C Designer", _ '"Visual WX-C Designer"
					wxSize( -1, -1 ), wxSize( 200 - 2, 600 ), _
					wxDEFAULT_FRAME_STYLE Or wxCLOSE_BOX Xor wxMAXIMIZE_BOX Xor wxRESIZE_BORDER, _
					"frame" )
	
	'Projectframe
	proj = wxFrame( )
	wxFrame_Create( proj, wx_frame, projframe, app.title, _
					wxSize( -1, -1 ), wxSize( 400, 400 ), _
					wxDEFAULT_FRAME_STYLE Xor wxMINIMIZE_BOX, _
					"frame" )
	
	'Projectpanel
	projpn = wxPanel( )
	wxPanel_Create( projpn, proj, 1, 0, 0, 0, 0 )
	
	init( )
	
	init_mainwin( )
	
	init_projwin( )
	
	redrawgrid( )
	
	wxApp_OnInit( wx_app )
	
End Sub

''
'' Exits all
''
Sub App_OnExit()
	
	wxApp_OnExit( wx_app )
	
End Sub


''
'' main
''
	wx_app = wxApp( )
	wxApp_RegisterVirtual( wx_app, Cast( Virtual_OnInit, @App_OnInit ), Cast( Virtual_OnExit, @App_OnExit ) )
	wxApp_Run( 0, 0 )
	
	End
