Thread: [Fxruby-users] Icons and tooltips
Status: Inactive
Brought to you by:
lyle
From: Hal F. <ha...@hy...> - 2004-05-23 07:51:00
|
Forwarding a question someone asked me. Assist if you can. Hal -------- Original Message -------- Subject: Re: "Speeling is both prety gudd", etc. Date: Sun, 23 May 2004 02:44:33 -0500 From: Hal Fulton <ha...@hy...> Reply-To: ha...@hy... To: RLMuller <RLM...@co...> References: <Aoi...@co...> <aJO...@co...> <40B...@hy...> <002f01c44097$4df09bb0$050...@as...> RLMuller wrote: > While I "have you on the phone," let me inject a serious note. > http://www.fxruby.org/examples/hello2.rb provides a nice ToolTip demo that > raise a few questions in my mind: > > 1. The syntax of the "FXPNGIcon.new(application, f.read)" statement would > lead me to think the icon is being attached to the application (e.g., for > purpose of displaying the app in an OS' toolbar when it runs, perhaps) > rather than in the application's FXMainWindow instance. I'd expect it to > have a "main" argument explicitly naming the window to which it should be > attached, as FxButton.new does. > > 2. FXTooltip.new's failure to name any particular object leads me to think > it should wire a tooltip into every object in the application (or rather, > the app's main window?) that's built to host a tooltip, and that the > tooltip text is to be gotten from each such object's caption text (using > everything following the first tab.) > > I could probably answer these questions myself if I could find documentation > on these classes, but all I could find on this website is class hierarchies > for the Fox classes. > > Could you point me to a source for documentation for the Fox classes that > addresses my questions, or in lieu of that comment on my inferences above? Overall that is as puzzling to me as it is to you. I'll forward this to the fxruby users' list in case someone can help you. There's also some stuff on fox-toolkit.org (naturally not ruby-specific) which is sometimes helpful. If you get answers to these, will you share them with me? Thanks, Hal Fulton |
From: Jamey C. <jc...@tw...> - 2004-05-23 15:16:40
|
I'm sure others, especially Lyle, can anwer these questions better than I can, but since we all want Lyle to be working on the next version of FXRuby instead of answering questions, I'll take a lame stab at some answers: :) Hal Fulton wrote: > Forwarding a question someone asked me. > RLMuller wrote: > >> 1. The syntax of the "FXPNGIcon.new(application, f.read)" statement >> would >> lead me to think the icon is being attached to the application (e.g., >> for >> purpose of displaying the app in an OS' toolbar when it runs, perhaps) >> rather than in the application's FXMainWindow instance. I'd expect >> it to >> have a "main" argument explicitly naming the window to which it >> should be >> attached, as FxButton.new does. >> FXPNGIcon.new isn't putting the icon into any particular widget, it is simply creating the icon so that it can later be put into one or more widgets or windows (i.e. button, dialogbox, etc.). That's why you don't specify the particular widget (i.e. button) when you initially create it. However, if you look in the docs for the FXButton class, you will see that you can specify an icon in the constructor. That's where you put the reference to the FXPNGIcon that you created earlier. Am I understanding the question or did I miss something? >> 2. FXTooltip.new's failure to name any particular object leads me to >> think >> it should wire a tooltip into every object in the application (or >> rather, >> the app's main window?) that's built to host a tooltip, and that the >> tooltip text is to be gotten from each such object's caption text (using >> everything following the first tab.) >> This is kind of the same thing. You initialize a FXTooltip object once for the entire application. Then, when you create each object (i.e. button), you can specify a text string in the constructor that will appear as the tooltip for that object. But you have toe create the FXTooltip first for the whole app in order for tooltips to work for each object. >> I could probably answer these questions myself if I could find >> documentation >> on these classes, but all I could find on this website is class >> hierarchies >> for the Fox classes. >> >> Could you point me to a source for documentation for the Fox classes >> that >> addresses my questions, or in lieu of that comment on my inferences >> above? > > A pretty good source for docs is at www.fxruby.org. Click on the "API" button. This will take you to definitions of all the FXRuby classes/methods/attributes. HTH. Jamey |
From: Lyle J. <ly...@kn...> - 2004-05-24 00:44:30
|
On May 23, 2004, at 2:50 AM, Hal Fulton wrote: >> 1. The syntax of the "FXPNGIcon.new(application, f.read)" statement >> would >> lead me to think the icon is being attached to the application (e.g., >> for >> purpose of displaying the app in an OS' toolbar when it runs, >> perhaps) >> rather than in the application's FXMainWindow instance. I'd expect >> it to >> have a "main" argument explicitly naming the window to which it >> should be >> attached, as FxButton.new does. Several kinds of objects in FOX applications are treated as shared resources; these include objects like cursors, fonts and icons. So while an icon is associated with a particular FXApp instance (as suggested by its constructor) it's a mistake to think of it in terms of the application "owning" the icon. In fact, you can use the same, single FXPNGIcon instance with your main window, labels, buttons, etc. (i.e. any widget that can be decorated with an icon). A mistake I see in a lot of FOX programs is that programmers will construct multiple icon objects all pointing to the same icon data, e.g. 0.upto(1000) { anIcon = FXPNGIcon.new(getApp(), someIconData) anIcon.create aTreeList.addItemLast(nil, "some text", anIcon) } The confusion may arise because of how the constructors for "non-shared" FOX objects (such as windows) are written. There, the first argument is almost always the parent window, and there is a definite parent-child containment hierarchy going on there: the "parent" window does "own" the child window, in a sense, and if you delete the parent window the child window goes away too. >> 2. FXTooltip.new's failure to name any particular object leads me to >> think >> it should wire a tooltip into every object in the application (or >> rather, >> the app's main window?) that's built to host a tooltip, and that the >> tooltip text is to be gotten from each such object's caption text >> (using >> everything following the first tab.) There is only one tooltip object (or, rather, it's unnecessary to have more than one tooltip object). Whenever the tooltip's update handler runs, the tooltip checks to see which widget the mouse cursor is currently hovering over. And of course there's a timer in the mix, so that the tooltip "waits" a little while before it displays itself. You are correct that when the tooltip does display itself, it "asks" the current widget under the cursor for its tooltip text and displays that. Hope this helps, Lyle |