chxavsettingsviewwindow.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:10k
源码类别:
Symbian
开发平台:
Visual C++
- /************************************************************************
- * chxavsettingsviewwindow.h
- * -------------------------
- *
- * Synopsis:
- * Contains the declaration of the setting view window.
- * This window entering/altering player settings.
- *
- * Target:
- * Symbian OS
- *
- *
- * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- ************************************************************************/
- // Symbian includes...
- #include <aknlists.h>
- #include <akntabgrp.h>
- #include <aknnavide.h>
- #include <akntitle.h>
- #include <aknsfld.h>
- #include <aknutils.h>
- #include <aknselectionlist.h>
- #include <barsread.h> //TResourceReader
- // Includes from this project...
- #include "chxavmisc.h"
- #include "chxavplayer.h"
- #include "chxavsettingslist.h"
- #include "chxavsettingsview.h"
- #include "chxavfileutil.h"
- #include "chxavplayerui.h"
- #include "chxavcleanstring.h"
- #include "chxavsettingsviewwindow.h"
- #include "realplayer.hrh"
- #include "player_uids.h"
- #include "hxsym_debug.h"
- #include "hxsym_leaveutil.h"
- #include "realplayer.mbg"
- #include "help/r1p.hlp.hrh"
- CHXAvSettingsViewWindow::CHXAvSettingsViewWindow(CHXAvSettingsView* pView)
- : m_pNaviPane(0)
- , m_pDecoratedTabGroup(0)
- , m_pTitlePane(0)
- , m_pTabGroup(0)
- , m_pView(pView)
- {
- HX_ASSERT(pView != NULL);
- // Grab a pointer to preferences here...
- CHXAvPlayerUI *playerUI = pView->GetPlayerUI();
- HX_ASSERT(playerUI);
- CHXClientEngineManagerPtr spClientEngine = playerUI->GetClientEngineManager();
- m_prefs = spClientEngine->GetPrefs();
- m_factory = spClientEngine->GetFactory();
- }
- CHXAvSettingsViewWindow::~CHXAvSettingsViewWindow()
- {
- CleanUpTabs();
- }
- ////////////////////////////////////////////////////////////
- //
- void CHXAvSettingsViewWindow::CleanUpTabs()
- {
- if( m_pNaviPane )
- {
- if(m_pDecoratedTabGroup)
- {
- m_pNaviPane->Pop(m_pDecoratedTabGroup);
- }
- m_pNaviPane = 0; // we don't own
- }
- HX_DELETE(m_pDecoratedTabGroup);
- m_pTabGroup = 0;
- }
- ////////////////////////////////////////////////////////////
- // update config so it reflects all changes made
- // to current data model
- //
- void CHXAvSettingsViewWindow::ApplyChangesL()
- {
- if( m_spList )
- {
- m_spList->StoreSettingsL();
- }
- HX_ASSERT(m_spData);
- if(m_spData)
- {
- m_spData->UpdatePreferencesL();
- }
- }
- ////////////////////////////////////////////////////////////
- //
- void CHXAvSettingsViewWindow::ConstructL(const TRect& rc, TInt idxInitTab)
- {
- CEikStatusPane* pStatusPane = iEikonEnv->AppUiFactory()->StatusPane();
- m_pTitlePane
- = static_cast<CAknTitlePane*>(
- pStatusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
- m_pNaviPane
- = static_cast<CAknNavigationControlContainer*>(
- pStatusPane->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
- CreateWindowL();
- SetRect(rc);
- CreateTabsL(idxInitTab);
- HX_ASSERT(idxInitTab == m_pTabGroup->ActiveTabIndex());
- ShowPageL(idxInitTab);
- ActivateL();
- }
- ////////////////////////////////////////////////////////////
- //
- void CHXAvSettingsViewWindow::CreateTabsL(TInt idxInitTab)
- {
- HX_ASSERT(m_pNaviPane != 0);
- HX_ASSERT(0 == m_pDecoratedTabGroup);
- m_pDecoratedTabGroup = m_pNaviPane->CreateTabGroupL();
- m_pTabGroup
- = static_cast<CAknTabGroup*>(m_pDecoratedTabGroup->DecoratedControl());
- m_pTabGroup->SetTabFixedWidthL(EAknTabWidthWithFourTabs);
- //
- // create tabs
- //
- TFileName* pImageFilePath = CHXAvFile::AllocAppFolderPathL(CHXAvUtil::KImagesMBMName);
- AUTO_PUSH_POP_DEL(pImageFilePath);
- CHXAvMisc::AddTabL(m_pTabGroup, *pImageFilePath,
- EAVPSetVideoTab,
- EMbmRealplayerQgn_prop_sett_video_tab,
- EMbmRealplayerQgn_prop_sett_video_tab_mask);
- CHXAvMisc::AddTabL(m_pTabGroup, *pImageFilePath,
- EAVPSetPlaybackTab,
- EMbmRealplayerQgn_prop_sett_playback_tab,
- EMbmRealplayerQgn_prop_sett_playback_tab_mask);
- CHXAvMisc::AddTabL(m_pTabGroup, *pImageFilePath,
- EAVPSetNetworkTab,
- EMbmRealplayerQgn_prop_sett_network_tab,
- EMbmRealplayerQgn_prop_sett_network_tab_mask);
- CHXAvMisc::AddTabL(m_pTabGroup, *pImageFilePath,
- EAVPSetProxyTab,
- EMbmRealplayerQgn_prop_sett_proxy_tab,
- EMbmRealplayerQgn_prop_sett_proxy_tab_mask);
- #if defined(HELIX_FEATURE_DPRINTF)
- m_pTabGroup->AddTabL(EAVPSetDebugTab, _L("D"));
- #endif
- m_pTabGroup->SetActiveTabByIndex(idxInitTab);
- m_pNaviPane->PushL(*m_pDecoratedTabGroup);
- }
- ////////////////////////////////////////////
- //
- void CHXAvSettingsViewWindow::UpdateTopAndBottomL()
- {
- UpdateNaviPaneL();
- if(m_spList)
- {
- CHXAvMisc::UpdateScrollBar(m_spList->ListBox());
- }
- }
- ////////////////////////////////////////////////////////////////////
- //
- void CHXAvSettingsViewWindow::ShowPageL(TInt idxPage)
- {
- TInt idTab = m_pTabGroup->TabIdFromIndex(idxPage);
- TInt resID = -1;
- TInt titleResId = -1;
- m_spList = 0;
- switch( idTab )
- {
- case EAVPSetPlaybackTab:
- resID = R_AVP_PLAYBACK_SETTINGS_LIST;
- titleResId = R_SETTINGS_TITLE_PLAYBACK;
- m_spData = new (ELeave) CHXAvSettingsDataPlayback(m_factory, m_prefs);
- break;
- case EAVPSetVideoTab:
- resID = R_AVP_VIDEO_SETTINGS_LIST;
- titleResId = R_SETTINGS_TITLE_VIDEO;
- m_spData = new (ELeave) CHXAvSettingsDataVideo(m_factory,m_prefs);
- break;
- case EAVPSetNetworkTab:
- resID = R_AVP_NETWORK_SETTINGS_LIST;
- titleResId = R_SETTINGS_TITLE_NETWORK;
- m_spData = new (ELeave) CHXAvSettingsDataNetwork(m_factory,m_prefs);
- break;
- case EAVPSetProxyTab:
- resID = R_AVP_PROXY_SETTINGS_LIST;
- titleResId = R_SETTINGS_TITLE_PROXY;
- m_spData = new (ELeave) CHXAvSettingsDataProxy(m_factory,m_prefs);
- break;
- #if defined(HELIX_FEATURE_DPRINTF)
- case EAVPSetDebugTab:
- resID = R_AVP_DEBUG_SETTINGS_LIST;
- titleResId = R_SETTINGS_TITLE_DEBUG;
- m_spData = new (ELeave) CHXAvSettingsDataDebug(m_factory,m_prefs);
- break;
- #endif
- default:
- HX_ASSERT(false);
- }
- m_spData->InitValuesFromPreferencesL();
- // set the title
- m_pTitlePane->SetTextL(CHXAvCleanString(titleResId)());
- // create the list box for current tab view
- m_spList = new (ELeave) CHXAvSettingsList(m_spData);
- m_spList->SetMopParent(this);
- m_spList->ConstructFromResourceL(resID);
- m_spList->OnPostConstructL();
- //
- // create a scrollbar
- //
- CEikFormattedCellListBox* pListBox = m_spList->ListBox();
- pListBox->CreateScrollBarFrameL( ETrue );
- CEikScrollBarFrame* pFrame = pListBox->ScrollBarFrame();
- pFrame->SetScrollBarVisibilityL(
- CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
- m_spList->MakeVisible(ETrue);
- TRect rc = Rect();
- rc.Move(Position());
- m_spList->SetRect(rc);
- m_spList->ActivateL();
- CHXAvMisc::UpdateScrollBar(m_spList->ListBox());
- DrawNow();
- }
- ////////////////////////////////////////////////////////////////////
- //
- void CHXAvSettingsViewWindow::UpdateNaviPaneL()
- {
- DPRINTF(SYMP_INFO, ("CHXAvSettingsViewWindow::UpdateNaviPaneL()n"));
- if( m_pNaviPane && m_pDecoratedTabGroup)
- {
- m_pNaviPane->PushL(*m_pDecoratedTabGroup);
- }
- }
- ////////////////////////////////////////////////////////////////////
- //
- TInt CHXAvSettingsViewWindow::GetCurrentPageIndex() const
- {
- TInt idxTab = -1;
- if( m_pTabGroup)
- {
- idxTab = m_pTabGroup->ActiveTabIndex();
- }
- return idxTab;
- }
- ////////////////////////////////////////////////////////////////////
- //
- void CHXAvSettingsViewWindow::EditCurrentItemL()
- {
- HX_ASSERT(m_spList);
- TInt idx = m_spList->ListBox()->CurrentItemIndex();
- if( idx != -1)
- {
- CAknSettingItemArray* pArray = m_spList->SettingItemArray();
- TInt idxVisible = (*pArray)[idx]->VisibleIndex();
- m_spList->EditItemL(idxVisible, ETrue);
- }
- }
- ////////////////////////////////////////////
- // CCoeControl
- CCoeControl* CHXAvSettingsViewWindow::ComponentControl( TInt aIndex ) const
- {
- HX_ASSERT(aIndex == 0);
- return m_spList.Ptr();
- }
- ////////////////////////////////////////////
- // CCoeControl
- TInt CHXAvSettingsViewWindow::CountComponentControls() const
- {
- return m_spList ? 1 : 0;
- }
- ////////////////////////////////////////////
- // CCoeControl
- void CHXAvSettingsViewWindow::SizeChanged()
- {
- TRect rc = Rect();
- if(m_spList)
- {
- m_spList->SetRect(rc);
- }
- }
- ////////////////////////////////////////////
- // CCoeControl
- void CHXAvSettingsViewWindow::GetHelpContext(TCoeHelpContext& aContext) const
- {
- HX_ASSERT(m_pTabGroup);
- TInt idxTab = m_pTabGroup->ActiveTabIndex();
- TInt idTab = m_pTabGroup->TabIdFromIndex(idxTab);
- TPtrC ptr(KRP_HLP_SETTINGS);
- switch( idTab )
- {
- case EAVPSetPlaybackTab:
- ptr.Set(KRP_HLP_SETT_PLAYBACK);
- break;
- case EAVPSetVideoTab:
- ptr.Set(KRP_HLP_SETT_VIDEO);
- break;
- case EAVPSetNetworkTab:
- ptr.Set(KRP_HLP_SETT_NETWORK);
- break;
- case EAVPSetProxyTab:
- ptr.Set(KRP_HLP_SETT_PROXY);
- break;
- default:
- ptr.Set(KRP_HLP_SETTINGS);
- break;
- }
- aContext = TCoeHelpContext( CHXAvMisc::KHelpUID, ptr );
- }
- ////////////////////////////////////////////////////////////////////
- //
- TKeyResponse CHXAvSettingsViewWindow::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
- {
- TKeyResponse response = EKeyWasNotConsumed;
- if( aType == EEventKey )
- {
- switch( aKeyEvent.iCode )
- {
- case EKeyLeftArrow:
- case EKeyRightArrow:
- // these go to tab control
- if( m_pTabGroup )
- {
- if( EKeyWasConsumed == m_pTabGroup->OfferKeyEventL(aKeyEvent, aType) )
- {
- // save changes made to current settings list...
- ApplyChangesL();
- TInt idxTab = m_pTabGroup->ActiveTabIndex();
- ShowPageL(idxTab);
- response = EKeyWasConsumed;
- }
- }
- break;
- default:
- // everything else goes to list
- if( m_spList )
- {
- response = m_spList->OfferKeyEventL(aKeyEvent, aType);
- }
- break;
- }
- }
- return response;
- }