Object-Oriented GUI Library

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Object-Oriented GUI Library

Post by datwill310 »

MrSwiss wrote:
datwill310 wrote:3) So I should explicitly use the long types instead of integer types? Oh man: should have spotted that one.
Yes, because they stay 32bit always (independent of the used Compiler).

On Windows UI, only the Pointer(s) are extended to 64bit (on x64 Platform).
All the rest remains 32bit(s). (Different from Linux UI, which extends every-
thing on x64 Platform.)
Another bad thing is that I've used quite a lot of longint datatypes, especially with indexes.

I shouldn't allow the programmer to feed in potentially 64-bit values, as that might cause some havoc!

But thanks for the pointer note especially.
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: Object-Oriented GUI Library

Post by kcvinu »

Hi,
Does this library supports UNICODE ?.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Object-Oriented GUI Library

Post by MrSwiss »

The probably most used Function in OGL optimized ...

Recoded Function waitevent(ByRef msg As MSG) As Boolean for speed & readability:

Code: Select all

Function waitevent(ByRef msg as MSG) As Boolean
	 Dim As Long ret = GetMessage(@msg, 0, 0, 0)  ' correct ret Type = Long
	 ' only one single line If - without any additional comparisons, e.g. ret <> 0
	 If ret Then TranslateMessage(@msg) : DispatchMessage(@msg)
	 Function = CBool(ret)  ' Type cast to Boolean
End Function
PaulSquires
Posts: 999
Joined: Jul 14, 2005 23:41

Re: Object-Oriented GUI Library

Post by PaulSquires »

kcvinu wrote:Hi,
Does this library supports UNICODE ?.
And it doesn't look like the library is High-DPI aware either?
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Object-Oriented GUI Library

Post by datwill310 »

kcvinu wrote:Does this library supports UNICODE ?.
No, as of now, the OGL does not support Unicode.
I did plan, however, to add Unicode support, and I will make this a priority in the upcoming updates (this will hopefully be added in the next major version). Just realised that it will not be as easy as I had thought. I will have to add Unicode versions of the methods and properties which use unicode (and may have to re-program the library if worst comes to the worst). I have a few ideas which make Unicode inclusion much easier than this, though.
The answer? No, it doesn't, but it will.
MrSwiss wrote:The probably most used Function in OGL optimized ...

Recoded Function waitevent(ByRef msg As MSG) As Boolean for speed & readability:

Code: Select all

Function waitevent(ByRef msg as MSG) As Boolean
    Dim As Long ret = GetMessage(@msg, 0, 0, 0)  ' correct ret Type = Long
    ' only one single line If - without any additional comparisons, e.g. ret <> 0
    If ret Then TranslateMessage(@msg) : DispatchMessage(@msg)
    Function = CBool(ret)  ' Type cast to Boolean
End Function
Thanks MrSwiss! I have already adapted most datatypes to the 32-bit "equivalents" according to your advise, but thanks for the other optimisations!
PaulSquires wrote:And it doesn't look like the library is High-DPI aware either?
You know, listening to other programmers really helps me realise I'm just a beginner at this...
I looked it up, and I think I can conclude that: no, it is not.
I will have to research into the subject more before I can include it into the OGL.
Thanks for bringing the subject to my attention.
PaulSquires
Posts: 999
Joined: Jul 14, 2005 23:41

Re: Object-Oriented GUI Library

Post by PaulSquires »

If you would like to see how Unicode and High DPI can be successfully implemented in a object based class for Windows API then take a look at Jose Roca's CWindow class over on my forum: http://www.planetsquires.com/protect/forum/index.php Maybe it can provide some hints and inspiration for your project.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Object-Oriented GUI Library

Post by datwill310 »

PaulSquires wrote:If you would like to see how Unicode and High DPI can be successfully implemented in a object based class for Windows API then take a look at Jose Roca's CWindow class over on my forum: http://www.planetsquires.com/protect/forum/index.php Maybe it can provide some hints and inspiration for your project.
Thanks and will do!

----

Please look at my original post!
I've discovered a fundamental flaw with the GUIFONT class which means you can't actually edit the font correctly (each time you edit a GUIFONT object, it actually destroys the old font - which means that the controls which used that font will revert back to the system font)! Will have to take most of its functionality away as I do not know a way to edit an HFONT object dynamically.
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: Object-Oriented GUI Library

Post by kcvinu »

Hi datwill310,
Thanks for the reply. Ready to wait for the next version. For me, unicode support is essential.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Object-Oriented GUI Library

Post by datwill310 »

