mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 11:39:55 +02:00
example: mediator: using canvas save/restore instead of savedc/restoredc
git-svn-id: trunk@22641 -
This commit is contained in:
parent
42d44be9aa
commit
d374dcd7b2
@ -168,10 +168,7 @@ procedure TMyWidgetMediator.Paint;
|
|||||||
procedure PaintWidget(AWidget: TMyWidget);
|
procedure PaintWidget(AWidget: TMyWidget);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
DC: HDC;
|
|
||||||
SavedDC: HDC;
|
|
||||||
Child: TMyWidget;
|
Child: TMyWidget;
|
||||||
SavedDC2: HDC;
|
|
||||||
begin
|
begin
|
||||||
with LCLForm.Canvas do begin
|
with LCLForm.Canvas do begin
|
||||||
// fill background
|
// fill background
|
||||||
@ -191,25 +188,24 @@ procedure TMyWidgetMediator.Paint;
|
|||||||
// caption
|
// caption
|
||||||
TextOut(5,2,AWidget.Caption);
|
TextOut(5,2,AWidget.Caption);
|
||||||
// childs
|
// childs
|
||||||
DC:=Handle;
|
|
||||||
if AWidget.ChildCount>0 then begin
|
if AWidget.ChildCount>0 then begin
|
||||||
SavedDC:=SaveDC(DC);
|
SaveHandleState;
|
||||||
// clip client area
|
// clip client area
|
||||||
MoveWindowOrgEx(DC,AWidget.BorderLeft,AWidget.BorderTop);
|
MoveWindowOrgEx(Handle,AWidget.BorderLeft,AWidget.BorderTop);
|
||||||
if IntersectClipRect(DC, 0, 0, AWidget.Width-AWidget.BorderLeft-AWidget.BorderRight,
|
if IntersectClipRect(Handle, 0, 0, AWidget.Width-AWidget.BorderLeft-AWidget.BorderRight,
|
||||||
AWidget.Height-AWidget.BorderTop-AWidget.BorderBottom)<>NullRegion
|
AWidget.Height-AWidget.BorderTop-AWidget.BorderBottom)<>NullRegion
|
||||||
then begin
|
then begin
|
||||||
for i:=0 to AWidget.ChildCount-1 do begin
|
for i:=0 to AWidget.ChildCount-1 do begin
|
||||||
SavedDC2:=SaveDC(DC);
|
SaveHandleState;
|
||||||
Child:=AWidget.Childs[i];
|
Child:=AWidget.Childs[i];
|
||||||
// clip child area
|
// clip child area
|
||||||
MoveWindowOrgEx(DC,Child.Left,Child.Top);
|
MoveWindowOrgEx(Handle,Child.Left,Child.Top);
|
||||||
if IntersectClipRect(DC,0,0,Child.Width,Child.Height)<>NullRegion then
|
if IntersectClipRect(Handle,0,0,Child.Width,Child.Height)<>NullRegion then
|
||||||
PaintWidget(Child);
|
PaintWidget(Child);
|
||||||
RestoreDC(DC,SavedDC2);
|
RestoreHandleState;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
RestoreDC(DC,SavedDC);
|
RestoreHandleState;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user