summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-09-18 19:19:36 +0000
committerIan C <ianc@noddybox.co.uk>2005-09-18 19:19:36 +0000
commitf8de91ae41929286b1cf43c72093e5c996b1f949 (patch)
treef9ccb2fa8461c2941e6d60187ae8952e9ee30f12
parentf79195715c66530b0bda50242380812c5e670c00 (diff)
Added documentation
-rw-r--r--bitmapfont.mod/bitmapfont.bmx49
-rw-r--r--bitmapfont.mod/doc/commands.html43
-rw-r--r--glflag.mod/doc/commands.html19
-rw-r--r--simplegui.mod/doc/commands.html109
-rw-r--r--simplegui.mod/simplegui.bmx223
-rw-r--r--vector.mod/doc/commands.html56
-rw-r--r--vector.mod/vector.bmx98
7 files changed, 546 insertions, 51 deletions
diff --git a/bitmapfont.mod/bitmapfont.bmx b/bitmapfont.mod/bitmapfont.bmx
index 35feb10..fd70671 100644
--- a/bitmapfont.mod/bitmapfont.bmx
+++ b/bitmapfont.mod/bitmapfont.bmx
@@ -1,3 +1,6 @@
+Rem
+bbdoc: noddybox.bitmapfont
+EndRem
Module noddybox.bitmapfont
ModuleInfo "Framework: Simple Bitmap Font Routines"
@@ -13,6 +16,13 @@ Import brl.Basic
Strict
+Rem
+bbdoc: Defines a bitmap font
+about: The @TBitmapFont object works from BMF Files, which are created using a tool called BitmapFontEd available at
+about: <a href="http://www.noddybox.demon.co.uk/free/index-csharp.html">http://www.noddybox.demon.co.uk/free/index-csharp.html</a><br>
+about: Note that when colours are referenced they simply modify the colours in the font images as @SetColor() would do on a norml image.<br>
+about: When drawing characters the current scale, alpha and rotation settings are applied.
+EndRem
Type TBitmapFont
Const NOCHR=95
@@ -24,6 +34,11 @@ Type TBitmapFont
Field max_width:Int
Field max_height:Int
+ Rem
+ bbdoc: Loads a font from the supplied BMF file.
+ returns: The created font, or null if the BMF file couldn't be loaded.
+ about: The @image_flags are passed onto @CreateImage() when the images for the font are being created.
+ EndRem
Function Load:TBitmapFont(path:String, image_flags:Int)
Local fnt:TBitmapFont
Local str:TStream
@@ -73,6 +88,10 @@ Type TBitmapFont
Return fnt
End Function
+ Rem
+ bbdoc: Draws coloured text.
+ about: Draws @txt at the supplied @x,@y co-ordinates. @red,@green and @blue control the colour.
+ EndRem
Method DrawColoured(txt:String, x:Int, y:Int, red:Int, green:Int, blue:Int)
Local f,r,g,b,c
Local xs#,ys#
@@ -91,10 +110,18 @@ Type TBitmapFont
SetColor(r,g,b)
End Method
+ Rem
+ bbdoc: Draws white text.
+ about: Draws @txt at the supplied @x,@y co-ordinates in white.
+ EndRem
Method Draw(txt:String, x:Int, y:Int)
DrawColoured(txt,x,y,255,255,255)
End Method
+ Rem
+ bbdoc: Draws centred, coloured text.
+ about: Draws @txt centred at the supplied @y co-ordinate. @red,@green and @blue control the colour.
+ EndRem
Method CentreColoured(txt:String, y:Int, red:Int, green:Int, blue:Int)
If is_fixed
DrawColoured(txt,GraphicsWidth()/2-Len(txt)*width[0]/2,y,red,green,blue)
@@ -103,6 +130,10 @@ Type TBitmapFont
EndIf
End Method
+ Rem
+ bbdoc: Draws centred, white text.
+ about: Draws @txt centred at the supplied @y co-ordinate in white.
+ EndRem
Method Centre(txt:String, y:Int)
If is_fixed
DrawColoured(txt,GraphicsWidth()/2-Len(txt)*width[0]/2,y,255,255,255)
@@ -111,6 +142,11 @@ Type TBitmapFont
EndIf
End Method
+ Rem
+ bbdoc: Width of the supplied string.
+ returns: The length of the string @txt in pixels.
+ about: The current scale settings are taken into account.
+ EndRem
Method TextWidth:Int(txt:String)
Local w
Local xs#,ys#
@@ -123,6 +159,11 @@ Type TBitmapFont
Return w
End Method
+ Rem
+ bbdoc: Height of the supplied string.
+ returns: The height of the string @txt in pixels.
+ about: The current scale settings are taken into account.
+ EndRem
Method TextHeight:Int(txt:String)
Local h:Int=0
Local xs#,ys#
@@ -136,10 +177,18 @@ Type TBitmapFont
Return h
End Method
+ Rem
+ bbdoc: Width of the largest character.
+ returns: The width in pixels of the largest character in the font.
+ EndRem
Method MaxWidth:Int()
Return max_width
End Method
+ Rem
+ bbdoc: Height of the largest character.
+ returns: The height in pixels of the largest character in the font.
+ EndRem
Method MaxHeight:Int()
Return max_height
End Method
diff --git a/bitmapfont.mod/doc/commands.html b/bitmapfont.mod/doc/commands.html
new file mode 100644
index 0000000..d196db5
--- /dev/null
+++ b/bitmapfont.mod/doc/commands.html
@@ -0,0 +1,43 @@
+<html>
+<head>
+<title>BlitzMax Module Reference</title>
+<link rel="stylesheet" type="text/css" href="../../../../doc/bmxstyle.css">
+</head>
+<body>
+<h1>Type Reference</h1>
+<p><div id=TBitmapFont class=ref>
+<div class=rootdoc><font class=token>Type TBitmapFont</font> Defines a bitmap font</div><div class=indent><p>The <b>TBitmapFont</b> object works from BMF Files, which are created using a tool called BitmapFontEd available at
+<a href="http://www.noddybox.demon.co.uk/free/index-csharp.html">http://www.noddybox.demon.co.uk/free/index-csharp.html</a><br>
+Note that when colours are referenced they simply modify the colours in the font images as <b>SetColor</b>() would do on a norml image.<br>
+When drawing characters the current scale, alpha and rotation settings are applied.</div><br><p><div id=DrawColoured>
+<div class=rootdoc><font class=token>Method DrawColoured( txt:String, x:Int, y:Int, red:Int, green:Int, blue:Int )</font> Draws coloured text.</div><div class=indent><p>Draws <b>txt</b> at the supplied <b>x</b>,<b>y</b> co-ordinates. <b>red</b>,<b>green</b> and <b>blue</b> control the colour.</div><br></div><br>
+<p><div id=Draw>
+<div class=rootdoc><font class=token>Method Draw( txt:String, x:Int, y:Int )</font> Draws white text.</div><div class=indent><p>Draws <b>txt</b> at the supplied <b>x</b>,<b>y</b> co-ordinates in white.</div><br></div><br>
+<p><div id=CentreColoured>
+<div class=rootdoc><font class=token>Method CentreColoured( txt:String, y:Int, red:Int, green:Int, blue:Int )</font> Draws centred, coloured text.</div><div class=indent><p>Draws <b>txt</b> centred at the supplied <b>y</b> co-ordinate. <b>red</b>,<b>green</b> and <b>blue</b> control the colour.</div><br></div><br>
+<p><div id=Centre>
+<div class=rootdoc><font class=token>Method Centre( txt:String, y:Int )</font> Draws centred, white text.</div><div class=indent><p>Draws <b>txt</b> centred at the supplied <b>y</b> co-ordinate in white.</div><br></div><br>
+<p><div id=TextWidth>
+<div class=rootdoc><font class=token>Method TextWidth:Int( txt:String )</font> Width of the supplied string.</div><div class=indent><p><b>Returns:</b> The length of the string <b>txt</b> in pixels.<p>The current scale settings are taken into account.</div><br></div><br>
+<p><div id=TextHeight>
+<div class=rootdoc><font class=token>Method TextHeight:Int( txt:String )</font> Height of the supplied string.</div><div class=indent><p><b>Returns:</b> The height of the string <b>txt</b> in pixels.<p>The current scale settings are taken into account.</div><br></div><br>
+<p><div id=MaxWidth>
+<div class=rootdoc><font class=token>Method MaxWidth:Int()</font> Width of the largest character.</div><div class=indent><p><b>Returns:</b> The width in pixels of the largest character in the font.</div><br></div><br>
+<p><div id=MaxHeight>
+<div class=rootdoc><font class=token>Method MaxHeight:Int()</font> Height of the largest character.</div><div class=indent><p><b>Returns:</b> The height in pixels of the largest character in the font.</div><br></div><br>
+<p><div id=Load>
+<div class=rootdoc><font class=token>Function Load:TBitmapFont( path:String, image_flags:Int )</font> Loads a font from the supplied BMF file.</div><div class=indent><p><b>Returns:</b> The created font, or null if the BMF file couldn't be loaded.<p>The <b>image_flags</b> are passed onto <b>CreateImage</b>() when the images for the font are being created.</div><br></div><br>
+</div><br>
+<h1>Module Information</h1>
+<table>
+<tr><td><b>Framework</b></td>
+<td> Simple Bitmap Font Routines</td></tr>
+<tr><td><b>Copyright</b></td>
+<td> Public Domain</td></tr>
+<tr><td><b>Author</b></td>
+<td> Ian Cowburn</td></tr>
+<tr><td><b>Version</b></td>
+<td> $Revision$</td></tr>
+</table>
+</body>
+</html>
diff --git a/glflag.mod/doc/commands.html b/glflag.mod/doc/commands.html
new file mode 100644
index 0000000..e59624f
--- /dev/null
+++ b/glflag.mod/doc/commands.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<title>BlitzMax Module Reference</title>
+<link rel="stylesheet" type="text/css" href="../../../../doc/bmxstyle.css">
+</head>
+<body>
+<h1>Module Information</h1>
+<table>
+<tr><td><b>Framework</b></td>
+<td> Simple Open GL Backdrop flag</td></tr>
+<tr><td><b>Copyright</b></td>
+<td> Public Domain</td></tr>
+<tr><td><b>Author</b></td>
+<td> Ian Cowburn</td></tr>
+<tr><td><b>Version</b></td>
+<td> $Revision$</td></tr>
+</table>
+</body>
+</html>
diff --git a/simplegui.mod/doc/commands.html b/simplegui.mod/doc/commands.html
new file mode 100644
index 0000000..c66334a
--- /dev/null
+++ b/simplegui.mod/doc/commands.html
@@ -0,0 +1,109 @@
+<html>
+<head>
+<title>BlitzMax Module Reference</title>
+<link rel="stylesheet" type="text/css" href="../../../../doc/bmxstyle.css">
+</head>
+<body>
+<h1>Function Reference</h1>
+<p><div id=GUINotify class=ref>
+<div class=rootdoc><font class=token>Function GUINotify( s:String )</font> Displays a notification alert with the supplied string.</div><div class=indent></div><br></div><br>
+<p><div id=GUIYesNo class=ref>
+<div class=rootdoc><font class=token>Function GUIYesNo:Int( s:String )</font> Displays a yes/no alert with the supplied string.</div><div class=indent><p><b>Returns:</b> True if Yes selected, otherwise False.</div><br></div><br>
+<p><div id=GUIMenu class=ref>
+<div class=rootdoc><font class=token>Function GUIMenu( title:String, options:String[],x,y )</font> Displays a pop-up menu.</div><div class=indent><p><b>Returns:</b> The index of the selected option, -1 for none.<p><b>title</b> is the menu title, <b>options</b> the options to display and <b>x</b> and <b>y</b> specify its position,.</div><br></div><br>
+<h1>Type Reference</h1>
+<p><div id=TGUIFont class=ref>
+<div class=rootdoc><font class=token>Type TGUIFont</font> Defines the <b>TBitmapFont</b> to be used by the GUI.</div><div class=indent></div><br><p><div id=font>
+<div class=rootdoc><font class=token>Global font:TBitmapFont</font> The font to use.</div><div class=indent></div><br></div><br>
+</div><br>
+<p><div id=TWidget class=ref>
+<div class=rootdoc><font class=token>Type TWidget Abstract</font> The base widget type.</div><div class=indent></div><br><p><div id=enabled>
+<div class=rootdoc><font class=token>Field enabled:Int</font> If true the widget is displayed and can be used.</div><div class=indent></div><br></div><br>
+<p><div id=text>
+<div class=rootdoc><font class=token>Field text:String</font> The text displayed in the widget.</div><div class=indent></div><br></div><br>
+<p><div id=x>
+<div class=rootdoc><font class=token>Field x:Int</font> The X co-ordinate of the widget.</div><div class=indent></div><br></div><br>
+<p><div id=y>
+<div class=rootdoc><font class=token>Field y:Int</font> The Y co-ordinate of the widget.</div><div class=indent></div><br></div><br>
+<p><div id=w>
+<div class=rootdoc><font class=token>Field w:Int</font> The width of the widget.</div><div class=indent></div><br></div><br>
+<p><div id=h>
+<div class=rootdoc><font class=token>Field h:Int</font> The height of the widget.</div><div class=indent></div><br></div><br>
+<p><div id=callback>
+<div class=rootdoc><font class=token>Field callback(w:TWidget)</font> Callback to call when clicked.</div><div class=indent></div><br></div><br>
+<p><div id=mouse_over>
+<div class=rootdoc><font class=token>Field mouse_over:Int</font> True if the mouse is over this widget, False otherwise.</div><div class=indent></div><br></div><br>
+<p><div id=owner>
+<div class=rootdoc><font class=token>Field owner:TGUIHandler</font> The <b>TGUIHandler</b> that owns this widget.</div><div class=indent></div><br></div><br>
+<p><div id=HandleKey>
+<div class=rootdoc><font class=token>Method HandleKey( k:Int )</font> Override this accept keypresses</div><div class=indent></div><br></div><br>
+<p><div id=MouseEnter>
+<div class=rootdoc><font class=token>Method MouseEnter()</font> Override this for when the mouse enters. Call this parent version to handle <b>mouse_over</b> too.</div><div class=indent></div><br></div><br>
+<p><div id=MouseLeave>
+<div class=rootdoc><font class=token>Method MouseLeave()</font> Override this for when the mouse leaves. Call this parent version to handle <b>mouse_over</b> too.</div><div class=indent></div><br></div><br>
+<p><div id=HandleClick>
+<div class=rootdoc><font class=token>Method HandleClick()</font> Override to handle a mouse button press.</div><div class=indent></div><br></div><br>
+<p><div id=Draw>
+<div class=rootdoc><font class=token>Method Draw()</font> Must be provided by a widget to draw itself.</div><div class=indent></div><br></div><br>
+<p><div id=DrawBox>
+<div class=rootdoc><font class=token>Function DrawBox( x:Int, y:Int, w:Int, h:Int )</font> Helper to draw a wireframe rectangle.</div><div class=indent></div><br></div><br>
+<p><div id=Draw3DBox>
+<div class=rootdoc><font class=token>Function Draw3DBox( x:Int, y:Int, w:Int, h:Int, invert:Int, size:Int=2 )</font> Helper to draw a 3D rectangle.</div><div class=indent></div><br></div><br>
+</div><br>
+<p><div id=TLabel class=ref>
+<div class=rootdoc><font class=token>Type TLabel Extends TWidget</font> The label widget (simply displays the supplied string)</div><div class=indent></div><br><p><div id=Create>
+<div class=rootdoc><font class=token>Function Create:TLabel( gui:TGUIHandler,x:Int, y:Int, text:String )</font> Create a TLabel widget.</div><div class=indent><p><b>Returns:</b> The created widget.<p><b>gui</b> is the <b>TGUIHandler</b> object managing this wiget. <b>x</b> and <b>y</b> are its position and <b>text</b> is the text to display in the label.</div><br></div><br>
+</div><br>
+<p><div id=TText class=ref>
+<div class=rootdoc><font class=token>Type TText Extends TWidget</font> The text entry widget</div><div class=indent></div><br><p><div id=Create>
+<div class=rootdoc><font class=token>Function Create:TText( gui:TGUIHandler,x:Int, y:Int, text:String, maxlen:Int, callback(w:TWidget)=Null )</font> Create a TText widget.</div><div class=indent><p><b>Returns:</b> The created widget.<p><b>gui</b> is the <b>TGUIHandler</b> object managing this wiget. <b>x</b> and <b>y</b> are its position and <b>text</b> is the initial text in the widget.
+<b>maxlen</b> is the maximum number of characters allowed. <b>callback</b> is called when RETURN is pressed in the text field.</div><br></div><br>
+</div><br>
+<p><div id=TCheckbox class=ref>
+<div class=rootdoc><font class=token>Type TCheckbox Extends TWidget</font> The checkbox widget</div><div class=indent></div><br><p><div id=checked>
+<div class=rootdoc><font class=token>Field checked:Int</font> True if the box is checked, False otherwise.</div><div class=indent></div><br></div><br>
+<p><div id=Create>
+<div class=rootdoc><font class=token>Function Create:TCheckbox( gui:TGUIHandler, x:Int, y:Int, text:String, callback(w:TWidget)=Null )</font> Create a TCheckox widget.</div><div class=indent><p><b>Returns:</b> The created widget.<p><b>gui</b> is the <b>TGUIHandler</b> object managing this wiget. <b>x</b> and <b>y</b> are its position and <b>text</b> is the text to display by the checkbox.
+<b>callback</b> is called when the checkbox is toggled.</div><br></div><br>
+</div><br>
+<p><div id=TButton class=ref>
+<div class=rootdoc><font class=token>Type TButton Extends TWidget</font> The button widget</div><div class=indent></div><br><p><div id=Create>
+<div class=rootdoc><font class=token>Function Create:TButton( gui:TGUIHandler, x:Int, y:Int, w:Int, h:Int, text:String, callback(w:TWidget) )</font> Create a TButton widget.</div><div class=indent><p><b>Returns:</b> The created widget.<p><b>gui</b> is the <b>TGUIHandler</b> object managing this wiget. <b>x</b>, <b>y</b>, <b>w</b> and <b>h</b> are its position and size, and <b>text</b> is the text to display in the button.
+<b>callback</b> is called when the button is pressed.</div><br></div><br>
+</div><br>
+<p><div id=TButtonList class=ref>
+<div class=rootdoc><font class=token>Type TButtonList Extends TWidget</font> A drop down list type widget</div><div class=indent></div><br><p><div id=selected>
+<div class=rootdoc><font class=token>Field selected:Int</font> The selected item.</div><div class=indent></div><br></div><br>
+<p><div id=Create>
+<div class=rootdoc><font class=token>Function Create:TButtonList( gui:TGUIHandler, x:Int, y:Int, options:String[], selected:Int, callback(w:TWidget) )</font> Create a TButtonList widget.</div><div class=indent><p><b>Returns:</b> The created widget.<p><b>gui</b> is the <b>TGUIHandler</b> object managing this wiget. <b>x</b> and <b>y</b> are its position. <b>options</b> are the options for the list and
+<b>selected</b> is the currently selected item. <b>callback</b> is called when the selection changes.</div><br></div><br>
+</div><br>
+<p><div id=TGUIHandler class=ref>
+<div class=rootdoc><font class=token>Type TGUIHandler</font> Handles the GUI.</div><div class=indent></div><br><p><div id=Register>
+<div class=rootdoc><font class=token>Method Register( w:TWidget )</font> Register a widget.</div><div class=indent><p>Widgets call this themselves.</div><br></div><br>
+<p><div id=Clear>
+<div class=rootdoc><font class=token>Method Clear()</font> Remove all widgets.</div><div class=indent></div><br></div><br>
+<p><div id=SetFocus>
+<div class=rootdoc><font class=token>Method SetFocus( w:TWidget )</font> Sets the keyboard focus to the supplied widget. Pass null for no focus.</div><div class=indent></div><br></div><br>
+<p><div id=GetFocus>
+<div class=rootdoc><font class=token>Method GetFocus:TWidget()</font> Gets the keyboard focus.</div><div class=indent><p><b>Returns:</b> The currently focused TWidget, or null for no focus.</div><br></div><br>
+<p><div id=Clicked>
+<div class=rootdoc><font class=token>Method Clicked:TWidget()</font> Gets the last clicked widget.</div><div class=indent><p><b>Returns:</b> The last clicked TWidget. Null is returned if this is called again before another widget is clicked.</div><br></div><br>
+<p><div id=EventLoop>
+<div class=rootdoc><font class=token>Method EventLoop()</font> Perform the event loop and pass any necessary events.</div><div class=indent><p>KeyHit(KEY_MOUSELEFT) and GetChar() are used to consume events for the interface.</div><br></div><br>
+<p><div id=Create>
+<div class=rootdoc><font class=token>Function Create:TGUIHandler()</font> Create a GUI Handler.</div><div class=indent><p><b>Returns:</b> The GUI Hanbler.</div><br></div><br>
+</div><br>
+<h1>Module Information</h1>
+<table>
+<tr><td><b>Framework</b></td>
+<td> (Very) Simple GUI</td></tr>
+<tr><td><b>Copyright</b></td>
+<td> Public Domain</td></tr>
+<tr><td><b>Author</b></td>
+<td> Ian Cowburn</td></tr>
+<tr><td><b>Version</b></td>
+<td> $Revision$</td></tr>
+</table>
+</body>
+</html>
diff --git a/simplegui.mod/simplegui.bmx b/simplegui.mod/simplegui.bmx
index 712c61f..bcabdb0 100644
--- a/simplegui.mod/simplegui.bmx
+++ b/simplegui.mod/simplegui.bmx
@@ -1,3 +1,6 @@
+Rem
+bbdoc: noddybox.simplegui
+EndRem
Module noddybox.simplegui
ModuleInfo "Framework: (Very) Simple GUI"
@@ -12,38 +15,92 @@ Import brl.Max2D
Import brl.Basic
Import noddybox.bitmapfont
+Rem
+bbdoc: Defines the @TBitmapFont to be used by the GUI.
+EndRem
Type TGUIFont
+ Rem
+ bbdoc: The font to use.
+ EndRem
Global font:TBitmapFont
End Type
+Rem
+bbdoc: The base widget type.
+EndRem
Type TWidget Abstract
+ Rem
+ bbdoc: If true the widget is displayed and can be used.
+ EndRem
Field enabled:Int
+ Rem
+ bbdoc: The text displayed in the widget.
+ EndRem
Field text:String
+ Rem
+ bbdoc: The X co-ordinate of the widget.
+ EndRem
Field x:Int
+ Rem
+ bbdoc: The Y co-ordinate of the widget.
+ EndRem
Field y:Int
+ Rem
+ bbdoc: The width of the widget.
+ EndRem
Field w:Int
+ Rem
+ bbdoc: The height of the widget.
+ EndRem
Field h:Int
- Field owner:TGUIHandler
+ Rem
+ bbdoc: Callback to call when clicked.
+ EndRem
Field callback(w:TWidget)
+ Rem
+ bbdoc: True if the mouse is over this widget, False otherwise.
+ EndRem
Field mouse_over:Int
-
+ Rem
+ bbdoc: The @TGUIHandler that owns this widget.
+ EndRem
+ Field owner:TGUIHandler
+
+ Rem
+ bbdoc: Override this accept keypresses
+ EndRem
Method HandleKey(k:Int)
End Method
+ Rem
+ bbdoc: Override this for when the mouse enters. Call this parent version to handle @mouse_over too.
+ EndRem
Method MouseEnter()
mouse_over=True
End Method
+ Rem
+ bbdoc: Override this for when the mouse leaves. Call this parent version to handle @mouse_over too.
+ EndRem
Method MouseLeave()
mouse_over=False
End Method
+ Rem
+ bbdoc: Override to handle a mouse button press.
+ EndRem
Method HandleClick()
End Method
+ Rem
+ bbdoc: Must be provided by a widget to draw itself.
+ EndRem
Method Draw() Abstract
+ Rem
+ bbdoc: Helper to draw a wireframe rectangle.
+ EndRem
Function DrawBox(x:Int, y:Int, w:Int, h:Int)
DrawLine(x,y,x+w-1,y)
DrawLine(x+w-1,y,x+w-1,y+h-1)
@@ -51,6 +108,9 @@ Type TWidget Abstract
DrawLine(x,y+h-1,x,y)
End Function
+ Rem
+ bbdoc: Helper to draw a 3D rectangle.
+ EndRem
Function Draw3DBox(x:Int, y:Int, w:Int, h:Int, invert:Int, size:Int=2)
Local f:Int
@@ -82,7 +142,15 @@ Type TWidget Abstract
End Type
+Rem
+bbdoc: The label widget (simply displays the supplied string)
+EndRem
Type TLabel Extends TWidget
+ Rem
+ bbdoc: Create a TLabel widget.
+ returns: The created widget.
+ about: @gui is the @TGUIHandler object managing this wiget. @x and @y are its position and @text is the text to display in the label.
+ EndRem
Function Create:TLabel(gui:TGUIHandler,x:Int, y:Int, text:String)
Local o:TLabel=New TLabel
o.enabled=True
@@ -101,9 +169,18 @@ Type TLabel Extends TWidget
End Type
+Rem
+bbdoc: The text entry widget
+EndRem
Type TText Extends TWidget
Field maxlen:Int
+ Rem
+ bbdoc: Create a TText widget.
+ returns: The created widget.
+ about: @gui is the @TGUIHandler object managing this wiget. @x and @y are its position and @text is the initial text in the widget.
+ about: @maxlen is the maximum number of characters allowed. @callback is called when RETURN is pressed in the text field.
+ EndRem
Function Create:TText(gui:TGUIHandler,x:Int, y:Int, text:String, maxlen:Int, callback(w:TWidget)=Null)
Local o:TText=New TText
o.enabled=True
@@ -153,9 +230,22 @@ Type TText Extends TWidget
End Method
End Type
+Rem
+bbdoc: The checkbox widget
+EndRem
Type TCheckbox Extends TWidget
+
+ Rem
+ bbdoc: True if the box is checked, False otherwise.
+ EndRem
Field checked:Int
+ Rem
+ bbdoc: Create a TCheckox widget.
+ returns: The created widget.
+ about: @gui is the @TGUIHandler object managing this wiget. @x and @y are its position and @text is the text to display by the checkbox.
+ about: @callback is called when the checkbox is toggled.
+ EndRem
Function Create:TCheckbox(gui:TGUIHandler, x:Int, y:Int, text:String, callback(w:TWidget)=Null)
Local o:TCheckbox=New TCheckbox
o.enabled=True
@@ -195,11 +285,20 @@ Type TCheckbox Extends TWidget
End Method
End Type
+Rem
+bbdoc: The button widget
+EndRem
Type TButton Extends TWidget
Field ox:Int
Field oy:Int
+ Rem
+ bbdoc: Create a TButton widget.
+ returns: The created widget.
+ about: @gui is the @TGUIHandler object managing this wiget. @x, @y, @w and @h are its position and size, and @text is the text to display in the button.
+ about: @callback is called when the button is pressed.
+ EndRem
Function Create:TButton(gui:TGUIHandler, x:Int, y:Int, w:Int, h:Int, text:String, callback(w:TWidget))
Local o:TButton=New TButton
o.enabled=True
@@ -233,6 +332,74 @@ Type TButton Extends TWidget
End Method
End Type
+Rem
+bbdoc: A drop down list type widget
+EndRem
+Type TButtonList Extends TWidget
+
+ Field options:String[]
+
+ Rem
+ bbdoc: The selected item.
+ EndRem
+ Field selected:Int
+
+ Rem
+ bbdoc: Create a TButtonList widget.
+ returns: The created widget.
+ about: @gui is the @TGUIHandler object managing this wiget. @x and @y are its position. @options are the options for the list and
+ about: @selected is the currently selected item. @callback is called when the selection changes.
+ EndRem
+ Function Create:TButtonList(gui:TGUIHandler, x:Int, y:Int, options:String[], selected:Int, callback(w:TWidget))
+ Local o:TButtonList=New TButtonList
+ Local maxw:Int=0
+ o.enabled=True
+ o.x=x
+ o.y=y
+ o.options=options
+ o.selected=selected
+ o.text=options[selected]
+
+ For Local s:String=EachIn options
+ maxw=Max(maxw,TGUIFont.font.TextWidth(s))
+ Next
+
+ o.w=maxw+TGUIFont.font.MaxHeight()+4
+ o.h=TGUIFont.font.MaxHeight()+2
+ o.callback=callback
+ gui.Register(o)
+ Return o
+ End Function
+
+ Method HandleClick()
+ Local sel:Int=GUIMenu("Select value",options,x,y)
+
+ If sel<>-1
+ selected=sel
+ text=options[selected]
+ If callback<>Null
+ callback(Self)
+ EndIf
+ EndIf
+ End Method
+
+ Method Draw()
+ If (mouse_over)
+ SetColor(128,128,128)
+ Else
+ SetColor(64,64,64)
+ EndIf
+
+ DrawRect(x,y,w,h)
+ Draw3DBox(x+2,y+2,h-4,h-4,False,1)
+
+ TGUIFont.font.Draw(text,x+TGUIFont.font.MaxHeight()+3,y+1)
+ End Method
+End Type
+
+Rem
+bbdoc: Handles the GUI.
+EndRem
Type TGUIHandler
' These are private
@@ -242,8 +409,10 @@ Type TGUIHandler
Field m_over:TWidget
Field m_clicked:TWidget
- ' Creates a new GUI handler
- '
+ Rem
+ bbdoc: Create a GUI Handler.
+ returns: The GUI Hanbler.
+ EndRem
Function Create:TGUIHandler()
Local o:TGUIHandler
@@ -257,41 +426,51 @@ Type TGUIHandler
Return o
End Function
- ' Register a widget
- '
+ Rem
+ bbdoc: Register a widget.
+ about: Widgets call this themselves.
+ EndRem
Method Register(w:TWidget)
m_widgets.AddLast(w)
w.owner=Self
End Method
- ' Clear widgets
- '
+ Rem
+ bbdoc: Remove all widgets.
+ EndRem
Method Clear()
m_widgets.Clear()
End Method
- ' Set the keyboard focus (null for none)
- '
+ Rem
+ bbdoc: Sets the keyboard focus to the supplied widget. Pass null for no focus.
+ EndRem
Method SetFocus(w:TWidget)
m_focus=w
End Method
- ' Get the keyboard focus (null for none)
- '
+ Rem
+ bbdoc: Gets the keyboard focus.
+ returns: The currently focused TWidget, or null for no focus.
+ EndRem
Method GetFocus:TWidget()
Return m_focus
End Method
- ' Gets the last clicked widget
- '
+ Rem
+ bbdoc: Gets the last clicked widget.
+ returns: The last clicked TWidget. Null is returned if this is called again before another widget is clicked.
+ EndRem
Method Clicked:TWidget()
Local last:TWidget=m_clicked
m_clicked=Null
Return last
End Method
- ' Perform a loop and any necessary events
- '
+ Rem
+ bbdoc: Perform the event loop and pass any necessary events.
+ about: KeyHit(KEY_MOUSELEFT) and GetChar() are used to consume events for the interface.
+ EndRem
Method EventLoop()
Local x:Int=MouseX()
Local y:Int=MouseY()
@@ -340,6 +519,9 @@ Type TGUIHandler
End Type
+Rem
+bbdoc: Displays a notification alert with the supplied string.
+EndRem
Function GUINotify(s:String)
Local back:TImage=CreateImage(GraphicsWidth(),GraphicsHeight(),1,0)
GrabImage(back,0,0)
@@ -368,6 +550,10 @@ Function GUINotify(s:String)
Wend
End Function
+Rem
+bbdoc: Displays a yes/no alert with the supplied string.
+returns: True if Yes selected, otherwise False.
+EndRem
Function GUIYesNo:Int(s:String)
Local back:TImage=CreateImage(GraphicsWidth(),GraphicsHeight(),1,0)
GrabImage(back,0,0)
@@ -400,6 +586,11 @@ Function GUIYesNo:Int(s:String)
End Function
+Rem
+bbdoc: Displays a pop-up menu.
+returns: The index of the selected option, -1 for none.
+about: @title is the menu title, @options the options to display and @x and @y specify its position,.
+EndRem
Function GUIMenu(title:String, options:String[],x,y)
Local f:Int
Local back:TImage=CreateImage(GraphicsWidth(),GraphicsHeight(),1,0)
diff --git a/vector.mod/doc/commands.html b/vector.mod/doc/commands.html
new file mode 100644
index 0000000..4cb9c08
--- /dev/null
+++ b/vector.mod/doc/commands.html
@@ -0,0 +1,56 @@
+<html>
+<head>
+<title>BlitzMax Module Reference</title>
+<link rel="stylesheet" type="text/css" href="../../../../doc/bmxstyle.css">
+</head>
+<body>
+<h1>Type Reference</h1>
+<p><div id=TVector class=ref>
+<div class=rootdoc><font class=token>Type TVector</font> Implements a 3D vector. Can be used as a 2D vector by ignoring Z.</div><div class=indent></div><br><p><div id=x>
+<div class=rootdoc><font class=token>Field x:Float</font> The X component of the vector.</div><div class=indent></div><br></div><br>
+<p><div id=y>
+<div class=rootdoc><font class=token>Field y:Float</font> The Y component of the vector.</div><div class=indent></div><br></div><br>
+<p><div id=z>
+<div class=rootdoc><font class=token>Field z:Float</font> The Z component of the vector.</div><div class=indent></div><br></div><br>
+<p><div id=IsNull>
+<div class=rootdoc><font class=token>Method IsNull:Int()</font> Is the vector null.</div><div class=indent><p><b>Returns:</b> True if the vector is null (all components zero), False otherwise.</div><br></div><br>
+<p><div id=Length>
+<div class=rootdoc><font class=token>Method Length:Float()</font> The length of the vector.</div><div class=indent><p><b>Returns:</b> The length of the vector.</div><br></div><br>
+<p><div id=Normalise>
+<div class=rootdoc><font class=token>Method Normalise()</font> Normalise the vector so its length is 1.</div><div class=indent></div><br></div><br>
+<p><div id=SetLength>
+<div class=rootdoc><font class=token>Method SetLength( sc:Float )</font> Set the vector so its length is <b>sc</b>.</div><div class=indent></div><br></div><br>
+<p><div id=AddScalar>
+<div class=rootdoc><font class=token>Method AddScalar( sc:Float )</font> Adds <b>sc</b> to all components.</div><div class=indent></div><br></div><br>
+<p><div id=Minus>
+<div class=rootdoc><font class=token>Method Minus()</font> Reverse the direction of the vector.</div><div class=indent></div><br></div><br>
+<p><div id=Scale>
+<div class=rootdoc><font class=token>Method Scale( sc:Float )</font> Scale all components by <b>sc</b>.</div><div class=indent></div><br></div><br>
+<p><div id=Add>
+<div class=rootdoc><font class=token>Method Add( v:TVector )</font> Add another vector to this vector.</div><div class=indent></div><br></div><br>
+<p><div id=Subtract>
+<div class=rootdoc><font class=token>Method Subtract( v:TVector )</font> Subtract another vector from this vector.</div><div class=indent></div><br></div><br>
+<p><div id=ScaleVector>
+<div class=rootdoc><font class=token>Method ScaleVector( v:TVector )</font> Scale this vector by another vector.</div><div class=indent></div><br></div><br>
+<p><div id=InverseScaleVector>
+<div class=rootdoc><font class=token>Method InverseScaleVector( v:TVector )</font> Inverse scale this vector by another vector.</div><div class=indent></div><br></div><br>
+<p><div id=Cross>
+<div class=rootdoc><font class=token>Method Cross:TVector( v:TVector )</font> Calculate the cross product of this vector with another.</div><div class=indent><p><b>Returns:</b> A new <b>TVector</b> holding the cross product.</div><br></div><br>
+<p><div id=Dot>
+<div class=rootdoc><font class=token>Method Dot:Float( v:TVector )</font> Calculate the dot product of this vector with another.</div><div class=indent><p><b>Returns:</b> The dot product.</div><br></div><br>
+<p><div id=Create>
+<div class=rootdoc><font class=token>Function Create:TVector( dx:Float=0.0, dy:Float=0.0, dz:Float=0.0 )</font> Create a vector.</div><div class=indent><p><b>Returns:</b> The created vector.<p><b>dx</b>, <b>dy</b> and <b>dz</b> are the initial component values.</div><br></div><br>
+</div><br>
+<h1>Module Information</h1>
+<table>
+<tr><td><b>Framework</b></td>
+<td> Simple Vector class</td></tr>
+<tr><td><b>Copyright</b></td>
+<td> Public Domain</td></tr>
+<tr><td><b>Author</b></td>
+<td> Ian Cowburn</td></tr>
+<tr><td><b>Version</b></td>
+<td> $Revision$</td></tr>
+</table>
+</body>
+</html>
diff --git a/vector.mod/vector.bmx b/vector.mod/vector.bmx
index f32035b..67818fe 100644
--- a/vector.mod/vector.bmx
+++ b/vector.mod/vector.bmx
@@ -1,3 +1,6 @@
+Rem
+bbdoc: noddybox.vector
+EndRem
Module noddybox.vector
ModuleInfo "Framework: Simple Vector class"
@@ -10,21 +13,30 @@ ModuleInfo "Version: $Revision$"
Strict
Import brl.math
+Rem
+bbdoc: Implements a 3D vector. Can be used as a 2D vector by ignoring Z.
+EndRem
Type TVector
+ Rem
+ bbdoc: The X component of the vector.
+ EndRem
Field x:Float
+ Rem
+ bbdoc: The Y component of the vector.
+ EndRem
Field y:Float
+ Rem
+ bbdoc: The Z component of the vector.
+ EndRem
Field z:Float
- ' Creates a new vector
- '
- ' dx - X componenent
- ' dy - Y componenent
- ' dz - Z componenent
- '
- ' Returns null for invalid parameters.
- '
+ Rem
+ bbdoc: Create a vector.
+ returns: The created vector.
+ about: @dx, @dy and @dz are the initial component values.
+ EndRem
Function Create:TVector(dx:Float=0.0, dy:Float=0.0, dz:Float=0.0)
Local o:TVector
@@ -37,14 +49,18 @@ Type TVector
Return o
End Function
- ' Is this vector null
- '
+ Rem
+ bbdoc: Is the vector null.
+ returns: True if the vector is null (all components zero), False otherwise.
+ EndRem
Method IsNull:Int()
Return x=0 And y=0 And z=0
End Method
- ' Get the length of the vector
- '
+ Rem
+ bbdoc: The length of the vector.
+ returns: The length of the vector.
+ EndRem
Method Length:Float()
If (IsNull())
Return 0
@@ -53,8 +69,9 @@ Type TVector
EndIf
End Method
- ' Normalise the vector
- '
+ Rem
+ bbdoc: Normalise the vector so its length is 1.
+ EndRem
Method Normalise()
Local l:Float=Length()
If (l<>0)
@@ -64,78 +81,89 @@ Type TVector
EndIf
End Method
- ' Set the vector to a length
- '
+ Rem
+ bbdoc: Set the vector so its length is @sc.
+ EndRem
Method SetLength(sc:Float)
Normalise()
Scale(sc)
End Method
- ' Add a scalar to the vector
- '
+ Rem
+ bbdoc: Adds @sc to all components.
+ EndRem
Method AddScalar(sc:Float)
x:+sc
y:+sc
z:+sc
End Method
- ' Flip the vector
- '
+ Rem
+ bbdoc: Reverse the direction of the vector.
+ EndRem
Method Minus()
x=-x
y=-y
z=-z
End Method
- ' Scale the vector by a scalar
- '
+ Rem
+ bbdoc: Scale all components by @sc.
+ EndRem
Method Scale(sc:Float)
x:*sc
y:*sc
z:*sc
End Method
- ' Add another vector to this
- '
+ Rem
+ bbdoc: Add another vector to this vector.
+ EndRem
Method Add(v:TVector)
x:+v.x
y:+v.y
z:+v.z
End Method
- ' Subtract another vector from this
- '
+ Rem
+ bbdoc: Subtract another vector from this vector.
+ EndRem
Method Subtract(v:TVector)
x:-v.x
y:-v.y
z:-v.z
End Method
- ' Scale this with another vector
- '
+ Rem
+ bbdoc: Scale this vector by another vector.
+ EndRem
Method ScaleVector(v:TVector)
x:*v.x
y:*v.y
z:*v.z
End Method
- ' Inverse scale this with another vector
- '
+ Rem
+ bbdoc: Inverse scale this vector by another vector.
+ EndRem
Method InverseScaleVector(v:TVector)
x:/v.x
y:/v.y
z:/v.z
End Method
- ' Calculate the cross product of this vector with another.
- ' Returns a new vector.
- '
+ Rem
+ bbdoc: Calculate the cross product of this vector with another.
+ returns: A new @TVector holding the cross product.
+ EndRem
Method Cross:TVector(v:TVector)
Return TVector.Create(y * v.z - v.y * z, z * v.x - v.z * x, x * v.y - v.x * y)
End Method
- ' Calculate the dot product of this vector with another.
- '
+ Rem
+ bbdoc: Calculate the dot product of this vector with another.
+ returns: The dot product.
+ EndRem
Method Dot:Float(v:TVector)
Return x*v.x + y*v.y + z*v.z
End Method