chxavplaylistnavicontrol.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:4k
源码类别:
Symbian
开发平台:
C/C++
- /*============================================================================*
- *
- * (c) 1995-2002 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- *============================================================================*/
- /*
- Description:
- draws and manages navi pane area shown during playlist navigate state
- */
- #include <aknutils.h>
- #include "chxavmisc.h"
- #include "chxavcleanupstack.h"
- #include "chxavcleanstring.h"
- #include "hxsym_debug.h"
- #include "chxavplaylistnavicontrol.h"
- ////////////////////////////////
- //
- CHXAvPlaylistNaviControl* CHXAvPlaylistNaviControl::NewL(CHXAvPlayer* pPlayer, const CCoeControl& parent)
- {
- CHXAvPlaylistNaviControl* pSelf = new(ELeave) CHXAvPlaylistNaviControl();
- AUTO_PUSH_POP(pSelf);
- pSelf->ConstructL(pPlayer, parent);
- return pSelf;
- }
- ///////////////////////////////////
- // ctor
- CHXAvPlaylistNaviControl::CHXAvPlaylistNaviControl()
- {
- }
- ///////////////////////////////////
- // dtor
- CHXAvPlaylistNaviControl::~CHXAvPlaylistNaviControl()
- {
- if(m_spPlayer)
- {
- m_spPlayer->GetPlayerState().RemoveObserver(this);
- }
- }
- ////////////////////////////
- //
- void CHXAvPlaylistNaviControl::ConstructL(CHXAvPlayer* pPlayer, const CCoeControl& parent)
- {
- m_spPlayer = pPlayer;
- m_spPlayer->GetPlayerState().AddObserver(this);
- SetContainerWindowL(parent);
- TRect rc(parent.Rect());
- SetRect(rc);
- // save this; we want to draw over whole navi control (see SizeChanged)
- m_rcParent = rc;
- //
- // playlist text
- //
- const TInt CID_PLAYLIST_TEXT = 1;
- m_spPlaylistText = CHXAvTextControl::NewL(*this, CID_PLAYLIST_TEXT);
- m_spPlaylistText->SetTextColor(KRgbWhite);
- m_spPlaylistText->UpdateFont(LatinBold12());
- m_spPlaylistText->MakeVisible(ETrue);
- m_spPlaylistText->SetRect(rc); // for now
- UpdatePlaylistTextL();
- }
- //////////////////////////////////////////////
- // hide or show playlist menu items depending
- // on whether or not a playlist is loaded
- void CHXAvPlaylistNaviControl::UpdatePlaylistTextL()
- {
- bool bHaveRam = m_spPlayer->IsPlaylistLoaded();
- if( bHaveRam )
- {
- // 1-based indexes
- TInt idxCount = m_spPlayer->GetPlaylistItemCount();
- TInt idxCurrent = m_spPlayer->GetPlaylistCurrentIndex() + 1;
- CHXAvCleanString playUrl(m_spPlayer->GetPlayURL());
- bool bLocal = CHXAvUtil::IsLocal(playUrl());
- HX_ASSERT(idxCount >= 1 && idxCurrent >= 1);
- if( idxCount > 1 )
- {
- //XXXLCM resource
- _LIT(KLocalClipFormat, "Local clip %d/%d");
- _LIT(KRemoteClipFormat, "Remote clip %d/%d");
- TBuf<40> buf;
- if( bLocal )
- {
- buf.Format(KLocalClipFormat, idxCurrent, idxCount);
- }
- else
- {
- buf.Format(KRemoteClipFormat, idxCurrent, idxCount);
- }
- // determine width needed
- const CFont* pFont = m_spPlaylistText->GetFont();
- TInt cxText = pFont->TextWidthInPixels(buf);
- const TUint CX_RIGHT_BORDER = 2;
- // size rect so text just fits
- TRect rcText = m_rcParent;
- rcText.iBr.iX -= CX_RIGHT_BORDER;
- rcText.iTl.iX = rcText.iBr.iX - cxText;
- if(rcText.iTl.iX < m_rcParent.iTl.iX )
- {
- rcText.iTl.iX = m_rcParent.iTl.iX;
- }
- m_spPlaylistText->SetRect(rcText);
- m_spPlaylistText->SetText(buf);
- }
- }
- }
- ////////////////////////////////////////
- //IHXSymPlayerStateObserver
- void CHXAvPlaylistNaviControl::OnAdvancePlaylist()
- {
- UpdatePlaylistTextL();
- m_spRefreshCmd->Execute();
- }
- ////////////////////////////////////////
- //
- void
- CHXAvPlaylistNaviControl::Draw(const TRect& /* rect */) const
- {
- // don't draw background; navi pane container draws background for us
- }
- //////////////////////////////
- //
- // CCoeControl
- //
- TInt CHXAvPlaylistNaviControl::CountComponentControls() const
- {
- return 1;
- }
- //////////////////////////////
- //
- // CCoeControl
- //
- CCoeControl* CHXAvPlaylistNaviControl::ComponentControl(TInt aIndex) const
- {
- HX_ASSERT(aIndex == 0);
- return m_spPlaylistText.Ptr();
- }