3 Main clnl-gltk package.
5 Use widgets available in clnl-gltk to create NetLogo user interface widgets in pure opengl. This project doesn't have much usefulness outside of CLNL.
9 * **variable [\*font\-height\*](#variable-font-height)** - The height of the font used by CLNL-GLTK.
10 * **variable [\*font\-width\*](#variable-font-width)** - The width of the font used by CLNL-GLTK.
11 * **variable [\*slider\-height\*](#variable-slider-height)** - The default slider height.
12 * **variable [\*switch\-height\*](#variable-switch-height)** - The default switch height.
13 * **function [button](#function-button)** - _button_ creates a button widget.
14 * **function [clear](#function-clear)** - Rests the inputbox _ib_ to empty.
15 * **function [font-print](#function-font-print)** - _font-print_ prints _str_ to the screen.
16 * **function [inputbox](#function-inputbox)** - _inputbox_ creates an inputbox widget.
17 * **function [key-pressed](#function-key-pressed)** - _key-pressed_ will do the appropriate thing in the case of a key being pressed.
18 * **function [mousedown](#function-mousedown)** - _mousedown_ is the general purpose mousedown entry point for all widgets. It is used to alert widgets that a mouse button has been pressed, and where. There's no information on which button has been pressed.
19 * **function [mousemove](#function-mousemove)** - _mousemove_ is the general purpose mousemove entry point for all widgets. It is used to alert widgets to movements of the mouse, regardless of button state.
20 * **function [mouseup](#function-mouseup)** - _mouseup_ is the general purpose mouseup entry point for all widgets. It is used to alert widgets to that a mouse button has been released, and where. There's no information on which button has been released, and it is up to the widget to decide if a click was triggered.
21 * **function [render](#function-render)** - _render_ is the entry point for rendering different items in the CLNL-GLTK package.
22 * **function [reposition](#function-reposition)** - _reposition_ is the general purpose resizing entry point for all widgets.
23 * **function [resize](#function-resize)** - _resize_ is the general purpose resizing entry point for all widgets.
24 * **function [setup](#function-setup)** - _setup_ sets up the clnl-gltk system, calling all the necessary underlying functions.
25 * **function [slider](#function-slider)** - _slider_ creates a button widget.
26 * **function [switch](#function-switch)** - _switch_ creates a switch widget.
27 * **function [textbox](#function-textbox)** - _textbox_ creates a textbox widget.
28 * **function [textbox-text](#function-textbox-text)** - _textbox-text_ allows for the retrieving and setting of the internal text of textbox _tb_.
29 * **function [toggle](#function-toggle)** - _toggle_ toggles an _item_.
30 * **function [value](#function-value)** - Returns the _text_ that currently resides in the inputbox _ib_.
32 ## Variable \*FONT\-HEIGHT\*
44 The height of the font used by CLNL-GLTK.
46 This can be used to calculate appropriate sizes of things that may have fonts displayed in them.
48 ## Variable \*FONT\-WIDTH\*
60 The width of the font used by CLNL-GLTK.
62 This can be used to calculate appropriate sizes of things that may have fonts displayed in them.
64 ## Variable \*SLIDER\-HEIGHT\*
76 The default slider height.
78 ## Variable \*SWITCH\-HEIGHT\*
90 The default switch height.
92 ## Function **BUTTON**
96 **button** _x_ _y_ _width_ _height_ _text_ _callback_ _&key_ _forever_ => _button_
98 #### Arguments and Values:
100 _x_---x offset, in pixels
101 _y_---y offset, in pixels
102 _width_---width, in pixels
103 _height_---height, in pixels
104 _text_---string for the textual display
105 _callback_---a function
106 _forever_---a boolean, including whether this button is a forever button
107 _button_---a button that can later be rendered
111 _button_ creates a button widget.
113 The widget will center the viewable TE_x_T inside itself, replacing the last three characters with an ellipses if the text is too large for the given dimensions. It will never clip a character.
115 _button_ objects also work with mouse movement functions. When it identifies that a click has happened, _callback_ will be called.
117 When _forever_ is non NIL, an extra icon is added to the button.
119 ## Function **CLEAR**
123 **clear** _ib_ => _result_
125 #### Arguments and Values:
132 Rests the inputbox _ib_ to empty.
134 ## Function **FONT-PRINT**
138 **font-print** _str_ => _result_
140 #### Arguments and Values:
142 _str_---a string to be printed to screen
147 _font-print_ prints _str_ to the screen.
149 It affirms no assumptions that are required for it to run, in the interest of speed. Those assumptions include that an opengl window has been opened, that all matrices are correct, and that SETUP-FONT has been run.
153 ```(font-print #P"Hello World" t)``` => ```nil```
155 ## Function **INPUTBOX**
159 **inputbox** _x_ _y_ _width_ => _ib_
161 #### Arguments and Values:
163 _x_---x offset, in pixels
164 _y_---y offset, in pixels
165 _width_---width, in characters
166 _ib_---an inputbox that can later be rendered
170 _inputbox_ creates an inputbox widget.
172 The inputbox is a simple, single lined, box that can hold a mutating string. Use the various _inputbox_-* functions to add to it and modify it. As a string is added to it that is too large, it will scroll the characters automatically.
174 The widget is defined in terms of characters, rather than pixels. In this way, it will never clip a portion of a character off.
176 ## Function **KEY-PRESSED**
180 **key-pressed** _ib_ _key_ => _result_
182 #### Arguments and Values:
185 _key_---Key pressed, an integer or a symbol
190 _key-pressed_ will do the appropriate thing in the case of a key being pressed.
192 When an integer, will insert the text into the appropriate location, if it's an ascii character less than 256.
194 The other values acceptable are:
196 :key-left moves the cursor one to the left :key-right moves the cursor one to the right
198 ## Function **MOUSEDOWN**
202 **mousedown** _item_ _x_ _y_ => _result_
204 #### Arguments and Values:
206 _item_---item handling event
213 _mousedown_ is the general purpose mousedown entry point for all widgets. It is used to alert widgets that a mouse button has been pressed, and where. There's no information on which button has been pressed.
215 _x_ and _y_ are absolute coordinates, and assumed to be opengl coordinates, not window coordinates (meaning they match the render and setup functions of widgets).
217 A catchall method that does nothing is also defined so that mouse functions can loop over all available widgets and let them decide what they want to do.
219 ## Function **MOUSEMOVE**
223 **mousemove** _item_ _x_ _y_ => _result_
225 #### Arguments and Values:
227 _item_---item handling event
234 _mousemove_ is the general purpose mousemove entry point for all widgets. It is used to alert widgets to movements of the mouse, regardless of button state.
236 _x_ and _y_ are absolute coordinates, and assumed to be opengl coordinates, not window coordinates (meaning they match the render and setup functions of widgets).
238 A catchall method that does nothing is also defined so that mouse functions can loop over all available widgets and let them decide what they want to do.
240 ## Function **MOUSEUP**
244 **mouseup** _item_ _x_ _y_ => _result_
246 #### Arguments and Values:
248 _item_---item handling event
255 _mouseup_ is the general purpose mouseup entry point for all widgets. It is used to alert widgets to that a mouse button has been released, and where. There's no information on which button has been released, and it is up to the widget to decide if a click was triggered.
257 _x_ and _y_ are absolute coordinates, and assumed to be opengl coordinates, not window coordinates (meaning they match the render and setup functions of widgets).
259 A catchall method that does nothing is also defined so that mouse functions can loop over all available widgets and let them decide what they want to do.
261 ## Function **RENDER**
265 **render** _item_ => _result_
267 #### Arguments and Values:
269 _item_---item to be rendered
274 _render_ is the entry point for rendering different items in the CLNL-GLTK package.
276 _render_ will return the opengl world to the way it found it after finishing, usually via just popping the matrix.
278 ## Function **REPOSITION**
282 **reposition** _item_ _x_ _y_ => _result_
284 #### Arguments and Values:
286 _item_---item to be rendered
293 _reposition_ is the general purpose resizing entry point for all widgets.
295 _x_ and _y_ are contextual to the actual item being repositioned, and may be even be ignored.
297 ## Function **RESIZE**
301 **resize** _item_ _width_ _height_ => _result_
303 #### Arguments and Values:
305 _item_---item to be rendered
307 _height_---an integer
312 _resize_ is the general purpose resizing entry point for all widgets.
314 _width_ and _height_ are contextual to the actual item being resized, and may be even be ignored.
316 ## Function **SETUP**
320 **setup** => _result_
322 #### Arguments and Values:
328 _setup_ sets up the clnl-gltk system, calling all the necessary underlying functions.
330 Calling before the opengl system has been initialized properly may or may not work, so calling it after everything else has been initialized is recommended.
332 ## Function **SLIDER**
336 **slider** _x_ _y_ _width_ _text_ _callback_ _min_ _max_ _increment_ _value_ => _slider_
338 #### Arguments and Values:
340 _x_---x offset, in pixels
341 _y_---y offset, in pixels
342 _width_---width, in pixels
343 _text_---string for the textual display
344 _callback_---a function
345 _min_---minimum value
346 _max_---maximum value
347 _increment_---increment when moving the slider
348 _value_---inital value
349 _slider_---a slider that can later be rendered
353 _slider_ creates a button widget.
355 TODO: The rest of this description needs to be updated!
357 ## Function **SWITCH**
361 **switch** _x_ _y_ _width_ _text_ _callback_ _&optional_ _initial-state_ => _switch_
363 #### Arguments and Values:
365 _x_---x offset, in pixels
366 _y_---y offset, in pixels
367 _width_---width, in pixels
368 _text_---string for the textual display
369 _callback_---a function
370 _initial-state_---a boolean, defaulting to nil
371 _switch_---a switch that can later be rendered
375 _switch_ creates a switch widget.
377 The widget will center the viewable TE_x_T inside itself, replacing the last three characters with an ellipses if the text is too large for the given dimensions. It will never clip a character.
379 _switch_ objects also work with mouse movement functions. When it identifies that a mousedown has happened, the state of the _switch_ will be changed, and _callback_ will be called with the new state.
381 The _initial-state_ defines whether the switch starts on or off.
383 ## Function **TEXTBOX**
387 **textbox** _x_ _y_ _width_ _height_ _&key_ _text_ _border_ _word-wrap_ => _tb_
389 #### Arguments and Values:
391 _x_---x offset, in pixels
392 _y_---y offset, in pixels
393 _width_---width, in characters
394 _height_---height, in characters
395 _text_---optional string for the textual display
396 _border_---boolean, whether we draw a border, defaults to t
397 _word-wrap_---boolean, whether we attempt to wrap the text
398 _tb_---a textbox that can later be rendered
402 _textbox_ creates a textbox widget.
404 The widget is defined in terms of characters, rather than pixels. In this way, it will never clip a portion of a character off. It will also display whatever it can of its text, clipping off characters that are outside.
406 Multiline strings are supported, and each one appears on a new line.
408 When _border_ is NIL, no border is drawn and the text box floats, which can be useful for labels.
410 When _word-wrap_ is non NIL, the text is attempted to wrap by the following rules. The wrapping is done at the line if possible, at a breaking character if possible, or just fits as many letters as it can befoer wrapping. It then only clips off on the bottom. The only breaking character currently is #Space.
412 ## Function **TEXTBOX-TEXT**
416 **textbox-text** _tb_ => _text_
418 #### Arguments and Values:
421 _text_---string currently being displayed
425 _textbox-text_ allows for the retrieving and setting of the internal text of textbox _tb_.
427 ## Function **TOGGLE**
431 **toggle** _item_ _&optional_ _state_ => _new-state_
433 #### Arguments and Values:
436 _state_---a boolean, the state to set to
437 _new-state_---a boolean, the state after being set
441 _toggle_ toggles an _item_.
443 Inverts the current toggle status of the _item_ if no _state_ passed in, otherwise sets to _state_.
445 ## Function **VALUE**
449 **value** _ib_ => _text_
451 #### Arguments and Values:
454 _text_---a string, the text currently in _ib_
458 Returns the _text_ that currently resides in the inputbox _ib_.