1 // Created by: PLOTNIKOV Eugeny & CHABROVSKY Dmitry
2 // Copyright (c) 1998-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #ifndef __W32_ALLOCATOR_HXX
22 # define __W32_ALLOCATOR_HXX
28 # ifndef WIN32_LEAN_AND_MEAN
29 # define WIN32_LEAN_AND_MEAN
31 # undef NOGDI /* we need GDI definitions here... */
34 # endif /* WIN32_LEAN_AND_MEAN */
35 # endif /* _WINDOWS */
37 # define __W32_DATA -1
41 # define W32F_TOUTLINE 0x00000001 // text flags
42 # define W32F_TUNICODE 0x00000002
43 # define W32F_TINDEX 0x00000004
44 # define W32F_TFREE 0x00000008
45 # define W32F_TFULINED 0x00000010
47 # define W32F_EMPTY 0x00000001
48 # define W32F_DRAWN 0x00000002
49 # define W32F_XFORM 0x00000004
50 # define W32F_MONO 0x00000008
51 # define W32F_DBUFF 0x00000010
52 # define W32F_START 0x00000020
53 # define W32F_WIN95 0x00000040
54 # define W32F_DVDRV 0x00000080
55 # define W32F_TULIN 0x00000100
56 # define W32F_MINIT 0x00000200
57 # define W32F_NOFIL 0x00000400
58 # define W32F_MFILL 0x80000000
59 # define W32F_MOUTL 0x40000000
60 # define W32F_POUTL 0x20000000
61 # define W32F_DFONT 0x10000000
63 #define OCC5415 /* avoid warning C4291 in MS VC++ 6.0 */
67 zzNone, zzPoint, zzLine, zzPolyRect, zzRect, zzPolyEllipse,
68 zzRoundRect, zzPolyRoundRect, zzArc, zzChord, zzPolyChord, zzSector,
69 zzPolySector, zzPolygon, zzPolyline, zzLinkedPolyline, zzBezier, zzText,
75 typedef W32_Allocator* PW32_Allocator;
77 typedef struct _W32_Block { // memory block
84 } W32_Block, *PW32_Block;
86 typedef struct _W32_bitmap {
91 } W32_Bitmap, *PW32_Bitmap;
93 typedef struct _W32_FCallParam {
98 } W32_FCALLPARAM, *PW32_FCALLPARAM;
100 typedef void ( WINAPI *GetPointFunc ) ( int, int, int, LPPOINT, int*, void* );
102 typedef void ( __cdecl *W32_FCall ) ( PW32_FCALLPARAM );
104 struct W32_Note { // base class to represent graphic object
107 virtual ~W32_Note () {}
109 void* operator new ( size_t, W32_Allocator* );
111 virtual void Play ( BOOL = TRUE ) = 0;
112 virtual void Xform ( void ) {}
113 virtual void Release ( void ) {}
115 PW32_Allocator myAllocator;
118 void operator delete (void*, W32_Allocator*) {}
119 private: // to protect against possible accidental usage
120 void operator delete (void*) {}
124 ///////////////////////// POINTS ////////////////////////////
126 struct W32_PointNote : public W32_Note {
128 W32_PointNote ( int, int );
130 virtual void Play ( BOOL = TRUE );
136 struct WNT_PointNote : public W32_PointNote {
138 WNT_PointNote ( int, int );
140 virtual void Play ( BOOL = TRUE );
141 virtual void Xform ( void );
147 struct W32_MarkerPointNote : public W32_PointNote {
149 W32_MarkerPointNote ( int, int );
151 virtual void Play ( BOOL = TRUE );
155 struct WNT_MarkerPointNote : public WNT_PointNote {
157 WNT_MarkerPointNote ( int, int );
159 virtual void Play ( BOOL = TRUE );
163 ///////////////////////// LINES //////////////////////////////
165 struct W32_LineNote : public W32_PointNote {
167 W32_LineNote ( int, int, int, int );
169 virtual void Play ( BOOL = TRUE );
175 struct WNT_LineNote : public WNT_PointNote {
177 WNT_LineNote ( int, int, int, int );
179 virtual void Play ( BOOL = TRUE );
180 virtual void Xform ( void );
182 int myX2, myY2, myTX2, myTY2;
186 ////////////////////// POLY ELLIPSES /////////////////////////
188 struct W32_PolyEllipseNote : public W32_PointNote {
190 W32_PolyEllipseNote ( int, int, int, int );
192 virtual void Play ( BOOL = TRUE );
198 struct WNT_PolyEllipseNote : public WNT_PointNote {
200 WNT_PolyEllipseNote ( int, int, int, int );
202 virtual void Play ( BOOL = TRUE );
203 virtual void Xform ( void );
205 int myXr, myYr, myTXr, myTYr;
209 ///////////////////////// ELLIPSES ///////////////////////////
211 struct W32_EllipseNote : public W32_PolyEllipseNote {
213 W32_EllipseNote ( int, int, int, int );
215 virtual void Play ( BOOL = TRUE );
219 struct WNT_EllipseNote : public WNT_PolyEllipseNote {
221 WNT_EllipseNote ( int, int, int, int );
223 virtual void Play ( BOOL = TRUE );
227 /////////////////////////// ARCS /////////////////////////////
229 struct W32_ArcNote : public W32_PolyEllipseNote {
231 W32_ArcNote ( int, int, int, int, double, double );
233 virtual void Play ( BOOL = TRUE );
239 struct WNT_ArcNote : public WNT_PolyEllipseNote {
241 WNT_ArcNote ( int, int, int, int, double, double );
243 virtual void Play ( BOOL = TRUE );
244 virtual void Xform ( void );
246 int mySX, mySY, myTSX, myTSY,
247 myEX, myEY, myTEX, myTEY,
251 /////////////////////// POLY CHORDS //////////////////////////
253 struct W32_PolyChordNote : public W32_ArcNote {
255 W32_PolyChordNote ( int, int, int, int, double, double );
257 virtual void Play ( BOOL = TRUE );
261 struct WNT_PolyChordNote : public WNT_ArcNote {
263 WNT_PolyChordNote ( int, int, int, int, double, double );
265 virtual void Play ( BOOL = TRUE );
269 ////////////////////////// CHORDS ////////////////////////////
271 struct W32_ChordNote : public W32_PolyChordNote {
273 W32_ChordNote ( int, int, int, int, double, double );
275 virtual void Play ( BOOL = TRUE );
279 struct WNT_ChordNote : public WNT_PolyChordNote {
281 WNT_ChordNote ( int, int, int, int, double, double );
283 virtual void Play ( BOOL = TRUE );
287 ////////////////////// POLY SECTORS //////////////////////////
289 struct W32_PolySectorNote : public W32_ArcNote {
291 W32_PolySectorNote ( int, int, int, int, double, double );
293 virtual void Play ( BOOL = TRUE );
297 struct WNT_PolySectorNote : public WNT_ArcNote {
299 WNT_PolySectorNote ( int, int, int, int, double, double );
301 virtual void Play ( BOOL = TRUE );
305 /////////////////////// SECTORS //////////////////////////////
307 struct W32_SectorNote : public W32_PolySectorNote {
309 W32_SectorNote ( int, int, int, int, double, double );
311 virtual void Play ( BOOL = TRUE );
315 struct WNT_SectorNote : public WNT_PolySectorNote {
317 WNT_SectorNote ( int, int, int, int, double, double );
319 virtual void Play ( BOOL = TRUE );
323 /////////////////////// MARKERS //////////////////////////////
325 struct W32_PolyMarkerNote : public W32_Note {
327 W32_PolyMarkerNote ( int );
329 void Replace ( int, int, int );
331 virtual void Play ( BOOL = TRUE ) {}
333 int myMaxPoints, mySetPoints;
338 struct W32_PolyMarker1Note : public W32_PolyMarkerNote {
340 W32_PolyMarker1Note ( int, GetPointFunc, int, void* );
342 virtual void Play ( BOOL = TRUE );
346 struct WNT_PolyMarker1Note : public W32_PolyMarker1Note {
348 WNT_PolyMarker1Note ( int, GetPointFunc, int, void* );
350 virtual void Play ( BOOL = TRUE );
354 struct W32_PolyMarker2Note : public W32_PolyMarker1Note {
356 W32_PolyMarker2Note ( int, GetPointFunc, int, void* );
358 virtual void Play ( BOOL = TRUE );
362 struct WNT_PolyMarker2Note : public WNT_PolyMarker1Note {
364 WNT_PolyMarker2Note ( int, GetPointFunc, int, void* );
366 virtual void Play ( BOOL = TRUE );
370 /////////////////////// POLYGONS /////////////////////////////
372 struct W32_PolygonNote : public W32_PolyMarkerNote {
374 W32_PolygonNote ( int );
376 void Add ( int, int );
378 virtual void Play ( BOOL = TRUE );
382 struct WNT_PolygonNote : public W32_PolygonNote {
384 WNT_PolygonNote ( int );
386 virtual void Play ( BOOL = TRUE );
387 virtual void Xform ( void );
393 /////////////////////// POLYLINES ////////////////////////////
395 struct W32_PolylineNote : public W32_PolygonNote {
397 W32_PolylineNote ( int );
399 virtual void Play ( BOOL = TRUE );
403 struct WNT_PolylineNote : public WNT_PolygonNote {
405 WNT_PolylineNote ( int );
407 virtual void Play ( BOOL = TRUE );
411 ///////////////////////// IMAGES /////////////////////////////
413 struct W32_ImageNote : public W32_PointNote {
415 W32_ImageNote ( int, int, PW32_Bitmap, double = 1.0 );
416 virtual ~W32_ImageNote ();
418 virtual void Play ( BOOL = TRUE );
420 PW32_Bitmap myBitmap;
425 struct WNT_ImageNote : public WNT_PointNote {
427 WNT_ImageNote ( int, int, PW32_Bitmap, double = 1.0 );
428 virtual ~WNT_ImageNote ();
430 virtual void Play ( BOOL = TRUE );
432 PW32_Bitmap myBitmap;
437 ///////////////////////// TEXTS //////////////////////////////
439 struct W32_TextNote : public W32_PointNote {
441 W32_TextNote ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE );
443 virtual void Play ( BOOL = TRUE );
451 struct WNT_TextNote : public WNT_PointNote {
453 WNT_TextNote ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE );
455 virtual void Play ( BOOL = TRUE );
456 virtual void Xform ( void );
458 void RestoreAttribs ();
473 /////////////////////// POLYTEXTS ////////////////////////////
475 struct W32_PolyTextNote : public W32_TextNote {
477 W32_PolyTextNote ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE );
479 virtual void Play ( BOOL = TRUE );
485 struct WNT_PolyTextNote : public WNT_TextNote {
487 WNT_PolyTextNote ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE );
489 virtual void Play ( BOOL = TRUE );
495 ////////////////// BEGIN/END MARKERS /////////////////////////
497 struct W32_BeginMarkerNote : public W32_PointNote {
499 W32_BeginMarkerNote ( int, int, int, int, double );
501 virtual void Play ( BOOL = TRUE );
503 int myWidth, myHeight;
508 struct WNT_BeginMarkerNote : public WNT_PointNote {
510 WNT_BeginMarkerNote ( int, int, int, int, double );
512 virtual void Play ( BOOL = TRUE );
513 virtual void Xform ( void );
515 int myWidth, myHeight;
516 double myAngle, myPrevAngle;
521 struct W32_EndMarkerNote : public W32_Note {
523 W32_EndMarkerNote ();
525 virtual void Play ( BOOL = TRUE );
529 struct WNT_EndMarkerNote : public W32_Note {
531 WNT_EndMarkerNote ();
533 virtual void Play ( BOOL = TRUE );
537 //////////////////// A T T R I B U T E S /////////////////////
539 struct W32_LineAttribNote : public W32_Note {
541 W32_LineAttribNote ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL );
543 virtual void Play ( BOOL = TRUE );
552 struct WNT_LineAttribNote : public W32_Note {
554 WNT_LineAttribNote ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL );
555 virtual ~WNT_LineAttribNote ();
557 virtual void Play ( BOOL = TRUE );
561 COLORREF myPointColor;
565 struct W32_PolyAttribNote : public W32_Note {
567 W32_PolyAttribNote ( PLOGBRUSH, BOOL, int = ALTERNATE );
569 virtual void Play ( BOOL = TRUE );
577 struct WNT_PolyAttribNote : public W32_Note {
579 WNT_PolyAttribNote ( PLOGBRUSH, BOOL, int = ALTERNATE );
580 virtual ~WNT_PolyAttribNote ();
582 virtual void Play ( BOOL = TRUE );
591 struct W32_TextAttribNote : public W32_Note {
594 HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
595 BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
597 virtual ~W32_TextAttribNote ();
599 virtual void Play ( BOOL = TRUE );
610 struct WNT_TextAttribNote : public W32_Note {
613 HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
614 BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
616 virtual ~WNT_TextAttribNote ();
618 virtual void Play ( BOOL = TRUE );
632 struct W32_MarkerAttribNote : public W32_Note {
634 W32_MarkerAttribNote ( COLORREF, DWORD, BOOL );
636 virtual void Play ( BOOL = TRUE );
642 struct WNT_MarkerAttribNote : public W32_Note {
644 WNT_MarkerAttribNote ( COLORREF, DWORD, BOOL );
645 virtual ~WNT_MarkerAttribNote ();
647 virtual void Play ( BOOL = TRUE );
650 COLORREF myMarkerPointColor;
655 //////////////////// F U N C T I O N C A L L ////////////////
657 struct W32_FCallNote : public W32_Note {
659 W32_FCallNote ( W32_FCall, int, PW32_FCALLPARAM );
661 virtual void Play ( BOOL = TRUE );
664 PW32_FCALLPARAM myParam;
668 //////////////////// A L L O C A T O R ///////////////////////
670 struct W32_Allocator {
672 W32_Allocator ( int, PW32_Allocator = NULL );
673 virtual ~W32_Allocator ();
675 PW32_Block MakeBlock ( int );
676 // allocates memory block
677 virtual PW32_Block KillBlock ( PW32_Block );
678 // deallocates memory block
679 void KillBlocks ( PW32_Block );
680 // deallocates memory blocks starting from specified one
681 void ClearBlocks ( void );
683 void ReleaseBlock ( PW32_Block );
684 // releases graphics primitives in the specified block
685 BOOL FreeSpace ( PW32_Block, int );
686 // checks for free space in the specified block
687 PW32_Block ReserveData ( unsigned int );
688 // checks for free space in the current block
689 PW32_Block ReserveFind ( unsigned int );
690 // searches for free space
691 void* ReserveBlock ( PW32_Block, int, BOOL = FALSE );
692 // reserves data in the specified block
693 void* NewClass ( unsigned int );
694 // gets space for a new class ( W32_Note )
695 void* NewData ( unsigned int, BOOL = FALSE );
696 // gets space for a new data
697 virtual void Xform ( void ) = 0;
698 // sets world transformation in the device context
700 virtual void Play ( HDC, PSIZE ) = 0;
702 virtual void URect ( LPRECT ) = 0;
703 // gets updated rectangle
705 virtual void Point ( int, int ) = 0;
707 virtual void MarkerPoint ( int, int ) = 0;
708 // stores a marker point
709 virtual void Line ( int, int, int, int ) = 0;
710 // stores a line segment
711 virtual void PolyEllipse ( int, int, int, int ) = 0;
712 // stores a polyellipse
713 virtual void Ellipse ( int, int, int, int ) = 0;
715 virtual void Arc ( int, int, int, int, double, double ) = 0;
717 virtual void PolyChord ( int, int, int, int, double, double ) = 0;
718 // stores a polychord
719 virtual void Chord ( int, int, int, int, double, double ) = 0;
721 virtual void PolySector ( int, int, int, int, double, double ) = 0;
722 // stores a polysector
723 virtual void Sector ( int, int, int, int, double, double ) = 0;
725 virtual void PolyMarker ( int ) = 0;
726 // stores a polymarker
727 virtual void PolyMarker1 ( int, GetPointFunc, int, void* ) = 0;
728 // stores a polymarker1
729 virtual void PolyMarker2 ( int, GetPointFunc, int, void* ) = 0;
730 // stores a polymarker2
731 virtual W32_Note* Polygon ( int ) = 0;
733 virtual W32_Note* Polyline ( int ) = 0;
735 virtual void Image ( int, int, PW32_Bitmap, double = 1.0 ) = 0;
737 virtual void Text ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE ) = 0;
739 virtual void Polytext ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE ) = 0;
741 virtual void BeginMarker ( int, int, int, int, double ) = 0;
742 // stores the begin of marker
743 virtual void EndMarker ( void ) = 0;
744 // stores end of the marker
745 virtual void LineAttrib ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL ) = 0;
746 // stores line attributes
747 virtual void PolyAttrib ( PLOGBRUSH, BOOL, int = ALTERNATE ) = 0;
748 // stores polygon attributes
749 virtual void TextAttrib (
750 HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
751 BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
753 //stores text attributes
754 virtual void MarkerAttrib ( COLORREF, DWORD, BOOL ) = 0;
755 // stores marker attributes
756 virtual void FunCall ( W32_FCall, int, PW32_FCALLPARAM ) = 0;
757 // stores function call
759 virtual int TextSize ( HDC, char*, PSIZE ) = 0;
760 virtual int TextSize ( HDC, wchar_t*, PSIZE ) = 0;
761 //obtains dimensions of the text string
764 PW32_Allocator myNext;
765 PW32_Block myStart, myEnd;
766 W32_Primitive myPrimitive;
772 double myScaleX, myScaleY;
778 COLORREF myPointColor,
783 extern PW32_Allocator ( *W32_GetAllocator ) ( int, PW32_Allocator );
785 #define P(v) LONG( ( v ) / myPixelToUnit + 0.5 )
786 #define U(v) ( ( v ) * myPixelToUnit )
788 #endif // __W32_ALLOCATOR_HXX