I'm going to try to explain one more time what this thing does.
EzeeGUI was only designed to make FULL WORKING Samples. It's wasn't designed to build projects. It doesn't have an IDE included where you can add to or take away.
I've seen these designers before, that positions little windows on a grid and lets you move them around and generates enough code just to display it, and that's all you would get. If you need a full working example that you can show you more, these things are totally incomplete. Not all of them are like that.
So I made EzeeGUI to give me a full working example. You not only get generated code to position and display the window, you get full WORKING example code that shows you how to:
Get text that you have typed in the Editbox or richedit and display it in a MessageBox to show you that it works. Also lets you change Edit to readonly.
Fill up a ComboBox or a ListBox with Items and when you click on an Item, it shows you how to retrieve it and puts it in a MessageBox just to show you that it works.
Shows you which Radiobutton and checkboxes are selected When you click on the OK Button to exit the Sample. You would want to add the OK button last.
Shows you how to change RadioButtons and Checkboxes to pushbuttons or flat pushbuttons.
Shows you how to make regular buttons into Flat PushButtons or add bitmaps or change fonts.
Shows you four different ways to fill up a ListView.
Lets you add a full working menu to your window. If you entered Exit, Save or Open for menu selections, it will add the supporting dialogs to your code. To make the Menu full working, it shows your selection in a MessageBox.
Writes code for displaying Etched lines on your window using the static control.
Shows you how to put Rectangles, Round Rectangles and ovals, all with hatch lines that you can recolor. Rectangles can be used to recolor the Parent at any color, you would also need to click one PS_Null in Pen styles.
Shows you how to put Bitmaps in Static Control and Buttons. You can either stretch the bitmap to fit the controls or resize the controls to fit the Bitmap.
Lets you change styles, colors, fonts and you get a full working examples for each one of these things also.
Gives you a working Progress Bar.
Gives you a working Horizontal and Vertical track bars.
Does messageboxes, where you can type in the text for Caption and Message, choose the Icon, select the styles and the Buttons. Its output is also generated to the windows clipboard for pasting.
If you need to learn how to Program in the Window's API, If you click on one control and then click on CodeView, It will display it in Either Jfishpro, Fbide, or Notepad, that is if they are located in the FBC directory. The code displayed will be a full working sample which would be easier to follow then if You were to put several controls on the window. After you go back to the form and add another control, you can click on CodeView again and see what it looks like with two controls added. If you want to see what a parent looks like by itself, don't add any controls.
If you want to see what it looks like in GUI everytime you add a Control, click on Preview. You would need to exit the GUI before going back to the Form.
If you want a designer/project maker, don't use EzeeGUI.
If you want to see a Full Working Sample and you can't find it in the Samples folder, you might try EzeeGUI.
Later, Jerry Fielden
Console based GUI/SDK Window Maker
-
- Posts: 165
- Joined: May 27, 2005 14:14
- Location: Marshall, Oklahoma, USA
- Contact:
-
- Posts: 165
- Joined: May 27, 2005 14:14
- Location: Marshall, Oklahoma, USA
- Contact:
A version 1.8 is available.
Since some wants to continue creating an example at a later time, I added the ability to save to a file.
This is just a sample API maker. It lets you see a working example of the code generated.
I changed out some premade buttons in the Button menu to Multimedia buttons. When you select the button, it will create the code for that button.
I added an example directory that has a few examples created by EzeeGUI. You can load one of these examples at program startup. You can view it by clicking on PreView. You can view the code by Clicking on CodeView.
I made better Style menus. After you click on your styles, click on OK to finish. Also included is a definition of what the style does is displayed in a message box when you Right click on the Style name.
Remember that this is just for making a working example to look at, its not to develope with. If you want to develope, try RADASM. Besides, my Generated API examples might not be totally correct.
There is a html Manual and a html tutorial that are seperate downloads. Both of them are quite large, they have a lot of screen and partial screen shots included.
http://www.freewebs.com/fielden/
Since some wants to continue creating an example at a later time, I added the ability to save to a file.
This is just a sample API maker. It lets you see a working example of the code generated.
I changed out some premade buttons in the Button menu to Multimedia buttons. When you select the button, it will create the code for that button.
I added an example directory that has a few examples created by EzeeGUI. You can load one of these examples at program startup. You can view it by clicking on PreView. You can view the code by Clicking on CodeView.
I made better Style menus. After you click on your styles, click on OK to finish. Also included is a definition of what the style does is displayed in a message box when you Right click on the Style name.
Remember that this is just for making a working example to look at, its not to develope with. If you want to develope, try RADASM. Besides, my Generated API examples might not be totally correct.
There is a html Manual and a html tutorial that are seperate downloads. Both of them are quite large, they have a lot of screen and partial screen shots included.
http://www.freewebs.com/fielden/
-
- Posts: 165
- Joined: May 27, 2005 14:14
- Location: Marshall, Oklahoma, USA
- Contact:
I added a few more things to it. Some useless stuff, like:
Polygon shaped windows pattern after Victor's example,
Star shaped windows using odd numbers for points,
Transparent windows,
Oval/circle windows,
Rounded Rectangles,
and Rotated text painted on your window.
I think most of them require win2000 and above, but I'm not sure about rotated text.
I may never use any of it, but I don't know, someday I may want to shell to a star or a stop sign with a timer in it.
http://www.freewebs.com/fielden/
Polygon shaped windows pattern after Victor's example,
Star shaped windows using odd numbers for points,
Transparent windows,
Oval/circle windows,
Rounded Rectangles,
and Rotated text painted on your window.
I think most of them require win2000 and above, but I'm not sure about rotated text.
I may never use any of it, but I don't know, someday I may want to shell to a star or a stop sign with a timer in it.
http://www.freewebs.com/fielden/
Re: Console based GUI/SDK Window Maker
This is a little bit of code that I've put together over the last few days.
Very basic, using some routines from the FreeBasic documentation.
Very basic, using some routines from the FreeBasic documentation.
Code: Select all
'
' console GUI
'
' Console based controls .
'
' sciwiseg@gmail.com
' 2022
'
' Mouse routines .
'
'
' Example 2: type-union-type structure
'
Type mouse
As Integer res
As Integer x, y, wheel, clip
Union
buttons As Integer
Type
Left:1 As Integer
Right:1 As Integer
middle:1 As Integer
End Type
End Union
End Type
'
' ----------------------------------------------------------------------
'
declare function selector(m as mouse, bt_area() as integer) as integer
declare sub button1(x1 as single,y1 as single,w as single,h as single,dg as single)
declare sub txt2but(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer)
declare sub routine_choice(sdx as integer)
declare sub F0()
declare sub F1()
'
' ----------------------------------------------------------------------
'
screen 19
window (-1.1,-1.2)-(1.1,1.1)
line (-1.1,-1.2)-(1.1,1.1),10,b
line (-1,-1)-(1,1),11,b
'
dim as single x1,y1,x2,y2,w,h,dg
'
dim as integer tx,ty,idx
redim as integer bt_area(0 to 1,0 to 3)
dim as integer sdx,ubx,crv
'redim as integer bt_area(0 to 1,0 to 3)
Dim As mouse m
dim as integer xp1,xp2,yp1,yp2
'
idx=0
tx=7
ty=36
txt2but(tx ,ty ," one",bt_area() ,idx )
'
locate 12,12
print bt_area(idx,0);" ";
print bt_area(idx,1);
locate 14,12
print bt_area(idx,2);" ";
print bt_area(idx,3)
idx=1
tx=89
ty=36
txt2but(tx ,ty ," two",bt_area() ,idx )
'
locate 12,78
print bt_area(idx,0);" ";
print bt_area(idx,1);
locate 14,78
print bt_area(idx,2);" ";
print bt_area(idx,3);
'
' ......................................................................
'
crv=0
Do
m.res = GetMouse( m.x, m.y, m.wheel, m.buttons, m.clip )
/'
locate 4,4
Print Using "res = #"; m.res;
locate 5,4
Print Using "x = ###; y = ###; wheel = +###; clip = ##"; m.x; m.y; m.wheel; m.clip;
'Print Using "buttons = ##; left = #; middle = #; right = #"; m.buttons; m.left; m.middle; m.right
'/
sdx = 10000
sdx=selector(m, bt_area())
' call a dedicated sub to selectively call other routines
if sdx < 10000 then
beep
locate 24,12
crv = (crv+1) mod 6
color crv+10,0
print " selected ";
' Other, main, code to go here, sdx determines what is called .
routine_choice(sdx)
Sleep 30, 1 ' 80ms , 1 Can't be interupted by key press, also less mouse button bounce problems.
'sdx=10000
end if
'
Loop While Inkey = ""
'
' ----------------------------------------------------------------------
'
sleep
end
'
' ======================================================================
'
sub button1(x1 as single,y1 as single,w as single,h as single,dg as single)
'
'
' General rectangular button .
'
'
static as single x2,y2,x3,y3,xyr
'
x2 = x1 + w
y2 = y1 + h
xyr = h/w
'
line (x1-dg,y1-dg)-(x2+dg,y2+dg),15,b
line (x1-dg,y1-dg)-(x2+dg,y2+dg),15
line (x2+dg,y1-dg)-(x1-dg,y2+dg),15
'
x3=x1+(x2-x1)*0.5
y3=y1+(y2-y1)*0.6
paint(x3,y3),2,15
y3=y1+(y2-y1)*0.4
paint(x3,y3),1,15
y3=y1+(y2-y1)*0.5
x3=x1+(x2-x1)*0.4
paint(x3,y3),2,15
x3=x1+(x2-x1)*0.6
paint(x3,y3),1,15
'
y3=dg*h/w
y3=int(y3*100-1)/100
'
' slope = (y2-y1)/(x2-x1) = (y1+h-y1)/(x1+w-x1) = h/w
' offset = y1, therefore y = y1 + (x-x1)*h/w
' for x = x1 + dg, y = y1 + dg*h/w
'
line (x1,y1-y3)-(x2,y2+y3),8,bf
line (x1,y1-y3)-(x2,y2+y3),15,b
' print dg*h/w
'
'
end sub
'
' ----------------------------------------------------------------------
'
sub txt2but(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer)
'
' text location sets button coordinates.
'
'locate ty,tx
'print txt;
static as integer rows, cols,wd
wd = Width
rows= HiWord(wd)
cols= LoWord(wd)
static sw As Integer, sh As Integer
static depth As Integer
static driver_name As String
static as integer x,y
static as single x1,y1,h,w,dg,x2,y2
static as integer xp1,xp2,yp1,yp2
'
ScreenInfo sw, sh, depth,,,,driver_name
x = int((tx-1)*(sw/cols))
x1 = pmap(x,2)
y = int(ty*(sh/rows))
y1 = pmap(y,3)
' .....................................
w=0.150
h=0.09
dg=0.02
x1=x1-w*0.25
dg=w/6
x1=x1+dg
y1=y1+dg*0.5
' ......................................
x2 = x1 + w
y2 = y1 + h
'locate 12,12
'print y1;" ";y2;
' return to indexed array, x1,y1,x2,y2; button area upon window.
' xp1=pmap(x1,0) , xp2=pmap(x2,0)
' yp1=pmap(y1,1) , yp2=pmap(y2,1)
' or xp1,yp1,xp2,yp2; button area upon view screen; more sensible .
'
xp1=pmap(x1,0)
xp2=pmap(x2,0)
yp1=pmap(y1,1)
yp2=pmap(y2,1)
'
bt_area(idx,0)=xp1
bt_area(idx,1)=xp2
bt_area(idx,2)=yp2 ' swapped, for some weird reason; maybe because screen y [n-->0]
bt_area(idx,3)=yp1 '
'
' ................................
'
button1(x1 ,y1 ,w ,h ,dg )
locate ty,tx
color 15,8 ' text,bg
print txt;
'
'
end sub
'
' ----------------------------------------------------------------------
'
/'
screen 19 default colours
0 black
1 blue
2 green
3 cyan
4 red
5 magenta
6 brown
7 white
8 gray
9 bright blue , light purple
10 bright green
11 bright cyan
12 bright red
13 pink
14 yellow
15 bright white
'/
function selector(m as mouse, bt_area() as integer) as integer
'
' Check various regions of the screen .
'
'
static as integer xp1,yp1,xp2,yp2,idx,ubx
'
ubx=ubound(bt_area)
for idx=0 to ubx
xp1=bt_area(idx,0)
xp2=bt_area(idx,1)
yp1=bt_area(idx,2)
yp2=bt_area(idx,3)
if ((m.x>xp1) and (m.x<xp2) and (m.y>yp1) and (m.y<yp2)) and (m.buttons=1) then return idx
next idx
'
return 10000
'
end function
'
' ----------------------------------------------------------------------
'
sub routine_choice(sdx as integer)
'
' Select and call a particular routine .
'
select case sdx
case 0:
F0()
case 1:
F1()
case else
end select
'
end sub
'
' ----------------------------------------------------------------------
'
sub F0()
locate 12,22
print " F0 ";
end sub
'
' ----------------------------------------------------------------------
'
sub F1()
locate 12,73
print " F1 ";
end sub
'
' ----------------------------------------------------------------------
'
Re: Console based GUI/SDK Window Maker
Put this together today , there were a few free moments.
Another widget, a progress bar, to activate press the F0 button.
Another widget, a progress bar, to activate press the F0 button.
Code: Select all
'
' console GUI
'
' Console based controls .
'
' sciwiseg@gmail.com
' 2023
'
' Mouse routines . Click twice to close window
'
'
' Example 2: type-union-type structure
'
Type mouse
As Integer res
As Integer x, y, wheel, clip
Union
buttons As Integer
Type
Left:1 As Integer
Right:1 As Integer
middle:1 As Integer
End Type
End Union
End Type
'
' ----------------------------------------------------------------------
'
declare function selector(m as mouse, bt_area() as integer) as integer
declare sub button1(x1 as single,y1 as single,w as single,h as single,dg as single)
declare sub txt2but(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer)
declare sub Progress1(x1 as single,y1 as single,w as single,h as single,dg as single,rp as single)
declare sub txt2prog(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer,rp as single)
declare sub routine_choice(bt_area() as integer,sdx as integer)
declare sub F0(bt_area() as integer)
declare sub F1()
declare sub store()
'
' ----------------------------------------------------------------------
'
screen 19
window (-1.1,-1.2)-(1.1,1.1)
line (-1.1,-1.2)-(1.1,1.1),10,b
line (-1,-1)-(1,1),11,b
'
dim as single x1,y1,x2,y2,w,h,dg
'
dim as integer tx,ty,idx
redim as integer bt_area(0 to 1,0 to 7)
dim as integer sdx,ubx,crv
'redim as integer bt_area(0 to 1,0 to 3)
Dim As mouse m
dim as single xp1,xp2,yp1,yp2,edx,edy,xa,xb, rp
dim as string txt
'
'
idx=0
tx=7
ty=36
txt2but(tx ,ty ," F0",bt_area() ,idx )
'
locate 12,12
print bt_area(idx,0);" ";
print bt_area(idx,1);
locate 14,12
print bt_area(idx,2);" ";
print bt_area(idx,3)
idx=1
tx=89
ty=36
txt2but(tx ,ty ," F1",bt_area() ,idx )
'
locate 12,78
print bt_area(idx,0);" ";
print bt_area(idx,1);
locate 14,78
print bt_area(idx,2);" ";
print bt_area(idx,3);
'
' ......................................................................
'
crv=0
Do
m.res = GetMouse( m.x, m.y, m.wheel, m.buttons, m.clip )
/'
locate 4,4
Print Using "res = #"; m.res;
locate 5,4
Print Using "x = ###; y = ###; wheel = +###; clip = ##"; m.x; m.y; m.wheel; m.clip;
'Print Using "buttons = ##; left = #; middle = #; right = #"; m.buttons; m.left; m.middle; m.right
'/
sdx = 10000
sdx=selector(m, bt_area())
' call a dedicated sub to selectively call other routines
if sdx < 10000 then
beep
locate 4,12
crv = (crv+1) mod 6
color crv+10,0
print " selected ";
' Other, main, code to go here, sdx determines what is called .
routine_choice(bt_area() ,sdx)
Sleep 30, 1 ' 80ms , 1 Can't be interupted by key press, also less mouse button bounce problems.
'sdx=10000
end if
'
Loop While Inkey = ""
'
' ----------------------------------------------------------------------
'
sleep
end
'
' ======================================================================
'
sub Progress1(x1 as single,y1 as single,w as single,h as single,dg as single,rp as single)
'
'
' General progress indicator .
' rp , progress [0,100]
'
static as single x2,y2,x3,y3,xyr,xa
'
x2 = x1 + w
y2 = y1 + h
xyr = h/w
xa = x1 + (x2-x1)*rp/100
'
line (x1-dg,y1-dg)-(x2+dg,y2+dg),11,bf
line (x1,y1)-(x2,y2),8,bf
line (x1 , y1)-(xa , y2),1,bf
end sub
'
' ----------------------------------------------------------------------
'
sub txt2prog(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer,rp as single)
'
' text location sets progress bar coordinates.
'
static as integer rows, cols,wd
wd = Width
rows= HiWord(wd)
cols= LoWord(wd)
static sw As Integer, sh As Integer
static depth As Integer
static driver_name As String
static as integer x,y
static as single x1,y1,h,w,dg,x2,y2
static as integer xp1,xp2,yp1,yp2
'
ScreenInfo sw, sh, depth,,,,driver_name
x = int((tx-1)*(sw/cols))
x1 = pmap(x,2)
y = int(ty*(sh/rows))
y1 = pmap(y,3)
' .....................................
dg=0.01
w=0.4
h=0.085+0.025
h=0.09
x1=x1-w*0.4
y1=y1 +0.01'-h*0.05
' ......................................
x2 = x1 + w
y2 = y1 + h
'
xp1=pmap(x1,0)
xp2=pmap(x2,0)
yp1=pmap(y1,1)
yp2=pmap(y2,1)
'
bt_area(idx,0)=xp1
bt_area(idx,1)=xp2
bt_area(idx,2)=yp2 ' swapped, for some weird reason; maybe because screen y [n-->0]
bt_area(idx,3)=yp1 '
'
' ................................
'
Progress1(x1 ,y1 ,w ,h ,dg, rp )
locate ty,tx
if rp<50 then
color 15,8 ' text,bg
else
color 15,1 ' text,bg
end if
print txt;
'
'
end sub
'
' ----------------------------------------------------------------------
'
sub button1(x1 as single,y1 as single,w as single,h as single,dg as single)
'
'
' General rectangular button .
'
'
static as single x2,y2,x3,y3,xyr
'
x2 = x1 + w
y2 = y1 + h
xyr = h/w
'
line (x1-dg,y1-dg)-(x2+dg,y2+dg),15,b
line (x1-dg,y1-dg)-(x2+dg,y2+dg),15
line (x2+dg,y1-dg)-(x1-dg,y2+dg),15
'
x3=x1+(x2-x1)*0.5
y3=y1+(y2-y1)*0.6
paint(x3,y3),2,15
y3=y1+(y2-y1)*0.4
paint(x3,y3),1,15
y3=y1+(y2-y1)*0.5
x3=x1+(x2-x1)*0.4
paint(x3,y3),2,15
x3=x1+(x2-x1)*0.6
paint(x3,y3),1,15
'
y3=dg*h/w
y3=int(y3*100-1)/100
'
' slope = (y2-y1)/(x2-x1) = (y1+h-y1)/(x1+w-x1) = h/w
' offset = y1, therefore y = y1 + (x-x1)*h/w
' for x = x1 + dg, y = y1 + dg*h/w
'
line (x1,y1-y3)-(x2,y2+y3),8,bf
line (x1,y1-y3)-(x2,y2+y3),15,b
'
'
end sub
'
' ----------------------------------------------------------------------
'
sub txt2but(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer)
'
' text location sets button coordinates.
'
static as integer rows, cols,wd
wd = Width
rows= HiWord(wd)
cols= LoWord(wd)
static sw As Integer, sh As Integer
static depth As Integer
static driver_name As String
static as integer x,y
static as single x1,y1,h,w,dg,x2,y2
static as integer xp1,xp2,yp1,yp2
'
ScreenInfo sw, sh, depth,,,,driver_name
x = int((tx-1)*(sw/cols))
x1 = pmap(x,2)
y = int(ty*(sh/rows))
y1 = pmap(y,3)
' .....................................
w=0.150
h=0.09
dg=0.02
x1=x1-w*0.25
dg=w/6
x1=x1+dg
y1=y1+dg*0.5
' ......................................
x2 = x1 + w
y2 = y1 + h
'
xp1=pmap(x1,0)
xp2=pmap(x2,0)
yp1=pmap(y1,1)
yp2=pmap(y2,1)
'
bt_area(idx,0)=xp1
bt_area(idx,1)=xp2
bt_area(idx,2)=yp2 ' swapped, for some weird reason; maybe because screen y [n-->0]
bt_area(idx,3)=yp1 '
'
' ................................
'
button1(x1 ,y1 ,w ,h ,dg )
locate ty,tx
color 15,8 ' text,bg
print txt;
'
'
end sub
'
' ----------------------------------------------------------------------
'
/'
screen 19 default colours
0 black
1 blue
2 green
3 cyan
4 red
5 magenta
6 brown
7 white
8 gray
9 bright blue , light purple
10 bright green
11 bright cyan
12 bright red
13 pink
14 yellow
15 bright white
'/
function selector(m as mouse, bt_area() as integer) as integer
'
' Check various regions of the screen .
'
'
static as integer xp1,yp1,xp2,yp2,idx,ubx
'
ubx=ubound(bt_area)
for idx=0 to ubx
xp1=bt_area(idx,0)
xp2=bt_area(idx,1)
yp1=bt_area(idx,2)
yp2=bt_area(idx,3)
if ((m.x>xp1) and (m.x<xp2) and (m.y>yp1) and (m.y<yp2)) and (m.buttons=1) then return idx
next idx
'
return 10000
'
end function
'
' ----------------------------------------------------------------------
'
sub routine_choice(bt_area() as integer,sdx as integer)
'
' Select and call a particular routine .
'
select case sdx
case 0:
F0(bt_area())
case 1:
F1()
case else
end select
'
end sub
'
' ----------------------------------------------------------------------
'
sub F0(bt_area() as integer)
'
static as integer idx,tx,ty
static as single rp
static as string txt
'
locate 12,22
print " F0 ";
line(-0.9,-0.8)-(-0.1,0.2),1,bf
idx=4
tx=37
ty=36
for rp=0 to 100
txt=str(rp)+"%"
txt2prog(tx ,ty ,txt,bt_area() ,idx ,rp)
sleep(260)
next rp
end sub
'
' ----------------------------------------------------------------------
'
sub F1()
locate 12,73
print " F1 ";
line(0.1,-0.8)-(0.9,0.2),4,bf
end sub
'
' ----------------------------------------------------------------------
'
' https://www.freebasic.net/forum/viewtopic.php?p=295914&hilit=console+gui#p295914
sub store()
/'
xp1=0
yp1=-0.025
xp2=0.4
yp2=0.085
edx=0.01
edy=0.01
xa=xp1+(xp2-xp1)*0.5
'xb=xp2-edx
line (xp1,yp1)-(xp2,yp2),11,bf
'line (0,0)-(0.4,0.1),11,bf
'line (0.01,0.01)-(0.39,0.09),1,bf
'lie (xp1 , 0.01)-(xa , 0.09),1,bf
lin (xp1+edx , yp1+edy)-(xp2-edx , yp2-edy),8,bf
line (xp1+edx , yp1+edy)-(xa ,yp2-edy ),1,bf
color 15,8
locate 18,58
print "100%";
'line (0,0)-(0.4,0.1),8,b
line (xp1,yp1)-(xp2,yp2),11,b
'/
end sub
Re: Console based GUI/SDK Window Maker
A very slight update.
Wondering about the use of a timer, to check for button presses.
Wondering about the use of a timer, to check for button presses.
Code: Select all
'
' console GUI
'
' Console based controls .
'
' sciwiseg@gmail.com
'
'
' (c) copyright 2023 LGPL
'
' Mouse routines . Click twice to close window
'
'
' Example 2: type-union-type structure
'
Type mouse
As Integer res
As Integer x, y, wheel, clip
Union
buttons As Integer
Type
Left:1 As Integer
Right:1 As Integer
middle:1 As Integer
End Type
End Union
End Type
'
' ----------------------------------------------------------------------
'
declare function selector(m as mouse, bt_area() as integer) as integer
declare sub button1(x1 as single,y1 as single,w as single,h as single,dg as single)
declare sub txt2but(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer)
declare sub Progress1(x1 as single,y1 as single,w as single,h as single,dg as single,rp as single)
declare sub txt2prog(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer,rp as single)
declare sub routine_choice(bt_area() as integer,sdx as integer)
declare sub F0(bt_area() as integer)
declare sub F1()
declare sub store()
'
' ----------------------------------------------------------------------
'
screen 19
window (-1.1,-1.2)-(1.1,1.1)
line (-1.1,-1.2)-(1.1,1.1),10,b
line (-1,-1)-(1,1),11,b
'
const pi=4*atn(1)
dim as single x1,y1,x2,y2,w,h,dg
'
dim as integer tx,ty,idx
redim as integer bt_area(0 to 1,0 to 7)
dim as integer sdx,ubx,crv
'redim as integer bt_area(0 to 1,0 to 3)
Dim As mouse m
dim as single xp1,xp2,yp1,yp2,edx,edy,xa,xb, rp
dim as string txt
'
'
idx=0
tx=7
ty=36
txt2but(tx ,ty ," F0",bt_area() ,idx )
'
locate 12,12
print bt_area(idx,0);" ";
print bt_area(idx,1);
locate 14,12
print bt_area(idx,2);" ";
print bt_area(idx,3)
idx=1
tx=89
ty=36
txt2but(tx ,ty ," F1",bt_area() ,idx )
'
locate 12,78
print bt_area(idx,0);" ";
print bt_area(idx,1);
locate 14,78
print bt_area(idx,2);" ";
print bt_area(idx,3);
'
' ......................................................................
'
crv=0
Do
m.res = GetMouse( m.x, m.y, m.wheel, m.buttons, m.clip )
/'
locate 4,4
Print Using "res = #"; m.res;
locate 5,4
Print Using "x = ###; y = ###; wheel = +###; clip = ##"; m.x; m.y; m.wheel; m.clip;
'Print Using "buttons = ##; left = #; middle = #; right = #"; m.buttons; m.left; m.middle; m.right
'/
sdx = 10000
sdx=selector(m, bt_area())
' call a dedicated sub to selectively call other routines
if sdx < 10000 then
beep
locate 4,12
crv = (crv+1) mod 6
color crv+10,0
print " selected ";
' Other, main, code to go here, sdx determines what is called .
routine_choice(bt_area() ,sdx)
Sleep 30, 1 ' 80ms , 1 Can't be interupted by key press, also less mouse button bounce problems.
'sdx=10000
end if
'
Loop While Inkey = ""
'
' ----------------------------------------------------------------------
'
sleep
end
'
' ======================================================================
'
sub Progress1(x1 as single,y1 as single,w as single,h as single,dg as single,rp as single)
'
'
' General progress indicator .
' rp , progress [0,100]
'
static as single x2,y2,x3,y3,xyr,xa
'
x2 = x1 + w
y2 = y1 + h
xyr = h/w
xa = x1 + (x2-x1)*rp/100
'
line (x1-dg,y1-dg)-(x2+dg,y2+dg),11,bf
line (x1,y1)-(x2,y2),8,bf
line (x1 , y1)-(xa , y2),1,bf
end sub
'
' ----------------------------------------------------------------------
'
sub txt2prog(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer,rp as single)
'
' text location sets progress bar coordinates.
'
static as integer rows, cols,wd
wd = Width
rows= HiWord(wd)
cols= LoWord(wd)
static sw As Integer, sh As Integer
static depth As Integer
static driver_name As String
static as integer x,y
static as single x1,y1,h,w,dg,x2,y2
static as integer xp1,xp2,yp1,yp2
'
ScreenInfo sw, sh, depth,,,,driver_name
x = int((tx-1)*(sw/cols))
x1 = pmap(x,2)
y = int(ty*(sh/rows))
y1 = pmap(y,3)
' .....................................
dg=0.01
w=0.4
h=0.085+0.025
h=0.09
x1=x1-w*0.4
y1=y1 +0.01'-h*0.05
' ......................................
x2 = x1 + w
y2 = y1 + h
'
xp1=pmap(x1,0)
xp2=pmap(x2,0)
yp1=pmap(y1,1)
yp2=pmap(y2,1)
'
bt_area(idx,0)=xp1
bt_area(idx,1)=xp2
bt_area(idx,2)=yp2 ' swapped, for some weird reason; maybe because screen y [n-->0]
bt_area(idx,3)=yp1 '
'
' ................................
'
Progress1(x1 ,y1 ,w ,h ,dg, rp )
locate ty,tx
if rp<50 then
color 15,8 ' text,bg
else
color 15,1 ' text,bg
end if
print txt;
'
'
end sub
'
' ----------------------------------------------------------------------
'
sub button1(x1 as single,y1 as single,w as single,h as single,dg as single)
'
'
' General rectangular button .
'
'
static as single x2,y2,x3,y3,xyr
'
x2 = x1 + w
y2 = y1 + h
xyr = h/w
'
line (x1-dg,y1-dg)-(x2+dg,y2+dg),15,b
line (x1-dg,y1-dg)-(x2+dg,y2+dg),15
line (x2+dg,y1-dg)-(x1-dg,y2+dg),15
'
x3=x1+(x2-x1)*0.5
y3=y1+(y2-y1)*0.6
paint(x3,y3),2,15
y3=y1+(y2-y1)*0.4
paint(x3,y3),1,15
y3=y1+(y2-y1)*0.5
x3=x1+(x2-x1)*0.4
paint(x3,y3),2,15
x3=x1+(x2-x1)*0.6
paint(x3,y3),1,15
'
y3=dg*h/w
y3=int(y3*100-1)/100
'
' slope = (y2-y1)/(x2-x1) = (y1+h-y1)/(x1+w-x1) = h/w
' offset = y1, therefore y = y1 + (x-x1)*h/w
' for x = x1 + dg, y = y1 + dg*h/w
'
line (x1,y1-y3)-(x2,y2+y3),8,bf
line (x1,y1-y3)-(x2,y2+y3),15,b
'
'
end sub
'
' ----------------------------------------------------------------------
'
sub txt2but(tx as integer,ty as integer,txt as string,bt_area() as integer,idx as integer)
'
' text location sets button coordinates.
'
static as integer rows, cols,wd
wd = Width
rows= HiWord(wd)
cols= LoWord(wd)
static sw As Integer, sh As Integer
static depth As Integer
static driver_name As String
static as integer x,y
static as single x1,y1,h,w,dg,x2,y2
static as integer xp1,xp2,yp1,yp2
'
ScreenInfo sw, sh, depth,,,,driver_name
x = int((tx-1)*(sw/cols))
x1 = pmap(x,2)
y = int(ty*(sh/rows))
y1 = pmap(y,3)
' .....................................
w=0.150
h=0.09
dg=0.02
x1=x1-w*0.25
dg=w/6
x1=x1+dg
y1=y1+dg*0.5
' ......................................
x2 = x1 + w
y2 = y1 + h
'
xp1=pmap(x1,0)
xp2=pmap(x2,0)
yp1=pmap(y1,1)
yp2=pmap(y2,1)
'
bt_area(idx,0)=xp1
bt_area(idx,1)=xp2
bt_area(idx,2)=yp2 ' swapped, for some weird reason; maybe because screen y [n-->0]
bt_area(idx,3)=yp1 '
'
' ................................
'
button1(x1 ,y1 ,w ,h ,dg )
locate ty,tx
color 15,8 ' text,bg
print txt;
'
'
end sub
'
' ----------------------------------------------------------------------
'
/'
screen 19 default colours
0 black
1 blue
2 green
3 cyan
4 red
5 magenta
6 brown
7 white
8 gray
9 bright blue , light purple
10 bright green
11 bright cyan
12 bright red
13 pink
14 yellow
15 bright white
'/
function selector(m as mouse, bt_area() as integer) as integer
'
' Check various regions of the screen .
'
'
static as integer xp1,yp1,xp2,yp2,idx,ubx
'
ubx=ubound(bt_area)
for idx=0 to ubx
xp1=bt_area(idx,0)
xp2=bt_area(idx,1)
yp1=bt_area(idx,2)
yp2=bt_area(idx,3)
if ((m.x>xp1) and (m.x<xp2) and (m.y>yp1) and (m.y<yp2)) and (m.buttons=1) then return idx
next idx
'
return 10000
'
end function
'
' ----------------------------------------------------------------------
'
sub routine_choice(bt_area() as integer,sdx as integer)
'
' Select and call a particular routine .
'
select case sdx
case 0:
F0(bt_area())
case 1:
F1()
case else
end select
'
end sub
'
' ----------------------------------------------------------------------
'
sub F0(bt_area() as integer)
'
static as integer idx,tx,ty
static as single rp
static as string txt
'
locate 12,22
print " F0 ";
line(-0.9,-0.8)-(-0.1,0.2),1,bf
idx=4
tx=37
ty=36
for rp=0 to 100
txt=str(rp)+"%"
txt2prog(tx ,ty ,txt,bt_area() ,idx ,rp)
sleep(260)
next rp
end sub
'
' ----------------------------------------------------------------------
'
sub F1()
static as single x,x1,y,y1
locate 12,73
print " F1 ";
line(0.1,-0.8)-(0.9,0.2),4,bf
' line(0.1,-0.8)-(0.9,0.2),14
x1=0
y1=sin(x1*2*pi)
for x=0 to 1 step 0.01
y=sin(x*2*pi)
line(0.1 +(0.9-0.1)*x,-0.8+(0.2--0.8)*(y+1)*0.5)-(0.1 +(0.9-0.1)*x1,-0.8+(0.2--0.8)*(y1+1)*0.5),14
x1=x
y1=y
next x
end sub
'
' ----------------------------------------------------------------------
'
' https://www.freebasic.net/forum/viewtopic.php?p=295914&hilit=console+gui#p295914
sub store()
/'
xp1=0
yp1=-0.025
xp2=0.4
yp2=0.085
edx=0.01
edy=0.01
xa=xp1+(xp2-xp1)*0.5
'xb=xp2-edx
line (xp1,yp1)-(xp2,yp2),11,bf
'line (0,0)-(0.4,0.1),11,bf
'line (0.01,0.01)-(0.39,0.09),1,bf
'line (xp1 , 0.01)-(xa , 0.09),1,bf
line (xp1+edx , yp1+edy)-(xp2-edx , yp2-edy),8,bf
line (xp1+edx , yp1+edy)-(xa ,yp2-edy ),1,bf
color 15,8
locate 18,58
print "100%";
'line (0,0)-(0.4,0.1),8,b
line (xp1,yp1)-(xp2,yp2),11,b
'/
end sub