コード例 #1
0
ファイル: Drawer.cpp プロジェクト: jinhuafeng/RS-MAN
void TDrawer::DrawTitleBackground(CWsBitmap* aBackUpBitmap, CWsBitmap* aResourceBitmap)
{
    TRect resourceRect = ipBitMapPosition->GetPosition(TBitMapPosition::EGameTitle, 0);
    TBitmapUtil objectUtil(aResourceBitmap);
    TBitmapUtil backUpUtil(aBackUpBitmap);
    //
    objectUtil.Begin(TPoint(0, 0));
    backUpUtil.Begin(TPoint(0, 0));
    R8G8B8* addr1 = (R8G8B8*) aResourceBitmap->DataAddress();// 对象
    R8G8B8* addr2 = (R8G8B8*) aBackUpBitmap->DataAddress();// 背景
    TSize desSize = aBackUpBitmap->SizeInPixels();
    TSize sourceSize;
    sourceSize.SetSize(resourceRect.iBr.iX - resourceRect.iTl.iX + 1, resourceRect.iBr.iY - resourceRect.iTl.iY + 1);
    TSize srcSize = aResourceBitmap->SizeInPixels();
    R8G8B8* addr22;
    R8G8B8* addr11;
    //TInt iCounts = desSize.iWidth * sourceSize.iWidth;
    TInt iWidthSpan = srcSize.iWidth - sourceSize.iWidth;
    addr22 = addr2;
    addr11 = addr1 + resourceRect.iTl.iY * srcSize.iWidth + resourceRect.iTl.iX;
    for (TInt j = 0; j < sourceSize.iHeight; j++)
    {
        for (TInt i = 0; i < desSize.iWidth; i++)
        {
            *addr22 = *addr11;
            addr22++;
            addr11++;
        }
        addr11 = addr11 + iWidthSpan;
    }
    backUpUtil.End();
    objectUtil.End();
}
コード例 #2
0
ファイル: WINS.CPP プロジェクト: cdaffara/symbiandump-os1
//Gets the Size dimension the RWindow is using as per orientation
TSize RWindows::GetOrientedSize()
	{
	TSize orientedSize;
	if (iOrientation&1)
	orientedSize.SetSize(iEpocBitmapSize.iHeight,iEpocBitmapSize.iWidth);
	else
	orientedSize = iEpocBitmapSize;

	return orientedSize;
	}
コード例 #3
0
void CSupImageHandler::LoadFileL(const TFileName& aFileName, TInt aSelectedFrame)
	{
	__ASSERT_ALWAYS(!IsActive(),User::Invariant());
	// create a CImageDecoder to read the specified file
	delete iLoadUtil;
	iLoadUtil = NULL;
	iLoadUtil = CImageDecoder::FileNewL(iFs, aFileName);
	// store the frame information and frame count
	iFrameInfo = iLoadUtil->FrameInfo(aSelectedFrame);
	iFrameCount = iLoadUtil->FrameCount();

	// resize the destination bitmap to fit the required size
	//TRect bitmapSize = iFrameInfo.iFrameCoordsInPixels;

	TSize bitmapSize = iFrameInfo.iOverallSizeInPixels;

	// Calculate scale factor,
	// if required
	if (bitmapSize.iWidth > KImageWidthThreshold || bitmapSize.iHeight > KImageHeightThreshold)
	{
		TUint hScaleFactor = bitmapSize.iWidth/KImageWidthThreshold;
		TUint vScaleFactor = bitmapSize.iHeight/KImageHeightThreshold;
		// apply the same scale factor to both horizontal and vertical
		TUint scaleFactor = 1;
		if (hScaleFactor <= vScaleFactor)
			scaleFactor = hScaleFactor;
		else
			scaleFactor = vScaleFactor;

		if (scaleFactor >= 4)
			scaleFactor = 4;
		else if (scaleFactor >= 2)
			scaleFactor = 2;
		else
			scaleFactor = 1;

		// we need a correction pixel on each coordinate if the size is not divisible with scale factor; the
		// decoder will not work otherwise
		TUint hCorrection = 0;
		if (bitmapSize.iWidth % scaleFactor)
			hCorrection = 1;
		TUint vCorrection = 0;
		if (bitmapSize.iHeight % scaleFactor)
			vCorrection = 1;
		// the magic formula for calculating the final size
		bitmapSize.SetSize(bitmapSize.iWidth/scaleFactor + hCorrection, bitmapSize.iHeight/scaleFactor + vCorrection);

	}

	//iBitmap.Resize(bitmapSize.Size());
	iBitmap.Resize(bitmapSize);
	// start reading the bitmap: RunL called when complete
	iLoadUtil->Convert(&iStatus, iBitmap, aSelectedFrame);
	SetActive();
	}
