From 8d75d080e27f0ea48ca58f55f5d8e950c7d8deaf Mon Sep 17 00:00:00 2001 From: tim Date: Tue, 28 Mar 2017 23:04:46 +0100 Subject: include altered ofxTestBlock --- menuApp/src/ofxTextBlock.h | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 menuApp/src/ofxTextBlock.h (limited to 'menuApp/src/ofxTextBlock.h') diff --git a/menuApp/src/ofxTextBlock.h b/menuApp/src/ofxTextBlock.h new file mode 100644 index 0000000..7455c70 --- /dev/null +++ b/menuApp/src/ofxTextBlock.h @@ -0,0 +1,96 @@ + /*********************************************************************** + + Copyright (c) 2009, Luke Malcolm, www.lukemalcolm.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + ***********************************************************************/ + +#ifndef OFXTEXTBLOCK_H +#define OFXTEXTBLOCK_H + +#include "ofMain.h" +#include + +class wordBlock { + public: + string rawWord; + float width; + float height; + ofColor color; + +}; + + +class lineBlock { + public: + vector wordsID; + + float width; + float height; + +}; + +//Just a helpful set of enumerated constants. +enum TextBlockAlignment { OF_TEXT_ALIGN_LEFT, OF_TEXT_ALIGN_RIGHT, OF_TEXT_ALIGN_JUSTIFIED, OF_TEXT_ALIGN_CENTER }; + +class ofxTextBlock +{ + public: + ofxTextBlock(); + virtual ~ofxTextBlock(); + + string rawText; + ofTrueTypeFont defaultFont; + wordBlock blankSpaceWord; + float scale; + + vector words; + vector lines; + + void init(string fontLocation, float fontSize,const char spacechar='x'); + + void setText(string _inputText); + + int wrapTextX(float lineWidth); //Returns the number of lines it formed. + void wrapTextArea(float rWidth, float rHeight); + bool wrapTextForceLines(int linesN); + + void setLineHeight(float lineHeight); + void setColor(int r, int g, int b, int a); + + void draw(float x, float y); //Draws left align. + void drawLeft(float x, float y, int numlines=9999); + void drawRight(float x, float y, int numlines=9999); + void drawCenter(float x, float y, int numlines=9999); + void drawJustified(float x, float y, float boxWidth, int numlines=9999); + + + void forceScale(float _scale); + + float getWidth(); + float getHeight(); + + protected: + + void _loadWords(); + + void _trimLineSpaces(); + float _getWidthOfWords(); + int _getLinedWords(); + + private: +}; + +#endif // OFXTEXTBLOCK_H -- cgit v1.2.3