add SetTextMaxWidth
This commit is contained in:
@@ -241,6 +241,19 @@ void BitmapText::SetText( CString sText, CString sAlternateText )
|
|||||||
BuildChars();
|
BuildChars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BitmapText::SetTextMaxWidth( float MaxWidth, const CString &text, const CString &alttext )
|
||||||
|
{
|
||||||
|
this->SetText(text, alttext);
|
||||||
|
|
||||||
|
/* Avoid division by zero. */
|
||||||
|
const int Width = GetWidestLineWidthInSourcePixels()+1;
|
||||||
|
|
||||||
|
/* Never decrease the zoom. Important: make sure you reset zoom before
|
||||||
|
* changing text with this function. */
|
||||||
|
const float Zoom = min( GetZoom(), MaxWidth/Width );
|
||||||
|
this->SetZoomX( Zoom );
|
||||||
|
}
|
||||||
|
|
||||||
bool BitmapText::StringWillUseAlternate(CString sText, CString sAlternateText) const
|
bool BitmapText::StringWillUseAlternate(CString sText, CString sAlternateText) const
|
||||||
{
|
{
|
||||||
ASSERT( m_pFont );
|
ASSERT( m_pFont );
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
bool LoadFromNumbers( CString sTexturePath ) { return LoadFromTextureAndChars(sTexturePath,"0123456789%. :x"); };
|
bool LoadFromNumbers( CString sTexturePath ) { return LoadFromTextureAndChars(sTexturePath,"0123456789%. :x"); };
|
||||||
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
|
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
|
||||||
void SetText( CString sText, CString sAlternateText = "" );
|
void SetText( CString sText, CString sAlternateText = "" );
|
||||||
|
void SetTextMaxWidth( float MaxWidth, const CString &text, const CString &alttext = "" );
|
||||||
|
|
||||||
int GetWidestLineWidthInSourcePixels() { return m_iWidestLineWidth; };
|
int GetWidestLineWidthInSourcePixels() { return m_iWidestLineWidth; };
|
||||||
void CropToWidth( int iWidthInSourcePixels );
|
void CropToWidth( int iWidthInSourcePixels );
|
||||||
|
|||||||
Reference in New Issue
Block a user