// Draw this control to the screen. Draw the area empty with
// appropriate color. If the control is focused, draw shadow border.
void CMessageListBox::Draw(const TRect& aRect) const
{
    CWindowGc& gc = SystemGc();
    gc.SetClippingRect(aRect);
    gc.Clear(iBorder.OuterRect(aRect));
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);

    if (IsFocused())
    {
        CEikBorderedControl::Draw(iBorder.OuterRect(aRect)); // Shadow border
        gc.SetBrushColor(TRgb(KFocusedBkgColor));
    }
    else
    {
        gc.SetBrushColor(TRgb(KNonFocusedBkgColor));
    }

    // Fill the controls background. The color depends on the focus status. In
    // this example this has no effect, because contained controls are drawn
    // over the same area. Here just for demonstrating design principle.
    gc.DrawRect(Border().InnerRect(Rect()));
}
Пример #2
0
TRgb TRgb::Gray16(int aGray16)
/** Gets TRgb from 16 level grayscale. 

The function takes a grayscale argument and return a TRgb whose red, green 
and blue values are set to an appropriate level.

@param aGray16 Grayscale value to be converted. 
@return Equivalent 24 bit colour. Gray16 has 16 levels- the function returns 
r=g=b=17*c, where c=0, 1, ... 15. */
	{
	aGray16 *= 17;
	return TRgb(aGray16,aGray16,aGray16);
	}
Пример #3
0
void CWsRootWindow::ConstructL()
	{
	CWsWindow::Construct();
	iParent=NULL;
	iSibling=NULL;
	iChild=NULL;
	iClientHandle=NULL;
	iAbs.Resize(iScreen->SizeInPixels());
	iRel=iAbs;
	iFlags=EFlagPointerCaptured;
	iPointerFilter=EPointerFilterEnterExit|EPointerFilterMove|EPointerFilterDrag;
	iArea.AddRect(iAbs);
	iRedraw=new(ELeave) CWsBlankWindow(this);
	iRedraw->ConstructL();
	TInt backgroundcolor;
	if(!WsIniFile->FindVar(KDefaultBackgroundColor,backgroundcolor))
		backgroundcolor = KRgbWhite.Value();
	TInt backgroundalpha;
	if(!WsIniFile->FindVar(KDefaultBackgroundAlpha,backgroundalpha))
		backgroundalpha = 0xFF;	
	iDefaultBackgroundColor = TRgb(backgroundcolor,backgroundalpha);
	
	if (WsIniFile->FindVar(KNoBlank))
		BlankRedraw()->SetBackgroundClear();
	else
		{
		if (WsIniFile->FindVar(KRootWinDefaultBackgroundColor,backgroundcolor))
			SetColor(TRgb(backgroundcolor,backgroundalpha));
		else
			SetColor(iDefaultBackgroundColor);
		}

	MWsWindowTreeObserver* const windowTreeObserver = Screen()->WindowTreeObserver();
	if (windowTreeObserver)
		{
		windowTreeObserver->NodeCreated(*this, NULL);
		iBaseWinFlags |= EBaseWinNodeCreated;
		}
	}
Пример #4
0
TRgb TRgb::Gray4(int aGray4)
/** Gets TRgb from 4 level grayscale. 

The function takes a grayscale argument and return a TRgb whose red, green 
and blue values are set to an appropriate level.

@param aGray4 Grayscale value to be converted. 
@return Equivalent 24 bit colour. Gray4 has 4 levels- the function returns 
r=g=b=85*c, where c=0,1,2, or 3. */
	{
	aGray4 *= 85;
	return TRgb(aGray4,aGray4,aGray4);
	}
Пример #5
0
TRgb TRgb::Gray2(int aGray2)
/** Gets TRgb from 2 level grayscale. 

The function takes a grayscale argument and return a TRgb whose red, green 
and blue values are set to an appropriate level. 

@param aGray2 Grayscale value to be converted. 
@return Equivalent 24 bit colour. Gray2 has only 2 levels (black and white), -
the function returns r=g=b=0 or r=g=b=255. */
	{
	aGray2 *= 255;
	return TRgb(aGray2,aGray2,aGray2);
	}
Пример #6
0
TRgb TRgb::Color256(int aColor256)
/** Gets TRgb from 8 bit colour index.

The function takes an 8 bit index into a colour palette and returns a TRgb 
whose red, green and blue values are set to an appropriate level.

@param aColor256 8 bit index into a colour palette. 
@return Equivalent 24 bit colour. */
	{
	if (color256Palette)
		return color256Palette[aColor256&0xff];
	else
		return TRgb(color256array[aColor256&0xff]);
	}
Пример #7
0
EXPORT_C void CHuiCanvasGc::SetDefaults()
	{
	SetTextStyle(0);
    SetPenColor(TRgb(255,255,255));
	SetPenWidth(1.0);
	SetOpacity(1.0);
	SetPolygonDrawMode(EHuiNoFill);
	SetTextAlign(EHuiAlignHLeft, EHuiAlignVTop);
    SetDrawMode(EHuiCanvasDrawModeBlend);
    EnableEffectiveOpacity(ETrue);    
    SetPolygonFillTexture(NULL);
    SetPolygonFillTextureOrigin(TPoint(0,0));
	CancelClipping();
	}
Пример #8
0
void CInputDialog::InitInput(TInt aType)
{
	switch(aType)
	{
	case 1:
		{
			iEdwin=iMainEngine.EditorsManager().CreateEdwin(iRect,20,TRgb(0,0,0));
			break;
		}
	case 2:
		{
			iEdwin=iMainEngine.EditorsManager().CreateEdwin(iRect,20,TRgb(0,0,0));
			iEdwin->SetAknEditorInputMode(EAknEditorNumericInputMode);
			iEdwin->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);
			break;
		}
	}

	if(iEdwin)
	{
		iMainEngine.EditorsManager().SetCurEdwin(iEdwin);
	}
}
Пример #9
0
// -----------------------------------------------------------------------------
// CSIPExGameView::DrawCursor
// Draws the cursor.
// -----------------------------------------------------------------------------
//
void CSIPExGameView::DrawCursor( CWindowGc& aGc, const TRect& aRect ) const
    {
    CWindowGc& gc =aGc;

	gc.SetPenColor(TRgb(0,0,0));
	gc.SetBrushColor(TRgb(255,0,0));
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);


	TInt i = iEngine->Cursor();

	TPoint p1 = aRect.iTl;
	TPoint p2 = aRect.iBr;

	p1.iX = p1.iX + iXOffset + iMidW + (i*iMidW) + (i*iBoxW);
	p1.iY = p1.iY + iLabelSize  + iYOffset - iBoxW;

	p2.iX = p1.iX + iBoxW;
	p2.iY = p1.iY + iBoxW;

	TRect rect( p1, p2 ); 
	gc.DrawEllipse( rect );
    }
Пример #10
0
void CImage::DrawCursor(  )
    {
    DBG(RDebug::Print(_L(" CImage::DrawCursor Start")));

    iSpriteGc->SetPenStyle(CGraphicsContext::ESolidPen);
    iSpriteGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
    iSpriteGc->SetBrushColor(TRgb(255,255,255));
    iSpriteGc->SetPenColor(TRgb(255,255,255));

    if ( (iBitmapDevice) && (iBitmapMaskDevice) )
        {
        DBG(RDebug::Print(_L(" CImage::DrawCursor iBitmapMaskDevice")));
        // Draw mask
        iSpriteGc->Activate(iBitmapMaskDevice);
        iSpriteGc->BitBlt(iLastUsedPoint, iCursorBitmapMask);

        DBG(RDebug::Print(_L(" CImage::DrawCursor iBitmapMaskDevice")));

        // Draw bitmap
        iSpriteGc->Activate(iBitmapDevice);
        iSpriteGc->BitBlt(iLastUsedPoint, iCursorBitmap);
        }
    DBG(RDebug::Print(_L(" CImage::DrawCursor END")));
    }
