MMSTextBoxWidget Class Reference

With this class you can display text with more than one line. More...

#include <mmstextboxwidget.h>

Inheritance diagram for MMSTextBoxWidget:

List of all members.


Public Member Functions

 MMSTextBoxWidget (MMSWindow *root, string className, MMSTheme *theme=NULL)
 ~MMSTextBoxWidget ()
MMSWidgetcopyWidget ()
bool reloadFile ()
 reload the file and display it in the textbox
string getFontPath ()
string getFontName (MMSLanguage lang=MMSLANG_NONE)
unsigned int getFontSize ()
MMSALIGNMENT getAlignment ()
bool getWrap ()
bool getSplitWords ()
MMSFBColor getColor ()
MMSFBColor getSelColor ()
MMSFBColor getColor_p ()
MMSFBColor getSelColor_p ()
MMSFBColor getColor_i ()
MMSFBColor getSelColor_i ()
string getText ()
void getText (string &text)
bool getTranslate ()
string getFilePath ()
string getFileName ()
MMSFBColor getShadowColor (MMSPOSITION position)
MMSFBColor getSelShadowColor (MMSPOSITION position)
void setFontPath (string fontpath, bool load=true, bool refresh=true)
void setFontName (MMSLanguage lang, string fontname, bool load=true, bool refresh=true)
void setFontName (string fontname, bool load=true, bool refresh=true)
void setFontSize (unsigned int fontsize, bool load=true, bool refresh=true)
void setFont (MMSLanguage lang, string fontpath, string fontname, unsigned int fontsize, bool load=true, bool refresh=true)
void setFont (string fontpath, string fontname, unsigned int fontsize, bool load=true, bool refresh=true)
void setAlignment (MMSALIGNMENT alignment, bool refresh=true)
void setWrap (bool wrap, bool refresh=true)
void setSplitWords (bool splitwords, bool refresh=true)
void setColor (MMSFBColor color, bool refresh=true)
void setSelColor (MMSFBColor selcolor, bool refresh=true)
void setColor_p (MMSFBColor color_p, bool refresh=true)
void setSelColor_p (MMSFBColor selcolor_p, bool refresh=true)
void setColor_i (MMSFBColor color_i, bool refresh=true)
void setSelColor_i (MMSFBColor selcolor_i, bool refresh=true)
void setText (string *text, bool refresh=true)
void setText (string text, bool refresh=true)
void setTranslate (bool translate, bool refresh=true)
void setFilePath (string filepath, bool load=true, bool refresh=true)
void setFileName (string filename, bool load=true, bool refresh=true)
void setShadowColor (MMSPOSITION position, MMSFBColor color, bool refresh=true)
void setSelShadowColor (MMSPOSITION position, MMSFBColor selcolor, bool refresh=true)
void updateFromThemeClass (MMSTextBoxWidgetClass *themeClass)

Private Member Functions

bool create (MMSWindow *root, string className, MMSTheme *theme)
void initLanguage (MMSTextBoxWidget *widget=NULL)
void loadFont (MMSTextBoxWidget *widget=NULL)
bool setSurfaceGeometry (unsigned int width=0, unsigned int height=0)
bool calcWordGeom (string &text, unsigned int startWidth, unsigned int startHeight, unsigned int *realWidth, unsigned int *realHeight, unsigned int *scrollDX, unsigned int *scrollDY, unsigned int *lines, unsigned int *paragraphs, bool wrap=true, bool splitwords=true, MMSALIGNMENT alignment=MMSALIGNMENT_CENTER, unsigned int *minWidth=NULL, unsigned int *minHeight=NULL, bool force_recalc=false)
bool init ()
bool release ()
bool prepareText (int *width, int *height, bool recalc=false)
void calcContentSize ()
 Internal method: Should be overridden by widgets which have a dynamic size based on content.
void getForeground (MMSFBColor *color)
bool enableRefresh (bool enable=true)
 Internal method: (re-)enable refresh status.
bool checkRefreshStatus ()
 Internal method: check drawn background against new background and (re-)enable refresh status if needed.
bool draw (bool *backgroundFilled=NULL)
void targetLangChanged (MMSLanguage lang)
 Internal method: Inform the widget, that the language has changed.
bool loadFile (bool refresh)

Private Attributes

string className
MMSTextBoxWidgetClasstextBoxWidgetClass
MMSTextBoxWidgetClass myTextBoxWidgetClass
MMSLanguage lang
 language in which the text is to be translated
MMSFBFontfont
 loaded font
string fontpath
 path to the loaded font file
string fontname
 name of the loaded font file
unsigned int fontsize
 requested size of the font
bool load_font
 have to (re)load font?
vector< TEXTBOX_WORDGEOM * > wordgeom
string lasttext
bool surfaceChanged
string translated_text
 the translated text will be stored here, this is used in the draw() method
bool translated
 if true the translated_text is valid
bool swap_left_right
 swap left-right alignment
MMSFilefile
 used to load text from a file
bool current_fgset
 current foreground values set?
MMSFBColor current_fgcolor
 current foreground color

Friends

class MMSWindow

Classes

