fpGUI
fpGUI copied to clipboard
Hint on fpgui-develop
Hello Graeme.
Balloon-hint only works once in fpgui-develop. After first time, the balloon is empty.
Thanks.
Fre;D
Thank you for reporting this. It is a know problem and I'm trying to find what is causing this.
Hello Graeme.
Here result of some investigations.
There is something strange with width of hint-window.
If the width stay same length, all works perfectly, hint is show always ok, with text too.
In fpg_main, line 1604, in procedure TfpgApplication.ActivateHint(APos: TPoint; AHint: TfpgString);
If this:
==> w := wnd.Font.TextWidth(AHint) + (wnd.Border * 2) + (wnd.Margin * 2);
is changed with something constant, like that:
==> w := 150;
Then hint-window is always show correctly, with text, even if the height of the hint-window change for a other hint.
But if the width change (I do not think that Font.TextWidth is guilty, it appends also with, for example, w := length(AHint) * 10; ==> then, after 2 or 3 time, text is not show anymore...
The position of the window-hint has no impact on te bug.
I continue investigations but maybe somebody has a idea what could cause this.
Fre;D
Wow, I've been working on this issue all morning... I've fixed a lot of things wrong with the hintwindow handling (since the Alien Windows changes), but it still eludes me why the text disappears after the hint window changes size. I'll still looking though. This is a tough one. :)
OK, found a solution! It will be fixed later today.
Ho, I am extremely curious to know what was the guilty.
Fre;D
I spoke too soon. I thought it was working, but then with further testing it didn't. :-( Interestingly, if you enable the AggCanvas, then the hints render correctly, even if the hint window's size changes.
OK, I will jump into code again. Write you later.
What I tried... The original HintWindow was designed so that text is painted directly on the form's canvas. This was because fpGUI didn't have full widget transparency. I thought I could now replace that text drawing code with a TfpgLable and set BackgroundColor = clNone, because now we support full widget transparency. Initially I thought this solved the problem (though the original cause still eluded me). But with further testing, and using the TfpgLabel in the HintWindow, the issue came back again! Without using a TfpgLabel, I tested the text rectangle, hint text, text rectangle position - everything checks out like it is supposed to be. I have no idea why the text doesn't display. Also, like I said, with AggCanvas, there is no problems at all. This suggests to me that maybe there is some refresh issue (a refresh message is not being received). So maybe the hintwindow canvas is updated, but because of a lost refresh message we don't see it. Normally by dragging another application window over the problematic window cause the paint refresh - but obviously with a hint window that is not possible, because the hint window will hide itself automatically.
Hello Graeme.
Huh, I just come here to say you that there was a solution using... a fpgLabel !
But are you sure it is not working ?
Please, could you try with fpg_hint.pas + fpg_main.pas modified in attachment. I try it for hours now and, it still work, with text , aggpas disabled...
PS: The code is not cleaned yet, for example procedure TfpgHintWindow.PaintHintText is not needed anymore.
Fre;D
Re-Hello Graeme.
Here in attachment, fpg_hint.pas using a private FHintLabel.
Tested, mercyless, during hours, without any problems and with text always show.
This does not need any modif to fpg_main.pas
Hum, by the way, about fpg_main.pas, is this still needed ?:
procedure RecreateHintWindow;
And in procedure TfpgApplication.ActivateHint(APos: TPoint; AHint: TfpgString):
if Assigned(wnd) and wnd.Visible then Exit;
If wnd was not assigned, wnd.Visible would raise a error (no?)
Maybe this would be:
if Assigned(wnd) then if wnd.Visible then Exit;
Last thing, wnd is declared in the procedure so how could the procedure check if wnd was assigned ?
So, maybe, if Assigned(wnd) and wnd.Visible then Exit is not needed.
Fre;D
It is weird, even with your copy of "fpg_hint.pas", I get the exact same behaviour as with my own changes. As soon as the hint window size changes, the Label widget doesn't appear any more - just like the original problem. :-( I'm still stumped as to why neither implementations work. The original (painting direct to hint window canvas) should for all intent purposes work, but it doesn't.
I'll test on another machine... maybe there is something on with my FPC and fpGUI setup.
Aaargh, very strange, here it is working perfectly for hours.
But I have to agree that there is still strange behaviour with hint-window.
For example, if you change the height of the hint in code, there is a strange "hole" between 10 and 25.
whint.height := 10 ; // ok, the height ot te hint-window is 10 pixels.
whint.height := 11; // not ok, the height becomes 25 pixels.
whint.height := 12; // not ok, the height becomes 25 pixels.
And this until whint.height := 25 then the height is normal.
whint.height := 26 ; // ok the height is 26 pixels.
Fre;D
Playing further with the embedded TfpgLable inside the hint window I eventually managed to get it working as expected. Now playing with custom hint windows (as can be seen in the hintwindow example). But ultimately I need to figure out why painting directly to the canvas is not working, as that affects the custom hint window too.
The hint window height issue is new as well. I'll take a look at that too. Some very odd things going on with the hint window. :-)
I wonder if using the DrawHandle function inside DoDrawString would cause the Xft object to be recreated if the double buffer(the actual drawhandle) has been reallocated because of a resize.
@andrewd207 : I think you are on to something. I had a look at this again over the weekend. X11 is affected, AggCanvas is not. I haven't tested GDI. Anyway, if I add a call RecreateHintWindow; as the first line inside TfpgApplication.ActivateHint(), then the problem is fixed But that's not a solution, because now you can't customise the hint window - like is done in the 'hintwindow' example... eg: changing border color, changing shadow color etc.
I also looked at not creating a hidden hint window in TfpgApplication.InternalInit(), and instead only create a hint window when it is really needed. But then there is the same issue about not being able to customise the default hintwindow settings (like what the 'hintwindow' example does) - unless we come up with an alternative solution to customising the default hint window. eg: via a style class, and a record property for things like Margin, Border Color, Shadow etc. I actually like this last idea a lot (moving customisations to a Style class), because I don't think creating a hint window at application start, and then immediately hiding it in case we need it later is a good use of resources.
Hello,
For information, your problems may be related with issue #99. Before this fix\check, my Hints properties were no longer displayed (under the X11 layer, whereas they worked perfectly under the GDI layer), as soon as a property was an empty string: for example, if only one Hint was affected with '', then all the others were no longer displayed.