Пример #11
0
void CGdiBlitMasked::doCreateTestBitmapL(CFbsBitmap *aBitmap, CFbsBitGc *&aGc, CFbsBitmapDevice *&aDevice, const TSize &aSize)
	{
	User::LeaveIfNull(aDevice=CFbsBitmapDevice::NewL(aBitmap));
	User::LeaveIfError(aDevice->CreateContext(aGc));
//
	aGc->SetBrushColor(TRgb(128,128,128));
	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
	aGc->SetPenStyle(CGraphicsContext::ENullPen);
	aGc->DrawRect(TRect(aBitmap->SizeInPixels()));
	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
	for(TInt index=(-aSize.iHeight);index<aSize.iWidth;index+=5)
		{
		aGc->DrawLine(TPoint(index,0),TPoint(index+aSize.iHeight,aSize.iHeight));
		aGc->DrawLine(TPoint(index,aSize.iHeight),TPoint(index+aSize.iHeight,0));
		}
	}
Пример #12
0
void CTestContainer::ConstructL()
	{
	iColor = KRgbBlack;
	CreateWindowL();
	RWindow window = Window();
	window.SetTransparencyAlphaChannel();
	window.SetBackgroundColor(TRgb(150,150,150,150));
	iAnimationsArray=new(ELeave) CArrayPtrFlat<CAnimation>(KArrayGranularity);
	
	//Set the background of the container window to the default. 
	iBackgroundType = EBackgroundBlackRedGreenYellowStripes;
	ActivateL();

	//Construct a window that can be used in test cases.
	iCoveringWindowControl = new (ELeave) CTestWindowControl;	
	iCoveringWindowControl->ConstructL();
	}
Пример #13
0
//////////////////////////////////////////////////////////////////////////
//From CControl
//////////////////////////////////////////////////////////////////////////
void CInputDialog::Draw(CGraphic& gc)const
{
	gc.SetPenColor(TRgb(0,0,0));
	gc.SetPenStyle(CBitmapContext::ESolidPen);
	gc.SetBrushStyle(CBitmapContext::ENullBrush);

	gc.BitBlt(iStartPoint,iDialogBmp);

	//画标题
	gc.DrawText(iStartPoint+TPoint(iMargin,iScreenLayout.FontHeight()/3),*iTitle);

	iBitmapFactory.DrawInputIconBmpByID(gc,iStartPoint+iIconPoint,iMainEngine.GetInputType()-1);
	//gc.BitBltMasked(iStartPoint+iIconPoint,iInputTypeIcon,iInputTypeIconMask);
	//画提示信息

	gc.DrawTextWithBlueUnderline(iStartPoint+TPoint(iMargin,(iScreenLayout.FontHeight()+iScreenLayout.FontHeight()/2)*2+iScreenLayout.FontHeight()/3),*iInfo);
}
Пример #14
0
void tst_NativeImageHandleProvider::bitmap()
{
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG)
    QPixmap tmp(10, 20);
    if (tmp.pixmapData()->classId() == QPixmapData::OpenVGClass) {
        BitmapProvider prov;

        // This should fail because of null ptr.
        QPixmap pm = pixmapFromNativeImageHandleProvider(&prov);
        QVERIFY(pm.isNull());
        pm = QPixmap();
        QCOMPARE(prov.refCount, 0);

        prov.bmp = new CFbsBitmap;
        QCOMPARE(prov.bmp->Create(TSize(prov.w, prov.h), EColor16MAP), KErrNone);
        CFbsBitmapDevice *bitmapDevice = CFbsBitmapDevice::NewL(prov.bmp);
        CBitmapContext *bitmapContext = 0;
        QCOMPARE(bitmapDevice->CreateBitmapContext(bitmapContext), KErrNone);
        TRgb symbianColor = TRgb(255, 200, 100);
        bitmapContext->SetBrushColor(symbianColor);
        bitmapContext->Clear();
        delete bitmapContext;
        delete bitmapDevice;

        pm = pixmapFromNativeImageHandleProvider(&prov);
        QVERIFY(!pm.isNull());
        QCOMPARE(pm.width(), prov.w);
        QCOMPARE(pm.height(), prov.h);
        QVERIFY(prov.refCount == 1);
        QImage img = pm.toImage();
        QVERIFY(prov.refCount == 1);
        QRgb pix = img.pixel(QPoint(1, 2));
        QCOMPARE(qRed(pix), symbianColor.Red());
        QCOMPARE(qGreen(pix), symbianColor.Green());
        QCOMPARE(qBlue(pix), symbianColor.Blue());

        pm = QPixmap(); // should result in calling release
        QCOMPARE(prov.refCount, 0);
        delete prov.bmp;
    } else {
         QSKIP("Not openvg", SkipSingle);
    }
