📄 tempgridcontainer.cpp
字号:
CleanupStack::Pop();*/
//iGrid->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
// gridsCreated = ETrue;
iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray);
// faxListIcon, emailListIcon, addressListIcon, iconArray
CleanupStack::Pop();
//iGrid->HandleItemAdditionL();
}
/**
* Return the number of controls in the container (override)
* @return count
*/
TInt CTempgridContainer::CountComponentControls() const
{
return ( int ) ELastControl;
}
/**
* Get the control with the given index (override)
* @param aIndex Control index [0...n) (limited by #CountComponentControls)
* @return Pointer to control
*/
CCoeControl* CTempgridContainer::ComponentControl( TInt aIndex ) const
{
// [[[ begin generated region: do not modify [Generated Contents]
switch ( aIndex )
{
case ERichText1:
return iRichText1;
}
// ]]] end generated region [Generated Contents]
// handle any user controls here...
return NULL;
}
/**
* Handle resizing of the container. This implementation will lay out
* full-sized controls like list boxes for any screen size, and will layout
* labels, editors, etc. to the size they were given in the UI designer.
* This code will need to be modified to adjust arbitrary controls to
* any screen size.
*/
void CTempgridContainer::SizeChanged()
{
CCoeControl::SizeChanged();
LayoutControls();
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
if (popupList && iGrid)
{
//CreatePopupGridL();
TRect rect = Rect();
iGrid->SetExtent(TPoint(0,50), TSize(rect.Width(), rect.Height()-50));
//TInt height = iGrid->ItemHeight() * 3; // 3 rows
//igri->SetExtent(TPoint(0, rect.iTl.iY + height), TSize(rect.Width(), rect.Height()-height));
}
}
// [[[ begin generated function: do not modify
/**
* Layout components as specified in the UI Designer
*/
void CTempgridContainer::LayoutControls()
{
iRichText1->SetExtent( TPoint( 0, -1 ), TSize( 388, 374 ) );
}
// ]]] end generated function
/**
* Handle key events.
*/
TKeyResponse CTempgridContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,
TEventCode aType )
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
if ( iFocusControl != NULL
&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
{
return EKeyWasConsumed;
}
return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
}
// [[[ begin generated function: do not modify
/**
* Initialize each control upon creation.
*/
void CTempgridContainer::InitializeControlsL()
{
iRichText1 = new ( ELeave ) CEikRichTextEditor;
iRichText1->SetContainerWindowL( *this );
{
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC( reader, R_TEMPGRID_CONTAINER_RICH_TEXT1 );
iRichText1->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
{
HBufC* text = StringLoader::LoadLC( R_TEMPGRID_CONTAINER_RICH_TEXT1_2 );
iRichText1->SetTextL( text );
CleanupStack::PopAndDestroy( text );
}
iRichText1->SetFocus( ETrue );
iFocusControl = iRichText1;
}
// ]]] end generated function
/**
* Handle global resource changes, such as scalable UI or skin events (override)
*/
void CTempgridContainer::HandleResourceChange( TInt aType )
{
CCoeControl::HandleResourceChange( aType );
SetRect( iAvkonViewAppUi->View( TUid::Uid( ETempgridContainerViewId ) )->ClientRect() );
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
/**
* Draw container contents.
*/
void CTempgridContainer::Draw( const TRect& aRect ) const
{
// [[[ begin generated region: do not modify [Generated Contents]
CWindowGc& gc = SystemGc();
gc.Clear( aRect );
// ]]] end generated region [Generated Contents]
}
TInt CTempgridContainer::CreatePopupGridL()
{
if (iGrid)
{
delete iGrid;
iGrid = NULL;
}
if (iGrid == NULL)
iGrid = new (ELeave) CAknGrid;
CAknGridM *iGridM = new (ELeave)CAknGridM;
iGrid->SetModel(iGridM);
//iGrid->SetContainerWindowL( *this );
popupList = CAknPopupList::NewL( iGrid, R_AVKON_SOFTKEYS_SELECT_BACK );
CleanupStack::PushL( popupList );
// Set title of dialog
popupList->SetTitleL( _L("Menu grid") );
iGrid->ConstructL(popupList, EAknListBoxSelectionGrid );
/*TResourceReader rr;
// initialize resource reader, passing resource id as parameter
iEikonEnv->CreateResourceReaderLC( rr, R_TEMPGRID_CONTAINER_GRID );
// Construct grid from resource
iGrid->ConstructFromResourceL( rr );
CleanupStack::PopAndDestroy(); // rr*/
// Set grid layout, and scrolling
iGrid->SetLayoutL( EFalse, ETrue, ETrue, 5/*rows*/ , 3/*columns*/, TSize( 33, 33 )/*cellsize*/, 2/*wspace*/, 2/*hspace*/ );
iGrid->SetPrimaryScrollingType( CAknGridView::EScrollIncrementLineAndLoops );
iGrid->SetSecondaryScrollingType( CAknGridView::EScrollIncrementLineAndLoops );
AknListBoxLayouts::SetupStandardGrid( *iGrid );
// Accesses grid model`s item array
CDesCArray *gridItemArray = static_cast<CDesCArray*>( iGridM->ItemTextArray() );
// Adds formatted cell item strings to grid including the indexes of icons in icon array.
gridItemArray->AppendL( _L("0\t") );
gridItemArray->AppendL( _L("1\t") );
gridItemArray->AppendL( _L("2\t") );
gridItemArray->AppendL( _L("3\t") );
gridItemArray->AppendL( _L("4\t") );
gridItemArray->AppendL( _L("5\t") );
gridItemArray->AppendL( _L("6\t") );
gridItemArray->AppendL( _L("7\t") );
gridItemArray->AppendL( _L("8\t") );
gridItemArray->AppendL( _L("9\t") );
gridItemArray->AppendL( _L("10\t") );
gridItemArray->AppendL( _L("11\t") );
gridItemArray->AppendL( _L("0\t") );
gridItemArray->AppendL( _L("2\t") );
gridItemArray->AppendL( _L("3\t") );
AddGridIconsL();
iGrid->HandleItemAdditionL();
// Setup the layout of the text in the cell.
AknListBoxLayouts::SetupFormGfxCell( *iGrid, iGrid->ItemDrawer(), 0 /*Column index*/,
0 /*Left pos*/, 0 /*Top pos*/,
0 /*unused*/, 0 /*unused*/,
32 /*Icon width*/, 32 /*Icon height*/,
TPoint(0,0) /*Start pos*/,
TPoint(31,31) /*End pos*/ );
// AknListBoxLayouts::SetupFormTextCell( *iGrid, iGrid->ItemDrawer(),
//
// 0, LatinBold16(), 0, 0, 0, 30,
//
// 0, CGraphicsContext::ECenter,
//
// TPoint(0,0), TPoint(0,0) );
//popupList->SetMaximumHeight(50);
//popupList->SetExtent(TPoint(0,0), TSize(100, 100));
TInt popupOk = popupList->ExecuteLD();
CleanupStack::Pop();
TInt index = iGrid->CurrentDataIndex();
return index;
}
void CTempgridContainer::SetRichText1FormattingL()
{
// [[[ begin generated region: do not modify [Generated GlobalText formatting]
// ]]] end generated region [Generated GlobalText formatting]
}
void CTempgridContainer::InsertIcon(TInt index)
{
// CArrayPtr<CGulIcon> *iconArray = iGrid->ItemDrawer()->ColumnData()->IconArray();
// CGulIcon *icon = iconArray->At(index);
CMyPicture* picture;
// Create a CPicture derived class which will draw our image, depending this Size
CFbsBitmap *bitmap = new (ELeave) CFbsBitmap(); //icon->Bitmap() //gives the handle
CleanupStack::PushL(bitmap);
//bitmap->Create(TSize(100, 100), EColor16M);
bitmap->Load(KAvkonBitmapFile, index);
picture = new( ELeave )CMyPicture(TSize(100, 100), *bitmap); /*process the last item of iBitmap*/
CleanupStack::PushL(picture);
// Prepare the Picture header, which will be instered into the Richtext
TPictureHeader header;
header.iPicture =TSwizzle<CPicture>(picture);
TInt aPos = iRichText1->CursorPos();
iRichText1->RichText()->InsertL( aPos, header);
DrawNow();
iRichText1->SetCursorPosL(aPos+1, EFalse);
CleanupStack::Pop(); // for bitmap
CleanupStack::Pop(); // picture - Richtext take the ownership
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -