Home |
Class PegDecoratedButton HMI (Human-Machine Interface) Classes |
Class PegDecoratedButtonPegDecoratedButton is a PegButton class that has the ability to display both text and a PegBitmap. The location of the text relative to the bitmap is user selectable using a set of extended style flags. PegDecoratedButton also supports a flyover mode, where the button appears flat until the pointer is over the button. class PegDecoratedButton : public PegButton, public PegTextThing { public: PegDecoratedButton(PegRect &Rect, const PEGCHAR * pText, PegBitmap * pBitmap, PEGUINT wId = 0, PEGUINT wStyle = AF_ENABLED, BOOL bFlyOver = FALSE); PegDecoratedButton(PEGINT iLeft, PEGINT iTop, PEGINT iWidth, const PEGCHAR * pText, PegBitmap * pBitmap, PEGUINT wId = 0, PEGUINT wStyle = AF_ENABLED, BOOL bFlyOver = FALSE); PegDecoratedButton(PEGINT iLeft, PEGINT iTop, const PEGCHAR * pText, PegBitmap * pBitmap, PEGUINT wId = 0, PEGUINT wStyle = AF_ENABLED, BOOL bFlyOver = FALSE); virtual void Draw(void); virtual PEGINT Message(const PegMessage& Mesg); virtual void SetBitmap(PegBitmap * pNewMap); BOOL GetFlyOver(void) const; void SetFlyOver(BOOL bFlyOver); BOOL InFlyOver(void) const; PEGUINT GetExStyle(void) const; void SetExStyle(PEGUINT wExStyle); }; Style FlagsFF_NONE, BF_REPEAT, and BF_DOWNACTION. PegDecoratedButton also supports two extended styles, DBF_ORIENT_TR and DBF_ORIENT_BR. These style flags are independent of the PegButton derived style flags. These flags allow the bitmap and text to be positioned relative to each other. Here is how they work together: !DBF_ORIENT_TR && !DBF_ORIENT_BRBitmap is displayed to the left of the text DBF_ORIENT_TR && !DBF_ORIENT_BRBitmap is displayed above the text !DBF_ORIENT_TR && DBF_ORIENT_BRBitmap is displayed below the text DBF_ORIENT_TR && DBF_ORIENT_BRBitmap is displayed to the right of the text SignalsPegDecoratedButton sends the PSF_CLICKED signal when selected. ConstructorsThe first constructor creates a PegDecoratedButton with a user defined size. The second constructor allows you to specify a top and left position for the button, as well as the width, allowing the PegDecoratedButton to determine its own height based on the size of the text and bitmap as well as their relative positions. The third constructor allows the button to automatically size itself relative to the text and bitmap size. Method DrawDraws the associated text and bitmap. Method GetExStyleReturns the extended style. The return value can be any combination of DBF_ORIENT_TR and DBF_ORIENT_BR. Method GetFlyOverReturns a boolean indicating if the PegDecoratedButton flyover mode for drawing itself is enabled or disabled. Method InFlyOverReturns whether or not the button is currently operating in flyover mode. Method MessagePegDecoratedButton overrides the Message() method to catch the PM_NONCURRENT, PM_POINTER_ENTER, and PM_POINTER_EXIT messages. Method SetBitmapAssigns the bitmap associated with the button. Method SetExStyleSets the extended style for the PegDecoratedButton. Method SetFlyOverEnables or disables the PegDecoratedButton flyover mode for drawing itself. Examples:The following are examples of PegDecoratedButton: The above example shows seven PegDecoratedButtons on the parent window. The first row of three does not have flyover enabled. (They are always drawn just like any other PegButton derived object). They also demonstrate having only text, only a bitmap and having both on a single button. The other four PegDecoratedButtons in the diamond pattern have flyover enabled. They are drawn flat until the pointer 'flies over' them. At that point, the border (if any) is drawn. This style is typical of most tool bar buttons in modern GUIs. They also demonstrate how the text and bitmap may be relatively positioned on the button. The PegToolBar on the parent window has one PegToolBarPanel attached to it with three PegDecoratedButtons on it. These buttons are also being drawn in 'flyover' style. (They do not draw their borders until the pointer is over them.) When a PegDecoratedButton is put on a PegToolBarPanel, it is best to have the bitmap situated either to the right or to the left of the text, not on the top or bottom, since the height of the button is restricted when it is on a PegToolBarPanel. The following example creates the four PegDecoratedButtons displayed in the above image in a diamond pattern on the parent PegDecoratedWindow. extern PegBitmap gbGreenDotBitmap; . . PegRect Rect; . . Rect.Shift(-175, 75); pButton = new PegDecoratedButton(Rect, "Text on the Bottom", &gbGreenDotBitmap, 0, AF_ENABLED, DBF_ORIENT_TR, TRUE); pWindow->Add(pButton); Rect.Shift(-150, 50); pButton = new PegDecoratedButton(Rect, "Text on the Right", &gbGreenDotBitmap, 0, AF_ENABLED, 0, TRUE); pWindow->Add(pButton); Rect.Shift(150, 50); pButton = new PegDecoratedButton(Rect, "Text on the Top", &gbGreenDotBitmap, 0, AF_ENABLED, DBF_ORIENT_BR, TRUE); pWindow->Add(pButton); Rect.Shift(150, -50); pButton = new PegDecoratedButton(Rect, "Text on the Left", &gbGreenDotBitmap, 0, AF_ENABLED, DBF_ORIENT_TR | DBF_ORIENT_BR, TRUE); pWindow->Add(pButton);
|