#else
    QSKIP("Not applicable", SkipSingle);
#endif
}
Пример #15
0
/**
Alpha blends two bitmaps together

@param aDisplayMode1 is the source display mode
@param aDisplayMode2 is the destination display mode
@param aSession is the windows server session
@param aWindow is a reference to the window
@param aGc is the graphics context of the window
@param aNumIterations is the number of iterations to run the test
*/	
void CAlphaBlendTest::DoAlphaBlendBitmapsBitmapTestL(TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
	{
	const TSize bitmapSize = aWindow.Size();	

	CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
	CleanupStack::PushL(bitmapDevice);
	
	CFbsBitGc* bitmapGc=NULL;
	User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));	
	CleanupStack::PushL(bitmapGc);
		
	CFbsBitmap* sourceUnder  = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
	CFbsBitmap* sourceOver   = CreateSoftwareBitmapLC(bitmapSize, aSrcMode);
	CFbsBitmap* sourceAlpha  = CreateSoftwareBitmapLC(bitmapSize, EGray256);

	VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
	VerticalGradientAlphaL(sourceUnder, TRgb(0xff000000), TRgb(0x00ffffff));
	VerticalGradientAlphaL(sourceOver, TRgb(0x00ffffff), TRgb(0xff000000));
	RDebug::Printf("DABBBT 2");

	TPoint point(0,0);
	TRect  rect(bitmapSize);
	
	bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
	bitmapGc->SetBrushColor(TRANSPARENT_BLACK);

	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
	bitmapGc->Clear();
	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
	bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);		

	aGc->Activate(aWindow);
	aGc->BitBlt(point, bitmapTarget);
	aGc->Deactivate();
	aSession.Flush();

	iProfiler->InitResults();
	// blend sourceUnder with sourceOver using alpha mask
	for(TInt i=0; i<aNumIterations; i++)
	{
		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
		bitmapGc->Clear();
		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
		bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);
		iProfiler->MarkResultSetL();
	}
	iProfiler->ResultsAnalysis(_L("DoAlphaBlendBitmapsBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations);
	
	// copy up to screen for sanity check
	BitBlt(aSession, aWindow, aGc, *bitmapTarget);	
	CleanupStack::PopAndDestroy(6, bitmapTarget); // sourceAlpha, sourceOver, sourceUnder, bitmapGc, bitmapDevice, bitmapTarget
	}	
void CEglTest_TestStep_StressLoad::LoadGpuMemoryL()
    {
    const TInt KMaxSurfaceAllocs = 1000;
    CSurface **surfaces = new CSurface*[KMaxSurfaceAllocs];
    ENGINE_ASSERT(surfaces);
    TInt nSurfaces = 0;
    TInt err;
    while(!__e32_atomic_load_acq32(&iStopThreadFlag[EThreadLoadGpuMemory]))     
        {
        ENGINE_ASSERT(nSurfaces < KMaxSurfaceAllocs);
        CSurface* s = CSurface::SurfaceFactoryL(ESurfTypePBuffer);
        if (s)
            {
            TRAP(err, s->CreateL(ELargeSurface));
            if (err == KErrNone)
                {
                surfaces[nSurfaces++] = s;
                TRAP(err, s->DrawContentL(TRgb(0x10, 0x20, 0xB0)));
                }
            else
                {
                delete s;
                s = NULL;
                }
            }
        if (!s)
            {
            User::After(100 * 1000);
            TInt nRelease = nSurfaces / 4;
            for(TInt i = 0; i < nRelease; i++)
                {
                delete surfaces[--nSurfaces];
                surfaces[nSurfaces] = NULL;
                }
            User::After(100 * 1000); // 100 ms. 
            }
        }
    while(nSurfaces)
        {
        delete surfaces[--nSurfaces];
        }
    delete [] surfaces;
    eglReleaseThread();
    }
void CSpaceInvadersAppView::DrawPoints(CWindowGc& aGc) const
{
    TRgb pencolor = TRgb(255,255,255);
    aGc.SetPenColor(pencolor);
    _LIT(KPointsText, "Points: ");

    TBufC<15> pointsText;
    TPtr pointsPtr = pointsText.Des();
    pointsPtr.Append(KPointsText);
    pointsPtr.AppendNum(iHolder->ActivePoints());

    const CFont* menuFont =
        AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont, NULL);
    aGc.UseFont(menuFont);
    TInt textLength = menuFont->TextWidthInPixels(pointsPtr);
    TInt textHeight = menuFont->HeightInPixels();
    TPoint textpoint(Rect().Width() / 2 - textLength / 2, textHeight);
    aGc.DrawText(pointsPtr, textpoint);
}
void CBuddycloudListComponent::ConfigureSkin() {
	// Background
	if(iBgContext) {
		delete iBgContext;
	}
	
	iBgContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaMain, iRect, false);
	
	// Colors
	AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), iColourTextSelected, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10);
	// AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), iColourTextLink, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG3);
	AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), iColourTextLink, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG21);
	AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), iColourText, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
	
	iColourTextLink = TRgb((iColourTextLink.Red() + iColourTextSelected.Red()) / 2, (iColourTextLink.Green() + iColourTextSelected.Green()) / 2, (iColourTextLink.Blue() + iColourTextSelected.Blue()) / 2);
	
	iColourTextSelectedTrans = iColourTextSelected;
	iColourTextSelectedTrans.SetAlpha(85);
}
void CSpaceInvadersAppView::DrawQuitCommand(CWindowGc& aGc) const
{
    TRgb pencolor = TRgb(255,255,255);
    aGc.SetPenColor(pencolor);
    _LIT(KQuitText, "Quit");

    TBufC<4> quitText;
    TPtr quitPtr = quitText.Des();
    quitPtr.Append(KQuitText);

    const CFont* menuFont =
        AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont, NULL);
    aGc.UseFont(menuFont);
    TInt textLength = menuFont->TextWidthInPixels(quitPtr);
    TInt textHeight = menuFont->HeightInPixels();
    TPoint textpoint(Rect().Width() - ( textLength + 10 ),
                     Rect().Height() - textHeight);
    aGc.DrawText(quitPtr, textpoint);
}
void CHuiShadowBorderBrush::Draw(CHuiGc& aGc, const MHuiBrushGuide& aGuide) const
    {
    TRect content = aGuide.BrushRect().Round();
    TReal32 opacity = aGuide.BrushOpacity() * iOpacity.Now();

    if(opacity <= 0)
        {
        return;
        }

    aGc.SetPenAlpha(TInt(opacity * 255));
    aGc.SetPenColor(TRgb(0, 0, 30));

    const CHuiTexture* shadowTexture = NULL;
    TInt err = aGuide.BrushSkin().GetTexture(EHuiSkinShadowTexture, shadowTexture);
    if (err!=KErrNone)
    	{
    	ASSERT(EFalse); // failed to get the shadow texture - unable to proceed!
    	return;
	    }
    ASSERT(shadowTexture);
    THuiImage shadowImage(*shadowTexture);

    aGc.Disable(CHuiGc::EFeatureDepthWrite);
    
    TReal32 widthInPixels = WidthInPixels(BrushGuide()); 
    content.Grow(HUI_ROUND_FLOAT_TO_INT(widthInPixels), HUI_ROUND_FLOAT_TO_INT(widthInPixels)); 
    
    // ID:  EHJK-7G5AHB - shadow border leaves artifacts in the display while visual is moved.
    TReal32 offset = 0.0f; // NOTE: It was 1.f. 

    // Note: DrawBorders does not (yet) support different widths for every border.
    aGc.DrawBorders(content, 
                    widthInPixels-offset, 
                    widthInPixels+offset, 
                    widthInPixels-offset, 
                    widthInPixels+offset, 
                    CHuiGc::EBorderImage, 
                    &shadowImage);            

    aGc.Enable(CHuiGc::EFeatureDepthWrite);
    }
