本文整理汇总了C++中CEikLabel::Font方法的典型用法代码示例。如果您正苦于以下问题:C++ CEikLabel::Font方法的具体用法?C++ CEikLabel::Font怎么用?C++ CEikLabel::Font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEikLabel
的用法示例。
在下文中一共展示了CEikLabel::Font方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SizeChanged
void CMainMenuListContainer::SizeChanged()
{
CCoeControl::SizeChanged();
if(iBgContext) {
iBgContext->SetRect(Rect());
if (&Window()) {
iBgContext->SetParentPos(PositionRelativeToScreen());
}
}
CCoeControlArray::TCursor cursor = Components().Find(ETitleLabel);
CEikLabel* label = cursor.Control<CEikLabel>();
const TDesC* titleText = label->Text();
TRect rect = Rect();
CFont* titleFont = FindLargestPossibleFontL(*titleText, rect.Width(), EAknLogicalFontPrimaryFont);
label->SetFont(titleFont);
CEikonEnv::Static()->ScreenDevice()->ReleaseFont(titleFont);
// Set the size of the label, need to think of the descent as well.
TSize size = label->MinimumSize();
size.iWidth = rect.Width();
TInt descent = label->Font()->DescentInPixels();
size.iHeight += descent;
// Set the pos for the listbox, use the height for the label when doing this.
// Also add the descent in pixels to get some space between the label and the
// listbox.
rect.iTl.iY = descent;
TPoint pos(0, descent);
label->SetExtent(rect.iTl, size);
rect.iTl.iY += size.iHeight;
// As default display both rows and hide the scrollbars
HideSecondRow(EFalse);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
CEikScrollBarFrame::EOff);
// Need to set the rect to get the listbox to update its values
iListBox->SetRect(rect);
TInt listBoxHeight = iListBox->ItemHeight() * iListBox->Model()->NumberOfItems();
if (listBoxHeight > rect.Height()) {
// The listbox is to large to fint, hide the row and check again.
HideSecondRow(ETrue);
iListBox->SetRect(rect);
listBoxHeight = iListBox->ItemHeight() * iListBox->Model()->NumberOfItems();
if (listBoxHeight > rect.Height()) {
// Show scroll bar only if the height of the listbox is larger then
// the rect.
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
CEikScrollBarFrame::EOn);
iListBox->UpdateScrollBarsL();
}
}
else {
// Setting the first item gets the list box positioned correctly on the screen
iListBox->ScrollToMakeItemVisible(0);
}
}
示例2: TSize
void
CPreviewPopUpContent::SetAvailableWidth(TInt aWidth, TInt aPadding,
CPreviewPopUpContent::TContentLayout aLayout,
TInt aHeight)
{
iLayout = aLayout;
TInt numLabels = iLabelContainer.Count();
if (numLabels == 0) {
return;
}
// The large font header label.
CEikLabel* labelLa = iLabelContainer[0].iLabel;
// The small font text label.
CEikLabel* labelSm = iLabelContainer[1].iLabel;
// Font height in pixels
TInt fontHeightLa = labelLa->Font()->HeightInPixels();
// Font descent in pixels
TInt descentLa = labelLa->Font()->DescentInPixels();
// The height of one label
TInt labelHeightLa = fontHeightLa + descentLa;
// Font height in pixels
TInt fontHeightSm = labelSm->Font()->HeightInPixels();
// Font descent in pixels
TInt descentSm = labelSm->Font()->DescentInPixels();
// The height of one label
TInt labelHeightSm = fontHeightSm + descentSm;
// totLabelsHeight will hold the total height of all labels that
// will be drawn (one large font and the rest small fonts).
// We additionaly remove a descent on the last line since that
// it seems otherwise we're over compensating.
TInt totLabelsHeight =
labelHeightLa + labelHeightSm * (numLabels - 1); // - descentSm;
// Calculate the image size.
// This calc will give us the height of two label rows.
iIconSize = fontHeightLa + fontHeightSm + descentLa;
TInt iconSize = iIconSize;
TInt padding = aPadding;
if (iBitmap) {
AknIconUtils::SetSize(iBitmap, TSize(iconSize, iconSize),
EAspectRatioPreservedAndUnusedSpaceRemoved);
iconSize = iBitmap->SizeInPixels().iWidth;
} else {
// We have no bitmap set so dont indent the text around the bitmap.
iconSize = 0;
padding = 0;
}
// controlRect will contain the rect for our control to draw in,
// including padding.
TRect controlRect;
if (iLayout == EFourLinesIndentedTextImageTopLeft) {
if (aHeight > 0) {
controlRect = TRect(TPoint(aPadding, aPadding),
TSize(aWidth, aHeight));
} else {
controlRect = TRect(TPoint(aPadding, aPadding),
TSize(aWidth, totLabelsHeight + aPadding));
}
} else if (iLayout == EFourLinesTextImageTopLeftAbove) {
if (aHeight > 0) {
controlRect = TRect(TPoint(aPadding, aPadding),
TSize(aWidth, aHeight));
} else {
controlRect = TRect(TPoint(aPadding, aPadding),
TSize(aWidth,
totLabelsHeight + iconSize + descentLa + aPadding));
}
}
// iComponentRect will contain the drawing area for our controls
// (image and labels).
iComponentRect = controlRect;
iComponentRect.Shrink(aPadding, aPadding);
// Calculate where the text should wrap and
// calculate the positions and rects for the labels in the control.
TRect labelRectLa;
TRect labelRectSm;
if (iLayout == EFourLinesIndentedTextImageTopLeft) {
// The first line will bew positioned next to the image and
// therefore the width will be a bit shorter.
iStringLengths->At(0) = (iComponentRect.Width() - (iconSize + padding));
// The width of the last line should not be wrapped but rather set to
// cropped later on.
iStringLengths->At(1) = (iComponentRect.Width() + 10000);
// The rect for the first label in the layout mode.
labelRectLa = TRect(TPoint(iComponentRect.iTl.iX + iconSize + padding,
iComponentRect.iTl.iY),
TSize(iComponentRect.Width() - (iconSize + padding),
labelHeightLa));
// The rect for the labels with small font as well.
labelRectSm = TRect(TPoint(iComponentRect.iTl.iX + iconSize + padding,
iComponentRect.iTl.iY),
TSize(iComponentRect.Width() - (iconSize + padding),
//.........这里部分代码省略.........