Creating of many interactive 2D objects (> 10000, for example 50000)

At the time of Open Cascade 5.2 i wrote message about critical error where many interactive curves (2D objects) created. Creating of many interactive 2D objects (> 10000, for example 50000) reduce to program failure. I don’t taked satisfactory answer for my question and I solved this problem independently. The problem consist in creating for every interactive object new PEN or BRUSH objects. At the same time number of PEN or BRUSH objects in MS Win limited.
In «WNT_Allocator.cxx» and «W32_Allocator.hxx» files I made PEN and BRUSH Manadger, which create only unique PEN and BRUSH objects.
After Open Cascade 5.2 appear 2 new version of OC, and PEN and BRUSH problem don’t soled.
At this message I attach repaired files for Open Cascade 6.1.0. All correction marked «ChP», and may be easy transfer to other version.
I hope this corrections will be used for production Open Cascade «7.1.0».

------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------- W32_Allocator.hxx -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// File: W32_Allocator.hxx
// Created: Feb 1998
// Author: PLOTNIKOV Eugeny & CHABROVSKY Dmitry
// Copyright: Matra Datavision 1998

#ifndef __W32_ALLOCATOR_HXX
# define __W32_ALLOCATOR_HXX

# ifndef _WINDOWS_
# ifndef STRICT
# define STRICT
# endif /* STRICT */
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# include
# include
# endif /* WIN32_LEAN_AND_MEAN */
# endif /* _WINDOWS */

# define __W32_DATA -1

# define EPS 0.005F

# define W32F_TOUTLINE 0x00000001 // text flags
# define W32F_TUNICODE 0x00000002
# define W32F_TINDEX 0x00000004
# define W32F_TFREE 0x00000008
# define W32F_TFULINED 0x00000010

# define W32F_EMPTY 0x00000001
# define W32F_DRAWN 0x00000002
# define W32F_XFORM 0x00000004
# define W32F_MONO 0x00000008
# define W32F_DBUFF 0x00000010
# define W32F_START 0x00000020
# define W32F_WIN95 0x00000040
# define W32F_DVDRV 0x00000080
# define W32F_TULIN 0x00000100
# define W32F_MINIT 0x00000200
# define W32F_NOFIL 0x00000400
# define W32F_MFILL 0x80000000
# define W32F_MOUTL 0x40000000
# define W32F_POUTL 0x20000000
# define W32F_DFONT 0x10000000

// !!! ChP
#include

#define OCC5415 /* avoid warning C4291 in MS VC++ 6.0 */

typedef enum {

zzNone, zzPoint, zzLine, zzPolyRect, zzRect, zzPolyEllipse,
zzRoundRect, zzPolyRoundRect, zzArc, zzChord, zzPolyChord, zzSector,
zzPolySector, zzPolygon, zzPolyline, zzLinkedPolyline, zzBezier, zzText,
zzPolyText, zzMarker

} W32_Primitive;

struct W32_Allocator;
typedef W32_Allocator* PW32_Allocator;

typedef struct _W32_Block { // memory block

_W32_Block* next;
int size;
int free;
int data[ 1 ];

} W32_Block, *PW32_Block;

typedef struct _W32_bitmap {

int nUsed;
HBITMAP hBmp;

} W32_Bitmap, *PW32_Bitmap;

typedef struct _W32_FCallParam {

void* pAllocator;
void* pDriver;

} W32_FCALLPARAM, *PW32_FCALLPARAM;

typedef void ( WINAPI *GetPointFunc ) ( int, int, int, LPPOINT, int*, void* );

typedef void ( __cdecl *W32_FCall ) ( PW32_FCALLPARAM );

struct W32_Note { // base class to represent graphic object

W32_Note () {}
virtual ~W32_Note () {}

void* operator new ( size_t, W32_Allocator* );

virtual void Play ( BOOL = TRUE ) = 0;
virtual void Xform ( void ) {}
virtual void Release ( void ) {}

PW32_Allocator myAllocator;

#ifdef OCC5415
void operator delete (void*, W32_Allocator*) {}
private: // to protect against possible accidental usage
void operator delete (void* p) {}
#endif
};
///
///////////////////////// POINTS ////////////////////////////
///
struct W32_PointNote : public W32_Note {

W32_PointNote ( int, int );

virtual void Play ( BOOL = TRUE );

int myX, myY;

};

struct WNT_PointNote : public W32_PointNote {

WNT_PointNote ( int, int );

virtual void Play ( BOOL = TRUE );
virtual void Xform ( void );

int myTX, myTY;

};

struct W32_MarkerPointNote : public W32_PointNote {

W32_MarkerPointNote ( int, int );

virtual void Play ( BOOL = TRUE );

};

struct WNT_MarkerPointNote : public WNT_PointNote {

WNT_MarkerPointNote ( int, int );

virtual void Play ( BOOL = TRUE );

};
///
///////////////////////// LINES //////////////////////////////
///
struct W32_LineNote : public W32_PointNote {

W32_LineNote ( int, int, int, int );

virtual void Play ( BOOL = TRUE );

int myX2, myY2;

};

struct WNT_LineNote : public WNT_PointNote {

WNT_LineNote ( int, int, int, int );

virtual void Play ( BOOL = TRUE );
virtual void Xform ( void );

int myX2, myY2, myTX2, myTY2;

};
///
////////////////////// POLY ELLIPSES /////////////////////////
///
struct W32_PolyEllipseNote : public W32_PointNote {

W32_PolyEllipseNote ( int, int, int, int );

virtual void Play ( BOOL = TRUE );

int myXr, myYr;

};

struct WNT_PolyEllipseNote : public WNT_PointNote {

WNT_PolyEllipseNote ( int, int, int, int );

virtual void Play ( BOOL = TRUE );
virtual void Xform ( void );

int myXr, myYr, myTXr, myTYr;

};
///
///////////////////////// ELLIPSES ///////////////////////////
///
struct W32_EllipseNote : public W32_PolyEllipseNote {

W32_EllipseNote ( int, int, int, int );

virtual void Play ( BOOL = TRUE );

};

struct WNT_EllipseNote : public WNT_PolyEllipseNote {

WNT_EllipseNote ( int, int, int, int );

virtual void Play ( BOOL = TRUE );

};
///
/////////////////////////// ARCS /////////////////////////////
///
struct W32_ArcNote : public W32_PolyEllipseNote {

W32_ArcNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

double mySa, myOa;

};

struct WNT_ArcNote : public WNT_PolyEllipseNote {

WNT_ArcNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );
virtual void Xform ( void );

int mySX, mySY, myTSX, myTSY,
myEX, myEY, myTEX, myTEY,
myDirect;
};
///
/////////////////////// POLY CHORDS //////////////////////////
///
struct W32_PolyChordNote : public W32_ArcNote {

W32_PolyChordNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

};

struct WNT_PolyChordNote : public WNT_ArcNote {

WNT_PolyChordNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

};
///
////////////////////////// CHORDS ////////////////////////////
///
struct W32_ChordNote : public W32_PolyChordNote {

W32_ChordNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

};

struct WNT_ChordNote : public WNT_PolyChordNote {

WNT_ChordNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

};
///
////////////////////// POLY SECTORS //////////////////////////
///
struct W32_PolySectorNote : public W32_ArcNote {

W32_PolySectorNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

};

struct WNT_PolySectorNote : public WNT_ArcNote {

WNT_PolySectorNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

};
///
/////////////////////// SECTORS //////////////////////////////
///
struct W32_SectorNote : public W32_PolySectorNote {

W32_SectorNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

};

struct WNT_SectorNote : public WNT_PolySectorNote {

WNT_SectorNote ( int, int, int, int, double, double );

virtual void Play ( BOOL = TRUE );

};
///
/////////////////////// MARKERS //////////////////////////////
///
struct W32_PolyMarkerNote : public W32_Note {

W32_PolyMarkerNote ( int );

void Replace ( int, int, int );

virtual void Play ( BOOL = TRUE ) {}

int myMaxPoints, mySetPoints;
LPPOINT myPoints;

};

struct W32_PolyMarker1Note : public W32_PolyMarkerNote {

W32_PolyMarker1Note ( int, GetPointFunc, int, void* );

virtual void Play ( BOOL = TRUE );

};

struct WNT_PolyMarker1Note : public W32_PolyMarker1Note {

WNT_PolyMarker1Note ( int, GetPointFunc, int, void* );

virtual void Play ( BOOL = TRUE );

};

struct W32_PolyMarker2Note : public W32_PolyMarker1Note {

W32_PolyMarker2Note ( int, GetPointFunc, int, void* );

virtual void Play ( BOOL = TRUE );

};

struct WNT_PolyMarker2Note : public WNT_PolyMarker1Note {

WNT_PolyMarker2Note ( int, GetPointFunc, int, void* );

virtual void Play ( BOOL = TRUE );

};
///
/////////////////////// POLYGONS /////////////////////////////
///
struct W32_PolygonNote : public W32_PolyMarkerNote {

W32_PolygonNote ( int );

void Add ( int, int );

virtual void Play ( BOOL = TRUE );

};

struct WNT_PolygonNote : public W32_PolygonNote {

WNT_PolygonNote ( int );

virtual void Play ( BOOL = TRUE );
virtual void Xform ( void );

LPPOINT myTPoints;

};
///
/////////////////////// POLYLINES ////////////////////////////
///
struct W32_PolylineNote : public W32_PolygonNote {

W32_PolylineNote ( int );

virtual void Play ( BOOL = TRUE );

};

struct WNT_PolylineNote : public WNT_PolygonNote {

WNT_PolylineNote ( int );

virtual void Play ( BOOL = TRUE );

};
///
///////////////////////// IMAGES /////////////////////////////
///
struct W32_ImageNote : public W32_PointNote {

W32_ImageNote ( int, int, PW32_Bitmap, double = 1.0 );
virtual ~W32_ImageNote ();

virtual void Play ( BOOL = TRUE );

PW32_Bitmap myBitmap;
double myScale;

};

struct WNT_ImageNote : public WNT_PointNote {

WNT_ImageNote ( int, int, PW32_Bitmap, double = 1.0 );
virtual ~WNT_ImageNote ();

virtual void Play ( BOOL = TRUE );

PW32_Bitmap myBitmap;
double myScale;

};
///
///////////////////////// TEXTS //////////////////////////////
///
struct W32_TextNote : public W32_PointNote {

W32_TextNote ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE );

virtual void Play ( BOOL = TRUE );

void* myText;
double myAngle;
DWORD myFlags;

};

struct WNT_TextNote : public WNT_PointNote {

WNT_TextNote ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE );

virtual void Play ( BOOL = TRUE );
virtual void Xform ( void );
void SetAttribs ();
void RestoreAttribs ();
void PaintText ();
void OutlineText ();
void FillText ();

void* myText;
double mySlant;
DWORD myFlags;
int myShift;
XFORM RMatrix,
IMatrix,
SMatrix;

};
///
/////////////////////// POLYTEXTS ////////////////////////////
///
struct W32_PolyTextNote : public W32_TextNote {

W32_PolyTextNote ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE );

virtual void Play ( BOOL = TRUE );

double myMargin;

};

struct WNT_PolyTextNote : public WNT_TextNote {

WNT_PolyTextNote ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE );

virtual void Play ( BOOL = TRUE );

double myMargin;

};
///
////////////////// BEGIN/END MARKERS /////////////////////////
///
struct W32_BeginMarkerNote : public W32_PointNote {

W32_BeginMarkerNote ( int, int, int, int, double );

virtual void Play ( BOOL = TRUE );

int myWidth, myHeight;
double myAngle;

};

struct WNT_BeginMarkerNote : public WNT_PointNote {

WNT_BeginMarkerNote ( int, int, int, int, double );

virtual void Play ( BOOL = TRUE );
virtual void Xform ( void );

int myWidth, myHeight;
double myAngle, myPrevAngle;
XFORM myMatrix;

};

struct W32_EndMarkerNote : public W32_Note {

W32_EndMarkerNote ();

virtual void Play ( BOOL = TRUE );

};

struct WNT_EndMarkerNote : public W32_Note {

WNT_EndMarkerNote ();

virtual void Play ( BOOL = TRUE );

};
///
//////////////////// A T T R I B U T E S /////////////////////
///
struct W32_LineAttribNote : public W32_Note {

W32_LineAttribNote ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL );

virtual void Play ( BOOL = TRUE );

LOGBRUSH myLogBrush;
DWORD myPenWidth;
DWORD myStyleCount;
PDWORD myStyles;

};

struct WNT_LineAttribNote : public W32_Note {

WNT_LineAttribNote ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL );
virtual ~WNT_LineAttribNote ();

virtual void Play ( BOOL = TRUE );

HPEN myPen;
DWORD myWidth;
COLORREF myPointColor;

};

struct W32_PolyAttribNote : public W32_Note {

W32_PolyAttribNote ( PLOGBRUSH, BOOL, int = ALTERNATE );

virtual void Play ( BOOL = TRUE );

LOGBRUSH myBrush;
BOOL myfEdge;
int myFillMode;

};

struct WNT_PolyAttribNote : public W32_Note {

WNT_PolyAttribNote ( PLOGBRUSH, BOOL, int = ALTERNATE );
virtual ~WNT_PolyAttribNote ();

virtual void Play ( BOOL = TRUE );

HBRUSH myBrush;
BOOL myfEdge;
int myFillMode;
BOOL myNoFill;

};

struct W32_TextAttribNote : public W32_Note {

W32_TextAttribNote (
HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
);
virtual ~W32_TextAttribNote ();

virtual void Play ( BOOL = TRUE );

COLORREF myColor;
HFONT myFont;
DWORD myFlags;
double mySlant,
myHScale,
myVScale;

};

struct WNT_TextAttribNote : public W32_Note {

WNT_TextAttribNote (
HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
);
virtual ~WNT_TextAttribNote ();

virtual void Play ( BOOL = TRUE );

COLORREF myColor;
HPEN myPen;
HBRUSH myBrush;
HFONT myFont;
BOOL myfFree;
DWORD myFlags;
double mySlant,
myHScale,
myVScale;

};

struct W32_MarkerAttribNote : public W32_Note {

W32_MarkerAttribNote ( COLORREF, DWORD, BOOL );

virtual void Play ( BOOL = TRUE );

LOGBRUSH myLogBrush;

};

struct WNT_MarkerAttribNote : public W32_Note {

WNT_MarkerAttribNote ( COLORREF, DWORD, BOOL );
virtual ~WNT_MarkerAttribNote ();

virtual void Play ( BOOL = TRUE );

HPEN myPen;
COLORREF myMarkerPointColor;
BOOL myFill;

};
///
//////////////////// F U N C T I O N C A L L ////////////////
///
struct W32_FCallNote : public W32_Note {

W32_FCallNote ( W32_FCall, int, PW32_FCALLPARAM );

virtual void Play ( BOOL = TRUE );

W32_FCall myFunc;
PW32_FCALLPARAM myParam;

};
///
//////////////////// A L L O C A T O R ///////////////////////
///
struct W32_Allocator {

W32_Allocator ( int, PW32_Allocator = NULL );
virtual ~W32_Allocator ();

PW32_Block MakeBlock ( int );
// allocates memory block
virtual PW32_Block KillBlock ( PW32_Block );
// deallocates memory block
void KillBlocks ( PW32_Block );
// deallocates memory blocks starting from specified one
void ClearBlocks ( void );
// resets allocator
void ReleaseBlock ( PW32_Block );
// releases graphics primitives in the specified block
BOOL FreeSpace ( PW32_Block, int );
// checks for free space in the specified block
PW32_Block ReserveData ( unsigned int );
// checks for free space in the current block
PW32_Block ReserveFind ( unsigned int );
// searches for free space
void* ReserveBlock ( PW32_Block, int, BOOL = FALSE );
// reserves data in the specified block
void* NewClass ( unsigned int );
// gets space for a new class ( W32_Note )
void* NewData ( unsigned int, BOOL = FALSE );
// gets space for a new data
virtual void Xform ( void ) = 0;
// sets world transformation in the device context

virtual void Play ( HDC, PSIZE ) = 0;
// plays notes
virtual void URect ( LPRECT ) = 0;
// gets updated rectangle

virtual void Point ( int, int ) = 0;
// stores a point
virtual void MarkerPoint ( int, int ) = 0;
// stores a marker point
virtual void Line ( int, int, int, int ) = 0;
// stores a line segment
virtual void PolyEllipse ( int, int, int, int ) = 0;
// stores a polyellipse
virtual void Ellipse ( int, int, int, int ) = 0;
// stores an ellipse
virtual void Arc ( int, int, int, int, double, double ) = 0;
// stores an arc
virtual void PolyChord ( int, int, int, int, double, double ) = 0;
// stores a polychord
virtual void Chord ( int, int, int, int, double, double ) = 0;
// stores a chord
virtual void PolySector ( int, int, int, int, double, double ) = 0;
// stores a polysector
virtual void Sector ( int, int, int, int, double, double ) = 0;
// stores a sector
virtual void PolyMarker ( int ) = 0;
// stores a polymarker
virtual void PolyMarker1 ( int, GetPointFunc, int, void* ) = 0;
// stores a polymarker1
virtual void PolyMarker2 ( int, GetPointFunc, int, void* ) = 0;
// stores a polymarker2
virtual W32_Note* Polygon ( int ) = 0;
// stores a polygon
virtual W32_Note* Polyline ( int ) = 0;
// stores a polyline
virtual void Image ( int, int, PW32_Bitmap, double = 1.0 ) = 0;
// stores an image
virtual void Text ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE ) = 0;
// stores a text
virtual void Polytext ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE ) = 0;
// stores a polytext
virtual void BeginMarker ( int, int, int, int, double ) = 0;
// stores the begin of marker
virtual void EndMarker ( void ) = 0;
// stores end of the marker
virtual void LineAttrib ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL ) = 0;
// stores line attributes
virtual void PolyAttrib ( PLOGBRUSH, BOOL, int = ALTERNATE ) = 0;
// stores polygon attributes
virtual void TextAttrib (
HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
) = 0;
//stores text attributes
virtual void MarkerAttrib ( COLORREF, DWORD, BOOL ) = 0;
// stores marker attributes
virtual void FunCall ( W32_FCall, int, PW32_FCALLPARAM ) = 0;
// stores function call

virtual int TextSize ( HDC, char*, PSIZE ) = 0;
virtual int TextSize ( HDC, wchar_t*, PSIZE ) = 0;
//obtains dimensions of the text string

int myID;
PW32_Allocator myNext;
PW32_Block myStart, myEnd;
W32_Primitive myPrimitive;
W32_Note* myNote;
int myFillMode;
DWORD myFlags;
POINT myPivot;
POINT myMove;
double myScaleX, myScaleY;
double myAngle;
double myTextVScale;
double myTextHScale;
double myTextSlant;
HFONT myTextFont;
COLORREF myPointColor,
myMarkerPointColor;

};

extern PW32_Allocator ( *W32_GetAllocator ) ( int, PW32_Allocator );

#define P(v) LONG( ( v ) / myPixelToUnit + 0.5 )
#define U(v) ( ( v ) * myPixelToUnit )

// !!!ChP
//----------------------------------------------------
// @author ChP
class CPenUsing
{

public:
CPenUsing();
~CPenUsing();

public:
//!!! ChP: Styles need for creation CPen
DWORD m_xWidth;
LOGBRUSH m_lb;
DWORD m_nStyles;
PDWORD m_pdwStyle;

int m_iNumOfUsing;

HPEN m_hPen;
};

// @author ChP
class CBrushUsing
{

public:
CBrushUsing();
~CBrushUsing();

public:
//!!! ChP: Styles need for creation CBrush
LOGBRUSH m_lb;

int m_iNumOfUsing;

HBRUSH m_hBrush;
};

/** @class Manadger for CPen, CBrush etc.
* @author ChP
*/
class CVizualizationModesManadger
{

public:
std::vector m_aPen;
CPenUsing m_PenForAdd;

std::vector m_aBrush;
CBrushUsing m_BrushForAdd;

public:
//@cmember Constructor
CVizualizationModesManadger();
//@cmember Destructor
~CVizualizationModesManadger();

public:
// Get new Brush
HBRUSH GetNewBrush(PLOGBRUSH plb);

void xDeleteBrush(HBRUSH hBrush);

HPEN GetNewPen(DWORD xWidth, PLOGBRUSH plb,
DWORD nStyles = 0, PDWORD pdwStyle = NULL);

void xDeletePen(HPEN hPen);

};
//----------------------------------------------------