Пример #21
0
EXPORT_C TRgb ColorUtils::RgbDarkerColor(TRgb aRgb, TDisplayMode aMode)
/** Creates a darker color.

@param aRgb The RGB color.
@param aMode The display mode, which indicates the screen output of the colour 
e.g. 256 colour display mode (8 bpp).
@return The darker colour. */
	{
	switch (aMode)
		{
	case EColor256:
		return TRgb::Color256(color256darklutab[aRgb.Color256()]);
	default:
		TInt value = aRgb.Internal();
		TInt b = Max( 0, ((value & 0x000000ff)  ) - KDarkRgbSubtractor );
		TInt g = Max( 0, ((value & 0x0000ff00)  >> 8) - KDarkRgbSubtractor );
		TInt r = Max( 0, ((value & 0x00ff0000)  >> 16) - KDarkRgbSubtractor );
		return TRgb(r,g,b,aRgb.Alpha());
		}
	}
Пример #22
0
EXPORT_C TRgb ColorUtils::RgbLighterColor(TRgb aRgb, TDisplayMode aMode)
/** Creates a lighter colour.

@param aRgb The Rgb colour.
@param aMode The display mode, which indicates the screen output of the colour 
e.g. 256 colour display mode (8 bpp).
@return The lighter colour. */
	{
	switch (aMode)
		{
	case EColor256:
		return TRgb::Color256(color256lightlutab[aRgb.Color256()]);
	default:
		TInt value = aRgb.Internal();
		TInt b = Min( 255, ((value & 0x000000ff)  ) + KLightRgbAdder );
		TInt g = Min( 255, ((value & 0x0000ff00)  >> 8) + KLightRgbAdder );
		TInt r = Min( 255, ((value & 0x00ff0000)  >> 16) + KLightRgbAdder );
		return TRgb(r,g,b,aRgb.Alpha());
		}
	}
