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
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by Mysoft »

oh no worries, i dont want to use a third party library on windows (other than window9 itself), and w9 almost have everything i need anyway, except for the font size part, and actual "char" received on keyboard events as i just have virtual key hehe... maybe we should add that for w9, as well utf-8 functions would make it extra useful...

but i see some things that are linux only like background/text color on buttons, that require some hackery on windows, but its doable, so it would be a good idea, to implement those as well, i even made a nice sample of "colored buttons" that could be useful

i also noticed some weakness on "custom events"... so minor improvements that would make this framework awesome... i will also port my layout engine that i have on winapi to be used with window9, as that would be nice when i make the "form" editor part of the IDE

its a simple layout engine, where it uses special constants, so that position,size can be relative to one of the edges of another control, as well percentage relative to the parent, as well absolute size... but i will add for this one "margin" parameters, that should be enough to have nice resizable forms on top of w9.

but i have a question....
on the event handling function to simplify instead of feeding a struct or whatever for the event details, you use functions, and so you store the state of the message internally, are you using TLS for that? or it would require to mutex the whole event processing for multithread?
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by VANYA »

Mysoft wrote:but i have a question....
on the event handling function to simplify instead of feeding a struct or whatever for the event details, you use functions, and so you store the state of the message internally, are you using TLS for that? or it would require to mutex the whole event processing for multithread?
I'm not good at knowing the internals (EXE\DLL\OBJ, etc.) of . Of course I have general ideas, but I can’t imagine why such knowledge is needed when creating a static library.
To be clear: the library does not support multithreading. All work related to the GUI should only be done on a single thread.
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by Mysoft »

hum... WindowBackgroundImage claims to be both windows/linux but i can't seem to find it on linux sources or bi files... (despite it seems badly documented as it suggestes DeleteObject to delete the returned hbrush, but i guess brush is only used for the auto-pattern while manual drawing on WM_ERASEBACKGROUND would be used to stretch the hbitmap, so i assume stretch one would not return a brush)

also i find weird that you have GetLenString for printer, but not for image/window, as the same thing should work for all of them (and its kinda dangerous to have some function names that are too generic like SizeX() and SizeY(), but heavily tied to specific events)

lack of a custom controls or child window, is another weakness that i'm having to tackle... as well the lack of "char" on the keyboard events, even that both gtk and winapi provide them almost as is...

another thing... theres little attention paid to avoid blinking when resizing , even that i draw the custom control (main window) over an image, there isnt a paint event (altough the header declares one but i believe thats windows only for WM_PAINT, but either way its not triggered)
but so i'm periodically setting a background image as the "updated" buffer, at least that way it auto updates when the window is resized, without needing to do that too fast, and seems theres no to have a window without a background (like if i dont use window image, it blinks when resizing because it draws the color background first and then only later it would update from the size event (that only happens on mouse up)

there seems to not have a way to focus some gadget, which would be useful for me to use a "invisible" editor gadget to receive the text, by always changing the focus to that gadget when the use uses the mouse, and getting the text from control on "change event" , but i dont get the mouse/keyboard events when they happen on a gadget (which otherwise would require subclass, but i think window9 is reading those from the message loop and filtering, however... i dont know the feasability of same on gtk, i assume there it would require to intercept everything :P)

and last but not least.... seems the 2D functions does not have options to drawing subimages, so i can't even do partial updates unless i crop that to another image first... and images that one could access directly trough pointer do exist on linux (pixbuf have such capabiliies like CreateDibSection?) if so those would be handy to be added.

oh one more thing, so to manage multiple windows, i guess i need different IDs for the gadgets of different windows, which is kinda weak... i assume if the ID conflicts it would either replace the old one, or it would create another one with the same ID, but then the functions that act on gadgets wont work unless ... they would obey the UseGadgetList(), so yeah i think theres some misplanned features.

i could add all of that and more to the windows version of the library, but i would need help with them for linux (as well some heads up on the capability level of such features on linux, so that the api names would make sense), lets improve this lib a little more? :)
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by VANYA »

