Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

/cygdrive/d/Eigene Dateien/!DProcs/code_gen/src/QFont.cpp

Go to the documentation of this file.
00001 // Class QFont 
00002 // Font class for drawing text
00003 // Filename QFont.cpp
00004 // FaPra 2003-2004, A5,  Alexander Kramer
00005 
00006 
00007 #include "QFont.h"
00008 
00009 #include <math.h>
00010 #include <iostream>
00011 using namespace std;
00012 
00013 
00014 #include <GL/glut.h>
00015 #include "DrawText.h"
00016 // implementation of QFont
00017 
00018 //! draws the text with maximum length)
00019 void QFont::draw( const  char*  aText , int  maxLength )
00020 {
00021   glPushMatrix();
00022   drawInternal(aText, maxLength);
00023   glPopMatrix();
00024 } // end of draw()
00025 
00026 //! draws the text and ajust the matrix
00027 void QFont::drawInternal( const  char*  aText , int  maxLength )
00028 {
00029   Color->setAsCurrent();
00030 
00031   glScalef (Size / 16.0, Size / 16.0, 1.0);
00032 
00033   TEXTDRAWER.PrintText(Bold,maxLength, aText);
00034 } // end of drawInternal()
00035 
00036 //! draws the text at given position
00037 void QFont::drawAtPos( const  char*  aText , int  x , int  y , int  maxLength )
00038 {
00039   glPushMatrix();
00040   glTranslatef(x,y,0);
00041   drawInternal(aText,maxLength);
00042   glPopMatrix();
00043 } // end of drawAtPos()
00044 
00045 //! returns width of text
00046 float QFont::getTextWidth( const  char*  aText )
00047 {
00048  return strlen(aText) * 12.0 * Size / 16.0;
00049 
00050 } // end of getTextWidth()
00051 
00052 //! returns length of string which can be drawn whithin the given width
00053 int QFont::getLengthForWidth( const  char*  aText , int  aWidth )
00054 {
00055   unsigned int maxlen = (unsigned int)(ceil(aWidth * 16.0 / (Size * 12.0)));
00056  
00057   if (maxlen < strlen(aText)) return maxlen;
00058   else
00059   return strlen(aText); 
00060 
00061 } // end of getLengthForWidth()
00062 
00063 //! initialization code
00064 void QFont::Init()
00065 {
00066 
00067 } // end of Init()
00068 
00069 //! clean up code
00070 void QFont::CleanUp()
00071 {
00072 
00073 } // end of CleanUp()
00074 
00075 //! getter method for Size
00076 int QFont::getSize()
00077 {
00078 return Size;
00079 } // end of getSize()
00080 
00081 //! setter method for Size
00082 void QFont::setSize( int  newValue )
00083 {
00084 Size = newValue;
00085 } // end of setSize()
00086 
00087 //! getter method for Bold
00088 bool QFont::getBold()
00089 {
00090 return Bold;
00091 } // end of getBold()
00092 
00093 //! setter method for Bold
00094 void QFont::setBold( bool  newValue )
00095 {
00096 Bold = newValue;
00097 } // end of setBold()
00098 
00099 //! getter method for Color
00100 QColor* QFont::getColor()
00101 {
00102 return Color;
00103 } // end of getColor()
00104 
00105 // WARNING : The implementation of this method will be automatically generated with code generator.
00106 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00107 //! copy itself from another instance
00108 void QFont::copyFrom( QFont*  from )
00109 {
00110 setSize(from->getSize());
00111 setBold(from->getBold());
00112 Color->copyFrom(from->getColor());
00113 } // end of copyFrom()
00114 
00115 // WARNING : The implementation of this method will be automatically generated with code generator.
00116 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00117 //! prints itself to the cout
00118 void QFont::print()
00119 {
00120 cout << "Class : QFont" << endl;
00121 cout << "Size = " << Size << endl;
00122 cout << "Bold = " << Bold << endl;
00123 } // end of print()
00124 
00125 // WARNING : The implementation of this method will be automatically generated with code generator.
00126 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00127 //! Constructor
00128  QFont::QFont(  )
00129 {
00130 Bold = false;
00131 Color = new QColor;
00132 Init();
00133 } // end of QFont()
00134 
00135 // WARNING : The implementation of this method will be automatically generated with code generator.
00136 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00137 //! Destructor
00138  QFont::~QFont()
00139 {
00140 delete Color;
00141 CleanUp();
00142 } // end of ~QFont()
00143 
00144 // end of implementation of QFont
00145 
00146 

Generated on Thu Mar 18 18:33:48 2004 for miniQT by doxygen1.2.18