openshot-audio  0.1.2
juce_TextLayout.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_TEXTLAYOUT_H_INCLUDED
26 #define JUCE_TEXTLAYOUT_H_INCLUDED
27 
28 
29 //==============================================================================
39 {
40 public:
45  TextLayout();
46  TextLayout (const TextLayout&);
47  TextLayout& operator= (const TextLayout&);
48  #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
50  TextLayout& operator= (TextLayout&&) noexcept;
51  #endif
52 
54  ~TextLayout();
55 
56  //==============================================================================
60  void createLayout (const AttributedString&, float maxWidth);
61 
65  void createLayout (const AttributedString&, float maxWidth, float maxHeight);
66 
73  void createLayoutWithBalancedLineLengths (const AttributedString&, float maxWidth);
74 
81  void createLayoutWithBalancedLineLengths (const AttributedString&, float maxWidth, float maxHeight);
82 
87  void draw (Graphics&, const Rectangle<float>& area) const;
88 
89  //==============================================================================
92  {
93  public:
94  Glyph (int glyphCode, Point<float> anchor, float width) noexcept;
95  Glyph (const Glyph&) noexcept;
96  Glyph& operator= (const Glyph&) noexcept;
97  ~Glyph() noexcept;
98 
101 
106 
107  float width;
108 
109  private:
111  };
112 
113  //==============================================================================
115  class JUCE_API Run
116  {
117  public:
118  Run() noexcept;
119  Run (const Run&);
120  Run (Range<int> stringRange, int numGlyphsToPreallocate);
121  ~Run() noexcept;
122 
128  private:
129  Run& operator= (const Run&);
131  };
132 
133  //==============================================================================
136  {
137  public:
138  Line() noexcept;
139  Line (const Line&);
140  Line (Range<int> stringRange, Point<float> lineOrigin,
141  float ascent, float descent, float leading, int numRunsToPreallocate);
142  ~Line() noexcept;
143 
145  Range<float> getLineBoundsX() const noexcept;
146 
148  Range<float> getLineBoundsY() const noexcept;
149 
151  Rectangle<float> getLineBounds() const noexcept;
152 
157  float ascent, descent, leading;
158 
159  private:
160  Line& operator= (const Line&);
162  };
163 
164  //==============================================================================
166  float getWidth() const noexcept { return width; }
167 
169  float getHeight() const noexcept { return height; }
170 
172  int getNumLines() const noexcept { return lines.size(); }
173 
175  Line& getLine (int index) const;
176 
179  void addLine (Line*);
180 
182  void ensureStorageAllocated (int numLinesNeeded);
183 
184 private:
185  OwnedArray<Line> lines;
186  float width, height;
187  Justification justification;
188 
189  void createStandardLayout (const AttributedString&);
190  bool createNativeLayout (const AttributedString&);
191  void recalculateSize (const AttributedString&);
192 
194 };
195 
196 #endif // JUCE_TEXTLAYOUT_H_INCLUDED
OwnedArray< Run > runs
Definition: juce_TextLayout.h:153
Range< int > stringRange
Definition: juce_TextLayout.h:126
Array< Glyph > glyphs
Definition: juce_TextLayout.h:125
Definition: juce_Font.h:39
#define noexcept
Definition: juce_CompilerSupport.h:141
Font font
Definition: juce_TextLayout.h:123
int glyphCode
Definition: juce_TextLayout.h:100
float getWidth() const noexcept
Definition: juce_TextLayout.h:166
float width
Definition: juce_TextLayout.h:107
Definition: juce_Range.h:44
Definition: juce_Justification.h:38
Definition: juce_TextLayout.h:135
Definition: juce_TextLayout.h:38
Definition: juce_Point.h:39
Range< int > stringRange
Definition: juce_TextLayout.h:154
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
Definition: juce_Rectangle.h:36
Point< float > lineOrigin
Definition: juce_TextLayout.h:156
Definition: juce_Colour.h:35
Colour colour
Definition: juce_TextLayout.h:124
Definition: juce_AttributedString.h:39
Definition: juce_TextLayout.h:115
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: juce_PNGLoader.cpp:2339
float leading
Definition: juce_TextLayout.h:157
Definition: juce_Array.h:60
Point< float > anchor
Definition: juce_TextLayout.h:105
Definition: juce_OwnedArray.h:55
Definition: juce_GraphicsContext.h:42
float getHeight() const noexcept
Definition: juce_TextLayout.h:169
Definition: juce_TextLayout.h:91
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
int getNumLines() const noexcept
Definition: juce_TextLayout.h:172