1 {****************************************************************************}
5 {* This unit implements a simple TrueType zone points viewer for the *}
6 {* FREETYPE project debugger. *}
8 {****************************************************************************}
14 uses Objects
, Views
, Drivers
, FreeType
, TTTypes
, TTTables
, TTObjs
, TTDebug
;
22 { This TView is a simple point array viewer }
24 PZoneViewer
= ^TZoneViewer
;
25 TZoneViewer
= object( TListViewer
)
27 constructor Init( var Bounds
: TRect
;
28 AZone
: PGlyph_Zone
);
30 procedure Draw
; virtual;
31 procedure HandleEvent( var Event
: TEvent
); virtual;
34 Zone
: PGlyph_Zone
; { Pointer to the zone being displayed }
35 Save
: TGlyph_Zone
; { A copy of the zone to highlight }
43 PZoneWindow
= ^TZoneWindow
;
44 TZoneWindow
= object( TWindow
)
45 ZoneView
: PZoneViewer
;
46 constructor Init( var Bounds
: TRect
;
47 AZone
: PGlyph_Zone
);
54 constructor TZoneViewer
.Init
;
58 inherited Init( Bounds
, 1, nil, nil );
60 GrowMode
:= gfGrowHiX
or gfGrowHiY
;
61 DragMode
:= dmDragGrow
or dmLimitLoX
or dmLimitLoY
;
62 Options
:= Options
or ofSelectable
;
63 EventMask
:= EventMask
or evWave
;
67 GetMem( Save
.org
, zone
^.n_points
*2*sizeof(Long
) );
68 GetMem( Save
.cur
, zone
^.n_points
*2*sizeof(Long
) );
69 GetMem( Save
.flags
, zone
^.n_points
*sizeof(Byte) );
71 Save
.n_points
:= Zone
^.n_points
;
72 Save
.n_contours
:= Zone
^.n_contours
;
76 SetRange( Save
.n_points
);
80 procedure TZoneViewer
.Copy_Zone
;
84 n
:= 2*zone
^.n_points
* sizeof(Long
);
86 (* Note that we save also the original coordinates, as we're not sure *)
87 (* that the debugger is debugged ! *)
89 move( Zone
^.org
^, Save
.org
^, n
);
90 move( Zone
^.cur
^, Save
.cur
^, n
);
91 move( Zone
^.flags
^, Save
.flags
^, zone
^.n_points
);
95 procedure TZoneViewer
.HandleEvent( var Event
: TEvent
);
98 Mini
, Maxi
: Objects
.TPoint
;
101 inherited HandleEvent(Event
);
105 evWave
: case Event
.Command
of
107 cmNewExecution
: Copy_Zone
;
109 cmRefocus
: DrawView
;
113 evCommand
: case Event
.Command
of
116 Owner
^.GetExtent(Limits
);
117 SizeLimits( Mini
, Maxi
);
118 DragView(Event
, DragMode
, Limits
, Mini
, Maxi
);
126 procedure TZoneViewer
.Draw
;
128 Colors
: array[0..3] of byte
130 Touchs
: array[0..3] of Char
132 OnOff
: array[0..1] of Char
151 if HScrollBar
<> nil then Indent
:= HScrollBar
^.Value
157 for I
:= 0 to Self
.Size
.Y
-1 do
160 MoveChar( B
, ' ', Colors
[0], Self
.Size
.X
);
165 ( Focused
= Item
) then Back_Color
:= 2
166 else Back_Color
:= 0;
168 if Item
< n_points
then
172 if ( flags
^[item
] <> Zone
^.flags
^[item
] ) then inc( Color
);
174 S
:= Hex16( Item
) + ': ';
175 S
[1] := OnOff
[Zone
^.flags
^[item
] and 1];
176 S
[7] := Touchs
[(Zone
^.flags
^[item
] and TT_Flag_Touched_Both
) shr 1];
178 MoveStr( B
, S
, Colors
[Color
] );
181 if ( org
^[item
].x
<> Zone
^.org
^[item
].x
) then inc( Color
);
183 MoveStr ( B
[8], Hex32( Zone
^.org
^[item
].x
), Colors
[Color
] );
184 MoveChar( B
[16], ',', Colors
[0], 1 );
187 if ( org
^[item
].y
<> Zone
^.org
^[item
].y
) then inc( Color
);
189 MoveStr( B
[17], Hex32( Zone
^.org
^[item
].y
), Colors
[Color
] );
190 MoveStr( B
[25], ' : ', Colors
[0] );
193 if ( cur
^[item
].x
<> Zone
^.cur
^[item
].x
) then inc( Color
);
195 MoveStr ( B
[28], Hex32( Zone
^.cur
^[item
].x
), Colors
[Color
] );
196 MoveChar( B
[36], ',', Colors
[0], 1 );
199 if ( cur
^[item
].y
<> Zone
^.cur
^[item
].y
) then inc( Color
);
201 MoveStr( B
[37], Hex32( Zone
^.cur
^[item
].y
), Colors
[Color
] );
205 WriteLine( 0, I
, Self
.Size
.X
, 1, B
);
212 constructor TZoneWindow
.Init
;
214 inherited Init( Bounds
,'Zone',wnNoNumber
);
217 New( ZoneView
, Init( Bounds
, AZone
) );