blob: 874d4083f872e2a3628ce5ca9d3ef8804155b588 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
{%MainUnit fpcanvas.pp}
{
This file is part of the Free Pascal run time library.
Copyright (c) 2003 by the Free Pascal development team
Implementation of TFPCanvasHelper
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{ TFPCanvasHelper }
constructor TFPCanvasHelper.Create;
begin
inherited create;
FCanvas := nil;
FFixedCanvas := false;
FAllocated := false;
end;
destructor TFPCanvasHelper.destroy;
begin
if Allocated then
DeAllocateResources;
inherited;
end;
procedure TFPCanvasHelper.SetFixedCanvas (AValue : boolean);
begin
FFixedCanvas := AValue;
end;
procedure TFPCanvasHelper.NotifyCanvas;
// called to unbind from canvas
begin
if FCanvas<>nil then
FCanvas.CheckHelper (self);
end;
procedure TFPCanvasHelper.CheckAllocated (ValueNeeded:boolean);
procedure RaiseErrAllocation;
begin
Raise TFPFontException.CreateFmt (ErrAllocation,
[EFont, ErrAlloc[ValueNeeded]]);
end;
begin
if (Allocated <> ValueNeeded) then
RaiseErrAllocation;
end;
procedure TFPCanvasHelper.SetFPColor(const AValue:TFPColor);
begin
FFPColor := AValue;
end;
procedure TFPCanvasHelper.Changing;
begin
if Assigned(FOnChanging) then FOnChanging(Self);
end;
procedure TFPCanvasHelper.Changed;
begin
if Assigned(FOnChange) then FOnChange(Self);
end;
procedure TFPCanvasHelper.Lock;
begin
end;
procedure TFPCanvasHelper.UnLock;
begin
end;
procedure TFPCanvasHelper.SetFlags (index:integer; AValue:boolean);
begin
if AValue then
FFlags := FFlags or (1 shl index)
else
FFlags := FFlags and not (1 shl index);
end;
function TFPCanvasHelper.GetFlags (index:integer) : boolean;
begin
result := (FFlags and (1 shl index)) <> 0;
end;
function TFPCanvasHelper.GetAllocated : boolean;
begin
if FFixedCanvas then
result := assigned(FCanvas)
else
result := FAllocated;
end;
procedure TFPCanvasHelper.AllocateResources (ACanvas : TFPCustomCanvas;
CanDelay: boolean);
begin
if FFixedCanvas and FAllocated then
DeallocateResources;
FCanvas := ACanvas;
if DelayAllocate and CanDelay then exit;
try
DoAllocateResources;
FAllocated := True;
except
FCanvas := nil;
FAllocated := False;
end;
end;
procedure TFPCanvasHelper.DeallocateResources;
begin
if FAllocated then
try
DoDeallocateResources;
finally
FAllocated := false;
NotifyCanvas;
FCanvas := nil;
end;
end;
procedure TFPCanvasHelper.DoCopyProps (From:TFPCanvasHelper);
begin
FPColor := from.FPColor;
end;
procedure TFPCanvasHelper.DoAllocateResources;
begin
end;
procedure TFPCanvasHelper.DoDeallocateResources;
begin
end;
|