Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

BitmapText.h

Go to the documentation of this file.
00001 /* BitmapText - An actor that holds a Font and draws text to the screen. */ 00002 00003 #ifndef BITMAPTEXT_H 00004 #define BITMAPTEXT_H 00005 00006 #include "Actor.h" 00007 class RageTexture; 00008 00009 #define LUA_BitmapText_METHODS( T ) \ 00010 LUA_Actor_METHODS( T ) \ 00011 static int wrapwidthpixels( T* p, lua_State *L ) { p->SetWrapWidthPixels( IArg(1) ); return 0; } \ 00012 static int maxwidth( T* p, lua_State *L ) { p->SetMaxWidth( FArg(1) ); return 0; } \ 00013 00014 #define LUA_BitmapText_METHODS_MAP( T ) \ 00015 LUA_Actor_METHODS_MAP( T ) \ 00016 LUA_METHOD_MAP( T, wrapwidthpixels ) \ 00017 LUA_METHOD_MAP( T, maxwidth ) \ 00018 00019 00020 class Font; 00021 00022 class BitmapText : public Actor 00023 { 00024 public: 00025 BitmapText(); 00026 virtual ~BitmapText(); 00027 00028 00029 bool LoadFromFont( const CString& sFontName ); 00030 bool LoadFromTextureAndChars( const CString& sTexturePath, const CString& sChars ); 00031 void SetText( const CString& sText, const CString& sAlternateText = "", int iWrapWidthPixels = -1 ); 00032 void SetMaxWidth( float MaxWidth ); 00033 void SetWrapWidthPixels( int iWrapWidthPixels ); 00034 00035 void CropToWidth( int iWidthInSourcePixels ); 00036 00037 virtual bool EarlyAbortDraw(); 00038 virtual void DrawPrimitives(); 00039 00040 void TurnRainbowOn() { m_bRainbow = true; }; 00041 void TurnRainbowOff() { m_bRainbow = false; }; 00042 00043 void SetHorizAlign( HorizAlign ha ); 00044 void SetVertAlign( VertAlign va ); 00045 00046 void GetLines( vector<wstring> &wTextLines ) { wTextLines = m_wTextLines; } 00047 00048 CString GetText() const { return m_sText; } 00049 /* Return true if the string 's' will use an alternate string, if available. */ 00050 bool StringWillUseAlternate(const CString& sText, const CString& sAlternateText) const; 00051 00052 // 00053 // Commands 00054 // 00055 virtual void PushSelf( lua_State *L ); 00056 00057 public: 00058 Font* m_pFont; 00059 00060 protected: 00061 00062 // recalculate the items below on SetText() 00063 CString m_sText; 00064 vector<wstring> m_wTextLines; 00065 vector<int> m_iLineWidths; // in source pixels 00066 int m_iWrapWidthPixels; // -1 = no wrap 00067 float m_fMaxWidth; 00068 00069 bool m_bRainbow; 00070 00071 vector<RageSpriteVertex> verts; 00072 vector<RageTexture *> tex; 00073 00074 void BuildChars(); 00075 void DrawChars(); 00076 void UpdateBaseZoom(); 00077 }; 00078 00079 00080 #endif 00081 00082 /* 00083 * (c) 2001-2004 Chris Danford 00084 * All rights reserved. 00085 * 00086 * Permission is hereby granted, free of charge, to any person obtaining a 00087 * copy of this software and associated documentation files (the 00088 * "Software"), to deal in the Software without restriction, including 00089 * without limitation the rights to use, copy, modify, merge, publish, 00090 * distribute, and/or sell copies of the Software, and to permit persons to 00091 * whom the Software is furnished to do so, provided that the above 00092 * copyright notice(s) and this permission notice appear in all copies of 00093 * the Software and that both the above copyright notice(s) and this 00094 * permission notice appear in supporting documentation. 00095 * 00096 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00097 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00098 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00099 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00100 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00101 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00102 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00103 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00104 * PERFORMANCE OF THIS SOFTWARE. 00105 */

Generated on Thu Jan 27 20:57:18 2005 for StepMania by doxygen 1.3.7