extern CVizualizationModesManadger gVizualizationModesManadger;

#endif // __W32_ALLOCATOR_HXX

------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------- WNT_Allocator.cxx-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
// WNT_Allocator //
// Provides memory management and drawing operations for Windows 95. //
// World transformations and styled lines are managed by EHDC stuff. //
// //
// History: FEB-98 - creation (EUG) //
// MAR-98 - modification (DCB) //
////////////////////////////////////////////////////////////////////////////////

#define PRO19042 //GG_251199 Avoid to crash with an insuffisant resources messag

#include "WNT_Allocator.hxx"

#include
#include
#include

// !!! ChP
CVizualizationModesManadger gVizualizationModesManadger;

#define ALLOCATOR ( ( PWNT_Allocator )myAllocator )

static XFORM xfmIdent = { ( FLOAT )0.8660, ( FLOAT )0.5000,
( FLOAT )-0.5000, ( FLOAT )0.8660,
( FLOAT )0.0000, ( FLOAT )0.0000
};

WNT_Allocator :: WNT_Allocator ( int anID, PW32_Allocator prev ) :
W32_Allocator ( anID, prev )
{
myLinePen = (HPEN) GetStockObject ( NULL_PEN );
myLineWidth = 1;
myPolyBrush = (HBRUSH) GetStockObject ( NULL_BRUSH );
myTextPen = (HPEN) GetStockObject ( NULL_PEN );
myTextBrush = (HBRUSH) GetStockObject ( NULL_BRUSH );
myTextFont = (HFONT) GetStockObject ( SYSTEM_FONT );
myMarkerPen = (HPEN) GetStockObject ( NULL_PEN );
myTextSlant = EPS;

myPO = (HPEN) NULL;
myBO = (HBRUSH) NULL;
myFO = (HFONT) NULL;
SetRectEmpty ( &myURect );

myMatrix.eM11 = myMatrix.eM22 = 1.0F;
myMatrix.eM12 = myMatrix.eM21 = 0.0F;
myMatrix.eDx = myMatrix.eDy = 0.0F;

myFlags &= ~W32F_WIN95;
} // end constructor

WNT_Allocator :: ~WNT_Allocator ()
{
DeletePen ( myLinePen );
DeleteBrush ( myPolyBrush );
DeletePen ( myTextPen );
DeleteBrush ( myTextBrush );
DeletePen ( myMarkerPen );
} // end destructor

void WNT_Allocator :: TransformPoint (int& X, int& Y)
{
X = int ( myScaleX * ( X - myPivot.x ) );
Y = int ( myScaleY * ( Y - myPivot.y ) );
} // WNT_Allocator :: TransformPoint

void WNT_Allocator :: TransformPoint (LPPOINT lpPoint)
{
lpPoint->x = int ( myScaleX * ( lpPoint->x - myPivot.x ) );
lpPoint->y = int ( myScaleY * ( lpPoint->y - myPivot.y ) );
} // WNT_Allocator :: TransformPoint

