Public Member Functions | |
| mxRegularFont () | |
| mxRegularFont (const mxRegularFont &font) | |
| mxRegularFont & | operator= (const mxRegularFont &font) |
| void | setFont (const mxRegularFont &font) |
| bool | loadFont (std::string font_name) |
| void | freeFont () |
| SDL_Font * | getFont () |
| SDL_Font * | operator* () |
| void | printText (mxSurface &surface, unsigned int x, unsigned int y, unsigned int color, std::string text) |
| void | printText (mxSurface &surface, Point p, Color color, std::string text) |
| void | printSizedText (mxSurface &surface, unsigned int x, unsigned int y, unsigned int size_w, unsigned int size_h, unsigned int color, std::string text) |
| int | printTextWidth_64 (int *depth, mxSurface &surface, int x, int y, int size_width, unsigned int color, const char *src) |
| int | printTextDepth (mxSurface &surface, unsigned int x, unsigned int y, unsigned int color, std::string text) |
Protected Attributes | |
| struct SDL_Font * | font |
Definition at line 30 of file mx_font.h.
| mx::mxRegularFont::mxRegularFont | ( | ) |
default constructor
Definition at line 21 of file mx_font.cpp.
References font.
00022 { 00023 font = 0; 00024 }
| mx::mxRegularFont::mxRegularFont | ( | const mxRegularFont & | font | ) |
copy constructor
| font | parameter to copy from |
Definition at line 28 of file mx_font.cpp.
References setFont().
00029 { 00030 setFont(fontX); 00031 00032 }
| void mx::mxRegularFont::freeFont | ( | ) |
| SDL_Font* mx::mxRegularFont::getFont | ( | ) | [inline] |
| bool mx::mxRegularFont::loadFont | ( | std::string | font_name | ) |
load font from string on disk
| font_name | the name of the mxFont in std::string form. |
Definition at line 47 of file mx_font.cpp.
References font.
00048 { 00049 font = SDL_InitFont(font_name.c_str()); 00050 if(font == 0) 00051 throw mx::mxException<std::string>(" could not load font: " + font_name + "\n"); 00052 return true; 00053 }
| SDL_Font* mx::mxRegularFont::operator* | ( | ) | [inline] |
| mxRegularFont & mx::mxRegularFont::operator= | ( | const mxRegularFont & | font | ) |
overloaded operator = for assigning another font
| font | font to assign from |
Definition at line 34 of file mx_font.cpp.
References setFont().
00035 { 00036 setFont(fontX); 00037 return *this; 00038 }
| void mx::mxRegularFont::printSizedText | ( | mxSurface & | surface, | |
| unsigned int | x, | |||
| unsigned int | y, | |||
| unsigned int | size_w, | |||
| unsigned int | size_h, | |||
| unsigned int | color, | |||
| std::string | text | |||
| ) |
printSizedText - print text stretched to a specific size
| surface | to print to | |
| x | x coordinate | |
| y | y coordinate | |
| size_w | width in pixels | |
| size_h | height in pixels | |
| color | 32bit RGBA value | |
| text | string value |
Definition at line 70 of file mx_font.cpp.
References font, and mx::mxSurface::getSurface().
00071 { 00072 if(font == 0) return; 00073 SDL_PrintTextScaled(surface.getSurface(), font, x,y,w,h,color,text.c_str()); 00074 }
| void mx::mxRegularFont::printText | ( | mxSurface & | surface, | |
| Point | p, | |||
| Color | color, | |||
| std::string | text | |||
| ) | [inline] |
printText overloaded method
| surface | to print string to | |
| p | Point object 2d coordinate | |
| color | Color object | |
| text | text to print to surface |
Definition at line 84 of file mx_font.h.
References mx::Color::mapRGB(), printText(), mx::Point::x, and mx::Point::y.
00084 { 00085 printText(surface, p.x, p.y, Color::mapRGB(surface, color), text); 00086 }
| void mx::mxRegularFont::printText | ( | mxSurface & | surface, | |
| unsigned int | x, | |||
| unsigned int | y, | |||
| unsigned int | color, | |||
| std::string | text | |||
| ) |
printText
| surface | surface to print to | |
| x | x coordinate in pixels | |
| y | y coordinate in pixels | |
| color | color value in 32bit RGBA | |
| text | string to print to surface |
Definition at line 64 of file mx_font.cpp.
References font, and mx::mxSurface::getSurface().
Referenced by printText().
00065 { 00066 if(font == 0) return; 00067 SDL_PrintText(surface.getSurface(), font, x, y, color, text.c_str()); 00068 }
| int mx::mxRegularFont::printTextDepth | ( | mxSurface & | surface, | |
| unsigned int | x, | |||
| unsigned int | y, | |||
| unsigned int | color, | |||
| std::string | text | |||
| ) |
printTextDepth - print text with coordinate offset returned by the function
| surface | surface to draw to | |
| x | x coordinate | |
| y | y coordinate | |
| color | 32bit RGBA value | |
| text | string to draw to surface |
Definition at line 81 of file mx_font.cpp.
References font, and mx::mxSurface::getSurface().
00081 { 00082 int depth = 0; 00083 SDL_PrintTextDepth(&depth,surface.getSurface(), font, x, y, color, text.c_str()); 00084 return depth; 00085 }
| int mx::mxRegularFont::printTextWidth_64 | ( | int * | depth, | |
| mxSurface & | surface, | |||
| int | x, | |||
| int | y, | |||
| int | size_width, | |||
| unsigned int | color, | |||
| const char * | src | |||
| ) |
printTextWidth_64 - print text with coordinate offset returned in depth variable, used for getting the offset of console height in masterx project
| depth | pointer to integer to contain coordinate | |
| surface | surface to draw to | |
| x | x coordinate in pixels | |
| y | y coordinate in pixels | |
| size_width | width in pixels | |
| color | 32bit RGBA value | |
| src | text to print to screen |
Definition at line 76 of file mx_font.cpp.
References font, and mx::mxSurface::getSurface().
00076 { 00077 SDL_PrintTextWidth(depth, surface.getSurface(), font, x, y, width, color, src); 00078 return *depth; 00079 }
| void mx::mxRegularFont::setFont | ( | const mxRegularFont & | font | ) |
setFont set another font to this font, same as overloaded operator = but as a method
| font | takes a font to assign to this object |
Definition at line 40 of file mx_font.cpp.
References font, and freeFont().
Referenced by mxRegularFont(), and operator=().
struct SDL_Font* mx::mxRegularFont::font [read, protected] |
the SDL_Font structure to hold are font
Definition at line 122 of file mx_font.h.
Referenced by freeFont(), loadFont(), mxRegularFont(), printSizedText(), printText(), printTextDepth(), printTextWidth_64(), and setFont().
1.5.8