|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================ 00003 * Name : HierarchicalColumnListAppView.cpp 00004 * Part of : Hierarchical Column List Example Application 00005 * Description : Implementation for HierarchicalColumnListAppView class. 00006 * Version : %version: 1 % 00007 * 00008 * Copyright © 2007 Nokia. All rights reserved. 00009 * This material, including documentation and any related computer 00010 * programs, is protected by copyright controlled by Nokia 00011 * Corporation. 00012 * ============================================================================ 00013 */ 00014 00015 #include <coemain.h> 00016 #include <aknsinglecolumnstyletreelist.h> 00017 #include <stringloader.h> 00018 #include <eikbtgpc.h> 00019 #include <aknappui.h> 00020 #include <aknsbasicbackgroundcontrolcontext.h> 00021 #include <eikmenup.h> 00022 #include <gulicon.h> 00023 00024 #include <avkon.mbg> 00025 #include <akniconutils.h> 00026 00027 #include <avkon.rsg> 00028 #include <HierarchicalColumnList.rsg> 00029 #include "HierarchicalColumnList.hrh" 00030 #include "HierarchicalColumnListAppView.h" 00031 00032 00033 // ======== LOCAL FUNCTIONS ======== 00034 00035 // --------------------------------------------------------------------------- 00036 // Adds some items to the given list. 00037 // --------------------------------------------------------------------------- 00038 // 00039 void PopulateListL( CAknSingleColumnStyleTreeList* aList ) 00040 { 00041 // In this example, this flag is used to set every item is persistent, 00042 // which means that they are not automatically removed from the list when 00043 // one of the nodes in which they are located is collapsed. 00044 TUint32 flags = CAknSingleColumnStyleTreeList::EPersistent; 00045 00046 // Add simple data row to the top-most level of the tree. The method 00047 // returns an identifier, which should be stored to be used later to 00048 // refer to the added item. 00049 _LIT( KSimpleDataRowText, "Simple data row" ); 00050 TAknTreeItemID simpleItem = aList->AddSimpleDataRowL( KAknTreeIIDRoot, 00051 KSimpleDataRowText, flags, EFalse ); 00052 00053 00054 // Add core data row to the top-most level of the tree. 00055 _LIT( KCoreDataRowText, "Core data row" ); 00056 TAknTreeItemID coreItem = aList->AddCoreDataRowL( KAknTreeIIDRoot, 00057 KCoreDataRowText, KNullDesC(), KNullDesC(), flags, EFalse ); 00058 00059 00060 // Add subtitle row to the to the top-most level of the tree. 00061 _LIT( KSubtitleRowText, "Subtitle row (default icons)" ); 00062 TAknTreeItemID subtitle = aList->AddSubtitleRowL( KAknTreeIIDRoot, 00063 KSubtitleRowText, flags, EFalse ); 00064 00065 00066 // Add subtitle row to the to the previously added subtitle row. 00067 // Although this is possible, the hierarchy should be restricted to 00068 // two levels. Otherwise, the list will get too complicated for the 00069 // user to use, as it offers no hints of the underlying hierarchy. 00070 _LIT( KEmptySubtitleRowText, "Subtitle row (empty)" ); 00071 aList->AddSubtitleRowL( subtitle, KEmptySubtitleRowText, flags, 00072 EFalse ); 00073 00074 00075 // Add icons to the list. The list returns an identifier for each icon 00076 // that is added to the list. The client should save this ID and use 00077 // it to set list items to use the icon. If the icon is no longer 00078 // required to be used by list items, it can be removed from the list 00079 // with CAknTreeList::RemoveIcon() method, when no longer needed. 00080 TInt icon = aList->AddIconL( KAknsIIDQgnIndiS60, 00081 AknIconUtils::AvkonIconFileName(), EMbmAvkonQgn_indi_s60, 00082 EMbmAvkonQgn_indi_s60_mask, EAspectRatioPreserved ); 00083 00084 TInt optIcon1 = aList->AddIconL( KAknsIIDQgnPropBtMisc, 00085 AknIconUtils::AvkonIconFileName(), EMbmAvkonQgn_prop_bt_misc, 00086 EMbmAvkonQgn_prop_bt_misc_mask, EAspectRatioPreserved ); 00087 00088 00089 // Add subtile row with new folder icons to top-most level. 00090 _LIT( KSubtitleWithIconRowText, "Subtitle row (new icons)" ); 00091 TAknTreeItemID parent = aList->AddSubtitleRowL( KAknTreeIIDRoot, 00092 KSubtitleWithIconRowText, flags, EFalse ); 00093 aList->SetIcon( parent, CAknSingleColumnStyleTreeList::ECollapsedNode, 00094 icon, EFalse ); 00095 aList->SetIcon( parent, CAknSingleColumnStyleTreeList::EExpandedNode, 00096 icon, EFalse ); 00097 00098 00099 // Add simple data row to the previously added subtitle row. 00100 TAknTreeItemID item1 = aList->AddSimpleDataRowL( parent, 00101 KSimpleDataRowText, flags, EFalse ); 00102 00103 // Set item use pre-defined hierarhciacl list file icon. 00104 aList->SetIcon( item1, CAknSingleColumnStyleTreeList::ELeaf, 00105 AknTreeListIconID::KDefaultFileIndication, EFalse ); 00106 00107 // Set item use added optional icon. 00108 aList->SetIcon( item1, CAknSingleColumnStyleTreeList::EOptionalIcon1, 00109 optIcon1, EFalse ); 00110 00111 00112 // Create bitmap icon with mask and add the bitmaps to the list. 00113 CFbsBitmap* bitmap = NULL; 00114 CFbsBitmap* mask = NULL; 00115 AknIconUtils::CreateIconLC( bitmap, mask, 00116 AknIconUtils::AvkonIconFileName(), 00117 EMbmAvkonQgn_indi_mce_priority_high, 00118 EMbmAvkonQgn_indi_mce_priority_high_mask ); 00119 00120 TInt bitmapIconId = aList->AddIconL( bitmap, mask, ETrue, 00121 EAspectRatioPreserved ); 00122 CleanupStack::Pop( 2 ); 00123 00124 00125 _LIT( KColumn1Text, "C1 - column" ); 00126 _LIT( KColumn2Text, "C2 - column" ); 00127 _LIT( KColumn3Text, "C3 - column" ); 00128 00129 // Add core data row with two columns to the list. And set row 00130 // emphasised with EEmphasis flag. 00131 TAknTreeItemID item2 = aList->AddCoreDataRowL( parent, 00132 KColumn1Text, KColumn2Text, 00133 flags | CAknSingleColumnStyleTreeList::EEmphasis, EFalse ); 00134 00135 // Set item use pre-defined file icon. By default, the core data row 00136 // does not use any icons. 00137 aList->SetIcon( item2, CAknSingleColumnStyleTreeList::ELeaf, 00138 AknTreeListIconID::KDefaultFileIndication, EFalse ); 00139 00140 // Set previously added bitmap icon as item's optional icon. 00141 aList->SetIcon( item2, CAknSingleColumnStyleTreeList::EOptionalIcon1, 00142 bitmapIconId, EFalse ); 00143 00144 00145 // Add core data row with three columns to the list. 00146 TAknTreeItemID item3 = aList->AddCoreDataRowL( parent, 00147 KColumn1Text, KColumn2Text, KColumn3Text, flags, EFalse ); 00148 00149 // Set item use pre-defined file icon. 00150 aList->SetIcon( item3, CAknSingleColumnStyleTreeList::ELeaf, 00151 AknTreeListIconID::KDefaultFileIndication, EFalse ); 00152 00153 // Set item emphasised. 00154 aList->SetEmphasis( item3, ETrue, EFalse ); 00155 } 00156 00157 00158 // ======== MEMBER FUNCTIONS ======== 00159 00160 // --------------------------------------------------------------------------- 00161 // Standard construction sequence 00162 // --------------------------------------------------------------------------- 00163 // 00164 CHierarchicalColumnListAppView* CHierarchicalColumnListAppView::NewL( 00165 const TRect& aRect ) 00166 { 00167 CHierarchicalColumnListAppView* self = 00168 CHierarchicalColumnListAppView::NewLC( aRect ); 00169 CleanupStack::Pop( self ); 00170 return self; 00171 } 00172 00173 00174 CHierarchicalColumnListAppView* CHierarchicalColumnListAppView::NewLC( 00175 const TRect& aRect ) 00176 { 00177 CHierarchicalColumnListAppView* self = 00178 new ( ELeave ) CHierarchicalColumnListAppView; 00179 CleanupStack::PushL( self ); 00180 self->ConstructL( aRect ); 00181 return self; 00182 } 00183 00184 00185 CHierarchicalColumnListAppView::CHierarchicalColumnListAppView() 00186 : iMarkingModeEnabled( EFalse ) 00187 { 00188 } 00189 00190 00191 CHierarchicalColumnListAppView::~CHierarchicalColumnListAppView() 00192 { 00193 delete iBgContext; 00194 delete iList; 00195 } 00196 00197 00198 void CHierarchicalColumnListAppView::ConstructL( const TRect& aRect ) 00199 { 00200 // Create a window for this application view. 00201 CreateWindowL(); 00202 00203 // Init component array. 00204 InitComponentArrayL(); 00205 Components().SetControlsOwnedExternally( ETrue ); 00206 00207 // Construct list. 00208 CAknSingleColumnStyleTreeList* list = 00209 CAknSingleColumnStyleTreeList::NewL( *this ); 00210 00211 // Use list as a component control of the view. 00212 Components().AppendLC( list, KCoeNoControlId ); 00213 CleanupStack::Pop( list ); 00214 iList = list; 00215 00216 // Set the view to observer events from tree list. These events will 00217 // be received through MAknTreeObserver inerface. 00218 iList->AddObserverL( this ); 00219 00220 // Populate the list with some list items. 00221 PopulateListL( iList ); 00222 00223 // Construct background control context. 00224 iBgContext = CAknsBasicBackgroundControlContext::NewL( 00225 KAknsIIDQsnBgAreaMain, iAvkonAppUi->ApplicationRect(), EFalse ); 00226 00227 SetComponentsToInheritVisibility( ETrue ); 00228 00229 // Set the windows size. 00230 SetRect( aRect ); 00231 00232 // Activate the window, which makes it ready to be drawn. This makes also 00233 // the list ready to be drawn, as it is now component of this control. 00234 ActivateL(); 00235 } 00236 00237 00238 // --------------------------------------------------------------------------- 00239 // Expands currently focused node. 00240 // --------------------------------------------------------------------------- 00241 // 00242 void CHierarchicalColumnListAppView::ExpandFocusedNode() 00243 { 00244 if ( iList ) 00245 { 00246 // Get focused item ID. 00247 TAknTreeItemID focused = iList->FocusedItem(); 00248 00249 // Check that focused item is a node and then expand it. 00250 if ( focused != KAknTreeIIDNone && iList->IsNode( focused ) ) 00251 { 00252 iList->ExpandNode( focused, ETrue ); 00253 } 00254 } 00255 } 00256 00257 00258 // --------------------------------------------------------------------------- 00259 // Collapses currently focused node. 00260 // --------------------------------------------------------------------------- 00261 // 00262 void CHierarchicalColumnListAppView::CollapseFocusedNode() 00263 { 00264 if ( iList ) 00265 { 00266 // Get focused item ID. 00267 TAknTreeItemID focused = iList->FocusedItem(); 00268 00269 // Check that focused item is a node and then collapse it. 00270 if ( focused != KAknTreeIIDNone && iList->IsNode( focused ) ) 00271 { 00272 iList->CollapseNode( focused, ETrue ); 00273 } 00274 } 00275 } 00276 00277 00278 // --------------------------------------------------------------------------- 00279 // Opens currently focused item. 00280 // --------------------------------------------------------------------------- 00281 // 00282 void CHierarchicalColumnListAppView::OpenFocusedItem() 00283 { 00284 if ( iList ) 00285 { 00286 // Get focused item ID. 00287 TAknTreeItemID focused = iList->FocusedItem(); 00288 00289 // Get item type of focused item. 00290 CAknSingleColumnStyleTreeList::TItemType type = 00291 iList->ItemType( focused ); 00292 00293 // If focused item is core data row, remove emphasis from the item. 00294 if ( type == CAknSingleColumnStyleTreeList::ECoreDataRow ) 00295 { 00296 iList->SetEmphasis( focused, EFalse, ETrue ); 00297 } 00298 } 00299 } 00300 00301 00302 // --------------------------------------------------------------------------- 00303 // Checks whether the list is looping. 00304 // --------------------------------------------------------------------------- 00305 // 00306 TBool CHierarchicalColumnListAppView::IsListLooping() const 00307 { 00308 return iList && ( iList->Flags() & KAknTreeListLooping ); 00309 } 00310 00311 00312 // --------------------------------------------------------------------------- 00313 // Toggles the looping setting. 00314 // --------------------------------------------------------------------------- 00315 // 00316 void CHierarchicalColumnListAppView::ChangeLooping() 00317 { 00318 if ( iList ) 00319 { 00320 iList->SetFlags( iList->Flags() ^ KAknTreeListLooping ); 00321 } 00322 } 00323 00324 00325 // --------------------------------------------------------------------------- 00326 // Checks whether marquee scrolling is enabled in the list. When marquee 00327 // scrolling is enabled for the hierarchical column list, marquee scolling 00328 // is used to display the content of those subtitle and simple data rows, 00329 // whose content is not otherwise fully visible. Marquee scolling is never 00330 // used with core data rows. 00331 // --------------------------------------------------------------------------- 00332 // 00333 TBool CHierarchicalColumnListAppView::IsMarqueeOn() const 00334 { 00335 return iList && ( iList->Flags() & KAknTreeListMarqueeScrolling ); 00336 } 00337 00338 00339 // --------------------------------------------------------------------------- 00340 // Toggles the marquee setting. 00341 // --------------------------------------------------------------------------- 00342 // 00343 void CHierarchicalColumnListAppView::ChangeMarquee() 00344 { 00345 if ( iList ) 00346 { 00347 iList->SetFlags( iList->Flags() ^ KAknTreeListMarqueeScrolling ); 00348 } 00349 } 00350 00351 00352 // --------------------------------------------------------------------------- 00353 // Checks whether list is set markable. When list is set markable, the list 00354 // list responds to the specified pointer and key events by marking and 00355 // unmarking the items as necessary. The list client can change the marking 00356 // of tree items through hierarchical list API, even if the list is not set 00357 // markable. 00358 // --------------------------------------------------------------------------- 00359 // 00360 TBool CHierarchicalColumnListAppView::IsMarkable() const 00361 { 00362 return iList && ( iList->Flags() & KAknTreeListMarkable ); 00363 } 00364 00365 00366 // --------------------------------------------------------------------------- 00367 // Toggles the markable setting. 00368 // --------------------------------------------------------------------------- 00369 // 00370 void CHierarchicalColumnListAppView::ChangeMarkable() 00371 { 00372 if ( iList ) 00373 { 00374 iList->SetFlags( iList->Flags() ^ KAknTreeListMarkable ); 00375 } 00376 } 00377 00378 00379 // --------------------------------------------------------------------------- 00380 // Changes the used collapse/expand function indicators. 00381 // --------------------------------------------------------------------------- 00382 // 00383 void CHierarchicalColumnListAppView::ChangeFunctionIndicatorsL() 00384 { 00385 if ( iList ) 00386 { 00387 iList->EnableTabModeFunctionIndicatorsL( 00388 !iList->TabModeFunctionIndicators() ); 00389 } 00390 } 00391 00392 00393 // --------------------------------------------------------------------------- 00394 // Marks the focused list item. 00395 // --------------------------------------------------------------------------- 00396 // 00397 void CHierarchicalColumnListAppView::Mark() 00398 { 00399 if ( iList && iList->FocusedItem() != KAknTreeIIDNone ) 00400 { 00401 iList->SetMarked( iList->FocusedItem(), ETrue, ETrue ); 00402 } 00403 } 00404 00405 00406 // --------------------------------------------------------------------------- 00407 // Unmarks the focused list item. 00408 // --------------------------------------------------------------------------- 00409 // 00410 void CHierarchicalColumnListAppView::Unmark() 00411 { 00412 if ( iList && iList->FocusedItem() != KAknTreeIIDNone ) 00413 { 00414 iList->SetMarked( iList->FocusedItem(), EFalse, ETrue ); 00415 } 00416 } 00417 00418 00419 // --------------------------------------------------------------------------- 00420 // Marks every item in the list. 00421 // --------------------------------------------------------------------------- 00422 // 00423 void CHierarchicalColumnListAppView::MarkAll() 00424 { 00425 if ( iList ) 00426 { 00427 // Every list item can be set marked by setting the tree root as 00428 // the marked item. 00429 iList->SetMarked( KAknTreeIIDRoot, ETrue, ETrue ); 00430 } 00431 } 00432 00433 00434 // --------------------------------------------------------------------------- 00435 // Unmarks every item in the list. 00436 // --------------------------------------------------------------------------- 00437 // 00438 void CHierarchicalColumnListAppView::UnmarkAll() 00439 { 00440 if ( iList ) 00441 { 00442 // The marking can be removed from every list item by specifying 00443 // the tree root as the unmarked item. 00444 iList->SetMarked( KAknTreeIIDRoot, EFalse, ETrue ); 00445 } 00446 } 00447 00448 00449 // --------------------------------------------------------------------------- 00450 // Dynamically initialises a options menu pane. 00451 // Unnecessary expand, collapse, and open commands are removed from the 00452 // options menu depending on focused item type and state. 00453 // --------------------------------------------------------------------------- 00454 // 00455 void CHierarchicalColumnListAppView::DynInitOptionsMenuPaneL( 00456 CEikMenuPane* aMenuPane ) 00457 { 00458 if ( iList && iList->FocusedItem() != KAknTreeIIDNone ) 00459 { 00460 if ( iList->IsNode( iList->FocusedItem() ) ) 00461 { 00462 // Focused item is node, remove open command and the invalid one 00463 // of expand and collapse commands. 00464 aMenuPane->DeleteMenuItem( EHclExampleCmdOpen ); 00465 if ( iList->IsExpanded( iList->FocusedItem() ) ) 00466 { 00467 aMenuPane->DeleteMenuItem( EHclExampleCmdExpand ); 00468 } 00469 else 00470 { 00471 aMenuPane->DeleteMenuItem( EHclExampleCmdCollapse ); 00472 } 00473 } 00474 else 00475 { 00476 // Focused item is a leaf, remove expand and collapse commands. 00477 aMenuPane->DeleteMenuItem( EHclExampleCmdExpand ); 00478 aMenuPane->DeleteMenuItem( EHclExampleCmdCollapse ); 00479 } 00480 } 00481 else 00482 { 00483 // No item is focused, remove all related commands. 00484 aMenuPane->DeleteMenuItem( EHclExampleCmdOpen ); 00485 aMenuPane->DeleteMenuItem( EHclExampleCmdExpand ); 00486 aMenuPane->DeleteMenuItem( EHclExampleCmdCollapse ); 00487 } 00488 } 00489 00490 00491 // --------------------------------------------------------------------------- 00492 // Dynamically initialises a settings menu pane. 00493 // --------------------------------------------------------------------------- 00494 // 00495 void CHierarchicalColumnListAppView::DynInitSettingsMenuPaneL( 00496 CEikMenuPane* aMenuPane ) 00497 { 00498 // List looping setting. The menu symbol is set for the item 00499 // depending whether looping is enabled for the list. 00500 if ( IsListLooping() ) 00501 { 00502 aMenuPane->ItemData( EHclExampleCmdChangeLooping ).iFlags 00503 |= EEikMenuItemSymbolOn; 00504 } 00505 else 00506 { 00507 aMenuPane->ItemData( EHclExampleCmdChangeLooping ).iFlags 00508 &= ~EEikMenuItemSymbolOn; 00509 } 00510 00511 // Marquee scrolling setting. The menu symbol is set for the item 00512 // depending whether marquee scrolling is enabled for the list. 00513 if ( IsMarqueeOn() ) 00514 { 00515 aMenuPane->ItemData( EHclExampleCmdChangeMarquee ).iFlags 00516 |= EEikMenuItemSymbolOn; 00517 } 00518 else 00519 { 00520 aMenuPane->ItemData( EHclExampleCmdChangeMarquee ).iFlags 00521 &= ~EEikMenuItemSymbolOn; 00522 } 00523 00524 // Markable list setting. The menu symbol is set for the item 00525 // depending whether list is set markable. 00526 if ( IsMarkable() ) 00527 { 00528 aMenuPane->ItemData( EHclExampleCmdChangeMarkable ).iFlags 00529 |= EEikMenuItemSymbolOn; 00530 } 00531 else 00532 { 00533 aMenuPane->ItemData( EHclExampleCmdChangeMarkable).iFlags 00534 &= ~EEikMenuItemSymbolOn; 00535 } 00536 00537 // Tabulator mode expand/collapse function indicator setting. 00538 // The menu symbol is set for the item depending whether tabulator 00539 // mode function indicators are enabled for the list. 00540 if ( iList && iList->TabModeFunctionIndicators() ) 00541 { 00542 aMenuPane->ItemData( EHclExampleCmdChangeIndicators ).iFlags 00543 |= EEikMenuItemSymbolOn; 00544 } 00545 else 00546 { 00547 aMenuPane->ItemData( EHclExampleCmdChangeIndicators ).iFlags 00548 &= ~EEikMenuItemSymbolOn; 00549 } 00550 } 00551 00552 00553 // --------------------------------------------------------------------------- 00554 // Dynamically initialises a marking menu pane. 00555 // --------------------------------------------------------------------------- 00556 // 00557 void CHierarchicalColumnListAppView::DynInitMarkingMenuPaneL( 00558 CEikMenuPane* aMenuPane ) 00559 { 00560 if ( iList && iList->FocusedItem() != KAknTreeIIDNone ) 00561 { 00562 if ( iList->IsMarked( iList->FocusedItem() ) ) 00563 { 00564 aMenuPane->DeleteMenuItem( EAknCmdMark ); 00565 } 00566 else 00567 { 00568 aMenuPane->DeleteMenuItem( EAknCmdUnmark ); 00569 } 00570 } 00571 else 00572 { 00573 aMenuPane->DeleteMenuItem( EAknCmdMark ); 00574 aMenuPane->DeleteMenuItem( EAknCmdUnmark ); 00575 } 00576 } 00577 00578 00579 // --------------------------------------------------------------------------- 00580 // From class CCoeControl. 00581 // Passes key event to the list. 00582 // --------------------------------------------------------------------------- 00583 // 00584 TKeyResponse CHierarchicalColumnListAppView::OfferKeyEventL( 00585 const TKeyEvent& aKeyEvent, TEventCode aType ) 00586 { 00587 if ( iList ) 00588 { 00589 return iList->OfferKeyEventL( aKeyEvent, aType ); 00590 } 00591 else 00592 { 00593 return EKeyWasNotConsumed; 00594 } 00595 } 00596 00597 00598 // --------------------------------------------------------------------------- 00599 // From class MAknTreeListObserver. 00600 // Handles the events from the hierarchical list. In this example application, 00601 // the received events are mainly used to update the MSK commands. 00602 // --------------------------------------------------------------------------- 00603 // 00604 TBool CHierarchicalColumnListAppView::HandleTreeListEvent( CAknTreeList& aList, 00605 TAknTreeItemID aItem, TEvent aEvent ) 00606 { 00607 // This event is received from hierarchical list, when one of the nodes 00608 // in the list is being expanded. In this example, the list contains only 00609 // a static structure, but when the list content is being updated 00610 // dynamically, the content of the node should be updated on this event. 00611 if ( aEvent == ENodeExpanded ) 00612 { 00613 // If the expanded node is currently focused and the list is not in 00614 // the marking mode, the MSK command is updated. 00615 if ( aItem == aList.FocusedItem() && !iMarkingModeEnabled ) 00616 { 00617 ChangeMskCommand( EHclExampleCmdCollapse, 00618 R_QTN_MSK_COLLAPSE ); 00619 } 00620 } 00621 00622 // This event is received from hierarchical list, when one of the nodes 00623 // in the list is collapsed. The item ID of collapsed node is received 00624 // in aItem parameter. 00625 else if ( aEvent == ENodeCollapsed ) 00626 { 00627 // If the collapsed node is currently focused and the list is not in 00628 // the marking mode, the MSK command is updated. 00629 if ( aItem == aList.FocusedItem() && !iMarkingModeEnabled ) 00630 { 00631 ChangeMskCommand( EHclExampleCmdExpand, 00632 R_QTN_MSK_EXPAND ); 00633 } 00634 } 00635 00636 // EItemFocused event is received from the list, when the focused item 00637 // changes. The list also sents this event, when it gains or loses focus. 00638 else if ( aEvent == EItemFocused ) 00639 { 00640 // MSK command is updated on focus change events, if the list is not 00641 // in the marking mode. 00642 if ( !iMarkingModeEnabled ) 00643 { 00644 UpdateMskCommand( aList, aItem ); 00645 } 00646 } 00647 00648 // EItemSelected event is received when a leaf item (simple data row or 00649 // core data row in hierarchical column list) is selected. 00650 else if ( aEvent == EItemSelected ) 00651 { 00652 OpenFocusedItem(); 00653 } 00654 00655 // EItemRemoved event is received when an item is being removed from 00656 // the list. 00657 else if ( aEvent == EItemRemoved ) 00658 { 00659 } 00660 00661 // EMarkinModeEnabled event is received when hierarchical list has 00662 // entered in marking mode. In marking mode, the list controls the 00663 // mark/unmark commands in MSK, and the list client is not allowed 00664 // to change MSK commands. 00665 else if ( aEvent == EMarkingModeEnabled ) 00666 { 00667 iMarkingModeEnabled = ETrue; 00668 } 00669 00670 // The EMarkingModeDisabled event is received when hierarchical list 00671 // exits the marking mode and it no longer controls the MSK commands. 00672 // At this point, the client should resume to update them itself. 00673 else if ( aEvent == EMarkingModeDisabled ) 00674 { 00675 iMarkingModeEnabled = EFalse; 00676 UpdateMskCommand( aList, aList.FocusedItem() ); 00677 } 00678 00679 return KErrNone; 00680 } 00681 00682 00683 // --------------------------------------------------------------------------- 00684 // From class CCoeControl. 00685 // --------------------------------------------------------------------------- 00686 // 00687 void CHierarchicalColumnListAppView::FocusChanged( TDrawNow aDrawNow ) 00688 { 00689 // When application view gets notification of focus change, the focus 00690 // state is updated also to the hierarchical column list. This is 00691 // required to get list show the highlight for focused item and to 00692 // respond to key events. 00693 if ( iList ) 00694 { 00695 iList->SetFocus( IsFocused(), aDrawNow ); 00696 } 00697 } 00698 00699 00700 // --------------------------------------------------------------------------- 00701 // From class CCoeControl. 00702 // Handles size change. 00703 // --------------------------------------------------------------------------- 00704 // 00705 void CHierarchicalColumnListAppView::SizeChanged() 00706 { 00707 // Get the rectangle set for the application view and update the list 00708 // and background control context to occupy the same area. 00709 TRect rect = Rect(); 00710 00711 if ( iList ) 00712 { 00713 iList->SetRect( rect ); 00714 } 00715 00716 if ( iBgContext ) 00717 { 00718 iBgContext->SetRect( rect ); 00719 } 00720 } 00721 00722 00723 // --------------------------------------------------------------------------- 00724 // From class CCoeControl. 00725 // Supplies background control context. 00726 // --------------------------------------------------------------------------- 00727 // 00728 TTypeUid::Ptr CHierarchicalColumnListAppView::MopSupplyObject( TTypeUid aId ) 00729 { 00730 if ( aId.iUid == MAknsControlContext::ETypeId && iBgContext ) 00731 { 00732 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); 00733 } 00734 return CCoeControl::MopSupplyObject( aId ); 00735 } 00736 00737 00738 // --------------------------------------------------------------------------- 00739 // Updates MSK command and label. 00740 // --------------------------------------------------------------------------- 00741 // 00742 void CHierarchicalColumnListAppView::UpdateMskCommand( CAknTreeList& aList, 00743 TAknTreeItemID aFocusedItem ) 00744 { 00745 TInt resourceId = NULL; 00746 TInt command = NULL; 00747 00748 // Determine the MSK command depending on the focused item type and state. 00749 if ( aFocusedItem == KAknTreeIIDNone ) 00750 { 00751 // No item focused. 00752 } 00753 else if ( aList.IsNode( aFocusedItem ) ) 00754 { 00755 if ( aList.IsExpanded( aFocusedItem ) ) 00756 { 00757 resourceId = R_QTN_MSK_COLLAPSE; 00758 command = EHclExampleCmdCollapse; 00759 } 00760 else 00761 { 00762 resourceId = R_QTN_MSK_EXPAND; 00763 command = EHclExampleCmdExpand; 00764 } 00765 } 00766 else if ( aList.IsLeaf( aFocusedItem ) ) 00767 { 00768 resourceId = R_QTN_MSK_OPEN; 00769 command = EHclExampleCmdOpen; 00770 } 00771 00772 if ( resourceId ) 00773 { 00774 ChangeMskCommand( command, resourceId ); 00775 } 00776 } 00777 00778 00779 // --------------------------------------------------------------------------- 00780 // Changes MSK command and label. 00781 // --------------------------------------------------------------------------- 00782 // 00783 void CHierarchicalColumnListAppView::ChangeMskCommand( TInt aCommandId, 00784 TInt aLabelResourceId ) 00785 { 00786 // The MSK commands should not be changed when controlled by the list. 00787 __ASSERT_DEBUG( !iMarkingModeEnabled, User::Invariant() ); 00788 00789 // Get cba and update the given label and command to MSK. 00790 CEikButtonGroupContainer* cba = iAvkonAppUi->Cba(); 00791 if ( cba ) 00792 { 00793 TBuf<20> label; 00794 StringLoader::Load( label, aLabelResourceId, iCoeEnv ); 00795 cba->SetCommandL( 3, aCommandId, label ); 00796 cba->DrawDeferred(); 00797 } 00798 } 00799 00800 00801 // --------------------------------------------------------------------------- 00802 // From class CCoeControl. 00803 // Draw this application's view to the screen. 00804 // --------------------------------------------------------------------------- 00805 // 00806 void CHierarchicalColumnListAppView::Draw( const TRect& /*aRect*/ ) const 00807 { 00808 // Get the standard graphics context. 00809 CWindowGc& gc = SystemGc(); 00810 00811 // Gets the control's extent. 00812 TRect rect = Rect(); 00813 00814 // Clears the screen. 00815 gc.Clear( rect ); 00816 } 00817 00818
|
© Nokia 2009 |