GUI library for Windows \ Linux (window9)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for windows 2

Post by VANYA »

Coolman wrote:it seems that installing gtk2 and gtk3 is a bad idea. some libraries conflict... for example the compilation of IUP_FB_EDITOR has been successful but the program does not run with an error message:

Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
I don’t know why you get this error when using IUP.
I have the libgtk2.0-dev, libgtk-3-dev packages installed at the same time and there are no errors. Please try compiling IUP_FB_EDITOR with flag -v "verbose" and copy the compiler output for me.

--------------------------
For window9, there should be no such problems, because in the window9.bi file at the very top there is a macro with which you install the GTK graphics subsystem:

for GTK2 (comment):

'#define __USE_GTK3__

for GTK3 (uncomment):

#define __USE_GTK3__

Having decided on the choice of the gtk subsystem, you must compile the library with this subsystem gtk.
Coolman
Posts: 294
Joined: Nov 05, 2010 15:09

Re: FBGUI library for windows 2

Post by Coolman »

this is the question I asked myself. what does iup have to do with gtk. to check I have uninstalled gtk2 and gtk3 and I got an error message when linking in connection with gtk-x11-2.0 and gdk-x11-2.0...

Code: Select all

FreeBASIC Compiler - Version 1.06.0 (03-06-2019), built for linux-x86_64 (64bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
target:       linux-x86_64, x86-64, 64bit
compiling:    fbnp.bas -o fbnp.c (main module)
compiling C:  gcc -m64 -march=x86-64 -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fwrapv -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -masm=intel "fbnp.c" -o "fbnp.asm"
assembling:   as --64 --strip-local-absolute "fbnp.asm" -o "fbnp.o"
linking:      ld -m elf_x86_64 -o "fbnp" -dynamic-linker /lib64/ld-linux-x86-64.so.2 "/usr/local/bin/../lib/freebasic/linux-x86_64/fbextra.x" -s -L "/usr/local/bin/../lib/freebasic/linux-x86_64" -L "." -L "/usr/lib/gcc/x86_64-linux-gnu/7" "/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crt1.o" "/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o" "/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o" "/usr/local/bin/../lib/freebasic/linux-x86_64/fbrt0.o" "fbnp.o" "-(" -liup -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangox-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -liup_scintilla -lfbmt -ltinfo -lm -ldl -lpthread -lgcc -lgcc_eh -lc "-)" "/usr/lib/gcc/x86_64-linux-gnu/7/crtend.o" "/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o" 
ld: cannot find -lgtk-x11-2.0
ld: cannot find -lgdk-x11-2.0
linking failed: 'ld' terminated with exit code 1
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for windows 2

Post by VANYA »

I requested the compiler output when you get this error:
Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported


In any case, such an error can occur only if you mix libraries intended for GTK2 with libraries intended for GTK3 in one project.
Coolman
Posts: 294
Joined: Nov 05, 2010 15:09

Re: FBGUI library for windows 2

Post by Coolman »

yes. there must be a gtk3 lib that is integrated when linking. but I don't see which one. i'll see later if i have time. i tested some examples found in the forum about win9linux. it works if it's simple. i still think fltk would be a better choice. perfectly suited to freebasic to generate light programs without dependencies with a static compilation. otherwise iup is equally excellent. but it's your job. your choice.
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

FBGUI 2 : About events

Post by enform »

Hello,

My questions are about events in the usual Do Loop in window9.bi .

With this test of EventMouseWheel , the behaviour changes before 1 click or 2 on the editor
or after the click : before we get the normal event EventMouseWheel but after ... nothing .
What happens ?

After a click on the editor , turning on the mousewheel just a bit , one step , we get
20 or 30 events ... and this is a lot if the treatment we want to do is heavy ... for ex syntax highlighting ...

Also, 1 click on the VScrollbar gives 2 events .

It is frequent that windows sends the same msg many times ... and it is 'sometimes' annnoying .

A test with PeekMessage (.... , PM_REMOVE) does nothing here , but it's surely me ....

The most part of the time or all the time ... i do not take that in count but it is not optimal .

If you have the answers , don't hesitate to comment , I'll thank you ! ;-)

The code below is a modified code from the w9.chm

Greetings

Code: Select all

#Include "window9.bi"
#Define ld __LINE__

Dim As integer event,MouseWheel,EventEditor
Dim As String buf
Var hwnd = OpenWindow ("1",10,10,500,400)
EditorGadget (1,10,10,300,300, "")
TextGadget (2,350,20,100,20, "Scroll")

For a As Integer = 1 To 500
	buf + = "String ?  " & a & Chr (10)
