initial commit
[rofl0r-KOL.git] / main_tcanvas.htm
blob77786642e73ae78754b70f351234dc27af03b3c6
1 <html>
2 <head>
3 <title>KOL Help: TCanvas object (main frame)</title>
4 <base target="_top">
5 </head>
7 <body bgcolor="#FFFFEF" text="#000000" link="#008080" vlink="#008000" alink="#808000">
8 <p><font face="Courier" color="#800080"><b>TCanvas( unit <a href=kol_pas.htm>KOL.pas</a> )
9 <font face="Wingdings">ï</font> <a href=tobj.htm>TObj</a>
10 <font face="Wingdings">ï</font> <a href=_tobj.htm>_TObj</a>
11 </b></font></p>
12 <p><b>
13 TCanvas = object( <a href=tobj.htm target="_top">TObj</a> )
14 </b></p>
15 Very similar to VCL's TCanvas object. But with some changes, specific
16 for KOL: there is no necessary to use canvases in all applications.
17 And graphic tools objects are not created with canvas, but only
18 if really accessed in program. (Actually, even if paint box used,
19 only programmer decides, if to implement painting using Canvas or
20 to call low level API drawing functions working directly with DC).
21 Therefore TCanvas has some powerful extensions: rotated text support,
22 geometric pen support - just by changing correspondent properties
23 of certain graphic tool objects (Font.FontOrientation, Pen.GeometricPen).
24 See also additional <a href=#font target="main">Font</a> properties (Font.FontWeight, Font.FontQuality,
25 etc.
26 <h3 align="center"><font color="#FF8080">TCanvas properties</font></h3>
27 <a name="handle"></a>
28 <p>
29 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Handle</b></font>: HDC;</font>
30 <br>
31 GDI device context object handle. Never created by
32 Canvas itself (to use Canvas with memory bitmaps,
33 always create DC by yourself and assign it to the
34 Handle property of Canvas object, or use property
35 Canvas of a bitmap).
36 </p>
37 <a name="penpos"></a>
38 <p>
39 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>PenPos</b></font>: TPoint;</font>
40 <br>
41 Position of a pen.
42 </p>
43 <a name="pen"></a>
44 <p>
45 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Pen</b></font>: <a href=kol_pas.htm#pgraphictool target="_top">PGraphicTool</a>;</font>
46 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
47 <br>
48 Pen of Canvas object. Do not change its Pen.OnChange event value.
49 </p>
50 <a name="brush"></a>
51 <p>
52 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Brush</b></font>: <a href=kol_pas.htm#pgraphictool target="_top">PGraphicTool</a>;</font>
53 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
54 <br>
55 Brush of Canvas object. Do not change its Brush.OnChange event value.
56 </p>
57 <a name="font"></a>
58 <p>
59 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Font</b></font>: <a href=kol_pas.htm#pgraphictool target="_top">PGraphicTool</a>;</font>
60 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
61 <br>
62 Font of Canvas object. Do not change its Font.OnChange event value.
63 </p>
64 <a name="modecopy"></a>
65 <p>
66 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>ModeCopy</b></font>: <a href=kol_pas.htm#tcopymode target="_top">TCopyMode</a>;</font>
67 <br>
68 Current copy mode. Is used in <a href=#copyrect target="main">CopyRect</a> method.
69 </p>
70 <a name="pixels"></a>
71 <p>
72 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Pixels</b></font>[ X, Y: <b>Integer</b> ]: TColor;</font>
73 <br>
74 Obvious.
75 </p>
76 <h4 align="center"><font color="black">Properties, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
77 <h3 align="center"><font color="#FF8080">TCanvas methods</font></h3>
78 <a name="destroy"></a>
79 <p>
80 <font face="Courier" color="#800080"><b>destructor</b> <font color="#808000"><b>Destroy</b></font>; <b>virtual</b>;</font>
81 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#78;</font>&nbsp;&nbsp;&nbsp;
82 <br>
83 </p>
84 <a name="arc"></a>
85 <p>
86 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Arc</b></font>( X1, Y1, X2, Y2, X3, Y3, X4, Y4: <b>Integer</b> ); stdcall;</font>
87 <br>
88 Draws arc. For more info, see Delphi TCanvas help.
89 </p>
90 <a name="chord"></a>
91 <p>
92 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Chord</b></font>( X1, Y1, X2, Y2, X3, Y3, X4, Y4: <b>Integer</b> ); stdcall;</font>
93 <br>
94 Draws chord. For more info, see Delphi TCanvas help.
95 </p>
96 <a name="drawfocusrect"></a>
97 <p>
98 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>DrawFocusRect</b></font>( <b>const</b> Rect: TRect );</font>
99 <br>
100 Draws rectangle to represent focused visual object.
101 For more info, see Delphi TCanvas help.
102 </p>
103 <a name="ellipse"></a>
105 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Ellipse</b></font>( X1, Y1, X2, Y2: <b>Integer</b> );</font>
106 <br>
107 Draws an ellipse. For more info, see Delphi TCanvas help.
108 </p>
109 <a name="fillrect"></a>
111 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>FillRect</b></font>( <b>const</b> Rect: TRect );</font>
112 <br>
113 Fills rectangle. For more info, see Delphi TCanvas help.
114 </p>
115 <a name="fillrgn"></a>
117 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>FillRgn</b></font>( <b>const</b> Rgn: HRgn );</font>
118 <br>
119 Fills region. For more info, see Delphi TCanvas help.
120 </p>
121 <a name="floodfill"></a>
123 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>FloodFill</b></font>( X, Y: <b>Integer</b>; Color: TColor; FillStyle: <a href=kol_pas.htm#tfillstyle target="_top">TFillStyle</a> );</font>
124 <br>
125 Fills a figure with givien color, floodfilling its surface.
126 For more info, see Delphi TCanvas help.
127 </p>
128 <a name="framerect"></a>
130 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>FrameRect</b></font>( <b>const</b> Rect: TRect );</font>
131 <br>
132 Draws a rectangle. For more info, see Delphi TCanvas help.
133 </p>
134 <a name="moveto"></a>
136 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>MoveTo</b></font>( X, Y: <b>Integer</b> );</font>
137 <br>
138 Moves current <a href=#penpos target="main">PenPos</a> to a new position.
139 For more info, see Delphi TCanvas help.
140 </p>
141 <a name="lineto"></a>
143 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>LineTo</b></font>( X, Y: <b>Integer</b> );</font>
144 <br>
145 Draws a line from current <a href=#penpos target="main">PenPos</a> up to new position.
146 For more info, see Delphi TCanvas help.
147 </p>
148 <a name="pie"></a>
150 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Pie</b></font>( X1, Y1, X2, Y2, X3, Y3, X4, Y4: <b>Integer</b> ); stdcall;</font>
151 <br>
152 Draws a pie. For more info, see Delphi TCanvas help.
153 </p>
154 <a name="polygon"></a>
156 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Polygon</b></font>( <b>const</b> Points: <b>array</b> <b>of</b> TPoint );</font>
157 <br>
158 Draws a polygon. For more info, see Delphi TCanvas help.
159 </p>
160 <a name="polyline"></a>
162 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Polyline</b></font>( <b>const</b> Points: <b>array</b> <b>of</b> TPoint );</font>
163 <br>
164 Draws a bound for polygon. For more info, see Delphi TCanvas help.
165 </p>
166 <a name="rectangle"></a>
168 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Rectangle</b></font>( X1, Y1, X2, Y2: <b>Integer</b> );</font>
169 <br>
170 Draws a rectangle using current <a href=#pen target="main">Pen</a> and/or <a href=#brush target="main">Brush</a>.
171 For more info, see Delphi TCanvas help.
172 </p>
173 <a name="roundrect"></a>
175 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>RoundRect</b></font>( X1, Y1, X2, Y2, X3, Y3: <b>Integer</b> );</font>
176 <br>
177 Draws a rounded rectangle. For more info, see Delphi TCanvas help.
178 </p>
179 <a name="textout"></a>
181 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>TextOut</b></font>( X, Y: <b>Integer</b>; <b>const</b> Text: <b>String</b> ); stdcall;</font>
182 <br>
183 Draws a text. For more info, see Delphi TCanvas help.
184 </p>
185 <a name="exttextout"></a>
187 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>ExtTextOut</b></font>( X, Y: <b>Integer</b>; Options: <b>DWORD</b>; <b>const</b> Rect: TRect; <b>const</b> Text: <b>String</b>; <b>const</b> Spacing: <b>array</b> <b>of</b> <b>Integer</b> );</font>
188 <br>
189 </p>
190 <a name="drawtext"></a>
192 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>DrawText</b></font>( Text: <b>String</b>; <b>var</b> Rect: TRect; Flags: <b>DWord</b> );</font>
193 <br>
194 </p>
195 <a name="textrect"></a>
197 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>TextRect</b></font>( <b>const</b> Rect: TRect; X, Y: <b>Integer</b>; <b>const</b> Text: <b>string</b> );</font>
198 <br>
199 Draws a text, clipping output into given rectangle.
200 For more info, see Delphi TCanvas help.
201 </p>
202 <a name="textextent"></a>
204 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>TextExtent</b></font>( <b>const</b> Text: <b>string</b> ): TSize;</font>
205 <br>
206 Calculates size of a Text, using current <a href=#font target="main">Font</a> settings.
207 Does not need in <a href=#handle target="main">Handle</a> for Canvas object (if it is not
208 yet allocated, temporary device context is created and used.
209 </p>
210 <a name="textarea"></a>
212 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>TextArea</b></font>( <b>const</b> Text: <b>String</b>; <b>var</b> Sz: TSize; <b>var</b> P0: TPoint );</font>
213 <br>
214 Calculates size and starting point to output Text,
215 taking into considaration all <a href=#font target="main">Font</a> attributes, including
216 Orientation (only if <a href=kol_pas.htm#globalgraphics_usefontorient target="_top">GlobalGraphics_UseFontOrient</a> flag
217 is set to True, i.e. if rotated fonts are used).
218 Like for <a href=#textextent target="main">TextExtent</a>, does not need in <a href=#handle target="main">Handle</a> (and if this
219 last is not yet allocated/assigned, temporary device context
220 is created and used).
221 </p>
222 <a name="textwidth"></a>
224 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>TextWidth</b></font>( <b>const</b> Text: <b>string</b> ): <b>Integer</b>;</font>
225 <br>
226 Calculates text width (using <a href=#textarea target="main">TextArea</a>).
227 </p>
228 <a name="textheight"></a>
230 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>TextHeight</b></font>( <b>const</b> Text: <b>string</b> ): <b>Integer</b>;</font>
231 <br>
232 Calculates text height (using <a href=#textarea target="main">TextArea</a>).
233 </p>
234 <a name="cliprect"></a>
236 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>ClipRect</b></font>: TRect;</font>
237 <br>
238 returns ClipBox. by Dmitry Zharov.
239 </p>
240 <a name="wtextout"></a>
242 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>WTextOut</b></font>( X, Y: <b>Integer</b>; <b>const</b> WText: WideString ); stdcall;</font>
243 <br>
244 Draws a Unicode text.
245 </p>
246 <a name="wexttextout"></a>
248 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>WExtTextOut</b></font>( X, Y: <b>Integer</b>; Options: <b>DWORD</b>; <b>const</b> Rect: TRect; <b>const</b> WText: WideString; <b>const</b> Spacing: <b>array</b> <b>of</b> <b>Integer</b> );</font>
249 <br>
250 </p>
251 <a name="wdrawtext"></a>
253 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>WDrawText</b></font>( WText: WideString; <b>var</b> Rect: TRect; Flags: <b>DWord</b> );</font>
254 <br>
255 </p>
256 <a name="wtextrect"></a>
258 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>WTextRect</b></font>( <b>const</b> Rect: TRect; X, Y: <b>Integer</b>; <b>const</b> WText: WideString );</font>
259 <br>
260 Draws a Unicode text, clipping output into given rectangle.
261 </p>
262 <a name="wtextextent"></a>
264 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>WTextExtent</b></font>( <b>const</b> WText: WideString ): TSize;</font>
265 <br>
266 Calculates Unicode text width and height.
267 </p>
268 <a name="wtextwidth"></a>
270 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>WTextWidth</b></font>( <b>const</b> WText: WideString ): <b>Integer</b>;</font>
271 <br>
272 Calculates Unicode text width.
273 </p>
274 <a name="wtextheight"></a>
276 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>WTextHeight</b></font>( <b>const</b> WText: WideString ): <b>Integer</b>;</font>
277 <br>
278 Calculates Unicode text height.
279 </p>
280 <a name="copyrect"></a>
282 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>CopyRect</b></font>( <b>const</b> DstRect: TRect; SrcCanvas: <a href=kol_pas.htm#pcanvas target="_top">PCanvas</a>; <b>const</b> SrcRect: TRect );</font>
283 <br>
284 Copyes a rectangle from source to destination, using StretchBlt.
285 </p>
286 <a name="assign"></a>
288 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>Assign</b></font>( SrcCanvas: <a href=kol_pas.htm#pcanvas target="_top">PCanvas</a> ): <b>Boolean</b>;</font>
289 <br>
290 </p>
291 <a name="requiredstate"></a>
293 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>RequiredState</b></font>( ReqState: <b>DWORD</b> ): <b>Integer</b>; stdcall;</font>
294 <br>
295 It is possible to call this method before using <a href=#handle target="main">Handle</a> property
296 to pass it into API calls - to provide valid combinations of
297 pen, brush and font, selected into device context. This method
298 can not provide valid <a href=#handle target="main">Handle</a> - You always must create it by
299 yourself and assign to TCanvas.Handle property manually.
300 To optimize assembler version, returns <a href=#handle target="main">Handle</a> value.
301 </p>
302 <a name="deselecthandles"></a>
304 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>DeselectHandles</b></font>;</font>
305 <br>
306 Call this method to deselect all graphic tool objects from the canvas.
307 </p>
308 <h4 align="center"><font color="black">Methods, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
309 <h3 align="center"><font color="#FF8080">TCanvas events</font></h3>
310 <a name="ongethandle"></a>
312 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>OnGetHandle</b></font>: <a href=kol_pas.htm#tongethandle target="_top">TOnGetHandle</a>;</font>
313 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#78;</font>&nbsp;&nbsp;&nbsp;
314 <br>
315 For internal use only.
316 </p>
317 <a name="onchange"></a>
319 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>OnChange</b></font>: <a href=kol_pas.htm#tonevent target="_top">TOnEvent</a>;</font>
320 <br>
321 </p>
322 <h4 align="center"><font color="black">Events, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
323 <h3 align="center"><font color="#FF8080">TCanvas fields</font></h3>
324 <a name="fispaintdc"></a>
326 <font face="Courier" color="#800080"><font color="#808000"><b>fIsPaintDC</b></font>: <b>Boolean</b>;</font>
327 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#78;</font>&nbsp;&nbsp;&nbsp;
328 <br>
329 TRUE, if DC obtained during current WM_PAINT (or WM_ERASEBKGND?)
330 processing for a control. This affects a way how <a href=#handle target="main">Handle</a> is released.
331 </p>
332 <h4 align="center"><font color="black">Fields, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
333 <hr>
334 <p align="center">[&nbsp;<a href=index.htm>Index</a>&nbsp;]</p>
335 <p align="center"><font face="Comic Sans MS"><small>This help is generated 22-Sep-2005 by KOL Help generator, (C) 2000-2001 by Vladimir Kladov<br>Modified (C) 2003 by Alexander Bartov</small></font></p>
336 </body>
337 </html>