MyGUI: MyGUI_EditText.h Source File

MyGUI 3.4.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"
13#include "MyGUI_ISubWidgetText.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 // метод для отрисовки себя
38 void doRender() override;
39
40 void setCaption(const UString& _value) override;
41 const UString& getCaption() const override;
42
43 void setTextColour(const Colour& _value) override;
44 const Colour& getTextColour() const override;
45
46 void setAlpha(float _value) override;
47
48 void setFontName(std::string_view _value) override;
49 std::string_view getFontName() const override;
50
51 void setFontHeight(int _value) override;
52 int getFontHeight() const override;
53
54 void createDrawItem(ITexture* _texture, ILayerNode* _node) override;
55 void destroyDrawItem() override;
56
57 void setTextAlign(Align _value) override;
58 Align getTextAlign() const override;
59
60 size_t getTextSelectionStart() const override;
61 size_t getTextSelectionEnd() const override;
62 void setTextSelection(size_t _start, size_t _end) override;
63
64 bool getSelectBackground() const override;
65 void setSelectBackground(bool _normal) override;
66
67 bool isVisibleCursor() const override;
68 void setVisibleCursor(bool _value) override;
69
71 bool getInvertSelected() const override;
75 void setInvertSelected(bool _value) override;
76
77 size_t getCursorPosition() const override;
78 void setCursorPosition(size_t _index) override;
79
80 IntSize getTextSize() const override;
81
82 // устанавливает смещение текста в пикселях
83 void setViewOffset(const IntPoint& _point) override;
84 IntPoint getViewOffset() const override;
85
86 // возвращает положение курсора по произвольному положению
87 size_t getCursorPosition(const IntPoint& _point) const override;
88
89 // возвращает положение курсора в обсолютных координатах
90 IntCoord getCursorCoord(size_t _position) const override;
91
92 bool getShadow() const override;
93 void setShadow(bool _value) override;
94
95 void setShiftText(bool _value) override;
96
97 void setWordWrap(bool _value) override;
98
99 void setStateData(IStateInfo* _data) override;
100
101 void setShadowColour(const Colour& _value) override;
102 const Colour& getShadowColour() const override;
103
104 /*internal:*/
105 void _updateView() override;
106 void _correctView() override;
107
108 void _setAlign(const IntSize& _oldsize) override;
109
110 virtual const VectorLineInfo& getLineInfo() const;
111
112 private:
113 void _setTextColour(const Colour& _value);
114 void checkVertexSize();
115 unsigned int getMixedNativeAlpha(float secondAlpha) const;
116
117 void drawQuad(
118 Vertex*& _vertex,
119 size_t& _vertexCount,
120 const FloatRect& _vertexRect,
121 float _vertexZ,
122 const FloatRect& _textureRect,
123 uint32 _colour) const;
124
125 void drawGlyph(
126 const RenderTargetInfo& renderTargetInfo,
127 Vertex*& _vertex,
128 size_t& _vertexCount,
129 FloatRect _vertexRect,
130 FloatRect _textureRect,
131 uint32 _colour) const;
132
133 protected:
134 bool mEmptyView{false};
135 uint32 mCurrentColourNative{0xFFFFFFFF};
136 uint32 mInverseColourNative{0xFF000000};
137 uint32 mShadowColourNative{0x00000000};
138 IntCoord mCurrentCoord;
139
140 UString mCaption;
141 UString::utf32string mUtf32Caption;
142 mutable bool mTextOutDate{false};
143 Align mTextAlign{Align::Default};
144
145 Colour mColour{Colour::White};
146 Colour mShadowColour{Colour::Black};
147 float mAlpha{ALPHA_MAX};
148 VertexColourType mVertexFormat;
149
150 IFont* mFont{nullptr};
151 ITexture* mTexture{nullptr};
152 int mFontHeight{0};
153 int mCustomFontHeight = 0;
154
155 bool mBackgroundNormal{true};
156 size_t mStartSelect{0};
157 size_t mEndSelect{0};
158 size_t mCursorPosition{0};
159 bool mVisibleCursor{false};
160 bool mInvertSelect{true};
161 bool mShadow{false};
162
163 IntPoint mViewOffset; // смещение текста
164
165 ILayerNode* mNode{nullptr};
166 RenderItem* mRenderItem{nullptr};
167 size_t mCountVertex;
168 bool mIsAddCursorWidth{true};
169
170 bool mShiftText{false};
171 bool mWordWrap{false};
172 bool mManualColour{false};
173 int mOldWidth{0};
174
175 mutable TextView mTextView;
176 };
177
178} // namespace MyGUI
179
180#endif // MYGUI_EDIT_TEXT_H_
MyGUI_IFont.h
MyGUI_ISubWidgetText.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:69
MyGUI_RenderFormat.h
MyGUI_ResourceSkin.h
MyGUI_TextView.h
MyGUI_Types.h
MyGUI_VertexData.h
MyGUI_XmlDocument.h
MyGUI::EditText::mBackgroundNormal
bool mBackgroundNormal
Definition MyGUI_EditText.h:155
MyGUI::EditText::setTextColour
void setTextColour(const Colour &_value) override
Definition MyGUI_EditText.cpp:170
MyGUI::EditText::mVertexFormat
VertexColourType mVertexFormat
Definition MyGUI_EditText.h:148
MyGUI::EditText::mCustomFontHeight
int mCustomFontHeight
Definition MyGUI_EditText.h:153
MyGUI::EditText::mShiftText
bool mShiftText
Definition MyGUI_EditText.h:170
MyGUI::EditText::mShadowColour
Colour mShadowColour
Definition MyGUI_EditText.h:146
MyGUI::EditText::getTextSelectionEnd
size_t getTextSelectionEnd() const override
Definition MyGUI_EditText.cpp:296
MyGUI::EditText::mWordWrap
bool mWordWrap
Definition MyGUI_EditText.h:171
MyGUI::EditText::setAlpha
void setAlpha(float _value) override
Definition MyGUI_EditText.cpp:196
MyGUI::EditText::mCurrentColourNative
uint32 mCurrentColourNative
Definition MyGUI_EditText.h:135
MyGUI::EditText::mStartSelect
size_t mStartSelect
Definition MyGUI_EditText.h:156
MyGUI::EditText::setFontName
void setFontName(std::string_view _value) override
Definition MyGUI_EditText.cpp:210
MyGUI::EditText::setSelectBackground
void setSelectBackground(bool _normal) override
Definition MyGUI_EditText.cpp:315
MyGUI::EditText::setTextSelection
void setTextSelection(size_t _start, size_t _end) override
Definition MyGUI_EditText.cpp:301
MyGUI::EditText::setWordWrap
void setWordWrap(bool _value) override
Definition MyGUI_EditText.cpp:449
MyGUI::EditText::_setAlign
void _setAlign(const IntSize &_oldsize) override
Definition MyGUI_EditText.cpp:45
MyGUI::EditText::isVisibleCursor
bool isVisibleCursor() const override
Definition MyGUI_EditText.cpp:325
MyGUI::EditText::getShadow
bool getShadow() const override
Definition MyGUI_EditText.cpp:615
MyGUI::EditText::mEmptyView
bool mEmptyView
Definition MyGUI_EditText.h:134
MyGUI::EditText::mFont
IFont * mFont
Definition MyGUI_EditText.h:150
MyGUI::EditText::getCursorCoord
IntCoord getCursorCoord(size_t _position) const override
Definition MyGUI_EditText.cpp:423
MyGUI::EditText::_correctView
void _correctView() override
Definition MyGUI_EditText.cpp:39
MyGUI::EditText::setVisible
void setVisible(bool _visible) override
Definition MyGUI_EditText.cpp:29
MyGUI::EditText::getLineInfo
virtual const VectorLineInfo & getLineInfo() const
Definition MyGUI_EditText.cpp:389
MyGUI::EditText::setInvertSelected
void setInvertSelected(bool _value) override
Definition MyGUI_EditText.cpp:600
MyGUI::EditText::mCaption
UString mCaption
Definition MyGUI_EditText.h:140
MyGUI::EditText::getTextColour
const Colour & getTextColour() const override
Definition MyGUI_EditText.cpp:191
MyGUI::EditText::setFontHeight
void setFontHeight(int _value) override
Definition MyGUI_EditText.cpp:250
MyGUI::EditText::mInverseColourNative
uint32 mInverseColourNative
Definition MyGUI_EditText.h:136
MyGUI::EditText::mTextView
TextView mTextView
Definition MyGUI_EditText.h:175
MyGUI::EditText::getShadowColour
const Colour & getShadowColour() const override
Definition MyGUI_EditText.cpp:642
MyGUI::EditText::mTexture
ITexture * mTexture
Definition MyGUI_EditText.h:151
MyGUI::EditText::mCursorPosition
size_t mCursorPosition
Definition MyGUI_EditText.h:158
MyGUI::EditText::mIsAddCursorWidth
bool mIsAddCursorWidth
Definition MyGUI_EditText.h:168
MyGUI::EditText::setShadowColour
void setShadowColour(const Colour &_value) override
Definition MyGUI_EditText.cpp:631
MyGUI::EditText::mNode
ILayerNode * mNode
Definition MyGUI_EditText.h:165
MyGUI::EditText::getCaption
const UString & getCaption() const override
Definition MyGUI_EditText.cpp:165
MyGUI::EditText::mTextOutDate
bool mTextOutDate
Definition MyGUI_EditText.h:142
MyGUI::EditText::mViewOffset
IntPoint mViewOffset
Definition MyGUI_EditText.h:163
MyGUI::EditText::getInvertSelected
bool getInvertSelected() const override
Definition MyGUI_EditText.cpp:610
MyGUI::EditText::setCaption
void setCaption(const UString &_value) override
Definition MyGUI_EditText.cpp:136
MyGUI::EditText::setTextAlign
void setTextAlign(Align _value) override
Definition MyGUI_EditText.cpp:355
MyGUI::EditText::mFontHeight
int mFontHeight
Definition MyGUI_EditText.h:152
MyGUI::EditText::mTextAlign
Align mTextAlign
Definition MyGUI_EditText.h:143
MyGUI::EditText::setStateData
void setStateData(IStateInfo *_data) override
Definition MyGUI_EditText.cpp:477
MyGUI::EditText::getFontHeight
int getFontHeight() const override
Definition MyGUI_EditText.cpp:263
MyGUI::EditText::getTextSelectionStart
size_t getTextSelectionStart() const override
Definition MyGUI_EditText.cpp:291
MyGUI::EditText::doRender
void doRender() override
Definition MyGUI_EditText.cpp:485
MyGUI::EditText::getViewOffset
IntPoint getViewOffset() const override
Definition MyGUI_EditText.cpp:402
MyGUI::EditText::mCountVertex
size_t mCountVertex
Definition MyGUI_EditText.h:167
MyGUI::EditText::setVisibleCursor
void setVisibleCursor(bool _value) override
Definition MyGUI_EditText.cpp:330
MyGUI::EditText::getFontName
std::string_view getFontName() const override
Definition MyGUI_EditText.cpp:245
MyGUI::EditText::mShadow
bool mShadow
Definition MyGUI_EditText.h:161
MyGUI::EditText::getSelectBackground
bool getSelectBackground() const override
Definition MyGUI_EditText.cpp:310
MyGUI::EditText::getTextSize
IntSize getTextSize() const override
Definition MyGUI_EditText.cpp:368
MyGUI::EditText::mEndSelect
size_t mEndSelect
Definition MyGUI_EditText.h:157
MyGUI::EditText::mManualColour
bool mManualColour
Definition MyGUI_EditText.h:172
MyGUI::EditText::getCursorPosition
size_t getCursorPosition() const override
Definition MyGUI_EditText.cpp:340
MyGUI::EditText::EditText
EditText()
Definition MyGUI_EditText.cpp:23
MyGUI::EditText::setViewOffset
void setViewOffset(const IntPoint &_point) override
Definition MyGUI_EditText.cpp:394
MyGUI::EditText::mOldWidth
int mOldWidth
Definition MyGUI_EditText.h:173
MyGUI::EditText::getTextAlign
Align getTextAlign() const override
Definition MyGUI_EditText.cpp:363
MyGUI::EditText::_updateView
void _updateView() override
Definition MyGUI_EditText.cpp:97
MyGUI::EditText::mInvertSelect
bool mInvertSelect
Definition MyGUI_EditText.h:160
MyGUI::EditText::mColour
Colour mColour
Definition MyGUI_EditText.h:145
MyGUI::EditText::mRenderItem
RenderItem * mRenderItem
Definition MyGUI_EditText.h:166
MyGUI::EditText::setShiftText
void setShiftText(bool _value) override
Definition MyGUI_EditText.cpp:439
MyGUI::EditText::mShadowColourNative
uint32 mShadowColourNative
Definition MyGUI_EditText.h:137
MyGUI::EditText::mVisibleCursor
bool mVisibleCursor
Definition MyGUI_EditText.h:159
MyGUI::EditText::mUtf32Caption
UString::utf32string mUtf32Caption
Definition MyGUI_EditText.h:141
MyGUI::EditText::mAlpha
float mAlpha
Definition MyGUI_EditText.h:147
MyGUI::EditText::createDrawItem
void createDrawItem(ITexture *_texture, ILayerNode *_node) override
Definition MyGUI_EditText.cpp:268
MyGUI::EditText::setCursorPosition
void setCursorPosition(size_t _index) override
Definition MyGUI_EditText.cpp:345
MyGUI::EditText::setShadow
void setShadow(bool _value) override
Definition MyGUI_EditText.cpp:620
MyGUI::EditText::mCurrentCoord
IntCoord mCurrentCoord
Definition MyGUI_EditText.h:138
MyGUI::EditText::updateRawData
void updateRawData() const
Definition MyGUI_EditText.cpp:458
MyGUI::EditText::destroyDrawItem
void destroyDrawItem() override
Definition MyGUI_EditText.cpp:281
MyGUI::IFont
Definition MyGUI_IFont.h:21
MyGUI::ILayerNode
Definition MyGUI_ILayerNode.h:29
MyGUI::IStateInfo
Definition MyGUI_IStateInfo.h:17
MyGUI::ISubWidgetText
Definition MyGUI_ISubWidgetText.h:19
MyGUI::ITexture
Definition MyGUI_ITexture.h:28
MyGUI::RenderItem
Definition MyGUI_RenderItem.h:23
MyGUI::TextView
Definition MyGUI_TextView.h:19
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition MyGUI_UString.h:144
MyGUI::UString::utf32string
std::basic_string< unicode_char > utf32string
string type used for returning UTF-32 formatted data
Definition MyGUI_UString.h:177
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::uint32
uint32_t uint32
Definition MyGUI_Types.h:48
MyGUI::VectorLineInfo
std::vector< LineInfo > VectorLineInfo
Definition MyGUI_TextViewData.h:129
MyGUI::ALPHA_MAX
constexpr float ALPHA_MAX
Definition MyGUI_Macros.h:20
MyGUI::IntPoint
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:27
MyGUI::FloatRect
types::TRect< float > FloatRect
Definition MyGUI_Types.h:34
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::IntSize
types::TSize< int > IntSize
Definition MyGUI_Types.h:30
MyGUI::Align
Definition MyGUI_Align.h:20
MyGUI::Align::Default
@ Default
Definition MyGUI_Align.h:36
MyGUI::Colour
Definition MyGUI_Colour.h:17
MyGUI::Colour::White
static const Colour White
Definition MyGUI_Colour.h:55
MyGUI::Colour::Black
static const Colour Black
Definition MyGUI_Colour.h:54
MyGUI::RenderTargetInfo
Definition MyGUI_RenderTargetInfo.h:16
MyGUI::VertexColourType
Definition MyGUI_RenderFormat.h:16
MyGUI::Vertex
Definition MyGUI_VertexData.h:17