MyGUI 3.2.0

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_EditText.cpp
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #include "MyGUI_Precompiled.h"
23 #include "MyGUI_EditText.h"
24 #include "MyGUI_RenderItem.h"
25 #include "MyGUI_FontManager.h"
26 #include "MyGUI_RenderManager.h"
27 #include "MyGUI_LanguageManager.h"
28 #include "MyGUI_TextIterator.h"
29 #include "MyGUI_IRenderTarget.h"
30 #include "MyGUI_FontData.h"
31 #include "MyGUI_CommonStateInfo.h"
32
33 namespace MyGUI
34 {
35
36 const size_t VERTEX_IN_QUAD = 6;
37 const size_t SIMPLETEXT_COUNT_VERTEX = 32 * VERTEX_IN_QUAD;
38
39 EditText::EditText() :
40 ISubWidgetText(),
41 mEmptyView(false),
42 mCurrentColourNative(0x00FFFFFF),
43 mInverseColourNative(0x00000000),
44 mCurrentAlphaNative(0xFF000000),
45 mShadowColourNative(0x00000000),
46 mTextOutDate(false),
47 mTextAlign(Align::Default),
48 mColour(Colour::White),
49 mShadowColour(Colour::Black),
50 mAlpha(ALPHA_MAX),
51 mFont(nullptr),
52 mTexture(nullptr),
53 mFontHeight(0),
54 mBackgroundNormal(true),
55 mStartSelect(0),
56 mEndSelect(0),
57 mCursorPosition(0),
58 mVisibleCursor(false),
59 mInvertSelect(true),
60 mShadow(false),
61 mNode(nullptr),
62 mRenderItem(nullptr),
63 mCountVertex(SIMPLETEXT_COUNT_VERTEX),
64 mIsAddCursorWidth(true),
65 mShiftText(false),
66 mWordWrap(false),
67 mManualColour(false),
68 mOldWidth(0)
69 {
70 mVertexFormat = RenderManager::getInstance().getVertexFormat();
71
72 mCurrentColourNative = texture_utility::toColourARGB(mColour);
73 texture_utility::convertColour(mCurrentColourNative, mVertexFormat);
74
75 mCurrentColourNative = (mCurrentColourNative & 0x00FFFFFF) | (mCurrentAlphaNative & 0xFF000000);
76 mShadowColourNative = (mShadowColourNative & 0x00FFFFFF) | (mCurrentAlphaNative & 0xFF000000);
77 mInverseColourNative = mCurrentColourNative ^ 0x00FFFFFF;
78 }
79
80 EditText::~EditText()
81 {
82 }
83
84 void EditText::setVisible(bool _visible)
85 {
86 if (mVisible == _visible)
87 return;
88 mVisible = _visible;
89
90 if (nullptr != mNode)
91 mNode->outOfDate(mRenderItem);
92 }
93
94 void EditText::_correctView()
95 {
96 if (nullptr != mNode)
97 mNode->outOfDate(mRenderItem);
98 }
99
100 void EditText::_setAlign(const IntSize& _oldsize)
101 {
102 if (mWordWrap)
103 {
104 // передается старая координата всегда
105 int width = mCroppedParent->getWidth();
106 if (mOldWidth != width)
107 {
108 mOldWidth = width;
109 mTextOutDate = true;
110 }
111 }
112
113 // необходимо разобраться
114 bool need_update = true;//_update;
115
116 // первоначальное выравнивание
117 if (mAlign.isHStretch())
118 {
119 // растягиваем
120 mCoord.width = mCoord.width + (mCroppedParent->getWidth() - _oldsize.width);
121 need_update = true;
122 mIsMargin = true; // при изменении размеров все пересчитывать
123 }
124 else if (mAlign.isRight())
125 {
126 // двигаем по правому краю
127 mCoord.left = mCoord.left + (mCroppedParent->getWidth() - _oldsize.width);
128 need_update = true;
129 }
130 else if (mAlign.isHCenter())
131 {
132 // выравнивание по горизонтали без растяжения
133 mCoord.left = (mCroppedParent->getWidth() - mCoord.width) / 2;
134 need_update = true;
135 }
136
137 if (mAlign.isVStretch())
138 {
139 // растягиваем
140 mCoord.height = mCoord.height + (mCroppedParent->getHeight() - _oldsize.height);
141 need_update = true;
142 mIsMargin = true; // при изменении размеров все пересчитывать
143 }
144 else if (mAlign.isBottom())
145 {
146 // двигаем по нижнему краю
147 mCoord.top = mCoord.top + (mCroppedParent->getHeight() - _oldsize.height);
148 need_update = true;
149 }
150 else if (mAlign.isVCenter())
151 {
152 // выравнивание по вертикали без растяжения
153 mCoord.top = (mCroppedParent->getHeight() - mCoord.height) / 2;
154 need_update = true;
155 }
156
157 if (need_update)
158 {
159 mCurrentCoord = mCoord;
160 _updateView();
161 }
162 }
163
164 void EditText::_updateView()
165 {
166 bool margin = _checkMargin();
167
168 mEmptyView = ((0 >= _getViewWidth()) || (0 >= _getViewHeight()));
169
170 mCurrentCoord.left = mCoord.left + mMargin.left;
171 mCurrentCoord.top = mCoord.top + mMargin.top;
172
173 // вьюпорт стал битым
174 if (margin)
175 {
176 // проверка на полный выход за границу
177 if (_checkOutside())
178 {
179 // запоминаем текущее состояние
180 mIsMargin = margin;
181
182 // обновить перед выходом
183 if (nullptr != mNode)
184 mNode->outOfDate(mRenderItem);
185 return;
186 }
187 }
188
189 // мы обрезаны или были обрезаны
190 if (mIsMargin || margin)
191 {
192 mCurrentCoord.width = _getViewWidth();
193 mCurrentCoord.height = _getViewHeight();
194 }
195
196 // запоминаем текущее состояние
197 mIsMargin = margin;
198
199 if (nullptr != mNode)
200 mNode->outOfDate(mRenderItem);
201 }
202
203 void EditText::setCaption(const UString& _value)
204 {
205 mCaption = _value;
206 mTextOutDate = true;
207
208 checkVertexSize();
209
210 if (nullptr != mNode)
211 mNode->outOfDate(mRenderItem);
212 }
213
214 void EditText::checkVertexSize()
215 {
216 // если вершин не хватит, делаем реалок, с учетом выделения * 2 и курсора
217 size_t need = (mCaption.size() * (mShadow ? 3 : 2) + 2) * VERTEX_IN_QUAD;
218 if (mCountVertex < need)
219 {
220 mCountVertex = need + SIMPLETEXT_COUNT_VERTEX;
221 if (nullptr != mRenderItem)
222 mRenderItem->reallockDrawItem(this, mCountVertex);
223 }
224 }
225
226 const UString& EditText::getCaption() const
227 {
228 return mCaption;
229 }
230
231 void EditText::setTextColour(const Colour& _value)
232 {
233 mManualColour = true;
234 _setTextColour(_value);
235 }
236
237 void EditText::_setTextColour(const Colour& _value)
238 {
239 if (mColour == _value)
240 return;
241
242 mColour = _value;
243 mCurrentColourNative = texture_utility::toColourARGB(mColour);
244
245 texture_utility::convertColour(mCurrentColourNative, mVertexFormat);
246
247 mCurrentColourNative = (mCurrentColourNative & 0x00FFFFFF) | (mCurrentAlphaNative & 0xFF000000);
248 mInverseColourNative = mCurrentColourNative ^ 0x00FFFFFF;
249
250 if (nullptr != mNode)
251 mNode->outOfDate(mRenderItem);
252 }
253
254 const Colour& EditText::getTextColour() const
255 {
256 return mColour;
257 }
258
259 void EditText::setAlpha(float _value)
260 {
261 if (mAlpha == _value)
262 return;
263 mAlpha = _value;
264
265 mCurrentAlphaNative = ((uint8)(mAlpha * 255) << 24);
266 mCurrentColourNative = (mCurrentColourNative & 0x00FFFFFF) | (mCurrentAlphaNative & 0xFF000000);
267 mShadowColourNative = (mShadowColourNative & 0x00FFFFFF) | (mCurrentAlphaNative & 0xFF000000);
268 mInverseColourNative = mCurrentColourNative ^ 0x00FFFFFF;
269
270 if (nullptr != mNode)
271 mNode->outOfDate(mRenderItem);
272 }
273
274 float EditText::getAlpha() const
275 {
276 return mAlpha;
277 }
278
279 void EditText::setFontName(const std::string& _value)
280 {
281 mTexture = 0;
282 mFont = FontManager::getInstance().getByName(_value);
283 if (mFont != nullptr)
284 {
285 mTexture = mFont->getTextureFont();
286
287 // если надо, устанавливаем дефолтный размер шрифта
288 if (mFont->getDefaultHeight() != 0)
289 {
290 mFontHeight = mFont->getDefaultHeight();
291 }
292 }
293
294 mTextOutDate = true;
295
296 // если мы были приаттаченны, то удаляем себя
297 if (nullptr != mRenderItem)
298 {
299 mRenderItem->removeDrawItem(this);
300 mRenderItem = nullptr;
301 }
302
303 // если есть текстура, то приаттачиваемся
304 if (nullptr != mTexture && nullptr != mNode)
305 {
306 mRenderItem = mNode->addToRenderItem(mTexture, false, false);
307 mRenderItem->addDrawItem(this, mCountVertex);
308 }
309
310 if (nullptr != mNode) mNode->outOfDate(mRenderItem);
311 }
312
313 const std::string& EditText::getFontName() const
314 {
315 return mFont->getResourceName();
316 }
317
318 void EditText::setFontHeight(int _value)
319 {
320 mFontHeight = _value;
321 mTextOutDate = true;
322
323 if (nullptr != mNode)
324 mNode->outOfDate(mRenderItem);
325 }
326
327 int EditText::getFontHeight() const
328 {
329 return mFontHeight;
330 }
331
332 void EditText::createDrawItem(ITexture* _texture, ILayerNode* _node)
333 {
334 mNode = _node;
335 // если уже есть текстура, то атачимся, актуально для смены леера
336 if (nullptr != mTexture)
337 {
338 MYGUI_ASSERT(!mRenderItem, "mRenderItem must be nullptr");
339
340 mRenderItem = mNode->addToRenderItem(mTexture, false, false);
341 mRenderItem->addDrawItem(this, mCountVertex);
342 }
343 }
344
345 void EditText::destroyDrawItem()
346 {
347 if (nullptr != mRenderItem)
348 {
349 mRenderItem->removeDrawItem(this);
350 mRenderItem = nullptr;
351 }
352 mNode = nullptr;
353 }
354
355 size_t EditText::getTextSelectionStart() const
356 {
357 return mStartSelect;
358 }
359
360 size_t EditText::getTextSelectionEnd() const
361 {
362 return mEndSelect;
363 }
364
365 void EditText::setTextSelection(size_t _start, size_t _end)
366 {
367 mStartSelect = _start;
368 mEndSelect = _end;
369
370 if (nullptr != mNode)
371 mNode->outOfDate(mRenderItem);
372 }
373
374 bool EditText::getSelectBackground() const
375 {
376 return mBackgroundNormal;
377 }
378
379 void EditText::setSelectBackground(bool _normal)
380 {
381 if (mBackgroundNormal == _normal)
382 return;
383 mBackgroundNormal = _normal;
384
385 if (nullptr != mNode)
386 mNode->outOfDate(mRenderItem);
387 }
388
389 bool EditText::isVisibleCursor() const
390 {
391 return mVisibleCursor;
392 }
393
394 void EditText::setVisibleCursor(bool _value)
395 {
396 if (mVisibleCursor == _value)
397 return;
398 mVisibleCursor = _value;
399
400 if (nullptr != mNode)
401 mNode->outOfDate(mRenderItem);
402 }
403
404 size_t EditText::getCursorPosition() const
405 {
406 return mCursorPosition;
407 }
408
409 void EditText::setCursorPosition(size_t _index)
410 {
411 if (mCursorPosition == _index)
412 return;
413 mCursorPosition = _index;
414
415 if (nullptr != mNode)
416 mNode->outOfDate(mRenderItem);
417 }
418
419 void EditText::setTextAlign(Align _value)
420 {
421 mTextAlign = _value;
422
423 if (nullptr != mNode)
424 mNode->outOfDate(mRenderItem);
425 }
426
427 Align EditText::getTextAlign() const
428 {
429 return mTextAlign;
430 }
431
432 IntSize EditText::getTextSize()
433 {
434 // если нуно обновить, или изменились пропорции экрана
435 if (mTextOutDate)
436 updateRawData();
437
438 IntSize size = mTextView.getViewSize();
439 // плюс размер курсора
440 if (mIsAddCursorWidth)
441 size.width += 2;
442
443 if (mShadow)
444 {
445 if (!mIsAddCursorWidth)
446 size.width ++;
447 size.height ++;
448 }
449
450 return size;
451 }
452
453 void EditText::setViewOffset(const IntPoint& _point)
454 {
455 mViewOffset = _point;
456
457 if (nullptr != mNode)
458 mNode->outOfDate(mRenderItem);
459 }
460
461 IntPoint EditText::getViewOffset() const
462 {
463 return mViewOffset;
464 }
465
466 size_t EditText::getCursorPosition(const IntPoint& _point)
467 {
468 if (nullptr == mFont)
469 return 0;
470
471 if (mTextOutDate)
472 updateRawData();
473
474 IntPoint point = _point;
475 point -= mCroppedParent->getAbsolutePosition();
476 point += mViewOffset;
477 point -= mCoord.point();
478
479 return mTextView.getCursorPosition(point);
480 }
481
482 IntCoord EditText::getCursorCoord(size_t _position)
483 {
484 if (nullptr == mFont)
485 return IntCoord();
486
487 if (mTextOutDate)
488 updateRawData();
489
490 IntPoint point = mTextView.getCursorPoint(_position);
491 point += mCroppedParent->getAbsolutePosition();
492 point -= mViewOffset;
493 point += mCoord.point();
494
495 return IntCoord(point.left, point.top, 2, mFontHeight);
496 }
497
498 void EditText::setShiftText(bool _value)
499 {
500 if (mShiftText == _value)
501 return;
502 mShiftText = _value;
503
504 if (nullptr != mNode)
505 mNode->outOfDate(mRenderItem);
506 }
507
508 void EditText::setWordWrap(bool _value)
509 {
510 mWordWrap = _value;
511 mTextOutDate = true;
512
513 if (nullptr != mNode)
514 mNode->outOfDate(mRenderItem);
515 }
516
517 void EditText::updateRawData()
518 {
519 if (nullptr == mFont)
520 return;
521 // сбрасывам флаги
522 mTextOutDate = false;
523
524 int width = -1;
525 if (mWordWrap)
526 {
527 width = mCoord.width;
528 // обрезать слова нужно по шарине, которую мы реально используем
529 if (mIsAddCursorWidth)
530 width -= 2;
531 }
532
533 mTextView.update(mCaption, mFont, mFontHeight, mTextAlign, mVertexFormat, width);
534 }
535
536 void EditText::setStateData(IStateInfo* _data)
537 {
538 EditTextStateInfo* data = _data->castType<EditTextStateInfo>();
539 if (!mManualColour && data->getColour() != Colour::Zero)
540 _setTextColour(data->getColour());
541 setShiftText(data->getShift());
542 }
543
544 void EditText::doRender()
545 {
546 if (nullptr == mFont || !mVisible || mEmptyView)
547 return;
548
549 if (mRenderItem->getCurrentUpdate() || mTextOutDate)
550 updateRawData();
551
552 Vertex* vertex = mRenderItem->getCurrentVertexBuffer();
553
554 const RenderTargetInfo& renderTargetInfo = mRenderItem->getRenderTarget()->getInfo();
555
556 // колличество отрисованных вершин
557 size_t vertexCount = 0;
558
559 // текущие цвета
560 uint32 colour = mCurrentColourNative;
561 uint32 inverseColour = mInverseColourNative;
562 uint32 selectedColour = mInvertSelect ? inverseColour : colour | 0x00FFFFFF;
563
564 const VectorLineInfo& textViewData = mTextView.getData();
565
566 float top = (float)(-mViewOffset.top + mCoord.top);
567
568 FloatRect vertexRect;
569
570 const FloatRect& selectedUVRect = mFont->getGlyphInfo(mBackgroundNormal ? FontCodeType::Selected : FontCodeType::SelectedBack)->uvRect;
571
572 size_t index = 0;
573
574 for (VectorLineInfo::const_iterator line = textViewData.begin(); line != textViewData.end(); ++line)
575 {
576 float left = (float)(line->offset - mViewOffset.left + mCoord.left);
577
578 for (VectorCharInfo::const_iterator sim = line->simbols.begin(); sim != line->simbols.end(); ++sim)
579 {
580 if (sim->isColour())
581 {
582 colour = sim->getColour() | (colour & 0xFF000000);
583 inverseColour = colour ^ 0x00FFFFFF;
584 selectedColour = mInvertSelect ? inverseColour : colour | 0x00FFFFFF;
585 continue;
586 }
587
588 // смещение текстуры для фона
589 bool select = index >= mStartSelect && index < mEndSelect;
590
591 float fullAdvance = sim->getBearingX() + sim->getAdvance();
592
593 // Render the selection, if any, first.
594 if (select)
595 {
596 vertexRect.set(left, top, left + fullAdvance, top + (float)mFontHeight);
597
598 drawGlyph(renderTargetInfo, vertex, vertexCount, vertexRect, selectedUVRect, selectedColour);
599 }
600
601 // Render the glyph shadow, if any.
602 if (mShadow)
603 {
604 vertexRect.left = left + sim->getBearingX() + 1.0f;
605 vertexRect.top = top + sim->getBearingY() + 1.0f;
606 vertexRect.right = vertexRect.left + sim->getWidth();
607 vertexRect.bottom = vertexRect.top + sim->getHeight();
608
609 drawGlyph(renderTargetInfo, vertex, vertexCount, vertexRect, sim->getUVRect(), mShadowColourNative);
610 }
611
612 // Render the glyph itself.
613 vertexRect.left = left + sim->getBearingX();
614 vertexRect.top = top + sim->getBearingY();
615 vertexRect.right = vertexRect.left + sim->getWidth();
616 vertexRect.bottom = vertexRect.top + sim->getHeight();
617
618 drawGlyph(renderTargetInfo, vertex, vertexCount, vertexRect, sim->getUVRect(), (!select || !mInvertSelect) ? colour : inverseColour);
619
620 left += fullAdvance;
621 ++index;
622 }
623
624 top += mFontHeight;
625 ++index;
626 }
627
628 // Render the cursor, if any, last.
629 if (mVisibleCursor)
630 {
631 IntPoint point = mTextView.getCursorPoint(mCursorPosition) - mViewOffset + mCoord.point();
632 GlyphInfo* cursorGlyph = mFont->getGlyphInfo(FontCodeType::Cursor);
633 vertexRect.set((float)point.left, (float)point.top, (float)point.left + cursorGlyph->width, (float)(point.top + mFontHeight));
634
635 drawGlyph(renderTargetInfo, vertex, vertexCount, vertexRect, cursorGlyph->uvRect, mCurrentColourNative | 0x00FFFFFF);
636 }
637
638 // колличество реально отрисованных вершин
639 mRenderItem->setLastVertexCount(vertexCount);
640 }
641
642 void EditText::setInvertSelected(bool _value)
643 {
644 if (mInvertSelect == _value)
645 return;
646 mInvertSelect = _value;
647
648 if (nullptr != mNode)
649 mNode->outOfDate(mRenderItem);
650 }
651
652 bool EditText::getInvertSelected() const
653 {
654 return mInvertSelect;
655 }
656
657 bool EditText::getShadow() const
658 {
659 return mShadow;
660 }
661
662 void EditText::setShadow(bool _value)
663 {
664 mShadow = _value;
665 mTextOutDate = true;
666
667 checkVertexSize();
668
669 if (nullptr != mNode)
670 mNode->outOfDate(mRenderItem);
671 }
672
673 void EditText::setShadowColour(const Colour& _value)
674 {
675 mShadowColour = _value;
676 mShadowColourNative = texture_utility::toColourARGB(mShadowColour);
677
678 texture_utility::convertColour(mShadowColourNative, mVertexFormat);
679
680 mShadowColourNative = (mShadowColourNative & 0x00FFFFFF) | (mCurrentAlphaNative & 0xFF000000);
681
682 if (nullptr != mNode)
683 mNode->outOfDate(mRenderItem);
684 }
685
686 const Colour& EditText::getShadowColour() const
687 {
688 return mShadowColour;
689 }
690
691 void EditText::drawQuad(
692 Vertex*& _vertex,
693 size_t& _vertexCount,
694 const FloatRect& _vertexRect,
695 float _vertexZ,
696 const FloatRect& _textureRect,
697 uint32 _colour) const
698 {
699 _vertex[0].x = _vertexRect.left;
700 _vertex[0].y = _vertexRect.top;
701 _vertex[0].z = _vertexZ;
702 _vertex[0].colour = _colour;
703 _vertex[0].u = _textureRect.left;
704 _vertex[0].v = _textureRect.top;
705
706 _vertex[1].x = _vertexRect.left;
707 _vertex[1].y = _vertexRect.bottom;
708 _vertex[1].z = _vertexZ;
709 _vertex[1].colour = _colour;
710 _vertex[1].u = _textureRect.left;
711 _vertex[1].v = _textureRect.bottom;
712
713 _vertex[2].x = _vertexRect.right;
714 _vertex[2].y = _vertexRect.top;
715 _vertex[2].z = _vertexZ;
716 _vertex[2].colour = _colour;
717 _vertex[2].u = _textureRect.right;
718 _vertex[2].v = _textureRect.top;
719
720 _vertex[3].x = _vertexRect.right;
721 _vertex[3].y = _vertexRect.top;
722 _vertex[3].z = _vertexZ;
723 _vertex[3].colour = _colour;
724 _vertex[3].u = _textureRect.right;
725 _vertex[3].v = _textureRect.top;
726
727 _vertex[4].x = _vertexRect.left;
728 _vertex[4].y = _vertexRect.bottom;
729 _vertex[4].z = _vertexZ;
730 _vertex[4].colour = _colour;
731 _vertex[4].u = _textureRect.left;
732 _vertex[4].v = _textureRect.bottom;
733
734 _vertex[5].x = _vertexRect.right;
735 _vertex[5].y = _vertexRect.bottom;
736 _vertex[5].z = _vertexZ;
737 _vertex[5].colour = _colour;
738 _vertex[5].u = _textureRect.right;
739 _vertex[5].v = _textureRect.bottom;
740
741 _vertex += VERTEX_IN_QUAD;
742 _vertexCount += VERTEX_IN_QUAD;
743 }
744
745 void EditText::drawGlyph(
746 const RenderTargetInfo& _renderTargetInfo,
747 Vertex*& _vertex,
748 size_t& _vertexCount,
749 FloatRect _vertexRect,
750 FloatRect _textureRect,
751 uint32 _colour) const
752 {
753 // символ залазиет влево
754 float leftClip = (float)mCurrentCoord.left - _vertexRect.left;
755 if (leftClip > 0.0f)
756 {
757 if ((float)mCurrentCoord.left < _vertexRect.right)
758 {
759 _textureRect.left += _textureRect.width() * leftClip / _vertexRect.width();
760 _vertexRect.left += leftClip;
761 }
762 else
763 {
764 return;
765 }
766 }
767
768 // символ залазиет вправо
769 float rightClip = _vertexRect.right - (float)mCurrentCoord.right();
770 if (rightClip > 0.0f)
771 {
772 if (_vertexRect.left < (float)mCurrentCoord.right())
773 {
774 _textureRect.right -= _textureRect.width() * rightClip / _vertexRect.width();
775 _vertexRect.right -= rightClip;
776 }
777 else
778 {
779 return;
780 }
781 }
782
783 // символ залазиет вверх
784 float topClip = (float)mCurrentCoord.top - _vertexRect.top;
785 if (topClip > 0.0f)
786 {
787 if ((float)mCurrentCoord.top < _vertexRect.bottom)
788 {
789 _textureRect.top += _textureRect.height() * topClip / _vertexRect.height();
790 _vertexRect.top += topClip;
791 }
792 else
793 {
794 return;
795 }
796 }
797
798 // символ залазиет вниз
799 float bottomClip = _vertexRect.bottom - (float)mCurrentCoord.bottom();
800 if (bottomClip > 0.0f)
801 {
802 if (_vertexRect.top < (float)mCurrentCoord.bottom())
803 {
804 _textureRect.bottom -= _textureRect.height() * bottomClip / _vertexRect.height();
805 _vertexRect.bottom -= bottomClip;
806 }
807 else
808 {
809 return;
810 }
811 }
812
813 float pix_left = mCroppedParent->getAbsoluteLeft() - _renderTargetInfo.leftOffset + _vertexRect.left;
814 float pix_top = mCroppedParent->getAbsoluteTop() - _renderTargetInfo.topOffset + (mShiftText ? 1.0f : 0.0f) + _vertexRect.top;
815
816 FloatRect vertexRect(
817 ((_renderTargetInfo.pixScaleX * pix_left + _renderTargetInfo.hOffset) * 2.0f) - 1.0f,
818 -(((_renderTargetInfo.pixScaleY * pix_top + _renderTargetInfo.vOffset) * 2.0f) - 1.0f),
819 ((_renderTargetInfo.pixScaleX * (pix_left + _vertexRect.width()) + _renderTargetInfo.hOffset) * 2.0f) - 1.0f,
820 -(((_renderTargetInfo.pixScaleY * (pix_top + _vertexRect.height()) + _renderTargetInfo.vOffset) * 2.0f) - 1.0f));
821
822 drawQuad(_vertex, _vertexCount, vertexRect, _renderTargetInfo.maximumDepth, _textureRect, _colour);
823 }
824
825 } // namespace MyGUI
MyGUI::ICroppedRectangle::getAbsoluteLeft
int getAbsoluteLeft() const
Definition: MyGUI_ICroppedRectangle.h:98
MyGUI::types::TCoord< int >
MyGUI::EditText::getViewOffset
virtual IntPoint getViewOffset() const
Definition: MyGUI_EditText.cpp:461
MyGUI::EditText::mIsAddCursorWidth
bool mIsAddCursorWidth
Definition: MyGUI_EditText.h:182
MyGUI::EditText::mInverseColourNative
uint32 mInverseColourNative
Definition: MyGUI_EditText.h:151
MyGUI::EditText::mOldWidth
int mOldWidth
Definition: MyGUI_EditText.h:187
MyGUI::TextView::getViewSize
const IntSize & getViewSize() const
Definition: MyGUI_TextView.cpp:388
MyGUI::EditText::setShiftText
virtual void setShiftText(bool _shift)
Definition: MyGUI_EditText.cpp:498
MyGUI::IFont::getTextureFont
virtual ITexture * getTextureFont()=0
MyGUI::EditText::mNode
ILayerNode * mNode
Definition: MyGUI_EditText.h:179
MyGUI::Vertex::y
float y
Definition: MyGUI_VertexData.h:43
MyGUI::Align::isVStretch
bool isVStretch() const
Definition: MyGUI_Align.h:99
MyGUI::EditText::setSelectBackground
virtual void setSelectBackground(bool _normal)
Definition: MyGUI_EditText.cpp:379
MyGUI::EditText::mFontHeight
int mFontHeight
Definition: MyGUI_EditText.h:167
MyGUI::FontCodeType::SelectedBack
Definition: MyGUI_FontData.h:45
MyGUI::EditText::setTextColour
void setTextColour(const Colour &_value)
Definition: MyGUI_EditText.cpp:231
MyGUI::uint32
unsigned int uint32
Definition: MyGUI_Types.h:63
MyGUI::ILayerNode::outOfDate
virtual void outOfDate(RenderItem *_item)=0
MyGUI::EditText::setCursorPosition
virtual void setCursorPosition(size_t _index)
Definition: MyGUI_EditText.cpp:409
MyGUI::types::TPoint< int >
MyGUI::ILayerNode
Definition: MyGUI_ILayerNode.h:42
MyGUI::EditText::getShadow
virtual bool getShadow() const
Definition: MyGUI_EditText.cpp:657
MyGUI::RenderItem::removeDrawItem
void removeDrawItem(ISubWidget *_item)
Definition: MyGUI_RenderItem.cpp:113
MyGUI::EditText::setWordWrap
virtual void setWordWrap(bool _value)
Definition: MyGUI_EditText.cpp:508
MyGUI::types::TRect::top
T top
Definition: MyGUI_TRect.h:36
MyGUI::EditText::createDrawItem
virtual void createDrawItem(ITexture *_texture, ILayerNode *_node)
Definition: MyGUI_EditText.cpp:332
MyGUI::RenderItem::addDrawItem
void addDrawItem(ISubWidget *_item, size_t _count)
Definition: MyGUI_RenderItem.cpp:138
MyGUI::EditText::getCursorCoord
virtual IntCoord getCursorCoord(size_t _position)
Definition: MyGUI_EditText.cpp:482
MyGUI_Precompiled.h
MyGUI::ICroppedRectangle::_getViewHeight
int _getViewHeight() const
Definition: MyGUI_ICroppedRectangle.h:168
MyGUI::ICroppedRectangle::mIsMargin
bool mIsMargin
Definition: MyGUI_ICroppedRectangle.h:263
MyGUI::ICroppedRectangle::getHeight
int getHeight() const
Definition: MyGUI_ICroppedRectangle.h:134
MyGUI::EditText::setTextSelection
virtual void setTextSelection(size_t _start, size_t _end)
Definition: MyGUI_EditText.cpp:365
MyGUI::RenderItem::getRenderTarget
IRenderTarget * getRenderTarget()
Definition: MyGUI_RenderItem.cpp:250
MyGUI::Align::isBottom
bool isBottom() const
Definition: MyGUI_Align.h:94
MyGUI::texture_utility::convertColour
__inline void convertColour(uint32 &_colour, VertexColourType _format)
Definition: MyGUI_TextureUtility.h:38
MyGUI::IStateInfo
Definition: MyGUI_IStateInfo.h:31
MyGUI::types::TSize< int >
MyGUI::EditText::getFontName
virtual const std::string & getFontName() const
Definition: MyGUI_EditText.cpp:313
MyGUI_IRenderTarget.h
MyGUI::VectorLineInfo
std::vector< LineInfo > VectorLineInfo
Definition: MyGUI_TextViewData.h:136
MyGUI::Singleton< RenderManager >::getInstance
static RenderManager & getInstance()
Definition: MyGUI_Singleton.h:53
MyGUI::EditText::mBackgroundNormal
bool mBackgroundNormal
Definition: MyGUI_EditText.h:169
MyGUI::Align::isVCenter
bool isVCenter() const
Definition: MyGUI_Align.h:64
MyGUI::EditText::setVisibleCursor
virtual void setVisibleCursor(bool _value)
Definition: MyGUI_EditText.cpp:394
MyGUI::EditText::mManualColour
bool mManualColour
Definition: MyGUI_EditText.h:186
MyGUI::EditText::getCursorPosition
virtual size_t getCursorPosition() const
Definition: MyGUI_EditText.cpp:404
MyGUI::EditText::mCursorPosition
size_t mCursorPosition
Definition: MyGUI_EditText.h:172
MyGUI::Vertex::colour
uint32 colour
Definition: MyGUI_VertexData.h:44
MyGUI::TextView::getData
const VectorLineInfo & getData() const
Definition: MyGUI_TextView.cpp:398
MyGUI::EditText::setShadow
virtual void setShadow(bool _value)
Definition: MyGUI_EditText.cpp:662
MyGUI::EditTextStateInfo::getColour
const Colour & getColour() const
Definition: MyGUI_CommonStateInfo.h:148
MyGUI::ICroppedRectangle::mCroppedParent
ICroppedRectangle * mCroppedParent
Definition: MyGUI_ICroppedRectangle.h:264
MyGUI::RenderManager::getVertexFormat
virtual VertexColourType getVertexFormat()=0
MyGUI::EditText::setViewOffset
virtual void setViewOffset(const IntPoint &_point)
Definition: MyGUI_EditText.cpp:453
MyGUI::ICroppedRectangle::getAbsoluteTop
int getAbsoluteTop() const
Definition: MyGUI_ICroppedRectangle.h:103
MyGUI::Vertex::u
float u
Definition: MyGUI_VertexData.h:45
MyGUI::Vertex::x
float x
Definition: MyGUI_VertexData.h:43
MyGUI::EditText::mAlpha
float mAlpha
Definition: MyGUI_EditText.h:162
MyGUI::EditText::mVertexFormat
VertexColourType mVertexFormat
Definition: MyGUI_EditText.h:163
MyGUI::IResource::getResourceName
const std::string & getResourceName() const
Definition: MyGUI_IResource.h:47
MyGUI::EditText::destroyDrawItem
virtual void destroyDrawItem()
Definition: MyGUI_EditText.cpp:345
MyGUI::EditText::getShadowColour
virtual const Colour & getShadowColour() const
Definition: MyGUI_EditText.cpp:686
nullptr
#define nullptr
Definition: MyGUI_Prerequest.h:47
MyGUI::Align::isHCenter
bool isHCenter() const
Definition: MyGUI_Align.h:59
MyGUI::types::TPoint::top
T top
Definition: MyGUI_TPoint.h:36
MyGUI::EditText::mCurrentAlphaNative
uint32 mCurrentAlphaNative
Definition: MyGUI_EditText.h:152
MyGUI::EditText::mRenderItem
RenderItem * mRenderItem
Definition: MyGUI_EditText.h:180
MyGUI::types::TCoord::width
T width
Definition: MyGUI_TCoord.h:39
MyGUI::EditText::mEndSelect
size_t mEndSelect
Definition: MyGUI_EditText.h:171
MyGUI_LanguageManager.h
MyGUI::EditText::getTextSelectionStart
virtual size_t getTextSelectionStart() const
Definition: MyGUI_EditText.cpp:355
MyGUI::GlyphInfo::uvRect
FloatRect uvRect
Definition: MyGUI_FontData.h:79
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition: MyGUI_Types.h:50
MyGUI::ILayerNode::addToRenderItem
virtual RenderItem * addToRenderItem(ITexture *_texture, bool _firstQueue, bool _separate)=0
MyGUI::ICroppedRectangle::mCoord
IntCoord mCoord
Definition: MyGUI_ICroppedRectangle.h:260
MyGUI::EditText::getAlpha
float getAlpha() const
Definition: MyGUI_EditText.cpp:274
MyGUI_FontData.h
MyGUI::EditText::mInvertSelect
bool mInvertSelect
Definition: MyGUI_EditText.h:174
MyGUI::EditText::mShadowColour
Colour mShadowColour
Definition: MyGUI_EditText.h:161
MyGUI::types::TCoord::top
T top
Definition: MyGUI_TCoord.h:38
MyGUI::EditText::mCurrentCoord
IntCoord mCurrentCoord
Definition: MyGUI_EditText.h:154
MyGUI_FontManager.h
MyGUI::SIMPLETEXT_COUNT_VERTEX
const size_t SIMPLETEXT_COUNT_VERTEX
Definition: MyGUI_EditText.cpp:37
MyGUI::EditText::setVisible
virtual void setVisible(bool _value)
Definition: MyGUI_EditText.cpp:84
MyGUI::EditText::isVisibleCursor
virtual bool isVisibleCursor() const
Definition: MyGUI_EditText.cpp:389
MyGUI::EditText::mCountVertex
size_t mCountVertex
Definition: MyGUI_EditText.h:181
MyGUI::EditText::_updateView
virtual void _updateView()
Definition: MyGUI_EditText.cpp:164
MyGUI::types::TRect::left
T left
Definition: MyGUI_TRect.h:35
MyGUI::EditText::getFontHeight
virtual int getFontHeight() const
Definition: MyGUI_EditText.cpp:327
MyGUI::EditText::setFontHeight
virtual void setFontHeight(int _value)
Definition: MyGUI_EditText.cpp:318
MyGUI::EditText::mCurrentColourNative
uint32 mCurrentColourNative
Definition: MyGUI_EditText.h:150
MyGUI::EditText::mShadow
bool mShadow
Definition: MyGUI_EditText.h:175
MyGUI_RenderManager.h
MyGUI::ICroppedRectangle::mMargin
IntRect mMargin
Definition: MyGUI_ICroppedRectangle.h:259
MyGUI::EditText::mTextOutDate
bool mTextOutDate
Definition: MyGUI_EditText.h:157
MyGUI::EditTextStateInfo
Definition: MyGUI_CommonStateInfo.h:134
MyGUI::RenderItem::getCurrentVertexBuffer
Vertex * getCurrentVertexBuffer() const
Definition: MyGUI_RenderItem.cpp:240
MyGUI::EditText::mTextAlign
Align mTextAlign
Definition: MyGUI_EditText.h:158
MyGUI::ALPHA_MAX
const float ALPHA_MAX
Definition: MyGUI_Macros.h:34
MyGUI::types::TPoint::left
T left
Definition: MyGUI_TPoint.h:35
MyGUI::ICroppedRectangle::getWidth
int getWidth() const
Definition: MyGUI_ICroppedRectangle.h:129
MyGUI::EditText::setCaption
void setCaption(const UString &_value)
Definition: MyGUI_EditText.cpp:203
MyGUI::ICroppedRectangle::getAbsolutePosition
const IntPoint & getAbsolutePosition() const
Definition: MyGUI_ICroppedRectangle.h:82
MyGUI::types::TCoord::right
T right() const
Definition: MyGUI_TCoord.h:165
MyGUI::types::TRect< float >
MyGUI::ICroppedRectangle::_getViewWidth
int _getViewWidth() const
Definition: MyGUI_ICroppedRectangle.h:164
MyGUI::EditText::mTexture
ITexture * mTexture
Definition: MyGUI_EditText.h:166
MyGUI::EditText::mFont
IFont * mFont
Definition: MyGUI_EditText.h:165
MyGUI::types::TSize::width
T width
Definition: MyGUI_TSize.h:35
MyGUI::EditText::getTextColour
const Colour & getTextColour() const
Definition: MyGUI_EditText.cpp:254
MyGUI::ISubWidget::mVisible
bool mVisible
Definition: MyGUI_ISubWidget.h:76
MyGUI::types::TCoord::bottom
T bottom() const
Definition: MyGUI_TCoord.h:170
MyGUI_CommonStateInfo.h
MyGUI_RenderItem.h
MyGUI::EditText::getTextSelectionEnd
virtual size_t getTextSelectionEnd() const
Definition: MyGUI_EditText.cpp:360
MyGUI::Align::isRight
bool isRight() const
Definition: MyGUI_Align.h:79
MyGUI::RenderItem::reallockDrawItem
void reallockDrawItem(ISubWidget *_item, size_t _count)
Definition: MyGUI_RenderItem.cpp:156
MyGUI::EditText::EditText
EditText()
Definition: MyGUI_EditText.cpp:39
MyGUI::ICroppedRectangle::_checkOutside
bool _checkOutside() const
Definition: MyGUI_ICroppedRectangle.h:250
MYGUI_ASSERT
#define MYGUI_ASSERT(exp, dest)
Definition: MyGUI_Diagnostic.h:58
MyGUI::ITexture
Definition: MyGUI_ITexture.h:41
MyGUI::EditText::mCaption
UString mCaption
Definition: MyGUI_EditText.h:156
MyGUI::EditText::getTextAlign
virtual Align getTextAlign() const
Definition: MyGUI_EditText.cpp:427
MyGUI::EditText::mShiftText
bool mShiftText
Definition: MyGUI_EditText.h:184
MyGUI::EditText::getCaption
const UString & getCaption() const
Definition: MyGUI_EditText.cpp:226
MyGUI::GlyphInfo::width
float width
Definition: MyGUI_FontData.h:74
MyGUI::VERTEX_IN_QUAD
const size_t VERTEX_IN_QUAD
Definition: MyGUI_EditText.cpp:36
MyGUI::IRenderTarget::getInfo
virtual const RenderTargetInfo & getInfo()=0
MyGUI::texture_utility::toColourARGB
uint32 toColourARGB(const Colour &_colour)
Definition: MyGUI_TextureUtility.cpp:83
MyGUI::EditText::_correctView
virtual void _correctView()
Definition: MyGUI_EditText.cpp:94
MyGUI::EditText::mTextView
TextView mTextView
Definition: MyGUI_EditText.h:189
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition: MyGUI_IObject.h:33
MyGUI::TextView::getCursorPosition
size_t getCursorPosition(const IntPoint &_value)
Definition: MyGUI_TextView.cpp:309
MyGUI::types::TRect::set
void set(T const &_left, T const &_top, T const &_right, T const &_bottom)
Definition: MyGUI_TRect.h:136
MyGUI::GlyphInfo
Definition: MyGUI_FontData.h:53
MyGUI::FloatRect
types::TRect< float > FloatRect
Definition: MyGUI_Types.h:48
MyGUI::EditText::mColour
Colour mColour
Definition: MyGUI_EditText.h:160
MyGUI::EditText::getInvertSelected
virtual bool getInvertSelected() const
Definition: MyGUI_EditText.cpp:652
MyGUI::ISubWidget::mAlign
Align mAlign
Definition: MyGUI_ISubWidget.h:75
MyGUI::EditText::updateRawData
virtual void updateRawData()
Definition: MyGUI_EditText.cpp:517
MyGUI::EditText::getTextSize
virtual IntSize getTextSize()
Definition: MyGUI_EditText.cpp:432
MyGUI::EditText::mWordWrap
bool mWordWrap
Definition: MyGUI_EditText.h:185
MyGUI::EditText::setStateData
virtual void setStateData(IStateInfo *_data)
Definition: MyGUI_EditText.cpp:536
MyGUI::FontManager::getByName
IFont * getByName(const std::string &_name) const
Definition: MyGUI_FontManager.cpp:206
MyGUI::FontCodeType::Cursor
Definition: MyGUI_FontData.h:46
MyGUI::EditText::mViewOffset
IntPoint mViewOffset
Definition: MyGUI_EditText.h:177
MyGUI::EditText::mEmptyView
bool mEmptyView
Definition: MyGUI_EditText.h:149
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition: MyGUI_UString.h:169
MyGUI::ISubWidgetText
Definition: MyGUI_ISubWidgetText.h:32
MyGUI::TextView::getCursorPoint
IntPoint getCursorPoint(size_t _position)
Definition: MyGUI_TextView.cpp:356
MyGUI::RenderTargetInfo
Definition: MyGUI_RenderTargetInfo.h:30
MyGUI::EditText::_setAlign
virtual void _setAlign(const IntSize &_oldsize)
Definition: MyGUI_EditText.cpp:100
MyGUI_EditText.h
MyGUI::IFont::getDefaultHeight
virtual int getDefaultHeight()=0
MyGUI::Align
Definition: MyGUI_Align.h:34
MyGUI::EditText::~EditText
virtual ~EditText()
Definition: MyGUI_EditText.cpp:80
MyGUI::Colour
Definition: MyGUI_Colour.h:31
MyGUI::EditText::doRender
virtual void doRender()
Definition: MyGUI_EditText.cpp:544
MyGUI::Vertex::v
float v
Definition: MyGUI_VertexData.h:45
MyGUI::EditText::setInvertSelected
virtual void setInvertSelected(bool _value)
Definition: MyGUI_EditText.cpp:642
MyGUI::EditText::mShadowColourNative
uint32 mShadowColourNative
Definition: MyGUI_EditText.h:153
MyGUI::Vertex
Definition: MyGUI_VertexData.h:31
MyGUI::EditText::getSelectBackground
virtual bool getSelectBackground() const
Definition: MyGUI_EditText.cpp:374
MyGUI::UString::size
size_type size() const
Returns the number of code points in the current string.
Definition: MyGUI_UString.cpp:601
MyGUI::types::TSize::height
T height
Definition: MyGUI_TSize.h:36
MyGUI::EditTextStateInfo::getShift
bool getShift() const
Definition: MyGUI_CommonStateInfo.h:153
MyGUI::EditText::setTextAlign
virtual void setTextAlign(Align _value)
Definition: MyGUI_EditText.cpp:419
MyGUI::types::TCoord::left
T left
Definition: MyGUI_TCoord.h:37
MyGUI::types::TRect::right
T right
Definition: MyGUI_TRect.h:37
MyGUI::Align::isHStretch
bool isHStretch() const
Definition: MyGUI_Align.h:84
MyGUI::EditText::mStartSelect
size_t mStartSelect
Definition: MyGUI_EditText.h:170
MyGUI::Colour::Zero
static const Colour Zero
Definition: MyGUI_Colour.h:69
MyGUI::uint8
unsigned char uint8
Definition: MyGUI_Types.h:61
MyGUI::types::TRect::bottom
T bottom
Definition: MyGUI_TRect.h:38
MyGUI::IFont::getGlyphInfo
virtual GlyphInfo * getGlyphInfo(Char _id)=0
MyGUI::ICroppedRectangle::_checkMargin
bool _checkMargin()
Definition: MyGUI_ICroppedRectangle.h:200
MyGUI::RenderItem::getCurrentUpdate
bool getCurrentUpdate() const
Definition: MyGUI_RenderItem.cpp:235
MyGUI::EditText::setFontName
virtual void setFontName(const std::string &_value)
Definition: MyGUI_EditText.cpp:279
MyGUI::RenderItem::setLastVertexCount
void setLastVertexCount(size_t _count)
Definition: MyGUI_RenderItem.cpp:245
MyGUI::TextView::update
void update(const UString &_text, IFont *_font, int _height, Align _align, VertexColourType _format, int _maxWidth=-1)
Definition: MyGUI_TextView.cpp:115
MyGUI::EditText::setShadowColour
virtual void setShadowColour(const Colour &_value)
Definition: MyGUI_EditText.cpp:673
MyGUI::types::TCoord::height
T height
Definition: MyGUI_TCoord.h:40
MyGUI::types::TCoord::point
TPoint< T > point() const
Definition: MyGUI_TCoord.h:200
MyGUI_TextIterator.h
MyGUI::EditText::mVisibleCursor
bool mVisibleCursor
Definition: MyGUI_EditText.h:173
MyGUI::FontCodeType::Selected
Definition: MyGUI_FontData.h:44
MyGUI::Vertex::z
float z
Definition: MyGUI_VertexData.h:43
MyGUI::EditText::setAlpha
void setAlpha(float _value)
Definition: MyGUI_EditText.cpp:259