Object-Oriented GUI Library

User projects written in or related to FreeBASIC.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Object-Oriented GUI Library

Postby datwill310 » Nov 23, 2016 18:42

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: 173
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: Object-Oriented GUI Library

Postby kcvinu » Nov 23, 2016 19:51

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

Re: Object-Oriented GUI Library

Postby MrSwiss » Nov 23, 2016 20:38

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: 757
Joined: Jul 14, 2005 23:41
Contact:

Re: Object-Oriented GUI Library

Postby PaulSquires » Nov 23, 2016 20:48

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

Postby datwill310 » Nov 23, 2016 21:15

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: 757
Joined: Jul 14, 2005 23:41
Contact:

Re: Object-Oriented GUI Library

Postby PaulSquires » Nov 23, 2016 22:10

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

Postby datwill310 » Nov 23, 2016 22:44

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: 173
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: Object-Oriented GUI Library

Postby kcvinu » Nov 24, 2016 6:26

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

Postby datwill310 » Nov 24, 2016 20:51

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: 2762
Joined: Jun 02, 2015 16:24

Re: Object-Oriented GUI Library

Postby Tourist Trap » Nov 24, 2016 20:57

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

Postby datwill310 » Nov 25, 2016 21:03

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: 3213
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Object-Oriented GUI Library

Postby MrSwiss » Nov 25, 2016 21:42

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

Postby datwill310 » Nov 25, 2016 22:06

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

Postby datwill310 » Nov 25, 2016 22:46

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: 3213
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Object-Oriented GUI Library

Postby MrSwiss » Nov 25, 2016 22:51

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

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 3 guests