0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / WNT / WNT_Allocator.cxx
CommitLineData
7fd59977 1////////////////////////////////////////////////////////////////////////////////
2// WNT_Allocator //
3// Provides memory management and drawing operations for Windows 95. //
4// World transformations and styled lines are managed by EHDC stuff. //
5// //
6// History: FEB-98 - creation (EUG) //
7// MAR-98 - modification (DCB) //
8////////////////////////////////////////////////////////////////////////////////
9
10#define PRO19042 //GG_251199 Avoid to crash with an insuffisant resources messag
11
12#include "WNT_Allocator.hxx"
13
14#include <math.h>
15#include <limits>
16#include <stdio.h>
17
18#define ALLOCATOR ( ( PWNT_Allocator )myAllocator )
19
20static XFORM xfmIdent = { ( FLOAT )0.8660, ( FLOAT )0.5000,
21 ( FLOAT )-0.5000, ( FLOAT )0.8660,
22 ( FLOAT )0.0000, ( FLOAT )0.0000
23 };
24
25WNT_Allocator :: WNT_Allocator ( int anID, PW32_Allocator prev ) :
26 W32_Allocator ( anID, prev )
27{
28 myLinePen = (HPEN) GetStockObject ( NULL_PEN );
29 myLineWidth = 1;
30 myPolyBrush = (HBRUSH) GetStockObject ( NULL_BRUSH );
31 myTextPen = (HPEN) GetStockObject ( NULL_PEN );
32 myTextBrush = (HBRUSH) GetStockObject ( NULL_BRUSH );
33 myTextFont = (HFONT) GetStockObject ( SYSTEM_FONT );
34 myMarkerPen = (HPEN) GetStockObject ( NULL_PEN );
35 myTextSlant = EPS;
36
37 myPO = (HPEN) NULL;
38 myBO = (HBRUSH) NULL;
39 myFO = (HFONT) NULL;
40 SetRectEmpty ( &myURect );
41
42 myMatrix.eM11 = myMatrix.eM22 = 1.0F;
43 myMatrix.eM12 = myMatrix.eM21 = 0.0F;
44 myMatrix.eDx = myMatrix.eDy = 0.0F;
45
46 myFlags &= ~W32F_WIN95;
47} // end constructor
48
49WNT_Allocator :: ~WNT_Allocator ()
50{
51 DeletePen ( myLinePen );
52 DeleteBrush ( myPolyBrush );
53 DeletePen ( myTextPen );
54 DeleteBrush ( myTextBrush );
55 DeletePen ( myMarkerPen );
56} // end destructor
57
58void WNT_Allocator :: TransformPoint (int& X, int& Y)
59{
60 X = int ( myScaleX * ( X - myPivot.x ) );
61 Y = int ( myScaleY * ( Y - myPivot.y ) );
62} // WNT_Allocator :: TransformPoint
63
64void WNT_Allocator :: TransformPoint (LPPOINT lpPoint)
65{
66 lpPoint->x = int ( myScaleX * ( lpPoint->x - myPivot.x ) );
67 lpPoint->y = int ( myScaleY * ( lpPoint->y - myPivot.y ) );
68} // WNT_Allocator :: TransformPoint
69
70#define ADD_POINT_TO_RECT(aPoint) \
71 { if ( aPoint.x < myURect.left ) myURect.left = aPoint.x - myLineWidth - 1; \
72 if ( aPoint.x > myURect.right ) myURect.right = aPoint.x + myLineWidth + 1; \
73 if ( aPoint.y < myURect.top ) myURect.top = aPoint.y - myLineWidth - 1; \
74 if ( aPoint.y > myURect.bottom ) myURect.bottom = aPoint.y + myLineWidth + 1; \
75 }
76
77void WNT_Allocator :: Register ( int x, int y )
78{
79 static POINT pt;
80 pt.x = x; pt.y = y;
81 LPtoDP ( myHDC, &pt, 1 );
82 ADD_POINT_TO_RECT (pt);
83} // WNT_Allocator :: Register
84
85void WNT_Allocator :: Register ( LPPOINT lpPts, int nPts )
86{
87 for ( int i = 0; i < nPts; i++ )
88 Register ( lpPts[i].x, lpPts[i].y );
89} // WNT_Allocator :: Register
90
91void WNT_Allocator :: Register ( LPRECT lpRect )
92{
93 Register ( lpRect->left, lpRect->top );
94 Register ( lpRect->left, lpRect->bottom );
95 Register ( lpRect->right, lpRect->top );
96 Register ( lpRect->right, lpRect->bottom );
97} // WNT_Allocator :: Register
98
99void WNT_Allocator :: RecalcMatrix (
100 XFORM& Matrix, double Angle,
101 double PivotX, double PivotY
102 )
103{
104 float CosA = ( float )cos ( Angle );
105 float SinA = ( float )sin ( Angle );
106 Matrix.eM11 = float ( CosA );
107 Matrix.eM12 = float ( SinA );
108 Matrix.eM21 = -float ( SinA );
109 Matrix.eM22 = float ( CosA );
110 Matrix.eDx = float ( PivotX );
111 Matrix.eDy = float ( PivotY );
112} // end WNT_Allocator :: RecalcMatrix
113
114void WNT_Allocator :: Play ( HDC hdc, PSIZE szClient )
115{
116 CopyMemory ( &mySize, szClient, sizeof ( SIZE ) );
117 if ( !( myFlags & W32F_EMPTY ) ) {
118 POINT pVOExt;
119 SIZE szWExt, szVExt;
120 int nMapMode, nGMode, nBkMode;
121
122 myHDC = hdc;
123 nMapMode = SetMapMode ( myHDC, MM_ISOTROPIC );
124 SetRect ( &myURect, mySize.cx, mySize.cy, 0, 0 );
125 SetWindowExtEx ( myHDC, szClient->cx, -szClient->cy, &szWExt );
126 SetViewportExtEx ( myHDC, szClient->cx, szClient->cy, &szVExt );
127 SetViewportOrgEx ( myHDC, 0, szClient->cy - 1, &pVOExt );
128 nGMode = SetGraphicsMode ( myHDC, GM_ADVANCED );
129 nBkMode = SetBkMode ( myHDC, TRANSPARENT );
130 SelectPen ( myHDC, myLinePen );
131 SelectBrush ( myHDC, myPolyBrush );
132 SetTextColor ( myHDC, myTextColor );
133
134 Xform ();
135 for ( PW32_Block aBlock = myStart; aBlock != NULL; aBlock = aBlock -> next )
136 for ( int i = 0; i < aBlock -> free; i += aBlock -> data[ i ] )
137 if ( aBlock -> data[ i + 1 ] != __W32_DATA ) {
138 W32_Note* pNote = ( W32_Note* )&( aBlock -> data[ i + 1 ] );
139 pNote -> Play ();
140 } // end if
141
142 SetMapMode ( myHDC, nMapMode );
143 SetWindowExtEx ( myHDC, szWExt.cx, szWExt.cy, NULL );
144 SetViewportExtEx ( myHDC, szVExt.cx, szVExt.cy, NULL );
145 SetViewportOrgEx ( myHDC, pVOExt.x, pVOExt.y, NULL );
146 SetBkMode ( myHDC, nBkMode );
147 SetGraphicsMode ( myHDC, nGMode );
148 } // end if
149} // end WNT_Allocator :: Play
150
151void WNT_Allocator :: URect ( LPRECT lpRect )
152{
153 CopyRect ( lpRect, &myURect );
154 if ( lpRect -> top < 0 ) lpRect -> top = 0;
155 if ( lpRect -> left < 0 ) lpRect -> left = 0;
156 if ( lpRect -> right > mySize.cx ) lpRect -> right = mySize.cx;
157 if ( lpRect -> bottom > mySize.cy ) lpRect -> bottom = mySize.cy;
158} // end WNT_Allocator :: URect
159
160void WNT_Allocator :: Xform ( void )
161{
162 if ( myAngle != 0.0 || myPivot.x != 0 || myPivot.y != 0 ||
163 myMove.x != 0 || myMove.y != 0 )
164 {
165 RecalcMatrix ( myMatrix, myAngle,
166 myPivot.x + myMove.x,
167 myPivot.y + myMove.y );
168 SetWorldTransform ( myHDC, &myMatrix );
169 } else {
170 ModifyWorldTransform ( myHDC, NULL, MWT_IDENTITY );
171 }
172} // end WNT_Allocator :: Xform
173
174void WNT_Allocator :: Point ( int x, int y ) {
175
176 new ( this ) WNT_PointNote ( x, y );
177
178} // end WNT_Allocator :: Point
179
180void WNT_Allocator :: MarkerPoint ( int x, int y ) {
181
182 new ( this ) WNT_MarkerPointNote ( x, y );
183
184} // end WNT_Allocator :: MarkerPoint
185
186void WNT_Allocator :: Line ( int x, int y, int x1, int y1 ) {
187
188 new ( this ) WNT_LineNote ( x, y, x1, y1 );
189
190} // end WNT_Allocator :: Line
191
192void WNT_Allocator :: PolyEllipse ( int xc, int yc, int xr, int yr ) {
193
194 new ( this ) WNT_PolyEllipseNote ( xc, yc, xr, yr );
195
196} // end WNT_Allocator :: PolyEllipse
197
198void WNT_Allocator :: Ellipse ( int xc, int yc, int xr, int yr ) {
199
200 new ( this ) WNT_EllipseNote ( xc, yc, xr, yr );
201
202} // end WNT_Allocator :: Ellipse
203
204void WNT_Allocator :: Arc (
205 int xc, int yc, int xr, int yr,
206 double sa, double oa
207 ) {
208
209 new ( this ) WNT_ArcNote ( xc, yc, xr, yr, sa, oa );
210
211} // end WNT_Allocator :: Arc
212
213void WNT_Allocator :: PolyChord (
214 int xc, int yc, int xr, int yr,
215 double sa, double oa
216 ) {
217
218 new ( this ) WNT_PolyChordNote ( xc, yc, xr, yr, sa, oa );
219
220} // end WNT_Allocator :: PolyChord
221
222void WNT_Allocator :: Chord (
223 int xc, int yc, int xr, int yr,
224 double sa, double oa
225 ) {
226
227 new ( this ) WNT_PolyChordNote ( xc, yc, xr, yr, sa, oa );
228
229} // end WNT_Allocator :: Chord
230
231void WNT_Allocator :: PolySector (
232 int xc, int yc, int xr, int yr,
233 double sa, double oa
234 ) {
235
236 new ( this ) WNT_PolySectorNote ( xc, yc, xr, yr, sa, oa );
237
238} // end WNT_Allocator :: PolySector
239
240void WNT_Allocator :: Sector (
241 int xc, int yc, int xr, int yr,
242 double sa, double oa
243 ) {
244
245 new ( this ) WNT_SectorNote ( xc, yc, xr, yr, sa, oa );
246
247} // end WNT_Allocator :: Sector
248
249void WNT_Allocator :: PolyMarker ( int aMaxPoints ) {
250
251 new ( this ) W32_PolyMarkerNote ( aMaxPoints );
252
253} // end WNT_Allocator :: PolyMarker
254
255void WNT_Allocator :: PolyMarker1 (
256 int aMaxPoints, GetPointFunc fn,
257 int aStartPoint, void* fParam
258 ) {
259
260 new ( this ) WNT_PolyMarker1Note (
261 aMaxPoints, fn, aStartPoint, fParam
262 );
263
264} // end WNT_Allocator :: PolyMarker1
265
266void WNT_Allocator :: PolyMarker2 (
267 int aMaxPoints, GetPointFunc fn,
268 int aStartPoint, void* fParam
269 ) {
270
271 new ( this ) WNT_PolyMarker2Note (
272 aMaxPoints, fn, aStartPoint, fParam
273 );
274
275} // end WNT_Allocator :: PolyMarker1
276
277W32_Note* WNT_Allocator :: Polygon ( int aMaxPoints ) {
278
279 return new ( this ) WNT_PolygonNote ( aMaxPoints );
280
281} // end WNT_Allocator :: Polygon
282
283W32_Note* WNT_Allocator :: Polyline ( int aMaxPoints ) {
284
285 return new ( this ) WNT_PolylineNote ( aMaxPoints );
286
287} // end WNT_Allocator :: Polyline
288
289void WNT_Allocator :: Image (
290 int x, int y, PW32_Bitmap pBmp, double aScale
291 ) {
292
293 new ( this ) WNT_ImageNote ( x, y, pBmp, aScale );
294
295} // end WNT_Allocator :: Image
296
297void WNT_Allocator :: Text (
298 int x, int y, double angle, void* text,
299 BOOL fWide, BOOL fOutlined
300 ) {
301
302 new ( this ) WNT_TextNote ( x, y, angle, text, fWide, fOutlined );
303
304} // end WNT_Allocator :: Text
305
306void WNT_Allocator :: Polytext (
307 int x, int y, double angle, double margin,
308 void* text, BOOL fWide, BOOL fOutlined
309 ) {
310
311 new ( this ) WNT_PolyTextNote ( x, y, angle, margin, text, fWide, fOutlined );
312
313} // end WNT_Allocator :: Polytext
314
315void WNT_Allocator :: BeginMarker (
316 int x, int y, int w, int h, double angle
317 ) {
318
319 new ( this ) WNT_BeginMarkerNote ( x, y, w, h, angle );
320
321} // end WNT_Allocator :: BeginMarker
322
323void WNT_Allocator :: EndMarker ( void ) {
324
325 new ( this ) WNT_EndMarkerNote ();
326
327} // end WNT_Allocator :: EndMarker
328
329void WNT_Allocator :: LineAttrib (
330 DWORD width, PLOGBRUSH plb,
331 DWORD nStyles, PDWORD pdwStyle
332 ) {
333
334 new ( this ) WNT_LineAttribNote ( width, plb, nStyles, pdwStyle );
335
336} // end WNT_Allocator :: LineAttrib
337
338void WNT_Allocator :: PolyAttrib (
339 PLOGBRUSH plb, BOOL fDrawEdge, int aFillMode
340 ) {
341
342 new ( this ) WNT_PolyAttribNote ( plb, fDrawEdge, aFillMode );
343
344} // end WNT_Allocator :: PolyAttrib
345
346void WNT_Allocator :: TextAttrib (
347 HFONT hFont, COLORREF color, double slant,
348 double hScale, double vScale,
349 BOOL fUnderlined, BOOL fFree, BOOL fIndex
350 ) {
351
352 new ( this ) WNT_TextAttribNote (
353 hFont, color, slant, hScale, vScale,
354 fUnderlined, fFree, fIndex
355 );
356
357} // end WNT_Allocator :: TextAttrib
358
359void WNT_Allocator :: MarkerAttrib (
360 COLORREF color, DWORD dwWidth, BOOL fFill
361 ) {
362
363 new ( this ) WNT_MarkerAttribNote ( color, dwWidth, fFill );
364
365} // end WNT_Allocator :: MarkerAttrib
366
367void WNT_Allocator :: FunCall (
368 W32_FCall fCall, int sz, PW32_FCALLPARAM param
369 ) {
370
371 new ( this ) W32_FCallNote ( fCall, sz, param );
372
373} // end WNT_Allocator :: FunCall
374
375void WNT_Allocator :: GetExtent ( LPSIZE lpSZ )
376{
377 CopyMemory ( lpSZ, &mySize, sizeof ( SIZE ) );
378}
379
380int WNT_Allocator :: TextSize ( HDC hdc, char* str, PSIZE psz ) {
381
382 int gMode = GetGraphicsMode ( hdc );
383 XFORM xfm, xfms;
384 POINT pt;
385 ABC abcf;
386
387 if ( gMode == GM_ADVANCED )
388 GetWorldTransform ( hdc, &xfms );
389 else
390 SetGraphicsMode ( hdc, GM_ADVANCED );
391
392 ModifyWorldTransform ( hdc, &xfmIdent, MWT_IDENTITY );
393 xfm.eM11 = 1.0F;
394 xfm.eM12 = 0.0F;
395 xfm.eM21 = ( FLOAT )tan ( myTextSlant );
396 xfm.eM22 = 1.0F;
397 xfm.eDx = 0.0F;
398 xfm.eDy = 0.0F;
399 ModifyWorldTransform ( hdc, &xfm, MWT_LEFTMULTIPLY );
400 xfm.eM11 = FLOAT ( myTextHScale * myScaleX );
401 xfm.eM12 = 0.0F;
402 xfm.eM21 = 0.0F;
403 xfm.eM22 = FLOAT ( myTextVScale * myScaleY );
404 xfm.eDx = 0.0F;
405 xfm.eDy = 0.0F;
406 ModifyWorldTransform ( hdc, &xfm, MWT_LEFTMULTIPLY );
407
408 MoveToEx ( hdc, 0, 0, &pt );
409 GetTextExtentPoint32A (
410 hdc, str, lstrlenA ( str ), psz
411 );
412 GetCharABCWidthsA ( hdc, str[ 0 ], str[ 0 ], &abcf );
413 MoveToEx ( hdc, pt.x, pt.y, NULL );
414
415 if ( gMode == GM_ADVANCED )
416 SetWorldTransform ( hdc, &xfms );
417 else {
418 psz->cx = LONG ( psz->cx * xfm.eM11 );
419 psz->cy = LONG ( psz->cy * xfm.eM22 );
420 abcf.abcA = UINT ( abcf.abcA * xfm.eM11 );
421 SetGraphicsMode ( hdc, gMode );
422 } // end else
423
424 return abcf.abcA;
425} // end WNT_Allocator :: TextSize
426
427int WNT_Allocator :: TextSize ( HDC hdc, wchar_t* str, PSIZE psz ) {
428
429 int gMode = GetGraphicsMode ( hdc );
430 XFORM xfm, xfms;
431 POINT pt;
432 ABC abcf;
433
434 if ( gMode == GM_ADVANCED )
435 GetWorldTransform ( hdc, &xfms );
436 else
437 SetGraphicsMode ( hdc, GM_ADVANCED );
438
439 ModifyWorldTransform ( hdc, &xfmIdent, MWT_IDENTITY );
440 xfm.eM11 = 1.0F;
441 xfm.eM12 = 0.0F;
442 xfm.eM21 = ( FLOAT )tan ( myTextSlant );
443 xfm.eM22 = 1.0F;
444 xfm.eDx = 0.0F;
445 xfm.eDy = 0.0F;
446 ModifyWorldTransform ( hdc, &xfm, MWT_LEFTMULTIPLY );
447 xfm.eM11 = FLOAT ( myTextHScale * myScaleX );
448 xfm.eM12 = 0.0F;
449 xfm.eM21 = 0.0F;
450 xfm.eM22 = FLOAT ( myTextVScale * myScaleY );
451 xfm.eDx = 0.0F;
452 xfm.eDy = 0.0F;
453 ModifyWorldTransform ( hdc, &xfm, MWT_LEFTMULTIPLY );
454
455 MoveToEx ( hdc, 0, 0, &pt );
456 GetTextExtentPoint32W (
457 hdc, str, lstrlenW ( str ), psz
458 );
459 GetCharABCWidthsW ( hdc, str[ 0 ], str[ 0 ], &abcf );
460 MoveToEx ( hdc, pt.x, pt.y, NULL );
461
462 if ( gMode == GM_ADVANCED )
463 SetWorldTransform ( hdc, &xfms );
464 else {
465 psz->cx = LONG ( psz->cx * xfm.eM11 );
466 psz->cy = LONG ( psz->cy * xfm.eM22 );
467 abcf.abcA = UINT ( abcf.abcA * xfm.eM11 );
468 SetGraphicsMode ( hdc, gMode );
469 } // end else
470
471 return abcf.abcA;
472} // end WNT_Allocator :: TextSize
473
474////////////////////////////////////////////////////////////////////////////////
475// W N T _ P o i n t N o t e //
476////////////////////////////////////////////////////////////////////////////////
477WNT_PointNote :: WNT_PointNote ( int x, int y ) :
478 W32_PointNote ( x, y )
479{
480} // end constructor
481
482void WNT_PointNote :: Play ( BOOL fDummy )
483{
484 Xform ();
485 SetPixel ( ALLOCATOR -> myHDC, myTX, myTY, ALLOCATOR -> myPointColor );
486} // end WNT_PointNote :: Play
487
488void WNT_PointNote :: Xform ()
489{
490 myTX = myX;
491 myTY = myY;
492 ALLOCATOR -> TransformPoint ( myTX, myTY );
493 ALLOCATOR -> Register ( myTX, myTY );
494}
495////////////////////////////////////////////////////////////////////////////////
496// W N T _ M a r k e r P o i n t N o t e //
497////////////////////////////////////////////////////////////////////////////////
498WNT_MarkerPointNote :: WNT_MarkerPointNote ( int x, int y ) :
499 WNT_PointNote ( x, y )
500{
501} // end constructor
502
503void WNT_MarkerPointNote :: Play ( BOOL fDummy )
504{
505 Xform ();
506 SetPixel ( ALLOCATOR -> myHDC, myTX, myTY, ALLOCATOR -> myMarkerPointColor );
507} // end WNT_MarkerPointNote :: Play
508////////////////////////////////////////////////////////////////////////////////
509// W N T _ L i n e N o t e //
510////////////////////////////////////////////////////////////////////////////////
511WNT_LineNote :: WNT_LineNote ( int x, int y, int x1, int y1 ) :
512 WNT_PointNote ( x, y )
513{
514 myX2 = x1;
515 myY2 = y1;
516} // end constructor
517
518void WNT_LineNote :: Play ( BOOL fDummy )
519{
520 Xform ();
521 MoveToEx ( ALLOCATOR -> myHDC, myTX , myTY, NULL );
522 LineTo ( ALLOCATOR -> myHDC, myTX2, myTY2 );
523} // end WNT_LineNote :: Play
524
525void WNT_LineNote :: Xform ()
526{
527 WNT_PointNote :: Xform ();
528 myTX2 = myX2;
529 myTY2 = myY2;
530 ALLOCATOR -> TransformPoint ( myTX2, myTY2 );
531 ALLOCATOR -> Register ( myTX2, myTY2 );
532}
533////////////////////////////////////////////////////////////////////////////////
534// W N T _ P o l y E l l i p s e N o t e //
535////////////////////////////////////////////////////////////////////////////////
536WNT_PolyEllipseNote :: WNT_PolyEllipseNote ( int xc, int yc, int xr, int yr ) :
537 WNT_PointNote ( xc, yc )
538{
539 myXr = xr;
540 myYr = yr;
541} // end constructor
542
543void WNT_PolyEllipseNote :: Play ( BOOL fDummy )
544{
545 Xform ();
546 Ellipse ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
547 myTX + myTXr, myTY + myTYr );
548} // end WNT_PolyEllipseNote :: Play
549
550void WNT_PolyEllipseNote :: Xform ()
551{
552 WNT_PointNote :: Xform ();
553 myTXr = int (myXr * ALLOCATOR -> myScaleX);
554 myTYr = int (myYr * ALLOCATOR -> myScaleY);
555 RECT r = { myTX - myTXr, myTY - myTYr, myTX + myTXr, myTY + myTYr };
556 ALLOCATOR -> Register ( &r );
557}
558////////////////////////////////////////////////////////////////////////////////
559// W N T _ E l l i p s e N o t e //
560////////////////////////////////////////////////////////////////////////////////
561WNT_EllipseNote :: WNT_EllipseNote ( int xc, int yc, int xr, int yr ) :
562 WNT_PolyEllipseNote ( xc, yc, xr, yr )
563{
564} // end constructor
565
566void WNT_EllipseNote :: Play ( BOOL fDummy )
567{
568 Xform ();
569 HBRUSH hob = SelectBrush ( ALLOCATOR -> myHDC, GetStockObject (NULL_BRUSH) );
570 Ellipse ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
571 myTX + myTXr, myTY + myTYr );
572 SelectBrush ( ALLOCATOR -> myHDC, hob );
573} // end WNT_PolyEllipseNote :: Play
574////////////////////////////////////////////////////////////////////////////////
575// W N T _ A r c N o t e //
576////////////////////////////////////////////////////////////////////////////////
577WNT_ArcNote :: WNT_ArcNote (
578 int xc, int yc, int xr, int yr, double sa, double oa
579 ) : WNT_PolyEllipseNote ( xc, yc, xr, yr )
580{
581 int Radius = max ( xr, yr );
582 double sSinA = sin ( sa + oa );
583 double sCosA = cos ( sa + oa );
584 double eSinA = sin ( sa );
585 double eCosA = cos ( sa );
586 myDirect = ( sa + oa > 0. ) ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE;
587
588 mySX = int ( sCosA * 2 * Radius + xc );
589 mySY = int ( sSinA * 2 * Radius + yc );
590 myEX = int ( eCosA * 2 * Radius + xc );
591 myEY = int ( eSinA * 2 * Radius + yc );
592} // end constructor
593
594void WNT_ArcNote :: Play ( BOOL fDummy )
595{
596 Xform ();
7fd59977 597 SetArcDirection ( ALLOCATOR -> myHDC, myDirect );
598 Arc ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
599 myTX + myTXr, myTY + myTYr,
600 myTSX, myTSY, myTEX, myTEY );
601} // end WNT_ArcNote :: Play
602
603void WNT_ArcNote :: Xform ()
604{
605 WNT_PolyEllipseNote :: Xform ();
606 myTSX = mySX;
607 myTSY = mySY;
608 ALLOCATOR -> TransformPoint ( myTSX, myTSY );
609 myTEX = myEX;
610 myTEY = myEY;
611 ALLOCATOR -> TransformPoint ( myTEX, myTEY );
612}
613////////////////////////////////////////////////////////////////////////////////
614// W N T _ P o l y C h o r d N o t e //
615////////////////////////////////////////////////////////////////////////////////
616WNT_PolyChordNote :: WNT_PolyChordNote (
617 int xc, int yc, int xr, int yr, double sa, double oa
618 ) : WNT_ArcNote ( xc, yc, xr, yr, sa, oa )
619{
620} // end constructor
621
622void WNT_PolyChordNote :: Play ( BOOL fDummy )
623{
624 Xform ();
625 Chord ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
626 myTX + myTXr, myTY + myTYr,
627 myTEX, myTEY, myTSX, myTSY );
628} // end WNT_PolyChordNote :: Play
629////////////////////////////////////////////////////////////////////////////////
630// W N T _ C h o r d N o t e //
631////////////////////////////////////////////////////////////////////////////////
632WNT_ChordNote :: WNT_ChordNote (
633 int xc, int yc, int xr, int yr, double sa, double oa
634 ) : WNT_PolyChordNote ( xc, yc, xr, yr, sa, oa )
635{
636} // end constructor
637
638void WNT_ChordNote :: Play ( BOOL fDummy )
639{
640 Xform ();
641 HBRUSH hob = SelectBrush ( ALLOCATOR -> myHDC, GetStockObject (NULL_BRUSH) );
642 Chord ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
643 myTX + myTXr, myTY + myTYr,
644 myTEX, myTEY, myTSX, myTSY );
645 SelectBrush ( ALLOCATOR -> myHDC, hob );
646} // end WNT_ChordNote :: Play
647////////////////////////////////////////////////////////////////////////////////
648// W N T _ P o l y S e c t o r N o t e //
649////////////////////////////////////////////////////////////////////////////////
650WNT_PolySectorNote :: WNT_PolySectorNote (
651 int xc, int yc, int xr, int yr, double sa, double oa
652 ) : WNT_ArcNote ( xc, yc, xr, yr, sa, oa )
653{
654} // end constructor
655
656void WNT_PolySectorNote :: Play ( BOOL fDummy )
657{
658 Xform ();
659 Pie ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
660 myTX + myTXr, myTY + myTYr,
661 myTEX, myTEY, myTSX, myTSY );
662} // end WNT_PolySectorNote :: Play
663////////////////////////////////////////////////////////////////////////////////
664// W N T _ S e c t o r N o t e //
665////////////////////////////////////////////////////////////////////////////////
666WNT_SectorNote :: WNT_SectorNote (
667 int xc, int yc, int xr, int yr, double sa, double oa
668 ) : WNT_PolySectorNote ( xc, yc, xr, yr, sa, oa )
669{
670} // end constructor
671
672void WNT_SectorNote :: Play ( BOOL fDummy )
673{
674 Xform ();
675 HBRUSH hob = SelectBrush ( ALLOCATOR -> myHDC, GetStockObject (NULL_BRUSH) );
676 Pie ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
677 myTX + myTXr, myTY + myTYr,
678 myTEX, myTEY, myTSX, myTSY );
679 SelectBrush ( ALLOCATOR -> myHDC, hob );
680} // end WNT_SectorNote :: Play
681
682////////////////////////////////////////////////////////////////////////////////
683// D r a w P o l y l i n e //
684////////////////////////////////////////////////////////////////////////////////
685void DrawPolyline ( HDC hdc, LPPOINT lpPts, int nPts, BOOL fClose )
686{
687 BeginPath ( hdc );
688 Polyline ( hdc, lpPts, nPts );
689 if (fClose)
690 CloseFigure ( hdc );
691 EndPath ( hdc );
692 StrokePath ( hdc );
693}
694////////////////////////////////////////////////////////////////////////////////
695// D r a w P o l y g o n //
696////////////////////////////////////////////////////////////////////////////////
697void DrawPolygon ( HDC hdc, LPPOINT lpPts, int nPts, UINT dwFlags )
698{
699 HPEN hpo = SelectPen ( hdc, GetStockObject ( NULL_PEN ) );
700 Polygon ( hdc, lpPts, nPts );
701 SelectPen ( hdc, hpo );
702
703 if ( dwFlags & POLYF_NOCLOSEDGE )
704 DrawPolyline ( hdc, lpPts, nPts, FALSE );
705 else if ( !( dwFlags & POLYF_NOEDGE ) )
706 DrawPolyline ( hdc, lpPts, nPts, TRUE );
707}
708////////////////////////////////////////////////////////////////////////////////
709// W N T _ P o l y M a r k e r 1 N o t e //
710////////////////////////////////////////////////////////////////////////////////
711WNT_PolyMarker1Note :: WNT_PolyMarker1Note (
712 int aMaxPoints, GetPointFunc fn, int aStartPoint,
713 void* fParam
714 ) : W32_PolyMarker1Note ( aMaxPoints, fn, aStartPoint, fParam)
715{
716} // end constructor
717
718void WNT_PolyMarker1Note :: Play ( BOOL fDummy )
719{
720 if ( ALLOCATOR -> myFlags & W32F_MFILL )
721 DrawPolygon ( ALLOCATOR -> myHDC, myPoints, mySetPoints, POLYF_NOCLOSEDGE );
722 else
723 DrawPolyline ( ALLOCATOR -> myHDC, myPoints, mySetPoints, FALSE );
724} // end WNT_PolyMarker1Note :: Play
725////////////////////////////////////////////////////////////////////////////////
726// W N T _ P o l y M a r k e r 2 N o t e //
727////////////////////////////////////////////////////////////////////////////////
728WNT_PolyMarker2Note :: WNT_PolyMarker2Note (
729 int aMaxPoints, GetPointFunc fn, int aStartPoint,
730 void* fParam
731 ) : WNT_PolyMarker1Note (
732 aMaxPoints, fn, aStartPoint, fParam
733 )
734{
735} // end constructor
736
737void WNT_PolyMarker2Note :: Play ( BOOL fDummy )
738{
739 if ( ALLOCATOR -> myFlags & W32F_MFILL )
740 DrawPolygon ( ALLOCATOR -> myHDC, myPoints, mySetPoints - 1, 0 );
741 else
742 DrawPolyline ( ALLOCATOR -> myHDC, myPoints, mySetPoints - 1, TRUE );
743} // end WNT_PolyMarker2Note :: Play
744////////////////////////////////////////////////////////////////////////////////
745// W N T _ P o l y g o n N o t e //
746////////////////////////////////////////////////////////////////////////////////
747WNT_PolygonNote :: WNT_PolygonNote ( int aMaxPoints ) :
748 W32_PolygonNote ( aMaxPoints )
749{
750 myTPoints = ( LPPOINT ) ALLOCATOR -> NewData (myMaxPoints * sizeof ( POINT ));
751} // end constructor
752
753void WNT_PolygonNote :: Play ( BOOL fDummy )
754{
755 Xform ();
756 DrawPolygon (
757 ALLOCATOR -> myHDC, myTPoints, mySetPoints,
758 ALLOCATOR -> myFlags & W32F_POUTL ? 0 : POLYF_NOEDGE
759 );
760} // end WNT_PolygonNote :: Play
761
762void WNT_PolygonNote :: Xform ()
763{
764 CopyMemory ( myTPoints, myPoints, mySetPoints*sizeof(POINT) );
765 for ( int i = 0; i < mySetPoints; i++ )
766 ALLOCATOR -> TransformPoint ( (myTPoints + i) );
767 ALLOCATOR -> Register ( myTPoints, mySetPoints );
768}
769////////////////////////////////////////////////////////////////////////////////
770// W N T _ P o l y l i n e N o t e //
771////////////////////////////////////////////////////////////////////////////////
772WNT_PolylineNote :: WNT_PolylineNote ( int aMaxPoints ) :
773 WNT_PolygonNote ( aMaxPoints )
774{
775} // end constructor
776
777void WNT_PolylineNote :: Play ( BOOL fDummy )
778{
779 Xform ();
780 DWORD nPts;
781 BOOL fClose;
782 int idx = mySetPoints - 1;
783 if ( myPoints -> x == myPoints[ idx ].x &&
784 myPoints -> y == myPoints[ idx ].y
785 ) {
786 nPts = idx;
787 fClose = TRUE;
788 } else {
789 nPts = mySetPoints;
790 fClose = FALSE;
791 } // end else
792 DrawPolyline ( ALLOCATOR->myHDC, myTPoints, nPts, fClose );
793} // end WNT_PolylineNote :: Play
794////////////////////////////////////////////////////////////////////////////////
795// W N T _ I m a g e N o t e //
796////////////////////////////////////////////////////////////////////////////////
797WNT_ImageNote :: WNT_ImageNote (
798 int x, int y, PW32_Bitmap pBmp, double aScale
799 ) : WNT_PointNote ( x, y )
800{
801 myBitmap = pBmp;
802 ++pBmp -> nUsed;
803 myScale = aScale;
804} // end constructor
805
806WNT_ImageNote :: ~WNT_ImageNote ()
807{
808 if ( myBitmap -> hBmp != NULL && --myBitmap -> nUsed == 0 ) {
809 DeleteObject ( myBitmap -> hBmp );
810 HeapFree ( GetProcessHeap (), 0, ( PVOID )myBitmap );
811 } // end if
812} // end WNT_ImageNote :: ~WNT_ImageNote
813
814void WNT_ImageNote :: Play ( BOOL fDummy )
815{
816 Xform ();
817 int xx, yy, w, h;
818 HDC hdcMem;
819 BITMAP bmp;
820 HBITMAP hbo;
821
822 GetObject ( myBitmap -> hBmp, sizeof ( BITMAP ), &bmp );
823 xx = myTX;
824 yy = myTY;
825 w = bmp.bmWidth;
826 h = bmp.bmHeight;
827 if ( myScale != 1.0 ) {
828 w = int ( w * myScale + 0.5 );
829 h = int ( h * myScale + 0.5 );
830 }
831 if ( ALLOCATOR -> myScaleX != 1.0 ) {
832 xx = int ( xx * ALLOCATOR -> myScaleX + 0.5 );
833 w = int ( w * ALLOCATOR -> myScaleX + 0.5 );
834 } // end if
835 if ( ALLOCATOR -> myScaleY != 1.0 ) {
836 yy = int ( yy * ALLOCATOR -> myScaleY + 0.5 );
837 h = int ( h * ALLOCATOR -> myScaleY + 0.5 );
838 } // end if
839 xx = xx - ( w >> 1 );
840 yy = yy + ( h >> 1 );
841 hdcMem = CreateCompatibleDC ( ALLOCATOR -> myHDC );
842 hbo = SelectBitmap ( hdcMem, myBitmap -> hBmp );
843 SetStretchBltMode ( hdcMem, COLORONCOLOR );
844 StretchBlt (
845 ALLOCATOR -> myHDC, xx, yy, w, -h,
846 hdcMem, 0, 0, bmp.bmWidth, bmp.bmHeight,
847 SRCCOPY
848 );
849 RECT r = { xx, yy, xx + w, yy - h };
850 ALLOCATOR -> Register ( &r );
851 SelectBitmap ( hdcMem, hbo );
852 DeleteDC ( hdcMem );
853} // end WNT_ImageNote :: Play
854////////////////////////////////////////////////////////////////////////////////
855// W N T _ T e x t N o t e //
856////////////////////////////////////////////////////////////////////////////////
857#define ROUNDL( d ) ( ( long )( ( d ) + ( ( d ) > 0 ? 0.5 : -0.5 ) ) )
858WNT_TextNote :: WNT_TextNote (
859 int x, int y, double angle, void* text,
860 BOOL fWide, BOOL fOutlined
861 ) : WNT_PointNote ( x, y )
862{
863 DWORD dwLen = fWide ? ( ( lstrlenW ( ( LPCWSTR )text ) + 1 ) << 1 )
864 : ( ( lstrlenA ( ( LPCSTR )text ) + 1 ) << 0 );
865 myText = ALLOCATOR -> NewData ( dwLen );
866 CopyMemory ( myText, text, dwLen );
867 myFlags = ( ( fWide ? W32F_TUNICODE : 0 ) |
868 ( fOutlined ? W32F_TOUTLINE : 0 )
869 );
870 ALLOCATOR -> RecalcMatrix ( RMatrix, angle );
871} // end constructor
872
873void WNT_TextNote :: PaintText ()
874{
875 if (myFlags & W32F_TUNICODE)
876 TextOutW ( ALLOCATOR -> myHDC, 0, myShift, (LPCWSTR)myText, lstrlenW ((LPCWSTR)myText) );
877 else
878 TextOutA ( ALLOCATOR -> myHDC, 0, myShift, (LPCSTR)myText, lstrlenA ((LPCSTR)myText) );
879} // end WNT_TextNote :: PaintText
880
881void WNT_TextNote :: SetAttribs ()
882{
883 ALLOCATOR -> myPO = SelectPen (ALLOCATOR -> myHDC, ALLOCATOR -> myTextPen );
884 ALLOCATOR -> myBO = SelectBrush (ALLOCATOR -> myHDC, ALLOCATOR -> myTextBrush);
885 ALLOCATOR -> myFO = SelectFont (ALLOCATOR -> myHDC, ALLOCATOR -> myTextFont );
886} // end WNT_TextNote :: SetAttribs
887
888void WNT_TextNote :: RestoreAttribs ()
889{
890 SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myPO );
891 SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myBO );
892 SelectFont ( ALLOCATOR -> myHDC, ALLOCATOR -> myFO );
893 ALLOCATOR -> Xform ();
894} // end WNT_TextNote :: RestoreAttribs
895
896void WNT_TextNote :: OutlineText ()
897{
898 BeginPath ( ALLOCATOR -> myHDC );
899 PaintText ( );
900 EndPath ( ALLOCATOR -> myHDC );
901 StrokePath ( ALLOCATOR -> myHDC );
902} // end WNT_TextNote :: OutlineText
903
904void WNT_TextNote :: FillText ()
905{
906 PaintText ();
907} // end WNT_TextNote :: FillText
908
909void WNT_TextNote :: Play ( BOOL fDummy )
910{
911 Xform ();
912 SIZE size;
913 RECT rect;
914 HDC hdc = ALLOCATOR -> myHDC;
915 // Set new world transform and attribs to get text size and metrics
916 SetAttribs ();
917 if ( myFlags & W32F_TUNICODE )
918 ALLOCATOR -> TextSize ( hdc, ( wchar_t* )myText, &size );
919 else
920 ALLOCATOR -> TextSize ( hdc, ( char* )myText, &size );
921 ModifyWorldTransform ( hdc, &RMatrix, MWT_LEFTMULTIPLY );
922 // Register and draw the bounding rect
923 rect.left = 0;
924 rect.top = 0;
925 rect.right = ROUNDL( ( FLOAT )size.cx * SMatrix.eM11 );
926 rect.bottom = -ROUNDL( ( FLOAT )size.cy * SMatrix.eM22 );
927 if (ALLOCATOR -> myTextSlant >= 0.F)
928 rect.right += ROUNDL( ( FLOAT )rect.bottom * IMatrix.eM21 );
929 else
930 rect.left += ROUNDL( ( FLOAT )rect.bottom * IMatrix.eM21 );
931 ALLOCATOR -> Register ( &rect );
932 // Draw ( fill or outline ) text
933 myShift = -size.cy;
934 ModifyWorldTransform ( hdc, &IMatrix, MWT_LEFTMULTIPLY );
935 ModifyWorldTransform ( hdc, &SMatrix, MWT_LEFTMULTIPLY );
936 if ( myFlags & W32F_TOUTLINE || ALLOCATOR -> myFlags & W32F_MONO ) OutlineText ();
937 else FillText ();
938 RestoreAttribs ();
939} // end WNT_TextNote :: Play
940
941void WNT_TextNote :: Xform ( void )
942{
7fd59977 943 WNT_PointNote :: Xform ();
944 RMatrix.eDx = float ( myTX );
945 RMatrix.eDy = float ( myTY );
946 SMatrix.eM11 = float ( ALLOCATOR -> myTextHScale * ALLOCATOR -> myScaleX );
947 SMatrix.eM12 = 0.0F;
948 SMatrix.eM21 = 0.0F;
949 SMatrix.eM22 = -float ( ALLOCATOR -> myTextVScale * ALLOCATOR -> myScaleY );
950 SMatrix.eDx = 0.0F;
951 SMatrix.eDy = 0.0F;
952 IMatrix.eM11 = 1.0F;
953 IMatrix.eM12 = 0.0F;
954 IMatrix.eM21 = float ( tan (ALLOCATOR -> myTextSlant) );
955 IMatrix.eM22 = 1.0F;
956 IMatrix.eDx = 0.0F;
957 IMatrix.eDy = 0.0F;
958} // enf WNT_TextNote :: Xform
959////////////////////////////////////////////////////////////////////////////////
960// W N T _ P o l y T e x t N o t e //
961////////////////////////////////////////////////////////////////////////////////
962WNT_PolyTextNote :: WNT_PolyTextNote (
963 int x, int y, double angle, double margin,
964 void* text, BOOL fWide, BOOL fOutlined
965 ) : WNT_TextNote ( x, y, angle, text, fWide, fOutlined ),
966 myMargin ( margin )
967{
968} // end constructor
969
970void WNT_PolyTextNote :: Play ( BOOL fDummy )
971{
972 Xform ();
973 SIZE size;
974 RECT rect;
975 int height;
976 HDC hdc = ALLOCATOR -> myHDC;
977 // Set new world transform and attribs to get text size and metrics
978 SetAttribs ();
979 if ( myFlags & W32F_TUNICODE )
980 ALLOCATOR -> TextSize ( hdc, ( wchar_t* )myText, &size );
981 else
982 ALLOCATOR -> TextSize ( hdc, ( char* )myText, &size );
983 RestoreAttribs ();
984 ModifyWorldTransform ( hdc, &RMatrix, MWT_LEFTMULTIPLY );
985 // Register and draw the bounding rect
986 rect.left = 0;
987 rect.top = 0;
988 rect.right = ROUNDL( ( FLOAT )size.cx * SMatrix.eM11 );
989 rect.bottom = -ROUNDL( ( FLOAT )size.cy * SMatrix.eM22 );
990 if (ALLOCATOR -> myTextSlant >= 0.F)
991 rect.right += ROUNDL( ( FLOAT )rect.bottom * IMatrix.eM21 );
992 else
993 rect.left += ROUNDL( ( FLOAT )rect.bottom * IMatrix.eM21 );
994 height = ROUNDL( (FLOAT)rect.bottom * (FLOAT)myMargin / 2.0F );
995 InflateRect ( &rect, height, height );
996 // Drawing round rectangle
997 HPEN hpo = ( (ALLOCATOR->myFlags & W32F_POUTL) ?
998 SelectPen ( hdc, ALLOCATOR -> myLinePen ):
999 SelectPen ( hdc, GetStockObject (NULL_PEN) ) );
1000 HBRUSH hbo = ( (ALLOCATOR->myFlags & W32F_NOFIL) ?
1001 SelectBrush ( hdc, GetStockObject (NULL_BRUSH) ):
1002 SelectBrush ( hdc, ALLOCATOR -> myPolyBrush ) );
1003 Rectangle ( hdc, rect.left, rect.top, rect.right, rect.bottom );
1004 SelectBrush ( hdc, hbo );
1005 SelectPen ( hdc, hpo );
1006 ALLOCATOR -> Register ( &rect );
1007 // Draw ( fill or outline ) text
1008 myShift = -size.cy;
1009 ModifyWorldTransform ( hdc, &IMatrix, MWT_LEFTMULTIPLY );
1010 ModifyWorldTransform ( hdc, &SMatrix, MWT_LEFTMULTIPLY );
1011 SetAttribs ();
1012 if (myFlags & W32F_TOUTLINE || ALLOCATOR -> myFlags & W32F_MONO) OutlineText ();
1013 else FillText ();
1014 RestoreAttribs ();
1015} // end WNT_PolyTextNote :: Play
1016////////////////////////////////////////////////////////////////////////////////
1017// W N T _ B e g i n M a r k e r N o t e //
1018////////////////////////////////////////////////////////////////////////////////
1019WNT_BeginMarkerNote :: WNT_BeginMarkerNote (
1020 int x, int y, int w, int h, double angle
1021 ) : WNT_PointNote ( x, y ),
1022 myAngle ( angle ), myWidth ( w ), myHeight ( h )
1023{
1024 myPrevAngle = ALLOCATOR -> myAngle;
1025 ALLOCATOR -> RecalcMatrix (myMatrix, myAngle - myPrevAngle, myX, myY);
1026} // end constructor
1027
1028void WNT_BeginMarkerNote :: Play ( BOOL fDummy )
1029{
1030 ALLOCATOR -> myPO = SelectPen (ALLOCATOR -> myHDC, ALLOCATOR -> myMarkerPen);
1031#ifdef PRO19042
1032 if ( ALLOCATOR -> myFlags & W32F_MFILL )
1033#else
1034 if ( ALLOCATOR -> myFlags | W32F_MFILL )
1035#endif
1036 ALLOCATOR -> myBO = SelectBrush (ALLOCATOR -> myHDC, ALLOCATOR -> myPolyBrush);
1037 else
1038 ALLOCATOR -> myBO = SelectBrush (ALLOCATOR -> myHDC, GetStockObject (NULL_BRUSH));
1039 Xform ();
1040} // end WNT_BeginMarkerNote :: Play
1041
1042void WNT_BeginMarkerNote :: Xform ()
1043{
1044 WNT_PointNote :: Xform ();
1045 if (myPrevAngle != ALLOCATOR -> myAngle) {
1046 myPrevAngle = ALLOCATOR -> myAngle;
1047 ALLOCATOR -> RecalcMatrix (myMatrix, myAngle - myPrevAngle, myX, myY);
1048 } // end if
1049 myMatrix.eDx = float ( myTX );
1050 myMatrix.eDy = float ( myTY );
1051 ModifyWorldTransform ( ALLOCATOR -> myHDC, &myMatrix, MWT_LEFTMULTIPLY );
1052 RECT r = { -myWidth / 2, -myHeight / 2, myWidth / 2, myHeight / 2 };
1053 ALLOCATOR -> Register ( &r );
1054}
1055////////////////////////////////////////////////////////////////////////////////
1056// W N T _ E n d M a r k e r N o t e //
1057////////////////////////////////////////////////////////////////////////////////
1058WNT_EndMarkerNote :: WNT_EndMarkerNote ()
1059{
1060}
1061
1062void WNT_EndMarkerNote :: Play ( BOOL fDummy )
1063{
1064 ALLOCATOR -> Xform ();
1065 SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myPO );
1066 SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myBO );
1067} // end WNT_EndMarkerNote :: Play
1068////////////////////////////////////////////////////////////////////////////////
1069// W N T _ L i n e A t t r i b N o t e //
1070////////////////////////////////////////////////////////////////////////////////
1071WNT_LineAttribNote :: WNT_LineAttribNote (
1072 DWORD width, PLOGBRUSH plb,
1073 DWORD nStyles, PDWORD pdwStyle
1074 )
1075{
1076 myPointColor = plb -> lbColor;
1077 myWidth = ((width == 0) ? 1 : width);
1078
1079 if ((width == 0 || width == 1) && (nStyles == 0)) {
1080 myPen = CreatePen (PS_SOLID, width, plb->lbColor);
1081 } else {
1082 DWORD pStyle = ( nStyles > 0 ? PS_USERSTYLE : PS_SOLID );
1083 pStyle |= ( PS_ENDCAP_FLAT | PS_JOIN_MITER | PS_GEOMETRIC );
1084 myPen = ExtCreatePen ( pStyle, width, plb, nStyles, pdwStyle );
1085 if ( !myPen ) {
1086 char err[1024];
1087 DWORD errCode = GetLastError();
1088 printf ( " *** WNT_LineAttribNote : Can't create extended pen: %lu\n", errCode );
1089 wsprintf ( err, "Can't create extended pen: %lu", errCode );
1090 MessageBox ( NULL, err, "WNT_Allocator", MB_OK | MB_ICONEXCLAMATION );
1091 myPen = CreatePen ( PS_SOLID, 1, RGB(170,170,70) );
1092 }
1093 }
1094 Play ( FALSE );
1095} // end constructor
1096
1097WNT_LineAttribNote :: ~WNT_LineAttribNote ( void )
1098{
1099#ifdef PRO19042
1100 if ( myPen ) {
1101#ifdef DEB
1102printf(" *** Destroy:WNT_LineAttribNote %x/%x\n",myPen,ALLOCATOR->myLinePen);
1103#endif
1104 DeletePen( myPen );
1105 myPen = NULL;
1106 }
1107#else
1108 if ( myPen && myPen != ALLOCATOR -> myLinePen )
1109 DeletePen( myPen );
1110#endif
1111} // enf WNT_LineAttribNote :: ~WNT_LineAttribNote
1112
1113void WNT_LineAttribNote :: Play ( BOOL fRealize )
1114{
1115 ALLOCATOR -> myLinePen = myPen;
1116 ALLOCATOR -> myLineWidth = myWidth;
1117 ALLOCATOR -> myPointColor = myPointColor;
1118 if ( fRealize )
1119 SelectPen ( ALLOCATOR -> myHDC, myPen );
1120} // end WNT_LineAttribNote :: Play
1121////////////////////////////////////////////////////////////////////////////////
1122// W N T _ P o l y A t t r i b N o t e //
1123////////////////////////////////////////////////////////////////////////////////
1124WNT_PolyAttribNote :: WNT_PolyAttribNote (
1125 PLOGBRUSH plb, BOOL fDrawEdge, int aFillMode
1126 )
1127{
1128 myfEdge = fDrawEdge;
1129 myNoFill = ( plb -> lbStyle == BS_NULL );
1130 myBrush = CreateBrushIndirect ( plb );
1131 Play ( FALSE );
1132} // end constructor
1133
1134WNT_PolyAttribNote :: ~WNT_PolyAttribNote ( void )
1135{
1136#ifdef PRO19042
1137 if ( myBrush ) {
1138#ifdef DEB
1139printf(" *** Destroy:WNT_PolyAttribNote %x/%x\n",myBrush,ALLOCATOR->myPolyBrush);
1140#endif
1141 DeleteBrush( myBrush );
1142 myBrush = NULL;
1143 }
1144#else
1145 if ( myBrush && myBrush != ALLOCATOR -> myPolyBrush )
1146 DeleteBrush( myBrush );
1147#endif
1148} // enf WNT_PolyAttribNote :: ~WNT_PolyAttribNote
1149
1150void WNT_PolyAttribNote :: Play ( BOOL fRealize )
1151{
1152 if ( myfEdge ) ALLOCATOR -> myFlags |= W32F_POUTL;
1153 else ALLOCATOR -> myFlags &= ~W32F_POUTL;
1154 if ( myNoFill ) ALLOCATOR -> myFlags |= W32F_NOFIL;
1155 else ALLOCATOR -> myFlags &= ~W32F_NOFIL;
1156 ALLOCATOR -> myPolyBrush = myBrush;
1157 if ( fRealize ) {
1158 SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myLinePen );
1159 SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myPolyBrush );
1160 }
1161} // end WNT_PolyAttribNote :: Play
1162////////////////////////////////////////////////////////////////////////////////
1163// W N T _ T e x t A t t r i b N o t e //
1164////////////////////////////////////////////////////////////////////////////////
1165WNT_TextAttribNote :: WNT_TextAttribNote (
1166 HFONT hFont, COLORREF color, double slant,
1167 double hScale, double vScale,
1168 BOOL fUnderlined, BOOL fFree, BOOL fIndex
1169 )
1170{
1171 myFont = hFont;
1172 mySlant = (slant == 0.0 ? EPS : slant);
1173 myHScale = vScale;
1174 myVScale = hScale;
1175 myFlags = ( fUnderlined ? W32F_TFULINED : 0 ) |
1176 ( fIndex ? W32F_TINDEX : 0 ) |
1177 ( fFree ? W32F_TFREE : 0 );
1178 myColor = color;
1179 myPen = CreatePen ( PS_SOLID, 0, color );
1180 myBrush = CreateSolidBrush ( color );
1181 Play ( FALSE );
1182} // end constructor
1183
1184WNT_TextAttribNote :: ~WNT_TextAttribNote ()
1185{
1186#ifdef PRO19042
1187 if ( myFont && (myFlags & W32F_TFREE) ) {
1188#ifdef DEB
1189printf(" *** Destroy:WNT_TextAttribNote_FONT %x/%x\n",myFont,ALLOCATOR->myTextFont);
1190#endif
1191 DeleteFont ( myFont );
1192 myFont = NULL;
1193 }
1194 if ( myPen ) {
1195#ifdef DEB
1196printf(" *** Destroy:WNT_TextAttribNote_PEN %x/%x\n",myPen,ALLOCATOR->myTextPen);
1197#endif
1198 DeletePen ( myPen );
1199 myPen = NULL;
1200 }
1201 if ( myBrush ) {
1202#ifdef DEB
1203printf(" *** Destroy:WNT_TextAttribNote_BRUSH %x/%x\n",myBrush,ALLOCATOR->myTextBrush);
1204#endif
1205 DeleteBrush ( myBrush );
1206 myBrush = NULL;
1207 }
1208#else
1209 if ( myFlags & W32F_TFREE ) DeleteFont ( myFont );
1210 if ( myPen && myPen != ALLOCATOR -> myTextPen ) DeletePen ( myPen );
1211 if ( myBrush && myBrush != ALLOCATOR -> myTextBrush ) DeleteBrush ( myBrush );
1212#endif
1213} // end destructor
1214
1215void WNT_TextAttribNote :: Play ( BOOL fRealize )
1216{
1217 if ( ( ALLOCATOR -> myFlags & W32F_DFONT ) && !( myFlags & W32F_TINDEX ) ) {
1218 DeleteFont( ALLOCATOR -> myTextFont );
1219 ALLOCATOR -> myFlags &= ~W32F_DFONT;
1220 } // end if
1221 ALLOCATOR -> myTextFont = myFont;
1222 ALLOCATOR -> myTextSlant = mySlant;
1223 ALLOCATOR -> myTextHScale = myHScale;
1224 ALLOCATOR -> myTextVScale = myVScale;
1225 ALLOCATOR -> myTextColor = myColor;
1226 ALLOCATOR -> myTextPen = myPen;
1227 ALLOCATOR -> myTextBrush = myBrush;
1228 if (myFlags & W32F_TFULINED) ALLOCATOR -> myFlags |= W32F_TULIN;
1229 else ALLOCATOR -> myFlags &= ~W32F_TULIN;
1230 if ( fRealize && !( myFlags & W32F_TINDEX ) ) {
1231 SetTextColor ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextColor );
1232 SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextPen );
1233 SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextBrush );
1234 SelectFont ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextFont );
1235 }
1236} // end WNT_TextAttribNote :: Play
1237////////////////////////////////////////////////////////////////////////////////
1238// W N T _ M a r k e r A t t r i b N o t e //
1239////////////////////////////////////////////////////////////////////////////////
1240WNT_MarkerAttribNote :: WNT_MarkerAttribNote (
1241 COLORREF color, DWORD dwWidth, BOOL fFill
1242 )
1243{
1244 DWORD width = (dwWidth == 0) ? 1 : dwWidth;
1245
1246 myFill = fFill;
1247 myMarkerPointColor = color;
1248 myPen = CreatePen ( PS_SOLID, width, color );
1249 Play ();
1250} // end constructor
1251
1252WNT_MarkerAttribNote :: ~WNT_MarkerAttribNote ( void )
1253{
1254#ifdef PRO19042
1255 if ( myPen ) {
1256#ifdef DEB
1257printf(" *** Destroy:WNT_MarkerAttribNote %x/%x\n",myPen,ALLOCATOR->myMarkerPen);
1258#endif
1259 DeletePen( myPen );
1260 myPen = NULL;
1261 }
1262#else
1263 if ( myPen && myPen != ALLOCATOR -> myMarkerPen ) DeletePen( myPen );
1264#endif
1265} // enf WNT_MarkerAttribNote :: ~WNT_MarkerAttribNote
1266
1267void WNT_MarkerAttribNote :: Play ( BOOL fRealize )
1268{
1269 if (myFill) ALLOCATOR -> myFlags |= W32F_MFILL;
1270 else ALLOCATOR -> myFlags &= ~W32F_MFILL;
1271
1272 ALLOCATOR -> myMarkerPen = myPen;
1273 ALLOCATOR -> myMarkerPointColor = myMarkerPointColor;
1274} // end WNT_MarkerAttribNote :: Play