chxavselectsettingsviewwindow.cpp

来自「symbian 下的helix player源代码」· C++ 代码 · 共 236 行

CPP
236
字号
/************************************************************************
 * chxavselectsettingsviewwindow.cpp
 * ---------------------------------
 *
 * Synopsis:
 * Implementation for window for the CHXAvSelectSettingsView view.
 *
 *
 * Target:
 * Symbian OS
 *
 *
 * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
 *
 ************************************************************************/

// Symbian includes...
#include <eikclbd.h>
#include <eikclb.h>
#include <akntitle.h>
#include <aknlists.h>
#include <AknGrid.h>

// Includes from this project...
#include "chxavmisc.h"
#include "chxavselectsettingsview.h"
#include "chxavselectsettingsviewwindow.h"
#include "chxavcleanstring.h"
#include "realplayer.hrh"
#include "hxsym_debug.h"
#include "chxavcleanupstack.h"
#include "realplayer.rsg"
#include "player_uids.h"
#include "realplayer.mbg"
#include "help/r1p.hlp.hrh"


///////////////////////////////////
// ctor
CHXAvSelectSettingsViewWindow::CHXAvSelectSettingsViewWindow(CHXAvSelectSettingsView* pView)
: m_wpView(pView)
{
}

///////////////////////////////////
// dtor
CHXAvSelectSettingsViewWindow::~CHXAvSelectSettingsViewWindow()
{
}

////////////////////////////////////////////////////////////
//
void CHXAvSelectSettingsViewWindow::ConstructL(const TRect& rc, TInt idxInit)
{
    CEikStatusPane* pStatusPane = iEikonEnv->AppUiFactory()->StatusPane();
    
    CAknTitlePane* pTitlePane
	= static_cast<CAknTitlePane*>(
	pStatusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));

    pTitlePane->SetTextL(CHXAvCleanString(R_SETTINGS_TITLE_MAIN)());

    CreateWindowL();
    SetRect(rc);
    ShowMainSelectionListBoxL(idxInit);
    ActivateL();
    DrawNow();
}

////////////////////////////////////////////////////////////
//
void CHXAvSelectSettingsViewWindow::AddItemHelperL(CDesCArrayFlat* pItems, TInt idxIcon, TInt resId) const
{
    HBufC* pEntry = CHXAvMisc::AllocGrListItemL(CHXAvMisc::Single, idxIcon , CHXAvCleanString(resId)());
    AUTO_PUSH_POP_DEL(pEntry);
    pItems->AppendL(*pEntry);
}

////////////////////////////////////////////////////////////
//
CDesCArrayFlat* CHXAvSelectSettingsViewWindow::AllocListItemsL() const
{
    CDesCArrayFlat* pItems = new (ELeave) CDesCArrayFlat(20 /*granularity*/);
    AUTO_PUSH_POP(pItems); // out

    AddItemHelperL(pItems, 0, R_SETTINGS_TAB_VIDEO);
    AddItemHelperL(pItems, 1, R_SETTINGS_TAB_PLAYBACK);
    AddItemHelperL(pItems, 2, R_SETTINGS_TAB_NETWORK); 
    AddItemHelperL(pItems, 3, R_SETTINGS_TAB_PROXY); 
#if defined(HELIX_FEATURE_DPRINTF)
    AddItemHelperL(pItems, 4, R_SETTINGS_TAB_DEBUG); 
#endif

    return pItems;
}

////////////////////////////////////////////////////////////
// 42 X 29 (their folder = 42 x 36; mark icon = 13 x 13) for large icons
void CHXAvSelectSettingsViewWindow::SetMainSelectionListBoxIconsL()
{
    HX_ASSERT(m_spCategoryListBox);
    CHXAvMisc::ImageInfo const settingsMainListIcons[] =
    {
    { EMbmRealplayerQgn_prop_sett_video_sub, EMbmRealplayerQgn_prop_sett_video_sub_mask }, 
    { EMbmRealplayerQgn_prop_sett_playback_sub, EMbmRealplayerQgn_prop_sett_playback_sub_mask },
    { EMbmRealplayerQgn_prop_sett_network_sub, EMbmRealplayerQgn_prop_sett_network_sub_mask },
    { EMbmRealplayerQgn_prop_sett_proxy_sub, EMbmRealplayerQgn_prop_sett_proxy_sub_mask },
    { EMbmRealplayerQgn_prop_media_sub, EMbmRealplayerQgn_prop_media_sub_mask } // debug arbitrary
    };

    CAknIconArray* pIcons = CHXAvMisc::AllocIconsL(settingsMainListIcons, ARRAY_COUNT(settingsMainListIcons));
    AUTO_PUSH_POP(pIcons);

    // CEikColumnListBox: // transfer icon array ownership to list box
    m_spCategoryListBox->ItemDrawer()->ColumnData()->SetIconArray(pIcons);

}

