Contents |
The following article shows what operations can be done on tabs. Tabs are UI components which facilitate easier navigation just by pressing the joystick left or right. Tabs are shown in the navigation pane and navigation pane itself is a part of the status pane.
Individual tab units can be either long or short. They can have simple labels or icons on them.
Following are the header files required: eikspane.h, aknnavide.h, akntabgrp.h
Link against: avkon.lib , eikcore.lib
Tabs can be constructed in the AppUi or the container of a particular view. The resources for the status pane and the tab group are as follows:
RESOURCE STATUS_PANE_APP_MODEL r_myview_status_pane { panes= { SPANE_PANE { id = EEikStatusPaneUidNavi; type = EAknCtNaviPane; resource = r_myview_navi_decorator; } }; } RESOURCE NAVI_DECORATOR r_myview_navi_decorator { type = ENaviDecoratorControlTabGroup; control = TAB_GROUP { tab_width = EAknTabWidthWithTwoTabs; // two tabs active = 0; tabs = { TAB { id = EMyViewView1Tab; // from application hrh txt = qtn_view1_tab; }, TAB { id = EMyViewView2Tab; txt = qtn_view2_tab; } }; }; }
if ( !iNaviPane ) { CEikStatusPane *sp = ( ( CAknAppUi* )iEikonEnv->EikAppUi() )->StatusPane(); iNaviPane = ( CAknNavigationControlContainer * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); } iNaviDecorator = iNaviPane->CreateTabGroupL(); CAknTabGroup * tabGroup = (CAknTabGroup*) iNaviDecorator->DecoratedControl(); iNaviPane->PushL(*iNaviDecorator);
The following operations can be performed:
void CMyContainer::AddNewTabL(TInt aTabid) { // get a pointer to the tab group CAknTabGroup* tabGroup = (CAknTabGroup*) iNaviDecorator->DecoratedControl(); // format the string of text to appear in the new tab TBuf<10> temp; temp.Format(_L("%d"), aTabid + 1); // add the new tab to the end, and make it active tabGroup->AddTabL(aTabid, temp); tabGroup->SetActiveTabById(aTabid); SetTitle(aTabid,2); }
TBool CMyContainer::SetActiveTab(TUid aTab) { // get a pointer to the tab group CAknTabGroup* tabGroup = (CAknTabGroup*) iNaviDecorator->DecoratedControl(); TInt iTabInt = aTab.iUid; tabGroup->SetActiveTabById(iTabInt); SetTitle(iTabInt,2); return ETrue; }
void CMyContainer::HideTabs() { iNaviPane->Pop(); }
void CMyContainer::ShowTabs() { iNaviPane->PushL(*iNaviDecorator); }
void CMyContainer::SetTitle(TInt aTabid, TInt aView) { CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); iTitlePane = ( CAknTitlePane*) sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle )); TBuf<10> temp; if( aView == 2) temp.Format(_L("Buddy %d"),aTabid+1); else temp.Copy(_L("MyView")); iTitlePane->SetTextL(temp); }
TInt CMyContainer::ActiveTab() { CAknTabGroup* iTabGroup = (CAknTabGroup*) iNaviDecorator->DecoratedControl(); return iTabGroup->ActiveTabId(); }
TKeyResponse CMyContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) { if (aType != EEventKey) { return EKeyWasNotConsumed; } CAknTabGroup* iTabGroup = (CAknTabGroup*) iNaviDecorator->DecoratedControl(); if ( iTabGroup == NULL ) { return EKeyWasNotConsumed; } TInt active = iTabGroup->ActiveTabIndex(); TInt count = iTabGroup->TabCount(); switch ( aKeyEvent.iCode ) { case EKeyLeftArrow: if ( active > 0 ) { active--; iTabGroup->SetActiveTabByIndex( active ); } break; case EKeyRightArrow: if( (active + 1) < count ) { active++; iTabGroup->SetActiveTabByIndex( active ); } break; default: return EKeyWasNotConsumed; break; } return EKeyWasConsumed; }
It may be a requirement that the tabs should not be shown when in a particular view. In such case in the views DoDeactivateL do the following
void CMyView::DoDeactivate() { iContainer->HideTabs(); iContainer->SetTitle(1,1); }
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Server shut down with KErrServerTerminated error | lss0986 | General Symbian C++ | 5 | 2007-04-18 12:05 |
| how to cancel RecvOneOrMore | marcinkrol84 | Symbian Networking & Messaging | 5 | 2007-08-09 12:56 |
| 关于同步Calendar时出现的问题! | bannerruby | OMA DM/DS/CP | 2 | 2006-01-18 02:44 |
| How to get a Tab view? | reshmasp | Symbian User Interface | 0 | 2003-05-18 08:05 |
| How To Access Image From Other .CPP?? Help Needed! | coolblues5000 | General Symbian C++ | 100 | 2008-10-22 09:01 |