Button library using zones.

File:
buttons.lib
Version:
1.0
Author:
John Master

Contents

Details
Constants
Sub routines


Details

Manages very simple text buttons using zones.


Constants

Button states for color settings

Name
Description
BTN_STATE_NORMAL
No activity.
BTN_STATE_OVER
Mouse over button.
BTN_STATE_PRESSED
Button pressed.

Button parts for color settings

Name
Description
BTN_PART_FILL
Fill color.
BTN_PART_TOP_LEFT
Top and left lines color.
BTN_PART_BOTTOM_RIGHT
Bottom and right lines color.
BTN_PART_LABEL
Text label color.


Subroutines

Name
Parameters
Brief description
procedure
ClearButtons
Remove all buttons and free zones.
procedure
SetButtonFont
index
Set font used by buttons.
procedure
SetButtonColor
state, part, rgb
Set colors used when drawing buttons.
function
NewButton
label$, x, y
Create new text button.
function
NewButtonCentered
label$, x, y
Create new centered text button.
function
NewImageButton
img, x, y
Create new image button.
function
ButtonX
btn
Get button x coordinate.
function
ButtonY
btn
Get button y coordinate.
function
RightOfButton
btn
Get X coordinate right of button.
function
BelowButton
btn
Get Y coordinate below button.
function
ButtonWidth
btn
Get width of button.
function
ButtonHeight
btn
Get height of button.
procedure
DrawButtons
Draw buttons.


Subroutine documentation

procedure ClearButtons ( )

Remove all buttons and free zones.

[ Back ]


procedure SetButtonFont ( index )

By default font index 0 is used. The font is used for calculating the size of buttons at creation time, and it applies to all buttons. If you want to use another font index than 0, this function should therefor be called before creating any of your buttons.

Parameter
Mode
Description
index
In
Font index.

[ Back ]


procedure SetButtonColor ( state, part, rgb )

The state parameter can be BTN_STATE_NORMAL, BTN_STATE_OVER or BTN_STATE_PRESSED, and the part parameter can be BTN_PART_FILL, BTN_PART_TOP_LEFT, BTN_PART_BOTTOM_RIGHT or BTN_PART_LABEL

Parameter
Mode
Description
state
In
Button state.
part
In
Button part.
rgb
In
Color.

[ Back ]


function NewButton ( label$, x, y )

This function returns a zone identifier. The identifier returned for the first button you create will be 1, for the second button it will be 2, and so forth. When you call ClearButtons all zones are freed and the identifier will start over at 1 when creating new buttons.

Parameter
Mode
Description
label
In
Button label.
x
In
X coordinate.
y
In
Y coordinate.

Return value
Zone id.

[ Back ]


function NewButtonCentered ( label$, x, y )

This function works just like NewButton but centers the button horizontaly.

Parameter
Mode
Description
label
In
Button label.
x
In
Center x coordinate.
y
In
Y coordinate.

Return value
Zone id.

[ Back ]


function NewImageButton ( img, x, y )

This function works just like NewButton but uses an image instead of a text label.

Parameter
Mode
Description
img
In
Image.
x
In
X coordinate.
y
In
Y coordinate.

Return value
Zone id.

[ Back ]


function ButtonX ( btn )

Get button x coordinate.

Parameter
Mode
Description
btn
In
Button/zone id.

Return value
X coordinate.

[ Back ]


function ButtonY ( btn )

Get button y coordinate.

Parameter
Mode
Description
btn
In
Button/zone id.

Return value
Y coordinate.

[ Back ]


function RightOfButton ( btn )

Get X coordinate right of button.

Parameter
Mode
Description
btn
In
Button/zone id.

Return value
X coordinate.

[ Back ]


function BelowButton ( btn )

Get Y coordinate below button.

Parameter
Mode
Description
btn
In
Button/zone id.

Return value
Y coordinate.

[ Back ]


function ButtonWidth ( btn )

Get width of button.

Parameter
Mode
Description
btn
In
Button/zone id.

Return value
Button width.

[ Back ]


function ButtonHeight ( btn )

Get height of button.

Parameter
Mode
Description
btn
In
Button/zone id.

Return value
Button height.

[ Back ]


procedure DrawButtons ( )

Draw buttons.

[ Back ]


Generated with NLDoc 20141122.