struct  TEXTBOX_WORDGEOM

Detailed Description

With this class you can display text with more than one line.

The textbox is focusable. So the user can scroll in it. Line breaks will be done with the normal line feed (
(0x0a)). Specify &#10; as line feed within XML. If you want to display only one line of static text, you should use the MMSLabel widget.

Author:
Jens Schneider

Definition at line 46 of file mmstextboxwidget.h.


Constructor & Destructor Documentation

MMSTextBoxWidget::MMSTextBoxWidget ( MMSWindow root,
string  className,
MMSTheme theme = NULL 
)

Definition at line 37 of file mmstextboxwidget.cpp.

MMSTextBoxWidget::~MMSTextBoxWidget (  ) 

Definition at line 41 of file mmstextboxwidget.cpp.


Member Function Documentation

bool MMSTextBoxWidget::create ( MMSWindow root,
string  className,
MMSTheme theme 
) [private]

Definition at line 50 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::initLanguage ( MMSTextBoxWidget widget = NULL  )  [private]

Definition at line 120 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::loadFont ( MMSTextBoxWidget widget = NULL  )  [private]

Definition at line 126 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::setSurfaceGeometry ( unsigned int  width = 0,
unsigned int  height = 0 
) [private, virtual]

Reimplemented from MMSWidget.

Definition at line 146 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::calcWordGeom ( string &  text,
unsigned int  startWidth,
unsigned int  startHeight,
unsigned int *  realWidth,
unsigned int *  realHeight,
unsigned int *  scrollDX,
unsigned int *  scrollDY,
unsigned int *  lines,
unsigned int *  paragraphs,
bool  wrap = true,
bool  splitwords = true,
MMSALIGNMENT  alignment = MMSALIGNMENT_CENTER,
unsigned int *  minWidth = NULL,
unsigned int *  minHeight = NULL,
bool  force_recalc = false 
) [private]

Definition at line 161 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::init (  )  [private, virtual]

Reimplemented from MMSWidget.

Definition at line 473 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::release (  )  [private, virtual]

Reimplemented from MMSWidget.

Definition at line 490 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::prepareText ( int *  width,
int *  height,
bool  recalc = false 
) [private]

Definition at line 507 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::calcContentSize (  )  [private, virtual]

Internal method: Should be overridden by widgets which have a dynamic size based on content.

Reimplemented from MMSWidget.

Definition at line 641 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::getForeground ( MMSFBColor color  )  [private]

Definition at line 651 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::enableRefresh ( bool  enable = true  )  [private, virtual]

Internal method: (re-)enable refresh status.

Reimplemented from MMSWidget.

Definition at line 683 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::checkRefreshStatus (  )  [private, virtual]

Internal method: check drawn background against new background and (re-)enable refresh status if needed.

Reimplemented from MMSWidget.

Definition at line 692 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::draw ( bool *  backgroundFilled = NULL  )  [private, virtual]

Reimplemented from MMSWidget.

Definition at line 713 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::targetLangChanged ( MMSLanguage  lang  )  [private]

Internal method: Inform the widget, that the language has changed.

Definition at line 790 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::loadFile ( bool  refresh  )  [private]

Definition at line 800 of file mmstextboxwidget.cpp.

MMSWidget * MMSTextBoxWidget::copyWidget (  )  [virtual]

Implements MMSWidget.

Definition at line 78 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::reloadFile (  ) 

reload the file and display it in the textbox

Definition at line 837 of file mmstextboxwidget.cpp.

string MMSTextBoxWidget::getFontPath (  ) 

Definition at line 873 of file mmstextboxwidget.cpp.

string MMSTextBoxWidget::getFontName ( MMSLanguage  lang = MMSLANG_NONE  ) 

Definition at line 877 of file mmstextboxwidget.cpp.

unsigned int MMSTextBoxWidget::getFontSize (  ) 

Definition at line 881 of file mmstextboxwidget.cpp.

MMSALIGNMENT MMSTextBoxWidget::getAlignment (  ) 

Definition at line 885 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::getWrap (  ) 

Definition at line 889 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::getSplitWords (  ) 

Definition at line 893 of file mmstextboxwidget.cpp.

MMSFBColor MMSTextBoxWidget::getColor (  ) 

Definition at line 897 of file mmstextboxwidget.cpp.

MMSFBColor MMSTextBoxWidget::getSelColor (  ) 

Definition at line 901 of file mmstextboxwidget.cpp.

MMSFBColor MMSTextBoxWidget::getColor_p (  ) 

Definition at line 905 of file mmstextboxwidget.cpp.

MMSFBColor MMSTextBoxWidget::getSelColor_p (  ) 

Definition at line 909 of file mmstextboxwidget.cpp.

MMSFBColor MMSTextBoxWidget::getColor_i (  ) 

Definition at line 913 of file mmstextboxwidget.cpp.

MMSFBColor MMSTextBoxWidget::getSelColor_i (  ) 

Definition at line 917 of file mmstextboxwidget.cpp.

string MMSTextBoxWidget::getText (  ) 

Definition at line 921 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::getText ( string &  text  ) 

Definition at line 925 of file mmstextboxwidget.cpp.

