MyGUI 3.2.2

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