53
52
------------------------------------------------------------------------------}
54
53
procedure TRegion.Assign(Source : Tpersistent);
58
Self.ClipRect := TRegion(Source).ClipRect;
59
//TODO : Get Polygon INFO
55
if Source is TRegion then
63
60
inherited Assign(Source);
63
procedure TRegion.AddRectangle(X1, Y1, X2, Y2: Integer);
68
lRGN := CreateRectRgn(X1, Y1, X2, Y2);
69
CombineRgn(FReference.Handle, FReference.Handle, lRGN, RGN_OR);
66
73
{------------------------------------------------------------------------------
67
74
Method: TRegion.SetHandle
68
75
Params: a region handle
72
79
------------------------------------------------------------------------------}
73
80
procedure TRegion.SetHandle(const Value: HRGN);
75
if HRGN(FRegionData.Reference.Handle) = Value then Exit;
82
if HRGN(FReference.Handle) = Value then Exit;
78
FRegionData.Reference._lclHandle := TLCLHandle(Value);
79
FRegionData.Rect := GetClipRect;
80
//TODO: query polygon params
85
FReference._lclHandle := TLCLHandle(Value);
86
//TODO: query region description data
96
102
function TRegion.GetReference: TWSRegionReference;
99
Result := FRegionData.Reference;
105
Result := FReference;
102
108
procedure TRegion.ReferenceNeeded;
111
// lSource1, lSource2, lDest: HRGN;
106
if FRegionData.Reference.Allocated then Exit;
108
if FRegionData.Polygon <> nil
110
if FRegionData.Winding
111
then FillMode := Winding
112
else FillMode := Alternate;
114
FRegionData.Reference._lclHandle := TLCLHandle(CreatePolygonRgn(
115
FRegionData.Polygon, FRegionData.NumPoints, FillMode));
119
with FRegionData.Rect do
113
if FReference.Allocated then Exit;
115
FReference._lclHandle := TLCLHandle(CreateRectRgn(0, 0, 0, 0));
117
{ At the moment all operations are executed on a live handle, so not yet used
119
for i := 0 to Length(RegionOperations) - 1 do
121
if (Right - Left <> 0) or (Bottom - Top <> 0)
123
FRegionData.Reference._lclHandle := TLCLHandle(CreateRectRgn(Left, Top, Right, Bottom));
121
// TRegionCombineMode = (rgnAnd, rgnCopy, rgnDiff, rgnOr, rgnXOR);
122
case RegionOperations[i].ROType of
125
lDest := LCLIntf.CreateRectRgn(
126
RegionOperations[i].Rect.Left, RegionOperations[i].Rect.Top,
127
RegionOperations[i].Rect.Left + RegionOperations[i].Rect.Width,
128
RegionOperations[i].Rect.Top + RegionOperations[i].Rect.Height);
133
RegionOperations[i].CombineMode:=;
135
CombineRgn(lDest, lSource1, lSource2);
138
Source1, Source2, Dest: Integer; // Index to the list of sub-regions, -1 indicates the main region
139
CombineMode: TRegionCombineMode; // Used only if ROType=rgnCombine
140
Rect: TRect; // Used for ROType=rgnNewRect
130
144
{------------------------------------------------------------------------------
135
149
Frees a region handle if needed
136
150
------------------------------------------------------------------------------}
152
procedure TRegion.AddOperation(AOp: TRegionOperation);
157
procedure TRegion.ClearSubRegions();
162
procedure TRegion.AddSubRegion(AHandle: HRGN);
138
167
procedure TRegion.FreeReference;
140
if not FRegionData.Reference.Allocated then Exit;
169
if not FReference.Allocated then Exit;
142
DeleteObject(HGDIOBJ(FRegionData.Reference.Handle));
143
FRegionData.Reference._lclHandle := 0;
171
DeleteObject(HGDIOBJ(FReference.Handle));
172
FReference._lclHandle := 0;
146
175
{------------------------------------------------------------------------------
152
181
------------------------------------------------------------------------------}
153
182
procedure TRegion.SetClipRect(Value : TRect);
155
if FRegionData.Rect = Value then Exit;
158
FRegionData.Rect := Value;
159
if FRegionData.Polygon <> nil then
160
ReallocMem(FRegionData.Polygon, 0);
162
FRegionData.Polygon := nil;
163
FRegionData.NumPoints := 0;
164
FRegionData.Winding := False;
184
// if ClipRect = Value then Exit;
187
// ClipRect := Value;
169
192
{------------------------------------------------------------------------------
175
198
------------------------------------------------------------------------------}
176
199
function TRegion.GetClipRect : TRect;
178
if FRegionData.Reference.Allocated
201
Result := Rect(0, 0, 0, 0);
202
// Result := ClipRect;
203
{ if FRegionData.Reference.Allocated
180
205
GetRgnBox(HRGN(FRegionData.Reference.Handle), @Result);