////////////////////////////////////////////
// MEikListBoxObserver; called when something happens with main selection list
void CHXAvSelectSettingsViewWindow::HandleListBoxEventL(CEikListBox* /*aListBox*/,TListBoxEvent aEventType)
{
    if( aEventType == MEikListBoxObserver::EEventEnterKeyPressed ||
	aEventType == MEikListBoxObserver::EEventItemClicked )
    {
	DPRINTF(SYMP_WSEVENTS, ("CHXAvSelectSettingsViewWindow::HandleListBoxEventL()\n: click!"));
        m_wpView->HandleCommandL(EOpenSettings);
    }
}

////////////////////////////////////////////
//
TInt CHXAvSelectSettingsViewWindow::GetCurrentSelectionIndex() const
{
    TInt idx = -1;
    if( m_spCategoryListBox )
    {
        idx = m_spCategoryListBox->CurrentItemIndex();
    }
    return idx;
}

////////////////////////////////////////////////////////////////////
// (re-)create the main selection list box for selecting settings
// category
//
void CHXAvSelectSettingsViewWindow::ShowMainSelectionListBoxL(TInt idxInit)
{
    //
    // list entries for 'CAknSingleLargeStyleListBox' should look like:
    //
    // {idxIcon}\t{text}
    //

    m_spCategoryListBox = new (ELeave) CAknSingleLargeStyleListBox();
    const TInt flags = EAknListBoxSelectionList;	    
    m_spCategoryListBox->ConstructL(this, flags);
    m_spCategoryListBox->SetMopParent(this);
    SetMainSelectionListBoxIconsL();

    // create and add listbox contents
    CDesCArrayFlat* pItems = AllocListItemsL();
    AUTO_PUSH_POP(pItems);
    CTextListBoxModel* pModel = m_spCategoryListBox->Model();
    pModel->SetItemTextArray(pItems);
    pModel->SetOwnershipType(ELbmOwnsItemArray);

    m_spCategoryListBox->CreateScrollBarFrameL( ETrue );
    m_spCategoryListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
    m_spCategoryListBox->SetListBoxObserver(this);

    m_spCategoryListBox->HandleItemAdditionL();
    m_spCategoryListBox->Reset();
    m_spCategoryListBox->SetCurrentItemIndex(idxInit);
   
    m_spCategoryListBox->MakeVisible(ETrue);
    m_spCategoryListBox->SetRect(Rect());
    m_spCategoryListBox->ActivateL();
    CHXAvMisc::UpdateScrollBar(m_spCategoryListBox.Ptr());
    
}
////////////////////////////////////////////
//
void CHXAvSelectSettingsViewWindow::UpdateTopAndBottomL()
{
    CHXAvMisc::UpdateScrollBar(m_spCategoryListBox.Ptr());
}

////////////////////////////////////////////
// CCoeControl
CCoeControl* CHXAvSelectSettingsViewWindow::ComponentControl( TInt aIndex ) const
{
    HX_ASSERT(aIndex == 0);
    return m_spCategoryListBox.Ptr();
}

////////////////////////////////////////////
// CCoeControl
TInt CHXAvSelectSettingsViewWindow::CountComponentControls() const
{
    return m_spCategoryListBox ? 1 : 0;
}

////////////////////////////////////////////
// CCoeControl
void CHXAvSelectSettingsViewWindow::SizeChanged()
{
    TRect rc = Rect();
    if(m_spCategoryListBox)
    {
	m_spCategoryListBox->SetRect(rc);
    }  
}

////////////////////////////////////////////
// CCoeControl
void CHXAvSelectSettingsViewWindow::GetHelpContext(TCoeHelpContext& aContext) const
{
    aContext = TCoeHelpContext( CHXAvMisc::KHelpUID, KRP_HLP_SETTINGS );
}

//////////////////////////////////////
// CCoeControl
TKeyResponse CHXAvSelectSettingsViewWindow::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
    // XXXLCM is there a better way to hook up the list box to get events? control stack?
    TKeyResponse response = EKeyWasNotConsumed;
    if( m_spCategoryListBox )
    {
        response = m_spCategoryListBox->OfferKeyEventL(aKeyEvent, aType);
    }

    return response;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?