systemsettings/gssensorplugin/src/gssensorbaseview.cpp
author William Roberts <williamr@symbian.org>
Fri, 23 Apr 2010 14:37:17 +0100
branchRCL_3
changeset 22 c82a39b81a38
parent 0 2e3d3ce01487
permissions -rw-r--r--
Rework addition of Symbian splash screen to reduce the source impact (uses SVG from Bug 2414) Notes: by using the OPTION SOURCEDIR parameter in the mifconv extension instructions, I can arrange to use the same source file name in sfimage, without having to export over the original Nokia file. This means that the name inside splashscreen.mbg is the same, which removes the need for the conditional compilation in SplashScreen.cpp, and gets rid of sf_splashscreen.mmp.

/*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Base view in GS Sensor Plugin.
*
*/


// INCLUDE FILES
#include "gssensorbaseview.h"
#include "gssensorplugin_debug.h"
#include "gssensormskobserver.h"
#include "gssensorplugin.hrh"

#include <aknViewAppUi.h>
#include <gsbasecontainer.h>
#include <StringLoader.h>
#include <eikbtgpc.h>

// CONSTANTS
_LIT( KGSDoActivateError, "DoActivateL" );

// ========================= MEMBER FUNCTIONS ================================

// ---------------------------------------------------------------------------
// CGSSensorBaseView::CGSSensorBaseView
// C++ constructor
// ---------------------------------------------------------------------------
//
CGSSensorBaseView::CGSSensorBaseView()
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::CGSSensorBaseView()" );
    iAppUi = iAvkonViewAppUi;
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::CGSSensorBaseView() - return" );
    }


// ---------------------------------------------------------------------------
// CGSSensorBaseView::~CGSSensorBaseView
// Destructor
// ---------------------------------------------------------------------------
//
CGSSensorBaseView::~CGSSensorBaseView()
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::~CGSSensorBaseView()" );
    if ( iContainer && iAppUi )
        {
        iAppUi->RemoveFromViewStack( *this, iContainer );
        delete iContainer;
        }
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::~CGSSensorBaseView() - return" );
    }

// ---------------------------------------------------------------------------
// CGSSensorBaseView::SetCurrentItem
// ---------------------------------------------------------------------------
//
void CGSSensorBaseView::SetCurrentItem( TInt aIndex )
    {
    TRACE_1( "[GSSensorPlugin] CGSSensorBaseView::SetCurrentItem() - %i", aIndex );
    iCurrentItem = aIndex;
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::SetCurrentItem() - return" );
    }

// ---------------------------------------------------------------------------
// CGSSensorBaseView::HandleListBoxEventL
// ---------------------------------------------------------------------------
//
void CGSSensorBaseView::HandleListBoxEventL( 
    CEikListBox* /*aListBox*/, 
    TListBoxEvent aEventType )
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::HandleListBoxEventL()" );
    switch ( aEventType )
        {
        case EEventEnterKeyPressed:
        case EEventItemSingleClicked:
            HandleListBoxSelectionL();
            break;
        default:
           break;
        }
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::HandleListBoxEventL() - return" );
    }

// ---------------------------------------------------------------------------
// CGSSensorBaseView::HandleClientRectChange
// ---------------------------------------------------------------------------
//
void CGSSensorBaseView::HandleClientRectChange()
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::HandleClientRectChange()" );
    if ( iContainer && iContainer->iListBox )
        {
        iContainer->SetRect( ClientRect() );
        }
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::HandleClientRectChange() - return" );
    }

// ---------------------------------------------------------------------------
// CGSSensorBaseView::DoActivateL
// Activates the view.
// ---------------------------------------------------------------------------
//
void CGSSensorBaseView::DoActivateL( 
    const TVwsViewId& /*aPrevViewId*/,
    TUid /*aCustomMessageId*/, 
    const TDesC8& /*aCustomMessage*/ )
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::DoActivateL()" );
    if ( iContainer )
        {
        iAppUi->RemoveFromViewStack( *this, iContainer );
        delete iContainer;
        iContainer = NULL;
        }

    CreateContainerL();

    iAppUi->AddToViewStackL( *this, iContainer );
    iContainer->iListBox->SetListBoxObserver( this );
    // Update MSK label
    CheckMiddleSoftkeyLabelL();

    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::DoActivateL() - return" );
    }

// ---------------------------------------------------------------------------
// CGSSensorBaseView::DoDeactivate()
// ---------------------------------------------------------------------------
//
void CGSSensorBaseView::DoDeactivate()
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::DoDeactivate()" );
    if ( iContainer )
        {
        iAppUi->RemoveFromViewStack( *this, iContainer );
        delete iContainer;
        iContainer = NULL;
        }
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::DoDeactivate() - return" );
    }

// ---------------------------------------------------------------------------
// CGSSensorBaseView::CreateContainerL()
// ---------------------------------------------------------------------------
//
void CGSSensorBaseView::CreateContainerL()
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::CreateContainerL()" );
    NewContainerL();
    __ASSERT_ALWAYS( iContainer, User::Panic( KGSDoActivateError, EGSViewPanicNullPtr ) );
    iContainer->SetMopParent( this );

    TRAPD( error, iContainer->ConstructL( ClientRect() ) );

    if ( error )
        {
        TRACE_1( "[GSSensorPlugin] CGSSensorBaseView::CreateContainerL() - Error: %i", error );
        delete iContainer;
        iContainer = NULL;
        User::Leave( error );
        }
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::CreateContainerL() - return" );
    }

// -----------------------------------------------------------------------------
// CGSSensorBaseView::RemoveCommandFromMSK
// This method should do nothing but MSK issues.
// -----------------------------------------------------------------------------
//
void CGSSensorBaseView::RemoveCommandFromMSK()
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::RemoveCommandFromMSK()" );
    CEikButtonGroupContainer* cbaGroup = Cba();
    if ( cbaGroup )
        {
        // Remove command from stack
        cbaGroup->RemoveCommandFromStack( KGSSenPluginMSKControlID, EGSSenMskGeneral );
        }
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::RemoveCommandFromMSK() - return" );
    }

// -----------------------------------------------------------------------------
// CGSSensorBaseView::SetMiddleSoftKeyLabelL
// Sets middle softkey label.
// -----------------------------------------------------------------------------
//
void CGSSensorBaseView::SetMiddleSoftKeyLabelL( 
    const TInt aResourceId, const TInt aCommandId )
    {
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::SetMiddleSoftKeyLabelL()" );
    CEikButtonGroupContainer* cbaGroup = Cba();
    if ( cbaGroup )
        {
        HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
        TPtr mskPtr = middleSKText->Des();
        cbaGroup->AddCommandToStackL( 
            KGSSenPluginMSKControlID, 
            aCommandId, 
            mskPtr );
        CleanupStack::Pop( middleSKText );
        delete middleSKText;
        }
    TRACE_( "[GSSensorPlugin] CGSSensorBaseView::SetMiddleSoftKeyLabelL() - return" );
    }