bool MMSTextBoxWidget::getTranslate (  ) 

Definition at line 929 of file mmstextboxwidget.cpp.

string MMSTextBoxWidget::getFilePath (  ) 

Definition at line 933 of file mmstextboxwidget.cpp.

string MMSTextBoxWidget::getFileName (  ) 

Definition at line 937 of file mmstextboxwidget.cpp.

MMSFBColor MMSTextBoxWidget::getShadowColor ( MMSPOSITION  position  ) 

Definition at line 941 of file mmstextboxwidget.cpp.

MMSFBColor MMSTextBoxWidget::getSelShadowColor ( MMSPOSITION  position  ) 

Definition at line 945 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setFontPath ( string  fontpath,
bool  load = true,
bool  refresh = true 
)

Definition at line 953 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setFontName ( MMSLanguage  lang,
string  fontname,
bool  load = true,
bool  refresh = true 
)

Definition at line 966 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setFontName ( string  fontname,
bool  load = true,
bool  refresh = true 
)

Definition at line 979 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setFontSize ( unsigned int  fontsize,
bool  load = true,
bool  refresh = true 
)

Definition at line 983 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setFont ( MMSLanguage  lang,
string  fontpath,
string  fontname,
unsigned int  fontsize,
bool  load = true,
bool  refresh = true 
)

Definition at line 996 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setFont ( string  fontpath,
string  fontname,
unsigned int  fontsize,
bool  load = true,
bool  refresh = true 
)

Definition at line 1011 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setAlignment ( MMSALIGNMENT  alignment,
bool  refresh = true 
)

Definition at line 1015 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setWrap ( bool  wrap,
bool  refresh = true 
)

Definition at line 1024 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setSplitWords ( bool  splitwords,
bool  refresh = true 
)

Definition at line 1033 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setColor ( MMSFBColor  color,
bool  refresh = true 
)

Definition at line 1042 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setSelColor ( MMSFBColor  selcolor,
bool  refresh = true 
)

Definition at line 1051 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setColor_p ( MMSFBColor  color_p,
bool  refresh = true 
)

Definition at line 1060 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setSelColor_p ( MMSFBColor  selcolor_p,
bool  refresh = true 
)

Definition at line 1069 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setColor_i ( MMSFBColor  color_i,
bool  refresh = true 
)

Definition at line 1078 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setSelColor_i ( MMSFBColor  selcolor_i,
bool  refresh = true 
)

Definition at line 1087 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setText ( string *  text,
bool  refresh = true 
)

Definition at line 1097 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setText ( string  text,
bool  refresh = true 
)

Definition at line 1109 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setTranslate ( bool  translate,
bool  refresh = true 
)

Definition at line 1113 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setFilePath ( string  filepath,
bool  load = true,
bool  refresh = true 
)

Definition at line 1123 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setFileName ( string  filename,
bool  load = true,
bool  refresh = true 
)

Definition at line 1134 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setShadowColor ( MMSPOSITION  position,
MMSFBColor  color,
bool  refresh = true 
)

Definition at line 1145 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::setSelShadowColor ( MMSPOSITION  position,
MMSFBColor  selcolor,
bool  refresh = true 
)

Definition at line 1154 of file mmstextboxwidget.cpp.

void MMSTextBoxWidget::updateFromThemeClass ( MMSTextBoxWidgetClass themeClass  ) 

Definition at line 1164 of file mmstextboxwidget.cpp.


Friends And Related Function Documentation

friend class MMSWindow [friend]

Reimplemented from MMSWidget.

Definition at line 188 of file mmstextboxwidget.h.


Member Data Documentation

string MMSTextBoxWidget::className [private]

Definition at line 55 of file mmstextboxwidget.h.

language in which the text is to be translated

Definition at line 60 of file mmstextboxwidget.h.

loaded font

Definition at line 63 of file mmstextboxwidget.h.

string MMSTextBoxWidget::fontpath [private]

path to the loaded font file

Definition at line 66 of file mmstextboxwidget.h.

string MMSTextBoxWidget::fontname [private]

name of the loaded font file

Definition at line 69 of file mmstextboxwidget.h.

unsigned int MMSTextBoxWidget::fontsize [private]

requested size of the font

Definition at line 72 of file mmstextboxwidget.h.

have to (re)load font?

Definition at line 75 of file mmstextboxwidget.h.

Definition at line 78 of file mmstextboxwidget.h.

string MMSTextBoxWidget::lasttext [private]

Definition at line 80 of file mmstextboxwidget.h.

Definition at line 81 of file mmstextboxwidget.h.

the translated text will be stored here, this is used in the draw() method

Definition at line 84 of file mmstextboxwidget.h.

if true the translated_text is valid

Definition at line 87 of file mmstextboxwidget.h.

swap left-right alignment

Definition at line 90 of file mmstextboxwidget.h.

used to load text from a file

Definition at line 93 of file mmstextboxwidget.h.

current foreground values set?

Definition at line 96 of file mmstextboxwidget.h.

current foreground color

Definition at line 99 of file mmstextboxwidget.h.


The documentation for this class was generated from the following files: