Exemplo n.º 1
0
/*--------------------------------------------------------------------------*/
void PegBitmapWindow::Draw()
{
	PegPoint tPutBitmap;
	PegRect CaptureRect;

  if (!mbCaptured)
  {
      // Capture the four bitmaps on my corners
      CaptureRect.wLeft = mReal.wLeft;
      CaptureRect.wTop = mReal.wTop;
      CaptureRect.wRight = CaptureRect.wLeft + CORNER_RADIUS;
      CaptureRect.wBottom = CaptureRect.wTop + CORNER_RADIUS;
      Screen()->Capture(&mCaptures[TOP_LEFT], CaptureRect);

			CaptureRect.Shift(mReal.Width() - CORNER_RADIUS, 0);
      Screen()->Capture(&mCaptures[TOP_RIGHT], CaptureRect);

			CaptureRect.Shift(0, mReal.Height() - CORNER_RADIUS);
      Screen()->Capture(&mCaptures[BOTTOM_RIGHT], CaptureRect);

      CaptureRect.Shift(-(mReal.Width() - CORNER_RADIUS), 0);
      Screen()->Capture(&mCaptures[BOTTOM_LEFT], CaptureRect);
      mbCaptured = TRUE;
  }

	BeginDraw();

  muColors[PCI_NORMAL] = mFillColor; /* set default value with given color */

	if (mpBitmap == NULL)
	{ /* no bitmap given, so fill frame with given color */
		DrawFrame();
	}
	else
	{
		Screen()->Restore(this, &mCaptures[TOP_LEFT]);
    Screen()->Restore(this, &mCaptures[TOP_RIGHT]);
    Screen()->Restore(this, &mCaptures[BOTTOM_RIGHT]);
    Screen()->Restore(this, &mCaptures[BOTTOM_LEFT]);

		if (mBitmapStyle == kCenterBitmap)
		{ /* center bitmap in window */
			tPutBitmap.x = mReal.wLeft + ((mReal.wRight - mReal.wLeft) - mpBitmap->wWidth)/2;
			tPutBitmap.y = mReal.wTop + ((mReal.wBottom - mReal.wTop) - mpBitmap->wHeight)/2;
		}
		else
    {
      tPutBitmap.x = mReal.wLeft;
      tPutBitmap.y = mReal.wTop;
    }

		Bitmap(tPutBitmap, mpBitmap); /* set bitmap */
	}

	DrawChildren(); /* draw buttons */
	EndDraw();
}
Exemplo n.º 2
0
DialWindow::DialWindow(const PegRect& Rect) :
    PegDecoratedWindow(Rect)
{
    Add(new PegTitle(gsWindowTitle));

    miDial1Dir = 1;
    miDial2Dir = 1;
    miDial1Val = 0;
    miDial2Val = 0;

    PegRect WinRect;

    WinRect.Set(50, 50, 199, 199);
    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_POLYNEEDLE) & ~DS_THINNEEDLE);
    mpDial2->SetNeedleColor(BLUE);

    Add(mpDial1);
    Add(new PegPrompt(105, 210, 40, gsZero, 101, FF_RECESSED | TJ_RIGHT |
                      TT_COPY));
    Add(mpDial2);
    Add(new PegPrompt(265, 210, 40, gsZero, 102, FF_RECESSED | TJ_RIGHT |
                      TT_COPY));

    WinRect.Shift(160, 0);
    mpDial3 = new PegFiniteBitmapDial(WinRect, 180, 90, 0, 100,
                                      &gbdialbkg4Bitmap, NULL,
                                      0);
    mpDial3->Style(FF_NONE | AF_TRANSPARENT | DS_THICKNEEDLE | DS_USERCOR |
                   DS_CLOCKWISE);
    mpDial3->SetCOR(123, 123);
    mpDial3->SetNeedleLength(65);
    mpDial3->SetColor(PCI_NORMAL, BLUE);
    Add(mpDial3);

    SetColor(PCI_NORMAL, GREEN);

    Add(new PegPrompt(425, 210, 40, gsZero, 101, FF_RECESSED | TJ_RIGHT |
                      TT_COPY));

    WinRect.Set(245, 240, 330, 270);
    Add(new PegTextButton(WinRect, gsChangeColor, IDB_CHANGECOLOR));
}
Exemplo n.º 3
0
/*--------------------------------------------------------------------------*/
LightWindow::LightWindow(const PegRect& Rect) :
    PegDecoratedWindow(Rect)
{
    Add(new PegTitle("PegBitmapLight Demo Window"));

    muColors[PCI_NORMAL] = GREEN;
    
    mpLight1 = new PegBitmapLight(mClient.wLeft + 20, mClient.wTop + 20, 3);
    mpLight1->SetStateBitmap(2, &gbredltBitmap);
    mpLight1->SetStateBitmap(1, &gbyellowltBitmap);
    mpLight1->SetStateBitmap(0, &gbgreenltBitmap);
    Add(mpLight1); 
    
    PegRect tRect;
    tRect.Set(mClient.wLeft + 200, mClient.wTop + 40, 
              mClient.wLeft + 300, mClient.wTop + 80);
    mpStart = new PegTextButton(tRect, "Start the Light", IDB_START);
    Add(mpStart);

    tRect.Shift(0, 50);
    mpStop = new PegTextButton(tRect, "Stop the Light", IDB_STOP);
    Add(mpStop);


}
Exemplo n.º 4
0
/*--------------------------------------------------------------------------*/
SIGNED PegWindow::Message(const PegMessage &Mesg)
{
    SIGNED Result = 0;
    PegMessage NewMessage;

    switch(Mesg.wType)
    {
    case PM_POINTER_MOVE:
        if (muMoveMode)
        {
            if (Mesg.Point.x != mMovePoint.x ||
                Mesg.Point.y != mMovePoint.y)
            {
                DrawMoveFrame(TRUE);
                mMovePoint = Mesg.Point;
                DrawMoveFrame(FALSE);
            }
        }
        else
        {
            if (StatusIs(PSF_SIZEABLE) && !mbMaximized)
            {
                UCHAR uTemp = BorderContains(Mesg.Point);

                if (uTemp != mbShowPointer)
                {
                    mbShowPointer = uTemp;

                    switch(uTemp)
                    {
                    case PMM_MOVELEFT:
                    case PMM_MOVERIGHT:
                        SetPointerType(PPT_HSIZE);
                        break;

                    case PMM_MOVETOP:
                    case PMM_MOVEBOTTOM:
                        SetPointerType(PPT_VSIZE);
                        break;

                    case PMM_MOVEUR:
                    case PMM_MOVELL:
                        SetPointerType(PPT_NESW_SIZE);
                        break;

                    case PMM_MOVEUL:
                    case PMM_MOVELR:
                        SetPointerType(PPT_NWSE_SIZE);
                        break;

                    default:
                        SetPointerType(PPT_NORMAL);
                        break;
                    }
                }
            }
        }
        break;

    case PM_SHOW:
        PegThing::Message(Mesg);

       #if defined(PEG_KEYBOARD_SUPPORT) && defined(PEG_TAB_KEY_SUPPORT)
        SetDefaultTabLinks();
       #endif

        if (muScrollMode & WSM_AUTOSCROLL)
        {
            CheckAutoScroll();
        }
        break;

    #if defined(PEG_KEYBOARD_SUPPORT)

    case PM_GAINED_KEYBOARD:
        if (!StatusIs(PSF_KEEPS_CHILD_FOCUS))
        {
            MoveFocusToFirstClientChild();
        }
        break;

    #else

    case PM_CURRENT:
        PegThing::Message(Mesg);
        if (Presentation()->GetCurrentThing() == this &&
            !StatusIs(PSF_KEEPS_CHILD_FOCUS))
        {
            MoveFocusToFirstClientChild();
        }
        break;

    #endif

    case PM_ADDICON:
        AddIcon((PegIcon *) Mesg.pData);
        break;

    case PM_BEGIN_MOVE:
        if (!muMoveMode && StatusIs(PSF_MOVEABLE))
        {
            muMoveMode = (UCHAR) Mesg.iData;
            mbMoveFrame = FALSE;
            CapturePointer();
            mStartMove = Mesg.Point;
            mMovePoint = mStartMove;

            if (muMoveMode == PMM_MOVELR)
            {
                SetPointerType(PPT_NWSE_SIZE);
                mbShowPointer = TRUE;
            }
        }
        break;

    case PM_POINTER_EXIT:
        if (mbShowPointer)
        {
            SetPointerType(PPT_NORMAL);
            mbShowPointer = 0;
        }
        PegThing::Message(Mesg);
        break;

    case PM_LBUTTONDOWN:
        if (!muMoveMode && StatusIs(PSF_SIZEABLE) && !mbMaximized)
        {
            muMoveMode = BorderContains(Mesg.Point);

            if (muMoveMode)
            {
                mbMoveFrame = FALSE;
                CapturePointer();
                mStartMove = Mesg.Point;
                mMovePoint = mStartMove;
            }
        }
        break;

    case PM_LBUTTONUP:
        if (muMoveMode)
        {
            DrawMoveFrame(TRUE);
            SetPointerType(PPT_NORMAL);
            ReleasePointer();
            PegRect OldSize = mReal;

            if (mStartMove.x == mMovePoint.x &&
                mStartMove.y == mMovePoint.y)
            {
                muMoveMode = 0;
                break;  // didn't really move or size anything
            }

            PegRect NewSize = mReal;
            int xShift = mMovePoint.x - mStartMove.x;
            int yShift = mMovePoint.y - mStartMove.y;

            switch(muMoveMode)
            {
            case PMM_MOVEALL:
                NewSize.Shift(xShift, yShift);
                break;

            case PMM_MOVERIGHT:
                NewSize.wRight += xShift;
                break;

            case PMM_MOVELEFT:
                NewSize.wLeft += xShift;
                break;

            case PMM_MOVETOP:
                NewSize.wTop += yShift;
                break;

            case PMM_MOVEBOTTOM:
                NewSize.wBottom += yShift;
                break;

            case PMM_MOVEUL:
                NewSize.wLeft += xShift;
                NewSize.wTop += yShift;
                break;

            case PMM_MOVELL:
                NewSize.wLeft += xShift;
                NewSize.wBottom += yShift;
                break;

            case PMM_MOVEUR:
                NewSize.wRight += xShift;
                NewSize.wTop += yShift;
                break;

            case PMM_MOVELR:
                NewSize.wRight += xShift;
                NewSize.wBottom += yShift;
                break;
            }
            CheckResizeRect(NewSize);

            NewMessage.wType = PM_SIZE;
            NewMessage.Rect = NewSize;
            Message(NewMessage);

            if (StatusIs(PSF_VISIBLE))
            {
                if (mReal.Contains(OldSize))
                {
                    Draw();
                }
                else
                {
                    Parent()->Draw();
                }
            }
            muMoveMode = 0;
        }
        break;

    case PM_VSCROLL:
        MoveClientObjects(0, Mesg.iData - (SIGNED) Mesg.lData);
        break;

    case PM_HSCROLL:
        MoveClientObjects(Mesg.iData - (SIGNED) Mesg.lData, 0);
        break;

    case PM_MAXIMIZE:
        if (StatusIs(PSF_SIZEABLE))
        {
            mbMaximized = TRUE;
            mRestore = mReal;
            NewMessage.wType = PM_SIZE;
            NewMessage.Rect = Parent()->mClient;
            Message(NewMessage);
            Draw();
        }
        break;

    case PM_MINIMIZE:
        if (StatusIs(PSF_SIZEABLE) && !IsModal())
        {
            NewMessage.wType = PM_ADDICON;
            PegIcon *pIcon = new PegIcon(this, mpIconMap);
            pIcon->Id(Id());
            NewMessage.pData = pIcon;
            NewMessage.pTarget = Parent();
            MessageQueue()->Push(NewMessage);
            Parent()->Remove(this);
        }
        break;

    case PM_RESTORE:
        if (StatusIs(PSF_SIZEABLE))
        {
            if (mbMaximized)
            {
                mbMaximized = FALSE;
                NewMessage.wType = PM_SIZE;
                NewMessage.Rect = mRestore;
                Message(NewMessage);
                Parent()->Draw();
            }
        }
        break;

   #ifdef PEG_KEYBOARD_SUPPORT
    case PM_KEY:
        if (Parent() == Presentation() &&
            Mesg.iData == PK_F4 &&
            (Mesg.lData & KF_CTRL))
        {
            NewMessage.wType = PM_CLOSE;
            NewMessage.pTarget = this;
            MessageQueue()->Push(NewMessage);
        }
        else
        {
            return PegThing::Message(Mesg);
        }
        break;
   #endif

    case PM_CLOSE:
        Destroy(this);
        return(IDB_CLOSE);

    case PEG_SIGNAL(IDB_CLOSE, PSF_CLICKED):
    case PEG_SIGNAL(IDB_OK, PSF_CLICKED):
    case PEG_SIGNAL(IDB_CANCEL, PSF_CLICKED):
    case PEG_SIGNAL(IDB_YES, PSF_CLICKED):
    case PEG_SIGNAL(IDB_NO, PSF_CLICKED):
    case PEG_SIGNAL(IDB_RETRY, PSF_CLICKED):
    case PEG_SIGNAL(IDB_ABORT, PSF_CLICKED):
    case PEG_SIGNAL(IDB_APPLY, PSF_CLICKED):
        Destroy(this);
        return(Mesg.iData);

    default:
        return (PegThing::Message(Mesg));
    }
    return (Result);
}
Exemplo n.º 5
0
/*--------------------------------------------------------------------------*/
void PegWindow::DrawMoveFrame(BOOL bErase)
{
    if (bErase)
    {
        if (!mbMoveFrame)
        {
            return;
        }
        mbMoveFrame = FALSE;
    }
    else
    {
        if (mbMoveFrame)
        {
            return;
        }
        mbMoveFrame = TRUE;
    }

    PegRect Invalid = mReal;

    if (mMovePoint.x > Parent()->mClient.wRight)
    {
        mMovePoint.x = Parent()->mClient.wRight;
    }
    else
    {
        if (mMovePoint.x < Parent()->mClient.wLeft)
        {
            mMovePoint.x = Parent()->mClient.wLeft;
        }
    }

    if (mMovePoint.y > Parent()->mClient.wBottom)
    {
        mMovePoint.y = Parent()->mClient.wBottom;
    }
    else
    {
        if (mMovePoint.y < Parent()->mClient.wTop)
        {
            mMovePoint.y = Parent()->mClient.wTop;
        }
    }
    int xShift = mMovePoint.x - mStartMove.x;
    int yShift = mMovePoint.y - mStartMove.y;

    switch(muMoveMode)
    {
    case PMM_MOVEALL:
        Invalid.Shift(xShift, yShift);
        break;

    case PMM_MOVERIGHT:
        Invalid.wRight += xShift;
        break;

    case PMM_MOVELEFT:
        Invalid.wLeft += xShift;
        break;

    case PMM_MOVETOP:
        Invalid.wTop += yShift;
        break;

    case PMM_MOVEBOTTOM:
        Invalid.wBottom += yShift;
        break;

    case PMM_MOVEUL:
        Invalid.wLeft += xShift;
        Invalid.wTop += yShift;
        break;

    case PMM_MOVELL:
        Invalid.wLeft += xShift;
        Invalid.wBottom += yShift;
        break;

    case PMM_MOVEUR:
        Invalid.wRight += xShift;
        Invalid.wTop += yShift;
        break;

    case PMM_MOVELR:
        Invalid.wRight += xShift;
        Invalid.wBottom += yShift;
        break;
    }

    CheckResizeRect(Invalid);

    PegRect OldClip = mClip;
    mClip = Parent()->mClip & Parent()->mClient;
    Invalidate(Invalid);
    BeginDraw();
    Screen()->RectangleXOR(this, Invalid);
    EndDraw();
    mClip = OldClip;
}
Exemplo n.º 6
0
/*--------------------------------------------------------------------------*/
void PegWindow::MoveClientObjects(SIGNED xShift, SIGNED yShift, BOOL bDraw)
{
    PegThing *Child = First();

    if (StatusIs(PSF_VISIBLE))
    {
        Invalidate();
    }

    while(Child)
    {
        if (!(Child->StatusIs(PSF_NONCLIENT)))
        {
            PegRect MoveRect = Child->mReal;
            MoveRect.Shift(xShift, yShift);
            Child->Resize(MoveRect);
        }
        Child = Child->Next();
    }

    if (!bDraw)
    {
        return;
    }

    #ifdef FAST_BLIT
     if (StatusIs(PSF_CURRENT))
     //if (Presentation()->First() == this)
     {
        // scroll as much as possible using RectMove()

        PegPoint Put;
        PegRect Invalid, SaveClip;

        // figure out what needs to be re-drawn

        Invalid = mClient & mClip;
        SaveClip = mClient;

        if (xShift)
        {
            Put.y = mClient.wTop;

            if (xShift > 0)
            {
                Invalid.wRight = Invalid.wLeft + xShift;
                SaveClip.wRight -= xShift;
                Put.x = mClient.wLeft + xShift;
            }
            else
            {
                Invalid.wLeft = Invalid.wRight + xShift;
                SaveClip.wLeft -= xShift;
                Put.x = mClient.wLeft;
            }
        }
        else
        {
            Put.x = mClient.wLeft;
            if (yShift > 0)
            {
                Invalid.wBottom = Invalid.wTop + yShift;
                SaveClip.wBottom -= yShift;
                Put.y = mClient.wTop + yShift;
            }
            else
            {
                Invalid.wTop = Invalid.wBottom + yShift;
                SaveClip.wTop -= yShift;
                Put.y = mClient.wTop;
            }
        }
        BeginDraw();
        Screen()->RectMove(this, SaveClip, Put);
        EndDraw();

        SaveClip = mClip;
        Invalidate(Invalid);
        mClip = Invalid;
        Draw();
        mClip = SaveClip;
        return;
    }
    #endif

     // for non-accelerated hardware,
     // forced to re-draw the client area:

     Draw();
}
Exemplo n.º 7
0
/*--------------------------------------------------------------------------*/
void PegAppInitialize(PegPresentationManager* pPresent)
{
	PegRect Rect;
	Rect.Set(10, 10, 630, 370);
	PegDecoratedWindow* pWindow = new PegDecoratedWindow(Rect);

	pWindow->Add(new PegTitle("PegDecoratedButton Example"));

	PegToolBar* pToolBar = new PegToolBar();
	pWindow->Add(pToolBar);

	pWindow->SetColor(PCI_NORMAL, BROWN);

	Rect = pWindow->mClient;
	Rect.wLeft += (pWindow->mClient.Width() >> 4);
	Rect.wTop += (pWindow->mClient.Height() >> 4);
	Rect.wRight = Rect.wLeft + 150;
	Rect.wBottom = Rect.wTop + 50;
	PegDecoratedButton* pButton = new PegDecoratedButton(Rect, "Text Only", NULL);
	pWindow->Add(pButton);

	Rect.Shift(175, 0);
	pButton = new PegDecoratedButton(Rect, NULL, &gbRedDotBitmap);
	pWindow->Add(pButton);

	Rect.Shift(175, 0);
	pButton = new PegDecoratedButton(Rect, "Text and Bitmap", &gbRedDotBitmap);
	pWindow->Add(pButton);

	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);

	// Now add some buttons to a toolbar panel. we'll just
	// let them size themselves and have the panel put them
	// where it wants them
	PegToolBarPanel* pPanel = new PegToolBarPanel();
	pButton = new PegDecoratedButton(0, 0, "Stop", &gbStopBitmap, 0, AF_ENABLED,
									 0, TRUE);
	pPanel->Add(pButton);

	pButton = new PegDecoratedButton(0, 0, "Refresh", &gbRefreshBitmap, 0, AF_ENABLED,
								     0, TRUE);
	pPanel->Add(pButton);

	pButton = new PegDecoratedButton(0, 0, "New", &gbNewBitmap, 0, AF_ENABLED,
								     0, TRUE);
	pPanel->Add(pButton);

	pToolBar->AddPanel(pPanel);

	// Center the window and add it to the presentation manager
	pPresent->Center(pWindow);
	pPresent->Add(pWindow);
}