| Line | |
|---|
| 1 | /*! |
|---|
| 2 | * @file limited_width_text.h |
|---|
| 3 | * @brief Definition of a text Class, that is able to render text. |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | #ifndef _LIMITED_WIDTH_TEXT_H |
|---|
| 7 | #define _LIMITED_WIDTH_TEXT_H |
|---|
| 8 | |
|---|
| 9 | #include "text.h" |
|---|
| 10 | |
|---|
| 11 | #include <vector> |
|---|
| 12 | |
|---|
| 13 | //! Represents one textElement. |
|---|
| 14 | class LimitedWidthText : public Text |
|---|
| 15 | { |
|---|
| 16 | ObjectListDeclaration(LimitedWidthText); |
|---|
| 17 | public: |
|---|
| 18 | typedef enum { |
|---|
| 19 | Begin, |
|---|
| 20 | End, |
|---|
| 21 | } DotsPosition; |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | public: |
|---|
| 25 | LimitedWidthText(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE, float lineWidth = 100.0, DotsPosition dotsPosition = Begin); |
|---|
| 26 | |
|---|
| 27 | // Setup: |
|---|
| 28 | void setLineWidth(float lineWidth); |
|---|
| 29 | void setDotsPosition(LimitedWidthText::DotsPosition dotsPosition); |
|---|
| 30 | |
|---|
| 31 | // Retrieve: |
|---|
| 32 | /** @returns the LineWidth (maximum distance from the left to the right */ |
|---|
| 33 | inline float lineWidth() const { return this->_lineWidth; }; |
|---|
| 34 | /** @returns the dots position. */ |
|---|
| 35 | inline float dotsPosition() const { return this->_dotsPosition; }; |
|---|
| 36 | |
|---|
| 37 | virtual void draw() const; |
|---|
| 38 | |
|---|
| 39 | void debug() const; |
|---|
| 40 | |
|---|
| 41 | protected: |
|---|
| 42 | virtual void setupTextWidth(); |
|---|
| 43 | |
|---|
| 44 | private: |
|---|
| 45 | std::string _dotedText; |
|---|
| 46 | |
|---|
| 47 | DotsPosition _dotsPosition; |
|---|
| 48 | float _lineWidth; |
|---|
| 49 | unsigned int _lineEnds; |
|---|
| 50 | }; |
|---|
| 51 | |
|---|
| 52 | #endif /* _LIMITED_WIDTH_TEXT_H */ |
|---|
Note: See
TracBrowser
for help on using the repository browser.