~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to components/tachart/tadraweraggpas.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
 *****************************************************************************
 
3
 *                                                                           *
 
4
 *  See the file COPYING.modifiedLGPL.txt, included in this distribution,    *
 
5
 *  for details about the copyright.                                         *
 
6
 *                                                                           *
 
7
 *  This program is distributed in the hope that it will be useful,          *
 
8
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 
9
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
 
10
 *                                                                           *
 
11
 *****************************************************************************
 
12
 
 
13
Authors: Alexander Klenin
 
14
 
 
15
}
 
16
unit TADrawerAggPas;
 
17
 
 
18
{$H+}
 
19
 
 
20
interface
 
21
 
 
22
uses
 
23
  Classes, FPCanvas, Agg_LCL, TAChartUtils, TADrawUtils;
 
24
 
 
25
type
 
26
 
 
27
  { TAggPasDrawer }
 
28
 
 
29
  TAggPasDrawer = class(TBasicDrawer, IChartDrawer)
 
30
  strict private
 
31
    FCanvas: TAggLCLCanvas;
 
32
    procedure SetBrush(ABrush: TFPCustomBrush);
 
33
    procedure SetFont(AFont: TFPCustomFont);
 
34
    procedure SetPen(APen: TFPCustomPen);
 
35
  strict protected
 
36
    function GetFontAngle: Double; override;
 
37
    function SimpleTextExtent(const AText: String): TPoint; override;
 
38
    procedure SimpleTextOut(AX, AY: Integer; const AText: String); override;
 
39
  public
 
40
    constructor Create(ACanvas: TAggLCLCanvas);
 
41
  public
 
42
    procedure AddToFontOrientation(ADelta: Integer);
 
43
    procedure ClippingStart;
 
44
    procedure ClippingStart(const AClipRect: TRect);
 
45
    procedure ClippingStop;
 
46
    procedure Ellipse(AX1, AY1, AX2, AY2: Integer);
 
47
    procedure FillRect(AX1, AY1, AX2, AY2: Integer);
 
48
    function GetBrushColor: TChartColor;
 
49
    procedure Line(AX1, AY1, AX2, AY2: Integer);
 
50
    procedure Line(const AP1, AP2: TPoint);
 
51
    procedure LineTo(AX, AY: Integer); override;
 
52
    procedure MoveTo(AX, AY: Integer); override;
 
53
    procedure Polygon(
 
54
      const APoints: array of TPoint; AStartIndex, ANumPts: Integer); override;
 
55
    procedure Polyline(
 
56
      const APoints: array of TPoint; AStartIndex, ANumPts: Integer);
 
57
    procedure PrepareSimplePen(AColor: TChartColor);
 
58
    procedure RadialPie(
 
59
      AX1, AY1, AX2, AY2: Integer;
 
60
      AStartAngle16Deg, AAngleLength16Deg: Integer);
 
61
    procedure Rectangle(const ARect: TRect);
 
62
    procedure Rectangle(AX1, AY1, AX2, AY2: Integer);
 
63
    procedure SetBrushColor(AColor: TChartColor);
 
64
    procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor);
 
65
    procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
 
66
  end;
 
67
 
 
68
implementation
 
69
 
 
70
uses
 
71
  Math, TAGeometry;
 
72
 
 
73
{ TAggPasDrawer }
 
74
 
 
75
procedure TAggPasDrawer.AddToFontOrientation(ADelta: Integer);
 
76
begin
 
77
  with FCanvas.Font do
 
78
    AggAngle := AggAngle + OrientToRad(ADelta);
 
79
end;
 
80
 
 
81
procedure TAggPasDrawer.ClippingStart(const AClipRect: TRect);
 
82
begin
 
83
  FCanvas.ClipRect := AClipRect;
 
84
  FCanvas.Clipping := true;
 
85
end;
 
86
 
 
87
procedure TAggPasDrawer.ClippingStart;
 
88
begin
 
89
  FCanvas.Clipping := true;
 
90
end;
 
91
 
 
92
procedure TAggPasDrawer.ClippingStop;
 
93
begin
 
94
  FCanvas.Clipping := false;
 
95
end;
 
96
 
 
97
constructor TAggPasDrawer.Create(ACanvas: TAggLCLCanvas);
 
98
begin
 
99
  inherited Create;
 
100
  FCanvas := ACanvas;
 
101
end;
 
102
 
 
103
procedure TAggPasDrawer.Ellipse(AX1, AY1, AX2, AY2: Integer);
 
104
begin
 
105
  FCanvas.Ellipse(AX1, AY1, AX2, AY2);
 
106
end;
 
107
 
 
108
procedure TAggPasDrawer.FillRect(AX1, AY1, AX2, AY2: Integer);
 
109
begin
 
110
  FCanvas.FillRect(AX1, AY1, AX2, AY2);
 
111
end;
 
112
 
 
113
function TAggPasDrawer.GetBrushColor: TChartColor;
 
114
begin
 
115
  Result := FCanvas.Brush.Color;
 
116
end;
 
117
 
 
118
function TAggPasDrawer.GetFontAngle: Double;
 
119
begin
 
120
  Result := FCanvas.Font.AggAngle;
 
121
end;
 
122
 
 
123
procedure TAggPasDrawer.Line(AX1, AY1, AX2, AY2: Integer);
 
124
begin
 
125
  FCanvas.Line(AX1, AY1, AX2, AY2);
 
126
end;
 
127
 
 
128
procedure TAggPasDrawer.Line(const AP1, AP2: TPoint);
 
