diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index e955667aa0..9babce5c5b 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -151,6 +151,8 @@ type function getGeometry: TRect; virtual; function getVisible: Boolean; virtual; function getText: WideString; virtual; + function getHeight: Integer; + function getWidth: Integer; procedure grabMouse; virtual; function hasFocus: Boolean; virtual; procedure lowerWidget; @@ -2264,6 +2266,16 @@ begin Result := FText; end; +function TQtWidget.getHeight: Integer; +begin + Result := QWidget_height(Widget); +end; + +function TQtWidget.getWidth: Integer; +begin + Result := QWidget_width(Widget); +end; + function TQtWidget.getClientBounds: TRect; begin QWidget_contentsRect(Widget, @Result); diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 370783b553..bd29b910b5 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -2334,19 +2334,67 @@ begin end; function TQtWidgetSet.GetScrollBarSize(Handle: HWND; BarKind: Integer): integer; +var + w: TQtWidget; + ScrollBar: TQtScrollBar; begin - Result := 15; - {$ifdef VerboseQtWinAPI_MISSING_IMPLEMENTATION} - WriteLn('***** [WinAPI TQtWidgetSet.GetScrollBarSize] missing implementation '); + {$ifdef VerboseQtWinAPI} + writeln('Trace:> [WinAPI GetScrollBarSize] Handle: ' + dbghex(Handle),' BarKind: ',BarKind); {$endif} + Result := 0; + if Handle = 0 then exit; + + w := TQtWidget(Handle); + + {TODO: find out what to do with TCustomForm descendants } + if w is TQtAbstractScrollArea then + begin + if BarKind = SM_CYVSCROLL then + ScrollBar := TQtAbstractScrollArea(w).verticalScrollBar + else + ScrollBar := TQtAbstractScrollArea(w).horizontalScrollBar; + end else + if w is TQtScrollBar then + ScrollBar := TQtScrollBar(w) + else + ScrollBar := nil; + if ScrollBar <> nil then + begin + if BarKind = SM_CYVSCROLL then + Result := ScrollBar.getWidth + else + Result := ScrollBar.getHeight; + end; end; function TQtWidgetSet.GetScrollbarVisible(Handle: HWND; SBStyle: Integer): boolean; +var + w: TQtWidget; + ScrollBar: TQtScrollBar; begin - Result := False; - {$ifdef VerboseQtWinAPI_MISSING_IMPLEMENTATION} - WriteLn('***** [WinAPI TQtWidgetSet.GetScrollBarVisible] missing implementation '); + {$ifdef VerboseQtWinAPI} + writeln('Trace:> [WinAPI GetScrollBarVisible] Handle: ' + dbghex(Handle),' SBStyle: ',SBStyle); {$endif} + Result := False; + if Handle = 0 then exit; + + w := TQtWidget(Handle); + + {TODO: find out what to do with TCustomForm descendants } + if w is TQtAbstractScrollArea then + begin + if SBStyle = SB_VERT then + ScrollBar := TQtAbstractScrollArea(w).verticalScrollBar + else + ScrollBar := TQtAbstractScrollArea(w).horizontalScrollBar; + end else + if w is TQtScrollBar then + ScrollBar := TQtScrollBar(w) + else + ScrollBar := nil; + + if ScrollBar <> nil then + Result := ScrollBar.getVisible; end; {------------------------------------------------------------------------------