summaryrefslogtreecommitdiff
path: root/menuApp/src/ofxTextBlock.h
diff options
context:
space:
mode:
authortim <tim@eclectronics.org>2017-03-28 23:04:46 +0100
committertim <tim@eclectronics.org>2017-03-28 23:04:46 +0100
commit8d75d080e27f0ea48ca58f55f5d8e950c7d8deaf (patch)
tree100e45720488fd6286964a2fad3e726d1d94f819 /menuApp/src/ofxTextBlock.h
parentd3aa7d233596c7d4dae649df90e1176ed6be2c68 (diff)
include altered ofxTestBlock
Diffstat (limited to 'menuApp/src/ofxTextBlock.h')
-rw-r--r--menuApp/src/ofxTextBlock.h96
1 files changed, 96 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
+
+ ***********************************************************************/
+
+#ifndef OFXTEXTBLOCK_H
+#define OFXTEXTBLOCK_H
+
+#include "ofMain.h"
+#include <iterator>
+
+class wordBlock {
+ public:
+ string rawWord;
+ float width;
+ float height;
+ ofColor color;
+
+};
+
+
+class lineBlock {
+ public:
+ vector<int> 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<wordBlock> words;
+ vector<lineBlock> 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