129
begin
 
130
  FCanvas.Line(AP1, AP2);
 
131
end;
 
132
 
 
133
procedure TAggPasDrawer.LineTo(AX, AY: Integer);
 
134
begin
 
135
  FCanvas.LineTo(AX, AY);
 
136
end;
 
137
 
 
138
procedure TAggPasDrawer.MoveTo(AX, AY: Integer);
 
139
begin
 
140
  FCanvas.MoveTo(AX, AY);
 
141
end;
 
142
 
 
143
procedure TAggPasDrawer.Polygon(
 
144
  const APoints: array of TPoint; AStartIndex, ANumPts: Integer);
 
145
begin
 
146
  if ANumPts <= 0 then exit;
 
147
  FCanvas.Polygon(APoints, false, AStartIndex, ANumPts);
 
148
  FCanvas.Polyline(APoints, AStartIndex, ANumPts);
 
149
  FCanvas.Line(APoints[ANumPts - 1], APoints[0])
 
150
end;
 
151
 
 
152
procedure TAggPasDrawer.Polyline(
 
153
  const APoints: array of TPoint; AStartIndex, ANumPts: Integer);
 
154
begin
 
155
  FCanvas.Polyline(APoints, AStartIndex, ANumPts);
 
156
end;
 
157
 
 
158
procedure TAggPasDrawer.PrepareSimplePen(AColor: TChartColor);
 
159
begin
 
160
  with FCanvas.Pen do begin
 
161
    Color := AColor;
 
162
    Style := psSolid;
 
163
    Mode := pmCopy;
 
164
    Width := 1;
 
165
  end;
 
166
end;
 
167
 
 
168
procedure TAggPasDrawer.RadialPie(
 
169
  AX1, AY1, AX2, AY2: Integer;
 
170
  AStartAngle16Deg, AAngleLength16Deg: Integer);
 
171
begin
 
172
  FCanvas.RadialPie(
 
173
    AX1, AY1, AX2, AY2, AStartAngle16Deg, AAngleLength16Deg);
 
174
end;
 
175
 
 
176
procedure TAggPasDrawer.Rectangle(AX1, AY1, AX2, AY2: Integer);
 
177
begin
 
178
  FCanvas.Rectangle(AX1, AY1, AX2, AY2);
 
179
end;
 
180
 
 
181
procedure TAggPasDrawer.Rectangle(const ARect: TRect);
 
182
begin
 
183
  FCanvas.Rectangle(ARect);
 
184
end;
 
185
 
 
186
procedure TAggPasDrawer.SetBrush(ABrush: TFPCustomBrush);
 
187
begin
 
188
  with FCanvas.Brush do begin
 
189
    Style := ABrush.Style;
 
190
    Image := ABrush.Image;
 
191
    Pattern := ABrush.Pattern;
 
192
    FPColor := ABrush.FPColor;
 
193
  end;
 
194
end;
 
195
 
 
196
procedure TAggPasDrawer.SetBrushColor(AColor: TChartColor);
 
197
begin
 
198
  FCanvas.Brush.Color := AColor;
 
199
end;
 
200
 
 
201
procedure TAggPasDrawer.SetBrushParams(
 
202
  AStyle: TFPBrushStyle; AColor: TChartColor);
 
203
begin
 
204
  FCanvas.Brush.Color := AColor;
 
205
  FCanvas.Brush.Style := AStyle;
 
206
end;
 
207
 
 
208
procedure TAggPasDrawer.SetFont(AFont: TFPCustomFont);
 
209
const
 
210
  DEFAULT_FONT_SIZE = 10; // Just a random value.
 
211
var
 
212
  f: TAggLCLFont;
 
213
  fontSize: Integer;
 
214
begin
 
215
  f := FCanvas.Font;
 
216
  fontSize := IfThen(AFont.Size = 0, DEFAULT_FONT_SIZE, AFont.Size);
 
217
  // This should be: FCanvas.Font.DoCopyProps(AFont);
 
218
  f.LoadFromFile(
 
219
    AFont.Name, f.SizeToAggHeight(fontSize), AFont.Bold, AFont.Italic);
 
220
  f.FPColor := AFont.FPColor;
 
221
  f.AggAngle := OrientToRad(-FGetFontOrientationFunc(AFont));
 
222
end;
 
223
 
 
224
type
 
225
  TAggLCLPenCrack = class(TAggLCLPen);
 
226
 
 
227
procedure TAggPasDrawer.SetPen(APen: TFPCustomPen);
 
228
begin
 
229
  TAggLCLPenCrack(FCanvas.Pen).DoCopyProps(APen);
 
230
  FCanvas.Pen.FPColor := APen.FPColor;
 
231
end;
 
232
 
 
233
procedure TAggPasDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
 
234
begin
 
235
  FCanvas.Pen.Style := AStyle;
 
236
  FCanvas.Pen.Color := AColor;
 
237
end;
 
238
 
 
239
function TAggPasDrawer.SimpleTextExtent(const AText: String): TPoint;
 
240
begin
 
241
  Result := FCanvas.TextExtent(AText);
 
242
end;
 
243
 
 
244
procedure TAggPasDrawer.SimpleTextOut(AX, AY: Integer; const AText: String);
 
245
begin
 
246
  FCanvas.TextOut(AX, AY, AText);
 
247
end;
 
248
 
 
249
initialization
 
250
  // Suppress incorrect "TAGeometry is unused" hint
 
251
  Unused(DoublePoint(0, 0));
 
252
 
 
253
end.
 
254