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

Definition at line 32 of file ListboxNumberContainer.h.
Public Member Functions |
|
| void | ConstructL (const TRect &aRect) |
| CListboxNumberContainer () | |
| ~CListboxNumberContainer () | |
| TInt | ItemCount () |
| void | AddItemL () |
| void | RemoveItemL () |
Private Member Functions |
|
| TInt | CountComponentControls () const |
| CCoeControl * | ComponentControl (TInt aIndex) const |
| void | SizeChanged () |
| TKeyResponse | OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType) |
| void | CreateListboxL () |
Private Attributes |
|
| CEikColumnListBox * | iListBox |
| CNaviScrollTimer * | iTimer |
|
|
Default constructor. Definition at line 38 of file ListboxNumberContainer.cpp.
|
|
|
Destructor. Definition at line 47 of file ListboxNumberContainer.cpp. References iListBox, and iTimer.
|
|
|
2nd phase constructor. Definition at line 58 of file ListboxNumberContainer.cpp. References CreateListboxL(), iListBox, iTimer, CNaviScrollTimer::NewL(), and CNaviScrollTimer::StartScroll(). 00059 { 00060 CreateWindowL(); // Creates window. 00061 00062 SetRect( aRect ); // Sets rectangle of frame. 00063 00064 CreateListboxL(); 00065 iListBox->SetRect(Rect()); 00066 00067 ActivateL(); // Activates window. ( Ready to draw ) 00068 00069 // Show listbox class name in navigation pane 00070 iTimer = CNaviScrollTimer::NewL( KNaviPaneText ); 00071 iTimer->StartScroll(); 00072 }
|
|
|
Getter for listbox item count.
Definition at line 230 of file ListboxNumberContainer.cpp. References iListBox. 00231 { 00232 return iListBox->Model()->NumberOfItems(); 00233 }
|
|
|
Gets the number of controls contained in a compound control.
Definition at line 111 of file ListboxNumberContainer.cpp.
|
|
|
Gets an indexed component of a compound control.
Definition at line 121 of file ListboxNumberContainer.cpp. References iListBox. 00122 { 00123 switch( aIndex ) 00124 { 00125 case 0: 00126 return iListBox; 00127 default: 00128 return NULL; 00129 } 00130 }
|
|
|
Responds to changes to the size and position of the contents of this control. Definition at line 137 of file ListboxNumberContainer.cpp. References iListBox.
|
|
||||||||||||
|
Handles key events.
Definition at line 240 of file ListboxNumberContainer.cpp. References iListBox. 00242 { 00243 if ( aKeyEvent.iCode == EKeyDownArrow || aKeyEvent.iCode == EKeyUpArrow ) 00244 // Forward key events to listbox 00245 return iListBox->OfferKeyEventL( aKeyEvent, aType ); 00246 00247 return EKeyWasNotConsumed; 00248 }
|
|
|
Constructs listbox from resource, creates scroll bar and sets empty list background text. Definition at line 80 of file ListboxNumberContainer.cpp. References iListBox. Referenced by ConstructL(). 00081 { 00082 iListBox = new ( ELeave ) CAknSingleNumberStyleListBox(); 00083 00084 iListBox->SetContainerWindowL( *this ); 00085 00086 TResourceReader reader; 00087 iEikonEnv->CreateResourceReaderLC( reader, 00088 R_LISTBOX_SINGLE_NUMBER_STYLE ); 00089 00090 // Construct listbox from resource 00091 iListBox->ConstructFromResourceL( reader ); 00092 CleanupStack::PopAndDestroy(); 00093 00094 // Creates scrollbar. 00095 iListBox->CreateScrollBarFrameL( ETrue ); 00096 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 00097 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); 00098 00099 // Set the listbox empty text 00100 HBufC* emptyText = StringLoader::LoadLC( R_LISTBOX_EMPTYTEXT ); 00101 iListBox->View()->SetListEmptyTextL( emptyText->Des() ); 00102 CleanupStack::PopAndDestroy( emptyText ); 00103 }
|
|
|
Adds item to the end of the list. Definition at line 150 of file ListboxNumberContainer.cpp. References iListBox. 00151 { 00152 // Number of items 00153 TInt numOfItems = iListBox->Model()->NumberOfItems(); 00154 // Item array. By default iListBox owns the item array, so no deletion 00155 // is needed. 00156 CDesCArray* itemArray = 00157 static_cast<CDesC16ArrayFlat*>(iListBox->Model()->ItemTextArray()); 00158 00159 // if listbox does not have items, load first item from resource. 00160 if( numOfItems < 1 ) 00161 { 00162 HBufC* itemText = StringLoader::LoadLC( R_LISTBOX_ITEMTEXT ); 00163 itemArray->AppendL( itemText->Des() ); 00164 CleanupStack::PopAndDestroy( itemText ); 00165 } 00166 else // Add new item to the end of the listbox's item array 00167 { 00168 // Item text of last item 00169 TPtrC itemPtr = iListBox->Model()->ItemText( numOfItems - 1 ); 00170 00171 TInt numSep = itemPtr.FindC( KNumberSeparator ); 00172 00173 // Item number in TDes format 00174 TBuf<5> numBuf = itemPtr.Mid( 0, numSep ); 00175 // Convert to TInt and add 1 00176 TInt itemIndex(0); 00177 TLex conv( numBuf ); 00178 conv.Val( itemIndex ); 00179 ++itemIndex; 00180 00181 // Create new item text 00182 _LIT( KItemFormat, "%d\t%S" ); 00183 TBuf<10> itemEnd = itemPtr.Mid( numSep + KNumberSeparator().Length() ); 00184 TBuf<60> itemText; 00185 itemText.Format( KItemFormat, itemIndex, &itemEnd ); 00186 00187 itemArray->AppendL( itemText ); 00188 } 00189 00190 // Update the listbox 00191 iListBox->HandleItemAdditionL(); 00192 }
|
|
|
Removes item from the end of the list. Definition at line 199 of file ListboxNumberContainer.cpp. References iListBox. 00200 { 00201 // Number of items 00202 TInt numOfItems = iListBox->Model()->NumberOfItems(); 00203 00204 if( numOfItems > 0 ) 00205 { 00206 TInt currentItemIndex = iListBox->CurrentItemIndex(); 00207 // Item array. By default iListBox owns the item array, so no deletion 00208 // is needed. 00209 CDesCArray* itemArray = 00210 static_cast<CDesC16ArrayFlat*>(iListBox->Model()->ItemTextArray()); 00211 // Delete last item 00212 itemArray->Delete( numOfItems - 1 ); 00213 00214 if( currentItemIndex >= ( numOfItems - 1 ) && 00215 currentItemIndex > 0 ) 00216 iListBox->SetCurrentItemIndex( numOfItems - 2 ); 00217 } 00218 else 00219 return; 00220 00221 // Update the listbox 00222 iListBox->HandleItemAdditionL(); 00223 }
|
|
|
Pointer to listbox control. Owned. Definition at line 116 of file ListboxNumberContainer.h. Referenced by AddItemL(), ComponentControl(), ConstructL(), CreateListboxL(), ItemCount(), OfferKeyEventL(), RemoveItemL(), SizeChanged(), and ~CListboxNumberContainer(). |
|
|
Timer for scrolling listbox class name on the navigation pane. Owned Definition at line 123 of file ListboxNumberContainer.h. Referenced by ConstructL(), and ~CListboxNumberContainer(). |
|
© Nokia 2009 |