gui_chung for windows gui

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
chung
Posts: 648
Joined: Jan 16, 2010 20:52
Location: France
Contact:

gui_chung for windows gui

Post by chung »

gui_chung is a gui_chung.bi file to add to your windows freebasic programs .
it is a text like interface to create and handle Windows hwnd .
Is inspired from "liberty basic" syntax and is even more powerfull and more simple to use.
I use it in all my freebasic gui programs.
includes an openGL windows creation , textures loading and drawtext features.

you can find it there => http://chungswebsite.blogspot.fr/search/label/gui_chung

Image
RNBW
Posts: 267
Joined: Apr 11, 2015 11:06
Location: UK

Re: gui_chung for windows gui

Post by RNBW »

@chung
A very interesting library.

To those unfamiliar with Liberty Basic (LB), it is probably the easiest way to write GUI programs. Its downside is that it is only an interpreter and it does have some long-standing bugs, most of which have write-arounds. Richard Russell (who wrote BBC Basic for Windows) has written LBB which eliminates the bugs and is largely compatible with LB. It converts the programs into BBC Basic and allows compact standalone .EXE programs to be written. Personally, I rarely use LB and write programs in LBB.

So, I am very interested to see how your library works in FreeBasic (FB). I downloaded the library and tried out the one example provided, which was very basic, but worked well.

I think that to get people interested, you will need to provide a few more examples. Lothar Schirm has provided some very useful examples in his Simple GUI. Perhaps similar examples could be provided.

I look forward to seeing how the library progresses.
chung
Posts: 648
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Re: gui_chung for windows gui

Post by chung »

here you can find yet for now examples of use of gui_chung and its variants (available at chungswebsite.blogspot.com or sourceforge.net)
(+if you use fbedit , when you type a function or sub name , it displays a preview of required parameters with the current parameter highlighted)
(all source provided with fbedit fbp project file)
note : speed is not the priority for human i/o.
you can however speed up things by handling directly the windows hwnd with var winh=getguih("win.controlname")

aiml_chung
AIMLscintilla_chung
autopiano_chung
baxandall_chung
chatbot_chung
chung_edit
circuit_chung
cross_car_chung
cube_chung
face3D_chung
flightcombat_chung
flightcombat_chung_web
flightspace_chung
freetanks_chung
freewebcar_chung
glvideotexture_chung
guivideo_chung
listtext_chung
loadobj3ds_chung
minimidi_chung
morphobj3ds_chung
mydddungeonsGL
mydungeon_chung
myOCR_chung
perso3D_chung
rpg_chung
sunset_chung
the_four_orbs
TileCity_chung
xvideocapture_chung
adele
Posts: 47
Joined: Jun 13, 2015 19:33

Re: gui_chung for windows gui

Post by adele »

Hi Chung,

I like your approach to simplify GUI programming.
If you agree, I (or others) will use your code, modify and maybe in some years re-publish it :)

Question: Is there any _easy to understand_ DLL / LIB for displaying pictures with win64 that could be used instead of the "old" JPG DLL ?

