Hi all!
I created this simple easy-to-use gui (graphical user interface) for those of us who are too poor or lazy to buy BlueGUI, and don't mind if it looks a little rough. It's very simple, and is definitely lacking in some places, but it is very functional and easy to use. I have included the .dba and documentation in the zip file. The gui is intended to be included using the #include command, and then accessed using the functions. Here's a little bit out of the document describing the interface:
--Setup Functions--
These functions are what you use to set up the GUI objects.
makeBtn(ButtonText$, xPos, yPos, Width, Height, Border)
- Makes a button, with the text in ButtonText$, with upper-left corner at xPos, yPos, and with the width and height specified. The border number is just a colored border around the button, just set it as 1 normally. Returns the number of the GUI object created.
makeChk(Text$, xpos, ypos, xsiz, ysiz, border, state)
- Makes a checkbox. The Text$ supplied is the text that will be printed to the left of the checkbox. The checkbox will be built at xpos, ypos, and will be xsiz and ysiz in size. The border specifies the thickness of the box, and if state is set at 1 then the checkbox will be checked. Returns the number of the GUI object created.
makeRbtn(Text$,xpos, ypos, xsiz, ysiz, border, state, group)
- Makes a radiobutton. The Text$ is the text which will be printed to the left of the radiobutton. The radiobbutton will be built at xpos, ypos, and will be xsiz and ysiz in size. The border specifies the thickness of the box, and if state is set at 1 then the radiobutton will be checked. The group specifies which group the radiobutton belongs to. In a single group, only one button can be selected at a time. Returns the number of the GUI object created.
makeTbox(Text$, xpos, ypos, xsiz, ysiz, border)
- Makes a text input box. The Text$ is text that will be in the textbox when it is created. To leave it empty, just put "" for Text$. The textbox will be built at xpos, ypos, and will be xsiz and ysiz in size. The border specifies the thickness of the box. Returns the number of the GUI object created.
--Interface Functions--
These are the main functions to interface with the GUI.
guiEvent()
- This is the main function that returns data to your program. In order for this function to work, you must call it as frequently as you want to get user input. If anything is clicked on, the function will return the id number of the GUI object clicked.
updateGui(noCls,noSync)
- This is the command that will draw the gui to your screen. If the first parameter is set to 1 then the program will not clear the screen when drawing. If the second parameter is set to 1 then the program will not sync after GUI is drawn to screen.
--Input Functions--
Use these functions to return data from the GUI.
returnSelection(groupNum)
- Will return the number of the radiobutton selected from the group specified
function returnState(objNum)
- This function returns the state (selected, unselected) of the object specified, either a checkbox or a radiobutton.
function clearGui()
- This function destroys all GUI objects
And a (very) small sample program:
#include "DBGUI.dba"
rem Set up some vars for the GUI program
global backClr as integer: backClr = rgb(245,245,245) `off-white
global clr1 as integer: clr1 = rgb(200,200,200) `light gray
global clr2 as integer: clr2 = rgb(70,70,70) `dark gray
global borderClr as integer: borderClr = rgb(0,0,0) `black
global btnTextClr as integer: btnTextClr = rgb(10,10,10) `almost black
global textClr as integer: textClr = rgb(0,0,0) `black
global chkClr as integer: chkClr = rgb(255,0,0) `bright red
global rbtnClr as integer: rbtnClr = rgb(25,100,25) `green
global tboxClr as integer: tboxClr = rgb(150,150,150) `gray
rem create a custom type to hold gui info
TYPE guiInfo
type as string
name as string
posX as integer
posY as integer
width as integer
height as integer
border as integer
state as integer
group as integer
ENDTYPE
rem now create the array
dim obj(100) as guiInfo
global objIndex = 1
testBtn = makeBtn("Hello!",10,10,50,20,1)
exitBtn = makeBtn("Exit", 70,10,50,20,1)
event = 0
while event <> exitBtn
updateGui(0,0)
event = guiEvent()
if event = testBtn
red = rnd(255)
green = rnd(255)
blue = rnd(255)
backClr = rgb(red, green, blue)
endif
endwhile
Anyways, feel free to try it out and tell me what you think. Please, don't make fun of its looks, I didn't make it for beauty, more for functionality.
-H4ck1d
EDIT:
Just so you know, this seems to work a lot better and faster when exe is in windowed, non-fullscreen mode.
There are 10 types of people, those who understand binary and those that don't.