📄 aknexgridcontainerasselection.cpp
字号:
TPoint( iGrid->ColumnWidth(), iGrid->ItemHeight() )
);
}
DrawNow();
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsSelection::CheckIndex()
// Shows current index
// -----------------------------------------------------------------------------
//
void CAknExGridContainerAsSelection::CheckIndex()
{
// Counter of the number of marked item
TInt selectedItemCount = 0;
// Load message.
TBuf<KLengthOfStringToShowIndex> number;
TBuf<KLengthOfStringToShowIndex> format;
iCoeEnv->ReadResource( format, R_EXGR_FORMATSTRING_CURRENTINDEX );
if ( iGridType == EAknExGridMarkableGrid )
{
// The number of items.
TInt numberOfData = iGrid->GridModel()->NumberOfData();
// Check marked item. And if the item is marked,display dialog.
for ( TInt checkData = 0; checkData < numberOfData; checkData++ )
{
CListBoxView* view = iGrid->View();
if ( view->ItemIsSelected( checkData ) )
{
selectedItemCount++;
// display dialog.
number.Format( format, checkData );
iEikonEnv->AlertWin( number );
}
}
if ( selectedItemCount == 0 )
{
number.Format( format, -1 );
iEikonEnv->AlertWin( number );
}
return;
}
// if "Selection Grid",
// display the result of current index.
else if ( iGridType == EAknExGridSelectionGrid )
{
// we do a check of the position and index functions here
// as well as giving the current index
TInt currentIndex = iGrid->CurrentDataIndex();
TPoint currentPos = iGrid->PositionAtIndex( currentIndex );
TInt index = iGrid->IndexOfPosition( currentPos );
if ( index == currentIndex )
{
number.Format( format, currentIndex );
iEikonEnv->AlertWin( number );
}
}
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsSelection::MarkAllItems()
// Select/Deselect/Toggle selection of all items.
// -----------------------------------------------------------------------------
//
void CAknExGridContainerAsSelection::MarkAllItemsL( TInt aCommand )
{
if ( iGridType == EAknExGridMarkableGrid )
{
// Get number of items.
TInt numberOfData = iGrid->GridModel()->NumberOfData();
CListBoxView* gridView = iGrid->View();
// execute specified method of each item.
for ( TInt index = 0; index < numberOfData; index++ )
{
switch ( aCommand )
{
case EAknExGridCmdSelectAll: // Select the item
gridView->SelectItemL( index );
break;
case EAknExGridCmdDeselectAll: // Do not select the item
gridView->DeselectItem( index );
break;
case EAknExGridCmdToggle: // toggle selection
gridView->ToggleItemL( index );
break;
}
}
}
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsSelection::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CAknExGridContainerAsSelection::SizeChanged()
{
if ( iGrid )
{
iGrid->SetRect( Rect() );
}
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsSelection::CountComponentControls())
// Returns the number of components owned by this container.
// -----------------------------------------------------------------------------
//
TInt CAknExGridContainerAsSelection::CountComponentControls() const
{
// return number of controls inside this container
return KNumberOfComponentSelection;
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsMenu::ComponentControl()
// Returns the pointer to the specified control.
// -----------------------------------------------------------------------------
//
CCoeControl* CAknExGridContainerAsSelection::ComponentControl
( TInt aIndex ) const
{
switch ( aIndex )
{
case ELabel:
return iLabel;
case EDoLabel:
return iToDoLabel;
case EGrid:
return iGrid;
default:
return NULL;
}
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsMenu::Draw()
// Draws this container to the screen.
// -----------------------------------------------------------------------------
//
void CAknExGridContainerAsSelection::Draw( const TRect& /*aRect*/ ) const
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsGMS::OfferKeyEventL()
// Handles key events.
// -----------------------------------------------------------------------------
//
TKeyResponse CAknExGridContainerAsSelection::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType )
{
TInt code = aKeyEvent.iCode;
if ( iGrid )
{
if ( code == EKeyEnter || code == EKeyOK )
{
TBool shiftKeyPressed = ( aKeyEvent.iModifiers & EModifierShift );
if ( !shiftKeyPressed )
{
CheckIndex(); // show the current index
return( EKeyWasConsumed );
}
else
{
return iGrid->OfferKeyEventL( aKeyEvent, aType );
}
}
else
{
return iGrid->OfferKeyEventL( aKeyEvent, aType );
}
}
return( EKeyWasNotConsumed );
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsSelection::HandleControlEventL()
// Handles an event of type aEventType reported
// by the control aControl to this observer.
// -----------------------------------------------------------------------------
//
void CAknExGridContainerAsSelection::HandleControlEventL(
CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/ )
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CAknExGridContainerAsMenu::AutoTestL()
// Runs different tests.
// -----------------------------------------------------------------------------
//
TBool CAknExGridContainerAsSelection::AutoTestL()
{
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
iTestNumber++;
switch( iTestNumber )
{
case ESelectionTest1:
titlePane->SetTextL( ( *iTitles )[ESelectionTest1] );
break;
case ESelectionTest2:
{
titlePane->SetTextL( ( *iTitles )[ESelectionTest2] );
TBuf< KLengthOfAboutString > aboutString;
iCoeEnv->ReadResource( aboutString,
R_EXGR_TEXT_ABOUT_SELECTION );
iEikonEnv->AlertWin( aboutString );
break;
}
case ESelectionTest3:
titlePane->SetTextL( ( *iTitles )[ESelectionTest3] );
InsertDataL( 1 );
break;
case ESelectionTest4:
titlePane->SetTextL( ( *iTitles )[ESelectionTest4] );
AddDataL( 5 );
break;
case ESelectionTest5:
titlePane->SetTextL( ( *iTitles )[ESelectionTest5] );
RemoveDataL( 1 , KRemoveFromCurrent );
break;
case ESelectionTest6:
titlePane->SetTextL( ( *iTitles )[ESelectionTest6] );
RemoveDataL( 5 , KRemoveFromLast );
break;
case ESelectionTest7:
titlePane->SetTextL( ( *iTitles )[ESelectionTest7] );
RemoveDataL( KRemoveAllItems , KRemoveFromLast );
break;
case ESelectionTest8:
titlePane->SetTextL( ( *iTitles )[ESelectionTest8] );
AddDataL( iNumOfItems );
iVerticalOrientation = EFalse;
iTopToBottom = EFalse;
iLeftToRight = EFalse;
SetGridLayoutL();
break;
case ESelectionTest9:
titlePane->SetTextL( ( *iTitles )[ESelectionTest9] );
iVerticalOrientation = ETrue;
iTopToBottom = ETrue;
iLeftToRight = ETrue;
SetGridLayoutL();
SetVerticalScrollingTypeL(
CAknGridView::EScrollIncrementLineAndLoops );
SetHorizontalScrollingTypeL(
CAknGridView::EScrollIncrementLineAndLoops );
break;
case ESelectionTest10:
titlePane->SetTextL( ( *iTitles )[ESelectionTest10] );
SetVerticalScrollingTypeL(
CAknGridView::EScrollIncrementLineAndStops );
SetHorizontalScrollingTypeL(
CAknGridView::EScrollIncrementLineAndStops );
break;
case ESelectionTest11:
titlePane->SetTextL( ( *iTitles )[ESelectionTest11] );
SetVerticalScrollingTypeL( CAknGridView::EScrollFollowsGrid );
SetHorizontalScrollingTypeL( CAknGridView::EScrollFollowsGrid );
break;
case ESelectionTest12:
titlePane->SetTextL( ( *iTitles )[ESelectionTest12] );
SetVerticalScrollingTypeL( CAknGridView::EScrollStops );
SetHorizontalScrollingTypeL( CAknGridView::EScrollStops );
break;
case ESelectionTest13:
titlePane->SetTextL( ( *iTitles )[ESelectionTest13] );
SetVerticalScrollingTypeL(
CAknGridView::EScrollIncrementLineAndLoops );
SetHorizontalScrollingTypeL(
CAknGridView::EScrollIncrementLineAndLoops );
SelectContents( EContainText );
break;
case ESelectionTest14:
titlePane->SetTextL( ( *iTitles )[ESelectionTest14] );
SelectContents( EContainGraphic );
break;
case ESelectionTest15:
titlePane->SetTextL( ( *iTitles )[ESelectionTest15] );
SelectContents( EContainBoth );
break;
case ESelectionTest16:
{
titlePane->SetTextL( ( *iTitles )[ESelectionTest16] );
SetNumberOfColumns( 3 );
SetNumberOfRows( 3 );
TRect rect = Rect();
iSizeOfItems.iWidth =
( rect.iBr.iX - rect.iTl.iX ) / iNumOfColumns;
iSizeOfItems.iHeight =
( rect.iBr.iY - rect.iTl.iY ) / iNumOfRows;
SetGridLayoutL();
ApplySelGridGraphicStyleL();
break;
}
case ESelectionTest17:
{
titlePane->SetTextL( ( *iTitles )[ESelectionTest17] );
SetNumberOfColumns( 5 );
SetNumberOfRows( 5 );
TRect rect = Rect();
iSizeOfItems.iWidth =
( rect.iBr.iX - rect.iTl.iX ) / iNumOfColumns;
iSizeOfItems.iHeight =
( rect.iBr.iY - rect.iTl.iY ) / iNumOfRows;
SetGridLayoutL();
ApplySelGridGraphicStyleL();
break;
}
case ESelectionTest18:
{
titlePane->SetTextL( ( *iTitles )[ESelectionTest18] );
SetNumberOfColumns( 10 );
SetNumberOfRows( 10 );
TRect rect = Rect();
iSizeOfItems.iWidth =
( rect.iBr.iX - rect.iTl.iX ) / iNumOfColumns;
iSizeOfItems.iHeight =
( rect.iBr.iY - rect.iTl.iY ) / iNumOfRows;
SetGridLayoutL();
ApplySelGridGraphicStyleL();
break;
}
default:
return ETrue;
}
return EFalse;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -