Home |
Class PegMLTextButton HMI (Human-Machine Interface) Classes |
Class PegMLTextButtonPegMLTextButton provides a pushbutton object with visual feedback indicating to the user the button depress and release operation. PegMLTextButton differs from PegTextButton in that the text displayed can span multiple lines in the button client area, hence the class name PegMLTextButton (multi-line button). Any custom fonts or colors may be applied to PegMLTextButton. Users often create custom derived versions of PegMLTextButton to draw modified border styles, modified border shapes, etc. PegMLTextButton is also commonly used to populate PegHorzList and PegVertList objects. The text strings displayed on the button face are vertically centered over the button client area, and may be horizontally justified in different ways by using the different text justification styles such as TJ_LEFT or TJ_CENTER. The text breaks for a multi-line text button are defined by the caller when the text string is passed to the button, either during object construction or with the DataSet() function. The character to be used as a break character is passed to the class constructor(s), and defaults to '|'. Simple formatting such as insertion of blank lines is also possible through clever use of the break character. If the first or last characters in the string are any number of break characters, the vertical centering will be adjusted. If the string contains two or more back-to-back break characters, blank lines will be inserted into the displayed text. class PegMLTextButton : public PegButton { public: PegMLTextButton(PegRect &, const PEGCHAR * Text, PEGCHAR cMarker = '|', PEGUINT wId = 0, PEGUINT wStyle = TJ_CENTER | AF_ENABLED); PegMLTextButton(int wLeft, int wTop, int iWidth, const PEGCHAR * Text, PEGCHAR cMarker = '|', PEGUINT wId = 0, PEGUINT wStyle = AF_ENABLED); PegMLTextButton(int wLeft, int wTop, const PEGCHAR * Text, PEGCHAR cMarker = '|', PEGUINT wId = 0, PEGUINT wStyle = AF_ENABLED); virtual void Draw(void); virtual void DataSet(const PEGCHAR * Text); virtual void SetFont(PegFont * pFont); }; PegMLTextButton supports the same style flags and signals as PegTextButton. Demo program PegDemo uses this class. ConstructorsPegMLTextButton offers three constructors, depending on how you want to specify the button size. The first constructor allows you to fully specify the button size and position. The second constructor allows you to specify the top-left corner of the button and the button width. The last constructor allows you to specify the top-left corner position of the button. In this case the button calculates its own height and width on the default textbutton font. Method DrawPegMLTextButton overrides the Draw() function to draw the text on the button face. Method DataSetPegMLTextButton overrides the DataSet() function to invalidate the button client area and re-calculate the number of lines to display. Method SetFontPegMLTextButton overrides the SetFont() function to invalidate the button client area and re-calculate substring positions. ExamplesThe following is a default multi-line text button: Created using the following code fragment: Add(new PegMLTextButton(mClient.wLeft + 10, mClient.wTop + 10, "Multi-Line|Text|Button")); The following is a multi-line text button with a blank line, modified color, and modified font: Created using the following code fragment: Rect.Set(0, 0, 90, 72); Rect.Shift(mClient.wLeft + 10, mClient.wTop + 10); PegMLTextButton * pButton = new PegMLTextButton(Rect, "This Button|Has A||Blank Line"); pButton->SetColor(PCI_NORMAL, BLUE); pButton->SetColor(PCI_NTEXT, WHITE); pButton->SetFont(&SysFont); Add(pButton);
|