Update documentation after 0.1.1 release
[clnl] / docs / DocsGltk.md
diff --git a/docs/DocsGltk.md b/docs/DocsGltk.md
new file mode 100644 (file)
index 0000000..721ae03
--- /dev/null
@@ -0,0 +1,458 @@
+# Package CLNL-GLTK
+
+Main clnl-gltk package.
+
+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.
+
+## Contents
+
+* **variable [\*font\-height\*](#variable-font-height)** - The height of the font used by CLNL-GLTK.
+* **variable [\*font\-width\*](#variable-font-width)** - The width of the font used by CLNL-GLTK.
+* **variable [\*slider\-height\*](#variable-slider-height)** - The default slider height.
+* **variable [\*switch\-height\*](#variable-switch-height)** - The default switch height.
+* **function [button](#function-button)** - _button_ creates a button widget.
+* **function [clear](#function-clear)** - Rests the inputbox _ib_ to empty.
+* **function [font-print](#function-font-print)** - _font-print_ prints _str_ to the screen.
+* **function [inputbox](#function-inputbox)** - _inputbox_ creates an inputbox widget.
+* **function [key-pressed](#function-key-pressed)** - _key-pressed_ will do the appropriate thing in the case of a key being pressed.
+* **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.
+* **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.
+* **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.
+* **function [render](#function-render)** - _render_ is the entry point for rendering different items in the CLNL-GLTK package.
+* **function [reposition](#function-reposition)** - _reposition_ is the general purpose resizing entry point for all widgets.
+* **function [resize](#function-resize)** - _resize_ is the general purpose resizing entry point for all widgets.
+* **function [setup](#function-setup)** - _setup_ sets up the clnl-gltk system, calling all the necessary underlying functions.
+* **function [slider](#function-slider)** - _slider_ creates a button widget.
+* **function [switch](#function-switch)** - _switch_ creates a switch widget.
+* **function [textbox](#function-textbox)** - _textbox_ creates a textbox widget.
+* **function [textbox-text](#function-textbox-text)** - _textbox-text_ allows for the retrieving and setting of the internal text of textbox _tb_.
+* **function [toggle](#function-toggle)** - _toggle_ toggles an _item_.
+* **function [value](#function-value)** - Returns the _text_ that currently resides in the inputbox _ib_.
+
+## Variable \*FONT\-HEIGHT\*
+
+#### Value Type:
+
+an integer
+
+#### Initial Value:
+
+14
+
+#### Description:
+
+The height of the font used by CLNL-GLTK.
+
+This can be used to calculate appropriate sizes of things that may have fonts displayed in them.
+
+## Variable \*FONT\-WIDTH\*
+
+#### Value Type:
+
+an integer
+
+#### Initial Value:
+
+7.
+
+#### Description:
+
+The width of the font used by CLNL-GLTK.
+
+This can be used to calculate appropriate sizes of things that may have fonts displayed in them.
+
+## Variable \*SLIDER\-HEIGHT\*
+
+#### Value Type:
+
+an integer
+
+#### Initial Value:
+
+33
+
+#### Description:
+
+The default slider height.
+
+## Variable \*SWITCH\-HEIGHT\*
+
+#### Value Type:
+
+an integer
+
+#### Initial Value:
+
+33
+
+#### Description:
+
+The default switch height.
+
+## Function **BUTTON**
+
+#### Syntax:
+
+**button** _x_ _y_ _width_ _height_ _text_ _callback_ _&key_ _forever_ => _button_
+
+#### Arguments and Values:
+
+_x_---x offset, in pixels  
+_y_---y offset, in pixels  
+_width_---width, in pixels  
+_height_---height, in pixels  
+_text_---string for the textual display  
+_callback_---a function  
+_forever_---a boolean, including whether this button is a forever button  
+_button_---a button that can later be rendered  
+
+#### Description:
+
+_button_ creates a button widget.
+
+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.
+
+_button_ objects also work with mouse movement functions.  When it identifies that a click has happened, _callback_ will be called.
+
+When _forever_ is non NIL, an extra icon is added to the button.
+
+## Function **CLEAR**
+
+#### Syntax:
+
+**clear** _ib_ => _result_
+
+#### Arguments and Values:
+
+_ib_---an inputbox  
+_result_---undefined  
+
+#### Description:
+
+Rests the inputbox _ib_ to empty.
+
+## Function **FONT-PRINT**
+
+#### Syntax:
+
+**font-print** _str_ => _result_
+
+#### Arguments and Values:
+
+_str_---a string to be printed to screen  
+_result_---undefined  
+
+#### Description:
+
+_font-print_ prints _str_ to the screen.
+
+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.
+
+#### Examples:
+
+```(font-print #P"Hello World" t)``` => ```nil```  
+
+## Function **INPUTBOX**
+
+#### Syntax:
+
+**inputbox** _x_ _y_ _width_ => _ib_
+
+#### Arguments and Values:
+
+_x_---x offset, in pixels  
+_y_---y offset, in pixels  
+_width_---width, in characters  
+_ib_---an inputbox that can later be rendered  
+
+#### Description:
+
+_inputbox_ creates an inputbox widget.
+
+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.
+
+The widget is defined in terms of characters, rather than pixels.  In this way, it will never clip a portion of a character off.
+
+## Function **KEY-PRESSED**
+
+#### Syntax:
+
+**key-pressed** _ib_ _key_ => _result_
+
+#### Arguments and Values:
+
+_ib_---An inputbox  
+_key_---Key pressed, an integer or a symbol  
+_result_---Undefined  
+
+#### Description:
+
+_key-pressed_ will do the appropriate thing in the case of a key being pressed.
+
+When an integer, will insert the text into the appropriate location, if it's an ascii character less than 256.
+
+The other values acceptable are:
+
+:key-left moves the cursor one to the left :key-right moves the cursor one to the right
+
+## Function **MOUSEDOWN**
+
+#### Syntax:
+
+**mousedown** _item_ _x_ _y_ => _result_
+
+#### Arguments and Values:
+
+_item_---item handling event  
+_x_---an integer  
+_y_---an integer  
+_result_---undefined  
+
+#### Description:
+
+_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.
+
+_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).
+
+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.
+
+## Function **MOUSEMOVE**
+
+#### Syntax:
+
+**mousemove** _item_ _x_ _y_ => _result_
+
+#### Arguments and Values:
+
+_item_---item handling event  
+_x_---an integer  
+_y_---an integer  
+_result_---undefined  
+
+#### Description:
+
+_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.
+
+_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).
+
+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.
+
+## Function **MOUSEUP**
+
+#### Syntax:
+
+**mouseup** _item_ _x_ _y_ => _result_
+
+#### Arguments and Values:
+
+_item_---item handling event  
+_x_---an integer  
+_y_---an integer  
+_result_---undefined  
+
+#### Description:
+
+_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.
+
+_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).
+
+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.
+
+## Function **RENDER**
+
+#### Syntax:
+
+**render** _item_ => _result_
+
+#### Arguments and Values:
+
+_item_---item to be rendered  
+_result_---undefined  
+
+#### Description:
+
+_render_ is the entry point for rendering different items in the CLNL-GLTK package.
+
+_render_ will return the opengl world to the way it found it after finishing, usually via just popping the matrix.
+
+## Function **REPOSITION**
+
+#### Syntax:
+
+**reposition** _item_ _x_ _y_ => _result_
+
+#### Arguments and Values:
+
+_item_---item to be rendered  
+_x_---an integer  
+_y_---an integer  
+_result_---undefined  
+
+#### Description:
+
+_reposition_ is the general purpose resizing entry point for all widgets.
+
+_x_ and _y_ are contextual to the actual item being repositioned, and may be even be ignored.
+
+## Function **RESIZE**
+
+#### Syntax:
+
+**resize** _item_ _width_ _height_ => _result_
+
+#### Arguments and Values:
+
+_item_---item to be rendered  
+_width_---an integer  
+_height_---an integer  
+_result_---undefined  
+
+#### Description:
+
+_resize_ is the general purpose resizing entry point for all widgets.
+
+_width_ and _height_ are contextual to the actual item being resized, and may be even be ignored.
+
+## Function **SETUP**
+
+#### Syntax:
+
+**setup** => _result_
+
+#### Arguments and Values:
+
+_result_---undefined  
+
+#### Description:
+
+_setup_ sets up the clnl-gltk system, calling all the necessary underlying functions.
+
+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.
+
+## Function **SLIDER**
+
+#### Syntax:
+
+**slider** _x_ _y_ _width_ _text_ _callback_ _min_ _max_ _increment_ _value_ => _slider_
+
+#### Arguments and Values:
+
+_x_---x offset, in pixels  
+_y_---y offset, in pixels  
+_width_---width, in pixels  
+_text_---string for the textual display  
+_callback_---a function  
+_min_---minimum value  
+_max_---maximum value  
+_increment_---increment when moving the slider  
+_value_---inital value  
+_slider_---a slider that can later be rendered  
+
+#### Description:
+
+_slider_ creates a button widget.
+
+TODO: The rest of this description needs to be updated!
+
+## Function **SWITCH**
+
+#### Syntax:
+
+**switch** _x_ _y_ _width_ _text_ _callback_ _&optional_ _initial-state_ => _switch_
+
+#### Arguments and Values:
+
+_x_---x offset, in pixels  
+_y_---y offset, in pixels  
+_width_---width, in pixels  
+_text_---string for the textual display  
+_callback_---a function  
+_initial-state_---a boolean, defaulting to nil  
+_switch_---a switch that can later be rendered  
+
+#### Description:
+
+_switch_ creates a switch widget.
+
+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.
+
+_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.
+
+The _initial-state_ defines whether the switch starts on or off.
+
+## Function **TEXTBOX**
+
+#### Syntax:
+
+**textbox** _x_ _y_ _width_ _height_ _&key_ _text_ _border_ _word-wrap_ => _tb_
+
+#### Arguments and Values:
+
+_x_---x offset, in pixels  
+_y_---y offset, in pixels  
+_width_---width, in characters  
+_height_---height, in characters  
+_text_---optional string for the textual display  
+_border_---boolean, whether we draw a border, defaults to t  
+_word-wrap_---boolean, whether we attempt to wrap the text  
+_tb_---a textbox that can later be rendered  
+
+#### Description:
+
+_textbox_ creates a textbox widget.
+
+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.
+
+Multiline strings are supported, and each one appears on a new line.
+
+When _border_ is NIL, no border is drawn and the text box floats, which can be useful for labels.
+
+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.
+
+## Function **TEXTBOX-TEXT**
+
+#### Syntax:
+
+**textbox-text** _tb_ => _text_
+
+#### Arguments and Values:
+
+_tb_---a textbox  
+_text_---string currently being displayed  
+
+#### Description:
+
+_textbox-text_ allows for the retrieving and setting of the internal text of textbox _tb_.
+
+## Function **TOGGLE**
+
+#### Syntax:
+
+**toggle** _item_ _&optional_ _state_ => _new-state_
+
+#### Arguments and Values:
+
+_item_---an item  
+_state_---a boolean, the state to set to  
+_new-state_---a boolean, the state after being set  
+
+#### Description:
+
+_toggle_ toggles an _item_.
+
+Inverts the current toggle status of the _item_ if no _state_ passed in, otherwise sets to _state_.
+
+## Function **VALUE**
+
+#### Syntax:
+
+**value** _ib_ => _text_
+
+#### Arguments and Values:
+
+_ib_---an inputbox  
+_text_---a string, the text currently in _ib_  
+
+#### Description:
+
+Returns the _text_ that currently resides in the inputbox _ib_.