Guiliani  Version 2.5 revision 7293 (documentation build 13)
GUIEditableText.h
1/*
2* Copyright (C) TES Electronic Solutions GmbH,
3* All Rights Reserved.
4* Contact: info@guiliani.de
5*
6* This file is part of the Guiliani HMI framework
7* for the development of graphical user interfaces on embedded systems.
8*/
9
10#if !defined(GUIEDITABLETEXT__H_)
11#define GUIEDITABLETEXT__H_
12
13#include "GUIText.h"
14
15#include "GUIPropertyResource.h"
16#include "GUIRect.h"
17#include "eC_TList_doubleLinked.h"
18#include"eC_TList.h"
19#include "bidi.h"
20
22
61{
62public:
65 {
71 eC_UInt uiCharIndex = 0,
72 eC_UInt uiLineIndex = 0) :
73 m_uiCharIndex(uiCharIndex),
74 m_uiLineIndex(uiLineIndex)
75 {}
76
77 eC_UInt m_uiCharIndex;
78 eC_UInt m_uiLineIndex;
79 };
80
85 {
87 eC_TList<eC_UInt> fromRtLIndex;
89 eC_TList<eC_UInt> fromLtRIndex;
93 eC_TList<LeftEmbedding> leftEmbeddingLevels;
97 eC_TList<RightEmbedding> rightEmbeddingLevels;
98 };
100
114 const CGUIObject* const pkParentObject,
115 const eC_String &kText,
116 const eC_Value& vXPos = eC_FromInt(0),
117 const eC_Value& vYPos = eC_FromInt(0),
118 const eC_Value& vTextWidth = eC_FromInt(0),
119 eC_Bool bWordWrap = false);
120
134 const CGUIObject* const pkParentObject,
135 const eC_String* const pkText,
136 const eC_Value& vXPos = eC_FromInt(0),
137 const eC_Value& vYPos = eC_FromInt(0),
138 const eC_Value& vTextWidth = eC_FromInt(0),
139 eC_Bool bWordWrap = false);
140
154 const CGUIObject* const pkParentObject,
155 const TextResource_t &eTextID,
156 const eC_Value& vXPos = eC_FromInt(0),
157 const eC_Value& vYPos = eC_FromInt(0),
158 const eC_Value& vTextWidth = eC_FromInt(0),
159 eC_Bool bWordWrap = false);
160
165
169
175
181 void Insert(const eC_String& kInsChars);
182
190 void Delete(
191 eC_UInt uiCursorPosAtStartLine,
192 eC_UInt uiCursorPosAtEndLine,
193 eC_UInt uiStartLine = 0,
194 eC_UInt uiEndLine = 0);
195
204 virtual void PrintText();
205
210
215 virtual const eC_String* const GetPassword();
216
222
228
235
243
251 virtual void SetTextString(const eC_String& rkTextString);
252
259 eC_UInt uiCursorPosAtLine,
260 eC_UInt uiCurrentLine = 0);
261
269 CursorPos_t GetBestCursorPosition(const eC_Value& vRelXPos, const eC_Value& vRelYPos);
270
274
279 eC_UInt GetLtrTurnPnt(eC_UInt currentIndex);
280
285 eC_UInt GetRtlTurnPnt(eC_UInt currentIndex);
286
291 eC_Bool IsInLtRField(eC_UInt currentIndex);
292
298 eC_Bool GetLTRpivotField(eC_UInt currentIndex, LeftEmbedding& ltrPivotPair);
299
305 eC_Bool GetRectOfIndex(eC_UInt uiIndex, CGUIRect& rect);
306
310 void SetEmbeddingDirection(const eC_Bool bRightToLeft);
311
316
320 eC_Bool HasSelection();
321
324 void SelectAll();
325
332 void SetWordWrap(eC_Bool bWordWrap, const eC_Value& vWidth = eC_FromInt(0));
333
340
347 void ExtendSelection(eC_UInt uiCharIndex, eC_UInt uiLineIndex = 0);
348
353
358 void SetCursorVisible(eC_Bool bVisible);
359
365
369 eC_Bool IsCursorVisible() const;
370
374 void SetCursorWidth(eC_Value vWidth);
375
379 eC_Value GetCursorWidth() const;
380
384 void SetSelectionColor(const eC_UInt& uiSelectionColor);
385
389 void SetSelectionColor(const GlobalProperty_t& uiSelectionColor);
390
394 eC_UInt GetSelectionColor() const;
395
399 virtual void SetFont(const FontResource_t &eFontID);
400
406 void SetPasswordCharacter(eC_String& kPwdStr);
407
411 void SetPasswordMode(eC_Bool bPasswordMode);
412
419
424 eC_String GetStrOfLine(eC_UInt uiCurrentLine) const;
425
429 eC_String GetSelectedText();
430
434 eC_Value GetLineHeight()
435 {
436 return m_vLineHeight;
437 }
438
441 virtual CGUIEditableText* Clone() const;
442
443#ifdef GUILIANI_STREAM_GUI
445#endif
446
447#ifdef GUILIANI_WRITE_GUI
448 virtual void WriteToStream(const eC_Bool bWriteTextType = false);
449#endif
450
451private:
453
455
456 eC_Bool m_bRtLEmbedding;
457
460 class CursorIndex_t
461 {
462 public:
469 CursorIndex_t(
470 eC_UInt uiCursorIndex,
471 const WidthListIterator& kCursorIter,
472 WidthList* pList) :
473 m_uiCursorIndex(uiCursorIndex),
474 m_kCursorIter(kCursorIter),
475 m_pList(pList)
476 {
477 }
478
481 CursorIndex_t() :
482 m_uiCursorIndex(0),
483 m_pList(NULL)
484 {
485 }
486
491 CursorIndex_t& operator++() // prefix
492 {
493 if ((m_pList != NULL) && (m_uiCursorIndex + 1 < m_pList->GetQuantity()))
494 {
495 ++m_kCursorIter;
496 ++m_uiCursorIndex;
497 }
498 return *this;
499 }
500
505 CursorIndex_t operator++(int) // postfix
506 {
507 CursorIndex_t kResult = *this;
508 operator++();
509 return kResult;
510 }
511
516 CursorIndex_t& operator--() // prefix
517 {
518 if (m_uiCursorIndex > 0)
519 {
520 --m_uiCursorIndex;
521 --m_kCursorIter;
522 }
523 return *this;
524 }
525
530 CursorIndex_t operator--(int) // postfix
531 {
532 CursorIndex_t kResult = *this;
533 operator--();
534 return kResult;
535 }
536
540 eC_Value operator*()
541 {
542 if (m_kCursorIter.IsValid())
543 {
544 return *m_kCursorIter;
545 }
546 return eC_FromInt(0);
547 }
548
552 eC_Bool operator==(CursorIndex_t kCursorIndex)
553 {
554 return m_uiCursorIndex == kCursorIndex.m_uiCursorIndex &&
555 m_kCursorIter == kCursorIndex.m_kCursorIter;
556 }
557
561 eC_Bool operator==(eC_UInt uiCursorIndex)
562 {
563 return m_uiCursorIndex == uiCursorIndex;
564 }
565
569 eC_Bool operator!=(CursorIndex_t kCursorIndex)
570 {
571 return !operator==(kCursorIndex);
572 }
573
577 eC_Bool operator!=(eC_UInt uiCursorIndex)
578 {
579 return m_uiCursorIndex != uiCursorIndex;
580 }
581
586 eC_Bool operator>(eC_UInt uiCursorIndex)
587 {
588 return m_uiCursorIndex > uiCursorIndex;
589 }
590
595 eC_Bool operator<(eC_UInt uiCursorIndex)
596 {
597 return m_uiCursorIndex < uiCursorIndex;
598 }
599
606 void SetCursorIndex(eC_UInt uiCursorIndex, const WidthListIterator& kCursorIter, WidthList* pList)
607 {
608 m_uiCursorIndex = uiCursorIndex;
609 m_kCursorIter = kCursorIter;
610 m_pList = pList;
611 }
612
616 eC_UInt GetCursorIndex() const
617 {
618 return m_uiCursorIndex;
619 }
620
625 WidthListIterator GetCursorIter() const
626 {
627 return m_kCursorIter;
628 }
629
630 private:
632 eC_UInt m_uiCursorIndex;
633
636 WidthListIterator m_kCursorIter;
637
639 WidthList* m_pList;
640 };
641
642private:
646
649 void Init(const eC_Value& vTextWidth);
650
653 void CopyAttributes(const CGUIEditableText& rkSource);
654
657 virtual void SetTextSingleLine(const eC_Bool &bSingleLine);
658
659 virtual void CollectHyphenationMarks(eC_String& rkStr, eC_UInt uiOffset);
660
663 void DrawSelection();
664
667 void DrawCursor();
668
673 void SetIndexOfWidthList(eC_UInt uiIndexOfWidthList);
674
683 void SetSelection(eC_UInt uiStartIndexOfWidthList, eC_UInt uiEndIndexOfWidthList);
684
693 void RemoveString(eC_UInt uiStartIndexOfWidthList, eC_UInt uiEndIndexOfWidthList);
694
699 eC_UInt LinePosToIndexOfWidthList(const CursorPos_t &tCursorLinePos);
700
705 CursorPos_t GetCursorPositionFromIndex(eC_UInt uiIndexOfWidthList);
706
719 void ComputeWidths(const eC_String &kAdjustedStr, eC_UInt uiStartIndexOfWidthList);
720
721 // TODO: documentation
722 void ComputeBidiWidths(const eC_String &kAdjustedStr, eC_UInt uiStartIndexOfWidthList);
723
733 void AdjustWidths(
734 ExtendedStringList_t::Iterator &StartStrIter,
735 WidthListIterator &StartWidthIter,
736 WidthListIterator &EndWidthIter);
737
750 eC_UInt MoveCurrentWidthIndexToSafePos(
751 eC_UInt uiCurrentWidthIndex,
752 eC_UInt uiCursorPosAtCurrentLine,
754
765 void AdjustStr(
766 eC_String* pkResultStr,
767 eC_String* pkStrToAnalyse,
768 eC_String* pkRestStr,
769 WidthListIterator &StartWidthIter);
770
773 void EnsureMinimumTextWidth();
774
775private:
786 WidthList m_kAccumulatedWidth;
787
788 static const eC_UInt INDEX_COLOR_SELECTION;
789
791 CursorIndex_t m_kIndexOfWidthList;
792
794 CursorIndex_t m_kSelStartIndexOfWidthList;
795
797 CursorIndex_t m_kSelEndIndexOfWidthList;
798
800 eC_Value m_vCursorWidth;
801
803 eC_Bool m_bCursorVisible;
804
806 eC_Bool m_bPasswordMode;
807
809 eC_String* m_pkPassword;
810
812 eC_String m_kPwdChar;
813
814 static const eC_UInt ms_uiInvalidPivot;
815};
816
817#endif
FontResource_t
List of font resource ids.
Definition: GUIFontResource.h:54
Helper Macros in Guiliani
GlobalProperty_t
List of property resource ids.
Definition: GUIPropertyResource.h:67
TextResource_t
List of text resource ids.
Definition: GUITextResource.h:40
Specialization of CGUIText that allows for modification and selection of text.
Definition: GUIEditableText.h:61
virtual void WriteToStream(const eC_Bool bWriteTextType=false)
eC_UInt GetRtlTurnPnt(eC_UInt currentIndex)
CursorPos_t GetBestCursorPosition(const eC_Value &vRelXPos, const eC_Value &vRelYPos)
void Delete(eC_UInt uiCursorPosAtStartLine, eC_UInt uiCursorPosAtEndLine, eC_UInt uiStartLine=0, eC_UInt uiEndLine=0)
CGUIEditableText(const CGUIObject *const pkParentObject, const eC_String &kText, const eC_Value &vXPos=eC_FromInt(0), const eC_Value &vYPos=eC_FromInt(0), const eC_Value &vTextWidth=eC_FromInt(0), eC_Bool bWordWrap=false)
eC_Bool HasSelection()
CGUIEditableText(const CGUIEditableText &rkSource)
eC_Bool GetRectOfIndex(eC_UInt uiIndex, CGUIRect &rect)
void SetWordWrap(eC_Bool bWordWrap, const eC_Value &vWidth=eC_FromInt(0))
virtual CGUIEditableText * Clone() const
BidiTurningPoint_t m_kBidiTurnPoints
turning-points
Definition: GUIEditableText.h:99
eC_Value GetLineHeight()
Definition: GUIEditableText.h:434
CursorPos_t GetLastCursorPos()
CursorPos_t GetCursorPosition()
virtual void SetFont(const FontResource_t &eFontID)
void SetEmbeddingDirection(const eC_Bool bRightToLeft)
virtual void SetTextString(const eC_String &rkTextString)
eC_UInt GetSelectionColor() const
CursorPos_t GetCursorPosByCharIndex(eC_UInt uiCharIndex)
CursorPos_t GetSelectionStart()
void Insert(const eC_String &kInsChars)
void SetSelectionColor(const eC_UInt &uiSelectionColor)
CursorPos_t GetSelectionEnd()
eC_Bool IsInLtRField(eC_UInt currentIndex)
CGUIEditableText(const CGUIObject *const pkParentObject, const TextResource_t &eTextID, const eC_Value &vXPos=eC_FromInt(0), const eC_Value &vYPos=eC_FromInt(0), const eC_Value &vTextWidth=eC_FromInt(0), eC_Bool bWordWrap=false)
void SetSelectionColor(const GlobalProperty_t &uiSelectionColor)
CGUIEditableText & operator=(const CGUIEditableText &rkSource)
eC_String GetStrOfLine(eC_UInt uiCurrentLine) const
void ResetTurningPoints()
eC_String GetSelectedText()
eC_Bool IsLeftToRightEmbedding()
virtual void PrintText()
CGUIRect GetCursorAbsRect()
void SetCursorVisible(eC_Bool bVisible)
virtual const eC_String *const GetPassword()
void ExtendSelection(eC_UInt uiCharIndex, eC_UInt uiLineIndex=0)
void SetCursorPosition(eC_UInt uiCursorPosAtLine, eC_UInt uiCurrentLine=0)
void DeleteSelection()
eC_Value GetCursorWidth() const
eC_UInt GetLtrTurnPnt(eC_UInt currentIndex)
void SetPasswordCharacter(eC_String &kPwdStr)
eC_Bool GetLTRpivotField(eC_UInt currentIndex, LeftEmbedding &ltrPivotPair)
void SetCursorWidth(eC_Value vWidth)
eC_Bool IsCursorVisible() const
void SetPasswordMode(eC_Bool bPasswordMode)
CGUIEditableText(const CGUIObject *const pkParentObject, const eC_String *const pkText, const eC_Value &vXPos=eC_FromInt(0), const eC_Value &vYPos=eC_FromInt(0), const eC_Value &vTextWidth=eC_FromInt(0), eC_Bool bWordWrap=false)
This is the Guiliani base class all controls are derived from.
Definition: GUIObject.h:79
Helper class to supply a platform independent rectangle implementation.
Definition: GUIRect.h:63
Class for handling a text.
Definition: GUIText.h:103
eC_Value m_vLineHeight
The height of one text line with this text's font.
Definition: GUIText.h:980
eC_TIterator< ExtendedString_t > Iterator
Iterator is typedef'd as eC_TIterator ot type T.
Definition: eC_TList_doubleLinked.h:74
bool operator==(const NSmartPtr::SharedPtr< C1 > &a, const NSmartPtr::SharedPtr< C2 > &b)
Definition: SharedPtr.h:240
bool operator!=(const NSmartPtr::SharedPtr< C1 > &a, const NSmartPtr::SharedPtr< C2 > &b)
Definition: SharedPtr.h:226
Definition: GUIEditableText.h:85
eC_TList< eC_UInt > fromRtLIndex
List of Turning points which indicate the indexes of changes from writing RTL chars to LTR ones.
Definition: GUIEditableText.h:87
eC_TList< LeftEmbedding > leftEmbeddingLevels
Definition: GUIEditableText.h:93
eC_TList< RightEmbedding > rightEmbeddingLevels
Definition: GUIEditableText.h:97
eC_TList< eC_UInt > fromLtRIndex
List of Turning points which indicate the indexes of changes from writing LTR chars to RTL ones.
Definition: GUIEditableText.h:89
Holds a cursor position.
Definition: GUIEditableText.h:65
CursorPos_t(eC_UInt uiCharIndex=0, eC_UInt uiLineIndex=0)
Definition: GUIEditableText.h:70
eC_UInt m_uiCharIndex
Cursor position of current line starting from index 0.
Definition: GUIEditableText.h:77
eC_UInt m_uiLineIndex
The line where the cursor is located.
Definition: GUIEditableText.h:78
Definition: bidi.h:91