|
Nokia N97 SDK Example Applications Guide |
#include <ListboxGraphicContainer.h>
Inheritance diagram for CListboxGraphicContainer:

Definition at line 33 of file ListboxGraphicContainer.h.
Public Member Functions |
|
| void | ConstructL (const TRect &aRect) |
| CListboxGraphicContainer () | |
| ~CListboxGraphicContainer () | |
| void | AddItemL () |
| void | RemoveItemL () |
| TInt | ItemCount () |
Private Member Functions |
|
| TInt | CountComponentControls () const |
| CCoeControl * | ComponentControl (TInt aIndex) const |
| void | SizeChanged () |
| TKeyResponse | OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType) |
| void | CreateListboxL () |
| void | SetIconsL () |
| void | SetItemsL () |
Private Attributes |
|
| CEikColumnListBox * | iListBox |
| RFs | iFsSession |
| CIconFileProvider * | iFileProvider |
| CNaviScrollTimer * | iTimer |
|
|
Default constructor. Definition at line 47 of file ListboxGraphicContainer.cpp.
|
|
|
Destructor. Definition at line 56 of file ListboxGraphicContainer.cpp. References iFileProvider, iFsSession, iListBox, and iTimer. 00057 { 00058 if( iListBox ) delete iListBox; 00059 iFsSession.Close(); 00060 if( iFileProvider ) delete iFileProvider; 00061 if( iTimer ) delete iTimer; 00062 }
|
|
|
2nd phase constructor. Definition at line 69 of file ListboxGraphicContainer.cpp. References CreateListboxL(), iListBox, iTimer, CNaviScrollTimer::NewL(), SetIconsL(), SetItemsL(), and CNaviScrollTimer::StartScroll(). 00070 { 00071 // Creates window. 00072 CreateWindowL(); 00073 // Sets rectangle of frame. 00074 SetRect( aRect ); 00075 00076 CreateListboxL(); 00077 00078 iListBox->SetRect(Rect()); 00079 00080 // Set lisbox icons 00081 SetIconsL(); 00082 // Set listbox item texts 00083 SetItemsL(); 00084 // Activates window. ( Ready to draw ) 00085 ActivateL(); 00086 // Show listbox class name in navigation pane 00087 iTimer = CNaviScrollTimer::NewL( KNaviPaneText ); 00088 iTimer->StartScroll(); 00089 00090 CEikMenuBar* menuBar = CEikonEnv::Static()->AppUiFactory()->MenuBar(); 00091 menuBar->SetContextMenuTitleResourceId( 00092 R_LISTBOX_GRAPHICVIEW_MSK_MENUBAR ); 00093 }
|
|
|
Adds item to the listbox. Asks the item text from user with data query. Item is added to the index which is currently focused. Definition at line 194 of file ListboxGraphicContainer.cpp. References iListBox. 00195 { 00196 // Icon number for all items. 00197 _LIT( KItemStart, "0\t" ); 00198 // New item text 00199 TBuf<50> itemText; 00200 CAknTextQueryDialog *dialog = CAknTextQueryDialog::NewL( itemText ); 00201 // Maximum length for input text. Can also be defined in 00202 // R_LISTBOX_DATA_QUERY_DIALOG resourse. 00203 dialog->SetMaxLength( 45 ); 00204 // Execute dialog 00205 if (dialog->ExecuteLD( R_LISTBOX_DATA_QUERY_DIALOG ) ) 00206 { 00207 // Insert icon number at the beginning of itemText. Note that max 00208 // length for dialog input text is 45 and itemText size is 50. So 00209 // there is space for item number and column separator. 00210 itemText.Insert( 0, KItemStart() ); 00211 // Item array. By default iListBox owns the item array, so no 00212 // deletion is needed. 00213 CDesCArray* itemArray = 00214 static_cast<CDesC16ArrayFlat*>(iListBox->Model()->ItemTextArray()); 00215 00216 // Insert item to the item array 00217 if( itemArray->Count() > 0 ) 00218 itemArray->InsertL( iListBox->View()->CurrentItemIndex(),itemText ); 00219 else 00220 itemArray->InsertL( 0, itemText ); 00221 00222 // Update the listbox 00223 iListBox->HandleItemAdditionL(); 00224 } 00225 }
|
|
|
Removes focused item from the listbox. Definition at line 232 of file ListboxGraphicContainer.cpp. References iListBox. 00233 { 00234 // If we don't have items, do nothing and return 00235 if( iListBox->Model()->NumberOfItems() < 1 ) 00236 return; 00237 00238 TInt oldIndex = iListBox->View()->CurrentItemIndex(); 00239 // Item array. By default iListBox owns the item array, so no deletion is 00240 // needed. 00241 CDesCArray* itemArray = 00242 static_cast<CDesC16ArrayFlat*>(iListBox->Model()->ItemTextArray()); 00243 00244 // Remove highlighted item from the listbox. 00245 itemArray->Delete( iListBox->View()->CurrentItemIndex() ); 00246 00247 // If focused item is out of range, bring it forth 00248 if( (oldIndex > ( itemArray->Count()-1 )) && 00249 ( (itemArray->Count()-1) >= 0 ) ) 00250 { 00251 iListBox->View()->SetCurrentItemIndex( itemArray->Count()-1 ); 00252 } 00253 00254 // Update the listbox 00255 iListBox->HandleItemAdditionL(); 00256 }
|
|
|
Getter for listbox item count. Definition at line 317 of file ListboxGraphicContainer.cpp. References iListBox. 00318 { 00319 return iListBox->Model()->NumberOfItems(); 00320 }
|
|
|
Gets the number of controls contained in a compound control.
Definition at line 263 of file ListboxGraphicContainer.cpp.
|
|
|
Gets an indexed component of a compound control.
Definition at line 273 of file ListboxGraphicContainer.cpp. References iListBox. 00274 { 00275 switch( aIndex ) 00276 { 00277 case 0: 00278 return iListBox; 00279 default: 00280 return NULL; 00281 } 00282 }
|
|
|
Responds to changes to the size and position of the contents of this control. Definition at line 289 of file ListboxGraphicContainer.cpp. References iListBox.
|
|
||||||||||||
|
Handles key events.
Definition at line 302 of file ListboxGraphicContainer.cpp. References iListBox. 00304 { 00305 if ( aKeyEvent.iCode == EKeyDownArrow || aKeyEvent.iCode == EKeyUpArrow ) 00306 // Forward key events to listbox 00307 return iListBox->OfferKeyEventL( aKeyEvent, aType ); 00308 00309 return EKeyWasNotConsumed; 00310 }
|
|
|
Constructs listbox, creates scroll bar, sets empty list background text, and enables marquee. Definition at line 102 of file ListboxGraphicContainer.cpp. References iListBox. Referenced by ConstructL(). 00103 { 00104 iListBox = new ( ELeave ) CAknSingleGraphicStyleListBox(); 00105 iListBox->ConstructL(this); 00106 iListBox->SetContainerWindowL( *this ); 00107 00108 // Creates scrollbar. 00109 iListBox->CreateScrollBarFrameL( ETrue ); 00110 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 00111 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); 00112 00113 // Enable marquee 00114 iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); 00115 00116 // Set empty text for the listbox. 00117 HBufC* emptyText = StringLoader::LoadLC( R_LISTBOX_EMPTYTEXT ); 00118 iListBox->View()->SetListEmptyTextL( emptyText->Des() ); 00119 CleanupStack::PopAndDestroy( emptyText ); 00120 }
|
|
|
Sets icons for the listbox. Only one icon is used and loaded from application private directory using CIconFileProvider and AknIconUtils. Definition at line 127 of file ListboxGraphicContainer.cpp. References iFileProvider, iFsSession, and iListBox. Referenced by ConstructL(). 00128 { 00129 CArrayPtr<CGulIcon>* iconList = new (ELeave) CAknIconArray(1); 00130 // push iconarray to stack 00131 CleanupStack::PushL(iconList); 00132 00133 User::LeaveIfError( iFsSession.Connect() ); 00134 // Let other sessions to use this. ShareProtected() must be called for 00135 // enabling other other threads in this process to use this handle. 00136 iFsSession.ShareProtected(); 00137 TBuf<256> path; 00138 iFsSession.PrivatePath( path ); 00139 00140 path.Append( KMifFileName() ); 00141 // insert the drive to the private path 00142 TParsePtrC parse( 00143 (CEikonEnv::Static()->EikAppUi()->Application())->AppFullName() ); 00144 path.Insert( 0, parse.Drive() ); 00145 00146 CFbsBitmap* bitmap = NULL; 00147 CFbsBitmap* mask = NULL; 00148 00149 iFileProvider = CIconFileProvider::NewL( iFsSession, path ); 00150 00151 // Create icons. This function uses CIconFileProvider to pass handle to 00152 // icon file (which lies in application private directory) to AknIcon 00153 // server. This server does not have access to private directories. 00154 AknIconUtils::CreateIconL(bitmap, 00155 mask, 00156 *iFileProvider, 00157 EMbmListbox_bitmapsListbox_icon, 00158 EMbmListbox_bitmapsListbox_icon_mask); 00159 00160 CGulIcon* newIcon = CGulIcon::NewL( bitmap, mask ); 00161 iconList->AppendL( newIcon ); 00162 00163 iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconList ); 00164 CleanupStack::Pop(iconList); 00165 }
|
|
|
Sets items to the listbox. Definition at line 172 of file ListboxGraphicContainer.cpp. Referenced by ConstructL(). 00173 { 00174 TBuf<20> itemText; 00175 00176 CDesCArray* itemArray = new ( ELeave ) CDesCArrayFlat(4); 00177 00178 for( TInt i = 1; i < 5; ++i ) 00179 { 00180 itemText.Format( KListItemFormat(), i ); 00181 itemArray->AppendL( itemText ); 00182 } 00183 00184 iListBox->Model()->SetItemTextArray( itemArray ); 00185 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); 00186 iListBox->HandleItemAdditionL(); 00187 }
|
|
|
Pointer to listbox control. Owned. Definition at line 127 of file ListboxGraphicContainer.h. Referenced by AddItemL(), ComponentControl(), ConstructL(), CreateListboxL(), ItemCount(), OfferKeyEventL(), RemoveItemL(), SetIconsL(), SizeChanged(), and ~CListboxGraphicContainer(). |
|
|
File server. Definition at line 132 of file ListboxGraphicContainer.h. Referenced by SetIconsL(), and ~CListboxGraphicContainer(). |
|
|
Icon file provider. With this it is possible to open a icon file from application private directory. Owned. Definition at line 140 of file ListboxGraphicContainer.h. Referenced by SetIconsL(), and ~CListboxGraphicContainer(). |
|
|
Timer for scrolling listbox class name on the navigation pane. Owned Definition at line 147 of file ListboxGraphicContainer.h. Referenced by ConstructL(), and ~CListboxGraphicContainer(). |
|
© Nokia 2009 |