MyGUI  3.2.0
MyGUI_EditText.h
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 #ifndef __MYGUI_EDIT_TEXT_H__
00023 #define __MYGUI_EDIT_TEXT_H__
00024 
00025 #include "MyGUI_Prerequest.h"
00026 #include "MyGUI_XmlDocument.h"
00027 #include "MyGUI_Types.h"
00028 #include "MyGUI_ISubWidgetText.h"
00029 #include "MyGUI_IFont.h"
00030 #include "MyGUI_ResourceSkin.h"
00031 #include "MyGUI_RenderFormat.h"
00032 #include "MyGUI_TextView.h"
00033 #include "MyGUI_VertexData.h"
00034 
00035 namespace MyGUI
00036 {
00037 
00038     class RenderItem;
00039 
00040     class MYGUI_EXPORT EditText :
00041         public ISubWidgetText
00042     {
00043         MYGUI_RTTI_DERIVED( EditText )
00044 
00045     public:
00046         EditText();
00047         virtual ~EditText();
00048 
00049         virtual void setVisible(bool _value);
00050 
00051         // обновляет все данные связанные с тектом
00052         virtual void updateRawData();
00053 
00054         // метод для отрисовки себя
00055         virtual void doRender();
00056 
00057         void setCaption(const UString& _value);
00058         const UString& getCaption() const;
00059 
00060         void setTextColour(const Colour& _value);
00061         const Colour& getTextColour() const;
00062 
00063         void setAlpha(float _value);
00064         float getAlpha() const;
00065 
00066         virtual void setFontName(const std::string& _value);
00067         virtual const std::string& getFontName() const;
00068 
00069         virtual void setFontHeight(int _value);
00070         virtual int getFontHeight() const;
00071 
00072         virtual void createDrawItem(ITexture* _texture, ILayerNode* _node);
00073         virtual void destroyDrawItem();
00074 
00075         virtual void setTextAlign(Align _value);
00076         virtual Align getTextAlign() const;
00077 
00078         virtual size_t getTextSelectionStart() const;
00079         virtual size_t getTextSelectionEnd() const;
00080         virtual void setTextSelection(size_t _start, size_t _end);
00081 
00082         virtual bool getSelectBackground() const;
00083         virtual void setSelectBackground(bool _normal);
00084 
00085         virtual bool isVisibleCursor() const;
00086         virtual void setVisibleCursor(bool _value);
00087 
00089         virtual bool getInvertSelected() const;
00093         virtual void setInvertSelected(bool _value);
00094 
00095         virtual size_t getCursorPosition() const;
00096         virtual void setCursorPosition(size_t _index);
00097 
00098         virtual IntSize getTextSize();
00099 
00100         // устанавливает смещение текста в пикселях
00101         virtual void setViewOffset(const IntPoint& _point);
00102         virtual IntPoint getViewOffset() const;
00103 
00104         // возвращает положение курсора по произвольному положению
00105         virtual size_t getCursorPosition(const IntPoint& _point);
00106 
00107         // возвращает положение курсора в обсолютных координатах
00108         virtual IntCoord getCursorCoord(size_t _position);
00109 
00110         virtual bool getShadow() const;
00111         virtual void setShadow(bool _value);
00112 
00113         virtual void setShiftText(bool _shift);
00114 
00115         virtual void setWordWrap(bool _value);
00116 
00117         virtual void setStateData(IStateInfo* _data);
00118 
00119         virtual void setShadowColour(const Colour& _value);
00120         virtual const Colour& getShadowColour() const;
00121 
00122     /*internal:*/
00123         virtual void _updateView();
00124         virtual void _correctView();
00125 
00126         virtual void _setAlign(const IntSize& _oldsize);
00127 
00128     private:
00129         void _setTextColour(const Colour& _value);
00130         void checkVertexSize();
00131 
00132         void drawQuad(
00133             Vertex*& _buff,
00134             const FloatRect& _vertexRect,
00135             float v_z,
00136             uint32 _colour,
00137             const FloatRect& _textureRect,
00138             size_t& _count) const;
00139 
00140         void drawCursor(
00141             const RenderTargetInfo& _info,
00142             Vertex*& _vertex,
00143             float _vertex_z,
00144             uint32 _colour,
00145             size_t& _vertex_count);
00146 
00147         void drawSimbol(
00148             VectorCharInfo::const_iterator _sim,
00149             const RenderTargetInfo& _info,
00150             GlyphInfo* back_glyph,
00151             Vertex*& _vertex,
00152             float _vertex_z,
00153             const IntPoint& _point,
00154             bool _select,
00155             uint32 _colour,
00156             uint32 _back_colour,
00157             size_t& _vertex_count);
00158 
00159     protected:
00160         bool mEmptyView;
00161         uint32 mCurrentColourNative;
00162         uint32 mInverseColourNative;
00163         uint32 mCurrentAlphaNative;
00164         uint32 mShadowColourNative;
00165         IntCoord mCurrentCoord;
00166 
00167         UString mCaption;
00168         bool mTextOutDate;
00169         Align mTextAlign;
00170 
00171         Colour mColour;
00172         Colour mShadowColour;
00173         float mAlpha;
00174         VertexColourType mVertexFormat;
00175 
00176         IFont* mFont;
00177         ITexture* mTexture;
00178         int mFontHeight;
00179 
00180         bool mBackgroundNormal;
00181         size_t mStartSelect;
00182         size_t mEndSelect;
00183         size_t mCursorPosition;
00184         bool mVisibleCursor;
00185         bool mInvertSelect;
00186         bool mShadow;
00187 
00188         IntPoint mViewOffset; // смещение текста
00189 
00190         ILayerNode* mNode;
00191         RenderItem* mRenderItem;
00192         size_t mCountVertex;
00193         bool mIsAddCursorWidth;
00194 
00195         bool mShiftText;
00196         bool mWordWrap;
00197         bool mManualColour;
00198         int mOldWidth;
00199 
00200         TextView mTextView;
00201     };
00202 
00203 } // namespace MyGUI
00204 
00205 #endif // __MYGUI_EDIT_TEXT_H__