コード例 #4
0
ファイル: FBSFONT.CPP プロジェクト: cdaffara/symbiandump-os1
/** Gets the character metrics and the glyph bitmap. 
@param aCode The character code in Unicode. 
@param aMetrics On return, contains the character metrics. 
@param aBitmap On return, contains a pointer to the compressed glyph bitmap. 
@param aBitmapSize The size of the returned glyph bitmap in pixels. This is 
not necessarily the same as the size implied by the returned metrics, which 
may incorporate algorithmic multiplication. 
@publishedAll 
@released
*/
EXPORT_C CFont::TCharacterDataAvailability CFbsFont::DoGetCharacterData(TUint aCode,TOpenFontCharMetrics& aMetrics,
		const TUint8*& aBitmap,TSize& aBitmapSize) const
	{
	aBitmap = NULL;
	if (!iHandle)
		return CFont::ENoCharacterData;

	CBitmapFont* bitmap_font = Address();

	if (!bitmap_font->GetCharacterData(iFbs->ServerSessionHandle(),aCode,aMetrics,aBitmap))
		{
		TPckgBuf<TRasterizeParams> paramsBuf;
		TIpcArgs args(iHandle, aCode, &paramsBuf);
		
		if(iFbs->SendCommand(EFbsMessRasterize, args))
			{				
			// Translate the offsets sent to the server back to pointers relative to
			// the heap base of the current process
			const TOpenFontCharMetrics* metrics = (const TOpenFontCharMetrics*)OffsetToPointer(paramsBuf().iMetricsOffset, iFbs->HeapBase());
			if (metrics)
				{
				aMetrics = *metrics;
				}
			aBitmap = static_cast<TUint8*>(OffsetToPointer(paramsBuf().iBitmapPointerOffset, iFbs->HeapBase()));			
			}
		else
			{
			return CFont::ENoCharacterData;
			}
		}

	aBitmapSize.SetSize(aMetrics.Width(),aMetrics.Height());

	if (!bitmap_font->IsOpenFont())
		{
		TAlgStyle null_style;
		if (!(bitmap_font->iAlgStyle == null_style))
			{
			const int width_factor = bitmap_font->iAlgStyle.WidthFactor();
			const int height_factor = bitmap_font->iAlgStyle.HeightFactor();
			const int bold_addition =	bitmap_font->iAlgStyle.IsBold() ? width_factor : 0;
			const int italic_addition = bitmap_font->iAlgStyle.IsItalic() ? width_factor : 0;

			aMetrics.SetWidth(aMetrics.Width() * width_factor + bold_addition + italic_addition);
			aMetrics.SetHeight(aMetrics.Height() * height_factor);
			aMetrics.SetHorizBearingX(aMetrics.HorizBearingX() * width_factor);
			aMetrics.SetHorizBearingY(aMetrics.HorizBearingY() * height_factor);
			aMetrics.SetVertBearingX(aMetrics.VertBearingX() * width_factor);
			aMetrics.SetVertBearingY(aMetrics.VertBearingY() * height_factor);
			if (bitmap_font->iAlgStyle.IsMono())
				aMetrics.SetHorizAdvance(bitmap_font->CBitmapFont::DoMaxNormalCharWidthInPixels() + bold_addition);
			else
				aMetrics.SetHorizAdvance(aMetrics.HorizAdvance() * width_factor + bold_addition);
			aMetrics.SetVertAdvance(aMetrics.VertAdvance() * height_factor);
			}
		}
	return CFont::EAllCharacterData;
	}
コード例 #5
0
// -----------------------------------------------------------------------------
// CTestSDKNotes::TestNPIMinimumSizeL
// -----------------------------------------------------------------------------
TInt CTestSDKNotes::TestNPIMinimumSizeL( CStifItemParser& /*aItem*/ )
    {
    CEikProgressInfo::SInfo sInfo;
    CEikProgressInfo* progress = new (ELeave) CEikProgressInfo( sInfo );
    CleanupStack::PushL( progress );
    STIF_ASSERT_NOT_NULL( progress );
    progress->ConstructL();
    
    TSize size = progress->MinimumSize();
    TPoint point = size.AsPoint();
    STIF_ASSERT_NOT_EQUALS( 0, point.iX );
    STIF_ASSERT_NOT_EQUALS( 0, point.iY );
    
    CleanupStack::PopAndDestroy( progress );
    
    return KErrNone;
    
    }
コード例 #6
0
//
/// Overrides TWindow::SetupWindow to create tooltips for the gadget window.
//
void
TGadgetWindow::SetupWindow()
{
  TWindow::SetupWindow();

  // if 'WantTimer' is enabled, start a timer
  //
  if (WantTimer)
    EnableTimer();

  if (DirtyLayout)    // !CQ latest OWL 5 was here...
    LayoutSession();

  // Now that this window is created, see if any of the gadgets have changed
  // sizes (like control gadgets). If so, remember the size & relayout the
  // gadgets. Also adjust the size of this gadget window to match what we want.
  // !CQ should do or is done earlier? Like EvWindowPosChanging??
  //
  TSize  size;
  GetDesiredSize(size);

//  if (DirtyLayout)  // !CQ was here in old OWL 5, & Conrad's is here...
//    LayoutSession();

  if (ShrinkWrapWidth  && Attr.W != size.cx ||
      ShrinkWrapHeight && Attr.H != size.cy)
  {
    if (ShrinkWrapWidth)
      Attr.W = size.cx;
    if (ShrinkWrapHeight)
      Attr.H = size.cy;

    LayoutSession();
    SetWindowPos(0, 0, 0, size.X(), size.Y(),
                 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
  }

  // Create toolips after all other windows have been created.
  ///JGD This fixes problem with tooltips and dialog initially showing
  ///JGD up behind the main window (BTS 43768)
  //
  PostMessage( WM_OWLCREATETTIP );
}
コード例 #7
0
// -----------------------------------------------------------------------------
// CTestSDKEditors::TestSEMinimumSizeL
// -----------------------------------------------------------------------------
//
TInt CTestSDKEditors::TestSEMinimumSizeL( CStifItemParser& /*aItem*/ )
    {
    CEikSecretEditor* secretEditor = new (ELeave) CEikSecretEditor;
    CleanupStack::PushL( secretEditor );
    STIF_ASSERT_NOT_NULL( secretEditor );
    
    TResourceReader reader;
    CCoeEnv::Static()->CreateResourceReaderLC( reader, R_TESTSDK_SECRETTEXT );
    secretEditor->ConstructFromResourceL( reader );
    CleanupStack::PopAndDestroy();
    
    TSize size = secretEditor->MinimumSize();
    STIF_ASSERT_NOT_EQUALS( 0, size.AsPoint().iX );
    STIF_ASSERT_NOT_EQUALS( 0, size.AsPoint().iY );
    
    CleanupStack::PopAndDestroy( secretEditor );
    
    return KErrNone;
    
    }
コード例 #8
0
ファイル: ping.cpp プロジェクト: cdaffara/symbiandump-os2
void CConsoleControl::ConstructL(TPoint aTopLeft,const TSize& aSize,TInt aFlags)
    {
   TRect rect(aTopLeft,aTopLeft + aSize.AsPoint());
#if EPOC_SDK >= 0x06000000
    SetRect(rect);
#else
    SetRectL(rect);
#endif
    iConsole=new(ELeave) CEikConsoleScreen;
    iConsole->ConstructL(_L("TEST"),aTopLeft,aSize,aFlags,EEikConsWinInPixels);
    iConsole->SetHistorySizeL(200,0);
    iHistory=200;
    }
コード例 #9
0
ファイル: Drawer.cpp プロジェクト: jinhuafeng/RS-MAN
void TDrawer::DrawLifeValue(CWsBitmap* aBackUpBitmap, CWsBitmap* aResourceBitmap, TInt aLifeValue)
{
    if (aLifeValue < 1)
    {
        return;
    }
    //
    TRect srcRect = ipBitMapPosition->GetPosition(TBitMapPosition::ELifeValue, aLifeValue - 1);
    TBitmapUtil objectUtil(aResourceBitmap);
    TBitmapUtil backUpUtil(aBackUpBitmap);
    objectUtil.Begin(TPoint(0, 0));
    backUpUtil.Begin(TPoint(0, 0));
    R8G8B8* addr1 = (R8G8B8*) aResourceBitmap->DataAddress();// 对象
    R8G8B8* addr2 = (R8G8B8*) aBackUpBitmap->DataAddress();// 背景
    TSize desSize = aBackUpBitmap->SizeInPixels();
    TSize srcSize = aResourceBitmap->SizeInPixels();
    TSize elementSize;
    elementSize.SetSize(srcRect.iBr.iX - srcRect.iTl.iX + 1, srcRect.iBr.iY - srcRect.iTl.iY + 1);
    R8G8B8* addr22;
    R8G8B8* addr11;
    //TInt iCounts = desSize.iWidth * sourceSize.iWidth;
    TInt iWidthSpanSrc = srcSize.iWidth - elementSize.iWidth;
    TInt iWidthSpanDes = desSize.iWidth - elementSize.iWidth;
    addr22 = addr2 + desSize.iWidth * LIFE_BEGIN_Y + LIFE_BEGIN_X;
    addr11 = addr1 + srcRect.iTl.iY * srcSize.iWidth + srcRect.iTl.iX;
    for (TInt j = 0; j < elementSize.iHeight; j++)
    {
        for (TInt i = 0; i < elementSize.iWidth; i++)
        {
            *addr22 = *addr11;
            addr22++;
            addr11++;
        }
        addr11 = addr11 + iWidthSpanSrc;
        addr22 = addr22 + iWidthSpanDes;
    }
    backUpUtil.End();
    objectUtil.End();
}
コード例 #10
0
TBool CDataWrapperBase::GetSizeFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TSize& aResult)
	{
	TBuf<KMaxTestExecuteCommandLength>	tempStore;

	TInt	width;
	tempStore.Format(KFormatEntryField, &aKeyName, &KTagSizeWidth);
	TBool	ret=GetIntFromConfig(aSectName, tempStore, width);

	TInt	height;
	tempStore.Format(KFormatEntryField, &aKeyName, &KTagSizeHeight);
	if ( !GetIntFromConfig(aSectName, tempStore, height) )
		{
		ret=EFalse;
		}

	if ( ret )
		{
		aResult.SetSize(width, height);
		}

	return ret;
	}
