|
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
|
00001 /********************************************************************************
00002 * *
00003 * F o n t r o t a t i o n o b j e c t *
00004 * *
00005 *********************************************************************************
00006 * Copyright (C) 2002 by Richard L. Herbst. All Rights Reserved. *
00007 *********************************************************************************
00008 * This program is free software; you can redistribute it and/or *
00009 * modify it under the terms of the GNU Lesser General Public *
00010 * License as published by the Free Software Foundation; either *
00011 * version 2.1 of the License, or (at your option) any later version. *
00012 * *
00013 * This library is distributed in the hope that it will be useful, *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
00016 * Lesser General Public License for more details. *
00017 * *
00018 * You should have received a copy of the GNU Lesser General Public *
00019 * License along with this library; if not, write to the Free Software *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
00021 ********************************************************************************/
00022 #ifndef FXROTATABLEFONT_H
00023 #define FXROTATABLEFONT_H
00024
00025 #ifndef FXFONT_H
00026 #include <fox/FXFont.h>
00027 using namespace FX;
00028 #endif
00029 namespace FXEX {
00030 class FXRotatableFont;
00031
00032 /// Font metrics object
00033 class FXAPI FXFontMatrix {
00034 friend class FXRotatableFont;
00035
00036 protected:
00037 FXfloat a, b, c, d; // font properties
00038
00039 protected:
00040 /// return string'ised version of sign
00041 FXString getSign(FXfloat x);
00042
00043 /// return string'ised name of font
00044 FXString getXLFDStr(void);
00045
00046 public:
00047 /// build font metrics
00048 FXFontMatrix(FXfloat FontSz=1.0);
00049
00050 /// provide copy constructor
00051 FXFontMatrix(const FXFontMatrix &M);
00052
00053 /// adjust font size
00054 void setFontSz(FXfloat FontSz);
00055
00056 /// rotation angle (+) Rotates counter-clockwise
00057 void setRotate(FXfloat T);
00058
00059 /// set shear metric (+) Shears counter-clockwise
00060 void setShear(FXfloat T);
00061
00062 /// set font to anamorphic
00063 void setAnamorphic(FXfloat a1, FXfloat d1);
00064
00065 /// set font to mirror about X
00066 void setMirrorX();
00067
00068 /// set font to mirror about Y
00069 void setMirrorY();
00070
00071 /// allow font metrics multiplication
00072 friend FXFontMatrix operator * (FXFontMatrix M1, FXFontMatrix M2);
00073 };
00074
00075
00076 /**
00077 * A Rotatable Font is like any other font, in that you can draw the font onto your FXDC.
00078 * It differs in that it has the ability to be able to draw the font at a specified angle,
00079 * rather than the tradional left-to-right.
00080 */
00081 class FXAPI FXRotatableFont : public FXFont {
00082 protected:
00083 FXfloat pixelMul; // pixel scaling factor
00084 FXFontMatrix matrix; // font metrics
00085
00086 #ifndef WIN32
00087 protected:
00088 /**
00089 * We need this to get the Resolution and the
00090 * complete font data from the font Dialog Box
00091 */
00092 FXString getFontStr(void);
00093
00094 // We need to get at the attributes data to calculate the character width
00095 FXint getFontAttributes(const FXchar *text, FXuint n);
00096
00097 /**
00098 * Set the font's XLFD name. copy of the XLFD font constructor for FXFont
00099 * (except the reset of size etc to 0 is removed)
00100 */
00101 void setXName(const FXString& n);
00102 #endif
00103
00104 public:
00105 /**
00106 * Construct font from font description
00107 */
00108 FXRotatableFont(FXApp* a,const FXFontDesc& fontdesc,FXfloat ang=0);
00109
00110 /**
00111 * Construct a font with given face name, size in points(pixels),
00112 * weight, slant, character set encoding, setwidth, and hints
00113 */
00114 FXRotatableFont(FXApp* a,const FXString& face,FXuint sz,FXfloat ang=0,FXuint wt=FONTWEIGHT_NORMAL,FXuint sl=FONTSLANT_REGULAR,FXuint enc=FONTENCODING_DEFAULT,FXuint setw=FONTSETWIDTH_DONTCARE,FXuint h=0);
00115
00116 /// display text using font
00117 void displayText(FXDC& dc,const FXString& str,FXint xstart,FXint ystart);
00118
00119 /// return angle
00120 FXfloat getAngle() const { return angle; }
00121
00122 /// set to new angle
00123 void setAngle(FXfloat ang);
00124
00125 /// create font resources
00126 void create();
00127 };
00128
00129 } // namespace FXEX
00130 #endif // FXROTATABLEFONT_H