Guiliani  Version 2.6 revision 7293 (documentation build 12)
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
20#include "bidi.h"
21
23
62{
63public:
66 {
72 eC_UInt uiCharIndex = 0,
73 eC_UInt uiLineIndex = 0) :
74 m_uiCharIndex(uiCharIndex),
75 m_uiLineIndex(uiLineIndex)
76 {}
77
78 eC_UInt m_uiCharIndex;
79 eC_UInt m_uiLineIndex;
80 };
81
86 {
88 eC_TList<eC_UInt> fromRtLIndex;
90 eC_TList<eC_UInt> fromLtRIndex;
94 eC_TList<LeftEmbedding> leftEmbeddingLevels;
98 eC_TList<RightEmbedding> rightEmbeddingLevels;
99 };
101
115 const CGUIObject* const pkParentObject,
116 const eC_String &kText,
117 const eC_Value& vXPos = eC_FromInt(0),
118 const eC_Value& vYPos = eC_FromInt(0),
119 const eC_Value& vTextWidth = eC_FromInt(0),
120 eC_Bool bWordWrap = false);
121
135 const CGUIObject* const pkParentObject,
136 const eC_String* const pkText,
137 const eC_Value& vXPos = eC_FromInt(0),
138 const eC_Value& vYPos = eC_FromInt(0),
139 const eC_Value& vTextWidth = eC_FromInt(0),
140 eC_Bool bWordWrap = false);
141
155 const CGUIObject* const pkParentObject,
156 const TextResource_t &eTextID,
157 const eC_Value& vXPos = eC_FromInt(0),
158 const eC_Value& vYPos = eC_FromInt(0),
159 const eC_Value& vTextWidth = eC_FromInt(0),
160 eC_Bool bWordWrap = false);
161
166
170
176
182 void Insert(const eC_String& kInsChars);
183
191 void Delete(
192 eC_UInt uiCursorPosAtStartLine,
193 eC_UInt uiCursorPosAtEndLine,
194 eC_UInt uiStartLine = 0,
195 eC_UInt uiEndLine = 0);
196
205 virtual void PrintText();
206
211
216 virtual const eC_String* const GetPassword();
217
223
229
236
244
252 virtual void SetTextString(const eC_String& rkTextString);
253
260 eC_UInt uiCursorPosAtLine,
261 eC_UInt uiCurrentLine = 0);
262
270 CursorPos_t GetBestCursorPosition(const eC_Value& vRelXPos, const eC_Value& vRelYPos);
271
275
280 eC_UInt GetLtrTurnPnt(eC_UInt currentIndex);
281
286 eC_UInt GetRtlTurnPnt(eC_UInt currentIndex);
287
292 eC_Bool IsInLtRField(eC_UInt currentIndex);
293
299 eC_Bool GetLTRpivotField(eC_UInt currentIndex, LeftEmbedding& ltrPivotPair);
300
306 eC_Bool GetRectOfIndex(eC_UInt uiIndex, CGUIRect& rect);
307
311 void SetEmbeddingDirection(const eC_Bool bRightToLeft);
312
317
321 eC_Bool HasSelection();
322
325 void SelectAll();
326
333 void SetWordWrap(eC_Bool bWordWrap, const eC_Value& vWidth = eC_FromInt(0));
334
341
348 void ExtendSelection(eC_UInt uiCharIndex, eC_UInt uiLineIndex = 0);
349
354
359 void SetCursorVisible(eC_Bool bVisible);
360
366
370 eC_Bool IsCursorVisible() const;
371
375 void SetCursorWidth(eC_Value vWidth);
376
380 eC_Value GetCursorWidth() const;
381
385 void SetSelectionColor(const eC_UInt& uiSelectionColor);
386
390 void SetSelectionColor(const GlobalProperty_t& uiSelectionColor);
391
395 eC_UInt GetSelectionColor() const;
396
400 virtual void SetFont(const FontResource_t &eFontID);
401
407 void SetPasswordCharacter(eC_String& kPwdStr);
408
412 void SetPasswordMode(eC_Bool bPasswordMode);
413
420
425 eC_String GetStrOfLine(eC_UInt uiCurrentLine) const;
426
430 eC_String GetSelectedText();
431
435 eC_Value GetLineHeight()
436 {
437 return m_vLineHeight;
438 }
439
442 virtual CGUIEditableText* Clone() const;
443
444#ifdef GUILIANI_STREAM_GUI
446#endif
447
448#ifdef GUILIANI_WRITE_GUI
449 virtual void WriteToStream(const eC_Bool bWriteTextType = false);
450#endif
451
452private:
454
456
457 eC_Bool m_bRtLEmbedding;
458
461 class CursorIndex_t
462 {
463 public:
470 CursorIndex_t(
471 eC_UInt uiCursorIndex,
472 const WidthListIterator& kCursorIter,
473 WidthList* pList) :
474 m_uiCursorIndex(uiCursorIndex),
475 m_kCursorIter(kCursorIter),
476 m_pList(pList)
477 {
478 }
479
482 CursorIndex_t() :
483 m_uiCursorIndex(0),
484 m_pList(NULL)
485 {
486 }
487
492 CursorIndex_t& operator++() // prefix
493 {
494 if ((m_pList != NULL) && (m_uiCursorIndex + 1 < m_pList->GetQuantity()))
495 {
496 ++m_kCursorIter;
497 ++m_uiCursorIndex;
498 }
499 return *this;
500 }
501
506 CursorIndex_t operator++(int) // postfix
507 {
508 CursorIndex_t kResult = *this;
509 operator++();
510 return kResult;
511 }
512
517 CursorIndex_t& operator--() // prefix
518 {
519 if (m_uiCursorIndex > 0)
520 {
521 --m_uiCursorIndex;
522 --m_kCursorIter;
523 }
524 return *this;
525 }
526
531 CursorIndex_t operator--(int) // postfix
532 {
533 CursorIndex_t kResult = *this;
534 operator--();
535 return kResult;
536 }
537
541 eC_Value operator*()
542 {
543 if (m_kCursorIter.IsValid())
544 {
545 return *m_kCursorIter;
546 }
547 return eC_FromInt(0);
548 }
549
553 eC_Bool operator==(CursorIndex_t kCursorIndex)
554 {
555 return m_uiCursorIndex == kCursorIndex.m_uiCursorIndex &&
556 m_kCursorIter == kCursorIndex.m_kCursorIter;
557 }
558
562 eC_Bool operator==(eC_UInt uiCursorIndex)
563 {
564 return m_uiCursorIndex == uiCursorIndex;
565 }
566
570 eC_Bool operator!=(CursorIndex_t kCursorIndex)
571 {
572 return !operator==(kCursorIndex);
573 }
574
578 eC_Bool operator!=(eC_UInt uiCursorIndex)
579 {
580 return m_uiCursorIndex != uiCursorIndex;
581 }
582
587 eC_Bool operator>(eC_UInt uiCursorIndex)
588 {
589 return m_uiCursorIndex > uiCursorIndex;
590 }
591
596 eC_Bool operator<(eC_UInt uiCursorIndex)
597 {
598 return m_uiCursorIndex < uiCursorIndex;
599 }
600
607 void SetCursorIndex(eC_UInt uiCursorIndex, const WidthListIterator& kCursorIter, WidthList* pList)
608 {
609 m_uiCursorIndex = uiCursorIndex;
610 m_kCursorIter = kCursorIter;
611 m_pList = pList;
612 }
613
617 eC_UInt GetCursorIndex() const
618 {
619 return m_uiCursorIndex;
620 }
621
626 WidthListIterator GetCursorIter() const
627 {
628 return m_kCursorIter;
629 }
630
631 private:
633 eC_UInt m_uiCursorIndex;
634
637 WidthListIterator m_kCursorIter;
638
640 WidthList* m_pList;
641 };
642
643private:
647
650 void Init(const eC_Value& vTextWidth);
651
654 void CopyAttributes(const CGUIEditableText& rkSource);
655
658 virtual void SetTextSingleLine(const eC_Bool &bSingleLine);
659
660 virtual void CollectHyphenationMarks(eC_String& rkStr, eC_UInt uiOffset);
661
664 void DrawSelection();
665
668 void DrawCursor();
669
674 void SetIndexOfWidthList(eC_UInt uiIndexOfWidthList);
675
684 void SetSelection(eC_UInt uiStartIndexOfWidthList, eC_UInt uiEndIndexOfWidthList);
685
694 void RemoveString(eC_UInt uiStartIndexOfWidthList, eC_UInt uiEndIndexOfWidthList);
695
700 eC_UInt LinePosToIndexOfWidthList(const CursorPos_t &tCursorLinePos);
701
706 CursorPos_t GetCursorPositionFromIndex(eC_UInt uiIndexOfWidthList);
707
720 void ComputeWidths(const eC_String &kAdjustedStr, eC_UInt uiStartIndexOfWidthList);
721
727 void ComputeBidiWidths(const eC_String &kAdjustedStr, eC_UInt uiStartIndexOfWidthList);
728
738 void AdjustWidths(
739 ExtendedStringList_t::Iterator &StartStrIter,
740 WidthListIterator &StartWidthIter,
741 WidthListIterator &EndWidthIter);
742
755 eC_UInt MoveCurrentWidthIndexToSafePos(
756 eC_UInt uiCurrentWidthIndex,
757 eC_UInt uiCursorPosAtCurrentLine,
759
770 void AdjustStr(
771 eC_String* pkResultStr,
772 eC_String* pkStrToAnalyse,
773 eC_String* pkRestStr,
774 WidthListIterator &StartWidthIter);
775
778 void EnsureMinimumTextWidth();
779
780private:
791 WidthList m_kAccumulatedWidth;
792
793 static const eC_UInt INDEX_COLOR_SELECTION;
794 static int ms_aiEmbeddingLevels[BIDI_MAX_CCH]; // TODO: needs 4096 bytes of stack
795
797 CursorIndex_t m_kIndexOfWidthList;
798
800 CursorIndex_t m_kSelStartIndexOfWidthList;
801
803 CursorIndex_t m_kSelEndIndexOfWidthList;
804
806 eC_Value m_vCursorWidth;
807
809 eC_Bool m_bCursorVisible;
810
812 eC_Bool m_bPasswordMode;
813
815 eC_String* m_pkPassword;
816
818 eC_String m_kPwdChar;
819
820 static const eC_UInt ms_uiInvalidPivot;
821};
822
823#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:62
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:100
eC_Value GetLineHeight()
Definition: GUIEditableText.h:435
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:81
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:86
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:88
eC_TList< LeftEmbedding > leftEmbeddingLevels
Definition: GUIEditableText.h:94
eC_TList< RightEmbedding > rightEmbeddingLevels
Definition: GUIEditableText.h:98
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:90
Holds a cursor position.
Definition: GUIEditableText.h:66
CursorPos_t(eC_UInt uiCharIndex=0, eC_UInt uiLineIndex=0)
Definition: GUIEditableText.h:71
eC_UInt m_uiCharIndex
Cursor position of current line starting from index 0.
Definition: GUIEditableText.h:78
eC_UInt m_uiLineIndex
The line where the cursor is located.
Definition: GUIEditableText.h:79
Definition: bidi.h:91