fixed: compile issue
[opensg.git] / Source / System / Window / Foreground / OSGSimpleTextForeground.h
blob0718539111cc53500c4ca800043e8a974311c900
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: David Kabala (djkabala@gmail.com) *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSIMPLETEXTFOREGROUND_H_
40 #define _OSGSIMPLETEXTFOREGROUND_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGSimpleTextForegroundBase.h"
46 #include "OSGTextureObjChunkFields.h"
47 #include "OSGTextureEnvChunkFields.h"
48 #include "OSGTextTXFFace.h"
50 OSG_BEGIN_NAMESPACE
52 /*! \brief SimpleTextForeground class. See \ref
53 PageUtilSimpleTextForeground for a description.
56 class OSG_WINDOW_DLLMAPPING SimpleTextForeground :
57 public SimpleTextForegroundBase
60 protected:
62 /*========================== PUBLIC =================================*/
64 public:
66 typedef SimpleTextForegroundBase Inherited;
67 typedef SimpleTextForeground Self;
69 /*---------------------------------------------------------------------*/
70 /*! \name Modes */
71 /*! \{ */
73 enum HorizontalAlignE
75 Left = 0,
76 Middle = 1,
77 Right = 2
80 enum VerticalAlignE
82 Top = 0,
83 Center = 1,
84 Bottom = 2
87 /*! \} */
88 /*---------------------------------------------------------------------*/
89 /*! \name Sync */
90 /*! \{ */
92 virtual void changed(ConstFieldMaskArg whichField,
93 UInt32 origin,
94 BitVector details );
96 /*! \} */
97 /*---------------------------------------------------------------------*/
98 /*! \name Output */
99 /*! \{ */
101 virtual void dump( UInt32 uiIndent = 0,
102 const BitVector bvFlags = 0) const;
104 /*! \} */
105 /*---------------------------------------------------------------------*/
106 /*! \name Draw */
107 /*! \{ */
109 virtual void draw(DrawEnv *pEnv);
111 /*! \} */
112 /*---------------------------------------------------------------------*/
113 /*! \name Convenience Functions */
114 /*! \{ */
116 void addLine(const std::string &szText);
117 void clear ( void );
119 /*! \} */
120 /*========================= PROTECTED ===============================*/
122 protected:
124 // Variables should all be in SimpleTextForegroundBase.
126 /*---------------------------------------------------------------------*/
127 /*! \name Constructors */
128 /*! \{ */
130 SimpleTextForeground(void);
131 SimpleTextForeground(const SimpleTextForeground &source);
133 /*! \} */
134 /*---------------------------------------------------------------------*/
135 /*! \name Destructors */
136 /*! \{ */
138 virtual ~SimpleTextForeground(void);
140 /*! \} */
141 /*---------------------------------------------------------------------*/
142 /*! \name Init */
143 /*! \{ */
145 static void initMethod(InitPhase ePhase);
147 /*! \} */
148 /*---------------------------------------------------------------------*/
149 /*! \name Init */
150 /*! \{ */
152 virtual void resolveLinks(void);
154 /*! \} */
155 /*---------------------------------------------------------------------*/
156 /*! \name Init */
157 /*! \{ */
159 void beginOrthoRender(DrawEnv *pEnv,
160 UInt32 &fullWidth,
161 UInt32 &fullHeight);
163 void endOrthoRender (DrawEnv *pEnv );
165 /*! \} */
166 /*========================== PRIVATE ================================*/
168 private:
170 class TextColoredRange
172 public:
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;
182 private:
184 UInt32 _uiStart,
185 _uiEnd;
186 Color4f _cColor;
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,
196 bool bWithColoring);
198 void initText (const std::string & szFamily,
199 Real32 fsize );
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;
222 OSG_END_NAMESPACE
224 #include "OSGSimpleTextForegroundBase.inl"
225 #include "OSGSimpleTextForeground.inl"
227 #endif /* _OSGSIMPLETEXTFOREGROUND_H_ */