Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2010-03

#15882: "QT: automatic tool tip window tries to draw beyond screen boundaries and fails."

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

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;
zeljko
to Juha Manninen: I found something interesting about issue #15882. The problem is not about drawing beyond…
Juha Manninen wrote 14 lines
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.

No, it uses QToolTip flag in constructor and it is QToolTip. () (qtwidgets) and
TQtWSHintWindow.CreateHandle() (qtwsforms).
QToolTipH doesn't have constructor.

Show quoted text 11 lines
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?)

Don't know, Paul commited that wierd piece of code http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/qt/qtwidgets.pas?root=lazarus&view=diff&r1=15148&r2=15149 Seem like useless code.

zeljko

Juha Manninen
to zeljko

The hint window is now much better but still not perfect. I added a note to the issue.
Now, why can't the cursor be on the hint window area? Is it an inherent limitation in QT?

On Friday I can inspect more the big debug hints. Now I am busy with many exams.

Juha

zeljko
to Juha Manninen
Juha Manninen wrote
The hint window is now much better but still not perfect. I added a note to the issue.

hmm, I'll optimize a bit positioning algorithm in that case.

Now, why can't the cursor be on the hint window area? Is it an inherent limitation in QT?

yes.

On Friday I can inspect more the big debug hints. Now I am busy with many exams.

ok.