Nokia N97 SDK
Example Applications Guide

HWRMTestAppContainer.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : HWRMTestAppContainer.h
00004 *  Part of     : HWRMTestApp
00005 *  Interface   : 
00006 *  Description : HWRM Test application container implementation
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2002-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation. 
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include <eikedwin.h>
00018 #include <aknutils.h>
00019 #include <HWRMTestApp.rsg>
00020 #include "HWRMTestAppContainer.h"
00021 
00022 
00023 // ============================ MEMBER FUNCTIONS ===============================
00024 
00025 // -----------------------------------------------------------------------------
00026 // CHWRMTestAppContainer::ConstructL
00027 // Symbian 2nd phase constructor can leave.
00028 // -----------------------------------------------------------------------------
00029 //
00030 void CHWRMTestAppContainer::ConstructL(const TRect& aRect)
00031     {
00032     CreateWindowL();
00033 
00034     // Set up a read-only editor window for displaying messages
00035     iEdwin = new ( ELeave ) CEikEdwin();
00036     iEdwin->SetContainerWindowL( *this );
00037     
00038     TInt edwinFlags = CEikEdwin::ENoAutoSelection;
00039     edwinFlags |= CEikEdwin::EJustAutoCurEnd;
00040     edwinFlags |= CEikEdwin::EReadOnly;
00041     edwinFlags |= CEikEdwin::EInclusiveSizeFixed;
00042     iEdwin->ConstructL( edwinFlags );
00043     iEdwin->CreateScrollBarFrameL();
00044         iEdwin->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
00045 
00046     SetRect(aRect);
00047     ActivateL();
00048     }
00049 
00050 // -----------------------------------------------------------------------------
00051 // CHWRMTestAppContainer::~CHWRMTestAppContainer
00052 // Destructor
00053 // -----------------------------------------------------------------------------
00054 //
00055 CHWRMTestAppContainer::~CHWRMTestAppContainer()
00056     {
00057     delete iEdwin;
00058     }
00059 
00060 // -----------------------------------------------------------------------------
00061 // CHWRMTestAppContainer::SizeChanged
00062 // Called by framework when the view size is changed
00063 // -----------------------------------------------------------------------------
00064 //
00065 void CHWRMTestAppContainer::SizeChanged()
00066     {
00067     iEdwin->SetRect( Rect() );
00068     }
00069 
00070 // -----------------------------------------------------------------------------
00071 // CHWRMTestAppContainer::CountComponentControls
00072 // Return number of controls in container
00073 // -----------------------------------------------------------------------------
00074 //
00075 TInt CHWRMTestAppContainer::CountComponentControls() const
00076     {
00077     return 1; // return nbr of controls inside this container
00078     }
00079 
00080 // -----------------------------------------------------------------------------
00081 // CHWRMTestAppContainer::ComponentControl
00082 // Return component control
00083 // -----------------------------------------------------------------------------
00084 //
00085 CCoeControl* CHWRMTestAppContainer::ComponentControl(TInt aIndex) const
00086     {
00087     switch ( aIndex )
00088         {
00089         case 0:
00090             return iEdwin;
00091 
00092         default:
00093             return NULL;
00094         }
00095     }
00096 
00097 // -----------------------------------------------------------------------------
00098 // CHWRMTestAppContainer::Draw
00099 // -----------------------------------------------------------------------------
00100 //
00101 void CHWRMTestAppContainer::Draw(const TRect& /*aRect*/) const
00102     {
00103     }
00104 
00105 // -----------------------------------------------------------------------------
00106 // CHWRMTestAppContainer::HandleControlEventL
00107 // -----------------------------------------------------------------------------
00108 //
00109 void CHWRMTestAppContainer::HandleControlEventL(
00110     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
00111     {
00112     // TODO: Add your control event handler code here
00113     }
00114 
00115 // -----------------------------------------------------------------------------
00116 // CHWRMTestAppContainer::AddMessageL
00117 // Add message to editor window in the container
00118 // -----------------------------------------------------------------------------
00119 //
00120 void CHWRMTestAppContainer::AddMessageL( const TDesC& aMsg ) const
00121     {
00122     
00123     CPlainText* text = iEdwin->Text();
00124     text->InsertL( text->DocumentLength(), aMsg );
00125     text->InsertL( text->DocumentLength(), CEditableText::ELineBreak );
00126     iEdwin->HandleTextChangedL();
00127     iEdwin->SetSelectionL( text->DocumentLength(), text->DocumentLength() );
00128     iEdwin->SetFocus( ETrue );
00129     }
00130 
00131     
00132 // -----------------------------------------------------------------------------
00133 // CHWRMTestAppContainer::OfferKeyEventL
00134 // Pass key event to appropriate controls
00135 // -----------------------------------------------------------------------------
00136 //
00137 TKeyResponse CHWRMTestAppContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType )
00138     {
00139     return iEdwin->OfferKeyEventL( aKeyEvent, aType );
00140     }
00141 
00142 // ---------------------------------------------------------
00143 // CHWRMTestAppContainer::HandleResourceChange()
00144 // Called by framework when layout is changed.
00145 // ---------------------------------------------------------
00146 //
00147 void CHWRMTestAppContainer::HandleResourceChange(TInt aType)
00148     {
00149     CCoeControl::HandleResourceChange(aType);
00150 
00151     // ADDED FOR SCALABLE UI SUPPORT
00152     // *****************************
00153     if ( aType==KEikDynamicLayoutVariantSwitch )
00154         {
00155         TRect rect;
00156         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00157         SetRect(rect);
00158         }
00159     
00160     // Redraw the editor window
00161     iEdwin->DrawNow();
00162     }
00163 
00164 // End of File  
00165 

© Nokia 2009

Back to top