meetingrequest/mrgui/src/cmrresponsedialogview.cpp
branchRCL_3
changeset 64 3533d4323edc
child 80 726fba06891a
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Response dialog's custom control implementation
       
    15 *
       
    16 */
       
    17 #include "cmrresponsedialogview.h"
       
    18 // System includes
       
    19 #include <AknsDrawUtils.h>
       
    20 #include <AknsBasicBackgroundControlContext.h>
       
    21 #include <eikrted.h>
       
    22 #include <AknDef.h>
       
    23 // DEBUG
       
    24 #include "emailtrace.h"
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CESMRResponseDialogView::NewL
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CESMRResponseDialogView* CESMRResponseDialogView::NewL()
       
    31     {
       
    32     FUNC_LOG;
       
    33     CESMRResponseDialogView* self =
       
    34         new (ELeave) CESMRResponseDialogView();
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop( self );
       
    38     return self;
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CESMRResponseDialogView::CESMRResponseDialogView
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CESMRResponseDialogView::CESMRResponseDialogView()
       
    46     {
       
    47     FUNC_LOG;
       
    48     // Do nothing
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CESMRResponseDialogView::ConstructL
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void CESMRResponseDialogView::ConstructL()
       
    56     {
       
    57     FUNC_LOG;
       
    58     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
    59                         KAknsIIDQsnBgAreaMain, Rect() , ETrue );
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CESMRResponseDialogView::~CESMRResponseDialogView
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CESMRResponseDialogView::~CESMRResponseDialogView()
       
    67     {
       
    68     FUNC_LOG;    
       
    69     delete iEditor;
       
    70     delete iBgContext;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CESMRResponseDialogView::OfferKeyEventL
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 TKeyResponse CESMRResponseDialogView::OfferKeyEventL(
       
    78         const TKeyEvent& aEvent,
       
    79         TEventCode aType)
       
    80     {
       
    81     FUNC_LOG;
       
    82     return iEditor->OfferKeyEventL( aEvent, aType );
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CESMRResponseDialogView::Draw
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CESMRResponseDialogView::Draw(const TRect& aRect) const
       
    90     {
       
    91     FUNC_LOG;
       
    92     CWindowGc& gc = SystemGc();
       
    93       
       
    94     // Redraw the background using the default skin
       
    95     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
    96     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
    97     AknsDrawUtils::Background( skin, cc, this, gc, aRect );    
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // CESMRResponseDialogView::MopSupplyObject
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 TTypeUid::Ptr CESMRResponseDialogView::MopSupplyObject(TTypeUid aId)
       
   105     {
       
   106     if (iBgContext )
       
   107         {
       
   108         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   109         }
       
   110     return CCoeControl::MopSupplyObject(aId);
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CESMRResponseDialogView::CountComponentControls
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 TInt CESMRResponseDialogView::CountComponentControls() const
       
   118     {
       
   119     FUNC_LOG;
       
   120     return 1;
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CESMRResponseDialogView::ComponentControl
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 CCoeControl* CESMRResponseDialogView::ComponentControl( TInt /*aInd*/ ) const
       
   128     {
       
   129     FUNC_LOG;
       
   130     return iEditor;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // CESMRResponseDialogView::GetTextL
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 HBufC* CESMRResponseDialogView::GetTextL()
       
   138     {
       
   139     FUNC_LOG;
       
   140     return iEditor->GetTextInHBufL();
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CESMRResponseDialogView::SetContainerWindowL
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 void CESMRResponseDialogView::SetContainerWindowL(
       
   148         const CCoeControl& aContainer)
       
   149     {
       
   150     FUNC_LOG;
       
   151     CCoeControl::SetContainerWindowL( aContainer );
       
   152     iEditor = new (ELeave )CEikRichTextEditor();
       
   153     iEditor->ConstructL( this, 0, 0, CEikEdwin::ENoAutoSelection, 0, 0 );
       
   154     iEditor->SetFocus( ETrue );
       
   155     iEditor->SetContainerWindowL( *this );
       
   156     iEditor->SetSize( Rect().Size() );
       
   157     iEditor->SetSkinBackgroundControlContextL( iBgContext );
       
   158     iEditor->EnableCcpuSupportL(ETrue);
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // CESMRResponseDialogView::HandleResourceChange()
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CESMRResponseDialogView::HandleResourceChange( TInt aType )
       
   166     {
       
   167     FUNC_LOG;
       
   168     CCoeControl::HandleResourceChange( aType );
       
   169 
       
   170     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   171         {
       
   172         iEditor->SetRect( Rect() );
       
   173         }
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // CESMRResponseDialogView::SizeChanged()
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 void CESMRResponseDialogView::SizeChanged()
       
   181     {
       
   182     if(iBgContext)
       
   183         {
       
   184         iBgContext->SetRect(Rect());
       
   185         if ( &Window() )
       
   186             {
       
   187             iBgContext->SetParentPos( PositionRelativeToScreen() );
       
   188             }
       
   189         }
       
   190     if( iEditor )
       
   191         {
       
   192         iEditor->SetRect( Rect() );
       
   193         }
       
   194     }
       
   195 
       
   196 // end of file