⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aknexmenusubcontainer.cpp

📁 symbian ui的 例子 初学者可以 好好看看,这个是培训的资料,应该比较宝贵
💻 CPP
字号:
/* Copyright (c) 2005, Nokia. All rights reserved */


// INCLUDE FILES
#include <barsread.h>
#include <akndef.h>
#include <aknutils.h>
#include <AknExMenu.rsg>

#include "AknExMenuSubContainer.h"
#include "AknExMenusubview.h"


// ========================= MEMBER FUNCTIONS ==================================

// -----------------------------------------------------------------------------
// CAknExMenuSubContainer::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CAknExMenuSubContainer::ConstructL( const TRect& aRect, 
                                         CAknExMenuSubView* aParent )
    {

    CreateWindowL();
    
    // Interprets resource data read from a resource file.
    TResourceReader reader;
    iUpperText = new( ELeave ) CEikEdwin;
    iUpperText->SetContainerWindowL( *this );

    // Load RSS resource into TResourceReader Object.
    iCoeEnv->CreateResourceReaderLC( reader, R_AKNEXMENU_TEXT_VIEW );
    iUpperText->ConstructFromResourceL( reader );
    
    // Pop and Destroy TResourceReader from CleanupStack.
    CleanupStack::PopAndDestroy();

    iUpperText->SetTextL( &( aParent->iUpperMsg ) );
    iLowerText = new( ELeave ) CEikEdwin;
    iLowerText->SetContainerWindowL( *this );

    // Load RSS resource into TResourceReader Object.
    iCoeEnv->CreateResourceReaderLC( reader, R_AKNEXMENU_TEXT_VIEW );
    iLowerText->ConstructFromResourceL( reader );
   
    // Pop and Destroy TResourceReader from CleanupStack.
    CleanupStack::PopAndDestroy();

    iLowerText->SetTextL( &( aParent->iLowerMsg ) );
    SetRect( aRect );
    ActivateL();
    }

// -----------------------------------------------------------------------------
// CAknExMenuSubContainer::~CHelloWorldPlusAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CAknExMenuSubContainer::~CAknExMenuSubContainer()
    {
    delete iUpperText;
    delete iLowerText;
    }

// -----------------------------------------------------------------------------
// CAknExMenuSubContainer::SizeChanged()
// Called by framework when the view size is changed
// -----------------------------------------------------------------------------
//
void CAknExMenuSubContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    TRect rect = Rect();
    TSize size;
    size.iWidth = rect.iBr.iX - rect.iTl.iX;
    size.iHeight = ( rect.iBr.iY - rect.iTl.iY ) / 2;
    iUpperText->SetExtent( rect.iTl, size );
    size.iHeight-=1;
    iLowerText->SetExtent( TPoint( rect.iTl.iX, ( rect.iBr.iY/2 )+1 ), size );
    }

// -----------------------------------------------------------------------------
// CAknExMenuSubContainer::CountComponentControls() const
// return nbr of controls inside this container.
// -----------------------------------------------------------------------------
//
TInt CAknExMenuSubContainer::CountComponentControls() const
    {
    return KNumberOfComponentSubView;
    }

// -----------------------------------------------------------------------------
// CAknExMenuSubContainer::ComponentControl() const
// return pointer of controls inside this container
// -----------------------------------------------------------------------------
//
CCoeControl* CAknExMenuSubContainer::ComponentControl( TInt aIndex ) const
    {
    switch ( aIndex )
        {
        case EUpperTextSubView:
            return iUpperText;
        case ELowerTextSubView:
            return iLowerText;
        default:
            return NULL;
        }
    }

// -----------------------------------------------------------------------------
// CAknExMenuSubContainer::HandleControlEventL()
// Handles an event of type aEventType reported
// by the control aControl to this observer.
// -----------------------------------------------------------------------------
//
void CAknExMenuSubContainer::HandleControlEventL( CCoeControl* /*aControl*/,
                                                  TCoeEvent /*aEventType*/ )
    {
    // TODO: Add your control event handler code here
    }

// -----------------------------------------------------------------------------
// CAknExMenuContainer::Draw() const
// Draws the display
// -----------------------------------------------------------------------------
//
void CAknExMenuSubContainer::Draw( const TRect& aRect ) const
    {

    TRgb MyRgb;
    MyRgb = KAknExSubMenuWhite;

    CWindowGc& gc = SystemGc();
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( MyRgb );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

// ---------------------------------------------------------
// CAknExMenuSubContainer::HandleResourceChange()
// Called by framework when layout is changed.
// ---------------------------------------------------------
//
void CAknExMenuSubContainer::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 + -