📄 secondcontainer2.cpp
字号:
/*
========================================================================
Name : SecondContainer2.cpp
Author : HSG
Copyright : Your copyright notice
Description :
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <aknviewappui.h>
#include <eikappui.h>
#include <Second.rsg>
// ]]] end generated region [Generated System Includes]
// [[[ begin generated region: do not modify [Generated User Includes]
#include "SecondContainer2.h"
#include "SecondContainer2View.h"
#include "Second.hrh"
#include "SecondContainer.hrh"
#include "SecondContainer2.hrh"
#include "Second.mbg"
#include "FBS.H"
#include "e32std.h"
#include "AknUtils.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.
*/
CSecondContainer2::CSecondContainer2()
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
/**
* Destroy child controls.
*/
CSecondContainer2::~CSecondContainer2()
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
delete iBitMap;
iBitMap=NULL;
}
/**
* Construct the control (first phase).
* Creates an instance and initializes it.
* Instance is not left on cleanup stack.
* @param aRect bounding rectangle
* @param aParent owning parent, or NULL
* @param aCommandObserver command observer
* @return initialized instance of CSecondContainer2
*/
CSecondContainer2* CSecondContainer2::NewL(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
CSecondContainer2* self = CSecondContainer2::NewLC(
aRect,
aParent,
aCommandObserver );
CleanupStack::Pop( self );
return self;
}
/**
* Construct the control (first phase).
* Creates an instance and initializes it.
* Instance is left on cleanup stack.
* @param aRect The rectangle for this window
* @param aParent owning parent, or NULL
* @param aCommandObserver command observer
* @return new instance of CSecondContainer2
*/
CSecondContainer2* CSecondContainer2::NewLC(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
CSecondContainer2* self = new ( ELeave ) CSecondContainer2();
CleanupStack::PushL( self );
self->ConstructL( aRect, aParent, aCommandObserver );
return self;
}
/**
* Construct the control (second phase).
* Creates a window to contain the controls and activates it.
* @param aRect bounding rectangle
* @param aCommandObserver command observer
* @param aParent owning parent, or NULL
*/
void CSecondContainer2::ConstructL(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
if ( aParent == NULL )
{
CreateWindowL();
}
else
{
SetContainerWindowL( *aParent );
}
Loadbitmap();
iPointLeft=30;//图片的的初始位置
iPointTop=30;
iFocusControl = NULL;
iCommandObserver = aCommandObserver;
InitializeControlsL();
SetRect( aRect );
ActivateL();
// [[[ begin generated region: do not modify [Post-ActivateL initializations]
// ]]] end generated region [Post-ActivateL initializations]
}
/**
* Return the number of controls in the container (override)
* @return count
*/
TInt CSecondContainer2::CountComponentControls() const
{
return ( int ) ELastControl;
}
/**
* Get the control with the given index (override)
* @param aIndex Control index [0...n) (limited by #CountComponentControls)
* @return Pointer to control
*/
CCoeControl* CSecondContainer2::ComponentControl( TInt aIndex ) const
{
// [[[ begin generated region: do not modify [Generated Contents]
switch ( aIndex )
{
}
// ]]] end generated region [Generated Contents]
// handle any user controls here...
return NULL;
}
/**
* Handle resizing of the container. This implementation will lay out
* full-sized controls like list boxes for any screen size, and will layout
* labels, editors, etc. to the size they were given in the UI designer.
* This code will need to be modified to adjust arbitrary controls to
* any screen size.
*/
void CSecondContainer2::SizeChanged()
{
CCoeControl::SizeChanged();
LayoutControls();
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
// [[[ begin generated function: do not modify
/**
* Layout components as specified in the UI Designer
*/
void CSecondContainer2::LayoutControls()
{
}
// ]]] end generated function
/**
* Handle key events.
*/
TKeyResponse CSecondContainer2::OfferKeyEventL(
const TKeyEvent& aKeyEvent,
TEventCode aType )
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
switch(aKeyEvent.iCode)
{case EKeyLeftArrow:
if(iPointLeft>=0)
{
iPointLeft=iPointLeft-3;
DrawDeferred();
}
break;
case EKeyRightArrow:
if(iPointLeft<60)
{
iPointLeft=iPointLeft+3;
DrawDeferred();
}
break;
case EKeyUpArrow:
if(iPointTop>=0)
{
iPointTop=iPointTop-3;
TPoint topLeft(iPointLeft,iPointTop);
DrawDeferred();
}
break;
case EKeyDownArrow:
if(iPointTop<60)
{
iPointTop=iPointTop+3;
TPoint topLeft(iPointLeft,iPointTop);
DrawDeferred();
}
break;
default:
return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
break;
}
if ( iFocusControl != NULL
&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
{
return EKeyWasConsumed;
}
return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
}
// [[[ begin generated function: do not modify
/**
* Initialize each control upon creation.
*/
void CSecondContainer2::InitializeControlsL()
{
}
// ]]] end generated function
/**
* Handle global resource changes, such as scalable UI or skin events (override)
*/
void CSecondContainer2::HandleResourceChange( TInt aType )
{
CCoeControl::HandleResourceChange( aType );
SetRect( iAvkonViewAppUi->View( TUid::Uid( ESecondContainer2ViewId ) )->ClientRect() );
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
/**
* Draw container contents.
*/
void CSecondContainer2::Draw( const TRect& aRect ) const
{
// [[[ begin generated region: do not modify [Generated Contents]
CWindowGc& gc = SystemGc();
gc.Clear( aRect );
TPoint topLeft(iPointLeft,iPointTop);
gc.BitBlt (topLeft,iBitMap);
}
void CSecondContainer2::Loadbitmap()
{
iBitMap=new(ELeave)CFbsBitmap();
_LIT(KMBMFILE,"\\system\\apps\\Second\\Second.mbm");
TFileName file(KMBMFILE);
User::LeaveIfError(CompleteWithAppPath(file));
User::LeaveIfError(iBitMap->Load(file,EMbmSecondkunan));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -