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

« back to all changes in this revision

Viewing changes to components/aggpas/src/agg_rounded_rect.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
 
// Anti-Grain Geometry - Version 2.4 (Public License)
3
 
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4
 
//
5
 
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6
 
// Pascal Port By: Milan Marusinec alias Milano
7
 
//                 milan@marusinec.sk
8
 
//                 http://www.aggpas.org
9
 
// Copyright (c) 2005-2006
10
 
//
11
 
// Permission to copy, use, modify, sell and distribute this software
12
 
// is granted provided this copyright notice appears in all copies.
13
 
// This software is provided "as is" without express or implied
14
 
// warranty, and with no claim as to its suitability for any purpose.
15
 
//
16
 
//----------------------------------------------------------------------------
17
 
// Contact: mcseem@antigrain.com
18
 
//          mcseemagg@yahoo.com
19
 
//          http://www.antigrain.com
20
 
//
21
 
//----------------------------------------------------------------------------
22
 
//
23
 
// Rounded rectangle vertex generator
24
 
//
25
 
// [Pascal Port History] -----------------------------------------------------
26
 
//
27
 
// 17.01.2006-Milano: Unit port establishment
28
 
//
29
 
{ agg_rounded_rect.pas }
30
 
unit
31
 
 agg_rounded_rect ;
32
 
 
33
 
INTERFACE
34
 
 
35
 
{$I agg_mode.inc }
36
 
 
37
 
uses
38
 
 agg_basics ,
39
 
 agg_vertex_source ,
40
 
 agg_arc ;
41
 
 
42
 
type
43
 
 rounded_rect = object(vertex_source )
44
 
   m_x1  ,
45
 
   m_y1  ,
46
 
   m_x2  ,
47
 
   m_y2  ,
48
 
   m_rx1 ,
49
 
   m_ry1 ,
50
 
   m_rx2 ,
51
 
   m_ry2 ,
52
 
   m_rx3 ,
53
 
   m_ry3 ,
54
 
   m_rx4 ,
55
 
   m_ry4 : double;
56
 
 
57
 
   m_status : unsigned;
58
 
   m_arc    : arc;
59
 
 
60
 
   constructor Construct; overload;
61
 
   constructor Construct(x1 ,y1 ,x2 ,y2 ,r : double ); overload;
62
 
 
63
 
   procedure rect(x1 ,y1 ,x2 ,y2 : double );
64
 
 
65
 
   procedure radius(r : double ); overload;
66
 
   procedure radius(rx ,ry : double ); overload;
67
 
   procedure radius(rx_bottom ,ry_bottom ,rx_top ,ry_top : double ); overload;
68
 
   procedure radius(rx1 ,ry1 ,rx2 ,ry2 ,rx3 ,ry3 ,rx4 ,ry4 : double ); overload;
69
 
 
70
 
   procedure normalize_radius;
71
 
 
72
 
   procedure approximation_scale_(s : double );
73
 
   function  _approximation_scale : double;
74
 
 
75
 
   procedure rewind(path_id : unsigned ); virtual;
76
 
   function  vertex(x ,y : double_ptr ) : unsigned; virtual;
77
 
 
78
 
  end;
79
 
 
80
 
{ GLOBAL PROCEDURES }
81
 
 
82
 
 
83
 
IMPLEMENTATION
84
 
{ LOCAL VARIABLES & CONSTANTS }
85
 
{ UNIT IMPLEMENTATION }
86
 
{ CONSTRUCT }
87
 
constructor rounded_rect.Construct;
88
 
begin
89
 
 m_x1 :=0;
90
 
 m_y1 :=0;
91
 
 m_x2 :=0;
92
 
 m_y2 :=0;
93
 
 m_rx1:=0;
94
 
 m_ry1:=0;
95
 
 m_rx2:=0;
96
 
 m_ry2:=0;
97
 
 m_rx3:=0;
98
 
 m_ry3:=0;
99
 
 m_rx4:=0;
100
 
 m_ry4:=0;
101
 
 
102
 
 m_status:=0;
103
 
 
104
 
 m_arc.Construct;
105
 
 
106
 
end;
107
 
 
108
 
{ CONSTRUCT }
109
 
constructor rounded_rect.Construct(x1 ,y1 ,x2 ,y2 ,r : double );
110
 
begin
111
 
 Construct;
112
 
 
113
 
 m_x1 :=x1;
114
 
 m_y1 :=y1;
115
 
 m_x2 :=x2;
116
 
 m_y2 :=y2;
117
 
 m_rx1:=r;
118
 
 m_ry1:=r;
119
 
 m_rx2:=r;
120
 
 m_ry2:=r;
121
 
 m_rx3:=r;
122
 
 m_ry3:=r;
123
 
 m_rx4:=r;
124
 
 m_ry4:=r;
125
 
 
126
 
 if x1 > x2 then
127
 
  begin
128
 
   m_x1:=x2;
129
 
   m_x2:=x1;
130
 
 
131
 
  end;
132
 
 
133
 
 if y1 > y2 then
134
 
  begin
