Home |
Class PegToolBarPanel HMI (Human-Machine Interface) Classes |
Class PegToolBarPanelPegToolBarPanel is a container object that is used on conjunction with PegToolBar. Any PegThing derived object may be placed on a PegToolBarPanel. As the objects are added, the panel positions the objects as well as assigns them a default height. The objects may be of any width. class PegToolBarPanel : public PegThing { public: PegToolBarPanel(PEGUINT wID = 0); virtual void Draw(void); virtual void Add(PegThing * Who, BOOL bDraw = TRUE); virtual void AddToEnd(PegThing * Who, BOOL bDraw = TRUE); virtual PegThing * Remove(PegThing * Who, BOOL bDraw = TRUE); }; ConstructorThe size of the panel is determined by its child objects. It's position on the PegToolBar is determined when it is added to the PegToolBar. Method DrawDraws the tool bar background. Method AddThis is an overridden version of the PegThing::Add method. Once the PegThing object is added, we may have to resize the pWho object (height, only). We will have to resize ourselve based on the width of the pWho object. We also send a message to our parent object (PegToolBar) to reposition any sibling panels based on our new size. If bDraw is set to true, the panel and its children are redrawn. Method AddToEndAdds the object to the end of the child list. Method RemoveThis method is an override of the PegThing::Remove method. ExamplesThe following is an example of two PegDecoratedWindows with PegToolBars and PegToolBarPanels. Note that there are three PegToolBarPanels on the top window and that there are two PegToolBarPanels on the second window. Note also that the PegThing derived objects are added to the PegToolBarPanels, not to the PegToolBar itself. The following example creates a PegToolBar and adds three PegToolBarPanels to the PegToolBar. This is the PegToolBar in the above top level window. Usually you would do this in the constructor of you PegDecoratedWindow derived window. extern PegBitmap gbBullsEyeBitmap; extern PegBitmap gbBlueDotBitmap; extern PegBitmap gbGreyDotBitmap; extern PegBitmap gbGreenDotBitmap; extern PegBitmap gbRedDotBitmap; //... some code deleted ... PegToolBar * pToolBar = new PegToolBar(); PegRect Rect; PegToolBarPanel * pPanel = new PegToolBarPanel(); Rect.Set(0, 0, 70, 20); pPanel->Add(new PegTextButton(Rect, "Remove It ->", IDB_ALPHA_BUTTON)); Rect.Set(0, 0, 20, 20); pPanel->AddToEnd(new PegTextButton(Rect, "B")); pToolBar->AddPanel(pPanel); Rect.Set(0, 0, 200, 20); pPanel = new PegToolBarPanel(IDC_STRING_PANEL); pPanel->Add(new PegString(Rect, "String on a ToolBarPanel")); pToolBar->AddPanel(pPanel); Rect.Set(0, 0, 19, 18); pPanel = new PegToolBarPanel(); pPanel->Add(new PegBitmapButton(Rect, &gbBullsEyeBitmap, IDB_BULL_BUTTON), FALSE); pPanel->Add(new PegBitmapButton(Rect, &gbBlueDotBitmap, IDB_BLUE_BUTTON), FALSE); pPanel->Add(new PegBitmapButton(Rect, &gbGreyDotBitmap, IDB_GREY_BUTTON), FALSE); pPanel->Add(new PegBitmapButton(Rect, &gbGreenDotBitmap, IDB_GREEN_BUTTON), FALSE); pPanel->Add(new PegBitmapButton(Rect, &gbRedDotBitmap, IDB_RED_BUTTON), FALSE); pToolBar->AddPanel(pPanel); Add(pToolBar);
|