/*
============================================================================
Name : TestStatusAppUi.cpp
Author : Lion
Copyright : Your copyright notice
Description : CTestStatusAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <TestStatus.rsg>
#include <f32file.h>
#include <s32file.h>
#include <FBS.H>
#include "TestStatus.pan"
#include "TestStatusAppUi.h"
#include "TestStatusAppView.h"
#include "TestStatus.hrh"
#include "example.mbg"
_LIT( KFileName, "C:\\private\\0F07F5DD\\TestStatus.txt" );
_LIT( KText, "Hello World!");
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CTestStatusAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CTestStatusAppUi::ConstructL()
{
// Initialise app UI with standard value.
BaseConstructL();
// Create view object
iAppView = CTestStatusAppView::NewL( ClientRect() );
// Create a file to write the text to
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL( fsSession );
TInt err = fsSession.MkDirAll(KFileName);
if ( KErrNone != err )
{
CleanupStack::PopAndDestroy(1); // fsSession
return;
}
RFile file;
err = file.Replace(fsSession, KFileName, EFileWrite );
CleanupClosePushL( file );
if ( KErrNone != err )
{
CleanupStack::PopAndDestroy(2); // file, fsSession
return;
}
RFileWriteStream outputFileStream( file );
CleanupClosePushL( outputFileStream );
outputFileStream << KText;
CleanupStack::PopAndDestroy(3); // outputFileStream, file, fsSession
}
// -----------------------------------------------------------------------------
// CTestStatusAppUi::CTestStatusAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CTestStatusAppUi::CTestStatusAppUi()
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CTestStatusAppUi::~CTestStatusAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CTestStatusAppUi::~CTestStatusAppUi()
{
if ( iAppView )
{
delete iAppView;
iAppView = NULL;
}
}
// -----------------------------------------------------------------------------
// CTestStatusAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CTestStatusAppUi::HandleCommandL( TInt aCommand )
{
switch( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
case ECommand1:
{
CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
CAknTitlePane* titlePane = static_cast<CAknTitlePane*>(statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
titlePane->SetTextL(_L("New Title"));
}
break;
case ECommand2:
{
CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
CAknContextPane* contextPane = (CAknContextPane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext));
_LIT(KContextBitMapFile, "\\resource\\apps\\example.mbm");
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(KContextBitMapFile, EMbmExamplePic);
CFbsBitmap* bitmapM = iEikonEnv->CreateBitmapL(KContextBitMapFile, EMbmExamplePic_mask);
contextPane->SetPicture(bitmap, bitmapM);
}
break;
default:
Panic( ETestStatusUi );
break;
}
}
// -----------------------------------------------------------------------------
// Called by the framework when the application status pane
// size is changed. Passes the new client rectangle to the
// AppView
// -----------------------------------------------------------------------------
//
void CTestStatusAppUi::HandleStatusPaneSizeChange()
{
iAppView->SetRect( ClientRect() );
}
// End of File