Child gadgets?

Mac OSX specific forum
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Child gadgets?

Post by WilliamL »

This code will make a child gadget on a windows machine but it doesn't work for me (on a Mac). Does this code work for any other Mac user? The original post is http://www.purebasic.fr/english/viewtop ... 13&t=43489 . Any ideas? I thought the idea could be useful.

Code: Select all

UseJPEGImageDecoder()
If OpenWindow(0, 0, 0, 300, 300, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If LoadImage(0,#PB_Compiler_Home +"Examples/Sources/Data/Clouds.jpg")
        hWnd = ImageGadget(0,  10, 10, 0, 0, ImageID(0))
        UseGadgetList(hWnd)
        TextGadget(1, 10, 10, 80, 20, "Heyho!")
    EndIf
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: Child gadgets?

Post by dhouston »

It works for me under XP & Windows 7 but all I see is the clouds on my Mac.
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Child gadgets?

Post by WilliamL »

Thanks for trying it dhouston!

Must be some difference between the Mac and PC compiler. I'm not going to report it as a bug since I don't understand it well enough but it would appear to be an easy way to change the text that is over an image.
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: Child gadgets?

Post by dhouston »

I know next to nothing about OSX but it seems to have no parent/child hierarchy like Windows & Linux. I cannot find a way to disable the parent (as I can under Windows & Linux) to prevent users from launching multiple child windows. Could this be related?
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Child gadgets?

Post by WilliamL »

OSX but it seems to have no parent/child hierarchy like Windows & Linux. I cannot find a way to disable the parent
Oh, that's very interesting. This is a point that freak could answer and also comment on the child gadget puzzle. I keep wondering why OSX is different from Linux if they both draw on UNIX but that really doesn't matter to me as long as pb works as described in the manual. I suppose if the problem could be posed as a bug then we might get answers.

I am really quite amazed at the far ranging ablilites of purebasic!
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: Child gadgets?

Post by dhouston »

WilliamL wrote:I am really quite amazed at the far ranging ablilites of purebasic!
+1

It took about 20 minutes to port my Windows code to Linux and even less time to port my Linux code to OSX. With both, I had several hours of tweaking to adjust for different fonts and gadget sizes but, overall I am very, very pleased. I had looked for a cross-platform Basic for several years, trying each that I found and finding each lacking (an understatement in a few cases as they were real dogs) and was prepared for another disappointment when I tried PB. Fred and his team deserve a lot of praise.

I did encounter one problem with both Linux & OSX (EditGadgets do not automatically scroll to the last line as they do under Windows) which I was able to fix under Linux by calling a few gtk functions. So far, I have not found a fix that works under OSX.
freak
PureBasic Team
PureBasic Team
Posts: 5950
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Child gadgets?

Post by freak »

WilliamL wrote:I keep wondering why OSX is different from Linux if they both draw on UNIX but that really doesn't matter to me as long as pb works as described in the manual.
That only applies to lower level stuff. Anything GUI related is fundamentally different for example.
WilliamL wrote:I suppose if the problem could be posed as a bug then we might get answers.
Please do not post bugreports just to get answers to questions. That is not what they are for.

As for your original question:
In both Windows and Linux, a Gadget and a Window are the same basic data type so UseGadgetList() will work on both. OSX differentiates between a the two that is why Window-related functions like UseGadgetList() only work on real Windows.
quidquid Latine dictum sit altum videtur
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Child gadgets?

Post by WilliamL »

Thanks for the info freak!

I interpret that to mean that child gadgets don't work in OSX (maybe an addition to manual?) and that child windows may be.. limited? (maybe another addition to manual?)

As for getting info, in my defense, it would be difficult to tell if this was a bug or not since it works in Windows and not on the Mac (at least until we are told otherwise). Maybe it was unfortunate wording on my part but I thought it might be a bug.

We have been warned! :twisted: [glad I didn't put it into the 'bugs' forum]
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: Child gadgets?

Post by dhouston »

WilliamL wrote:As for getting info, in my defense, it would be difficult to tell if this was a bug or not since it works in Windows and not on the Mac...
I agree that it's not always easy to tell whether or not something is a bug without having in-depth knowledge of the various APIs. I expected that something as fundamental as automatically scrolling an EditorGadget to the last line (whenever lines are added) would be built in and not require API calls. And, since I am using PB because, at 68 and in poor health, I don't want to acquire in-depth knowledge of the Linux & OSX API - having to research an API that appears to have been created by non-terrestials is disheartening - I have no idea where to go for info on the OSX API. I found an excellent gtk tutorial online (and a helpful author) so I managed to handle it under Linux but, so far, have no clue where to go for similar help with the OSX API.
User avatar
Shardik
Addict
Addict
Posts: 2075
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Child gadgets?

Post by Shardik »

dhouston wrote:I found an excellent gtk tutorial online (and a helpful author) so I managed to handle it under Linux but, so far, have no clue where to go for similar help with the OSX API.
You could take these links as starting points:

Apple Human Interface Guidelines: Controls
http://developer.apple.com/mac/library/ ... trols.html

Data Browser Reference
http://developer.apple.com/mac/library/ ... rence.html

Handling Carbon Windows and Controls (PDF)
http://developer.apple.com/legacy/mac/l ... ntrols.pdf

HIView Programming Guide (PDF)
http://developer.apple.com/legacy/mac/l ... HIView.pdf
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: Child gadgets?

Post by dhouston »

Shardik wrote:You could take these links as starting points:
Thanks - a bunch! :D

I guess part of the problem is related to the comparative market shares of the platforms. Windows has always generated a lot of third-party books and tools, such as Dan Appleman's excellent books on the Windows API which included VB code examples. Linux is too fragmented to generate similar commercial support and while there are a lot of free online resources, examples tend to be in C or C++ which is less helpful for someone like me whose first programs were in Fortran, typed onto punch cards and fed to an IBM mainframe and whose smattering of C proved inadequate when the Windows GUI arrived. VB was just what I needed at the time. OSX seems to have neither wide third party commercial support nor open source examples.

A cross reference of PB gadgets to the underlying API GUI components for Windows, Linux & OSX would be very helpful to us dim-witted relics.
freak
PureBasic Team
PureBasic Team
Posts: 5950
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Child gadgets?

Post by freak »

freak wrote:I interpret that to mean that child gadgets don't work in OSX (maybe an addition to manual?) and that child windows may be.. limited? (maybe another addition to manual?)
The manual is clear on this allready. UseGadgetList() expects a WindowID, what Gadgets have is a GadgetID. Nowhere does it say that you can mix the two. People only do, because it works (on Windows and Linux).
WilliamL wrote:As for getting info, in my defense, it would be difficult to tell if this was a bug or not since it works in Windows and not on the Mac (at least until we are told otherwise). Maybe it was unfortunate wording on my part but I thought it might be a bug.
Just a misunderstanding then. I read it as "lets just post in the bug forum [even though its not] and we will get an official answer", which of i would not have liked that much. No hard feelings then.
dhouston wrote:I expected that something as fundamental as automatically scrolling an EditorGadget to the last line (whenever lines are added) would be built in and not require API calls.
The options that the native API's provide are very extensive, so naturally we cannot add everything as a cross-platform PB command. If you think something generally useful is missing, feel free to post a feature request for it.
quidquid Latine dictum sit altum videtur
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: Child gadgets?

Post by dhouston »

freak wrote:The options that the native API's provide are very extensive, so naturally we cannot add everything as a cross-platform PB command. If you think something generally useful is missing, feel free to post a feature request for it.
I understand your position. I think (and have posted here) that the PB team deserves praise for what has been accomplished. I've bought most of the cross-platform Basic compilers, beginning with Zedcor's ZBasic in 1985 (about the time you were born) and none came anywhere close to PB. I also understand you have limited time to deal with this. While it was many years ago, I too went to university full-time while also working (more than) full-time (in GE's Large Jet Engine R&D).

My application is fairly large and I've only encountered two issues (for all three platforms). I wanted to automatically enumerate the serial ports on the user's PC and I wanted to automatically scroll the EditorGadget to display the last line whenever it was updated. Both issues require the API on all three platforms. The difference is that the Windows API is well documented (e.g. Dan Appleman's books with VB example code) and I was familiar with it from several years of using VB.

I already had a procedure for the serial ports that I had used with VB and other users here were quite helpful in converting it to PB. It was a bit more difficult to do under Linux but I'm acquainted with an old Linux hand who pointed me in the right direction. I posted my solution to the Linux forum. Now, I do understand why this is not built-in, with serial ports disappearing from PCs and never having been used much by Apple, it would make no sense for you to spend time on it. Again, other users have made suggestions that pointed the way to a solution under OSX.

The scrolling issue is a little different (and, I think, more fundamental). While it did require the Windows API, all that was needed was SendMessage which I was intimately familiar with. For Linux, it was a bit more difficult to learn that an EditorGadget equates to a GtkTextView and to find the needed commands but there's a lot of documentation on the web and it was only a few lines of code which I posted to the Linux forum once I had it working. OSX is proving more difficult. I still don't know which underlying API entity equates to the EditorGadget and Apple's monopolistic culture means there's little third-party support and a dearth of documentation online. While I've read all of the documentation suggested so far by others here, I'm still clueless.

One final point. A 25 year old probably has more patience posting a Feature Request than a 68 year old already diagnosed with congestive heart failure and lung cancer. :cry:
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: Child gadgets?

Post by Vera »

dhouston wrote:someone like me whose first programs were in Fortran, typed onto punch cards
you are not alone ;)

I'm sorry to hear :(
You're welcome to call on me any time and I keep on wishing that your aim will be successful :)

greeting ~ Vera
freak
PureBasic Team
PureBasic Team
Posts: 5950
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Child gadgets?

Post by freak »

dhouston wrote:A cross reference of PB gadgets to the underlying API GUI components for Windows, Linux & OSX would be very helpful to us dim-witted relics.
See here:
http://www.purebasic.fr/blog/?p=336
quidquid Latine dictum sit altum videtur
Post Reply