📄 aknexformcontainer.cpp
字号:
/* Copyright (c) 2005, Nokia. All rights reserved */
// INCLUDE FILES
#include <aknutils.h> // for AKN_LAF_COLOR
#include <eikenv.h>
#include <eiklabel.h> // for label
#include <aknform.h> // for form control
#include <eikseced.h> // for secret editor
#include <eikedwin.h> // for edwins
#include <akndef.h>
#include <aknexform.rsg>
#include "AknExForm.hrh"
#include "AknExFormView.h"
#include "AknExFormContainer.h"
#include "AknExFormSaveForm.h"
// ================= MEMBER FUNCTIONS =========================================
// ----------------------------------------------------------------------------
// CAknExFormContainer::CAknExFormContainer()
// Overload constructor.
// ----------------------------------------------------------------------------
//
CAknExFormContainer::CAknExFormContainer( CAknExFormView* aView )
: iView( aView ), iLabel( NULL )
{
}
// ----------------------------------------------------------------------------
// void CAknExFormContainer::ConstructL()
// Symbian constructor.
// ----------------------------------------------------------------------------
//
void CAknExFormContainer::ConstructL( const TRect& aRect )
{
// Creates window.
CreateWindowL();
// Creates label object.
CreateLabelL();
SetRect( aRect ); // Sets rectangle of frame.
ActivateL(); // Activates the window. ( Ready to draw )
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::~CAknExFormContainer()
// Destructor.
// ----------------------------------------------------------------------------
//
CAknExFormContainer::~CAknExFormContainer()
{
delete iLabel;
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::SetTextToLabelL()
//
// ----------------------------------------------------------------------------
//
void CAknExFormContainer::SetTextToLabelL( TInt aResourceId )
{
TBuf<KAknExFormMessageBufLength> messageString( NULL );
iCoeEnv->ReadResource( messageString, aResourceId );
iLabel->SetTextL( messageString );
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::DisplayFormL()
//
// ----------------------------------------------------------------------------
//
void CAknExFormContainer::DisplayFormL( TInt aResourceId )
{
CAknExFormSaveForm* form = CAknExFormSaveForm::NewL();
if ( aResourceId == R_AKNEXFORM_DOUBLE_AND_SINGLE_LINE_FORM )
{
form->PrepareLC( aResourceId );
TBuf<KAknExFormMessageBufLength> edwinString( NULL );
iCoeEnv->ReadResource( edwinString, R_AKNEXFORM_TEXT_EDWIN_TEXT );
CEikEdwin* myEdwin = static_cast<CEikEdwin*>
( form->ControlOrNull( EAknExFormDlgCtrlIdEdwin01 ) );
if ( myEdwin )
{
myEdwin->SetTextL( &edwinString );
}
myEdwin = static_cast<CEikEdwin*>
( form->ControlOrNull( EAknExFormDlgCtrlIdEdwin11 ) ) ;
if ( myEdwin )
{
myEdwin->SetTextL( &edwinString );
}
form->RunLD();
}
else
{
form->ExecuteLD( aResourceId );
}
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::CreateLabelL()
// Creates label object.
// ----------------------------------------------------------------------------
//
void CAknExFormContainer::CreateLabelL()
{
if ( !iLabel )
{
iLabel = new( ELeave ) CEikLabel;
iLabel->SetContainerWindowL( *this );
iLabel->SetAlignment( EHCenterVCenter );
#ifdef __AVKON_APAC__
iLabel->SetFont( ApacPlain16());
#else
iLabel->SetFont( LatinBold19());
#endif
}
SetTextToLabelL( R_AKNEXFORM_TEXT_LABEL_TITLE );
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::OfferKeyEventL()
// Handles the key events.
// ----------------------------------------------------------------------------
//
TKeyResponse CAknExFormContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType )
{
if ( aType != EEventKey ) // Is not key event?
{
return EKeyWasNotConsumed;
}
switch ( aKeyEvent.iCode ) // The code of key event is...
{
case EKeySpace: // Space key.
{
// Requires to display next outline screen.
iView->DisplayNextOutlineL();
DrawNow();
break;
}
default:
return EKeyWasNotConsumed;
}
return EKeyWasConsumed;
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::SizeChanged()
// Called by framework when the view size is changed
// ----------------------------------------------------------------------------
//
void CAknExFormContainer::SizeChanged()
{
iLabel->SetRect( Rect() );
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::CountComponentControls()
// Returns number of component.
// ----------------------------------------------------------------------------
//
TInt CAknExFormContainer::CountComponentControls() const
{
// returns nbr of controls inside this container
return KAknExFormCountComponent;
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::ComponentControl()
// Returns pointer to particular component.
// ----------------------------------------------------------------------------
//
CCoeControl* CAknExFormContainer::ComponentControl( TInt aIndex ) const
{
switch ( aIndex ) // Component is...
{
case EAknExFormComponentLabel: // Label object.
return iLabel;
default: // Exception : returns NULL value.
return NULL;
}
}
// ----------------------------------------------------------------------------
// CAknExFormContainer::Draw()
// Clears the window's rectangle.
// ----------------------------------------------------------------------------
//
void CAknExFormContainer::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( AKNEXFORM_BACKGROUND_COLOR );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}
// ---------------------------------------------------------
// CAknExFormContainer::HandleResourceChange()
// Called by framework when layout is changed.
// ---------------------------------------------------------
//
void CAknExFormContainer::HandleResourceChange(TInt aType)
{
CCoeControl::HandleResourceChange(aType);
// ADDED FOR SCALABLE UI SUPPORT
// *****************************
if ( aType==KEikDynamicLayoutVariantSwitch )
{
TRect rect;
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
SetRect(rect);
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -