Skip to content
Chris Petersen edited this page Oct 16, 2014 · 1 revision

glgui-box plots a filled rectangle (without callback, i.e. not clickable)

Parameter Description
g Graphical User Interface (GUI) for this widget
x Lower left corner along the x-axis in pixels
y Lower left corner along the y-axis in pixels
w Width of the element in pixels
h Height of the element in pixels
c Color, with which the box is filled

Example

Example 1: Draw a red box at x=10, y=20, which is 50px wide and 75px high

(set! gui:main (make-glgui))
(glgui-box gui:main 10 20 50 75 Red)

Example 2: Draw a blue box at x=50, y=50, which is 100px wide and 100px high. If clicked it toggles it's color between blue and yellow.

(define (mybox-callback g wgt t x y)
  (glgui-widget-set! g wgt 'color (if (= (glgui-widget-get g wgt 'color) Blue) Yellow Blue)))
(set! gui:main (make-glgui))
(set! mybox (glgui-box gui:main 50 50 100 100 Blue))
(glgui-widget-set! gui:main mybox 'callback mybox-callback)
Clone this wiki locally