#define ADD_POINT_TO_RECT(aPoint) \
{ if ( aPoint.x if ( aPoint.x > myURect.right ) myURect.right = aPoint.x + myLineWidth + 1; \
if ( aPoint.y if ( aPoint.y > myURect.bottom ) myURect.bottom = aPoint.y + myLineWidth + 1; \
}

void WNT_Allocator :: Register ( int x, int y )
{
static POINT pt;
pt.x = x; pt.y = y;
LPtoDP ( myHDC, &pt, 1 );
ADD_POINT_TO_RECT (pt);
} // WNT_Allocator :: Register

void WNT_Allocator :: Register ( LPPOINT lpPts, int nPts )
{
for ( int i = 0; i Register ( lpPts[i].x, lpPts[i].y );
} // WNT_Allocator :: Register

void WNT_Allocator :: Register ( LPRECT lpRect )
{
Register ( lpRect->left, lpRect->top );
Register ( lpRect->left, lpRect->bottom );
Register ( lpRect->right, lpRect->top );
Register ( lpRect->right, lpRect->bottom );
} // WNT_Allocator :: Register

void WNT_Allocator :: RecalcMatrix (
XFORM& Matrix, double Angle,
double PivotX, double PivotY
)
{
float CosA = ( float )cos ( Angle );
float SinA = ( float )sin ( Angle );
Matrix.eM11 = float ( CosA );
Matrix.eM12 = float ( SinA );
Matrix.eM21 = -float ( SinA );
Matrix.eM22 = float ( CosA );
Matrix.eDx = float ( PivotX );
Matrix.eDy = float ( PivotY );
} // end WNT_Allocator :: RecalcMatrix

void WNT_Allocator :: Play ( HDC hdc, PSIZE szClient )
{
CopyMemory ( &mySize, szClient, sizeof ( SIZE ) );
if ( !( myFlags & W32F_EMPTY ) ) {
POINT pVOExt;
SIZE szWExt, szVExt;
int nMapMode, nGMode, nBkMode;

myHDC = hdc;
nMapMode = SetMapMode ( myHDC, MM_ISOTROPIC );
SetRect ( &myURect, mySize.cx, mySize.cy, 0, 0 );
SetWindowExtEx ( myHDC, szClient->cx, -szClient->cy, &szWExt );
SetViewportExtEx ( myHDC, szClient->cx, szClient->cy, &szVExt );
SetViewportOrgEx ( myHDC, 0, szClient->cy - 1, &pVOExt );
nGMode = SetGraphicsMode ( myHDC, GM_ADVANCED );
nBkMode = SetBkMode ( myHDC, TRANSPARENT );
SelectPen ( myHDC, myLinePen );
SelectBrush ( myHDC, myPolyBrush );
SetTextColor ( myHDC, myTextColor );

Xform ();
for ( PW32_Block aBlock = myStart; aBlock != NULL; aBlock = aBlock -> next )
for ( int i = 0; i free; i += aBlock -> data[ i ] )
if ( aBlock -> data[ i + 1 ] != __W32_DATA ) {
W32_Note* pNote = ( W32_Note* )&( aBlock -> data[ i + 1 ] );
pNote -> Play ();
} // end if

SetMapMode ( myHDC, nMapMode );
SetWindowExtEx ( myHDC, szWExt.cx, szWExt.cy, NULL );
SetViewportExtEx ( myHDC, szVExt.cx, szVExt.cy, NULL );
SetViewportOrgEx ( myHDC, pVOExt.x, pVOExt.y, NULL );
SetBkMode ( myHDC, nBkMode );
SetGraphicsMode ( myHDC, nGMode );
} // end if
} // end WNT_Allocator :: Play

void WNT_Allocator :: URect ( LPRECT lpRect )
{
CopyRect ( lpRect, &myURect );
if ( lpRect -> top top = 0;
if ( lpRect -> left left = 0;
if ( lpRect -> right > mySize.cx ) lpRect -> right = mySize.cx;
if ( lpRect -> bottom > mySize.cy ) lpRect -> bottom = mySize.cy;
} // end WNT_Allocator :: URect

void WNT_Allocator :: Xform ( void )
{
if ( myAngle != 0.0 || myPivot.x != 0 || myPivot.y != 0 ||
myMove.x != 0 || myMove.y != 0 )
{
RecalcMatrix ( myMatrix, myAngle,
myPivot.x + myMove.x,
myPivot.y + myMove.y );
SetWorldTransform ( myHDC, &myMatrix );
} else {
ModifyWorldTransform ( myHDC, NULL, MWT_IDENTITY );
}
} // end WNT_Allocator :: Xform

void WNT_Allocator :: Point ( int x, int y ) {

new ( this ) WNT_PointNote ( x, y );

} // end WNT_Allocator :: Point

void WNT_Allocator :: MarkerPoint ( int x, int y ) {

new ( this ) WNT_MarkerPointNote ( x, y );

} // end WNT_Allocator :: MarkerPoint

void WNT_Allocator :: Line ( int x, int y, int x1, int y1 ) {

new ( this ) WNT_LineNote ( x, y, x1, y1 );

} // end WNT_Allocator :: Line

void WNT_Allocator :: PolyEllipse ( int xc, int yc, int xr, int yr ) {

new ( this ) WNT_PolyEllipseNote ( xc, yc, xr, yr );

} // end WNT_Allocator :: PolyEllipse

void WNT_Allocator :: Ellipse ( int xc, int yc, int xr, int yr ) {

new ( this ) WNT_EllipseNote ( xc, yc, xr, yr );

} // end WNT_Allocator :: Ellipse

void WNT_Allocator :: Arc (
int xc, int yc, int xr, int yr,
double sa, double oa
) {

new ( this ) WNT_ArcNote ( xc, yc, xr, yr, sa, oa );

} // end WNT_Allocator :: Arc

void WNT_Allocator :: PolyChord (
int xc, int yc, int xr, int yr,
double sa, double oa
) {

new ( this ) WNT_PolyChordNote ( xc, yc, xr, yr, sa, oa );

} // end WNT_Allocator :: PolyChord

void WNT_Allocator :: Chord (
int xc, int yc, int xr, int yr,
double sa, double oa
) {

new ( this ) WNT_PolyChordNote ( xc, yc, xr, yr, sa, oa );

} // end WNT_Allocator :: Chord

void WNT_Allocator :: PolySector (
int xc, int yc, int xr, int yr,
double sa, double oa
) {

new ( this ) WNT_PolySectorNote ( xc, yc, xr, yr, sa, oa );

} // end WNT_Allocator :: PolySector

void WNT_Allocator :: Sector (
int xc, int yc, int xr, int yr,
double sa, double oa
) {

new ( this ) WNT_SectorNote ( xc, yc, xr, yr, sa, oa );

} // end WNT_Allocator :: Sector

void WNT_Allocator :: PolyMarker ( int aMaxPoints ) {

new ( this ) W32_PolyMarkerNote ( aMaxPoints );

} // end WNT_Allocator :: PolyMarker

void WNT_Allocator :: PolyMarker1 (
int aMaxPoints, GetPointFunc fn,
int aStartPoint, void* fParam
) {

new ( this ) WNT_PolyMarker1Note (
aMaxPoints, fn, aStartPoint, fParam
);

} // end WNT_Allocator :: PolyMarker1

void WNT_Allocator :: PolyMarker2 (
int aMaxPoints, GetPointFunc fn,
int aStartPoint, void* fParam
) {

new ( this ) WNT_PolyMarker2Note (
aMaxPoints, fn, aStartPoint, fParam
);

} // end WNT_Allocator :: PolyMarker1

W32_Note* WNT_Allocator :: Polygon ( int aMaxPoints ) {

return new ( this ) WNT_PolygonNote ( aMaxPoints );

} // end WNT_Allocator :: Polygon

W32_Note* WNT_Allocator :: Polyline ( int aMaxPoints ) {

return new ( this ) WNT_PolylineNote ( aMaxPoints );

} // end WNT_Allocator :: Polyline

void WNT_Allocator :: Image (
int x, int y, PW32_Bitmap pBmp, double aScale
) {

new ( this ) WNT_ImageNote ( x, y, pBmp, aScale );

} // end WNT_Allocator :: Image

void WNT_Allocator :: Text (
int x, int y, double angle, void* text,
BOOL fWide, BOOL fOutlined
) {

new ( this ) WNT_TextNote ( x, y, angle, text, fWide, fOutlined );

} // end WNT_Allocator :: Text

void WNT_Allocator :: Polytext (
int x, int y, double angle, double margin,
void* text, BOOL fWide, BOOL fOutlined
) {

new ( this ) WNT_PolyTextNote ( x, y, angle, margin, text, fWide, fOutlined );

} // end WNT_Allocator :: Polytext

void WNT_Allocator :: BeginMarker (
int x, int y, int w, int h, double angle
) {

new ( this ) WNT_BeginMarkerNote ( x, y, w, h, angle );

} // end WNT_Allocator :: BeginMarker

void WNT_Allocator :: EndMarker ( void ) {

new ( this ) WNT_EndMarkerNote ();

} // end WNT_Allocator :: EndMarker

void WNT_Allocator :: LineAttrib (
DWORD width, PLOGBRUSH plb,
DWORD nStyles, PDWORD pdwStyle
) {

new ( this ) WNT_LineAttribNote ( width, plb, nStyles, pdwStyle );

} // end WNT_Allocator :: LineAttrib

void WNT_Allocator :: PolyAttrib (
PLOGBRUSH plb, BOOL fDrawEdge, int aFillMode
) {

new ( this ) WNT_PolyAttribNote ( plb, fDrawEdge, aFillMode );

} // end WNT_Allocator :: PolyAttrib

void WNT_Allocator :: TextAttrib (
HFONT hFont, COLORREF color, double slant,
double hScale, double vScale,
BOOL fUnderlined, BOOL fFree, BOOL fIndex
) {

new ( this ) WNT_TextAttribNote (
hFont, color, slant, hScale, vScale,
fUnderlined, fFree, fIndex
);

} // end WNT_Allocator :: TextAttrib

void WNT_Allocator :: MarkerAttrib (
COLORREF color, DWORD dwWidth, BOOL fFill
) {

new ( this ) WNT_MarkerAttribNote ( color, dwWidth, fFill );

} // end WNT_Allocator :: MarkerAttrib

void WNT_Allocator :: FunCall (
W32_FCall fCall, int sz, PW32_FCALLPARAM param
) {

new ( this ) W32_FCallNote ( fCall, sz, param );

} // end WNT_Allocator :: FunCall

void WNT_Allocator :: GetExtent ( LPSIZE lpSZ )
{
CopyMemory ( lpSZ, &mySize, sizeof ( SIZE ) );
}

int WNT_Allocator :: TextSize ( HDC hdc, char* str, PSIZE psz ) {

int gMode = GetGraphicsMode ( hdc );
XFORM xfm, xfms;
POINT pt;
ABC abcf;

if ( gMode == GM_ADVANCED )
GetWorldTransform ( hdc, &xfms );
else
SetGraphicsMode ( hdc, GM_ADVANCED );

ModifyWorldTransform ( hdc, &xfmIdent, MWT_IDENTITY );
xfm.eM11 = 1.0F;
xfm.eM12 = 0.0F;
xfm.eM21 = ( FLOAT )tan ( myTextSlant );
xfm.eM22 = 1.0F;
xfm.eDx = 0.0F;
xfm.eDy = 0.0F;
ModifyWorldTransform ( hdc, &xfm, MWT_LEFTMULTIPLY );
xfm.eM11 = FLOAT ( myTextHScale * myScaleX );
xfm.eM12 = 0.0F;
xfm.eM21 = 0.0F;
xfm.eM22 = FLOAT ( myTextVScale * myScaleY );
xfm.eDx = 0.0F;
xfm.eDy = 0.0F;
ModifyWorldTransform ( hdc, &xfm, MWT_LEFTMULTIPLY );

MoveToEx ( hdc, 0, 0, &pt );
GetTextExtentPoint32A (
hdc, str, lstrlenA ( str ), psz
);
GetCharABCWidthsA ( hdc, str[ 0 ], str[ 0 ], &abcf );
MoveToEx ( hdc, pt.x, pt.y, NULL );

if ( gMode == GM_ADVANCED )
SetWorldTransform ( hdc, &xfms );
else {
psz->cx = LONG ( psz->cx * xfm.eM11 );
psz->cy = LONG ( psz->cy * xfm.eM22 );
abcf.abcA = UINT ( abcf.abcA * xfm.eM11 );
SetGraphicsMode ( hdc, gMode );
} // end else

return abcf.abcA;
} // end WNT_Allocator :: TextSize

int WNT_Allocator :: TextSize ( HDC hdc, wchar_t* str, PSIZE psz ) {

int gMode = GetGraphicsMode ( hdc );
XFORM xfm, xfms;
POINT pt;
ABC abcf;

if ( gMode == GM_ADVANCED )
GetWorldTransform ( hdc, &xfms );
else
SetGraphicsMode ( hdc, GM_ADVANCED );

ModifyWorldTransform ( hdc, &xfmIdent, MWT_IDENTITY );
xfm.eM11 = 1.0F;
xfm.eM12 = 0.0F;
xfm.eM21 = ( FLOAT )tan ( myTextSlant );
xfm.eM22 = 1.0F;
xfm.eDx = 0.0F;
xfm.eDy = 0.0F;
ModifyWorldTransform ( hdc, &xfm, MWT_LEFTMULTIPLY );
xfm.eM11 = FLOAT ( myTextHScale * myScaleX );
xfm.eM12 = 0.0F;
xfm.eM21 = 0.0F;
xfm.eM22 = FLOAT ( myTextVScale * myScaleY );
xfm.eDx = 0.0F;
xfm.eDy = 0.0F;
ModifyWorldTransform ( hdc, &xfm, MWT_LEFTMULTIPLY );

MoveToEx ( hdc, 0, 0, &pt );
GetTextExtentPoint32W (
hdc, str, lstrlenW ( str ), psz
);
GetCharABCWidthsW ( hdc, str[ 0 ], str[ 0 ], &abcf );
MoveToEx ( hdc, pt.x, pt.y, NULL );

if ( gMode == GM_ADVANCED )
SetWorldTransform ( hdc, &xfms );
else {
psz->cx = LONG ( psz->cx * xfm.eM11 );
psz->cy = LONG ( psz->cy * xfm.eM22 );
abcf.abcA = UINT ( abcf.abcA * xfm.eM11 );
SetGraphicsMode ( hdc, gMode );
} // end else

return abcf.abcA;
} // end WNT_Allocator :: TextSize

////////////////////////////////////////////////////////////////////////////////
// W N T _ P o i n t N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PointNote :: WNT_PointNote ( int x, int y ) :
W32_PointNote ( x, y )
{
} // end constructor

void WNT_PointNote :: Play ( BOOL fDummy )
{
Xform ();
SetPixel ( ALLOCATOR -> myHDC, myTX, myTY, ALLOCATOR -> myPointColor );
} // end WNT_PointNote :: Play

void WNT_PointNote :: Xform ()
{
myTX = myX;
myTY = myY;
ALLOCATOR -> TransformPoint ( myTX, myTY );
ALLOCATOR -> Register ( myTX, myTY );
}
////////////////////////////////////////////////////////////////////////////////
// W N T _ M a r k e r P o i n t N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_MarkerPointNote :: WNT_MarkerPointNote ( int x, int y ) :
WNT_PointNote ( x, y )
{
} // end constructor

void WNT_MarkerPointNote :: Play ( BOOL fDummy )
{
Xform ();
SetPixel ( ALLOCATOR -> myHDC, myTX, myTY, ALLOCATOR -> myMarkerPointColor );
} // end WNT_MarkerPointNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ L i n e N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_LineNote :: WNT_LineNote ( int x, int y, int x1, int y1 ) :
WNT_PointNote ( x, y )
{
myX2 = x1;
myY2 = y1;
} // end constructor

void WNT_LineNote :: Play ( BOOL fDummy )
{
Xform ();
MoveToEx ( ALLOCATOR -> myHDC, myTX , myTY, NULL );
LineTo ( ALLOCATOR -> myHDC, myTX2, myTY2 );
} // end WNT_LineNote :: Play

void WNT_LineNote :: Xform ()
{
WNT_PointNote :: Xform ();
myTX2 = myX2;
myTY2 = myY2;
ALLOCATOR -> TransformPoint ( myTX2, myTY2 );
ALLOCATOR -> Register ( myTX2, myTY2 );
}
////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y E l l i p s e N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolyEllipseNote :: WNT_PolyEllipseNote ( int xc, int yc, int xr, int yr ) :
WNT_PointNote ( xc, yc )
{
myXr = xr;
myYr = yr;
} // end constructor

void WNT_PolyEllipseNote :: Play ( BOOL fDummy )
{
Xform ();
Ellipse ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
myTX + myTXr, myTY + myTYr );
} // end WNT_PolyEllipseNote :: Play

void WNT_PolyEllipseNote :: Xform ()
{
WNT_PointNote :: Xform ();
myTXr = int (myXr * ALLOCATOR -> myScaleX);
myTYr = int (myYr * ALLOCATOR -> myScaleY);
RECT r = { myTX - myTXr, myTY - myTYr, myTX + myTXr, myTY + myTYr };
ALLOCATOR -> Register ( &r );
}
////////////////////////////////////////////////////////////////////////////////
// W N T _ E l l i p s e N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_EllipseNote :: WNT_EllipseNote ( int xc, int yc, int xr, int yr ) :
WNT_PolyEllipseNote ( xc, yc, xr, yr )
{
} // end constructor

void WNT_EllipseNote :: Play ( BOOL fDummy )
{
Xform ();
HBRUSH hob = SelectBrush ( ALLOCATOR -> myHDC, GetStockObject (NULL_BRUSH) );
Ellipse ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
myTX + myTXr, myTY + myTYr );
SelectBrush ( ALLOCATOR -> myHDC, hob );
} // end WNT_PolyEllipseNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ A r c N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_ArcNote :: WNT_ArcNote (
int xc, int yc, int xr, int yr, double sa, double oa
) : WNT_PolyEllipseNote ( xc, yc, xr, yr )
{
int Radius = max ( xr, yr );
double sSinA = sin ( sa + oa );
double sCosA = cos ( sa + oa );
double eSinA = sin ( sa );
double eCosA = cos ( sa );
myDirect = ( sa + oa > 0. ) ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE;

mySX = int ( sCosA * 2 * Radius + xc );
mySY = int ( sSinA * 2 * Radius + yc );
myEX = int ( eCosA * 2 * Radius + xc );
myEY = int ( eSinA * 2 * Radius + yc );
} // end constructor

void WNT_ArcNote :: Play ( BOOL fDummy )
{
Xform ();
HDC hdc = ALLOCATOR -> myHDC;
SetArcDirection ( ALLOCATOR -> myHDC, myDirect );
Arc ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
myTX + myTXr, myTY + myTYr,
myTSX, myTSY, myTEX, myTEY );
} // end WNT_ArcNote :: Play

void WNT_ArcNote :: Xform ()
{
WNT_PolyEllipseNote :: Xform ();
myTSX = mySX;
myTSY = mySY;
ALLOCATOR -> TransformPoint ( myTSX, myTSY );
myTEX = myEX;
myTEY = myEY;
ALLOCATOR -> TransformPoint ( myTEX, myTEY );
}
////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y C h o r d N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolyChordNote :: WNT_PolyChordNote (
int xc, int yc, int xr, int yr, double sa, double oa
) : WNT_ArcNote ( xc, yc, xr, yr, sa, oa )
{
} // end constructor