Next

SetGadgetText (1, buf)

'/'
Do
	event = WaitEvent ()
	If IsMouseOver(hwnd) And (event = 522 Or event = 1025) Then ' filter
	' EventMouseWheel   522 disappears after 1 or 2 clicks on the editor
		?
		? ld,"eventA",event,EventWParam,EventLParam
		? ld,"eventB",LoWord(EventWParam),HiWord(EventWParam)
		? ld,"eventC",LoWord(EventLParam),HiWord(EventLParam)
	EndIf 	
	Select Case event
		Case EventClose
			Exit Do
		Case EventMouseWheel  ' 522
			If EventKEY < 0 Then
				MouseWheel += 1
				SetGadgetText (2, Str (MouseWheel))
				? ld,"wheel down",EventMouseWheel,MouseWheel
			Else
				MouseWheel -= 1
				SetGadgetText (2, Str (MouseWheel))
				? ld,"wheel up",EventMouseWheel,MouseWheel
			EndIf	
		Case EventGadget  ' 1025  many events for a minimal movement of the mousewheel
			If EventNumber = 1 Then
				EventEditor += 1
				? ld,"editor",EventGadget,EventEditor
			ElseIf EventNumber = 2 Then
				LineScrollEditor (1,5)
				MouseWheel = 0
				EventEditor = 0
			EndIf
	End Select
Loop

VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for windows 2

Post by VANYA »

With this test of EventMouseWheel , the behaviour changes before 1 click or 2 on the editor
or after the click : before we get the normal event EventMouseWheel but after ... nothing .
What happens ?
When you click in the RICHEDIT editor (editorgadget), it captures the focus, so the EventMouseWheel messages no longer come to the main window. TextGadget does not capture focus. Try changing the textgadget to buttongadget, click on the button and you will see that the button captures the focus and the EventMouseWheel message will be processed again.
After a click on the editor , turning on the mousewheel just a bit , one step , we get
20 or 30 events ... and this is a lot if the treatment we want to do is heavy ... for ex syntax highlighting ...
Yes, exactly, there is such a nuisance, but I can’t do anything, it’s a little implementation curve RICHEDIT from microsoft. Below in the example you will see that this happens regardless of window9:

Code: Select all

#INCLUDE "windows.bi"
LoadLibrary "RICHED20.DLL"
Dim msg As MSG
Dim As WNDCLASSEX wc
Dim As String NameClass="MyClass" 
Dim As HINSTANCE Hinst=GetModuleHandle(0) 
Dim Shared As Integer iCount

Function wndproc(hwnd As HWND, msg As Uinteger,_
    wparam As WPARAM, lparam As LPARAM) As Integer
    Select Case msg
        Case WM_DESTROY
            PostQuitMessage(0)
        Case WM_CREATE
            CreateWindowEx(WS_EX_CLIENTEDGE, "RICHEDIT20A", "RichEdit Control",_
            WS_VISIBLE Or WS_CHILD Or WS_HSCROLL Or WS_VSCROLL  Or ES_MULTILINE Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL,_
            10,10,200,200, hwnd, Cast(HMENU,1), 0, 0)
       Case WM_COMMAND
          iCount+=1
          ? iCount
    End Select
    Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function

With wc
    .cbSize=SizeOf(WNDCLASSEX)
    .style=CS_HREDRAW Or CS_VREDRAW
    .lpfnWndProc=@wndproc
    .hInstance=Hinst
    .hIcon=LoadIcon(0,IDI_WINLOGO)
    .hCursor=LoadCursor(0,IDC_ARROW)
    .hbrBackground=Cast(HBRUSH,COLOR_WINDOWFRAME)
    .lpszClassName=StrPtr(NameClass)
    .hIconSm=.hIcon
End With

If RegisterClassEx(@wc)=0 Then
    Print "Register error, press any key"
    Sleep
    End
Endif

CreateWindowEx(0,NameClass,"RichEdit",_
WS_VISIBLE Or WS_OVERLAPPEDWINDOW,100,100,240,260,0,0,Hinst,0)

While GetMessage(@msg,0,0,0)
    TranslateMessage(@msg)
    DispatchMessage(@msg)
Wend
And now we change the class of the editor with "RICHEDIT20A" on the "EDIT". As you can see, there is already no such problem, but "EDIT" does not have extended functionality like "RICHEDIT20A"

Code: Select all

#INCLUDE "windows.bi"
Dim msg As MSG
Dim As WNDCLASSEX wc
Dim As String NameClass="MyClass" 
Dim As HINSTANCE Hinst=GetModuleHandle(0) 
Dim Shared As Integer iCount

