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

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

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