MyGUI  3.2.0
MyGUI_EditText.h
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_EDIT_TEXT_H__
23 #define __MYGUI_EDIT_TEXT_H__
24 
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_XmlDocument.h"
27 #include "MyGUI_Types.h"
28 #include "MyGUI_ISubWidgetText.h"
29 #include "MyGUI_IFont.h"
30 #include "MyGUI_ResourceSkin.h"
31 #include "MyGUI_RenderFormat.h"
32 #include "MyGUI_TextView.h"
33 #include "MyGUI_VertexData.h"
34 
35 namespace MyGUI
36 {
37 
38  class RenderItem;
39 
41  public ISubWidgetText
42  {
44 
45  public:
46  EditText();
47  virtual ~EditText();
48 
49  virtual void setVisible(bool _value);
50 
51  // обновляет все данные связанные с тектом
52  virtual void updateRawData();
53 
54  // метод для отрисовки себя
55  virtual void doRender();
56 
57  void setCaption(const UString& _value);
58  const UString& getCaption() const;
59 
60  void setTextColour(const Colour& _value);
61  const Colour& getTextColour() const;
62 
63  void setAlpha(float _value);
64  float getAlpha() const;
65 
66  virtual void setFontName(const std::string& _value);
67  virtual const std::string& getFontName() const;
68 
69  virtual void setFontHeight(int _value);
70  virtual int getFontHeight() const;
71 
72  virtual void createDrawItem(ITexture* _texture, ILayerNode* _node);
73  virtual void destroyDrawItem();
74 
75  virtual void setTextAlign(Align _value);
76  virtual Align getTextAlign() const;
77 
78  virtual size_t getTextSelectionStart() const;
79  virtual size_t getTextSelectionEnd() const;
80  virtual void setTextSelection(size_t _start, size_t _end);
81 
82  virtual bool getSelectBackground() const;
83  virtual void setSelectBackground(bool _normal);
84 
85  virtual bool isVisibleCursor() const;
86  virtual void setVisibleCursor(bool _value);
87 
89  virtual bool getInvertSelected() const;
93  virtual void setInvertSelected(bool _value);
94 
95  virtual size_t getCursorPosition() const;
96  virtual void setCursorPosition(size_t _index);
97 
98  virtual IntSize getTextSize();
99 
100  // устанавливает смещение текста в пикселях
101  virtual void setViewOffset(const IntPoint& _point);
102  virtual IntPoint getViewOffset() const;
103 
104  // возвращает положение курсора по произвольному положению
105  virtual size_t getCursorPosition(const IntPoint& _point);
106 
107  // возвращает положение курсора в обсолютных координатах
108  virtual IntCoord getCursorCoord(size_t _position);
109 
110  virtual bool getShadow() const;
111  virtual void setShadow(bool _value);
112 
113  virtual void setShiftText(bool _shift);
114 
115  virtual void setWordWrap(bool _value);
116 
117  virtual void setStateData(IStateInfo* _data);
118 
119  virtual void setShadowColour(const Colour& _value);
120  virtual const Colour& getShadowColour() const;
121 
122  /*internal:*/
123  virtual void _updateView();
124  virtual void _correctView();
125 
126  virtual void _setAlign(const IntSize& _oldsize);
127 
128  private:
129  void _setTextColour(const Colour& _value);
130  void checkVertexSize();
131 
132  void drawQuad(
133  Vertex*& _vertex,
134  size_t& _vertexCount,
135  const FloatRect& _vertexRect,
136  float _vertexZ,
137  const FloatRect& _textureRect,
138  uint32 _colour) const;
139 
140  void drawGlyph(
141  const RenderTargetInfo& renderTargetInfo,
142  Vertex*& _vertex,
143  size_t& _vertexCount,
144  FloatRect _vertexRect,
145  FloatRect _textureRect,
146  uint32 _colour) const;
147 
148  protected:
149  bool mEmptyView;
150  uint32 mCurrentColourNative;
151  uint32 mInverseColourNative;
152  uint32 mCurrentAlphaNative;
153  uint32 mShadowColourNative;
154  IntCoord mCurrentCoord;
155 
156  UString mCaption;
157  bool mTextOutDate;
158  Align mTextAlign;
159 
160  Colour mColour;
161  Colour mShadowColour;
162  float mAlpha;
163  VertexColourType mVertexFormat;
164 
165  IFont* mFont;
166  ITexture* mTexture;
167  int mFontHeight;
168 
169  bool mBackgroundNormal;
170  size_t mStartSelect;
171  size_t mEndSelect;
172  size_t mCursorPosition;
173  bool mVisibleCursor;
174  bool mInvertSelect;
175  bool mShadow;
176 
177  IntPoint mViewOffset; // смещение текста
178 
179  ILayerNode* mNode;
180  RenderItem* mRenderItem;
181  size_t mCountVertex;
182  bool mIsAddCursorWidth;
183 
184  bool mShiftText;
185  bool mWordWrap;
186  bool mManualColour;
187  int mOldWidth;
188 
189  TextView mTextView;
190  };
191 
192 } // namespace MyGUI
193 
194 #endif // __MYGUI_EDIT_TEXT_H__