Function wndproc(hwnd As HWND, msg As Uinteger,_
    wparam As WPARAM, lparam As LPARAM) As Integer
    Select Case msg
        Case WM_DESTROY
            PostQuitMessage(0)
        Case WM_CREATE
            CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "Edit Control",_
            WS_VISIBLE Or WS_CHILD Or WS_HSCROLL Or WS_VSCROLL  Or ES_MULTILINE Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL,_
            10,10,200,200, hwnd, Cast(HMENU,1), 0, 0)
       Case WM_COMMAND
          iCount+=1
          ? iCount
    End Select
    Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function

With wc
    .cbSize=SizeOf(WNDCLASSEX)
    .style=CS_HREDRAW Or CS_VREDRAW
    .lpfnWndProc=@wndproc
    .hInstance=Hinst
    .hIcon=LoadIcon(0,IDI_WINLOGO)
    .hCursor=LoadCursor(0,IDC_ARROW)
    .hbrBackground=Cast(HBRUSH,COLOR_WINDOWFRAME)
    .lpszClassName=StrPtr(NameClass)
    .hIconSm=.hIcon
End With

If RegisterClassEx(@wc)=0 Then
    Print "Register error, press any key"
    Sleep
    End
Endif

CreateWindowEx(0,NameClass,"Edit",_
WS_VISIBLE Or WS_OVERLAPPEDWINDOW,100,100,240,260,0,0,Hinst,0)

While GetMessage(@msg,0,0,0)
    TranslateMessage(@msg)
    DispatchMessage(@msg)
Wend

P.S. It seems to me when RICHEDIT was created, the microsoft company was in a hurry somewhere, because this control was not thought out.
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FBGUI library for windows 2

Post by enform »

I made tests with other Gadgets , I see the differences .
Adding SetCapture(hwnd) somewhere and after our task is finished re-valid the EventMouseWheel .

Maybe later I'll have a look at Scintilla , but it's another task ...

For the repeated events , no possibilities with PeekMessage(.......,PM_REMOVE) ?
I have used an event filter with some If NewEvent <> OldEvent Then do the task ; OldEvent = NewEvent

Thank you , dear teacher , have fun
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for windows 2

Post by VANYA »

enform wrote: For the repeated events , no possibilities with PeekMessage(.......,PM_REMOVE) ?
I can't talk about this right now, since we have different versions of the window9 library. The fact is that I have already made a lot of changes on the local disk, and I don’t even remember what I fixed over the years :)

I expect to release the library update until the end of April. Let us after the update, you will present an example in which you present recurring events or other problems. Good luck!
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FBGUI library for windows 2

Post by enform »

For sure , I'll wait ! Courage !
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for Windows 2

Post by VANYA »

Library updated. Now officially confirm that the library is cross-platform (FOR Windows and Linux).

1) Help file completely changed to support Linux. I'm sorry, but the help file is only in Russian
2) Many fixes

Files available at sf.net

The library setup is described in the first post
Xusinboy Bekchanov
Posts: 783
Joined: Jul 26, 2018 18:28

Re: FBGUI library for Windows 2

Post by Xusinboy Bekchanov »

Good work!
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for Windows 2

Post by VANYA »

Errors were found, so the library has been updated again.

Xusinboy Bekchanov, thanks for the kind words
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FBGUI library for Windows 2

Post by enform »

Wow, thank you !
You said previously you have many versions on your disk (of course) : "since we have different versions of the window9 library"

maybe you can add a version number to the zip file you share with the users ,corresponding to your work . Maybe with the date : like window9-190409.zip for example ?
This give a common reference , what do think about ?

greetings
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: FBGUI library for Windows 2

Post by VANYA »

enform wrote:Wow, thank you !
You said previously you have many versions on your disk (of course) : "since we have different versions of the window9 library"

maybe you can add a version number to the zip file you share with the users ,corresponding to your work . Maybe with the date : like window9-190409.zip for example ?
This give a common reference , what do think about ?

greetings
Hi enform!

The current library version located on sf.net:

https://sourceforge.net/projects/guiwindow9/files/

The old versions can always be found in the folder "Older Version":

https://sourceforge.net/projects/guiwin ... 20Version/

Suggest to use the new help file, despite the fact that he is on Russian language (google translate will help )
enform
Posts: 185
Joined: Apr 24, 2011 12:57
Location: France

Re: FBGUI library for Windows 2

Post by enform »

ok, I already downloded the files , but it was not the object of my post .... :-)

I just suggest to add a version number to the window9.zip file in order to know 'what is what' in case of question for you .

Have a good day
Post Reply