kcvinu wrote:Hi datwill310,
Thanks for the reply. Ready to wait for the next version. For me, unicode support is essential.
The official first version is now released, but it does not support Unicode just yet. Thanks for your patience, and I promise I will release the nest version with support for Unicode.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Object-Oriented GUI Library

Post by Tourist Trap »

I'll try this this week end. Very happy to see this development effort! Gui programming is really needed. Thanks.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Object-Oriented GUI Library

Post by datwill310 »

Looks like I may have to rewrite the OGL if I am to support Unicode. Everything will get the same names, just that the bestest option in terms of simplicity involves supporting Unicode ONLY (since Unicode supports all the characters within ANSI and more), and it isn't as simple as replacing variable names.
A Unicode-only version should be out by next week if I concentrate, but I can't promise anything.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Object-Oriented GUI Library

Post by MrSwiss »

Well, since for UNICODE, only the String type differs: String vs. WString and
Windows API supports both of them, it should not be too difficult to support both.

simplified example:

Code: Select all

#ifdef UNICODE
Declare Function WindowsStringFunction Alias "WindowsStringFunctionW"(parameters) '' UNICODE = WString
#else
Declare Function WindowsStringFunction Alias "WindowsStringFunctionA"(parameters) '' ANSI String
#endif
where:
WindowsStringFunction ' the Name that is later used in FB
the Alias(es):
"WindowsStringFunctionW"
"WindowsStringFunctionA" ' are the REAL Names in WIN-API
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Object-Oriented GUI Library

Post by datwill310 »

MrSwiss wrote:Well, since for UNICODE, only the String type differs: String vs. WString and
Windows API supports both of them, it should not be too difficult to support both.

simplified example:

Code: Select all

#ifdef UNICODE
Declare Function WindowsStringFunction Alias "WindowsStringFunctionW"(parameters) '' UNICODE = WString
#else
Declare Function WindowsStringFunction Alias "WindowsStringFunctionA"(parameters) '' ANSI String
#endif
Where:
WindowsStringFunction ' the Name that is later used in FB
the Alias(es):
"WindowsStringFunctionW"
"WindowsStringFunctionA" ' are the REAL Names in WIN-API
Yes, I have read that, but this involves me using Windows API types (such as LPTSTR etc.), and these aren't as simple to use as Free BASIC strings (Windows API string datatypes are explicitly pointers and the programmer must treat them as such, but Free BASIC strings are easier to work with, e.g. "Hello World" - FB does all the hard work for the programmer). I would like to keep the OGL as simple as possible, so if I can avoid pointers, it would be good...
Alas, this is impossible with Unicode in Free BASIC... But I've tested a few of my Unicode functions out, and they seem to work very similarly:

Code: Select all

'here's my loadico() function - it accepts Unicode directories
function loadico(byval iconpath as [b]wstring ptr[/b], byval w as long = 32, byval h as long = 32, byval additionalflags as ulong = 0) as HICON
	return LoadImageW(0, *iconpath, IMAGE_ICON, w, h, LR_LOADFROMFILE or additionalflags)
end function
And it works if I provide a literal, like this:

Code: Select all

loadico("iconф.ico")
But something tells me this is wrong in some way...

Thanks again.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Object-Oriented GUI Library

Post by datwill310 »

MrSwiss wrote:Well, since for UNICODE, only the String type differs: String vs. WString and
Windows API supports both of them, it should not be too difficult to support both.

simplified example:

Code: Select all

#ifdef UNICODE
Declare Function WindowsStringFunction Alias "WindowsStringFunctionW"(parameters) '' UNICODE = WString
#else
Declare Function WindowsStringFunction Alias "WindowsStringFunctionA"(parameters) '' ANSI String
#endif
where:
WindowsStringFunction ' the Name that is later used in FB
the Alias(es):
"WindowsStringFunctionW"
"WindowsStringFunctionA" ' are the REAL Names in WIN-API
I tried what you suggested, and it worked better than I had thought! I think I might be done with implementing unicode! Thanks man!
... Please ignore what I said above this post Image...
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Object-Oriented GUI Library

Post by MrSwiss »

Yes, but the Ptr issue is not that hard to solve, since,
usually the Pointers use fixed length (String/WString):

Code: Select all

Dim As String Ptr pStr = CAllocate(260) ' or
Dim As WString Ptr pWStr = CAllocate(260 * 2)

... ' use them
*pWStr = "any text you like!" ' assign
Print *pWStr ' output
... ' use finished

' deallocate to free used MEM
Delete pStr : pStr = 0 ' or
Delete pWStr : pWStr = 0
Post Reply