📄 btnviewcontainer.cpp
字号:
// BtnViewContainer.cpp: implementation of the CBtnViewContainer class.
//
//////////////////////////////////////////////////////////////////////
#include "MySymStd.h"
#include "BtnViewContainer.h"
#include <barsread.h>
#include <aknnotewrappers.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBtnViewContainer::CBtnViewContainer()
{
igBtn[0] = NULL ;
igBtn[1] = NULL ;
igBtn[2] = NULL ;
// iLabel1 = NULL ;
}
CBtnViewContainer::~CBtnViewContainer()
{
delete igBtn[0] ;
delete igBtn[1] ;
delete igBtn[2] ;
// delete iLabel1 ;
}
CBtnViewContainer* CBtnViewContainer::NewL( const TRect& aRect, const CCoeControl* aParent )
{
CBtnViewContainer * self =CBtnViewContainer::NewLC(aRect,aParent) ;
CleanupStack::Pop(self) ;
return self ;
}
CBtnViewContainer* CBtnViewContainer::NewLC( const TRect& aRect, const CCoeControl* aParent )
{
CBtnViewContainer * self = new(ELeave)CBtnViewContainer( ) ;
CleanupStack::PushL(self) ;
self->ConstructL(aRect , aParent) ;
return self ;
}
void CBtnViewContainer::ConstructL( const TRect& aRect, const CCoeControl* aParent )
{
if ( !aParent )
{
CreateWindowL( );
}
else
{
SetContainerWindowL( *aParent );
}
InitControlsL( );
SetRect( aRect );
ActivateL( );
}
TInt CBtnViewContainer::CountComponentControls( ) const
{
return (int) ELastControl ;
//return 1 ;
}
CCoeControl* CBtnViewContainer::ComponentControl( TInt aIndex ) const
{
if(aIndex < 0 || aIndex > 2 )
return NULL ;
return igBtn[aIndex] ;
//return iLabel1 ;
}
TKeyResponse CBtnViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType )
{
if (aType != EEventKey)
{
return EKeyWasNotConsumed;
}
if (aKeyEvent.iScanCode == EStdKeyUpArrow)
{
igBtn[inCurrBtn]->SetFocus(EFalse,EDrawNow) ;
inCurrBtn-- ;
if( inCurrBtn < 0 )
inCurrBtn= 2 ;
igBtn[inCurrBtn]->SetFocus( ETrue,EDrawNow ) ;
return EKeyWasConsumed;
}
else if (aKeyEvent.iScanCode == EStdKeyDownArrow)
{
igBtn[inCurrBtn]->SetFocus(EFalse,EDrawNow) ; //原来的失去焦点
inCurrBtn++ ;
inCurrBtn %= 3 ;
igBtn[inCurrBtn]->SetFocus(ETrue,EDrawNow) ; //现在的获取焦点
return EKeyWasConsumed;
}
else if (aKeyEvent.iScanCode == EStdKeyDevice3)
{
TBuf<20> strHint ;
switch (inCurrBtn)
{
case EBtnUp :
{
_LIT(kStrUP,"正在上传!") ;
strHint.Append(kStrUP) ;
break;
}
case EBtnDown :
{
_LIT(kStrDown,"正在下载!") ;
strHint.Append(kStrDown) ;
break;
}
case EBtnView :
{
_LIT(kStrView,"正在查看!") ;
strHint.Append(kStrView) ;
break ;
}
default :
//User::Panic(KShapeDrawerPanicName, EShapeDrawerInvalidBrushType);
return EKeyWasConsumed ;
}
CAknInformationNote * pNote = new(ELeave)CAknInformationNote( ) ;
pNote->ExecuteLD(strHint ) ;
return EKeyWasConsumed;
}
return EKeyWasNotConsumed ;
}
void CBtnViewContainer::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc( );
gc.Clear( aRect );
}
void CBtnViewContainer::SizeChanged( )
{
CCoeControl::SizeChanged( );
LayoutControls( ) ;
}
void CBtnViewContainer::LayoutControls( )
{
igBtn[0]->SetExtent(TPoint(5,5),TSize(50,20) ) ;
igBtn[1]->SetExtent(TPoint(5,30),TSize(50,20) ) ;
igBtn[2]->SetExtent(TPoint(5,55),TSize(50,20) ) ;
//iLabel1->SetExtent( TPoint(5,5),TSize(50,20) );
}
void CBtnViewContainer::InitControlsL( )
{
/*
iLabel1 = new (ELeave) CEikLabel ;
iLabel1->SetContainerWindowL( *this );
{
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC( reader, R_STUSYM_BTNCONT_UPLOAD );
iLabel1->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
*/
TRect cltRect= Rect( ) ;
TRect btnRect ;
TPoint iTl ;
iTl =cltRect.iTl;
btnRect.iTl = TPoint(iTl.iX + 5, iTl.iY + 5) ;
btnRect.SetWidth( 50 ) ;
btnRect.SetHeight(20 ) ;
_LIT(kStrUp,"上传");
igBtn[0] = CBtnCtrl::NewL(btnRect,this,kStrUp);
igBtn[0]->SetFocus(ETrue , EDrawNow ) ;
iTl =cltRect.iTl;
btnRect.iTl = TPoint(iTl.iX + 5, iTl.iY + 30) ;
btnRect.SetWidth( 50 ) ;
btnRect.SetHeight(20 ) ;
_LIT(kStrDown,"下载");
igBtn[1]= CBtnCtrl::NewL(btnRect,this,kStrDown);
iTl =cltRect.iTl;
btnRect.iTl = TPoint(iTl.iX + 5, iTl.iY + 55) ;
btnRect.SetWidth( 50 ) ;
btnRect.SetHeight(20 ) ;
_LIT(kStrView,"查看");
igBtn[2] = CBtnCtrl::NewL(btnRect,this,kStrView);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -