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

« back to all changes in this revision

Viewing changes to components/aggpas/src/ctrl/agg_cbox_ctrl.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
 
// [Pascal Port History] -----------------------------------------------------
22
 
//
23
 
// 15.01.2006-Milano: Unit port establishment
24
 
//
25
 
{ agg_cbox_ctrl.pas }
26
 
unit
27
 
 agg_cbox_ctrl ;
28
 
 
29
 
INTERFACE
30
 
 
31
 
{$I agg_mode.inc }
32
 
 
33
 
uses
34
 
 SysUtils ,
35
 
 agg_basics ,
36
 
 agg_ctrl ,
37
 
 agg_conv_stroke ,
38
 
 agg_gsv_text ,
39
 
 agg_color ,
40
 
 agg_math_stroke ;
41
 
 
42
 
{ TYPES DEFINITION }
43
 
type
44
 
 cbox_ctrl_impl = object(ctrl )
45
 
   m_text_thickness ,
46
 
   m_text_height    ,
47
 
   m_text_width     : double;
48
 
 
49
 
   m_label  : array[0..127 ] of char;
50
 
   m_status : boolean;
51
 
 
52
 
   m_vx ,
53
 
   m_vy : array[0..31 ] of double;
54
 
 
55
 
   m_text      : gsv_text;
56
 
   m_text_poly : conv_stroke;
57
 
 
58
 
   m_idx    ,
59
 
   m_vertex : unsigned;
60
 
 
61
 
   constructor Construct(x ,y : double; l : PChar; flip_y : boolean = false );
62
 
   destructor  Destruct; virtual;
63
 
 
64
 
   procedure text_thickness_(t : double );
65
 
   procedure text_size_     (h : double; w : double = 0 );
66
 
 
67
 
   function  _label : PChar;
68
 
   procedure label_(l : PChar );
69
 
 
70
 
   function  _status : boolean;
71
 
   procedure status_(st : boolean );
72
 
 
73
 
   function  in_rect(x ,y : double ) : boolean; virtual;
74
 
 
75
 
   function  on_mouse_button_down(x ,y : double ) : boolean; virtual;
76
 
   function  on_mouse_button_up  (x ,y : double ) : boolean; virtual;
77
 
 
78
 
   function  on_mouse_move(x ,y : double; button_flag : boolean ) : boolean; virtual;
79
 
   function  on_arrow_keys(left ,right ,down ,up : boolean ) : boolean; virtual;
80
 
 
81
 
  // Vertex source interface
82
 
   function  num_paths : unsigned; virtual;
83
 
   procedure rewind(path_id : unsigned ); virtual;
84
 
   function  vertex(x ,y : double_ptr ) : unsigned; virtual;
85
 
 
86
 
  end;
87
 
 
88
 
 cbox_ctrl_ptr = ^cbox_ctrl;
89
 
 cbox_ctrl = object(cbox_ctrl_impl )
90
 
   m_text_color     ,
91
 
   m_inactive_color ,
92
 
   m_active_color   : aggclr;
93
 
 
94
 
   m_colors : array[0..2 ] of aggclr_ptr;
95
 
 
96
 
   constructor Construct(x ,y : double; l : PChar; flip_y : boolean = false );
97
 
 
98
 
   procedure text_color_    (c : aggclr_ptr );
99
 
   procedure inactive_color_(c : aggclr_ptr );
100
 
   procedure active_color_  (c : aggclr_ptr );
101
 
 
102
 
   function  _color(i : unsigned ) : aggclr_ptr; virtual;
103
 
 
104
 
  end;
105
 
 
106
 
{ GLOBAL PROCEDURES }
107
 
 
108
 
 
109
 
IMPLEMENTATION
110
 
{ LOCAL VARIABLES & CONSTANTS }
111
 
{ UNIT IMPLEMENTATION }
112
 
{ CONSTRUCT }
113
 
constructor cbox_ctrl_impl.Construct;
114
 
begin
115
 
 inherited Construct(x ,y ,x + 9.0 * 1.5 ,y + 9.0 * 1.5 ,flip_y );
116
 
 
117
 
 m_text.Construct;
118
 
 m_text_poly.Construct(@m_text );
119
 
 
120
 
 m_text_thickness:=1.5;
121
 
 m_text_height   :=9.0;
122
 
 m_text_width    :=0.0;
123
 
 
124
 
 m_status:=false;
125
 
 
126
 
 label_(l );
127
 
 
128
 
end;
129
 
 
130
 
{ DESTRUCT }
131
 
destructor cbox_ctrl_impl.Destruct;
132
 
begin
133
 
 m_text_poly.Destruct;
134
 
 m_text.Destruct;
135
 
 
136
 
end;
137
 
 
138
 
{ TEXT_THICKNESS_ }
139
 
procedure cbox_ctrl_impl.text_thickness_;
140
 
begin
141
 
 m_text_thickness:=t;
142
 
 
143
 
end;
144
 
 
145
 
{ TEXT_SIZE_ }
146
 
procedure cbox_ctrl_impl.text_size_;
147
 