135
 
   m_y1:=y2;
136
 
   m_y2:=y1;
137
 
 
138
 
  end; 
139
 
 
140
 
end;
141
 
 
142
 
{ RECT }
143
 
procedure rounded_rect.rect;
144
 
begin
145
 
 m_x1:=x1;
146
 
 m_y1:=y1;
147
 
 m_x2:=x2;
148
 
 m_y2:=y2;
149
 
 
150
 
 if x1 > x2 then
151
 
  begin
152
 
   m_x1:=x2;
153
 
   m_x2:=x1;
154
 
 
155
 
  end;
156
 
 
157
 
 if y1 > y2 then
158
 
  begin
159
 
   m_y1:=y2;
160
 
   m_y2:=y1;
161
 
 
162
 
  end;
163
 
 
164
 
end;
165
 
 
166
 
{ RADIUS }
167
 
procedure rounded_rect.radius(r : double );
168
 
begin
169
 
 m_rx1:=r;
170
 
 m_ry1:=r;
171
 
 m_rx2:=r;
172
 
 m_ry2:=r;
173
 
 m_rx3:=r;
174
 
 m_ry3:=r;
175
 
 m_rx4:=r;
176
 
 m_ry4:=r;
177
 
 
178
 
end;
179
 
 
180
 
{ RADIUS }
181
 
procedure rounded_rect.radius(rx ,ry : double );
182
 
begin
183
 
 m_rx1:=rx;
184
 
 m_rx2:=rx;
185
 
 m_rx3:=rx;
186
 
 m_rx4:=rx;
187
 
 m_ry1:=ry;
188
 
 m_ry2:=ry;
189
 
 m_ry3:=ry;
190
 
 m_ry4:=ry;
191
 
 
192
 
end;
193
 
 
194
 
{ RADIUS }
195
 
procedure rounded_rect.radius(rx_bottom ,ry_bottom ,rx_top ,ry_top : double );
196
 
begin
197
 
 m_rx1:=rx_bottom;
198
 
 m_rx2:=rx_bottom;
199
 
 m_rx3:=rx_top;
200
 
 m_rx4:=rx_top;
201
 
 m_ry1:=ry_bottom;
202
 
 m_ry2:=ry_bottom;
203
 
 m_ry3:=ry_top;
204
 
 m_ry4:=ry_top;
205
 
 
206
 
end;
207
 
 
208
 
{ RADIUS }
209
 
procedure rounded_rect.radius(rx1 ,ry1 ,rx2 ,ry2 ,rx3 ,ry3 ,rx4 ,ry4 : double );
210
 
begin
211
 
 m_rx1:=rx1;
212
 
 m_ry1:=ry1;
213
 
 m_rx2:=rx2;
214
 
 m_ry2:=ry2;
215
 
 m_rx3:=rx3;
216
 
 m_ry3:=ry3;
217
 
 m_rx4:=rx4;
218
 
 m_ry4:=ry4;
219
 
 
220
 
end;
221
 
 
222
 
{ NORMALIZE_RADIUS }
223
 
procedure rounded_rect.normalize_radius;
224
 
var
225
 
 dx ,dy  ,k ,t : double;
226
 
 
227
 
begin
228
 
 dx:=Abs(m_y2 - m_y1 );
229
 
 dy:=Abs(m_x2 - m_x1 );
230
 
 
231
 
 k:=1.0;
232
 
 
233
 
 try
234
 
  t:=dx / (m_rx1 + m_rx2 );
235
 
 
236
 
  if t < k then
237
 
   k:=t;
238
 
 
239
 
 except
240
 
 end;
241
 
 
242
 
 try
243
 
  t:=dx / (m_rx3 + m_rx4 );
244
 
 
245
 
  if t < k then
246
 
   k:=t;
247
 
 
248
 
 except
249
 
 end;
250
 
 
251
 
 try
252
 
  t:=dy / (m_ry1 + m_ry2 );
253
 
 
254
 
  if t < k then
255
 
   k:=t;
256
 
 
257
 
 except
258
 
 end;
259
 
 
260
 
 try
261
 
  t:=dy / (m_ry3 + m_ry4 );
262
 
 
263
 
  if t < k then
264
 
   k:=t;
265
 
 
266
 
 except
267
 
 end;  
268
 
 
269
 
 if k < 1.0 then
270
 
  begin
271
 
   m_rx1:=m_rx1 * k;
272
 
   m_ry1:=m_ry1 * k;
273
 
   m_rx2:=m_rx2 * k;
274
 
   m_ry2:=m_ry2 * k;
275
 
   m_rx3:=m_rx3 * k;
276
 
   m_ry3:=m_ry3 * k;
277
 
   m_rx4:=m_rx4 * k;
278
 
   m_ry4:=m_ry4 * k;
279
 
 
280
 
  end;
281
 
 
282
 
end;
283
 
 
284
 
{ APPROXIMATION_SCALE_ }
285
 
procedure rounded_rect.approximation_scale_;
286
 
begin
287
 
 m_arc.approximation_scale_(s );
