openshot-audio  0.1.4
juce_AttributedString.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_ATTRIBUTEDSTRING_H_INCLUDED
26 #define JUCE_ATTRIBUTEDSTRING_H_INCLUDED
27 
28 
29 //==============================================================================
40 {
41 public:
44 
46  explicit AttributedString (const String& text);
47 
49  AttributedString& operator= (const AttributedString&);
50  #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
53  #endif
54 
57 
58  //==============================================================================
60  const String& getText() const noexcept { return text; }
61 
66  void setText (const String& newText);
67 
69  void append (const String& textToAppend);
71  void append (const String& textToAppend, const Font& font);
73  void append (const String& textToAppend, Colour colour);
75  void append (const String& textToAppend, const Font& font, Colour colour);
76 
81  void append (const AttributedString& other);
82 
87  void clear();
88 
89  //==============================================================================
94  void draw (Graphics& g, const Rectangle<float>& area) const;
95 
96  //==============================================================================
100  Justification getJustification() const noexcept { return justification; }
101 
105  void setJustification (Justification newJustification) noexcept;
106 
107  //==============================================================================
111  enum WordWrap
112  {
116  };
117 
119  WordWrap getWordWrap() const noexcept { return wordWrap; }
120 
122  void setWordWrap (WordWrap newWordWrap) noexcept;
123 
124  //==============================================================================
129  {
133  };
134 
136  ReadingDirection getReadingDirection() const noexcept { return readingDirection; }
137 
139  void setReadingDirection (ReadingDirection newReadingDirection) noexcept;
140 
141  //==============================================================================
143  float getLineSpacing() const noexcept { return lineSpacing; }
144 
146  void setLineSpacing (float newLineSpacing) noexcept;
147 
148  //==============================================================================
151  {
152  public:
156  Attribute (Range<int> range, Colour colour);
157 
161  Attribute (Range<int> range, const Font& font);
162 
163  Attribute (const Attribute&);
164  ~Attribute();
165 
167  const Font* getFont() const noexcept { return font; }
168 
170  const Colour* getColour() const noexcept { return colour; }
171 
174 
175  private:
176  ScopedPointer<Font> font;
177  ScopedPointer<Colour> colour;
178 
179  friend class AttributedString;
180  Attribute (const Attribute&, int);
181  Attribute& operator= (const Attribute&);
182 
184  };
185 
187  int getNumAttributes() const noexcept { return attributes.size(); }
188 
192  const Attribute* getAttribute (int index) const noexcept { return attributes.getUnchecked (index); }
193 
194  //==============================================================================
196  void setColour (Range<int> range, Colour colour);
197 
199  void setColour (Colour colour);
200 
202  void setFont (Range<int> range, const Font& font);
203 
205  void setFont (const Font& font);
206 
207 private:
208  String text;
209  float lineSpacing;
210  Justification justification;
211  WordWrap wordWrap;
212  ReadingDirection readingDirection;
213  OwnedArray<Attribute> attributes;
214 
216 };
217 
218 #endif // JUCE_ATTRIBUTEDSTRING_H_INCLUDED
Definition: juce_AttributedString.h:131
Definition: juce_Font.h:39
#define noexcept
Definition: juce_CompilerSupport.h:141
const String & getText() const noexcept
Definition: juce_AttributedString.h:60
Definition: juce_Range.h:44
Definition: juce_AttributedString.h:130
const Font * getFont() const noexcept
Definition: juce_AttributedString.h:167
Definition: juce_Justification.h:38
Definition: juce_AttributedString.h:113
Definition: juce_AttributedString.h:115
Definition: juce_String.h:43
Justification getJustification() const noexcept
Definition: juce_AttributedString.h:100
void setColour(Range< int > range, Colour colour)
Definition: juce_AttributedString.cpp:193
Definition: juce_AttributedString.h:150
int getNumAttributes() const noexcept
Definition: juce_AttributedString.h:187
#define JUCE_API
Definition: juce_StandardHeader.h:139
const Colour * getColour() const noexcept
Definition: juce_AttributedString.h:170
float getLineSpacing() const noexcept
Definition: juce_AttributedString.h:143
void setFont(Range< int > range, const Font &font)
Definition: juce_AttributedString.cpp:207
WordWrap
Definition: juce_AttributedString.h:111
Definition: juce_Rectangle.h:36
WordWrap getWordWrap() const noexcept
Definition: juce_AttributedString.h:119
Definition: juce_Colour.h:35
ReadingDirection getReadingDirection() const noexcept
Definition: juce_AttributedString.h:136
const Attribute * getAttribute(int index) const noexcept
Definition: juce_AttributedString.h:192
AttributedString & operator=(const AttributedString &)
Definition: juce_AttributedString.cpp:79
Definition: juce_AttributedString.h:132
Definition: juce_AttributedString.h:39
Definition: juce_OwnedArray.h:55
Definition: juce_GraphicsContext.h:42
Definition: juce_AttributedString.h:114
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
ReadingDirection
Definition: juce_AttributedString.h:128
const Range< int > range
Definition: juce_AttributedString.h:173