begin
148
 
 m_text_width :=w;
149
 
 m_text_height:=h;
150
 
 
151
 
end;
152
 
 
153
 
{ _LABEL }
154
 
function cbox_ctrl_impl._label;
155
 
begin
156
 
 result:=@m_label[0 ];
157
 
 
158
 
end;
159
 
 
160
 
{ LABEL_ }
161
 
procedure cbox_ctrl_impl.label_;
162
 
var
163
 
 len : unsigned;
164
 
 
165
 
begin
166
 
 len:=StrLen(l );
167
 
 
168
 
 if len > 127 then
169
 
  len:=127;
170
 
 
171
 
 move(l^ ,m_label[0 ] ,len );
172
 
 
173
 
 m_label[len ]:=#0;
174
 
 
175
 
end;
176
 
 
177
 
{ _STATUS }
178
 
function cbox_ctrl_impl._status;
179
 
begin
180
 
 result:=m_status;
181
 
 
182
 
end;
183
 
 
184
 
{ STATUS_ }
185
 
procedure cbox_ctrl_impl.status_;
186
 
begin
187
 
 m_status:=st;
188
 
 
189
 
end;
190
 
 
191
 
{ IN_RECT }
192
 
function cbox_ctrl_impl.in_rect;
193
 
begin
194
 
 inverse_transform_xy(@x ,@y );
195
 
 
196
 
 result:=
197
 
  (x >= m_x1 ) and
198
 
  (y >= m_y1 ) and
199
 
  (x <= m_x2 ) and
200
 
  (y <= m_y2 );
201
 
 
202
 
end;
203
 
 
204
 
{ ON_MOUSE_BUTTON_DOWN }
205
 
function cbox_ctrl_impl.on_mouse_button_down;
206
 
begin
207
 
 inverse_transform_xy(@x ,@y );
208
 
 
209
 
 if (x >= m_x1 ) and
210
 
    (y >= m_y1 ) and
211
 
    (x <= m_x2 ) and
212
 
    (y <= m_y2 ) then
213
 
  begin
214
 
   m_status:=not m_status;
215
 
 
216
 
   result:=true;
217
 
 
218
 
  end
219
 
 else
220
 
  result:=false;
221
 
 
222
 
end;
223
 
 
224
 
{ ON_MOUSE_BUTTON_UP }
225
 
function cbox_ctrl_impl.on_mouse_button_up;
226
 
begin
227
 
 result:=false;
228
 
 
229
 
end;
230
 
 
231
 
{ ON_MOUSE_MOVE }
232
 
function cbox_ctrl_impl.on_mouse_move;
233
 
begin
234
 
 result:=false;
235
 
 
236
 
end;
237
 
 
238
 
{ ON_ARROW_KEYS }
239
 
function cbox_ctrl_impl.on_arrow_keys;
240
 
begin
241
 
 result:=false;
242
 
 
243
 
end;
244
 
 
245
 
{ NUM_PATHS }
246
 
function cbox_ctrl_impl.num_paths;
247
 
begin
248
 
 result:=3;
249
 
 
250
 
end;
251
 
 
252
 
{ REWIND }
253
 
procedure cbox_ctrl_impl.rewind;
254
 
var
255
 
 d2 ,t : double;
256
 
 
257
 
begin
258
 
 m_idx:=path_id;
259
 
 
260
 
 case path_id of
261
 
  0 : // Border
262
 
   begin
263
 
    m_vertex:=0;
264
 
 
265
 
    m_vx[0 ]:=m_x1;
266
 
    m_vy[0 ]:=m_y1;
267
 
    m_vx[1 ]:=m_x2;
268
 
    m_vy[1 ]:=m_y1;
269
 
    m_vx[2 ]:=m_x2;
270
 
    m_vy[2 ]:=m_y2;
271
 
    m_vx[3 ]:=m_x1;
272
 
    m_vy[3 ]:=m_y2;
273
 
    m_vx[4 ]:=m_x1 + m_text_thickness;
274
 
    m_vy[4 ]:=m_y1 + m_text_thickness;
275
 
    m_vx[5 ]:=m_x1 + m_text_thickness;
276
 
    m_vy[5 ]:=m_y2 - m_text_thickness;
277
 
    m_vx[6 ]:=m_x2 - m_text_thickness;
278
 
    m_vy[6 ]:=m_y2 - m_text_thickness;
279
 
    m_vx[7 ]:=m_x2 - m_text_thickness;
280
 
    m_vy[7 ]:=m_y1 + m_text_thickness;
281
 
 
282
 
   end;
283
 
 
284
 
  1 : // Text
285
 
   begin
286
 
    m_text.text_       (@m_label[0 ] );
287
 
    m_text.start_point_(m_x1 + m_text_height * 2.0 ,m_y1 + m_text_height / 5.0 );
288
 
    m_text.size_       (m_text_height ,m_text_width );
289
 
 
290
 
    m_text_poly.width_    (m_text_thickness );
291
 
    m_text_poly.line_join_(round_join );
292
 
    m_text_poly.line_cap_ (round_cap );
