Home |
HMI (Human-Machine Interface) Classes Class PegFiniteBitmapDial |
Class PegFiniteBitmapDialPegFiniteBitmapDial behaves exactly the same as PegFiniteDial, from which it derives. The differences are the user may specify a background bitmap over which the dial needle will be drawn as well as a bitmap that will be used to draw the needle anchor at the center of rotation. This allows for very custom looking finite dials. An added feature of PegFiniteBitmapDial is the ability to specify a center of rotation that is not necessarily the center of the bounding rectangle for the dial. Typically, the needle of the dial would originate at the center of the bounding rectangle. PegFiniteBitmapDial allows for the needle to originate from anywhere inside its bounding rectangle. This further adds to the custom possibilities when designing your dials. Style FlagsPegFiniteBitmapDial supports the styles described in PegDial. PegFiniteBitmapDial does not support any of the frame styles because it uses the background bitmap for drawing in the client area of the dial. SignalsPegFiniteBitmapDial does not send any signals. class PegFiniteBitmapDial : public PegFiniteDial { public: PegFiniteBitmapDial(PEGINT iLeft, PEGINT iTop, PEGINT iMinAngle, PEGINT iMaxAngle, LONG lMinValue, LONG lMaxValue, PegBitmap * pBkgBmp, PegBitmap * pAnchorBitmap = NULL, PEGUINT wStyle = DS_STANDARDSTYLE); PegFiniteBitmapDial(const PegRect& tRect, PEGINT iMinAngle, PEGINT iMaxAngle, LONG lMinValue, LONG lMaxValue, PegBitmap * pBkgBmp, PegBitmap * pAnchorBitmap = NULL, PEGUINT wStyle = DS_STANDARDSTYLE); virtual void Draw(); PegBitmap * GetBkgBitmap(void) const; void SetBkgBitmap(PegBitmap * pBmp); PegBitmap * GetAnchorBitmap(void) const; void SetAnchorBitmap(PegBitmap * pBmp); void UseTrueCOR(BOOL bUse); void SetCOR(PEGINT CORX, PEGINT CORY, BOOL bRedraw = FALSE); PEGINT GetCORX(void) const; PEGINT GetCORY(void) const; protected: virtual void CalcNeedlePos(); void DrawToComposite(); PegBitmap * mpBkgBitmap; PegBitmap * mpAnchorBitmap; PegBitmap * mpCompBitmap; PegPoint mtCOR; }; ConstructorsThe first constructor takes a reference to a PegRect to determine its size, a minimum and maximum angle, a minimum and maximum value, a pointer to a bitmap that will be used for drawing the background, a pointer to a bitmap that will be used to draw the needle anchor, and a style PEGUINT. The second constructor takes PEGINT values to the left and top positions of the dial. If a background bitmap is specified, the object is sized to the height and width of the bitmap. The remaining parameters are the same as the above constructor. The dial will map the minimum angle to the minimum value, and the maximum angle to the maximum value. So, the dial will behave as expected. If you set the minimum angle to be 0 and the maximum angle to be 180, and the minimum value to 0 and the maximum value to 100, then setting the value on the dial to 50 will set the needle to 90 degrees, straight up. Method DrawPegFiniteBitmapDial overrides the Draw() function to draw the background bitmap and needle. Method GetAnchorBitmapThis method returns a PegBitmap pointer to the anchor bitmap. Method GetBkgBitmapThis method returns a PegBitmap pointer to the background bitmap. Methods GetCORX and GetCORYThese inline functions return the respective values of the x and y center of rotation. Method SetAnchorBitmapThis method set the anchor bitmap to point to pBmp. Method SetBkgBitmapThis method set the background bitmap to point to pBmp. Method SetCORThis allows for the setting of the x and y values of the center of rotation (the origin of the needle) of the dial. UseTrueCORThis method is short hand for setting the style flags DS_RECTCOR and DS_USERCOR to on or off, depending on the value of bUse. ExamplesThe following is an example of three PegFiniteBitmapDials on a PegDecoratedWindow. Notice that the third dial, on the right, has a center of rotation that is in the bottom right corner of the bounding rectangle of the dial. The above PegFiniteBitmapDials were created by the following code snippet: extern PegBitmap gbdialbkg3Bitmap; extern PegBitmap gbdialbkg2Bitmap; extern PegBitmap gbdialbkg4Bitmap; extern PegBitmap gbAbFluidBitmap; extern PegBitmap gbDialAnchor1Bitmap; . . PegFiniteBitmapDial * mpDial1, * mpDial2, * mpDial3; . . PegRect WinRect; WinRect.Set(50, 50, 200, 200); mpDial1 = new PegFiniteBitmapDial(WinRect, 180, 0, 0, 100, &gbdialbkg2Bitmap); WinRect.Shift(160, 0); mpDial2 = new PegFiniteBitmapDial(WinRect, 225, 315, -25, 125, &gbdialbkg3Bitmap, &gbDialAnchor1Bitmap); mpDial2->Style((mpDial2->Style() | DS_THICKNEEDLE) & ~DS_THINNEEDLE); mpDial2->SetNeedleColor(BLUE); WinRect.Shift(160, 0); mpDial3 = new PegFiniteBitmapDial(WinRect, 180, 90, 0, 100, &gbdialbkg4Bitmap); mpDial3->Style(DS_THICKNEEDLE | DS_USERCOR); mpDial3->SetCOR(123, 123); mpDial3->SetNeedleLength(65); Add(mpDial1); Add(mpDial2); Add(mpDial3);
|