AaronCameron.net
No ads. No Profit. No Master, But Truth.
Not a Member? - Login or Create an Account
Wednesday the 23rd of May 2012 @ 10:29am
Front Page Journal Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cGuiTextStyle.h

Go to the documentation of this file.
00001 /************************************************************************
00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library
00003 Copyright (C) 2002  Aaron Cameron
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Lesser General Public
00007 License as published by the Free Software Foundation; either
00008 version 2.1 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018 
00019 A copy of the GNU Lesser General Public License has been provided with
00020 this library in the file 'COPYING'.
00021 
00022 Contact information for the author of this library has been provided
00023 with this library in the file 'AUTHOR'.
00024 ************************************************************************/
00025 #ifndef _n2l4_cGuiTextStyle_H
00026 #define _n2l4_cGuiTextStyle_H
00027 
00028 #include "n2l/n2l.h"
00029 #include "n2l/video.h"
00030 #include "n2l/fonts.h"
00031 
00032 #include "gui/types.h"
00033 
00034 namespace n2l
00035 {
00036     class cVfsNodeInterface;
00037     class cDynVar;
00038 
00044     class cGuiTextStyle
00045     {
00046     public:
00047         typedef enum {
00048             Align_Left,
00049             Align_Right,
00050             Align_Center,
00051 
00052             Align_NumAligns
00053         } tAlign;
00054 
00055         typedef enum {
00056             VAlign_Top,
00057             VAlign_Middle,
00058             VAlign_Bottom,
00059 
00060             VAlign_NumVAligns
00061         } tVAlign;
00062 
00063         typedef enum {
00067             Clipping_NoClip,
00068 
00071             Clipping_Letter,
00072 
00075             Clipping_Word,
00076             
00078             Clipping_HardWord,  
00079 
00080             Clipping_NumClippings
00081         } tClipping;
00082     
00083         cGuiTextStyle();
00084         cGuiTextStyle( const cVfsNodeInterface & iNode );
00085         cGuiTextStyle( const cDynVar & iDefinition );
00086         ~cGuiTextStyle();
00087 
00088         void load( const cVfsNodeInterface & iNode );
00089         void load( const cDynVar & iDefinition );
00090 
00091         void font( const cAutoPtr<const cFontInterface> & i_iFont );
00092         const cAutoPtr<const cFontInterface> & font() const;
00093         
00094         void fontHeight( const tFloat & iFontHeight );
00095         const tFloat & fontHeight() const;
00096         
00097         void colour( const tGuiColour & iColour );
00098         void colourInherit( const tBool iValue );
00099 
00100         void align( const tAlign iAlign );
00101         void vAlign( const tVAlign iVAlign );
00102         void clipping( const tClipping iClipping );
00103 
00113         const tString::size_type draw(  const tGuiPos & iPos,
00114             const tGuiPos & iSize, const tString & iText,
00115             const tString::size_type iSPos = 0,
00116             const tString::size_type iMaxSize = 0 ) const;
00117 
00123         const tString::size_type wouldDraw( const tGuiPos & iSize,
00124             const tString & iText, const tString::size_type iSPos = 0,
00125             const tString::size_type iMaxSize = 0 ) const;
00126 
00127         const tFloat calcGlyphHeight( const tGuiPos &iSize ) const;
00128 
00129         void prop( const tString &iName, const cDynVar &iVal );
00130         const cDynVar prop( const tString &iName ) const;
00131 
00132     private:
00133         tBool       mColourInherit;
00134         tGuiColour  mColour;
00135         tFloat      mFontHeight;
00136         cAutoPtr<const cFontInterface> mFont;
00137 
00138         tAlign      mAlign;
00139         tVAlign     mVAlign;
00140         tClipping   mClipping;
00141 
00142 
00145         void commonDraw( const tGuiPos &iPos, const tGuiPos &iSize,
00146             const tString &iText, const tString::size_type iSPos,
00147             const tString::size_type iMaxSize,
00148             tString::size_type & oCharactersDrawn, tGuiPos & oFinalPos,
00149             tFloat & oGlyphHeight, tString::size_type & oSPos,
00150             tString::size_type & oCEndPos ) const;
00151 
00152         void alignInBounds( const tAlign iAlign ) const;
00153         void vAlignInBounds( const tVAlign iVAlign ) const;
00154         void clippingInBounds( const tClipping iClipping ) const;
00155 
00156     }; // class 
00157 
00158 } // namespace n2l
00159 
00160 #endif
©2012 Aaron Cameron