293
 
 
294
 
    m_text_poly.rewind(0 );
295
 
 
296
 
   end;
297
 
 
298
 
  2 : // Active item
299
 
   begin
300
 
    m_vertex:=0;
301
 
 
302
 
    d2:=(m_y2 - m_y1 ) / 2.0;
303
 
    t :=m_text_thickness * 1.5;
304
 
 
305
 
    m_vx[0 ]:=m_x1 + m_text_thickness;
306
 
    m_vy[0 ]:=m_y1 + m_text_thickness;
307
 
    m_vx[1 ]:=m_x1 + d2;
308
 
    m_vy[1 ]:=m_y1 + d2 - t;
309
 
    m_vx[2 ]:=m_x2 - m_text_thickness;
310
 
    m_vy[2 ]:=m_y1 + m_text_thickness;
311
 
    m_vx[3 ]:=m_x1 + d2 + t;
312
 
    m_vy[3 ]:=m_y1 + d2;
313
 
    m_vx[4 ]:=m_x2 - m_text_thickness;
314
 
    m_vy[4 ]:=m_y2 - m_text_thickness;
315
 
    m_vx[5 ]:=m_x1 + d2;
316
 
    m_vy[5 ]:=m_y1 + d2 + t;
317
 
    m_vx[6 ]:=m_x1 + m_text_thickness;
318
 
    m_vy[6 ]:=m_y2 - m_text_thickness;
319
 
    m_vx[7 ]:=m_x1 + d2 - t;
320
 
    m_vy[7 ]:=m_y1 + d2;
321
 
 
322
 
   end;
323
 
 
324
 
 end;
325
 
 
326
 
end;
327
 
 
328
 
{ VERTEX }
329
 
function cbox_ctrl_impl.vertex;
330
 
var
331
 
 cmd : unsigned;
332
 
 
333
 
begin
334
 
 cmd:=path_cmd_line_to;
335
 
 
336
 
 case m_idx of
337
 
  0 :
338
 
   begin
339
 
    if (m_vertex = 0 ) or
340
 
       (m_vertex = 4 ) then
341
 
     cmd:=path_cmd_move_to;
342
 
 
343
 
    if m_vertex >= 8then
344
 
     cmd:=path_cmd_stop;
345
 
 
346
 
    x^:=m_vx[m_vertex ];
347
 
    y^:=m_vy[m_vertex ];
348
 
 
349
 
    inc(m_vertex );
350
 
 
351
 
   end;
352
 
 
353
 
  1 :
354
 
   cmd:=m_text_poly.vertex(x ,y );
355
 
 
356
 
  2 :
357
 
   if m_status then
358
 
    begin
359
 
     if m_vertex = 0 then
360
 
      cmd:=path_cmd_move_to;
361
 
 
362
 
     if m_vertex >= 8 then
363
 
      cmd:=path_cmd_stop;
364
 
 
365
 
     x^:=m_vx[m_vertex ];
366
 
     y^:=m_vy[m_vertex ];
367
 
 
368
 
     inc(m_vertex );
369
 
 
370
 
    end
371
 
   else
372
 
    cmd:=path_cmd_stop;
373
 
 
374
 
  else
375
 
   cmd:=path_cmd_stop;
376
 
 
377
 
 end;
378
 
 
379
 
 if not is_stop(cmd ) then
380
 
  transform_xy(x ,y );
381
 
 
382
 
 result:=cmd;
383
 
 
384
 
end;
385
 
 
386
 
{ CONSTRUCT }
387
 
constructor cbox_ctrl.Construct;
388
 
begin
389
 
 inherited Construct(x ,y ,l ,flip_y );
390
 
 
391
 
 m_text_color.ConstrDbl    (0.0 ,0.0 ,0.0 );
392
 
 m_inactive_color.ConstrDbl(0.0 ,0.0 ,0.0 );
393
 
 m_active_color.ConstrDbl  (0.4 ,0.0 ,0.0 );
394
 
 
395
 
 m_colors[0 ]:=@m_inactive_color;
396
 
 m_colors[1 ]:=@m_text_color;
397
 
 m_colors[2 ]:=@m_active_color;
398
 
 
399
 
end;
400
 
 
401
 
{ TEXT_COLOR_ }
402
 
procedure cbox_ctrl.text_color_;
403
 
begin
404
 
 m_text_color:=c^;
405
 
 
406
 
end;
407
 
 
408
 
{ INACTIVE_COLOR_ }
409
 
procedure cbox_ctrl.inactive_color_;
410
 
begin
411
 
 m_inactive_color:=c^;
412
 
 
413
 
end;
414
 
 
415
 
{ ACTIVE_COLOR_ }
416
 
procedure cbox_ctrl.active_color_;
417
 
begin
418
 
 m_active_color:=c^;
419
 
 
420
 
end;
421
 
 
422
 
{ _COLOR }
423
 
function cbox_ctrl._color;
424
 
begin
425
 
 result:=m_colors[i ];
426
 
 
427
 
end;
428
 
 
429
 
END.
430