Below a list of changes I did to make it compile with FBC/Win64, FYI: Win10/16299
The JPG DLL won`t work, because it is 32 Bit. But you caught the "Erreur" in your code :)
Beware: the "Erreur" message when trying to load a picture still appears, changes are is only to avoid compiler errors or warnings.

Code: Select all

---------- GUI_CHUNG_DLL.BAS
[935]	wc.lpfnWndProc=Cast(WNDPROC,@guiWndProc)  'changed
[1402]Sub getcomboindex cdecl alias "getcomboindex" (byval comboname As zstringPtr,Byval i As LongInt ptr) EXPORT 'changed uInt -> LongInt 
[1406]   If *i=CB_ERR Then *i=0 Else *i=*i+1 'CHG:TD:' CB_ERR defined as -1,-> not Unsigned !
[1423]Dim As Integer i 'changed
[1502]Dim As integer i 'changed
[1511]Sub getlistboxindex cdecl alias "getlistboxindex" (byval listboxname As zstringPtr,Byval i As integer Ptr) EXPORT 'chg:TD' 
[1525]Dim As INTEGER i 'changed
[1995]'changed
[2013]glGenTextures(1, Cast(GLuint Ptr,@itexture) )'changed
[2029]	If itexture>0 Then glDeleteTextures (1,Cast(GLuint Ptr,@itexture) ) 'changed: cast

---------- GUI_CHUNG_DLL_TEST.BAS
[5]   #define noguijpeg 'changed JPG.dll is 32 Bit only
Have a good time
Adi
chung
Posts: 648
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Re: gui_chung for windows gui

Post by chung »

(12/02/2018) i have replaced jpeg.dll by gdiplus windows hbitmap image load (bmp gif jpg ico png tif ...)

may work with freebasic 1.05-win64 now (tested with gui_chung_test.bas & testopenGL.bas )
Last edited by chung on Feb 13, 2018 1:54, edited 1 time in total.
adele
Posts: 47
Joined: Jun 13, 2015 19:33

Re: gui_chung for windows gui

Post by adele »

Hi Chung,

thank you, but :

Code: Select all

()\ld.exe: skipping incompatible ./glext.dll when searching for -lglext
()\ld.exe: skipping incompatible ./glext.dll when searching for -lglext
Make done
I couldn´t find a precompiled glext.dll for x64. Neither "here" nor "there" nor "anywhere" :)

Adi
chung
Posts: 648
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Re: gui_chung for windows gui

Post by chung »

hello ,

sorry but glext is not my library , and it seems to work only with win32

https://sourceforge.net/projects/glextwin32/
honey data
Posts: 28
Joined: Feb 11, 2018 19:54
Location: portugal lisbon
Contact:

Re: gui_chung for windows gui

Post by honey data »

Code: Select all

const true as boolean=-1
const false as boolean=0
const TitleBarSize as integer=16
const maxWin as integer=10
type windows
x as integer
y as integer
w as integer
h as integer
images As Any Ptr
index as integer
id as integer
title as string
titlebar as boolean
end type

type wwin
win(0 to maxWin) as windows
count as integer
wins(0 to maxWin) as integer
end type




sub moveToFront(w as wwin,i as integer)
dim a as integer
dim b as integer
dim c as integer
b=w.wins(i)
for a =i to w.count-2
c=w.wins(a+1)
w.wins(a)=c
next a
w.wins(w.count-1)=b

end sub



sub drawWindows(byref w as wwin)
dim a as integer
ScreenSync
  ScreenLock
for a= 0 to w.count-1
put (w.win(w.wins(a)).x,w.win(w.wins(a)).y),w.win(w.wins(a)).images,pset
next a
ScreenUnlock


end sub

sub drawClsWindow(w as wwin,i as integer)
line w.win(i).images,(0,TitleBarSize+1)-(w.win(i).w,w.win(i).h),rgb(255,255,255),bf
line w.win(i).images,(0,0)-(w.win(i).w-1,w.win(i).h-1),rgb(0,0,0),b
end sub 

sub drawTitleBar(byref w as wwin,i as integer)
line w.win(i).images,(0,0)-(w.win(i).w,TitleBarSize),rgb(0,0,255),bf
Draw String w.win(i).images,(4, 4), w.win(i).title,rgb(255,255,255)
line w.win(i).images,(0,0)-(w.win(i).w,TitleBarSize),rgb(0,0,0),b
end sub

function clickons(w as wwin,x as integer,y as integer) as integer
dim a as integer
dim b as integer
dim c as integer=-1
for a=w.count-1 to 1 step -1
if x> w.win(w.wins(a)).x and x<w.win(w.wins(a)).x+w.win(w.wins(a)).w and y>w.win(w.wins(a)).y and y<w.win(w.wins(a)).y+w.win(w.wins(a)).h then
c=a
a=0
end if
next a
return c
end function


function creatWindows(byref w as wwin,xx as integer,yy as integer, ww as integer ,hh as integer, ccolors as ulong,title as string,tbar as boolean) as integer
dim r as integer=-1
if w.count < maxwin -1 then
w.count=w.count+1
w.win(w.count-1).images=ImageCreate( ww,hh,ccolors,16 )
line w.win(w.count-1).images,(0,0)-(ww-1,hh-1),rgb(0,0,0),b
w.win(w.count-1).x=xx
w.win(w.count-1).y=yy
w.win(w.count-1).w=ww
w.win(w.count-1).h=hh
w.win(w.count-1).title=title
w.win(w.count-1).titlebar=tbar
w.wins(w.count-1)=w.count-1
if tbar then drawTitleBar w,w.count-1
line w.win(w.count-1).images,(0,0)-(ww-1,hh-1),rgb(0,0,0),b
r=w.count-1
end if
return r
end function


#include "vbcompat.bi"
Dim a As Double, b As Double
dim win as wwin
dim x as integer
dim y as integer
dim i as integer
dim w as integer
dim h as integer
dim ii as integer
dim y1 as integer
dim b1 as integer

dim bb as integer
dim x1 as integer
w=640
h=480


'' Create a graphics screen.
ScreenRes w, h, 16
 
dim s as string
s = "im love marina"
'Set the window title
WindowTitle s


win.count=0


i=creatWindows(win,0,0,w,h,rgb(0,128,255),s,false)


i=creatWindows(win,20,20,160,80,rgb(255,255,255),"month",true)
i=creatWindows(win,40,40,160,80,rgb(255,255,255),"day",true)
i=creatWindows(win,60,60,160,80,rgb(255,255,255),"year",true)
i=creatWindows(win,80,80,160,80,rgb(255,255,255),"hour",true)
i=creatWindows(win,100,100,160,80,rgb(255,255,255),"minuts",true)
i=creatWindows(win,120,120,160,80,rgb(255,255,255),"seconds",true)


do
for ii=1 to win.count-1
 drawClsWindow win,ii
next ii

a = Now
Draw String win.win(1).images,(4,TitleBarSize +8 ),str$(month(a)),rgb(0,0,255)
Draw String win.win(2).images,(4,TitleBarSize +8 ),str$(day(a)),rgb(0,0,255)
Draw String win.win(3).images,(4,TitleBarSize +8 ),str$(year(a)),rgb(0,0,255)

Draw String win.win(4).images,(4,TitleBarSize +8 ),str$(Hour(a)),rgb(0,0,255)
Draw String win.win(5).images,(4,TitleBarSize +8 ),str$(minute(a)),rgb(0,0,255)
Draw String win.win(6).images,(4,TitleBarSize +8 ),str$(second(a)),rgb(0,0,255)


drawWindows win
sleep 1
GetMouse(x1,y1,,b1)
if b1<> 0 then
b1=clickons (win,x1,y1)
if b1<> -1 then
moveToFront(win,b1)
end if
end if 
loop until inkey$<>""









cls
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: gui_chung for windows gui

Post by counting_pine »

Hi honey data, welcome to the forum.
Did you mean to post your code in this thread? It doesn't look like it makes use of gui_chung.
honey data
Posts: 28
Joined: Feb 11, 2018 19:54
Location: portugal lisbon
Contact:

Re: gui_chung for windows gui

Post by honey data »

yes , thanks this is a windows sample x,y sample for make you one gui
chung
Posts: 648
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Re: gui_chung for windows gui

Post by chung »

(28/04/2018) trapmousewheel => guimousewheel added
Post Reply