📄 exerciselistboxview.cpp
字号:
/*
========================================================================
Name : ExerciseListBoxView.cpp
Author :
Copyright : Your copyright notice
Description :
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <aknviewappui.h>
#include <eikmenub.h>
#include <avkon.hrh>
#include <barsread.h>
#include <stringloader.h>
#include <aknlists.h>
#include <eikenv.h>
#include <akniconarray.h>
#include <eikclbd.h>
#include <akncontext.h>
#include <akntitle.h>
#include <eikbtgpc.h>
#include <Exercise.rsg>
// ]]] end generated region [Generated System Includes]
// [[[ begin generated region: do not modify [Generated User Includes]
#include "Exercise.hrh"
#include "ExerciseListBoxView.h"
#include "ExerciseListBox.h"
#include "ExerciseListBox.hrh"
#include <aknquerydialog.h>
// ]]] end generated region [Generated User Includes]
// [[[ begin generated region: do not modify [Generated Constants]
// ]]] end generated region [Generated Constants]
/**
* First phase of Symbian two-phase construction. Should not contain any
* code that could leave.
*/
CExerciseListBoxView::CExerciseListBoxView()
{
// [[[ begin generated region: do not modify [Generated Contents]
iExerciseListBox = NULL;
// ]]] end generated region [Generated Contents]
}
/**
* The view's destructor removes the container from the control
* stack and destroys it.
*/
CExerciseListBoxView::~CExerciseListBoxView()
{
// [[[ begin generated region: do not modify [Generated Contents]
delete iExerciseListBox;
iExerciseListBox = NULL;
// ]]] end generated region [Generated Contents]
}
/**
* Symbian two-phase constructor.
* This creates an instance then calls the second-phase constructor
* without leaving the instance on the cleanup stack.
* @return new instance of CExerciseListBoxView
*/
CExerciseListBoxView* CExerciseListBoxView::NewL()
{
CExerciseListBoxView* self = CExerciseListBoxView::NewLC();
CleanupStack::Pop( self );
return self;
}
/**
* Symbian two-phase constructor.
* This creates an instance, pushes it on the cleanup stack,
* then calls the second-phase constructor.
* @return new instance of CExerciseListBoxView
*/
CExerciseListBoxView* CExerciseListBoxView::NewLC()
{
CExerciseListBoxView* self = new ( ELeave ) CExerciseListBoxView();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
/**
* Second-phase constructor for view.
* Initialize contents from resource.
*/
void CExerciseListBoxView::ConstructL()
{
// [[[ begin generated region: do not modify [Generated Code]
BaseConstructL( R_EXERCISE_LIST_BOX_EXERCISE_LIST_BOX_VIEW );
// ]]] end generated region [Generated Code]
// add your own initialization code here
}
/**
* @return The UID for this view
*/
TUid CExerciseListBoxView::Id() const
{
return TUid::Uid( EExerciseListBoxViewId );
}
/**
* Handle a command for this view (override)
* @param aCommand command id to be handled
*/
void CExerciseListBoxView::HandleCommandL( TInt aCommand )
{
// [[[ begin generated region: do not modify [Generated Code]
TBool commandHandled = EFalse;
switch ( aCommand )
{ // code to dispatch to the AknView's menu and CBA commands is generated here
case EExerciseListBoxViewNext_viewMenuItemCommand://change view's command
AppUi()->HandleCommandL( EAknSoftkeyDone );
commandHandled =ETrue;
break;
case EExerciseListBoxViewAdd_listMenuItemCommand://add item' command
{
TBuf<100> Name;
RunDataQuery1L(Name,ETrue,NULL);
commandHandled=HandleAddMenuItemSelectedL(Name);
}
break;
case EExerciseListBoxViewDelete_listMenuItemCommand: //delete item's command
commandHandled=HandleDeleteMenuItemSelectedL();
break;
case EAknSoftkeyDone:
AppUi()->HandleCommandL( EAknSoftkeyDone );
commandHandled =ETrue;
break;
default:
break;
}
if ( !commandHandled )
{
if ( aCommand == EAknSoftkeyExit )
{
AppUi()->HandleCommandL( EEikCmdExit );
}
}
// ]]] end generated region [Generated Code]
}
/**
* Handles user actions during activation of the view,
* such as initializing the content.
*/
void CExerciseListBoxView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/ )
{
// [[[ begin generated region: do not modify [Generated Contents]
SetupStatusPaneL();
if ( iExerciseListBox == NULL )
{
iExerciseListBox = CreateContainerL();
iExerciseListBox->SetMopParent( this );
AppUi()->AddToStackL( *this, iExerciseListBox );
}
// ]]] end generated region [Generated Contents]
}
/**
*/
void CExerciseListBoxView::DoDeactivate()
{
// [[[ begin generated region: do not modify [Generated Contents]
CleanupStatusPane();
if ( iExerciseListBox != NULL )
{
AppUi()->RemoveFromViewStack( *this, iExerciseListBox );
delete iExerciseListBox;
iExerciseListBox = NULL;
}
// ]]] end generated region [Generated Contents]
}
/**
* Handle status pane size change for this view (override)
*/
void CExerciseListBoxView::HandleStatusPaneSizeChange()
{
CAknView::HandleStatusPaneSizeChange();
// this may fail, but we're not able to propagate exceptions here
TInt result;
TRAP( result, SetupStatusPaneL() );
// [[[ begin generated region: do not modify [Generated Code]
// ]]] end generated region [Generated Code]
}
// [[[ begin generated function: do not modify
void CExerciseListBoxView::SetupStatusPaneL()
{
// reset the context pane
TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
CEikStatusPaneBase::TPaneCapabilities subPaneContext =
StatusPane()->PaneCapabilities( contextPaneUid );
if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
{
CAknContextPane* context = static_cast< CAknContextPane* > (
StatusPane()->ControlL( contextPaneUid ) );
context->SetPictureToDefaultL();
}
// setup the title pane
TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
CEikStatusPaneBase::TPaneCapabilities subPaneTitle =
StatusPane()->PaneCapabilities( titlePaneUid );
if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
{
CAknTitlePane* title = static_cast< CAknTitlePane* >(
StatusPane()->ControlL( titlePaneUid ) );
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC( reader, R_EXERCISE_LIST_BOX_TITLE_RESOURCE );
title->SetFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
}
// ]]] end generated function
// [[[ begin generated function: do not modify
void CExerciseListBoxView::CleanupStatusPane()
{
}
// ]]] end generated function
/**
* Creates the top-level container for the view. You may modify this method's
* contents and the CExerciseListBox::NewL() signature as needed to initialize the
* container, but the signature for this method is fixed.
* @return new initialized instance of CExerciseListBox
*/
CExerciseListBox* CExerciseListBoxView::CreateContainerL()
{
return CExerciseListBox::NewL( ClientRect(), NULL, this );
}
TInt CExerciseListBoxView::RunDataQuery1L(
TDes& aData,
TBool aUseDefaults,
const TDesC* aOverridePrompt )
{
if ( aUseDefaults )
{
HBufC* text = StringLoader::LoadLC( R_LI1_CONTAINER_EDIT1 );//load from resourcefile
aData.Copy( *text );//get the data
CleanupStack::PopAndDestroy( text );
}
CAknTextQueryDialog* queryDialog = CAknTextQueryDialog::NewL( aData );
if ( aOverridePrompt != NULL )
{
CleanupStack::PushL( queryDialog );
queryDialog->SetPromptL( *aOverridePrompt );
CleanupStack::Pop();
}
return queryDialog->ExecuteLD( R_LI1_CONTAINER_DATA_QUERY1 );//run it
}
TBool CExerciseListBoxView::HandleAddMenuItemSelectedL(TBuf<100>& aName)
{
iExerciseListBox->RunAddListItemL(aName);//add item
return ETrue;
}
TBool CExerciseListBoxView::HandleDeleteMenuItemSelectedL()
{
iExerciseListBox->RunDeleteItemL();//delete item
return ETrue;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -