right now i have making forms a auto made close button. moving windows. making buttons and putting text on the window.
to make the buttons do something. use the variable Cbutton(Form) that will return the current button being clicked.
i finaly got priority ( well kinda. you can't press buttons behind a window but the actuall priority isn't set up.)
= Done
= Working on
= Planning
Making a form
Setting a title
Printing text
Buttons
Resize forms
Exit
Tabs
Minimize
Priority
And much much more. i know alot of people say there making these but never finish but i think (probebly
lol) i'll finish this! im determend! lol
ideas. bugs. critism. anything would be nice! heres the code and image
remstart
-------------------------------------------------------------------
program name: Form Functions
-------------------------------------------------------------------
written by: Caleb Stewart
date:
-------------------------------------------------------------------
comments:
-------------------------------------------------------------------
remend
Dim Forms(101) : Dim FormX(101)
Dim FormY(101) : Dim Forminfo(2,101)
Dim Buttons(101,150) : Dim NumButtons(101)
Dim ButtonWidth(101,150) : Dim ButtonHeight(101,150)
dim ButtonX(100,150) : Dim ButtonY(101,150)
dim buttonimg(101,150,1) : Dim ClosebuttonX(101)
DIm ClosebuttonY(101) : Dim WinOrder(100)
Dim FImage(101) : Dim Cbutton(100)
Sync on
Sync rate 0
WinX=(640/2)/2+25
WinY=(480/2)/2+25
Set window on
Set window position WinX,WinY
Make form(1,"Error!",150,75,50,50,0,5,25,"Cannot Save File")
Make form(2,"Form 2",300,300,75,50,0,0,0,"")
make button(2,3,"Hi",5,75,30,20,705)
make button(2,1,"Ok",5,50,30,20,701)
Make button(2,2,"Cancel",40,50,50,20,703)
make button(1,1,"Hey",40,50,50,20,707)
Form Text(2,"Hehe Text",100,100)
setup
ink rgb(255,255,255),0
Do
update forms
if cbutton(1)=1 then print "Hehe"
Sync
cls
Loop
function setup
make memblock 10,9
endfunction
Function Form text(Form,Text$,X,Y)
Paste image Form+600,0,0
Text x,y,Text$
Get image form+600,0,0,forminfo(1,form),Forminfo(2,Form)
endfunction
Function Make Form(formnum,title$,width,height,X,Y,Color,tx,ty,text$)
Forms(formnum)=1
FormX(Formnum)=X
FormY(Formnum)=Y
Forminfo(1,formnum)=width
Forminfo(2,Formnum)=height
ClosebuttonX(Formnum)=Width-11
ClosebuttonY(formnum)=Height+2
exitbutton(Formnum)
Winorder(100)=Formnum
For X=99 to 2 step -1
winorder(X)=winorder(X-1)
next x
numforms=numforms+1
Fimage(Formnum)=Formnum+600
Ink RGB(192,192,192),0
Box 1,11,width,height
ink RGB(0,0,255),0
box 1,1,width,12
ink Rgb(0,0,0),0
line 1,13,width,13
ink RGB(255,255,255),0
line 0,0,width,0
line 0,0,0,height
ink RGB(0,0,0),0
Line width,0,width,height
line 0,height,width,height
Tsize=text size()
Set text size tsize-1
text 0,0," "+Title$
set text size tsize
if text$>""
Text tx,ty,Text$
endif
Get image formnum+600,0,0,width+1,height+1
cls
endfunction
Function Make Button(Form,button,Text$,X,Y,width,Height,img)
if buttons(form,button)!0 then break "Whoops"
buttons(Form,button)=1
ButtonX(Form,button)=X
ButtonY(Form,button)=Y
ButtonWidth(form,button)=width
ButtonHeight(Form,Button)=Height
Numbuttons(form)=NumButtons(Form)+1
Width=width
height=Height
buttonimg(form,button,0)=img
buttonimg(form,button,1)=img+1
Ink RGB(192,192,192),0
Box 1,1,width+1,Height+1
ink RGB(255,255,255),0
line 0,0,width,0
line 0,0,0,height
ink RGB(0,0,0),0
Line width,0,width,height
line width,height,0,height
Text 0,0," "+Text$
Get image img,0,0,width+1,Height+1
Ink RGB(192,192,192),0
Box 1,1,width+1,Height+1
ink RGB(0,0,0),0
line 0,0,width,0
line 0,0,0,height
ink RGB(255,255,255),0
Line width,0,width,height
line width,height,0,height
ink rgb(0,0,0),0
Text 0,0," "+Text$
Get image img+1,0,0,width+1,Height+1
endfunction
function Update forms
for X=1 to 101
For Y=1 to 101
if forms(y)=1
if mouseinside(Formx(Y),FormY(Y),Forminfo(1,Y)+FormX(Y),Forminfo(2,Y)+FormY(Y))
selected=Y
endif
endif
next y
if forms(X)=1
Sprite X+600,formx(X),FormY(X),X+600
set sprite X+600,1,0
if mouseclick()
if move=0 and selected=X
if on title(X)
move=X
endif
endif
if move=X and selected=x
if MF=0
diffx=mouseX()-formX(X)
diffY=MouseY()-formY(X)
mf=1
endif
formX(X)=mouseX()-diffX
formY(X)=MouseY()-DiffY
move=X
endif
endif
X1=FormX(X)+ClosebuttonX(X)
X2=FormX(X)+ClosebuttonX(X)+11
Y1=FormY(X)+1
Y2=FormY(X)+11
if mouseclick() and mouseinside(X1,Y1,X2,Y2) and selected=x
sprite (X+50),X1,Y1,802
set sprite (X+50),1,0
Repeat : sync : until mouseclick()=0
if mouseinside(X1,Y1,X2,Y2) then Close form(X)
else
sprite (X+50),X1,Y1,801
set sprite (X+50),1,0
endif
if mouseclick()=0 then move=0 : title=0 : MF=0
oldb=cbutton(0)
for y=1 to numbuttons(X)
if buttons(X,Y)=1
for Z=1 to 100
if mouseclick() and on button(x,y) and on form(Z)=0 and selected=x
sprite Buttonimg(X,Y,1),buttonX(x,y)+FormX(X),buttonY(X,Y)+FormY(X),buttonimg(x,y,1)
show sprite Buttonimg(X,Y,1)
set sprite Buttonimg(X,Y,1),1,0
Cbutton(X)=Y
else
if sprite exist(Buttonimg(X,Y,1)) then hide sprite Buttonimg(X,Y,1)
sprite Buttonimg(X,Y,0),buttonX(x,y)+FormX(X),buttonY(X,Y)+FormY(X),buttonimg(x,y,0)
set sprite Buttonimg(X,Y,0),1,0
endif
next z
endif
next y
first=0
endif
next x
endfunction
function on button(form,button)
clicked=0
if mouseX()>buttonX(form,button)+FormX(form) and MouseX()<(buttonX(form,button)+FormX(form))+buttonwidth(form,button)
if mouseY()>ButtonY(form,button)+FormY(Form) and MouseY()<(buttonY(form,button)+FormY(Form))+buttonheight(Form,button)
clicked=1
exitfunction clicked
endif
endif
endfunction
function on title(form)
if mouseX()>formX(form) and MouseX()<FormX(form)+Forminfo(1,Form)-10
If mouseY()>FormY(Form) and Mousey()<FormY(form)+10
on=1
exitfunction on
endif
endif
endfunction 0
function on form(Form)
if mouseX()>formX(form) and mouseX()<formX(form)+Forminfo(1,form)
if mouseY()>formY(form) and mouseY()<formY(form)+Forminfo(2,form)
exitfunction 1
endif
endif
endfunction 0
function exitbutton(Form)
img=801
width=10
height=10
Ink RGB(192,192,192),0
Box 1,1,width+1,Height+1
ink RGB(255,255,255),0
line 0,0,width,0
line 0,0,0,height
ink RGB(0,0,0),0
Line width,0,width,height
line width,height,0,height
tsize=text size()
set text size tsize-1
Text 2,-2,"X"
Get image 801,0,0,width+1,Height+1
Ink RGB(192,192,192),0
Box 1,1,width+1,Height+1
ink RGB(0,0,0),0
line 0,0,width,0
line 0,0,0,height
ink RGB(255,255,255),0
Line width,0,width,height
line width,height,0,height
ink rgb(0,0,0),0
Text 2,-2,"X"
Get image 802,0,0,width+1,Height+1
set text size tsize
endfunction
Function mouseinside(X1,Y1,X2,Y2)
if mouseX()>X1 and MouseX()<X2
If MouseY()>Y1 and MouseY()<Y2
exitfunction 1
endif
endif
endfunction 0
Function Close Form(Form)
For X=1 to numbuttons(Form)
if buttons(form,X)=1
buttons(Form,X)=0
ButtonX(Form,X)=0
ButtonY(Form,X)=0
ButtonWidth(form,X)=0
ButtonHeight(Form,X)=0
Width=0
height=0
delete sprite buttonimg(form,X,0)
if sprite exist(Buttonimg(form,x,1)) then delete sprite buttonimg(form,x,1)
delete image buttonimg(form,X,0)
buttonimg(form,X,0)=0
delete image buttonimg(form,X,1)
buttonimg(form,X,1)=0
endif
next x
numbuttons(Form)=0
Forms(form)=0
FormX(Form)=0
FormY(Form)=0
Forminfo(1,form)=0
Forminfo(2,Form)=0
ClosebuttonX(Form)=0
ClosebuttonY(form)=0
Delete sprite Form+600
delete sprite form+50
endfunction