void medSplashScreen::paintEvent(QPaintEvent* pe) { QRect aTextRect(rect()); aTextRect.setRect(aTextRect.x() + 5, aTextRect.y() + 5, aTextRect.width() - 10, aTextRect.height() - 10); QPainter aPainter(this); aPainter.drawPixmap(rect(), d->pixmap); aPainter.setPen(d->color); aPainter.drawText(aTextRect, d->alignment, d->message); }
void CTextList::Draw(const TRect& /*aRect*/) const { if ((!iItemTextArray) || (iItemTextArray->MdcaCount() <= 0)) { return; } // Set the attributes to draw text CWindowGc& gc = SystemGc(); const CFont* font = CCoeEnv::Static()->NormalFont(); gc.UseFont(font); gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetPenColor(KRgbBlack); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.SetBrushColor(KRgbWhite); // Only draw visible items. // CTextList object (iTextList) is set to height of the screen. i.e. iHeight == screen height TInt itemHeight = Size().iHeight / KNumItemsOnScreen; TInt itemToDraw = iPos / -itemHeight; // This accounts for looping around in the same direction multiple times. itemToDraw %= KNumItems; TInt startPos = iPos + (itemToDraw * itemHeight); //startPos should always be offscreen so that item slides into view. if (startPos > 0) { startPos -= itemHeight; } TRect aTextRect(TPoint(0, startPos), TSize(Size().iWidth, itemHeight)); TInt aBaselineOffset = (aTextRect.iBr.iY - aTextRect.iTl.iY - font->HeightInPixels()) / 2 + font->AscentInPixels(); for(TInt i = 0; i < KNumItemsOnScreen + 1; ++i) { if (itemToDraw >= KNumItems) { itemToDraw = 0; } else if (itemToDraw < 0) { itemToDraw = KNumItems + itemToDraw; } ASSERT(itemToDraw >= 0 && itemToDraw < KNumItems); TPtrC itemText = iItemTextArray->MdcaPoint(itemToDraw); gc.DrawText(itemText, aTextRect, aBaselineOffset, CGraphicsContext::ELeft, 1); gc.DrawLine(TPoint(0, (aTextRect.iBr.iY-5)), TPoint(aTextRect.iBr.iX, aTextRect.iBr.iY-5)); aTextRect.iTl.iY += itemHeight; aTextRect.iBr.iY += itemHeight; itemToDraw++; } }