ofxOui - UI Components for OpenFrameworks

ofxOuiTextBox.hpp
Go to the documentation of this file.
1 /*
2  * ofxOuiTextBox.hpp
3  *
4  * Text Box (Wrapper around ofTrueTypeFont)
5  *
6  * This code has been authored by Jules Francoise <jfrancoi@sfu.ca>
7  * during his postdoc contract at Simon Fraser University (MovingStories
8  * project).
9  * See:
10  * http://julesfrancoise.com/
11  * http://movingstories.ca/
12  *
13  * Copyright (C) 2016 Jules Francoise.
14  *
15  * This Source Code Form is subject to the terms of the Mozilla Public
16  * License, v. 2.0. If a copy of the MPL was not distributed with this
17  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
18  */
19 
20 #ifndef ofxOuiText_hpp
21 #define ofxOuiText_hpp
22 
23 #include "ofxOuiCommon.hpp"
24 
25 namespace ofxOui {
26 
31 class TextBox {
32  public:
36  TextBox();
37 
41  virtual ~TextBox();
42 
46  virtual void update();
47 
51  virtual void draw();
52 
57  virtual string getFontPath() const;
58 
63  virtual void setFontPath(string path);
64 
69  virtual float getFontSize() const;
70 
75  virtual void setFontSize(float size);
76 
81  virtual float getLetterSpacing() const;
82 
87  virtual void setLetterSpacing(float letter_spacing);
88 
93  virtual float getLineHeight() const;
94 
99  virtual void setLineHeight(float line_height);
100 
107  virtual int getCharacterIndex(int x_, int y_) const;
108 
116  virtual int getCursorIndex(int x_, int y_) const;
117 
121  string text = "";
122 
126  int x = 0;
127 
131  int y = 0;
132 
136  int width = 100;
137 
141  int height = 100;
142 
146  int padding = 10;
147 
152 
156  ofColor color = ofColor::black;
157 
161  ofRectangle rect;
162 
163  protected:
164  virtual void adjustFont_();
165 
166  ofTrueTypeFont* base_Font_;
167  string font_path_;
168  float font_size_;
170  float letter_spacing_ = 1.;
171  int y_diff_;
172 };
173 }
174 
175 #endif
string font_path_
Definition: ofxOuiTextBox.hpp:167
virtual void adjustFont_()
Definition: ofxOuiTextBox.cpp:107
int y_diff_
Definition: ofxOuiTextBox.hpp:171
virtual void setFontSize(float size)
set the font size
Definition: ofxOuiTextBox.cpp:88
virtual float getLineHeight() const
get the line height
Definition: ofxOuiTextBox.cpp:100
virtual float getFontSize() const
get the font size
Definition: ofxOuiTextBox.cpp:86
float font_size_
Definition: ofxOuiTextBox.hpp:168
ofTrueTypeFont * base_Font_
Definition: ofxOuiTextBox.hpp:166
virtual float getLetterSpacing() const
get the letter spacing
Definition: ofxOuiTextBox.cpp:93
Anchor alignment
Alignment.
Definition: ofxOuiTextBox.hpp:151
Text box font wrapper.
Definition: ofxOuiTextBox.hpp:31
string text
label
Definition: ofxOuiTextBox.hpp:121
virtual void setLetterSpacing(float letter_spacing)
set the letter spacing
Definition: ofxOuiTextBox.cpp:95
virtual void update()
OF-like update function: updates the position of the icon.
Definition: ofxOuiTextBox.cpp:33
ofRectangle rect
Actual rectangle where the text is drawn.
Definition: ofxOuiTextBox.hpp:161
int height
height (of the containing box)
Definition: ofxOuiTextBox.hpp:141
virtual ~TextBox()
Destructor.
Definition: ofxOuiTextBox.cpp:31
Definition: ofxOuiColormap.hpp:25
int y
y position (of the containing box)
Definition: ofxOuiTextBox.hpp:131
virtual int getCharacterIndex(int x_, int y_) const
get the index of the character at a given mouse position
Definition: ofxOuiTextBox.cpp:112
TextBox()
Default Constructor.
Definition: ofxOuiTextBox.cpp:24
virtual int getCursorIndex(int x_, int y_) const
get the index of the cursor (inter-character) at a given mouse position
Definition: ofxOuiTextBox.cpp:126
Anchor
Generic Anchor specifier for Text/Image alignment.
Definition: ofxOuiCommon.hpp:57
virtual string getFontPath() const
get the path to the font path
Definition: ofxOuiTextBox.cpp:79
float line_height_
Definition: ofxOuiTextBox.hpp:169
int padding
padding (within the containing box)
Definition: ofxOuiTextBox.hpp:146
virtual void setFontPath(string path)
set the path to the font path
Definition: ofxOuiTextBox.cpp:81
virtual void draw()
OF-like draw function: draws the text box.
Definition: ofxOuiTextBox.cpp:73
virtual void setLineHeight(float line_height)
set the line height
Definition: ofxOuiTextBox.cpp:102
int width
width (of the containing box)
Definition: ofxOuiTextBox.hpp:136
int x
x position (of the containing box)
Definition: ofxOuiTextBox.hpp:126
ofColor color
Color (in case of a binary icon)
Definition: ofxOuiTextBox.hpp:156
float letter_spacing_
Definition: ofxOuiTextBox.hpp:170