MyGUI 3.0.1
MyGUI_EditText.cpp
Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009 
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014 
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #include "MyGUI_Precompiled.h"
00024 #include "MyGUI_EditText.h"
00025 #include "MyGUI_RenderItem.h"
00026 #include "MyGUI_FontManager.h"
00027 #include "MyGUI_RenderManager.h"
00028 #include "MyGUI_LanguageManager.h"
00029 #include "MyGUI_TextIterator.h"
00030 #include "MyGUI_IRenderTarget.h"
00031 #include "MyGUI_FontData.h"
00032 #include "MyGUI_CommonStateInfo.h"
00033 
00034 namespace MyGUI
00035 {
00036 
00037     const size_t VERTEX_IN_QUAD = 6;
00038     const size_t SIMPLETEXT_COUNT_VERTEX = 32 * VERTEX_IN_QUAD;
00039 
00040     MYGUI_FORCEINLINE void DrawQuad(
00041         MyGUI::Vertex*& _buff,
00042         float v_left,
00043         float v_top,
00044         float v_rignt,
00045         float v_bottom,
00046         float v_z,
00047         MyGUI::uint32 _colour,
00048         float t_left,
00049         float t_top,
00050         float t_right,
00051         float t_bottom,
00052         size_t& _count)
00053     {
00054         _buff[0].x = v_left;
00055         _buff[0].y = v_top;
00056         _buff[0].z = v_z;
00057         _buff[0].colour = _colour;
00058         _buff[0].u = t_left;
00059         _buff[0].v = t_top;
00060 
00061         _buff[1].x = v_left;
00062         _buff[1].y = v_bottom;
00063         _buff[1].z = v_z;
00064         _buff[1].colour = _colour;
00065         _buff[1].u = t_left;
00066         _buff[1].v = t_bottom;
00067 
00068         _buff[2].x = v_rignt;
00069         _buff[2].y = v_top;
00070         _buff[2].z = v_z;
00071         _buff[2].colour = _colour;
00072         _buff[2].u = t_right;
00073         _buff[2].v = t_top;
00074 
00075         _buff[3].x = v_rignt;
00076         _buff[3].y = v_top;
00077         _buff[3].z = v_z;
00078         _buff[3].colour = _colour;
00079         _buff[3].u = t_right;
00080         _buff[3].v = t_top;
00081 
00082         _buff[4].x = v_left;
00083         _buff[4].y = v_bottom;
00084         _buff[4].z = v_z;
00085         _buff[4].colour = _colour;
00086         _buff[4].u = t_left;
00087         _buff[4].v = t_bottom;
00088 
00089         _buff[5].x = v_rignt;
00090         _buff[5].y = v_bottom;
00091         _buff[5].z = v_z;
00092         _buff[5].colour = _colour;
00093         _buff[5].u = t_right;
00094         _buff[5].v = t_bottom;
00095 
00096         _buff += VERTEX_IN_QUAD;
00097         _count += VERTEX_IN_QUAD;
00098     }
00099 
00100     EditText::EditText() :
00101         ISubWidgetText(),
00102         mEmptyView(false),
00103         mCurrentColour(0x00FFFFFF),
00104         mInverseColour(0x00000000),
00105         mCurrentAlpha(0xFF000000),
00106         mTextOutDate(false),
00107         mTextAlign(Align::Default),
00108         mColour(Colour::White),
00109         mAlpha(ALPHA_MAX),
00110         mFont(nullptr),
00111         mTexture(nullptr),
00112         mFontHeight(0),
00113         mBackgroundNormal(true),
00114         mStartSelect(0),
00115         mEndSelect(0),
00116         mCursorPosition(0),
00117         mVisibleCursor(false),
00118         mInvertSelect(true),
00119         mNode(nullptr),
00120         mRenderItem(nullptr),
00121         mCountVertex(SIMPLETEXT_COUNT_VERTEX),
00122         mIsAddCursorWidth(true),
00123         mShiftText(false),
00124         mWordWrap(false),
00125         mOldWidth(0)
00126     {
00127         mVertexFormat = RenderManager::getInstance().getVertexFormat();
00128 
00129         mCurrentColour = texture_utility::toColourARGB(mColour);
00130         texture_utility::convertColour(mCurrentColour, mVertexFormat);
00131 
00132         mCurrentColour = (mCurrentColour & 0x00FFFFFF) | mCurrentAlpha;
00133         mInverseColour = mCurrentColour ^ 0x00FFFFFF;
00134     }
00135 
00136     EditText::~EditText()
00137     {
00138     }
00139 
00140     void EditText::setVisible(bool _visible)
00141     {
00142         if (mVisible == _visible) return;
00143         mVisible = _visible;
00144 
00145         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00146     }
00147 
00148     void EditText::_correctView()
00149     {
00150         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00151     }
00152 
00153     void EditText::_setAlign(const IntCoord& _oldcoord, bool _update)
00154     {
00155         _setAlign(_oldcoord.size(), _update);
00156     }
00157 
00158     void EditText::_setAlign(const IntSize& _oldsize, bool _update)
00159     {
00160 
00161         if (mWordWrap)
00162         {
00163             // передается старая координата всегда
00164             int width = mCroppedParent->getWidth();
00165             if (mOldWidth != width)
00166             {
00167                 mOldWidth = width;
00168                 mTextOutDate = true;
00169             }
00170         }
00171 
00172         // необходимо разобраться
00173         bool need_update = true;//_update;
00174 
00175         // первоначальное выравнивание
00176         if (mAlign.isHStretch())
00177         {
00178             // растягиваем
00179             mCoord.width = mCoord.width + (mCroppedParent->getWidth() - _oldsize.width);
00180             need_update = true;
00181             mIsMargin = true; // при изменении размеров все пересчитывать
00182         }
00183         else if (mAlign.isRight())
00184         {
00185             // двигаем по правому краю
00186             mCoord.left = mCoord.left + (mCroppedParent->getWidth() - _oldsize.width);
00187             need_update = true;
00188         }
00189         else if (mAlign.isHCenter())
00190         {
00191             // выравнивание по горизонтали без растяжения
00192             mCoord.left = (mCroppedParent->getWidth() - mCoord.width) / 2;
00193             need_update = true;
00194         }
00195 
00196         if (mAlign.isVStretch())
00197         {
00198             // растягиваем
00199             mCoord.height = mCoord.height + (mCroppedParent->getHeight() - _oldsize.height);
00200             need_update = true;
00201             mIsMargin = true; // при изменении размеров все пересчитывать
00202         }
00203         else if (mAlign.isBottom())
00204         {
00205             // двигаем по нижнему краю
00206             mCoord.top = mCoord.top + (mCroppedParent->getHeight() - _oldsize.height);
00207             need_update = true;
00208         }
00209         else if (mAlign.isVCenter())
00210         {
00211             // выравнивание по вертикали без растяжения
00212             mCoord.top = (mCroppedParent->getHeight() - mCoord.height) / 2;
00213             need_update = true;
00214         }
00215 
00216         if (need_update)
00217         {
00218             mCurrentCoord = mCoord;
00219             _updateView();
00220         }
00221 
00222     }
00223 
00224     void EditText::_updateView()
00225     {
00226         bool margin = _checkMargin();
00227 
00228         mEmptyView = ((0 >= _getViewWidth()) || (0 >= _getViewHeight()));
00229 
00230         mCurrentCoord.left = mCoord.left + mMargin.left;
00231         mCurrentCoord.top = mCoord.top + mMargin.top;
00232 
00233         // вьюпорт стал битым
00234         if (margin)
00235         {
00236             // проверка на полный выход за границу
00237             if (_checkOutside())
00238             {
00239                 // запоминаем текущее состояние
00240                 mIsMargin = margin;
00241 
00242                 // обновить перед выходом
00243                 if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00244                 return;
00245             }
00246         }
00247 
00248         // мы обрезаны или были обрезаны
00249         if ((mIsMargin) || (margin))
00250         {
00251             mCurrentCoord.width = _getViewWidth();
00252             mCurrentCoord.height = _getViewHeight();
00253         }
00254 
00255         // запоминаем текущее состояние
00256         mIsMargin = margin;
00257 
00258         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00259     }
00260 
00261     void EditText::setCaption(const UString& _value)
00262     {
00263         mCaption = _value;
00264         mTextOutDate = true;
00265 
00266         // если вершин не хватит, делаем реалок, с учетом выделения * 2 и курсора
00267         size_t need = (mCaption.size() * 2 + 2) * VERTEX_IN_QUAD;
00268         if (mCountVertex < need)
00269         {
00270             mCountVertex = need + SIMPLETEXT_COUNT_VERTEX;
00271             if (nullptr != mRenderItem) mRenderItem->reallockDrawItem(this, mCountVertex);
00272         }
00273         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00274     }
00275 
00276     const UString& EditText::getCaption()
00277     {
00278         return mCaption;
00279     }
00280 
00281     void EditText::setTextColour(const Colour& _value)
00282     {
00283         if (mColour == _value) return;
00284         mColour = _value;
00285         mCurrentColour = texture_utility::toColourARGB(mColour);
00286 
00287         texture_utility::convertColour(mCurrentColour, mVertexFormat);
00288 
00289         mCurrentColour = (mCurrentColour & 0x00FFFFFF) | mCurrentAlpha;
00290         mInverseColour = mCurrentColour ^ 0x00FFFFFF;
00291 
00292         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00293     }
00294 
00295     const Colour& EditText::getTextColour()
00296     {
00297         return mColour;
00298     }
00299 
00300     void EditText::setAlpha(float _value)
00301     {
00302         if (mAlpha == _value) return;
00303         mAlpha = _value;
00304         mCurrentAlpha = ((uint8)(mAlpha*255) << 24);
00305         mCurrentColour = (mCurrentColour & 0x00FFFFFF) | mCurrentAlpha;
00306         mInverseColour = mCurrentColour ^ 0x00FFFFFF;
00307 
00308         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00309     }
00310 
00311     float EditText::getAlpha()
00312     {
00313         return mAlpha;
00314     }
00315 
00316     void EditText::setFontName(const std::string& _value)
00317     {
00318         mTexture = 0;
00319         mFont = FontManager::getInstance().getByName(_value);
00320         if (mFont != nullptr)
00321         {
00322             mTexture = mFont->getTextureFont();
00323 
00324             // если надо, устанавливаем дефолтный размер шрифта
00325             if (mFont->getDefaultHeight() != 0)
00326             {
00327                 mFontHeight = mFont->getDefaultHeight();
00328             }
00329         }
00330 
00331         mTextOutDate = true;
00332 
00333         // если мы были приаттаченны, то удаляем себя
00334         if (nullptr != mRenderItem)
00335         {
00336             mRenderItem->removeDrawItem(this);
00337             mRenderItem = nullptr;
00338         }
00339 
00340         // если есть текстура, то приаттачиваемся
00341         if (nullptr != mTexture && nullptr != mNode)
00342         {
00343             mRenderItem = mNode->addToRenderItem(mTexture, this);
00344             mRenderItem->addDrawItem(this, mCountVertex);
00345         }
00346 
00347         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00348     }
00349 
00350     const std::string& EditText::getFontName()
00351     {
00352         return mFont->getResourceName();
00353     }
00354 
00355     void EditText::setFontHeight(int _value)
00356     {
00357         mFontHeight = _value;
00358         mTextOutDate = true;
00359         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00360     }
00361 
00362     int EditText::getFontHeight()
00363     {
00364         return mFontHeight;
00365     }
00366 
00367     void EditText::createDrawItem(ITexture* _texture, ILayerNode * _node)
00368     {
00369         mNode = _node;
00370         // если уже есть текстура, то атачимся, актуально для смены леера
00371         if (nullptr != mTexture)
00372         {
00373             MYGUI_ASSERT(!mRenderItem, "mRenderItem must be nullptr");
00374 
00375             mRenderItem = mNode->addToRenderItem(mTexture, this);
00376             mRenderItem->addDrawItem(this, mCountVertex);
00377         }
00378     }
00379 
00380     void EditText::destroyDrawItem()
00381     {
00382         if (nullptr != mRenderItem)
00383         {
00384             mRenderItem->removeDrawItem(this);
00385             mRenderItem = nullptr;
00386         }
00387         mNode = nullptr;
00388     }
00389 
00390     size_t EditText::getTextSelectionStart()
00391     {
00392         return mStartSelect;
00393     }
00394 
00395     size_t EditText::getTextSelectionEnd()
00396     {
00397         return mEndSelect;
00398     }
00399 
00400     void EditText::setTextSelection(size_t _start, size_t _end)
00401     {
00402         mStartSelect=_start;
00403         mEndSelect=_end;
00404         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00405     }
00406 
00407     bool EditText::getSelectBackground()
00408     {
00409         return mBackgroundNormal;
00410     }
00411 
00412     void EditText::setSelectBackground(bool _normal)
00413     {
00414         if (mBackgroundNormal == _normal) return;
00415         mBackgroundNormal = _normal;
00416         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00417     }
00418 
00419     bool EditText::isVisibleCursor()
00420     {
00421         return mVisibleCursor;
00422     }
00423 
00424     void EditText::setVisibleCursor(bool _value)
00425     {
00426         if (mVisibleCursor == _value) return;
00427         mVisibleCursor = _value;
00428         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00429     }
00430 
00431     size_t EditText::getCursorPosition()
00432     {
00433         return mCursorPosition;
00434     }
00435 
00436     void EditText::setCursorPosition(size_t _index)
00437     {
00438         if (mCursorPosition == _index) return;
00439         mCursorPosition = _index;
00440         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00441     }
00442 
00443     void EditText::setTextAlign(Align _value)
00444     {
00445         mTextAlign = _value;
00446         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00447     }
00448 
00449     Align EditText::getTextAlign()
00450     {
00451         return mTextAlign;
00452     }
00453 
00454     IntSize EditText::getTextSize()
00455     {
00456         // если нуно обновить, или изменились пропорции экрана
00457         if (mTextOutDate) updateRawData();
00458 
00459         IntSize size = mTextView.getViewSize();
00460         // плюс размер курсора
00461         if (mIsAddCursorWidth)
00462             size.width += 2;
00463         return size;
00464     }
00465 
00466     void EditText::setViewOffset(const IntPoint& _point)
00467     {
00468         mViewOffset = _point;
00469         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00470     }
00471 
00472     IntPoint EditText::getViewOffset()
00473     {
00474         return mViewOffset;
00475     }
00476 
00477     size_t EditText::getCursorPosition(const IntPoint& _point)
00478     {
00479         if (nullptr == mFont) return 0;
00480         if (mTextOutDate) updateRawData();
00481 
00482         IntPoint point = _point;
00483         point -= mCroppedParent->getAbsolutePosition();
00484         point += mViewOffset;
00485         point -= mCoord.point();
00486 
00487         return mTextView.getCursorPosition(point);
00488     }
00489 
00490     IntCoord EditText::getCursorCoord(size_t _position)
00491     {
00492         if (nullptr == mFont) return IntCoord();
00493         if (mTextOutDate) updateRawData();
00494 
00495         IntPoint point = mTextView.getCursorPoint(_position);
00496         point += mCroppedParent->getAbsolutePosition();
00497         point -= mViewOffset;
00498         point += mCoord.point();
00499 
00500         return IntCoord(point.left, point.top, 2, mFontHeight);
00501     }
00502 
00503     void EditText::setShiftText(bool _value)
00504     {
00505         if (mShiftText == _value) return;
00506         mShiftText = _value;
00507         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00508     }
00509 
00510     void EditText::setWordWrap(bool _value)
00511     {
00512         mWordWrap = _value;
00513         mTextOutDate = true;
00514         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00515     }
00516 
00517     void EditText::updateRawData()
00518     {
00519         if (nullptr == mFont) return;
00520         // сбрасывам флаги
00521         mTextOutDate = false;
00522 
00523         int width = -1;
00524         if (mWordWrap)
00525         {
00526             width = mCoord.width;
00527             // обрезать слова нужно по шарине, которую мы реально используем
00528             if (mIsAddCursorWidth)
00529                 width -= 2;
00530         }
00531 
00532         mTextView.update(mCaption, mFont, mFontHeight, mTextAlign, mVertexFormat, width);
00533     }
00534 
00535     void EditText::setStateData(IStateInfo* _data)
00536     {
00537         EditTextStateInfo* data = _data->castType<EditTextStateInfo>();
00538         if (data->getColour() != Colour::Zero) setTextColour(data->getColour());
00539         setShiftText(data->getShift());
00540     }
00541 
00542     void EditText::doRender()
00543     {
00544         if (nullptr == mFont) return;
00545         if (!mVisible || mEmptyView) return;
00546 
00547         bool _update = mRenderItem->getCurrentUpdate();
00548         if (_update) mTextOutDate = true;
00549 
00550         if (mTextOutDate) updateRawData();
00551 
00552         Vertex* _vertex = mRenderItem->getCurrentVertextBuffer();
00553 
00554         const RenderTargetInfo& info = mRenderItem->getRenderTarget()->getInfo();
00555 
00556         // колличество отрисованных вершин
00557         size_t vertex_count = 0;
00558 
00559         // текущие цвета
00560         uint32 colour_current = mCurrentColour;
00561         uint32 colour = mCurrentColour;
00562         uint32 colour_inverse = mInverseColour;
00563 
00564         GlyphInfo* back_glyph = mFont->getGlyphInfo(mBackgroundNormal ? FontCodeType::Selected : FontCodeType::SelectedBack);
00565 
00566         float vertex_z = info.maximumDepth;
00567 
00568         const VectorLineInfo& data = mTextView.getData();
00569 
00570         int left = - mViewOffset.left + mCoord.left;
00571         int top = - mViewOffset.top + mCoord.top;
00572         int width = 0;
00573         const int height = mFontHeight;
00574 
00575         size_t index = 0;
00576         for (VectorLineInfo::const_iterator line=data.begin(); line!=data.end(); ++line)
00577         {
00578             left = line->offset - mViewOffset.left + mCoord.left;
00579             for (VectorCharInfo::const_iterator sim=line->simbols.begin(); sim!=line->simbols.end(); ++sim)
00580             {
00581                 if (sim->isColour())
00582                 {
00583                     colour = sim->getColour() | (colour & 0xFF000000);
00584                     colour_inverse = colour ^ 0x00FFFFFF;
00585                     continue;
00586                 }
00587 
00588                 // смещение текстуры для фона
00589                 bool select = !((index >= mEndSelect) || (index < mStartSelect));
00590 
00591                 uint32 back_colour = 0;
00592 
00593                 // выделение символа
00594                 if (!select || !mInvertSelect)
00595                 {
00596                     colour_current = colour;
00597                     back_colour = colour | 0x00FFFFFF;
00598                 }
00599                 else
00600                 {
00601                     colour_current = colour_inverse;
00602                     back_colour = colour_inverse;
00603                 }
00604 
00605                 bool draw = true;
00606 
00607                 // текущие размеры
00608                 MyGUI::FloatRect texture_rect = sim->getUVRect();
00609                 width = sim->getWidth();
00610 
00611                 // конечные размеры
00612                 int result_left = left;
00613                 int result_top = top;
00614                 int result_right = left + width;
00615                 int result_bottom = top + height;
00616 
00617                 float texture_width = texture_rect.right - texture_rect.left;
00618                 float texture_height = texture_rect.bottom - texture_rect.top;
00619 
00620                 // символ залазиет влево
00621                 if (left < mCurrentCoord.left)
00622                 {
00623                     // символ вообще не виден
00624                     if (left + width <= mCurrentCoord.left)
00625                     {
00626                         draw = false;
00627                     }
00628                     // символ обрезан
00629                     else
00630                     {
00631                         result_left = mCurrentCoord.left;
00632                         texture_rect.left += (texture_width * (float)(result_left - left) / (float)width);
00633                     }
00634                 }
00635 
00636                 // символ залазиет вправо
00637                 if (left + width > mCurrentCoord.right())
00638                 {
00639                     // символ вообще не виден
00640                     if (left >= mCurrentCoord.right())
00641                     {
00642                         draw = false;
00643                     }
00644                     // символ обрезан
00645                     else
00646                     {
00647                         result_right = mCurrentCoord.right();
00648                         texture_rect.right -= (texture_width * (float)((left + width) - result_right) / (float)width);
00649                     }
00650                 }
00651 
00652                 // символ залазиет вверх
00653                 if (top < mCurrentCoord.top)
00654                 {
00655                     // символ вообще не виден
00656                     if (top + height <= mCurrentCoord.top)
00657                     {
00658                         draw = false;
00659                     }
00660                     // символ обрезан
00661                     else
00662                     {
00663                         result_top = mCurrentCoord.top;
00664                         texture_rect.top += (texture_height * (float)(result_top - top) / (float)height);
00665                     }
00666                 }
00667 
00668                 // символ залазиет вниз
00669                 if (top + height > mCurrentCoord.bottom())
00670                 {
00671                     // символ вообще не виден
00672                     if (top >= mCurrentCoord.bottom())
00673                     {
00674                         draw = false;
00675                     }
00676                     // символ обрезан
00677                     else
00678                     {
00679                         result_bottom = mCurrentCoord.bottom();
00680                         texture_rect.bottom -= (texture_height * (float)((top + height) - result_bottom) / (float)height);
00681                     }
00682                 }
00683 
00684                 if (draw)
00685                 {
00686                     int pix_left = mCroppedParent->getAbsoluteLeft() - info.leftOffset + result_left;
00687                     int pix_top = mCroppedParent->getAbsoluteTop() - info.topOffset + (mShiftText ? 1 : 0) + result_top;
00688 
00689                     float real_left = ((info.pixScaleX * (float)(pix_left) + info.hOffset) * 2) - 1;
00690                     float real_top = - (((info.pixScaleY * (float)(pix_top) + info.vOffset) * 2) - 1);
00691                     float real_right = ((info.pixScaleX * (float)(pix_left + result_right - result_left) + info.hOffset) * 2) - 1;
00692                     float real_bottom = - (((info.pixScaleY * (float)(pix_top + result_bottom - result_top) + info.vOffset) * 2) - 1);
00693 
00694                     // если нужно рисуем выделение
00695                     if (select)
00696                     {
00697                         const FloatRect& background_current = back_glyph->uvRect;
00698                         DrawQuad(_vertex, real_left, real_top, real_right, real_bottom, vertex_z, back_colour,
00699                             background_current.left, background_current.top, background_current.left, background_current.top, vertex_count);
00700                     }
00701 
00702                     DrawQuad(_vertex, real_left, real_top, real_right, real_bottom, vertex_z, colour_current,
00703                         texture_rect.left, texture_rect.top, texture_rect.right, texture_rect.bottom, vertex_count);
00704                 }
00705 
00706                 left += width;
00707                 index++;
00708             }
00709 
00710             top += height;
00711             index++;
00712         }
00713 
00714         if (mVisibleCursor)
00715         {
00716             MyGUI::IntPoint point = mTextView.getCursorPoint(mCursorPosition);
00717             point -= mViewOffset;
00718             point += mCoord.point();
00719 
00720             bool draw = true;
00721 
00722             GlyphInfo* cursor_glyph = mFont->getGlyphInfo(FontCodeType::Cursor);
00723             MyGUI::FloatRect texture_rect = cursor_glyph->uvRect;
00724             left = point.left;
00725             top = point.top;
00726             width = 2;//cursor_glyph->width;
00727 
00728             // конечные размеры
00729             int result_left = left;
00730             int result_top = top;
00731             int result_width = width;
00732             int result_height = height;
00733 
00734             // символ залазиет влево
00735             if (left < mCurrentCoord.left)
00736             {
00737                 // символ вообще не виден
00738                 if (left + width <= mCurrentCoord.left)
00739                 {
00740                     draw = false;
00741                 }
00742                 // символ обрезан
00743                 else
00744                 {
00745                     result_left = mCurrentCoord.left;
00746                     result_width = width - (mCurrentCoord.left - left);
00747 
00748                     float texture_width = texture_rect.right - texture_rect.left;
00749                     texture_rect.left = texture_rect.right - (texture_width * (float)result_width / (float)width);
00750                 }
00751             }
00752 
00753             // символ залазиет вправо
00754             if (left + width > mCurrentCoord.right())
00755             {
00756                 // символ вообще не виден
00757                 if (left >= mCurrentCoord.right())
00758                 {
00759                     draw = false;
00760                 }
00761                 // символ обрезан
00762                 else
00763                 {
00764                     result_width = mCurrentCoord.right() - left;
00765 
00766                     float texture_width = texture_rect.right - texture_rect.left;
00767                     texture_rect.right = texture_rect.left + (texture_width * (float)result_width / (float)width);
00768                 }
00769             }
00770 
00771             // символ залазиет вверх
00772             if (top < mCurrentCoord.top)
00773             {
00774                 // символ вообще не виден
00775                 if (top + height <= mCurrentCoord.top)
00776                 {
00777                     draw = false;
00778                 }
00779                 // символ обрезан
00780                 else
00781                 {
00782                     result_top = mCurrentCoord.top;
00783                     result_height = height - (mCurrentCoord.top - top);
00784 
00785                     float texture_height = texture_rect.bottom - texture_rect.top;
00786                     texture_rect.top = texture_rect.bottom - (texture_height * (float)result_height / (float)height);
00787                 }
00788             }
00789 
00790             // символ залазиет вниз
00791             if (top + height > mCurrentCoord.bottom())
00792             {
00793                 // символ вообще не виден
00794                 if (top >= mCurrentCoord.bottom())
00795                 {
00796                     draw = false;
00797                 }
00798                 // символ обрезан
00799                 else
00800                 {
00801                     result_height = mCurrentCoord.bottom() - top;
00802 
00803                     float texture_height = texture_rect.bottom - texture_rect.top;
00804                     texture_rect.bottom = texture_rect.top + (texture_height * (float)result_height / (float)height);
00805                 }
00806             }
00807 
00808             if (draw)
00809             {
00810                 int pix_left = mCroppedParent->getAbsoluteLeft() - info.leftOffset + result_left;
00811                 int pix_top = mCroppedParent->getAbsoluteTop() - info.topOffset + (mShiftText ? 1 : 0) + result_top;
00812 
00813                 float real_left = ((info.pixScaleX * (float)(pix_left) + info.hOffset) * 2) - 1;
00814                 float real_top = - (((info.pixScaleY * (float)(pix_top) + info.vOffset) * 2) - 1);
00815                 float real_right = ((info.pixScaleX * (float)(pix_left + result_width) + info.hOffset) * 2) - 1;
00816                 float real_bottom = - (((info.pixScaleY * (float)(pix_top + result_height) + info.vOffset) * 2) - 1);
00817 
00818                 DrawQuad(_vertex, real_left, real_top, real_right, real_bottom, vertex_z, colour_current | 0x00FFFFFF,
00819                     texture_rect.left, texture_rect.top, texture_rect.right, texture_rect.bottom, vertex_count);
00820             }
00821         }
00822 
00823         // колличество реально отрисованных вершин
00824         mRenderItem->setLastVertexCount(vertex_count);
00825     }
00826 
00827     void EditText::setInvertSelected(bool _value)
00828     {
00829         if (mInvertSelect == _value) return;
00830         mInvertSelect = _value;
00831         if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00832     }
00833 
00834 } // namespace MyGUI