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