1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: David Kabala (djkabala@gmail.com) *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSIMPLETEXTFOREGROUND_H_
40 #define _OSGSIMPLETEXTFOREGROUND_H_
45 #include "OSGSimpleTextForegroundBase.h"
46 #include "OSGTextureObjChunkFields.h"
47 #include "OSGTextureEnvChunkFields.h"
48 #include "OSGTextTXFFace.h"
52 /*! \brief SimpleTextForeground class. See \ref
53 PageUtilSimpleTextForeground for a description.
56 class OSG_WINDOW_DLLMAPPING SimpleTextForeground
:
57 public SimpleTextForegroundBase
62 /*========================== PUBLIC =================================*/
66 typedef SimpleTextForegroundBase Inherited
;
67 typedef SimpleTextForeground Self
;
69 /*---------------------------------------------------------------------*/
88 /*---------------------------------------------------------------------*/
92 virtual void changed(ConstFieldMaskArg whichField
,
97 /*---------------------------------------------------------------------*/
101 virtual void dump( UInt32 uiIndent
= 0,
102 const BitVector bvFlags
= 0) const;
105 /*---------------------------------------------------------------------*/
109 virtual void draw(DrawEnv
*pEnv
);
112 /*---------------------------------------------------------------------*/
113 /*! \name Convenience Functions */
116 void addLine(const std::string
&szText
);
120 /*========================= PROTECTED ===============================*/
124 // Variables should all be in SimpleTextForegroundBase.
126 /*---------------------------------------------------------------------*/
127 /*! \name Constructors */
130 SimpleTextForeground(void);
131 SimpleTextForeground(const SimpleTextForeground
&source
);
134 /*---------------------------------------------------------------------*/
135 /*! \name Destructors */
138 virtual ~SimpleTextForeground(void);
141 /*---------------------------------------------------------------------*/
145 static void initMethod(InitPhase ePhase
);
148 /*---------------------------------------------------------------------*/
152 virtual void resolveLinks(void);
155 /*---------------------------------------------------------------------*/
159 void beginOrthoRender(DrawEnv
*pEnv
,
163 void endOrthoRender (DrawEnv
*pEnv
);
166 /*========================== PRIVATE ================================*/
170 class TextColoredRange
174 TextColoredRange(UInt32 uiStart
, UInt32 uiEnd
, const Color4f
&cColor
);
176 bool isBounded(UInt32 Position
) const;
178 const Color4f
&getColor(void) const;
179 UInt32
getStart(void) const;
180 UInt32
getEnd(void) const;
189 bool isColoredRange( UInt32 uiPosition
) const;
190 Color4f
getColorRange ( UInt32 uiPosition
) const;
192 void updateFormatting ( void );
194 void drawCharacters ( TextTXFFace
* const pTextFace
,
195 const TextLayoutResult
& oLayoutResult
,
198 void initText (const std::string
& szFamily
,
203 TextTXFFaceRefPtr _pFace
;
205 TextureObjChunkUnrecPtr _pTexChunk
;
206 TextureEnvChunkUnrecPtr _pTexEnvChunk
;
208 std::vector
<std::string
> _vPlainTextLines
;
209 std::vector
<TextColoredRange
> _vColorRanges
;
213 friend class FieldContainer
;
214 friend class SimpleTextForegroundBase
;
216 // prohibit default functions (move to 'public' if you need one)
217 void operator =(const SimpleTextForeground
&source
);
220 typedef SimpleTextForeground
*SimpleTextForegroundP
;
224 #include "OSGSimpleTextForegroundBase.inl"
225 #include "OSGSimpleTextForeground.inl"
227 #endif /* _OSGSIMPLETEXTFOREGROUND_H_ */