mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-12 10:00:38 +01:00
Initial implementation for restricting the visible part of a window to a region, also known as shaped windows. qt-only at the moment.
git-svn-id: trunk@18663 -
This commit is contained in:
parent
a0ffd5e9a7
commit
80be9b456a
@ -1166,7 +1166,7 @@ begin
|
|||||||
Changing;
|
Changing;
|
||||||
RequiredState([csHandleValid, csFontValid, csBrushValid]);
|
RequiredState([csHandleValid, csFontValid, csBrushValid]);
|
||||||
Flags := 0;
|
Flags := 0;
|
||||||
if TextStyle.Opaque then
|
If TextStyle.Opaque then
|
||||||
Flags := ETO_Opaque;
|
Flags := ETO_Opaque;
|
||||||
ExtUTF8Out(FHandle, X, Y, Flags, nil, PChar(Text), Length(Text), nil);
|
ExtUTF8Out(FHandle, X, Y, Flags, nil, PChar(Text), Length(Text), nil);
|
||||||
MoveTo(X + TextWidth(Text), Y);
|
MoveTo(X + TextWidth(Text), Y);
|
||||||
|
|||||||
@ -1472,6 +1472,12 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TWidgetset.SetWindowRgn(hWnd: HWND;
|
||||||
|
hRgn: HRGN; bRedraw: Boolean):longint;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
function TWidgetSet.ShowCaret(hWnd: HWND): Boolean;
|
function TWidgetSet.ShowCaret(hWnd: HWND): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|||||||
@ -820,6 +820,11 @@ begin
|
|||||||
Result := WidgetSet.SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
|
Result := WidgetSet.SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SetWindowRgn(hWnd: HWND; hRgn: HRGN; bRedraw: Boolean):longint;
|
||||||
|
begin
|
||||||
|
Result := WidgetSet.SetWindowRgn(hWnd, hRgn, bRedraw);
|
||||||
|
end;
|
||||||
|
|
||||||
function ShowCaret(hWnd: HWND): Boolean;
|
function ShowCaret(hWnd: HWND): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := WidgetSet.ShowCaret(hWnd)
|
Result := WidgetSet.ShowCaret(hWnd)
|
||||||
|
|||||||
@ -226,6 +226,7 @@ function SetWindowLong(Handle: HWND; Idx: Integer; NewLong : PtrInt): PtrInt;{$I
|
|||||||
function SetWindowOrgEx(dc : hdc; NewX, NewY : Integer; OldPoint: PPoint): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function SetWindowOrgEx(dc : hdc; NewX, NewY : Integer; OldPoint: PPoint): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND;
|
function SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND;
|
||||||
X, Y, cx, cy: Integer; uFlags: UINT): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
X, Y, cx, cy: Integer; uFlags: UINT): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
|
function SetWindowRgn(hWnd: HWND; hRgn: HRGN; bRedraw: Boolean):longint; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function ShowCaret(hWnd: HWND): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function ShowCaret(hWnd: HWND): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function ShowScrollBar(Handle: HWND; wBar: Integer; bShow: Boolean): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function ShowScrollBar(Handle: HWND; wBar: Integer; bShow: Boolean): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
|
|||||||
@ -1607,7 +1607,9 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
// Creates the widget
|
// Creates the widget
|
||||||
if CreateHandle then Widget := QRegion_create(X1,Y1,X2,Y2, RegionType);
|
// Note that QRegion_create expects a width and a height,
|
||||||
|
// and not a X2, Y2 bottom-right point
|
||||||
|
if CreateHandle then Widget := QRegion_create(X1,Y1,X2-X1,Y2-Y1, RegionType);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TQtRegion.Create(CreateHandle: Boolean; Poly: QPolygonH;
|
constructor TQtRegion.Create(CreateHandle: Boolean; Poly: QPolygonH;
|
||||||
|
|||||||
@ -202,7 +202,8 @@ type
|
|||||||
procedure setGeometry(ARect: TRect); overload;
|
procedure setGeometry(ARect: TRect); overload;
|
||||||
procedure setLayoutDirection(ADirection: QtLayoutDirection);
|
procedure setLayoutDirection(ADirection: QtLayoutDirection);
|
||||||
procedure setMaximumSize(AWidth, AHeight: Integer);
|
procedure setMaximumSize(AWidth, AHeight: Integer);
|
||||||
procedure setMask(AMask: QBitmapH);
|
procedure setMask(AMask: QBitmapH); overload;
|
||||||
|
procedure setMask(AMask: QRegionH); overload;
|
||||||
procedure setMinimumSize(AWidth, AHeight: Integer);
|
procedure setMinimumSize(AWidth, AHeight: Integer);
|
||||||
procedure setParent(parent: QWidgetH); virtual;
|
procedure setParent(parent: QWidgetH); virtual;
|
||||||
procedure setText(const W: WideString); virtual;
|
procedure setText(const W: WideString); virtual;
|
||||||
@ -3013,6 +3014,11 @@ begin
|
|||||||
QWidget_setMask(Widget, AMask);
|
QWidget_setMask(Widget, AMask);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TQtWidget.setMask(AMask: QRegionH);
|
||||||
|
begin
|
||||||
|
QWidget_setMask(Widget, AMask);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TQtWidget.setMinimumSize(AWidth, AHeight: Integer);
|
procedure TQtWidget.setMinimumSize(AWidth, AHeight: Integer);
|
||||||
begin
|
begin
|
||||||
QWidget_setMinimumSize(Widget, AWidth, AHeight);
|
QWidget_setMinimumSize(Widget, AWidth, AHeight);
|
||||||
|
|||||||
@ -493,7 +493,10 @@ end;
|
|||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: CreateEllipticRgn
|
Function: CreateEllipticRgn
|
||||||
Params: p1, p2, p3, p4: Integer
|
Params: p1 - X position of the top-left corner
|
||||||
|
p2 - Y position of the top-left corner
|
||||||
|
p3 - X position of the bottom-right corner
|
||||||
|
p4 - Y position of the bottom-right corner
|
||||||
Returns: HRGN
|
Returns: HRGN
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TQtWidgetSet.CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN;
|
function TQtWidgetSet.CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN;
|
||||||
@ -4449,6 +4452,43 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: SetWindowRgn
|
||||||
|
Params: hWnd - handle of the widget
|
||||||
|
hRgn - handle of the region
|
||||||
|
bRedraw - ?
|
||||||
|
Returns: 0 if the call failed, any other value if it was successful
|
||||||
|
|
||||||
|
Makes the region specifyed in hRgn be the only part of the window which is
|
||||||
|
visible.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TQtWidgetSet.SetWindowRgn(hWnd: HWND;
|
||||||
|
hRgn: HRGN; bRedraw: Boolean):longint;
|
||||||
|
var
|
||||||
|
w: TQtWidget;
|
||||||
|
r: TQtRegion;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
|
||||||
|
{$ifdef VerboseQtWinAPI}
|
||||||
|
WriteLn('[WinAPI SetWindowRgn] Handle: ', dbghex(hWnd));
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
// Basic checks
|
||||||
|
|
||||||
|
if (hWnd = 0) then Exit;
|
||||||
|
|
||||||
|
w := TQtWidget(hWnd);
|
||||||
|
|
||||||
|
r := TQtRegion(hRgn);
|
||||||
|
|
||||||
|
// Now set the mask in the widget
|
||||||
|
|
||||||
|
w.setMask(r.Widget);
|
||||||
|
|
||||||
|
Result := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
function TQtWidgetSet.ShowCaret(hWnd: HWND): Boolean;
|
function TQtWidgetSet.ShowCaret(hWnd: HWND): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := (hWnd <> 0) and (QtCaret.ShowCaret(TQtWidget(hWnd)));
|
Result := (hWnd <> 0) and (QtCaret.ShowCaret(TQtWidget(hWnd)));
|
||||||
|
|||||||
@ -177,6 +177,7 @@ function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;
|
|||||||
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;
|
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;
|
||||||
function SetTextColor(DC: HDC; Color: TColorRef): TColorRef; override;
|
function SetTextColor(DC: HDC; Color: TColorRef): TColorRef; override;
|
||||||
function SetWindowOrgEx(DC : HDC; NewX, NewY : Integer; OldPoint: PPoint) : Boolean; override;
|
function SetWindowOrgEx(DC : HDC; NewX, NewY : Integer; OldPoint: PPoint) : Boolean; override;
|
||||||
|
function SetWindowRgn(hWnd: HWND; hRgn: HRGN; bRedraw: Boolean):longint; override;
|
||||||
function ShowCaret(hWnd: HWND): Boolean; override;
|
function ShowCaret(hWnd: HWND): Boolean; override;
|
||||||
function ShowScrollBar(Handle: HWND; wBar: Integer; bShow: Boolean): Boolean; override;
|
function ShowScrollBar(Handle: HWND; wBar: Integer; bShow: Boolean): Boolean; override;
|
||||||
function ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean; override;
|
function ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean; override;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user