#!/usr/bin/env lisp
;;;
;;; generated by wxGlade
;;;

(asdf:operate 'asdf:load-op 'wxcl)
(use-package "FFI")
(ffi:default-foreign-language :stdc)


;;; begin wxGlade: dependencies
(use-package :wxButton)
(use-package :wxCL)
(use-package :wxColour)
(use-package :wxEvent)
(use-package :wxEvtHandler)
(use-package :wxFrame)
(use-package :wxGrid)
(use-package :wxPanel)
(use-package :wxSizer)
(use-package :wxWindow)
(use-package :wx_main)
(use-package :wx_wrapper)
;;; end wxGlade

;;; begin wxGlade: extracode
;;; end wxGlade


(defclass MyFrame()
        ((top-window :initform nil :accessor slot-top-window)
        (panel-1 :initform nil :accessor slot-panel-1)
        (sizer-1 :initform nil :accessor slot-sizer-1)
        (button-1 :initform nil :accessor slot-button-1)
        (grid-1 :initform nil :accessor slot-grid-1)))

(defun make-MyFrame ()
        (let ((obj (make-instance 'MyFrame)))
          (init obj)
          (set-properties obj)
          (do-layout obj)
          obj))

(defmethod init ((obj MyFrame))
"Method creates the objects contained in the class."
        ;;; begin wxGlade: MyFrame.__init__
        (setf (slot-top-window obj) (wxFrame_create nil wxID_ANY "" -1 -1 -1 -1 wxDEFAULT_FRAME_STYLE))
        (slot-top-window obj).wxWindow_SetSize((400, 300))
        (wxFrame_SetTitle (slot-top-window obj) "frame")
        
        (setf (slot-panel-1 obj) (wxPanel_Create (slot-top-window obj) wxID_ANY -1 -1 -1 -1 wxTAB_TRAVERSAL))
        
        (setf (slot-sizer-1 obj) (wxBoxSizer_Create wxVERTICAL))
        
        (setf (slot-button-1 obj) (wxButton_Create (slot-panel-1 obj) wxID_ANY "button_1" -1 -1 -1 -1 0))
        (wxSizer_AddWindow (slot-sizer-1 obj) (slot-button-1 obj) 0 0 0 nil)
        
        (setf (slot-grid-1 obj) (wxGrid_Create (slot-panel-1 obj) wxID_ANY -1 -1 -1 -1 wxWANTS_CHARS))
        (wxGrid_CreateGrid (slot-grid-1 obj) 10 4 0)
        (wxGrid_SetSelectionMode (slot-grid-1 obj) wxGridSelectRows)
        (wxSizer_AddWindow (slot-sizer-1 obj) (slot-grid-1 obj) 1 wxEXPAND 0 nil)
        
        (wxWindow_SetSizer (slot-panel-1 obj) (slot-sizer-1 obj))
        
        (wxFrame_layout (slot-frame self))

        (wxEvtHandler_Connect (slot-top-window obj) obj.panel-1 (expwxEVT_LEFT_DOWN)
        (wxClosure_Create #'on_left_down_panel obj))
        (wxEvtHandler_Connect (slot-top-window obj) obj.button-1 (expwxEVT_BUTTON)
        (wxClosure_Create #'on_button obj))
        (wxEvtHandler_Connect (slot-top-window obj) obj.button-1 (expwxEVT_LEFT_DOWN)
        (wxClosure_Create #'on_left_down obj))
        (wxEvtHandler_Connect (slot-top-window obj) obj.button-1 (expwxEVT_MOUSE_EVENTS)
        (wxClosure_Create #'on_mouse_events obj))
        (wxEvtHandler_Connect (slot-top-window obj) obj.grid-1 (expwxEVT_GRID_CMD_CELL_CHANGED)
        (wxClosure_Create #'on_grid_cmd_cell_changed obj))
        (wxEvtHandler_Connect (slot-top-window obj) obj.grid-1 (expwxEVT_TEXT_ENTER)
        (wxClosure_Create #'on_grid_text_enter obj))
        (wxEvtHandler_Connect (slot-top-window obj) obj (expwxEVT_LEFT_DOWN)
        (wxClosure_Create #'on_left_down_frame obj))
        ;;; end wxGlade
        )

(defun on_left_down_panel (function data event) ;;; wxGlade: MyFrame.<event_handler>
        (print "Event handler 'on_left_down_panel' not implemented!")
        (when event
                (wxEvent:wxEvent_Skip event)))

(defun on_button (function data event) ;;; wxGlade: MyFrame.<event_handler>
        (print "Event handler 'on_button' not implemented!")
        (when event
                (wxEvent:wxEvent_Skip event)))

(defun on_left_down (function data event) ;;; wxGlade: MyFrame.<event_handler>
        (print "Event handler 'on_left_down' not implemented!")
        (when event
                (wxEvent:wxEvent_Skip event)))

(defun on_mouse_events (function data event) ;;; wxGlade: MyFrame.<event_handler>
        (print "Event handler 'on_mouse_events' not implemented!")
        (when event
                (wxEvent:wxEvent_Skip event)))

(defun on_grid_cmd_cell_changed (function data event) ;;; wxGlade: MyFrame.<event_handler>
        (print "Event handler 'on_grid_cmd_cell_changed' not implemented!")
        (when event
                (wxEvent:wxEvent_Skip event)))

(defun on_grid_text_enter (function data event) ;;; wxGlade: MyFrame.<event_handler>
        (print "Event handler 'on_grid_text_enter' not implemented!")
        (when event
                (wxEvent:wxEvent_Skip event)))

(defun on_left_down_frame (function data event) ;;; wxGlade: MyFrame.<event_handler>
        (print "Event handler 'on_left_down_frame' not implemented!")
        (when event
                (wxEvent:wxEvent_Skip event)))

;;; end of class MyFrame


(defun init-func (fun data evt)
        (let ((frame (make-MyFrame)))
        (ELJApp_SetTopWindow (slot-top-window frame))
        (wxWindow_Show (slot-top-window frame))))
;;; end of class MyApp


(unwind-protect
    (Eljapp_initializeC (wxclosure_Create #'init-func nil) 0 nil)
    (ffi:close-foreign-library "../miscellaneous/wxc-msw2.6.2.dll"))