void WNT_PolyChordNote :: Play ( BOOL fDummy )
{
Xform ();
Chord ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
myTX + myTXr, myTY + myTYr,
myTEX, myTEY, myTSX, myTSY );
} // end WNT_PolyChordNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ C h o r d N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_ChordNote :: WNT_ChordNote (
int xc, int yc, int xr, int yr, double sa, double oa
) : WNT_PolyChordNote ( xc, yc, xr, yr, sa, oa )
{
} // end constructor

void WNT_ChordNote :: Play ( BOOL fDummy )
{
Xform ();
HBRUSH hob = SelectBrush ( ALLOCATOR -> myHDC, GetStockObject (NULL_BRUSH) );
Chord ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
myTX + myTXr, myTY + myTYr,
myTEX, myTEY, myTSX, myTSY );
SelectBrush ( ALLOCATOR -> myHDC, hob );
} // end WNT_ChordNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y S e c t o r N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolySectorNote :: WNT_PolySectorNote (
int xc, int yc, int xr, int yr, double sa, double oa
) : WNT_ArcNote ( xc, yc, xr, yr, sa, oa )
{
} // end constructor

void WNT_PolySectorNote :: Play ( BOOL fDummy )
{
Xform ();
Pie ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
myTX + myTXr, myTY + myTYr,
myTEX, myTEY, myTSX, myTSY );
} // end WNT_PolySectorNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ S e c t o r N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_SectorNote :: WNT_SectorNote (
int xc, int yc, int xr, int yr, double sa, double oa
) : WNT_PolySectorNote ( xc, yc, xr, yr, sa, oa )
{
} // end constructor

void WNT_SectorNote :: Play ( BOOL fDummy )
{
Xform ();
HBRUSH hob = SelectBrush ( ALLOCATOR -> myHDC, GetStockObject (NULL_BRUSH) );
Pie ( ALLOCATOR -> myHDC, myTX - myTXr, myTY - myTYr,
myTX + myTXr, myTY + myTYr,
myTEX, myTEY, myTSX, myTSY );
SelectBrush ( ALLOCATOR -> myHDC, hob );
} // end WNT_SectorNote :: Play

////////////////////////////////////////////////////////////////////////////////
// D r a w P o l y l i n e //
////////////////////////////////////////////////////////////////////////////////
void DrawPolyline ( HDC hdc, LPPOINT lpPts, int nPts, BOOL fClose )
{
BeginPath ( hdc );
Polyline ( hdc, lpPts, nPts );
if (fClose)
CloseFigure ( hdc );
EndPath ( hdc );
StrokePath ( hdc );
}
////////////////////////////////////////////////////////////////////////////////
// D r a w P o l y g o n //
////////////////////////////////////////////////////////////////////////////////
void DrawPolygon ( HDC hdc, LPPOINT lpPts, int nPts, UINT dwFlags )
{
HPEN hpo = SelectPen ( hdc, GetStockObject ( NULL_PEN ) );
Polygon ( hdc, lpPts, nPts );
SelectPen ( hdc, hpo );

if ( dwFlags & POLYF_NOCLOSEDGE )
DrawPolyline ( hdc, lpPts, nPts, FALSE );
else if ( !( dwFlags & POLYF_NOEDGE ) )
DrawPolyline ( hdc, lpPts, nPts, TRUE );
}
////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y M a r k e r 1 N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolyMarker1Note :: WNT_PolyMarker1Note (
int aMaxPoints, GetPointFunc fn, int aStartPoint,
void* fParam
) : W32_PolyMarker1Note ( aMaxPoints, fn, aStartPoint, fParam)
{
} // end constructor

void WNT_PolyMarker1Note :: Play ( BOOL fDummy )
{
if ( ALLOCATOR -> myFlags & W32F_MFILL )
DrawPolygon ( ALLOCATOR -> myHDC, myPoints, mySetPoints, POLYF_NOCLOSEDGE );
else
DrawPolyline ( ALLOCATOR -> myHDC, myPoints, mySetPoints, FALSE );
} // end WNT_PolyMarker1Note :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y M a r k e r 2 N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolyMarker2Note :: WNT_PolyMarker2Note (
int aMaxPoints, GetPointFunc fn, int aStartPoint,
void* fParam
) : WNT_PolyMarker1Note (
aMaxPoints, fn, aStartPoint, fParam
)
{
} // end constructor

void WNT_PolyMarker2Note :: Play ( BOOL fDummy )
{
if ( ALLOCATOR -> myFlags & W32F_MFILL )
DrawPolygon ( ALLOCATOR -> myHDC, myPoints, mySetPoints - 1, 0 );
else
DrawPolyline ( ALLOCATOR -> myHDC, myPoints, mySetPoints - 1, TRUE );
} // end WNT_PolyMarker2Note :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y g o n N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolygonNote :: WNT_PolygonNote ( int aMaxPoints ) :
W32_PolygonNote ( aMaxPoints )
{
myTPoints = ( LPPOINT ) ALLOCATOR -> NewData (myMaxPoints * sizeof ( POINT ));
} // end constructor

void WNT_PolygonNote :: Play ( BOOL fDummy )
{
Xform ();
DrawPolygon (
ALLOCATOR -> myHDC, myTPoints, mySetPoints,
ALLOCATOR -> myFlags & W32F_POUTL ? 0 : POLYF_NOEDGE
);
} // end WNT_PolygonNote :: Play

void WNT_PolygonNote :: Xform ()
{
CopyMemory ( myTPoints, myPoints, mySetPoints*sizeof(POINT) );
for ( int i = 0; i ALLOCATOR -> TransformPoint ( (myTPoints + i) );
ALLOCATOR -> Register ( myTPoints, mySetPoints );
}
////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y l i n e N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolylineNote :: WNT_PolylineNote ( int aMaxPoints ) :
WNT_PolygonNote ( aMaxPoints )
{
} // end constructor

void WNT_PolylineNote :: Play ( BOOL fDummy )
{
Xform ();
DWORD nPts;
BOOL fClose;
int idx = mySetPoints - 1;
if ( myPoints -> x == myPoints[ idx ].x &&
myPoints -> y == myPoints[ idx ].y
) {
nPts = idx;
fClose = TRUE;
} else {
nPts = mySetPoints;
fClose = FALSE;
} // end else
DrawPolyline ( ALLOCATOR->myHDC, myTPoints, nPts, fClose );
} // end WNT_PolylineNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ I m a g e N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_ImageNote :: WNT_ImageNote (
int x, int y, PW32_Bitmap pBmp, double aScale
) : WNT_PointNote ( x, y )
{
myBitmap = pBmp;
++pBmp -> nUsed;
myScale = aScale;
} // end constructor

WNT_ImageNote :: ~WNT_ImageNote ()
{
if ( myBitmap -> hBmp != NULL && --myBitmap -> nUsed == 0 ) {
DeleteObject ( myBitmap -> hBmp );
HeapFree ( GetProcessHeap (), 0, ( PVOID )myBitmap );
} // end if
} // end WNT_ImageNote :: ~WNT_ImageNote