288
 
 
289
 
end;
290
 
 
291
 
{ _APPROXIMATION_SCALE }
292
 
function rounded_rect._approximation_scale;
293
 
begin
294
 
 result:=m_arc._approximation_scale;
295
 
 
296
 
end;
297
 
 
298
 
{ REWIND }
299
 
procedure rounded_rect.rewind;
300
 
begin
301
 
 m_status:=0;
302
 
 
303
 
end;
304
 
 
305
 
{ VERTEX }
306
 
function rounded_rect.vertex;
307
 
var
308
 
 cmd : unsigned;
309
 
 
310
 
label
311
 
 _1 ,_2 ,_3 ,_4 ,_5 ,_6 ,_7 ,_8 ;
312
 
 
313
 
begin
314
 
 cmd:=path_cmd_stop;
315
 
 
316
 
 case m_status of
317
 
  0 :
318
 
   begin
319
 
    m_arc.init  (m_x1 + m_rx1 ,m_y1 + m_ry1 ,m_rx1 ,m_ry1 ,pi ,pi + pi * 0.5 );
320
 
    m_arc.rewind(0 );
321
 
 
322
 
    inc(m_status );
323
 
 
324
 
    goto _1;
325
 
 
326
 
   end;
327
 
 
328
 
  1 :
329
 
  _1:
330
 
   begin
331
 
    cmd:=m_arc.vertex(x ,y );
332
 
 
333
 
    if is_stop(cmd ) then
334
 
     begin
335
 
      inc(m_status );
336
 
 
337
 
      goto _2;
338
 
 
339
 
     end
340
 
    else
341
 
     begin
342
 
      result:=cmd;
343
 
 
344
 
      exit;
345
 
 
346
 
     end;
347
 
 
348
 
   end;
349
 
 
350
 
  2 :
351
 
  _2:
352
 
   begin
353
 
    m_arc.init  (m_x2 - m_rx2 ,m_y1 + m_ry2 ,m_rx2 ,m_ry2 ,pi + pi * 0.5 ,0.0 );
354
 
    m_arc.rewind(0 );
355
 
 
356
 
    inc(m_status );
357
 
 
358
 
    goto _3;
359
 
 
360
 
   end;
361
 
 
362
 
  3 :
363
 
  _3:
364
 
   begin
365
 
    cmd:=m_arc.vertex(x ,y );
366
 
 
367
 
    if is_stop(cmd ) then
368
 
     begin
369
 
      inc(m_status );
370
 
 
371
 
      goto _4;
372
 
 
373
 
     end
374
 
    else
375
 
     begin
376
 
      result:=path_cmd_line_to;
377
 
 
378
 
      exit;
379
 
 
380
 
     end;
381
 
 
382
 
   end;
383
 
 
384
 
  4 :
385
 
  _4: 
386
 
   begin
387
 
    m_arc.init  (m_x2 - m_rx3 ,m_y2 - m_ry3 ,m_rx3 ,m_ry3 ,0.0 ,pi * 0.5 );
388
 
    m_arc.rewind(0 );
389
 
 
390
 
    inc(m_status );
391
 
 
392
 
    goto _5;
393
 
 
394
 
   end;
395
 
 
396
 
  5 :
397
 
  _5:
398
 
   begin
399
 
    cmd:=m_arc.vertex(x ,y );
400
 
 
401
 
    if is_stop(cmd ) then
402
 
     begin
403
 
      inc(m_status );
404
 
 
405
 
      goto _6;
406
 
 
407
 
     end
408
 
    else
409
 
     begin
410
 
      result:=path_cmd_line_to;
411
 
 
412
 
      exit;
413
 
 
414
 
     end;
415
 
 
416
 
   end;
417
 
 
418
 
  6 :
419
 
  _6:
420
 
   begin
421
 
    m_arc.init  (m_x1 + m_rx4 ,m_y2 - m_ry4 ,m_rx4 ,m_ry4 ,pi * 0.5 ,pi );
422
 
    m_arc.rewind(0 );
423
 
 
424
 
    inc(m_status );
425
 
 
426
 
    goto _7;
427
 
 
428
 
   end;
429
 
 
430
 
  7 :
431
 
  _7:
432
 
   begin
433
 
    cmd:=m_arc.vertex(x ,y );
434
 
 
435
 
    if is_stop(cmd ) then
436
 
     begin
437
 
      inc(m_status );
438
 
 
439
 
      goto _8;
440
 
 
441
 
     end
442
 
    else
443
 
     begin
444
 
      result:=path_cmd_line_to;
445
 
 
446
 
      exit;
447
 
 
448
 
     end;
449
 
 
450
 
   end;
451
 
 
452
 
  8 :
453
 
  _8:
454
 
   begin
455
 
    cmd:=path_cmd_end_poly or path_flags_close or path_flags_ccw;
456
 
 
457
 
    inc(m_status );
458
 
 
459
 
   end;
460
 
 
461
 
 end;
462
 
 
463
 
 result:=cmd;
464
 
 
465
 
end;
466
 
 
467
 
END.
468