⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 progbuildview.cpp

📁 如题 就是 这东西 为什么非要我 说到 20个 字 呢 看看这回 够 不
💻 CPP
字号:
// ProgBuildView.cpp
//
// Copyright (c) 1999-2007 Symbian Software Ltd.  All rights reserved.
//
// $Change: 937687 $

// PROJECT HEADERS
#include "ProgBuildView.h"

const TUint KDataControlWidth = 200;

CDataControl* CDataControl::NewL(const CCoeControl& aCont, const TRect& aRect, RCountServ& aCounter)
    {
    CDataControl* self = NewLC(aCont, aRect, aCounter);
    CleanupStack::Pop(self);
    return self;
    }

CDataControl* CDataControl::NewLC(const CCoeControl & aCont, const TRect& aRect, RCountServ& aCounter)
    {
    CDataControl* self = new(ELeave) CDataControl(aCounter);
    CleanupStack::PushL(self);
    self -> ConstructL(aCont, aRect);
    return self;
    }

CDataControl::CDataControl(RCountServ& aCounter)
    :iCounter(aCounter)
    {
    }

void CDataControl::ConstructL(const CCoeControl & aCont, const TRect& aRect)
    {
    SetContainerWindowL(aCont);
    SetRect(aRect);
    ActivateL();
    }

void CDataControl::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetClippingRect(aRect);
    TRect drawRect = Rect();

    // Calculate upper and lower half of control
    TUint height = drawRect.iBr.iY - drawRect.iTl.iY;
    TRect topRect(drawRect.iTl.iX, drawRect.iTl.iY, drawRect.iBr.iX, drawRect.iTl.iY + (height / 2));
    TRect bottomRect(drawRect.iTl.iX, drawRect.iTl.iY + (height / 2), drawRect.iBr.iX, drawRect.iBr.iY);
    gc.DrawRect(drawRect);

    // Shrink upper and lower control for cosmetic reasons
    bottomRect.Shrink(1, 1);
    topRect.Shrink(1, 1);
    const CFont* font = iEikonEnv->TitleFont();
    gc.UseFont(font);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    TUint topbaseline = topRect.Height() / 2 + font->AscentInPixels() / 2;
    TUint bottombaseline = bottomRect.Height() / 2 + font->AscentInPixels() / 2;

    // Draw Label
    _LIT(KCounterTxt, "Counter Value:");
    TBuf<15> Label(KCounterTxt);
    gc.DrawText(Label, topRect, topbaseline, CGraphicsContext::ECenter);

    // Draw Body Location
    _LIT(KFormat, "%d");
    TBuf<10> buffer(KFormat);
    buffer.Format(KFormat, iCounter.CounterValue());
    gc.DrawText(buffer, bottomRect, bottombaseline, CGraphicsContext::ECenter);
    gc.DiscardFont();
    }

// ~CProgBuildView
CProgBuildView::~CProgBuildView()
    {
    delete iControl;
    }

CProgBuildView::CProgBuildView(RCountServ& aCounter)
    :iCounter(aCounter)
    {
    }

// ConstructL
// Initial object setup chores.
void CProgBuildView::ConstructL(const TRect& aRect) 
    {
    CreateWindowL();
    Window().SetShadowDisabled(ETrue);
    SetRect(aRect);
    const TInt KViewHeight = aRect.Height();
    TInt KDataControlHeight = KViewHeight / 3;
    TPoint centre = aRect.Center();
    TPoint topLeft = centre;
    topLeft.iX -= KDataControlWidth / 2;
    topLeft.iY -= (KDataControlHeight / 2);
    TInt offset = aRect.iTl.iY; //When build iControl: top left of parent window = (0,0) 
                                //Not (0,offset) which ClientRect() returns as top left for
                                //CProgView window
    topLeft.iY -= offset;
    TPoint bottomRight = centre;
    bottomRight.iX += KDataControlWidth / 2;
    bottomRight.iY += (KDataControlHeight / 2);
    bottomRight.iY -= offset;
    iControl = CDataControl::NewL(*this, TRect(topLeft, bottomRight), iCounter);
    ActivateL();
    }

// Draw
void CProgBuildView::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }

TInt CProgBuildView::CountComponentControls() const
    {
    return 1;
    }

CCoeControl* CProgBuildView::ComponentControl(TInt aIndex) const
    {
    switch (aIndex)
        {
        case 0: return iControl;
        default: return 0;
        };
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -