chickadee » qobischeme-ui » define-application

(define-application display-pane-width display-pane-height transcript-lines button-rows button-columns pre-initialize-procedure post-initialize-procedure finalize-procedure redraw-procedure listener-procedure)syntax

The main way of defining GUI.

The GUI is composed of different regions: at the top we have buttons in the button pane, the main content of the application is displayed below in the display pane, below that are the transcript pane and echo pane which are used to output and input text, and at the bottom we have the status pane on the left and message pane on the right. Each pane is an X window embedded in the main X window of the application.

The display-pane-width and display-pane-height are in pixel units. When width is #f other arguments will determine the width of the application. The other panes automatically adjust their sizes. transcript-lines defines the number of lines in the transcript pane, can be #f. button-rows and button-columns set the size of the button grid in the button pane. Buttons will be automatically sized to take up the appropriate amount of space.

All the following procedures take no arguments. pre-initialize-procedure code to run before the application is ready. This is typically where you define UI elements. post-initialize-procedure code to run right after the UI is ready. finalize-procedure runs after the UI exists. redraw-procedure runs as needed to redraw the UI. listener-procedure runs when return is pressed in the transcript pane.

 (use qobischeme-ui)
 (define-application main #f 480 5 2 6
  (lambda ()
   (define-button 0 0 "Help" #f help-command)
   (define-button 5 0 "Quit" #f quit-gui)
   (define-radio-buttons *object* (lambda () #f)
    (1 0 line-segment "Line")
    (2 0 ellipse "Ellipse"))
   (define-toggle-button 0 1 "Flag" *flag?*
    (lambda () (say (format #f "Flag=~s" *flag?*))))
   (define-cycle-button 1 1 *mode*
    (lambda () (say (format #f "Mode=~s" *mode*)))
    (a "A")
    (b "B")
    (c "C"))
   (define-integer-range-buttons 2 1 3 1 *k* 0 9
    (lambda () (format #f "-K ~s" *k*))
    (lambda () (format #f "+K ~s" *k*))
    (lambda () (say (format #f "K=~s" *k*))))
   (define-key (list (control #\x) (control #\c)) "Quit" quit-gui)
   (define-key (control #\h) "Help" help-command))
  (lambda () #f)
  (lambda () #f)
  (lambda () #f))
 (main '())