void WNT_ImageNote :: Play ( BOOL fDummy )
{
Xform ();
int xx, yy, w, h;
HDC hdcMem;
BITMAP bmp;
HBITMAP hbo;

GetObject ( myBitmap -> hBmp, sizeof ( BITMAP ), &bmp );
xx = myTX;
yy = myTY;
w = bmp.bmWidth;
h = bmp.bmHeight;
if ( myScale != 1.0 ) {
w = int ( w * myScale + 0.5 );
h = int ( h * myScale + 0.5 );
}
if ( ALLOCATOR -> myScaleX != 1.0 ) {
xx = int ( xx * ALLOCATOR -> myScaleX + 0.5 );
w = int ( w * ALLOCATOR -> myScaleX + 0.5 );
} // end if
if ( ALLOCATOR -> myScaleY != 1.0 ) {
yy = int ( yy * ALLOCATOR -> myScaleY + 0.5 );
h = int ( h * ALLOCATOR -> myScaleY + 0.5 );
} // end if
xx = xx - ( w >> 1 );
yy = yy + ( h >> 1 );
hdcMem = CreateCompatibleDC ( ALLOCATOR -> myHDC );
hbo = SelectBitmap ( hdcMem, myBitmap -> hBmp );
SetStretchBltMode ( hdcMem, COLORONCOLOR );
StretchBlt (
ALLOCATOR -> myHDC, xx, yy, w, -h,
hdcMem, 0, 0, bmp.bmWidth, bmp.bmHeight,
SRCCOPY
);
RECT r = { xx, yy, xx + w, yy - h };
ALLOCATOR -> Register ( &r );
SelectBitmap ( hdcMem, hbo );
DeleteDC ( hdcMem );
} // end WNT_ImageNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ T e x t N o t e //
////////////////////////////////////////////////////////////////////////////////
#define ROUNDL( d ) ( ( long )( ( d ) + ( ( d ) > 0 ? 0.5 : -0.5 ) ) )
WNT_TextNote :: WNT_TextNote (
int x, int y, double angle, void* text,
BOOL fWide, BOOL fOutlined
) : WNT_PointNote ( x, y )
{
DWORD dwLen = fWide ? ( ( lstrlenW ( ( LPCWSTR )text ) + 1 ) : ( ( lstrlenA ( ( LPCSTR )text ) + 1 ) myText = ALLOCATOR -> NewData ( dwLen );
CopyMemory ( myText, text, dwLen );
myFlags = ( ( fWide ? W32F_TUNICODE : 0 ) |
( fOutlined ? W32F_TOUTLINE : 0 )
);
ALLOCATOR -> RecalcMatrix ( RMatrix, angle );
} // end constructor

void WNT_TextNote :: PaintText ()
{
if (myFlags & W32F_TUNICODE)
TextOutW ( ALLOCATOR -> myHDC, 0, myShift, (LPCWSTR)myText, lstrlenW ((LPCWSTR)myText) );
else
TextOutA ( ALLOCATOR -> myHDC, 0, myShift, (LPCSTR)myText, lstrlenA ((LPCSTR)myText) );
} // end WNT_TextNote :: PaintText

void WNT_TextNote :: SetAttribs ()
{
ALLOCATOR -> myPO = SelectPen (ALLOCATOR -> myHDC, ALLOCATOR -> myTextPen );
ALLOCATOR -> myBO = SelectBrush (ALLOCATOR -> myHDC, ALLOCATOR -> myTextBrush);
ALLOCATOR -> myFO = SelectFont (ALLOCATOR -> myHDC, ALLOCATOR -> myTextFont );
} // end WNT_TextNote :: SetAttribs

void WNT_TextNote :: RestoreAttribs ()
{
SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myPO );
SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myBO );
SelectFont ( ALLOCATOR -> myHDC, ALLOCATOR -> myFO );
ALLOCATOR -> Xform ();
} // end WNT_TextNote :: RestoreAttribs

void WNT_TextNote :: OutlineText ()
{
BeginPath ( ALLOCATOR -> myHDC );
PaintText ( );
EndPath ( ALLOCATOR -> myHDC );
StrokePath ( ALLOCATOR -> myHDC );
} // end WNT_TextNote :: OutlineText

void WNT_TextNote :: FillText ()
{
PaintText ();
} // end WNT_TextNote :: FillText

void WNT_TextNote :: Play ( BOOL fDummy )
{
Xform ();
SIZE size;
RECT rect;
HDC hdc = ALLOCATOR -> myHDC;
// Set new world transform and attribs to get text size and metrics
SetAttribs ();
if ( myFlags & W32F_TUNICODE )
ALLOCATOR -> TextSize ( hdc, ( wchar_t* )myText, &size );
else
ALLOCATOR -> TextSize ( hdc, ( char* )myText, &size );
ModifyWorldTransform ( hdc, &RMatrix, MWT_LEFTMULTIPLY );
// Register and draw the bounding rect
rect.left = 0;
rect.top = 0;
rect.right = ROUNDL( ( FLOAT )size.cx * SMatrix.eM11 );
rect.bottom = -ROUNDL( ( FLOAT )size.cy * SMatrix.eM22 );
if (ALLOCATOR -> myTextSlant >= 0.F)
rect.right += ROUNDL( ( FLOAT )rect.bottom * IMatrix.eM21 );
else
rect.left += ROUNDL( ( FLOAT )rect.bottom * IMatrix.eM21 );
ALLOCATOR -> Register ( &rect );
// Draw ( fill or outline ) text
myShift = -size.cy;
ModifyWorldTransform ( hdc, &IMatrix, MWT_LEFTMULTIPLY );
ModifyWorldTransform ( hdc, &SMatrix, MWT_LEFTMULTIPLY );
if ( myFlags & W32F_TOUTLINE || ALLOCATOR -> myFlags & W32F_MONO ) OutlineText ();
else FillText ();
RestoreAttribs ();
} // end WNT_TextNote :: Play

void WNT_TextNote :: Xform ( void )
{
HDC hdc = ALLOCATOR -> myHDC;
WNT_PointNote :: Xform ();
RMatrix.eDx = float ( myTX );
RMatrix.eDy = float ( myTY );
SMatrix.eM11 = float ( ALLOCATOR -> myTextHScale * ALLOCATOR -> myScaleX );
SMatrix.eM12 = 0.0F;
SMatrix.eM21 = 0.0F;
SMatrix.eM22 = -float ( ALLOCATOR -> myTextVScale * ALLOCATOR -> myScaleY );
SMatrix.eDx = 0.0F;
SMatrix.eDy = 0.0F;
IMatrix.eM11 = 1.0F;
IMatrix.eM12 = 0.0F;
IMatrix.eM21 = float ( tan (ALLOCATOR -> myTextSlant) );
IMatrix.eM22 = 1.0F;
IMatrix.eDx = 0.0F;
IMatrix.eDy = 0.0F;
} // enf WNT_TextNote :: Xform
////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y T e x t N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolyTextNote :: WNT_PolyTextNote (
int x, int y, double angle, double margin,
void* text, BOOL fWide, BOOL fOutlined
) : WNT_TextNote ( x, y, angle, text, fWide, fOutlined ),
myMargin ( margin )
{
} // end constructor

void WNT_PolyTextNote :: Play ( BOOL fDummy )
{
Xform ();
SIZE size;
RECT rect;
int height;
HDC hdc = ALLOCATOR -> myHDC;
// Set new world transform and attribs to get text size and metrics
SetAttribs ();
if ( myFlags & W32F_TUNICODE )
ALLOCATOR -> TextSize ( hdc, ( wchar_t* )myText, &size );
else
ALLOCATOR -> TextSize ( hdc, ( char* )myText, &size );
RestoreAttribs ();
ModifyWorldTransform ( hdc, &RMatrix, MWT_LEFTMULTIPLY );
// Register and draw the bounding rect
rect.left = 0;
rect.top = 0;
rect.right = ROUNDL( ( FLOAT )size.cx * SMatrix.eM11 );
rect.bottom = -ROUNDL( ( FLOAT )size.cy * SMatrix.eM22 );
if (ALLOCATOR -> myTextSlant >= 0.F)
rect.right += ROUNDL( ( FLOAT )rect.bottom * IMatrix.eM21 );
else
rect.left += ROUNDL( ( FLOAT )rect.bottom * IMatrix.eM21 );
height = ROUNDL( (FLOAT)rect.bottom * (FLOAT)myMargin / 2.0F );
InflateRect ( &rect, height, height );
// Drawing round rectangle
HPEN hpo = ( (ALLOCATOR->myFlags & W32F_POUTL) ?
SelectPen ( hdc, ALLOCATOR -> myLinePen ):
SelectPen ( hdc, GetStockObject (NULL_PEN) ) );
HBRUSH hbo = ( (ALLOCATOR->myFlags & W32F_NOFIL) ?
SelectBrush ( hdc, GetStockObject (NULL_BRUSH) ):
SelectBrush ( hdc, ALLOCATOR -> myPolyBrush ) );
Rectangle ( hdc, rect.left, rect.top, rect.right, rect.bottom );
SelectBrush ( hdc, hbo );
SelectPen ( hdc, hpo );
ALLOCATOR -> Register ( &rect );
// Draw ( fill or outline ) text
myShift = -size.cy;
ModifyWorldTransform ( hdc, &IMatrix, MWT_LEFTMULTIPLY );
ModifyWorldTransform ( hdc, &SMatrix, MWT_LEFTMULTIPLY );
SetAttribs ();
if (myFlags & W32F_TOUTLINE || ALLOCATOR -> myFlags & W32F_MONO) OutlineText ();
else FillText ();
RestoreAttribs ();
} // end WNT_PolyTextNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ B e g i n M a r k e r N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_BeginMarkerNote :: WNT_BeginMarkerNote (
int x, int y, int w, int h, double angle
) : WNT_PointNote ( x, y ),
myAngle ( angle ), myWidth ( w ), myHeight ( h )
{
myPrevAngle = ALLOCATOR -> myAngle;
ALLOCATOR -> RecalcMatrix (myMatrix, myAngle - myPrevAngle, myX, myY);
} // end constructor

void WNT_BeginMarkerNote :: Play ( BOOL fDummy )
{
ALLOCATOR -> myPO = SelectPen (ALLOCATOR -> myHDC, ALLOCATOR -> myMarkerPen);
#ifdef PRO19042
if ( ALLOCATOR -> myFlags & W32F_MFILL )
#else
if ( ALLOCATOR -> myFlags | W32F_MFILL )
#endif
ALLOCATOR -> myBO = SelectBrush (ALLOCATOR -> myHDC, ALLOCATOR -> myPolyBrush);
else
ALLOCATOR -> myBO = SelectBrush (ALLOCATOR -> myHDC, GetStockObject (NULL_BRUSH));
Xform ();
} // end WNT_BeginMarkerNote :: Play

