home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
hpp.z
/
WFONT.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-18
|
13KB
|
442 lines
/**********************************************************************
*
* wfont.cpp -- Generalized font support.
*
**********************************************************************/
#ifndef _WFONT_HPP_INCLUDED
#define _WFONT_HPP_INCLUDED
#ifndef _WNO_PRAGMA_PUSH
#pragma pack(push,8);
#pragma enum int;
#endif
#ifndef _WSTRING_HPP_INCLUDED
# include "wstring.hpp"
#endif
#ifndef _WCANVAS_HPP_INCLUDED
# include "wcanvas.hpp"
#endif
//
// Stock fonts -- These are system fonts that are always available.
//
enum WFStockFont {
WFInheritedFont = -1,
WFNullFont = 0,
WFOEMFixedFont = 10,
WFFirstStockFont = WFOEMFixedFont,
WFAnsiFixedFont = 11,
WFAnsiFont = 12,
WFSystemFont = 13,
WFDeviceDefaultFont = 14,
WFSystemFixedFont = 16,
WFDefaultGUIFont = 17,
WFLastStockFontPlusOne,
WFLastStockFont = WFLastStockFontPlusOne - 1
};
//
// Boldness values
//
enum WFBoldType {
WFUnknownBold = 0,
WFThin = 100,
WFExtraLight = 200,
WFLight = 300,
WFNormal = 400,
WFMedium = 500,
WFSemiBold = 600,
WFBold = 700,
WFExtraBold = 800,
WFHeavy = 900,
};
//
// Character sets
//
enum WFCharSetType {
WFAnsiCharSet = 0,
WFDefaultCharSet = 1,
WFSymbolCharSet = 2,
WFMacCharSet = 77,
WFShiftJisCharSet = 128,
WFHangeulCharSet = 129,
WFJohabCharSet = 130,
WFGB2312CharSet = 134,
WFChineseBig5CharSet = 136,
WFGreekCharSet = 161,
WFTurkishCharSet = 162,
WFHebrewCharSet = 177,
WFArabicCharSet = 178,
WFBalticCharSet = 186,
WFRussianCharSet = 204,
WFThaiCharSet = 222,
WFEastEuropeCharSet = 238,
WFOEMCharSet = 255,
};
//
// Output precision
//
enum WFOutPrecType {
WFOutDefault = 0,
WFOutString = 1,
WFOutCharacter = 2,
WFOutStroke = 3,
WFOutTrueType = 4,
WFOutDevice = 5,
WFOutRaster = 6,
WFOutTrueTypeOnly = 7,
WFOutOutline = 8,
};
//
// Clipping precision
//
enum WFClipPrecType {
WFClipDefault = 0,
WFClipCharacter = 1,
WFClipStroke = 2,
WFClipMask = 0xf,
WFClipLHAngles = (1<<4),
WFClipTrueTypeAlways = (2<<4),
WFClipEmbedded = (8<<4),
};
//
// Output quality
//
enum WFQualityType {
WFDefaultQuality = 0,
WFDraftQuality = 1,
WFProofQuality = 2,
};
//
// Font pitch
//
enum WFPitchType {
WFDefaultPitch = 0,
WFFixedPitch = 1,
WFVariablePitch = 2,
};
//
// Font family
//
enum WFFamilyType {
WFDontCare = (0<<4),
WFRoman = (1<<4),
WFSwiss = (2<<4),
WFModern = (3<<4),
WFScript = (4<<4),
WFDecorative = (5<<4),
};
#ifndef _WIN16
#ifdef UNICODE
typedef struct tagLOGFONTW WSystemLogicalFont;
#else
typedef struct tagLOGFONTA WSystemLogicalFont;
#endif
#else
typedef struct tagLOGFONT WSystemLogicalFont;
#endif
class WFontReference; // internal use only
//
// WFont
//
class WCMCLASS WFont : public WObject {
WDeclareSubclass( WFont, WObject );
public:
/************************************************************
* Constructors
************************************************************/
WFont( WFStockFont fontType=WFNullFont );
WFont( const WChar *fontDescription,
const WInfoCanvas *canvas=NULL );
WFont( const WString & fontDescription,
const WInfoCanvas *canvas=NULL );
WFont( const WFont &font );
WFont( WFontHandle handle, WBool deleteHandle=FALSE );
WFont( const WSystemLogicalFont *logicalFont, WInt pointsize=0,
const WInfoCanvas *canvas=NULL );
WFont( const WString & faceName, WInt pointsize,
const WInfoCanvas *canvas=NULL,
WInt cy=0, WInt cx=0, WInt escape=0, WInt orient=0,
WFBoldType weight=WFNormal, WBool ital=FALSE,
WBool under=FALSE, WBool strike=FALSE,
WFCharSetType charset=WFDefaultCharSet,
WFOutPrecType outprec=WFOutDefault,
WFClipPrecType clipprec=WFClipDefault,
WFQualityType qual = WFDefaultQuality,
WFPitchType ptch=WFDefaultPitch,
WFFamilyType fmly=WFDontCare );
~WFont();
WFont& operator=( const WFont & f );
WFont& operator=( WFStockFont f );
/*******************************************************************
* Properties
*******************************************************************/
// Bold
//
// Bold is defined as Weight >= WFBold. Setting bold on sets
// the weight to WFBold, setting it off sets it to WFNormal.
WBool GetBold() const;
WBool SetBold( WBool on );
// CharacterSet
WFCharSetType GetCharacterSet() const;
WBool SetCharacterSet( WFCharSetType characterSet );
// ClipPrecision
WFClipPrecType GetClipPrecision() const;
WBool SetClipPrecision( WFClipPrecType clipPrecision );
// FaceName
WString GetFaceName() const;
WBool SetFaceName( const WString & name );
// Family
WFFamilyType GetFamily() const;
WBool SetFamily( WFFamilyType family );
// Handle
WFontHandle GetHandle( WBool noNullHandle=FALSE ) const;
// Height
WInt GetHeight() const;
// Italic
WBool GetItalic() const;
WBool SetItalic( WBool on );
// Name
//
// Returns the full name (i.e. "8.Helv.Bold") of the font.
// Use the FaceName property just for the face name.
// The extended name includes information useful for
// saving a font.
WString GetName( WBool extended=FALSE ) const;
WBool SetName( const WChar *name );
// OutputPrecision
WFOutPrecType GetOutputPrecision() const;
WBool SetOutputPrecision( WFOutPrecType outputPrecision );
// Pitch
WFPitchType GetPitch() const;
WBool SetPitch( WFPitchType pitch );
// PointSize
WInt GetPointSize() const;
WBool SetPointSize( WInt pointSize );
// Quality
WFQualityType GetQuality() const;
WBool SetQuality( WFQualityType quality );
// Stock
WBool GetStock() const;
// StrikeOut
WBool GetStrikeOut() const;
WBool SetStrikeOut( WBool on );
// Underline
WBool GetUnderline() const;
WBool SetUnderline( WBool on );
// Valid
//
// TRUE if font is defined.
WBool GetValid() const;
// Weight
WInt GetWeight() const;
WBool SetWeight( WInt weight );
// Width
//
// Calculates the average width of the font based on the
// average width of the 52 upper and lowercase English
// letters.
WInt GetWidth() const;
/*******************************************************************
* Methods
*******************************************************************/
// Clear
WBool Clear();
// CopyToLogicalFont
WBool CopyToLogicalFont( WSystemLogicalFont *copyInto );
// Create
//
// Create a font using a variety of methods....
WBool Create( WFStockFont fontType=WFNullFont );
WBool Create( const WChar *fontDescription,
const WInfoCanvas *canvas=NULL );
WBool Create( const WString & fontDescription,
const WInfoCanvas *canvas=NULL );
WBool Create( const WFont &font );
WBool Create( WFontHandle handle, WBool deleteHandle=FALSE );
WBool Create( const WSystemLogicalFont *logicalFont, WInt pointsize=0,
const WInfoCanvas *canvas=NULL );
WBool Create( const WString & faceName, WInt pointsize,
const WInfoCanvas *canvas=NULL,
WInt cy=0, WInt cx=0, WInt escape=0, WInt orient=0,
WFBoldType weight=WFNormal, WBool ital=FALSE,
WBool under=FALSE, WBool strike=FALSE,
WFCharSetType charset=WFDefaultCharSet,
WFOutPrecType outprec=WFOutDefault,
WFClipPrecType clipprec=WFClipDefault,
WFQualityType qual = WFDefaultQuality,
WFPitchType ptch=WFDefaultPitch,
WFFamilyType fmly=WFDontCare );
// HorizDUToPixel
//
// Convert horizontal dialog units into pixels based
// on the font.
WLong HorizDUToPixel( WLong dialogUnits ) const;
// VertDUToPixel
//
// Convert vertical dialog units into pixels based
// on the font.
WLong VertDUToPixel( WLong dialogUnits ) const;
// PixelToHorizDU
//
// Convert pixels into horizontal dialog units based
// on the font.
WLong PixelToHorizDU( WLong pixels ) const;
// PixelToVertDU
//
// Convert pixels into horizontal dialog units based
// on the font.
WLong PixelToVertDU( WLong pixels ) const;
/*************************************************************
* Static Properties
*************************************************************/
// DefaultGUIFont
static const WFont & GetDefaultGUIFont();
// InheritedFont
static const WFont & GetInheritedFont();
// NullFont
static const WFont & GetNullFont();
// SystemFont
static const WFont & GetSystemFont();
// StandardGUIFont
static const WFont & GetStandardGUIFont();
/************************************************************
* Static Methods
************************************************************/
// IsValidHandle
//
// Returns TRUE if the given handle is valid. Can
// optionally specify whether or not a null handle
// is "valid".
static WBool IsValidHandle( WFontHandle handle,
WBool nullValid=FALSE );
/*************************************************************
* Operator overloads
*************************************************************/
int operator==( const WFont & f ) const;
int operator!=( const WFont & f ) const;
/*************************************************************
* Private
*************************************************************/
protected:
WBool PrepareForRead() const;
WBool PrepareForUpdate() const;
private:
WFStockFont _stockFont;
WFontReference *_fontReference;
};
#ifdef _DEBUG
#define W_ISFONTHANDLE(h) CHECKGDI(WFont::IsValidHandle((WFontHandle)h))
#else
#define W_ISFONTHANDLE(h)
#endif
#ifndef _WNO_PRAGMA_PUSH
#pragma enum pop;
#pragma pack(pop);
#endif
#endif // _WFONT_HPP_INCLUDED