I wanted to create button API that wouldnt force user to manually set coordinates of each button, as i couldnt find something like that in other apis.
Project has grown rather big as im still in the middle of coding, and there are still many things to add :)/>

API
http://pastebin.com/LfRjGzRM


There is a lot of functions so for now ill explain only few of them, and the main concept.
Buttons
SpoilerButtons
Currently there are 2 groups of buttons:
Custom
Buttons that belong to this group are created with 2 functions

addCustomButton ( name, func, ymin, ymax, xmin, xmax, mode, colorOFF, colorON)
name - name of the button that will be showed on screen
func - this will be called then button is pressed (or at some other time, look below at Modes section)
ymin, ymax, xmin, xmax - coordinates
mode - button mode , look below
colorOFF, colorON - button colors when on and off. This will be defaulted to red and lime

addCustomCornerButton(name, func, mode, sizeX, sizeY, corner, colorOFF, colorON)
Simplified function to create buttons at corners of the screen.
sizeX, sizeY - size of the button
corner - select corner by passing string with first letters of the directions. so "TL" stands for top left corner of the screen etc.
Basic
Basic buttons will be automatically centered on the screen.

function addBasicButton(name, func, mode, colorOFF, colorON)
look above for parameter explaination.
Modes
SpoilerYou're selecting mode by passing function name.
button.toggle - simple on/off mode, will call "func" each time it is pressed
button.flash - flash mode that will revert to off after sleeping for 0,2. will call "func" when button goes from "off" to "on" state, default state is "off"
button.flashInvert - as above, but will call "func" when button goes from "on" to "off" state, default state is "on"
button.no - same as button.toggle but without any visual effects, useful for next/ previous buttons
Groups
SpoilerIn this api buttons are split into groups in which they were created. Function redrawScreen will show buttons that belong only to currently selected group.
You can change group by calling:

selectGroup (name)
If no group is selected adding button will default group name to "A".

setGroupMonitorBorder (mBT,mBR,mBD,mBL)
setGroupButtonVar (width, height,Xaxis)
setGroupButtonBorder (sX,sY)
setGroupHeading (text)
these are group-specific functions. for explanation look into Functions section below. group specific functions override global ones
Functions
Spoiler


findMonitor (monitor)
This function will search for monitor with a name passed as parameter. If you call it without any parameter it will search for first available monitor.

prepareMonitor ()
this will prepare monitor. if no monitor is specified it will call findMonitor without parameters. THIS HAS TO BE CALLED ONCE

setHeading (text)
This will set global header for all button groups.

setGlobalButtonVar (width, height,Xaxis)
this functions sets global height and width of all basic buttons, Xaxis controls how many button columns will be created. HAS NO EFFECT ON CUSTOM BUTTONS, EITHER THIS ONE OR GROUP VARIANT HAS TO BE CALLED IF YOURE USING BASIC BUTTONS

setGlobalMonitorBorder (mBT,mBR,mBD,mBL)
this sets global border. useful if you want to move basic buttons in any direction. parameters are: top, right, bottom, left. and they're defaulted to 0,0,0,0. if heading is set, defaults to 2,0,0,0.. HAS NO EFFECT ON CUSTOM BUTTONS

setGlobalButtonBorder (sX,sY)
Controls global space between buttons. Calling it with 5,0 will create separate columns of buttons that are touching each other HAS NO EFFECT ON CUSTOM BUTTONS

calculateButtons()
This function calculates positions of basic buttons.HAS TO BE CALLED ONCE IF YOU HAVE AT LEAST ONE BASIC BUTTON, HAS NO EFFECT ON CUSTOM BUTTONS

redrawScreen()
this function is responsible for printing all buttons in selected group on screen
getClick()
Function that controls touching, useful in while true do loop

There is a lot more functions in the code,look at them, i wont explain them here, and their names are self-explanatory

Examples
SpoilerCrazy (and edited like 1k times :P/> ) example
http://pastebin.com/02GW6fLQ

Most basic menu with 4 buttons would be something like:
http://pastebin.com/x0D8Yhfm

Please note that you dont have to set any coordinates, so no try & error in setting them centered, this is done by API


EDIT:
This API will no longer be updated, but i'll help you with using it.
I'm working with something way bigger and more powerful :D/>.