コード例 #11
0
    bool getTextExtentPoint(TUChar* pszText, int nLen, TSize& tSize)
    {
        bool bRet = false;
        do 
        {
            CC_BREAK_IF(! pszText);

            if (tSize.Width() > 0 && tSize.Height() > 0)
            {
                bRet = true;
                break;
            }

            int nLineCount = 0;
            int nWinWidth = 0;
            stdTUString FullString = pszText;

            if (tSize.Width() == 0)
            {
                // not specified the width,calculate the width and line count

                stdTUString strLeft = FullString;
                stdTUString strLine;

                while (strLeft.length() > 0)
                {
                    int nPos = strLeft.find('\n');

                    // get one line text
                    if (nPos != stdTUString::npos)
                    {
                        strLine = strLeft.substr(0, nPos);
                        strLeft = strLeft.substr(nPos + 1);
                    }
                    else
                    {
                        strLine = strLeft;
                        strLeft.erase();
                    }

                    // calculate the width of current line and update the window width
                    int nTempWidth = m_hFont.CharsWidth(strLine.c_str(), strLine.length() + 1);
                    if (nTempWidth >= nWinWidth)
                    {
                        nWinWidth = nTempWidth;
                    }

                    // update the line count
                    ++nLineCount;
                }
            }
            else
            {
                // have specified the window width,calculate the line count
                nWinWidth = tSize.Width();

                stdTUString strLeft = FullString;
                int nCurPos = 0;
                do 
                {
                    nCurPos = m_hFont.WordWrap(strLeft.c_str(), nWinWidth);
                    strLeft = strLeft.substr(nCurPos);
                    ++nLineCount;
                } while (strLeft.length() > 0);
            }

            // calculate the window height.
            tSize.SetHeight(nLineCount * m_hFont.LineHeight());
            tSize.SetWidth(nWinWidth);

            bRet = true;
        } while (0);
        return bRet;
    }
コード例 #12
0
    int drawText(TUChar* pszText, int nLen, TSize& tSize, UInt32 style)
    {
        int nRet = 0;
        do 
        {
            CC_BREAK_IF(! pszText);

            if (tSize.Width() <= 0 || tSize.Height() <= 0)
            {
                CC_BREAK_IF(! getTextExtentPoint(pszText, nLen, tSize));
            }
            CC_BREAK_IF(tSize.Width() <= 0 || tSize.Height() <= 0);

            CC_BREAK_IF(! prepareBitmap(tSize.Width(), tSize.Height()));

            Int32 nWidth  = tSize.Width();
            Int32 nHeight = tSize.Height();

            // create memory window
            if (m_pMemWnd)
            {
                TRectangle rcMemWnd(0, 0, 0, 0);
                m_pMemWnd->GetClientBounds(&rcMemWnd);
                if (rcMemWnd.Width() < nWidth || rcMemWnd.Height() < nHeight)
                {
                    m_pMemWnd->CloseWindow();
                    m_pMemWnd = NULL;
                }
            }

            do 
            {
                // if memory window is already break
                CC_BREAK_IF(m_pMemWnd);

                TApplication* pApp = TApplication::GetCurrentApplication();
                CC_BREAK_IF(! pApp || ! (m_pMemWnd = new TWindow(pApp)));

                Coord nCurrentWidth = pApp->GetScreenWidth();
                Coord nCurrentHeight = pApp->GetScreenHeight();

                Coord nMemWndW = (nWidth >= nCurrentWidth) ? nWidth : nCurrentWidth;
                Coord nMemWndH = (nHeight >= nCurrentHeight) ? nHeight : nCurrentHeight;
                CC_BREAK_IF(m_pMemWnd->CreateMemWindow(nMemWndW, nMemWndH,screenAlphaFormat));
                delete m_pMemWnd;
                m_pMemWnd = NULL;
            } while (0);
            CC_BREAK_IF(! m_pMemWnd);

            // create DC
            TDC dc(m_pMemWnd);

            // draw text
            m_pMemWnd->GetMemWindowTBitmapPtr()->Fill32(RGBA(0, 0, 0, 0), 0, 0, nWidth, nHeight);

            TRectangle rect(0, 0, nWidth, nHeight);
            dc.DrawTextInRectangleEx(pszText, 0, RGBA(255,255,255,255), RGBA(0,0,0,255), m_hFont, &rect, style);

            dc.ReadBitmap(m_pBmp, 0, 0);

            nRet = true;
        } while (0);
        return nRet;
    }