void WNT_BeginMarkerNote :: Xform ()
{
WNT_PointNote :: Xform ();
if (myPrevAngle != ALLOCATOR -> myAngle) {
myPrevAngle = ALLOCATOR -> myAngle;
ALLOCATOR -> RecalcMatrix (myMatrix, myAngle - myPrevAngle, myX, myY);
} // end if
myMatrix.eDx = float ( myTX );
myMatrix.eDy = float ( myTY );
ModifyWorldTransform ( ALLOCATOR -> myHDC, &myMatrix, MWT_LEFTMULTIPLY );
RECT r = { -myWidth / 2, -myHeight / 2, myWidth / 2, myHeight / 2 };
ALLOCATOR -> Register ( &r );
}
////////////////////////////////////////////////////////////////////////////////
// W N T _ E n d M a r k e r N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_EndMarkerNote :: WNT_EndMarkerNote ()
{
}

void WNT_EndMarkerNote :: Play ( BOOL fDummy )
{
ALLOCATOR -> Xform ();
SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myPO );
SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myBO );
} // end WNT_EndMarkerNote :: Play

////////////////////////////////////////////////////////////////////////////////
// W N T _ L i n e A t t r i b N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_LineAttribNote :: WNT_LineAttribNote (
DWORD width, PLOGBRUSH plb,
DWORD nStyles, PDWORD pdwStyle
)
{
myPointColor = plb ->lbColor;
myWidth = ((width == 0) ? 1 : width);

// !!!ChP
myPen = gVizualizationModesManadger.
GetNewPen(width, plb, nStyles, pdwStyle);

// !!!ChP
/*
if ((width == 0 || width == 1) && (nStyles == 0))
{
myPen = CreatePen (PS_SOLID, width, plb->lbColor);
}
else
{
DWORD pStyle = ( nStyles > 0 ? PS_USERSTYLE : PS_SOLID );
pStyle |= ( PS_ENDCAP_FLAT | PS_JOIN_MITER | PS_GEOMETRIC );
myPen = ExtCreatePen ( pStyle, width, plb, nStyles, pdwStyle );

if ( !myPen )
{
char err[1024];
DWORD errCode = GetLastError();
printf ( " *** WNT_LineAttribNote : Can't create extended pen: %lu\n", errCode );
wsprintf ( err, "Can't create extended pen: %lu", errCode );
MessageBox ( NULL, err, "WNT_Allocator", MB_OK | MB_ICONEXCLAMATION );
myPen = CreatePen ( PS_SOLID, 1, RGB(170,170,70) );
}
}
*/

Play ( FALSE );
} // end constructor

WNT_LineAttribNote :: ~WNT_LineAttribNote ( void )
{
#ifdef PRO19042
if ( myPen )
{
#ifdef DEB
printf(" *** Destroy:WNT_LineAttribNote %x/%x\n",myPen,ALLOCATOR->myLinePen);
#endif

// !!!ChP
gVizualizationModesManadger.xDeletePen( myPen );
//DeletePen( myPen );

myPen = NULL;
}
#else
if ( myPen && myPen != ALLOCATOR -> myLinePen )
{
// !!!ChP
gVizualizationModesManadger.xDeletePen( myPen );
//DeletePen( myPen );
}
#endif
} // enf WNT_LineAttribNote :: ~WNT_LineAttribNote

void WNT_LineAttribNote :: Play ( BOOL fRealize )
{
ALLOCATOR -> myLinePen = myPen;
ALLOCATOR -> myLineWidth = myWidth;
ALLOCATOR -> myPointColor = myPointColor;
if ( fRealize )
SelectPen ( ALLOCATOR -> myHDC, myPen );
} // end WNT_LineAttribNote :: Play

////////////////////////////////////////////////////////////////////////////////
// W N T _ P o l y A t t r i b N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_PolyAttribNote :: WNT_PolyAttribNote (
PLOGBRUSH plb, BOOL fDrawEdge, int aFillMode
)
{
myfEdge = fDrawEdge;
myNoFill = ( plb -> lbStyle == BS_NULL );

// !!!ChP
myBrush = gVizualizationModesManadger.GetNewBrush( plb );
//myBrush = CreateBrushIndirect ( plb );

Play ( FALSE );
} // end constructor

WNT_PolyAttribNote :: ~WNT_PolyAttribNote ( void )
{
#ifdef PRO19042
if ( myBrush )
{
#ifdef DEB
printf(" *** Destroy:WNT_PolyAttribNote %x/%x\n",myBrush,ALLOCATOR->myPolyBrush);
#endif

// !!!ChP
gVizualizationModesManadger.xDeleteBrush( myBrush );
//DeleteBrush( myBrush );
myBrush = NULL;
}
#else
if ( myBrush && myBrush != ALLOCATOR -> myPolyBrush )
{
// !!!ChP
gVizualizationModesManadger.xDeleteBrush( myBrush );
//DeleteBrush( myBrush );
}
#endif
} // enf WNT_PolyAttribNote :: ~WNT_PolyAttribNote

void WNT_PolyAttribNote :: Play ( BOOL fRealize )
{
if ( myfEdge ) ALLOCATOR -> myFlags |= W32F_POUTL;
else ALLOCATOR -> myFlags &= ~W32F_POUTL;
if ( myNoFill ) ALLOCATOR -> myFlags |= W32F_NOFIL;
else ALLOCATOR -> myFlags &= ~W32F_NOFIL;
ALLOCATOR -> myPolyBrush = myBrush;
if ( fRealize ) {
SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myLinePen );
SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myPolyBrush );
}
} // end WNT_PolyAttribNote :: Play

////////////////////////////////////////////////////////////////////////////////
// W N T _ T e x t A t t r i b N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_TextAttribNote :: WNT_TextAttribNote (
HFONT hFont, COLORREF color, double slant,
double hScale, double vScale,
BOOL fUnderlined, BOOL fFree, BOOL fIndex
)
{
myFont = hFont;
mySlant = (slant == 0.0 ? EPS : slant);
myHScale = vScale;
myVScale = hScale;
myFlags = ( fUnderlined ? W32F_TFULINED : 0 ) |
( fIndex ? W32F_TINDEX : 0 ) |
( fFree ? W32F_TFREE : 0 );
myColor = color;

// !!! ChP
LOGBRUSH lb = { BS_SOLID, color, 0 };
myPen = gVizualizationModesManadger.GetNewPen( 0, &lb, PS_SOLID );
myBrush = gVizualizationModesManadger.GetNewBrush( &lb );

// !!!ChP
/*
myPen = CreatePen ( PS_SOLID, 0, color );
myBrush = CreateSolidBrush ( color );
*/

Play ( FALSE );
} // end constructor

WNT_TextAttribNote :: ~WNT_TextAttribNote ()
{
#ifdef PRO19042
if ( myFont && (myFlags & W32F_TFREE) )
{
#ifdef DEB
printf(" *** Destroy:WNT_TextAttribNote_FONT %x/%x\n",myFont,ALLOCATOR->myTextFont);
#endif
DeleteFont( myFont );
myFont = NULL;
}

if ( myPen )
{
#ifdef DEB
printf(" *** Destroy:WNT_TextAttribNote_PEN %x/%x\n",myPen,ALLOCATOR->myTextPen);
#endif

// !!!ChP
gVizualizationModesManadger.xDeletePen( myPen );
//DeletePen( myPen );
myPen = NULL;
}

if ( myBrush )
{
#ifdef DEB
printf(" *** Destroy:WNT_TextAttribNote_BRUSH %x/%x\n",myBrush,ALLOCATOR->myTextBrush);
#endif

// !!!ChP
gVizualizationModesManadger.xDeleteBrush( myBrush );
//DeleteBrush( myBrush );
myBrush = NULL;
}
#else
if ( myFlags & W32F_TFREE )
{
DeleteFont( myFont );
}
if ( myPen && myPen != ALLOCATOR -> myTextPen )
{
// !!!ChP
gVizualizationModesManadger.xDeletePen( myPen );
//DeletePen( myPen );
}
if ( myBrush && myBrush != ALLOCATOR -> myTextBrush )
{
// !!!ChP
gVizualizationModesManadger.xDeleteBrush( myBrush );
//DeleteBrush( myBrush );
}
#endif
} // end destructor

void WNT_TextAttribNote :: Play ( BOOL fRealize )
{
if ( ( ALLOCATOR -> myFlags & W32F_DFONT ) && !( myFlags & W32F_TINDEX ) ) {
DeleteFont( ALLOCATOR -> myTextFont );
ALLOCATOR -> myFlags &= ~W32F_DFONT;
} // end if
ALLOCATOR -> myTextFont = myFont;
ALLOCATOR -> myTextSlant = mySlant;
ALLOCATOR -> myTextHScale = myHScale;
ALLOCATOR -> myTextVScale = myVScale;
ALLOCATOR -> myTextColor = myColor;
ALLOCATOR -> myTextPen = myPen;
ALLOCATOR -> myTextBrush = myBrush;
if (myFlags & W32F_TFULINED) ALLOCATOR -> myFlags |= W32F_TULIN;
else ALLOCATOR -> myFlags &= ~W32F_TULIN;
if ( fRealize && !( myFlags & W32F_TINDEX ) ) {
SetTextColor ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextColor );
SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextPen );
SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextBrush );
SelectFont ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextFont );
}
} // end WNT_TextAttribNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ M a r

Marina's picture

WNT_Allocator.cxx file ending

------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------- WNT_Allocator.cxx-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
// W N T _ T e x t A t t r i b N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_TextAttribNote :: WNT_TextAttribNote (
HFONT hFont, COLORREF color, double slant,
double hScale, double vScale,
BOOL fUnderlined, BOOL fFree, BOOL fIndex
)
{
myFont = hFont;
mySlant = (slant == 0.0 ? EPS : slant);
myHScale = vScale;
myVScale = hScale;
myFlags = ( fUnderlined ? W32F_TFULINED : 0 ) |
( fIndex ? W32F_TINDEX : 0 ) |
( fFree ? W32F_TFREE : 0 );
myColor = color;

// !!! ChP
LOGBRUSH lb = { BS_SOLID, color, 0 };
myPen = gVizualizationModesManadger.GetNewPen( 0, &lb, PS_SOLID );
myBrush = gVizualizationModesManadger.GetNewBrush( &lb );

// !!!ChP
/*
myPen = CreatePen ( PS_SOLID, 0, color );
myBrush = CreateSolidBrush ( color );
*/

Play ( FALSE );
} // end constructor

WNT_TextAttribNote :: ~WNT_TextAttribNote ()
{
#ifdef PRO19042
if ( myFont && (myFlags & W32F_TFREE) )
{
#ifdef DEB
printf(" *** Destroy:WNT_TextAttribNote_FONT %x/%x\n",myFont,ALLOCATOR->myTextFont);
#endif
DeleteFont( myFont );
myFont = NULL;
}

if ( myPen )
{
#ifdef DEB
printf(" *** Destroy:WNT_TextAttribNote_PEN %x/%x\n",myPen,ALLOCATOR->myTextPen);
#endif

// !!!ChP
gVizualizationModesManadger.xDeletePen( myPen );
//DeletePen( myPen );
myPen = NULL;
}

if ( myBrush )
{
#ifdef DEB
printf(" *** Destroy:WNT_TextAttribNote_BRUSH %x/%x\n",myBrush,ALLOCATOR->myTextBrush);
#endif

// !!!ChP
gVizualizationModesManadger.xDeleteBrush( myBrush );
//DeleteBrush( myBrush );
myBrush = NULL;
}
#else
if ( myFlags & W32F_TFREE )
{
DeleteFont( myFont );
}
if ( myPen && myPen != ALLOCATOR -> myTextPen )
{
// !!!ChP
gVizualizationModesManadger.xDeletePen( myPen );
//DeletePen( myPen );
}
if ( myBrush && myBrush != ALLOCATOR -> myTextBrush )
{
// !!!ChP
gVizualizationModesManadger.xDeleteBrush( myBrush );
//DeleteBrush( myBrush );
}
#endif
} // end destructor

void WNT_TextAttribNote :: Play ( BOOL fRealize )
{
if ( ( ALLOCATOR -> myFlags & W32F_DFONT ) && !( myFlags & W32F_TINDEX ) ) {
DeleteFont( ALLOCATOR -> myTextFont );
ALLOCATOR -> myFlags &= ~W32F_DFONT;
} // end if
ALLOCATOR -> myTextFont = myFont;
ALLOCATOR -> myTextSlant = mySlant;
ALLOCATOR -> myTextHScale = myHScale;
ALLOCATOR -> myTextVScale = myVScale;
ALLOCATOR -> myTextColor = myColor;
ALLOCATOR -> myTextPen = myPen;
ALLOCATOR -> myTextBrush = myBrush;
if (myFlags & W32F_TFULINED) ALLOCATOR -> myFlags |= W32F_TULIN;
else ALLOCATOR -> myFlags &= ~W32F_TULIN;
if ( fRealize && !( myFlags & W32F_TINDEX ) ) {
SetTextColor ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextColor );
SelectPen ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextPen );
SelectBrush ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextBrush );
SelectFont ( ALLOCATOR -> myHDC, ALLOCATOR -> myTextFont );
}
} // end WNT_TextAttribNote :: Play
////////////////////////////////////////////////////////////////////////////////
// W N T _ M a r k e r A t t r i b N o t e //
////////////////////////////////////////////////////////////////////////////////
WNT_MarkerAttribNote :: WNT_MarkerAttribNote (
COLORREF color, DWORD dwWidth, BOOL fFill
)
{
DWORD width = (dwWidth == 0) ? 1 : dwWidth;

myFill = fFill;
myMarkerPointColor = color;
myPen = CreatePen ( PS_SOLID, width, color );
Play ();
} // end constructor

WNT_MarkerAttribNote :: ~WNT_MarkerAttribNote ( void )
{
#ifdef PRO19042
if ( myPen ) {
#ifdef DEB
printf(" *** Destroy:WNT_MarkerAttribNote %x/%x\n",myPen,ALLOCATOR->myMarkerPen);
#endif
DeletePen( myPen );
myPen = NULL;
}
#else
if ( myPen && myPen != ALLOCATOR -> myMarkerPen ) DeletePen( myPen );
#endif
} // enf WNT_MarkerAttribNote :: ~WNT_MarkerAttribNote

void WNT_MarkerAttribNote :: Play ( BOOL fRealize )
{
if (myFill) ALLOCATOR -> myFlags |= W32F_MFILL;
else ALLOCATOR -> myFlags &= ~W32F_MFILL;

ALLOCATOR -> myMarkerPen = myPen;
ALLOCATOR -> myMarkerPointColor = myMarkerPointColor;
} // end WNT_MarkerAttribNote :: Play

// !!! ChP
//-----------------------------------------------------------------------
// Class - CPenUsing
//-----------------------------------------------------------------------

CPenUsing::CPenUsing()
{
m_iNumOfUsing = 0;

m_hPen = NULL;
}

CPenUsing::~CPenUsing()
{

}

//-----------------------------------------------------------------------
// Class - CBrushUsing
//-----------------------------------------------------------------------

CBrushUsing::CBrushUsing()
{
m_iNumOfUsing = 0;

m_hBrush = NULL;
}

CBrushUsing::~CBrushUsing()
{

}

//-----------------------------------------------------------------------
// Class - VizualizationModesManadger
//-----------------------------------------------------------------------

CVizualizationModesManadger::CVizualizationModesManadger()
{
}

CVizualizationModesManadger::~CVizualizationModesManadger()
{

}

HPEN CVizualizationModesManadger::GetNewPen(DWORD xWidth, PLOGBRUSH plb,
DWORD nStyles, PDWORD pdwStyle)
{
for (int i = 0; i < m_aPen.size(); i++)
{
if (
(m_aPen[i].m_xWidth == xWidth)
&&
(m_aPen[i].m_lb.lbStyle == plb->lbStyle)
&&
(m_aPen[i].m_lb.lbColor == plb->lbColor)
&&
(m_aPen[i].m_lb.lbHatch == plb->lbHatch)
&&
(m_aPen[i].m_nStyles == nStyles)
&&
(m_aPen[i].m_pdwStyle == pdwStyle)
)
{
if ( (m_aPen[i].m_iNumOfUsing > 0) && (m_aPen[i].m_hPen != NULL ) )
{
m_aPen[i].m_iNumOfUsing++;

return m_aPen[i].m_hPen;
}
}
}

//----------Create new pen begin-----------------------------------
m_PenForAdd.m_xWidth = xWidth;
m_PenForAdd.m_lb = *plb;
m_PenForAdd.m_nStyles = nStyles;
m_PenForAdd.m_pdwStyle = pdwStyle;

if ((xWidth == 0 || xWidth == 1) && (nStyles == 0))
{
m_PenForAdd.m_hPen = CreatePen(PS_SOLID, xWidth, plb->lbColor);
}
else
{

DWORD pStyle = ( nStyles > 0 ? PS_USERSTYLE : PS_SOLID );
pStyle |= ( PS_ENDCAP_FLAT | PS_JOIN_MITER | PS_GEOMETRIC );
m_PenForAdd.m_hPen = ExtCreatePen(pStyle, xWidth, plb, nStyles, pdwStyle );

if ( !m_PenForAdd.m_hPen )
{
char err[1024];
DWORD errCode = GetLastError();
printf ( " *** WNT_LineAttribNote : Can't create extended pen: %lu\n", errCode );
wsprintf ( err, "Can't create extended pen: %lu", errCode );
MessageBox ( NULL, err, "WNT_Allocator", MB_OK | MB_ICONEXCLAMATION );
m_PenForAdd.m_hPen = CreatePen ( PS_SOLID, 1, RGB(170,170,70) );
}
}

if (m_PenForAdd.m_hPen != NULL)
{
m_PenForAdd.m_iNumOfUsing++;

m_aPen.push_back(m_PenForAdd);

return m_PenForAdd.m_hPen;
}
//----------Create new pen end-----------------------------------

return NULL;
}

void CVizualizationModesManadger::xDeletePen(HPEN hPen)
{
if (hPen != NULL)
{
return;
}

for (int i = m_aPen.size() - 1; i >=0 ; i--)
{
if ( m_aPen[i].m_hPen == hPen )
{
m_aPen[i].m_iNumOfUsing--;

if (m_aPen[i].m_iNumOfUsing == 0)
{
DeletePen( m_aPen[i].m_hPen );

m_aPen.erase(&m_aPen[i]);
}
}
}
}

HBRUSH CVizualizationModesManadger::GetNewBrush(PLOGBRUSH plb)
{
for (int i = 0; i < m_aBrush.size(); i++)
{
if (
(m_aBrush[i].m_lb.lbStyle == plb->lbStyle)
&&
(m_aBrush[i].m_lb.lbColor == plb->lbColor)
&&
(m_aBrush[i].m_lb.lbHatch == plb->lbHatch)
)
{
if ( (m_aBrush[i].m_iNumOfUsing > 0) && (m_aBrush[i].m_hBrush != NULL ) )
{
m_aBrush[i].m_iNumOfUsing++;

return m_aBrush[i].m_hBrush;
}
}
}

//----------Create new brush begin-----------------------------------
m_BrushForAdd.m_lb = *plb;

m_BrushForAdd.m_hBrush = CreateBrushIndirect ( plb );

if (m_BrushForAdd.m_hBrush != NULL)
{
m_BrushForAdd.m_iNumOfUsing++;

m_aBrush.push_back(m_BrushForAdd);

return m_BrushForAdd.m_hBrush;
}
//----------Create new brush end-----------------------------------

return NULL;
}

void CVizualizationModesManadger::xDeleteBrush(HBRUSH hBrush)
{
if (hBrush != NULL)
{
return;
}

for (int i = m_aBrush.size() - 1; i >=0 ; i--)
{
if ( m_aBrush[i].m_hBrush == hBrush )
{
m_aBrush[i].m_iNumOfUsing--;

if (m_aBrush[i].m_iNumOfUsing == 0)
{
DeleteBrush( m_aBrush[i].m_hBrush );

m_aBrush.erase(&m_aBrush[i]);
}
}
}
}

//-----------------------------------------------------