📄 chxavviewbase.cpp
字号:
/************************************************************************
* chxavviewbase.cpp
* -----------------
*
* Synopsis:
* Contains the somewhat empty implementation of the CHXAvViewBase class.
* This is the base class of all views in this app.
*
* Target:
* Symbian OS
*
*
* (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
*
************************************************************************/
// Includes...
#include <aknenv.h>
#include <aknview.h>
#include <aknconsts.h>
#include <akntitle.h>
#include <aknnavide.h>
#include <akncontext.h>
#include <eikspane.h>
#include <coecntrl.h>
#include <aknviewappui.h>
#include <barsread.h>
// Includes from this project...
#include "hxsym_debug.h"
#include "hxsym_leaveutil.h"
#include "chxavviewbase.h"
#include "chxavplayerui.h"
/*
* CHXAvViewBase
* -------------
* Constructor.
*
*/
CHXAvViewBase::CHXAvViewBase(TInt viewIndex, CHXAvPlayerUI *playerUI)
: m_viewIndex(viewIndex)
, m_playerUI(playerUI)
, m_backViewIndex(-1)
, m_bFirstForegroundEventPending(true)
{
DPRINTF(SYMP_INFO, ("CHXAvViewBase::Ctor(): id = %d\n", m_viewIndex));
// status pane: container of other panes
m_statusPane = StatusPane();
// info area: used for tabs, volume control, etc.
m_naviPane
= static_cast<CAknNavigationControlContainer*>(
m_statusPane->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
// app bitmap pane
m_contextPane
= static_cast<CAknContextPane*>(
m_statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext)));
// app title pane
m_titlePane
= static_cast<CAknTitlePane*>(
m_statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
}
/*
* ~CHXAvViewBase
* --------------
* Destructor.
*
*/
CHXAvViewBase::~CHXAvViewBase()
{
DPRINTF(SYMP_INFO, ("CHXAvViewBase::Dtor(): id = %d\n", m_viewIndex));
}
/*
* ConstructL
* ----------
* default do-nothing implementation for override
*
*/
void CHXAvViewBase::ConstructL()
{
}
/*
* UpdateViewStateL
* ----------------
* default do-nothing implementation for override
*
*/
void CHXAvViewBase::UpdateViewStateL()
{
}
/*
* HandleLosePlayFocus
* ------------------
* default do-nothing implementation for override
*
*/
void CHXAvViewBase::HandleLosePlayFocus()
{
}
/*
* CAknView::HandleForegroundEventL
* ------------------
*
* Called after DoActivate() for new view and before DoDeactivate() for old view when
* switching among our own views. Also called when gaining or losing app focus.
*
*/
void CHXAvViewBase::HandleForegroundEventL(TBool bEnterForeground)
{
DPRINTF(SYMP_INFO, ("avPlayerAppViewBase::HandleForegroundEventL() enter_foreground = %d\n", bEnterForeground));
CAknView::HandleForegroundEventL(bEnterForeground);
if( bEnterForeground )
{
UpdateViewStateL();
if( m_bFirstForegroundEventPending )
{
m_bFirstForegroundEventPending = false;
m_playerUI->OnViewForegroundActivateL(m_viewIndex);
}
}
}
///////////////////////////////////
// called when we show or hide status pane
void CHXAvViewBase::HandleStatusPaneSizeChange()
{
if(m_window)
{
m_window->SetRect(ClientRect());
m_window->DrawNow();
}
}
/*
* Id
* --
* Return our id.
*
*/
TUid CHXAvViewBase::Id() const
{
return TUid::Uid(m_viewIndex);
}
/*
* DoActivateL
* -----------
* Called when the view is activating
*
* After this we expect following sequence of events
* 1) get foreground event for the new view
* 2) get loss of foreground event for old view
* 3) DoDeactivate() called for old view
*
*/
void CHXAvViewBase::DoActivateL(const TVwsViewId& prevViewID, TUid customMsgID, const TDesC8& customMsg)
{
m_bFirstForegroundEventPending = true;
// create window and add to stack first
m_window = CreateViewWindowForActivatingViewL();
HX_ASSERT(m_window);
m_window->SetMopParent(this);
// note: view state is updated when foreground event occurs
m_window->ActivateL();
m_window->MakeVisible(ETrue);
AppUi()->AddToStackL(*this, m_window);
FinishViewActivateL();
}
/*
* DoDeactivate
* ------------
* Call subclasses to handle their cleanup on leaving to a new view or exiting.
*
* This is called after DoActivate() for new view
*
*/
void CHXAvViewBase::DoDeactivate()
{
DPRINTF(SYMP_INFO, ("CHXAvViewBase::DoDeactivate(): for view = %d\n", m_viewIndex));
HX_ASSERT(m_window);
if( m_window )
{
AppUi()->RemoveFromStack(m_window);
}
// derived: do view window cleanup (possibly)
FinishViewDeactivateL();
// may or may not be valid from now on (typically derived views free this on each deactivation)
m_window = 0;
}
/*
* FinishViewActivateL
* ------------------
* default do-nothing implementation for override
*
*/
void CHXAvViewBase::FinishViewActivateL()
{
}
/*
* HandleCommandL
* --------------
* Handle the command by passing it the UI.
*
*/
void CHXAvViewBase::HandleCommandL(TInt command)
{
m_playerUI->HandleCommandL(command);
}
////////////////////////////////////////
//
void CHXAvViewBase::ClosePopupMenu()
{
if( m_pMenuPopup )
{
m_pMenuPopup->StopDisplayingMenuBar();
AppUi()->RemoveFromViewStack(*this, m_pMenuPopup.Ptr());
m_pMenuPopup = 0;
}
}
////////////////////////////////////////
//
void CHXAvViewBase::ShowPopupMenuL(TInt idRes)
{
ClosePopupMenu();
m_pMenuPopup = new(ELeave) CEikMenuBar;
TRAPD( err, ShowPopupMenuHelperL(idRes) );
if(err != KErrNone)
{
ClosePopupMenu();
HXSYM_LEAVE(err);
}
}
////////////////////////////////////////
//
void CHXAvViewBase::ShowPopupMenuHelperL(TInt idRes )
{
m_pMenuPopup->ConstructL( this, 0, idRes );
AppUi()->AddToViewStackL( *this, m_pMenuPopup.Ptr(), ECoeStackPriorityMenu, ECoeStackFlagRefusesFocus );
m_pMenuPopup->TryDisplayMenuBarL();
}
///////////////////////////////////
// calling CAknTitlePane::SetTextToDefaultL() results in title
// being set from long caption from caption resource; initially
// overridden app title is shown and that is what we really want
// to restore to
//
void CHXAvViewBase::SetDefaultAppTitleL()
{
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_AVP_OVERRIDEN_APP_NAME);
m_titlePane->SetFromResourceL(reader);
CleanupStack::PopAndDestroy(); // reader
}
////////////////////////////////////////
// normally called when new view is activating
void CHXAvViewBase::RestoreDefaultNaviPaneL()
{
m_naviPane->PushDefaultL();
}
////////////////////////////////////////
// hook to make menu go away
void CHXAvViewBase::ProcessCommandL(TInt cmd)
{
ClosePopupMenu();
CAknView::ProcessCommandL(cmd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -