chxavselectsettingsviewwindow.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:7k
源码类别:

Symbian

开发平台:

C/C++

  1. /************************************************************************
  2.  * chxavselectsettingsviewwindow.cpp
  3.  * ---------------------------------
  4.  *
  5.  * Synopsis:
  6.  * Implementation for window for the CHXAvSelectSettingsView view.
  7.  *
  8.  *
  9.  * Target:
  10.  * Symbian OS
  11.  *
  12.  *
  13.  * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
  14.  *
  15.  ************************************************************************/
  16. // Symbian includes...
  17. #include <eikclbd.h>
  18. #include <eikclb.h>
  19. #include <akntitle.h>
  20. #include <aknlists.h>
  21. #include <AknGrid.h>
  22. // Includes from this project...
  23. #include "chxavmisc.h"
  24. #include "chxavselectsettingsview.h"
  25. #include "chxavselectsettingsviewwindow.h"
  26. #include "chxavcleanstring.h"
  27. #include "realplayer.hrh"
  28. #include "hxsym_debug.h"
  29. #include "chxavcleanupstack.h"
  30. #include "realplayer.rsg"
  31. #include "player_uids.h"
  32. #include "realplayer.mbg"
  33. #include "help/r1p.hlp.hrh"
  34. ///////////////////////////////////
  35. // ctor
  36. CHXAvSelectSettingsViewWindow::CHXAvSelectSettingsViewWindow(CHXAvSelectSettingsView* pView)
  37. : m_wpView(pView)
  38. {
  39. }
  40. ///////////////////////////////////
  41. // dtor
  42. CHXAvSelectSettingsViewWindow::~CHXAvSelectSettingsViewWindow()
  43. {
  44. }
  45. ////////////////////////////////////////////////////////////
  46. //
  47. void CHXAvSelectSettingsViewWindow::ConstructL(const TRect& rc, TInt idxInit)
  48. {
  49.     CEikStatusPane* pStatusPane = iEikonEnv->AppUiFactory()->StatusPane();
  50.     
  51.     CAknTitlePane* pTitlePane
  52. = static_cast<CAknTitlePane*>(
  53. pStatusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
  54.     pTitlePane->SetTextL(CHXAvCleanString(R_SETTINGS_TITLE_MAIN)());
  55.     CreateWindowL();
  56.     SetRect(rc);
  57.     ShowMainSelectionListBoxL(idxInit);
  58.     ActivateL();
  59.     DrawNow();
  60. }
  61. ////////////////////////////////////////////////////////////
  62. //
  63. void CHXAvSelectSettingsViewWindow::AddItemHelperL(CDesCArrayFlat* pItems, TInt idxIcon, TInt resId) const
  64. {
  65.     HBufC* pEntry = CHXAvMisc::AllocGrListItemL(CHXAvMisc::Single, idxIcon , CHXAvCleanString(resId)());
  66.     AUTO_PUSH_POP_DEL(pEntry);
  67.     pItems->AppendL(*pEntry);
  68. }
  69. ////////////////////////////////////////////////////////////
  70. //
  71. CDesCArrayFlat* CHXAvSelectSettingsViewWindow::AllocListItemsL() const
  72. {
  73.     CDesCArrayFlat* pItems = new (ELeave) CDesCArrayFlat(20 /*granularity*/);
  74.     AUTO_PUSH_POP(pItems); // out
  75.     AddItemHelperL(pItems, 0, R_SETTINGS_TAB_VIDEO);
  76.     AddItemHelperL(pItems, 1, R_SETTINGS_TAB_PLAYBACK);
  77.     AddItemHelperL(pItems, 2, R_SETTINGS_TAB_NETWORK); 
  78.     AddItemHelperL(pItems, 3, R_SETTINGS_TAB_PROXY); 
  79. #if defined(HELIX_FEATURE_DPRINTF)
  80.     AddItemHelperL(pItems, 4, R_SETTINGS_TAB_DEBUG); 
  81. #endif
  82.     return pItems;
  83. }
  84. ////////////////////////////////////////////////////////////
  85. // 42 X 29 (their folder = 42 x 36; mark icon = 13 x 13) for large icons
  86. void CHXAvSelectSettingsViewWindow::SetMainSelectionListBoxIconsL()
  87. {
  88.     HX_ASSERT(m_spCategoryListBox);
  89.     CHXAvMisc::ImageInfo const settingsMainListIcons[] =
  90.     {
  91.     { EMbmRealplayerQgn_prop_sett_video_sub, EMbmRealplayerQgn_prop_sett_video_sub_mask }, 
  92.     { EMbmRealplayerQgn_prop_sett_playback_sub, EMbmRealplayerQgn_prop_sett_playback_sub_mask },
  93.     { EMbmRealplayerQgn_prop_sett_network_sub, EMbmRealplayerQgn_prop_sett_network_sub_mask },
  94.     { EMbmRealplayerQgn_prop_sett_proxy_sub, EMbmRealplayerQgn_prop_sett_proxy_sub_mask },
  95.     { EMbmRealplayerQgn_prop_media_sub, EMbmRealplayerQgn_prop_media_sub_mask } // debug arbitrary
  96.     };
  97.     CAknIconArray* pIcons = CHXAvMisc::AllocIconsL(settingsMainListIcons, ARRAY_COUNT(settingsMainListIcons));
  98.     AUTO_PUSH_POP(pIcons);
  99.     // CEikColumnListBox: // transfer icon array ownership to list box
  100.     m_spCategoryListBox->ItemDrawer()->ColumnData()->SetIconArray(pIcons);
  101. }
  102. ////////////////////////////////////////////
  103. // MEikListBoxObserver; called when something happens with main selection list
  104. void CHXAvSelectSettingsViewWindow::HandleListBoxEventL(CEikListBox* /*aListBox*/,TListBoxEvent aEventType)
  105. {
  106.     if( aEventType == MEikListBoxObserver::EEventEnterKeyPressed ||
  107. aEventType == MEikListBoxObserver::EEventItemClicked )
  108.     {
  109. DPRINTF(SYMP_WSEVENTS, ("CHXAvSelectSettingsViewWindow::HandleListBoxEventL()n: click!"));
  110.         m_wpView->HandleCommandL(EOpenSettings);
  111.     }
  112. }
  113. ////////////////////////////////////////////
  114. //
  115. TInt CHXAvSelectSettingsViewWindow::GetCurrentSelectionIndex() const
  116. {
  117.     TInt idx = -1;
  118.     if( m_spCategoryListBox )
  119.     {
  120.         idx = m_spCategoryListBox->CurrentItemIndex();
  121.     }
  122.     return idx;
  123. }
  124. ////////////////////////////////////////////////////////////////////
  125. // (re-)create the main selection list box for selecting settings
  126. // category
  127. //
  128. void CHXAvSelectSettingsViewWindow::ShowMainSelectionListBoxL(TInt idxInit)
  129. {
  130.     //
  131.     // list entries for 'CAknSingleLargeStyleListBox' should look like:
  132.     //
  133.     // {idxIcon}t{text}
  134.     //
  135.     m_spCategoryListBox = new (ELeave) CAknSingleLargeStyleListBox();
  136.     const TInt flags = EAknListBoxSelectionList;     
  137.     m_spCategoryListBox->ConstructL(this, flags);
  138.     m_spCategoryListBox->SetMopParent(this);
  139.     SetMainSelectionListBoxIconsL();
  140.     // create and add listbox contents
  141.     CDesCArrayFlat* pItems = AllocListItemsL();
  142.     AUTO_PUSH_POP(pItems);
  143.     CTextListBoxModel* pModel = m_spCategoryListBox->Model();
  144.     pModel->SetItemTextArray(pItems);
  145.     pModel->SetOwnershipType(ELbmOwnsItemArray);
  146.     m_spCategoryListBox->CreateScrollBarFrameL( ETrue );
  147.     m_spCategoryListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
  148.     m_spCategoryListBox->SetListBoxObserver(this);
  149.     m_spCategoryListBox->HandleItemAdditionL();
  150.     m_spCategoryListBox->Reset();
  151.     m_spCategoryListBox->SetCurrentItemIndex(idxInit);
  152.    
  153.     m_spCategoryListBox->MakeVisible(ETrue);
  154.     m_spCategoryListBox->SetRect(Rect());
  155.     m_spCategoryListBox->ActivateL();
  156.     CHXAvMisc::UpdateScrollBar(m_spCategoryListBox.Ptr());
  157.     
  158. }
  159. ////////////////////////////////////////////
  160. //
  161. void CHXAvSelectSettingsViewWindow::UpdateTopAndBottomL()
  162. {
  163.     CHXAvMisc::UpdateScrollBar(m_spCategoryListBox.Ptr());
  164. }
  165. ////////////////////////////////////////////
  166. // CCoeControl
  167. CCoeControl* CHXAvSelectSettingsViewWindow::ComponentControl( TInt aIndex ) const
  168. {
  169.     HX_ASSERT(aIndex == 0);
  170.     return m_spCategoryListBox.Ptr();
  171. }
  172. ////////////////////////////////////////////
  173. // CCoeControl
  174. TInt CHXAvSelectSettingsViewWindow::CountComponentControls() const
  175. {
  176.     return m_spCategoryListBox ? 1 : 0;
  177. }
  178. ////////////////////////////////////////////
  179. // CCoeControl
  180. void CHXAvSelectSettingsViewWindow::SizeChanged()
  181. {
  182.     TRect rc = Rect();
  183.     if(m_spCategoryListBox)
  184.     {
  185. m_spCategoryListBox->SetRect(rc);
  186.     }  
  187. }
  188. ////////////////////////////////////////////
  189. // CCoeControl
  190. void CHXAvSelectSettingsViewWindow::GetHelpContext(TCoeHelpContext& aContext) const
  191. {
  192.     aContext = TCoeHelpContext( CHXAvMisc::KHelpUID, KRP_HLP_SETTINGS );
  193. }
  194. //////////////////////////////////////
  195. // CCoeControl
  196. TKeyResponse CHXAvSelectSettingsViewWindow::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
  197. {
  198.     // XXXLCM is there a better way to hook up the list box to get events? control stack?
  199.     TKeyResponse response = EKeyWasNotConsumed;
  200.     if( m_spCategoryListBox )
  201.     {
  202.         response = m_spCategoryListBox->OfferKeyEventL(aKeyEvent, aType);
  203.     }
  204.     return response;
  205. }