Home |
Class PegString HMI (Human-Machine Interface) Classes |
Class PegStringPegString is a user-editable graphical string object. PegString can be displayed with any font or color and several different border styles. Only one line of text can be displayed in a PegString. PegString supports mark, cut, copy, and paste operations via keyboard input. The length of the contained string can be limited if desired. PegString shifts the string left or right as the string is edited if the string cannot be completely displayed in the client area of the PegString object. class PegString : public PegThing, public PegTextThing { public: PegString(const PegRect &Rect, const PEGCHAR * Text = NULL, PEGUINT wId = 0, PEGUINT wStyle = FF_RECESSED | AF_ENABLED | EF_EDIT, int iLen = -1); PegString(int iLeft, int iTop, int iWidth, const PEGCHAR * Text = NULL, PEGUINT wId = 0, PEGUINT wStyle = FF_RECESSED | AF_ENABLED | EF_EDIT, int iLen = -1); PegString(int iLeft, int iTop, const PEGCHAR * Text = NULL, PEGUINT wId = 0, PEGUINT wStyle = FF_RECESSED | AF_ENABLED | EF_EDIT, int iLen = -1); virtual PEGINT Message(const PegMessage &Mesg); virtual void Draw(void); virtual void DataSet(const PEGCHAR * Text); virtual void SetFont(PegFont * Font); virtual void Style(PEGUINT wStyle); virtual PEGUINT Style(void); virtual void SetMark(int iStart, int iEnd); virtual void SetMark(PEGCHAR * MarkStart, PEGCHAR * MarkEnd); virtual PEGINT GetMarkStart(void); virtual PEGINT GetMarkEnd(void); void DeleteMarkedText(void); void CopyToScratchPad(void); void PasteFromScratchPad(void); }; Demo programs PegDemo and Dialog use this class. Style FlagsFF_NONE, FF_THIN, FF_RAISED, FF_RECESSED, EF_EDIT, TT_COPY. SignalsPegString sends signals PSF_TEXT_SELECT, PSF_TEXT_EDIT, and PSF_TEXT_EDITDONE. ConstructorsEach constructor allows you to specify different parameters about the string position and size. The first constructor allows you to fully specify the PegString position and size. The second and third automatically determine the PegString height based on the default font. The second constructor allows you to specify the overall string width, while using the third constructor allows the string to calculate the minimum width required to display the specified text. Parameter iLen is the maximum string length (-1 indicates no limit). Method DataSetPegString overrides the DataSet function to reset any in-progress string mark or edit operations. Method CopyToScratchPadCopies the currently selected text to the scratch pad. Method DeleteMarkedTextThis method deletes the marked text. Method DrawPegString overrides the Draw() function to display the string border and text. Method GetMarkEndReturns the index of the last character marked by the user. Method GetMarkStartReturns the index of the first character marked by the user. Method MessagePegString catches various mouse and keyboard messages. Method PasteFromScratchPadPastes the text from the scratch pad and inserts it at the current cursor position. Method SetFontPegString overrides the SetFont function to re-calculate the overall string width, cursor height, etc.. Method SetMarkMarks all or a portion of the string text under program control. The iStart and iEnd values are the character indexes at which to begin and end marking, inclusive. Method SetMarkMarks all or a portion of the string text under program control. The MarkStart and MarkEnd values are pointers to the characters at which to begin and end marking, inclusive. Method StylePegString overrides the Style function to reset any in progress mark or edit operations if/when the EF_EDITstyle is removed. ExamplesThe following are each different styles of PegString: The following function creates a PegString object with a custom font: extern PegFont CustomFont; void MyWindow::AddCustomString(void) { PegRect ChildRect; ChildRect.Set(0, 0, 100, 40); PegString * pString = new PegString(ChildRect, "FooBar"); pString->SetFont(&CustomFont); Add(pPrompt); }
|