Пример #23
0
void TestRgb::TestSet()
	{
	TRgb c1;
	TRgb c2(128,128,128);
	TRgb c3(500,500,500);
	TRgb c4(iR,iG,iB);
	TRgb c5(500,600,700);
	iTest->TEST(c2.Red()==128);
	iTest->TEST(c2.Green()==128);
	iTest->TEST(c2.Blue()==128);
	iTest->TEST(c3.Red()<256);
	iTest->TEST(c3.Green()<256);
	iTest->TEST(c3.Blue()<256);
	iTest->TEST(c4.Red()==iR && c4.Green()==iG && c4.Blue()==iB);
	iTest->TEST(c5.Red()<256);
	iTest->TEST(c5.Green()<256);
	iTest->TEST(c5.Blue()<256);
	c1=c4;
	iTest->TEST(c1.Red()==iR && c1.Green()==iG && c1.Blue()==iB);
	c1=TRgb(64,128,192);
	iTest->TEST(c1.Red()==64);
	iTest->TEST(c1.Green()==128);
	iTest->TEST(c1.Blue()==192);
	c1=c5;
	iTest->TEST(c1.Red()<256);
	iTest->TEST(c1.Green()<256);
	iTest->TEST(c1.Blue()<256);
	c1=TRgb::Gray4(3);
	iTest->TEST(c1.Red()==255 && c1.Green()==255 && c1.Blue()==255);
	c1=TRgb::Gray16(15);
	iTest->TEST(c1.Red()==255 && c1.Green()==255 && c1.Blue()==255);
	c1=TRgb::Gray256(255);
	iTest->TEST(c1.Red()==255 && c1.Green()==255 && c1.Blue()==255);
	c1=TRgb::Gray4(4);
	iTest->TEST(c1.Red()<256 && c1.Green()<256 && c1.Blue()<256);
	c1=TRgb::Gray16(16);
	iTest->TEST(c1.Red()<256 && c1.Green()<256 && c1.Blue()<256);
	c1=TRgb::Gray256(256);
	iTest->TEST(c1.Red()<256 && c1.Green()<256 && c1.Blue()<256);
	iTest->TEST(c4.Red()==iR && c4.Green()==iG && c4.Blue()==iB);
	}
