[Qt] #15882: "QT: automatic tool tip window tries to draw beyond screen boundaries and fails."
Juha Manninen
juha.manninen at phnet.fi
Mon Mar 8 14:27:19 CET 2010
Zeljko,
I found something interesting about issue #15882.
The problem is not about drawing beyond screen boundaries.
In THintWindow.ActivateHintData, I commented out the offset calculation which
moves the window up / left so it is fully visible. After that the tool tip
windows show up nicely, only the bottom / right part is cropped off by screen
boundary.
I can't explain why it happens. The offset code looks correct and it works
correctly with other widgetsets.
If I understand right, the QT's builtin tooltip class (QToolTipH) is not used
for LCL tooltip but it is created from CustomForm.
I guess all widgetsets support tooltips. LCL should be changed accordingly.
That would surely solve this problem in QT as well.
In:
procedure TQtWidget.SlotPaint(Sender: QObjectH; Event: QEventH); cdecl;
I noticed this:
if LCLObject is THintWindow then
Msg.DC := Msg.DC;
It looks useless but maybe it has some meaning. (for debugging only?)
Regards,
Juha
-------------------
procedure THintWindow.ActivateHintData(ARect: TRect; const AHint: String;
AData: pointer);
var
InvalidateNeeded: Boolean;
AMonitor: TMonitor;
ABounds: TRect;
begin
if FActivating then exit;
FActivating := True;
try
//debugln('THintWindow.ActivateHint OldHint="',DbgStr(Caption),'"
NewHint="',DbgStr(AHint),'"');
InvalidateNeeded := Visible and (Caption <> AHint);
Caption := AHint;
AMonitor := Screen.MonitorFromPoint(ARect.TopLeft);
ABounds := AMonitor.BoundsRect;
// limit width, height by monitor
if (ARect.Right - ARect.Left) > (ABounds.Right - ABounds.Left) then
ARect.Right := ARect.Left + (ABounds.Right - ABounds.Left);
if (ARect.Bottom - ARect.Top) > (ABounds.Bottom - ABounds.Top) then
ARect.Bottom := ARect.Top + (ABounds.Bottom - ABounds.Top);
// offset hint to fit into monitor
{ if ARect.Bottom > ABounds.Bottom then
begin
ARect.Top := ABounds.Bottom - (ARect.Bottom - ARect.Top);
ARect.Bottom := ABounds.Bottom;
end;
if ARect.Right > ABounds.Right then
begin
ARect.Left := ABounds.Right - (ARect.Right - ARect.Left);
ARect.Right := ABounds.Right;
end;
}
if ARect.Left < ABounds.Left then ARect.Left := ABounds.Left;
if ARect.Top < ABounds.Top then ARect.Top := ABounds.Top;
SetBounds(ARect.Left, ARect.Top,
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
Visible := True;
TCustomTimer(FAutoHideTimer).Enabled := False;
TCustomTimer(FAutoHideTimer).Enabled := FAutoHide;
if InvalidateNeeded then Invalidate;
finally
FActivating := False;
end;
end;
More information about the Qt
mailing list