#!/usr/bin/env lisp
;;;
;;; generated by wxGlade 0.9.5 on Sun Feb  2 13:54:55 2020
;;;

;;; Note that this code file is not valid as it contains Python specific parts! It's just for testing.


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


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

;;; begin wxGlade: extracode
import matplotlib
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
;;; end wxGlade


(defclass MyFrame()
        ((top-window :initform nil :accessor slot-top-window)
        (matplotlib-canvas :initform nil :accessor slot-matplotlib-canvas)
        (label-4 :initform nil :accessor slot-label-4)
        (text-function :initform nil :accessor slot-text-function)
        (sizer-4 :initform nil :accessor slot-sizer-4)
        (label-1 :initform nil :accessor slot-label-1)
        (text-xmin :initform nil :accessor slot-text-xmin)
        (label-2 :initform nil :accessor slot-label-2)
        (text-max :initform nil :accessor slot-text-max)
        (label-3 :initform nil :accessor slot-label-3)
        (text-xstep :initform nil :accessor slot-text-xstep)
        (button-plot :initform nil :accessor slot-button-plot)
        (button-clear :initform nil :accessor slot-button-clear)
        (sizer-3 :initform nil :accessor slot-sizer-3)
        (sizer-2 :initform nil :accessor slot-sizer-2)
        (panel-1 :initform nil :accessor slot-panel-1)
        (sizer-1 :initform nil :accessor slot-sizer-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) "matplotlib canvas example")
        
        (setf (slot-sizer-1 obj) (wxBoxSizer_Create wxVERTICAL))
        
        (setf (slot-panel-1 obj) (wxPanel_Create (slot-top-window obj) wxID_ANY -1 -1 -1 -1 wxTAB_TRAVERSAL))
        (wxSizer_AddWindow (slot-sizer-1 obj) (slot-panel-1 obj) 1 wxEXPAND 0 nil)
        
        (setf (slot-sizer-2 obj) (wxBoxSizer_Create wxVERTICAL))
        
        figure = self.matplotlib_figure = Figure()
        # 1x1 grid, first subplot
        self.matplotlib_axes = figure.add_subplot(111)
        (setf matplotlib-canvas (FigureCanvas_Create (object-panel-1 self) wxID_ANY figure))
        (wxSizer_AddWindow (slot-sizer-2 obj) (slot-matplotlib-canvas obj) 1 (logior wxALL wxEXPAND) 3 nil)
        
        (setf (slot-sizer-4 obj) (wxBoxSizer_Create wxHORIZONTAL))
        (wxSizer_AddSizer (slot-sizer-2 obj) (slot-sizer-4 obj) 0 (logior wxALL wxEXPAND) 5 nil)
        
        (setf (slot-label-4 obj) (wxStaticText_Create (slot-panel-1 obj) wxID_ANY "f(x) = " -1 -1 -1 -1 0))
        (wxSizer_AddWindow (slot-sizer-4 obj) (slot-label-4 obj) 0 (logior wxALIGN_CENTER_VERTICAL wxALL) 5 nil)
        
        (setf (slot-text-function obj) (wxTextCtrl_Create (slot-panel-1 obj) wxID_ANY "sin(x)" -1 -1 -1 -1 0))
        (wxSizer_AddWindow (slot-sizer-4 obj) (slot-text-function obj) 1 0 0 nil)
        
        (setf (slot-sizer-3 obj) (wxBoxSizer_Create wxHORIZONTAL))
        (wxSizer_AddSizer (slot-sizer-2 obj) (slot-sizer-3 obj) 0 (logior wxALL wxEXPAND) 5 nil)
        
        (setf (slot-label-1 obj) (wxStaticText_Create (slot-panel-1 obj) wxID_ANY "xmin" -1 -1 -1 -1 0))
        (wxSizer_AddWindow (slot-sizer-3 obj) (slot-label-1 obj) 0 wxALIGN_CENTER_VERTICAL 0 nil)
        
        (setf (slot-text-xmin obj) (wxTextCtrl_Create (slot-panel-1 obj) wxID_ANY "0" -1 -1 -1 -1 0))
        (slot-text-xmin obj).SetMinSize((40, -1))
        (wxSizer_AddWindow (slot-sizer-3 obj) (slot-text-xmin obj) 0 0 0 nil)
        
        (setf (slot-label-2 obj) (wxStaticText_Create (slot-panel-1 obj) wxID_ANY "xmax" -1 -1 -1 -1 0))
        (wxSizer_AddWindow (slot-sizer-3 obj) (slot-label-2 obj) 0 wxALIGN_CENTER_VERTICAL 0 nil)
        
        (setf (slot-text-max obj) (wxTextCtrl_Create (slot-panel-1 obj) wxID_ANY "10" -1 -1 -1 -1 0))
        (slot-text-max obj).SetMinSize((40, -1))
        (wxSizer_AddWindow (slot-sizer-3 obj) (slot-text-max obj) 0 0 0 nil)
        
        (setf (slot-label-3 obj) (wxStaticText_Create (slot-panel-1 obj) wxID_ANY "step" -1 -1 -1 -1 0))
        (wxSizer_AddWindow (slot-sizer-3 obj) (slot-label-3 obj) 0 wxALIGN_CENTER_VERTICAL 0 nil)
        
        (setf (slot-text-xstep obj) (wxTextCtrl_Create (slot-panel-1 obj) wxID_ANY "0.1" -1 -1 -1 -1 0))
        (slot-text-xstep obj).SetMinSize((40, -1))
        (wxSizer_AddWindow (slot-sizer-3 obj) (slot-text-xstep obj) 0 0 0 nil)
        
        (wxSizer_AddWindow (slot-sizer-3 obj) ((20, 20) obj) 1 0 0 nil)
        
        (setf (slot-button-plot obj) (wxButton_Create (slot-panel-1 obj) wxID_ANY "Plot" -1 -1 -1 -1 0))
        (wxButton_SetDefault (slot-button-plot obj))
        (wxSizer_AddWindow (slot-sizer-3 obj) (slot-button-plot obj) 0 0 0 nil)
        
        (setf (slot-button-clear obj) (wxButton_Create (slot-panel-1 obj) wxID_ANY "Clear" -1 -1 -1 -1 0))
        (wxSizer_AddWindow (slot-sizer-3 obj) (slot-button-clear obj) 0 wxLEFT 8 nil)
        
        (wxWindow_SetSizer (slot-panel-1 obj) (slot-sizer-2 obj))
        
        (wxWindow_SetSizer (slot-top-window obj) (slot-sizer-1 obj))
        
        (wxFrame_layout (slot-frame self))

        (wxEvtHandler_Connect (slot-top-window obj) obj.button-plot (expwxEVT_BUTTON)
        (wxClosure_Create #'on_button_plot obj))
        ;;; end wxGlade
        ;;; some extra code at end of MyFrame init
        )

(defun on_button_plot (function data event) ;;; wxGlade: MyFrame.<event_handler>
        (print "Event handler 'on_button_plot' 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

;;; some extra code after MyApp

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