1
//----------------------------------------------------------------------------
2
// Anti-Grain Geometry - Version 2.4 (Public License)
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6
// Pascal Port By: Milan Marusinec alias Milano
8
// http://www.aggpas.org
9
// Copyright (c) 2005-2006
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.
16
//----------------------------------------------------------------------------
17
// Contact: mcseem@antigrain.com
18
// mcseemagg@yahoo.com
19
// http://www.antigrain.com
21
// [Pascal Port History] -----------------------------------------------------
23
// 15.01.2006-Milano: Unit port establishment
44
cbox_ctrl_impl = object(ctrl )
47
m_text_width : double;
49
m_label : array[0..127 ] of char;
53
m_vy : array[0..31 ] of double;
56
m_text_poly : conv_stroke;
61
constructor Construct(x ,y : double; l : PChar; flip_y : boolean = false );
62
destructor Destruct; virtual;
64
procedure text_thickness_(t : double );
65
procedure text_size_ (h : double; w : double = 0 );
67
function _label : PChar;
68
procedure label_(l : PChar );
70
function _status : boolean;
71
procedure status_(st : boolean );
73
function in_rect(x ,y : double ) : boolean; virtual;
75
function on_mouse_button_down(x ,y : double ) : boolean; virtual;
76
function on_mouse_button_up (x ,y : double ) : boolean; virtual;
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;
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;
88
cbox_ctrl_ptr = ^cbox_ctrl;
89
cbox_ctrl = object(cbox_ctrl_impl )
92
m_active_color : aggclr;
94
m_colors : array[0..2 ] of aggclr_ptr;
96
constructor Construct(x ,y : double; l : PChar; flip_y : boolean = false );
98
procedure text_color_ (c : aggclr_ptr );
99
procedure inactive_color_(c : aggclr_ptr );
100
procedure active_color_ (c : aggclr_ptr );
102
function _color(i : unsigned ) : aggclr_ptr; virtual;
106
{ GLOBAL PROCEDURES }
110
{ LOCAL VARIABLES & CONSTANTS }
111
{ UNIT IMPLEMENTATION }
113
constructor cbox_ctrl_impl.Construct;
115
inherited Construct(x ,y ,x + 9.0 * 1.5 ,y + 9.0 * 1.5 ,flip_y );
118
m_text_poly.Construct(@m_text );
120
m_text_thickness:=1.5;
131
destructor cbox_ctrl_impl.Destruct;
133
m_text_poly.Destruct;
139
procedure cbox_ctrl_impl.text_thickness_;
146
procedure cbox_ctrl_impl.text_size_;
154
function cbox_ctrl_impl._label;
156
result:=@m_label[0 ];
161
procedure cbox_ctrl_impl.label_;
171
move(l^ ,m_label[0 ] ,len );
178
function cbox_ctrl_impl._status;
185
procedure cbox_ctrl_impl.status_;
192
function cbox_ctrl_impl.in_rect;
194
inverse_transform_xy(@x ,@y );
204
{ ON_MOUSE_BUTTON_DOWN }
205
function cbox_ctrl_impl.on_mouse_button_down;
207
inverse_transform_xy(@x ,@y );
214
m_status:=not m_status;
224
{ ON_MOUSE_BUTTON_UP }
225
function cbox_ctrl_impl.on_mouse_button_up;
232
function cbox_ctrl_impl.on_mouse_move;
239
function cbox_ctrl_impl.on_arrow_keys;
246
function cbox_ctrl_impl.num_paths;
253
procedure cbox_ctrl_impl.rewind;
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;
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 );
290
m_text_poly.width_ (m_text_thickness );
291
m_text_poly.line_join_(round_join );
292
m_text_poly.line_cap_ (round_cap );
294
m_text_poly.rewind(0 );
302
d2:=(m_y2 - m_y1 ) / 2.0;
303
t :=m_text_thickness * 1.5;
305
m_vx[0 ]:=m_x1 + m_text_thickness;
306
m_vy[0 ]:=m_y1 + m_text_thickness;
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;
313
m_vx[4 ]:=m_x2 - m_text_thickness;
314
m_vy[4 ]:=m_y2 - m_text_thickness;
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;
329
function cbox_ctrl_impl.vertex;
334
cmd:=path_cmd_line_to;
339
if (m_vertex = 0 ) or
341
cmd:=path_cmd_move_to;
354
cmd:=m_text_poly.vertex(x ,y );
360
cmd:=path_cmd_move_to;
362
if m_vertex >= 8 then
379
if not is_stop(cmd ) then
387
constructor cbox_ctrl.Construct;
389
inherited Construct(x ,y ,l ,flip_y );
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 );
395
m_colors[0 ]:=@m_inactive_color;
396
m_colors[1 ]:=@m_text_color;
397
m_colors[2 ]:=@m_active_color;
402
procedure cbox_ctrl.text_color_;
409
procedure cbox_ctrl.inactive_color_;
411
m_inactive_color:=c^;
416
procedure cbox_ctrl.active_color_;
423
function cbox_ctrl._color;
425
result:=m_colors[i ];