WindowBackgroundImage claims to be both windows/linux
I tried to create it on linux, but something I didn't like. Now I don't remember what the problem was.
also i find weird that you have GetLenString for printer, but not for image/window,
Just at the moment I am writing a similar function, but it will be called differently
and its kinda dangerous to have some function names that are too generic like SizeX() and SizeY()
I agree, they will need to be renamed
lack of a custom controls or child window, is another weakness that i'm having to tackle..
What do you think I should have done? Arbitrary widgets for a knowledgeable winapi and gtk can always be linked to a library, but I have no idea how to do it for a user who knows little about the winapi and gtk subsystems.
as well the lack of "char" on the keyboard events, even that both gtk and winapi provide them almost as is...
I didn't see the point of this, since each window class (button, static, etc.) internally (at the system level) has its own window procedure and each of them has its own WM_CHAR handler. Do you offer every gadget you create to be subclassed? I don't like the idea!
another thing... theres little attention paid to avoid blinking when resizing , even that i draw the custom control (main window) over an image, there isnt a paint event (altough the header declares one but i believe thats windows only for WM_PAINT, but either way its not triggered)
In past versions, it was possible to catch WM_PAINT, but I removed it when I rewrote the event handler. WM_PAINT was still useless in the callback, and also caused some problems with other events for my library. Any events on the Windows system can always be caught directly from the window procedure (see SetWindowCallback).
there seems to not have a way to focus some gadget
I have already written analogues of SetFocus\GetFocus for Linux and it will be in the next version
and last but not least.... seems the 2D functions does not have options to drawing subimages, so i can't even do partial updates unless i crop that to another image first... and images that one could access directly trough pointer do exist on linux (pixbuf have such capabiliies like CreateDibSection?) if so those would be handy to be added.
Hands don't reach everything. In addition to the library, I have several projects in parallel.
oh one more thing, so to manage multiple windows, i guess i need different IDs for the gadgets of different windows, which is kinda weak... i assume if the ID conflicts it would either replace the old one, or it would create another one with the same ID, but then the functions that act on gadgets wont work unless ... they would obey the UseGadgetList(), so yeah i think theres some misplanned features.
I'm definitely not going to change anything here. The number of identifiers (more than 60,000) is enough to release projects of any complexity. Identifiers will remain unique. In any case, in large projects, the programmer tries to assign meaningful names to the identifiers using the ENUM block
i could add all of that and more to the windows version of the library, but i would need help with them for linux (as well some heads up on the capability level of such features on linux, so that the api names would make sense), lets improve this lib a little more?
My principle: if the improvements do not break the backward compatibility, then this is painlessly added and corrected, of course to the best of my ability. I don't want to be like the GNOME developers, who are constantly shaking up their APIs and causing developers using GTK to a nervous breakdown. Do not forget that adding code is only part of the work (the most pleasant), but there is also help (Russian and English). And Help in most cases takes much longer than adding code for new features. And working with help is not the most pleasant pastime :(

Let's start small. You, if you want, write some simple useful functions. We will think about how to implement this on a Linux system. If this is technically possible, then I think we can officially add them. Just don't write a lot of functions at once. It is better to write those functions that you definitely need for your project.

P.S. The library is not a full framework, such as Qt. In any case, when using W9, you need WinAPI and GTK knowledge. The library can help with basic things, but a considerable part will still have to write with system API. For example, in your case, when creating the editor, you will have to subclass the EDIT control on Windows and connect the Callback function to the GTK on Linux to catch the keystroke events. Only so it turns out to make a fast-running editor.
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by Mysoft »

VANYA wrote: Feb 08, 2022 6:20
also i find weird that you have GetLenString for printer, but not for image/window,
Just at the moment I am writing a similar function, but it will be called differently
ok, right now i used GetLenString on linux (because it does not seem to depend on any printing specific stuff, but it will add the whole printing module to the project but oh well, (maybe the IDE can have printing later either way :P)), and on windows i used winapi yes
lack of a custom controls or child window, is another weakness that i'm having to tackle..
What do you think I should have done? Arbitrary widgets for a knowledgeable winapi and gtk can always be linked to a library, but I have no idea how to do it for a user who knows little about the winapi and gtk subsystems.
i will think about this, because clearly the weak link here is gtk, that is easier to do such stuff compared to winapi, as basically on gtk you need lot more hooks, but yeah i need to learn how to use gtk, as i never used it... But yes theres a reason that the controls are "by name" on windows :P it simplifies creating custom controls.
But i already checked a few things on the window9 source, it bothers me a bit that the source codes are entirely separate (instead of having just some windows folder / linux fodler , for specific files and #ifdef on the rest to make a more centralized database, but specially the .bi file is entirely different hehe.
as well the lack of "char" on the keyboard events, even that both gtk and winapi provide them almost as is...
I didn't see the point of this, since each window class (button, static, etc.) internally (at the system level) has its own window procedure and each of them has its own WM_CHAR handler. Do you offer every gadget you create to be subclassed? I don't like the idea!
well i meant for the "window", because thats the only way to have "custom controls now", i'm using the main window events and having a virtual control that draws on the main window (i'm even speculating using a popup window, above the main window to have a separate window for the editor control since i can't have child windows as is.

yeah great good to know so if i implement some simple functions to be added to the framework, i dont need to worry about those :)

