Skip to content
charJe edited this page Aug 13, 2020 · 10 revisions

glgui-timepicker creates a time entry widget consisting of (24) hours and minutes verticalvaluepickers. Using this widget, a user can enter a time of day. Parameters, attributes and procedures in this widget are very similar to those available in glgui-timewheels.

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. The time text is centered in this height.
colorarrows Color of the up and down arrows in the widget
colorhighlight Color of the the highlighting on the buttons behind the arrows that appears only when they are pressed
colorvalue Color of the selected time text
colorbg Background color of the entire widget. This can be #f to not have a background color.
font Font for the time text

Example

Example 1: Creates a timepicker at coordinates 20,20, width 240, and height 110. The arrow buttons are grey with a faded blue highlight when pressed. There is no background color and the text is displayed in arial_20.fnt and is white.

(set! timep (glgui-timepicker gui 20 20 240 150 
               Grey (color-shade Blue 0.5) White #f arial_20.fnt))

Attributes

Besides the parameters set in the above procedure, the widget has the following attributes that can be set using glgui-widget-set! and retrieved using glgui-widget-get:

Attribute Default Value Description
ampm False If true, the time widget uses a 12-hour clock, and an AM/PM button is created.
button-normal-color colorbg The background color of the AM/PM button.
callback False If a procedure, this procedure is called when a time change is finished being made in the time picker. If Button1 (or your finger on a mobile platform) is being held down for cycling through minutes or hours, the callback is not called until you release.
hidden False If true, the widget is not displayed.
hourmin 0 The minimum hour available within the time picker.
hourmax 23 The maximum hour available within the time picker. This can be less than the minimum hour to include a range that wraps around midnight.
scalearrows False If true, the size of the arrow buttons will be proportional to the height of the widget.
topdown False By default, later times are reached by pressing the up arrows. By setting this to true, the values are reversed, with the down arrows going to later times.
value Current Time The time to show on the time picker (in seconds). This defaults to the current time.

Example

Example 2: Retrieves the current time value of the timepicker created in Example 1. This is a Unix timestamp that assumes the date is Jan 1st, 1970 (so it is the number of seconds since midnight).

(glgui-widget-get gui timep 'value)

It can be converted to that time the current date like this:

(string->seconds
 (seconds->string (glgui-widget-get gui timep 'value) "~H:~M")
 "~H:~M")
Clone this wiki locally