MyGUI 3.5.3
MyGUI_EditText.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_EDIT_TEXT_H_
8#define MYGUI_EDIT_TEXT_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_XmlDocument.h"
12#include "MyGUI_Types.h"
14#include "MyGUI_IFont.h"
15#include "MyGUI_ResourceSkin.h"
16#include "MyGUI_RenderFormat.h"
17#include "MyGUI_TextView.h"
18#include "MyGUI_VertexData.h"
19
20namespace MyGUI
21{
22
23 class RenderItem;
24
25 class MYGUI_EXPORT EditText : public ISubWidgetText
26 {
27 MYGUI_RTTI_DERIVED(EditText)
28
29 public:
30 EditText();
31
32 void setVisible(bool _visible) override;
33
34 // use in const methods, but actually might update object
35 void updateRawData() const;
36
37 void doRender() override;
38
39 void setCaption(const UString& _value) override;
40 const UString& getCaption() const override;
41
42 void setTextColour(const Colour& _value) override;
43 const Colour& getTextColour() const override;
44
45 void setAlpha(float _value) override;
46
47 void setFontName(std::string_view _value) override;
48 std::string_view getFontName() const override;
49
50 void setFontHeight(int _value) override;
51 int getFontHeight() const override;
52
53 void createDrawItem(ITexture* _texture, ILayerNode* _node) override;
54 void destroyDrawItem() override;
55
56 void setTextAlign(Align _value) override;
57 Align getTextAlign() const override;
58
59 size_t getTextSelectionStart() const override;
60 size_t getTextSelectionEnd() const override;
61 void setTextSelection(size_t _start, size_t _end) override;
62
63 bool getSelectBackground() const override;
64 void setSelectBackground(bool _normal) override;
65
66 bool isVisibleCursor() const override;
67 void setVisibleCursor(bool _value) override;
68
70 bool getInvertSelected() const override;
74 void setInvertSelected(bool _value) override;
75
76 size_t getCursorPosition() const override;
77 void setCursorPosition(size_t _index) override;
78
79 IntSize getTextSize() const override;
80
81 void setViewOffset(const IntPoint& _point) override;
82 IntPoint getViewOffset() const override;
83
84 size_t getCursorPosition(const IntPoint& _point) const override;
85
86 IntCoord getCursorCoord(size_t _position) const override;
87
88 bool getShadow() const override;
89 void setShadow(bool _value) override;
90
91 void setShiftText(bool _value) override;
92
93 void setWordWrap(bool _value) override;
94
95 void setStateData(IStateInfo* _data) override;
96
97 void setShadowColour(const Colour& _value) override;
98 const Colour& getShadowColour() const override;
99
100 /*internal:*/
101 void _invalidateTextLayout() override;
102 void _updateView() override;
103 void _correctView() override;
104
105 void _setAlign(const IntSize& _oldsize) override;
106
107 virtual const VectorLineInfo& getLineInfo() const;
108
109 private:
110 void _setTextColour(const Colour& _value);
111 void checkVertexSize();
112 unsigned int getMixedNativeAlpha(float secondAlpha) const;
113
114 void drawQuad(
115 Vertex*& _vertex,
116 size_t& _vertexCount,
117 const FloatRect& _vertexRect,
118 float _vertexZ,
119 const FloatRect& _textureRect,
120 uint32 _colour) const;
121
122 void drawGlyph(
123 const RenderTargetInfo& renderTargetInfo,
124 Vertex*& _vertex,
125 size_t& _vertexCount,
126 FloatRect _vertexRect,
127 FloatRect _textureRect,
128 uint32 _colour) const;
129
130 protected:
131 bool mEmptyView{false};
132 uint32 mCurrentColourNative{0xFFFFFFFF};
133 uint32 mInverseColourNative{0xFF000000};
134 uint32 mShadowColourNative{0xFF000000};
135 IntCoord mCurrentCoord;
136
137 UString mCaption;
138 mutable bool mTextOutDate{false};
139 Align mTextAlign{Align::Default};
140
141 Colour mColour{Colour::White};
142 Colour mShadowColour{Colour::Black};
143 float mAlpha{ALPHA_MAX};
144 VertexColourType mVertexFormat;
145
146 IFont* mFont{nullptr};
147 ITexture* mTexture{nullptr};
148 int mFontHeight{0};
149 int mCustomFontHeight = 0;
150
151 bool mBackgroundNormal{true};
152 size_t mStartSelect{0};
153 size_t mEndSelect{0};
154 size_t mCursorPosition{0};
155 bool mVisibleCursor{false};
156 bool mInvertSelect{true};
157 bool mShadow{false};
158
159 IntPoint mViewOffset;
160
161 ILayerNode* mNode{nullptr};
162 RenderItem* mRenderItem{nullptr};
163 size_t mCountVertex;
164 bool mIsAddCursorWidth{true};
165
166 bool mShiftText{false};
167 bool mWordWrap{false};
168 bool mManualColour{false};
169 int mOldWidth{0};
170
171 mutable TextView mTextView;
172 };
173
174} // namespace MyGUI
175
176#endif // MYGUI_EDIT_TEXT_H_
#define MYGUI_EXPORT
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:67
uint32_t uint32
Definition MyGUI_Types.h:47
std::vector< LineInfo > VectorLineInfo
constexpr float ALPHA_MAX
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:26
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:35
types::TSize< int > IntSize
Definition MyGUI_Types.h:29