yeah sure i just tought it would be natural to have added those along the image functions, as they kinda touch the issue, i'm doing some workaround with the load image from memory (with a bitmap in memory lol, and retrieving images using the very slow get pixel function for now, as that just for one very specific case on the about dialog. But no worries i will finish some projects concurrently to this as well then you may have a second hand, because i believe on this library unlike many many other libraries :P

yeah thats what i'm doing, but just because i'm doing the entire thing, but if i was to add extensions to the library without them being part of it officially, like say, some extra dialogs, it would conflict with existing stuff by other people... (the only other way would be to have them on separate dll files with another instance of window9, but thats get bloaty hehe)
and this uniqueness also does not help , iif i was to add a "form editor" to the IDE using window9 for example, but thats not part of the initial goal, so i see what can be done, but an optional way to have callbacks event on a function instead of reading on a loop (so you could grab events from specific gadgets or windows separately would help, knowing the owner of the control would be a useful tool... but i will see if theres a good strategy for the control handling, maybe something similar as UseGadgetList

yes i agree 100% with that , and i understand, i'm just for now avoiding system specific stuff, so i can feel the power of the library (and how much i can workaround those issues with ticks), and yeah i will try to finish some projects of my own to be able to help you, and i dont mind doing some fixes for the documentation (english), as well improving it with the functions... i.e. maintain it (but i can't do a thing for the russian one hehehe)

(forum broke my answer i will edit it later to re-add the quotes that it killed)
Vortex
Posts: 118
Joined: Sep 19, 2005 9:50

Re: GUI library for Windows \ Linux (window9)

Post by Vortex »

Hi VANYA,

Keep up the nice work. I liked your manual of the library supported by various examples.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by VANYA »

@Mysoft
It is better to use ImageGadget for drawing, while using ImageStartDraw+SetImageGadget.

@Vortex
thank you!
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by Mysoft »

VANYA wrote: Feb 09, 2022 5:06 @Mysoft
It is better to use ImageGadget for drawing, while using ImageStartDraw+SetImageGadget.

@Vortex
thank you!
yes but i can't get mouse and key events from an imageGadget with the current state... only from windows
oh btw i tested what i had done so far on a linux machine, and seems the linux one need lots of love... like
  • Catch_Image() crashes (even the sample one)
  • StatusBarGadget() does not create a status bar
  • the menu check mark does not appear (do i have to manually set an icon for that?)...
  • also on linux the "menu" is inside the client area, (that is not mentioned on the manual), so me trying to simplify the "area to draw" over the window (since i can't use a child window or an image control) wont work...
  • the menu event does not tell from which window the event came (it does on windows), im not relying on that but it failed to trigger as i was only checking menu events if the window was main window hehe
  • ResizeWindow() also crashes when i try to resize the window to "adjust the window/client area size", which on linux it does not matter because the gtk size is already the client area (so i could just comment that on linux, but the function crashes anyway :P)
  • OpenHlp() does not exist on linux yet? it would use the same principle as the CHMVIEW? or it will call that?
so seems i will have to install a linux VM to test a lot of such stuff, and help you with the library :)
Last edited by Mysoft on Feb 09, 2022 16:10, edited 1 time in total.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by VANYA »

@Mysoft

What version of linux did you test this on? What is the bitness of the system 32 or 64 bit?
SARG
Posts: 1765
Joined: May 27, 2005 7:15
Location: FRANCE

Re: GUI library for Windows \ Linux (window9)

Post by SARG »

Mysoft wrote: Feb 09, 2022 14:25 StatusBarGadget() does not create a status bar
StatusBarGadget works fine. Example what I'm using (WDS/LNX) :

Code: Select all

hmain=OpenWindow("",10,10,1155,600)

	''status bar
	StatusBarGadget(GSTATUSBAR,"",SBT_TOOLTIPS)
	statusbar_text(KSTBSTS,"Initialization")
	statusbar_text(KSTBTHD,"Tid or Pid")
	statusbar_text(KSTBUID,"Tid")
	statusbar_text(KSTBSRC,"Current source")
	statusbar_text(KSTBPRC,"Current proc")
	statusbar_text(KSTBBPM,"")
	statusbar_text(KSTBFRT,"Fast time ?")

With this kind of defines

Code: Select all

#define GSTATUSBAR 332
#define KSTBSTS 0 ''first field
#define KSTBTHD 1
#define KSTBUID 2
#define KSTBSRC 3
#define KSTBPRC 4
#define KSTBBPM 5
#define KSTBFRT 6

Code: Select all

