⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fepindicator.cpp

📁 Fep Example in Symbian
💻 CPP
字号:

#include <eikenv.h>         //CEikEnv
#include <eikspane.h>       //CEikStatusPane
#include <avkon.hrh>
#include <aknnavi.h>        //CAknNavigationControlContainer
#include <aknnavide.h>      //CAknNavigationDecorator
#include <aknindicatorcontainer.h>  //CAknIndicatorContainer
#include <aknutils.h>
#include "FepIndicator.h"

_LIT(KNaviPaneTextAbc, "abc");
_LIT(KNaviPaneText123, "123");

/**
 *
 */ 
CFepIndicator* CFepIndicator::NewL()
    {
    CFepIndicator* self = new(ELeave)CFepIndicator();
    return self;
    }


/**
 *
 */
CFepIndicator::CFepIndicator()
    :iPreviousState(EStateNone), 
	iEikEnv(*CEikonEnv::Static())
    {
    }

/**
 *
 */
CFepIndicator::~CFepIndicator()
    {
    RemoveContainer();
    }


/**
 *
 */
void CFepIndicator::SetState(TIndicatorState aState)
    {
    CAknNavigationControlContainer* naviPane = 0;
    TRAPD(err, naviPane = NaviPaneL());

    // If the navi pane has been changed, clean up and start again.
    if (iNaviPane != naviPane)
        {
        RemoveContainer();
        iNaviPane = naviPane;
        iNaviPaneChanged = ETrue;
        }
    
    if ( (iPreviousState == aState) && !iNaviPaneChanged )
        {
        // The required state already exists and navi pane has not been changed 
        // by launching embedded application. Leave the contents alone.
        return;
        }
        
    if (aState == EStateNone) 
        {
        if ( iNaviDecorator && naviPane )
            {
            naviPane->Pop(iNaviDecorator);
            }
        iPreviousState = aState;
        iNaviPaneChanged = EFalse;
        return;
        }
    
    if ( err == KErrNone )
        {
        iNaviPaneChanged = EFalse;
        TRAP(err,AddContainerL(naviPane));
        // Don't propagate the error since the only side-effect is that
        // the edit indicators won't show up

		if (aState == EStateAlphabat)
			{
			if (iNaviDecorator)
				{
				delete iNaviDecorator;
				iNaviDecorator = NULL;
				}

			iNaviDecorator = iNaviPane->CreateMessageLabelL(KNaviPaneTextAbc);
	        // Push the state to the navi-pane
		    if (naviPane)
				{
				TRAPD(ignore, naviPane->PushL(*iNaviDecorator));
				}        
			}
		else if (aState == EStateNumeric)
			{
			if (iNaviDecorator)
				{
				delete iNaviDecorator;
				iNaviDecorator = NULL;
				}

			iNaviDecorator = iNaviPane->CreateMessageLabelL(KNaviPaneText123);
	        // Push the state to the navi-pane
		    if (naviPane)
				{
				TRAPD(ignore, naviPane->PushL(*iNaviDecorator));
				}        
			}
        }
    iPreviousState = aState;    
    }


/**
 *  Create a new indicator container and push it to the navi-pane
 */
void CFepIndicator::AddContainerL(CAknNavigationControlContainer* aNaviPane)
    {
    // Create a new indicator container and push it to the navi-pane
    if (!iIndicatorContainer && aNaviPane)
        {
        iNaviDecorator = aNaviPane->CreateEditorIndicatorContainerL();
        iIndicatorContainer = STATIC_CAST(CAknIndicatorContainer*, iNaviDecorator->DecoratedControl());
        }
    }

/**
 * Pop the indicator container from the navi-pane
 */
void CFepIndicator::RemoveContainer()
    {
    // Pop the indicator container from the navi-pane
    if (iIndicatorContainer)
        {
        delete iNaviDecorator;
        iNaviDecorator = NULL;
        iIndicatorContainer = NULL;
        }
    }

/**
 *  get a handle to the Navi Pane
 */
CAknNavigationControlContainer* CFepIndicator::NaviPaneL()
    {
    CEikStatusPane *sp = iEikEnv.AppUiFactory()->StatusPane();
    User::LeaveIfNull(sp);
    // Fetch pointer to the default navi pane control
    return (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
    }

// End of file

⌨️ 快捷键说明

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