Пример #24
0
/****************************************************************************\
|	Function:	CNumberedWindow::Draw
 |	Purpose:	Redraws the contents of CNumberedWindow within a given
 |				rectangle.  CNumberedWindow displays a number in the window.
 |	Input:		aRect	Rectangle that needs redrawing
 |	Output:		None
 \****************************************************************************/
void CNumberedWindow::Draw(const TRect& aRect)
    {
    const TBufC<1> strings[5] =
        {
        *&KString1, *&KString2, *&KString3, *&KString4, *&KString5
        };

    CWindowGc* gc = SystemGc(); // get a graphics context
    gc->SetClippingRect(aRect); // clip outside the redraw area
    gc->Clear(aRect); // clear the redraw area
    TSize size = iWindow.Size();
    TInt height = size.iHeight; // Need window height to calculate vertical text offset
    TInt ascent = Font()->AscentInPixels();
    TInt descent = Font()->DescentInPixels();
    TInt offset = (height + (ascent + descent)) / 2; // Calculate vertical text offset
    gc->SetPenColor(TRgb(0, 0, 0)); // Set pen to black
    gc->UseFont(Font());
    gc->DrawText(strings[iNumber], TRect(TPoint(0, 0), size), offset,
            CGraphicsContext::ECenter);
    gc->DiscardFont();
    }
Пример #25
0
void CExampleWsClient::ConstructMainWindowL()
    {
    // Resources allocated in this function are freed in the CExampleWsClient destructor

    iMainWindow = new (ELeave) CMainWindow(this);
    iMainWindow->ConstructL(iRect, TRgb(255, 255, 255));
    TInt count = 0;
    TRect rect(TPoint(100, 0), TSize(100, 100));
    iWindow1 = new (ELeave) CNumberedWindow(this, count++);
    iWindow1->ConstructL(rect, TRgb(50, 50, 50), iMainWindow);
    iWindow2 = new (ELeave) CNumberedWindow(this, count++);
    iWindow2->ConstructL(rect, TRgb(100, 100, 100), iMainWindow);
    iWindow3 = new (ELeave) CNumberedWindow(this, count++);
    iWindow3->ConstructL(rect, TRgb(150, 150, 150), iMainWindow);
    iWindow4 = new (ELeave) CNumberedWindow(this, count++);
    rect.Shrink(10, 10);
    iWindow4->ConstructL(rect, TRgb(200, 200, 200), iWindow1);
    iWindow5 = new (ELeave) CNumberedWindow(this, count++);
    iWindow5->ConstructL(rect, TRgb(150, 150, 150), iWindow1);
    }
Пример #26
0
TRgb TSchemeOrange::Color(int aIndex) const
	{
	// color rotation for palette
	if (aIndex == 0)
		return TRgb(0x00000000);
	else if (aIndex == 0xff)
		return TRgb(0x00ffffff);
	else if (aIndex == 215)
		return TRgb(0x00dd00dd);
	else if (aIndex < StandardGrayBase)
		{
		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
		}
	else if (aIndex < SchemeSpecificColorBase)
		{
		int gray = aIndex - StandardGrayBase;
		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
		}
	else
		{
		return TRgb(KSchemeOrange[aIndex - SchemeSpecificColorBase]);
		}
    };
Пример #27
0
//
// The test:
//
CAnimationTestStep::CAnimationTestStep():
	iBackgroundColor1(TRgb(0xFF8080)),
	iBackgroundColor2(TRgb(0xFF0000))
	{
	}
// ---------------------------------------------------------------------------
// CMMACameraWindow::DrawViewFinderError()
// Draws the error message to specified area.
// Used in cases when viewfinder is unable to start.
// ---------------------------------------------------------------------------
//
void CMMACameraWindow::DrawViewFinderErrorL(
    const TInt /*aError*/,
    const TRect& aDrawRect)
{

    ASSERT(iDirectAccess);
    TInt dcError = KErrNone;
    if (!iDirectAccess->IsActive())
    {
        TRAP(dcError, iDirectAccess->StartL());
    }

    TRect drawRect(aDrawRect);

    if (dcError == KErrNone)
    {
        drawRect.Intersection(iClientRect);
        drawRect.Move(-iWindow->AbsPosition());

        CFbsBitGc* directGc = iDirectAccess->Gc();
        directGc->SetClippingRect(drawRect);
        directGc->SetBrushColor(TRgb(128,128,128));
        directGc->SetPenColor(TRgb(128,0,0));
        directGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
        directGc->SetPenStyle(CGraphicsContext::ESolidPen);
        directGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
        directGc->DrawRect(drawRect);

        if (!iErrorIconBitmap || !iErrorIconMaskBitmap)
        {
            if (iErrorIconBitmap)
            {
                delete iErrorIconBitmap;
                iErrorIconBitmap = NULL;
            }

            if (iErrorIconMaskBitmap)
            {
                delete iErrorIconMaskBitmap;
                iErrorIconMaskBitmap = NULL;
            }
            /*
                        AknsUtils::CreateIconL(
                            AknsUtils::SkinInstance(),
                            KAknsIIDQgnIndiCam4Camera,
                            iErrorIconBitmap,
                            iErrorIconMaskBitmap,
                            KCameraAppBitmapFile,
                            EMbmCameraappQgn_indi_cam4_camera,
                            EMbmCameraappQgn_indi_cam4_camera_mask
                        );
                        */
        }

        //TRect iconRect
        drawRect.iTl.iX += KErrorIconMargin;
        drawRect.iTl.iY += KErrorIconMargin;
        drawRect.iBr.iX -= KErrorIconMargin;
        drawRect.iBr.iY -= KErrorIconMargin;

        if (iErrorIconBitmap->SizeInPixels() != drawRect.Size())
        {
            AknIconUtils::SetSize(iErrorIconBitmap, drawRect.Size());
            AknIconUtils::SetSize(iErrorIconMaskBitmap, drawRect.Size());
        }

        directGc->BitBltMasked(
            drawRect.iTl, iErrorIconBitmap,
            TRect(iErrorIconBitmap->SizeInPixels()),
            iErrorIconMaskBitmap, EFalse);

        iDirectAccess->ScreenDevice()->Update();
    }

}
TRgb DarkGray()
{
	return TRgb(0x33,0x33,0x33);
}
TRgb Gray()
{
	return TRgb(100,100,100);
}