'' changes the text of a field in statusbar and tooltip
'==============================================================
private sub statusbar_text(fieldn as long, text as string)
	dim as integer fieldpos
	select case fieldn
		Case KSTBSTS
			fieldpos=200
		case KSTBTHD
			fieldpos=300
		Case KSTBUID
			fieldpos=400
		Case KSTBSRC
			fieldpos=600
		Case KSTBPRC
			fieldpos=800
		Case KSTBBPM
			fieldpos=830
		case KSTBFRT
			fieldpos=-1
	End Select
	SetStatusBarField(GSTATUSBAR,fieldn,fieldpos,text)
	ToolTipStatusBar(GSTATUSBAR,fieldn,text)
End Sub
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by Mysoft »

VANYA wrote: Feb 09, 2022 15:02 @Mysoft

What version of linux did you test this on? What is the bitness of the system 32 or 64 bit?
ubuntu 20.4 LTS (64bit freebasic), it does not show on the window, and even the "resize" of my "code control (main window)" fails because it draws till the status bar top position, that returns 0...
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by VANYA »

Mysoft wrote: Feb 09, 2022 15:38
VANYA wrote: Feb 09, 2022 15:02 @Mysoft

What version of linux did you test this on? What is the bitness of the system 32 or 64 bit?
ubuntu 20.4 LTS (64bit freebasic), it does not show on the window, and even the "resize" of my "code control (main window)" fails because it draws till the status bar top position, that returns 0...
Please provide examples of where these errors would be. Because, I tested on ubuntu 20.4, and there was not a single problem that you mentioned. You are talking about Catch_Image , but tell me how I have already used it in at least 10 of my programs? I can show one of them right now: viewtopic.php?t=29704 . Another example: SARG uses Catch_Image , StatusBar , ResizeWindow in its program. I wonder how he does it without CRASH?
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by Mysoft »

VANYA wrote: Feb 09, 2022 15:55
Mysoft wrote: Feb 09, 2022 15:38
VANYA wrote: Feb 09, 2022 15:02 @Mysoft

What version of linux did you test this on? What is the bitness of the system 32 or 64 bit?
ubuntu 20.4 LTS (64bit freebasic), it does not show on the window, and even the "resize" of my "code control (main window)" fails because it draws till the status bar top position, that returns 0...
Please provide examples of where these errors would be. Because, I tested on ubuntu 20.4, and there was not a single problem that you mentioned. You are talking about Catch_Image , but tell me how I have already used it in at least 10 of my programs? I can show one of them right now: viewtopic.php?t=29704 . Another example: SARG uses Catch_Image , StatusBar , ResizeWindow in its program. I wonder how he does it without CRASH?
ok i will setup a linux VM with that here and try to see if something up on the linux installation of the person that i'm using (remotely), but i remember the GTK error saying it fails to allocate culngint(-1)*culngint(-1) block :P , and ofcourse it may not matter but its the gtk2 version as the gtk3 version always shows that error that is not possible to have gtk2 and gtk3 on the same process (WHY??????????????????????????????), that i couldnt solve :P
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by VANYA »

Mysoft wrote: Feb 09, 2022 16:13gtk3 version always shows that error that is not possible to have gtk2 and gtk3 on the same process (WHY??????????????????????????????), that i couldnt solve :P
Look in the window9.bi file for the very first line.
ok i will setup a linux VM with that here and try to see if something up on the linux installation of the person that i'm using (remotely), but i remember the GTK error saying it fails to allocate culngint(-1)*culngint(-1) block
I don't know what you were doing there, but as I told you, if you encounter an error, please show an example that causes this error.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: GUI library for Windows \ Linux (window9)

Post by VANYA »

Now checked all your problems on 20.04

Catch_Image , StatusBarGadget , ResizeWindow - work fine
the menu event does not tell from which window the event came (it does on windows), im not relying on that but it failed to trigger as i was only checking menu events if the window was main window hehe
I didn't understand what you were talking about at all.
also on linux the "menu" is inside the client area, (that is not mentioned on the manual), so me trying to simplify the "area to draw" over the window (since i can't use a child window or an image control) wont work...
There is a mention of this in the toolbar section (CreateToolBar), because the creation of the toolbar depends on whether there is a menu or not. In other cases, it is clear that in GTK the menu eats up the space of the client area.
the menu check mark does not appear (do i have to manually set an icon for that?)...
Yes, there is your truth. В Ubuntu 20.04 default property for some reason "show-menu-images" disabled. Unfortunately, such things often happen on linux (what is on one OS distribution, not on another). I will force this property to be enabled.
OpenHlp() does not exist on linux yet? it would use the same principle as the CHMVIEW? or it will call that?
This feature is not planned in the library

Resume: there is only one problem, and that is not critical,different from what you described.
Post Reply