Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 03:00, 26 July 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to modify grid

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: rihoe (23 Nov 2007)
Last edited: hamishwillee (26 Jul 2012)
If you have created custom made CAknGrid then you may have to re-modify it if user rotates phone's screen or in case of E90 selects another screen with different resolution.

You have to make the modifications in SizeChanged method that is called by framework automatically.

void CGridContainer::SizeChanged()
{
//First reset grid
SetGridInitialParametersL();
//Calculate the maximum size of the text and set cell title's font
CGraphicsDevice* screenDevice = iCoeEnv->ScreenDevice();
TInt i;
TFontSpec fontSpec2 = CCoeEnv::Static()->NormalFont()->FontSpecInTwips();
fontSpec2.iTypeface.iName=_L("Latin");
CFont* fontText;
for(i=100;i>10;i=i-5)
{
fontSpec2.iHeight = i;
screenDevice->GetNearestFontInTwips(fontText,fontSpec2);
TInt fh=fontText->HeightInPixels();
TInt w=fontText->MeasureText(_L("MMMM MMMM")); //maximum text that may occure
if(w<iSizeOfCell.iWidth)
{ iGrid->ItemDrawer()->FormattedCellData()->SetSubCellFontL(1,fontText);
iFontSize=fontText->HeightInPixels();
CCoeEnv::Static()->ReleaseScreenFont(fontText);
break;
}
CCoeEnv::Static()->ReleaseScreenFont(fontText);
}
//Resize icons
TSize iconSize;
TInt side=(iSizeOfCell.iWidth>iSizeOfCell.iHeight)?iSizeOfCell.iHeight:iSizeOfCell.iWidth;
iconSize.iWidth = side;
iconSize.iHeight = side;
TInt icnt=iGrid->ItemDrawer()->FormattedCellData()->IconArray()->Count();
for(TInt i=0;i<icnt;i++)
AknIconUtils::SetSize( (*iGrid->ItemDrawer()->FormattedCellData()->IconArray())[i]->Bitmap(), iconSize );
//Set skinsupport on
iGrid->ItemDrawer()->ColumnData()->SetSkinEnabledL(ETrue);
//Set transparency on (helps to avoid subcell dissapearances)
iGrid->ItemDrawer()->FormattedCellData()->SetTransparentSubCellL(0,ETrue);
iGrid->ItemDrawer()->FormattedCellData()->SetTransparentSubCellL(1,ETrue);
iGrid->ItemDrawer()->FormattedCellData()->SetTransparentSubCellL(2,ETrue);
//Reposition subcells
iGrid->ItemDrawer()->FormattedCellData()->SetSubCellBaselinePosL(1,iFontSize+1);
TSize s1;
s1.iHeight=iFontSize+5;
s1.iWidth=iSizeOfCell.iWidth;
iGrid->ItemDrawer()->ColumnData()->SetSubCellSizeL(1,s1);
TPoint p;
p.iX=1;
p.iY=1;
iGrid->ItemDrawer()->ColumnData()->SetSubCellPositionL(1,p);
// Set colors
CFormattedCellListBoxData::TColors gridColors = iGrid->ItemDrawer()->ColumnData()->SubCellColors(0);
gridColors.iText = iTextColor;
gridColors.iHighlightedText = iHTextColor;
iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL( 1, gridColors );
 
}
 
void CGridContainer::SetGridInitialParametersL()
{
TSize mpSize; // main pane size
AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::EMainPane, mpSize );
iSizeOfCell.iWidth=(mpSize.iWidth-8)/5;
iSizeOfCell.iHeight=(mpSize.iHeight-2)/2;
 
// Set grid layout, and scrolling
iGrid->SetLayoutL( EFalse, ETrue, ETrue, 5, 2, iSizeOfCell, 0, 0 );
iGrid->SetPrimaryScrollingType( CAknGridView::EScrollFollowsItemsAndLoops );
iGrid->SetSecondaryScrollingType( CAknGridView::EScrollIncrementLineAndLoops );
iGrid->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOff);
}
This page was last modified on 26 July 2012, at 03:00.
36 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×