messagingappbase/smartmessaging/msgeditorutils/src/MsgDetailWindow.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15 *     Container for CRichbio.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "MsgDetailWindow.h"
       
    24 #include <CRichBio.h>
       
    25 #include "MsgEditorUtils.pan"           // for MsgEditorUtils panics
       
    26 
       
    27 // LOCAL CONSTANTS AND MACROS
       
    28 
       
    29 // Define the richbio size and position according to LAF.
       
    30 const TInt KRichBioTopLeftX = 0;
       
    31 const TInt KRichBioTopLeftY = 8;
       
    32 const TInt KRichBioWidth = 174;
       
    33 const TInt KRichBioHeight = 125;
       
    34 
       
    35 // These define detail/overview position and dimensions.
       
    36 // Detail window must cover the whole display area so that 
       
    37 // nothing "shines" through.
       
    38 const TInt KWindowTopLeftX = 1;
       
    39 const TInt KWindowTopLeftY = 44;
       
    40 const TInt KWindowHeight = 144;
       
    41 const TInt KWindowWidth = 174;
       
    42 
       
    43 // Define the position where window is moved when Hide()-method
       
    44 // is called.
       
    45 const TInt KWindowPosOutOfTheWayX = 1000;
       
    46 const TInt KWindowPosOutOfTheWayY = 1000;
       
    47 
       
    48 EXPORT_C CMsgDetailWindow* CMsgDetailWindow::NewL()
       
    49     {
       
    50     CMsgDetailWindow* self = new ( ELeave ) CMsgDetailWindow();
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop( self );
       
    54     return self;
       
    55     }
       
    56 
       
    57 EXPORT_C CMsgDetailWindow::~CMsgDetailWindow()
       
    58     {
       
    59     delete iRichBio;
       
    60     }
       
    61 
       
    62 EXPORT_C void CMsgDetailWindow::SetControlL(CRichBio* aRichBio)
       
    63     {
       
    64     // Control must not be set twice. Get a reference to the control with
       
    65     // Control()-method instead and update it.
       
    66     __ASSERT_DEBUG(iRichBio==NULL, Panic( EMEUControlAlreadySet ));
       
    67     __ASSERT_DEBUG(aRichBio!=NULL, Panic( EMEUControlNotSet ));
       
    68 
       
    69     aRichBio->SetContainerWindowL(*this);
       
    70     
       
    71     // Set the correct size and position.
       
    72     TSize richBioSize(KRichBioWidth, KRichBioHeight);
       
    73     TPoint richBioPos(KRichBioTopLeftX, KRichBioTopLeftY);
       
    74     aRichBio->SetAndGetSizeL( richBioSize );
       
    75     aRichBio->SetSize( richBioSize );
       
    76     aRichBio->SetPosition( richBioPos );    
       
    77     ActivateL();
       
    78     iRichBio = aRichBio;
       
    79     }
       
    80 
       
    81 EXPORT_C CRichBio& CMsgDetailWindow::Control() const
       
    82     {
       
    83     __ASSERT_DEBUG(iRichBio, Panic( EMEUControlNotSet ));
       
    84     return *iRichBio;
       
    85     }
       
    86 
       
    87 EXPORT_C void CMsgDetailWindow::Show()
       
    88     {
       
    89     TSize size(KWindowWidth, KWindowHeight);
       
    90     TPoint windowPos( KWindowTopLeftX, KWindowTopLeftY );
       
    91     SetSize(size);
       
    92     SetPosition( windowPos );
       
    93     }
       
    94 
       
    95 EXPORT_C void CMsgDetailWindow::Hide()
       
    96     {
       
    97     TPoint outOfTheWay( KWindowPosOutOfTheWayX, KWindowPosOutOfTheWayY );
       
    98     TSize size(KWindowWidth, KWindowHeight);
       
    99     SetSize(size);
       
   100     SetPosition( outOfTheWay );
       
   101     }
       
   102 
       
   103 TInt CMsgDetailWindow::CountComponentControls() const
       
   104     {
       
   105     if ( iRichBio )
       
   106         {
       
   107         return 1;
       
   108         }
       
   109     else
       
   110         {
       
   111         return 0;
       
   112         }
       
   113     }
       
   114 
       
   115 CCoeControl* CMsgDetailWindow::ComponentControl( TInt /*aIndex*/ ) const
       
   116     {
       
   117     return iRichBio;
       
   118     }
       
   119 
       
   120 void CMsgDetailWindow::SizeChanged()
       
   121     {
       
   122     if ( iRichBio )
       
   123         {
       
   124         TSize size(KRichBioWidth, KRichBioHeight);
       
   125         // Trap this here. If this leaves just set the 
       
   126         // defined size.
       
   127         TRAP_IGNORE( iRichBio->SetAndGetSizeL( size ) );
       
   128         iRichBio->SetSize( size );
       
   129         }
       
   130     }
       
   131 
       
   132 TKeyResponse CMsgDetailWindow::OfferKeyEventL( 
       
   133     const TKeyEvent& aKeyEvent, 
       
   134     TEventCode aType ) 
       
   135     {
       
   136     if ( iRichBio )
       
   137         {
       
   138         TKeyResponse response = iRichBio->OfferKeyEventL( aKeyEvent, aType );
       
   139         return response;
       
   140         }
       
   141     else
       
   142         {
       
   143         return EKeyWasNotConsumed;
       
   144         }
       
   145     }
       
   146 
       
   147 void CMsgDetailWindow::FocusChanged(TDrawNow /*aDrawNow*/) 
       
   148     {
       
   149     if ( iRichBio )
       
   150         {
       
   151         TBool isFocused = IsFocused();
       
   152         iRichBio->SetFocus( isFocused );
       
   153         }
       
   154     }
       
   155 
       
   156 CMsgDetailWindow::CMsgDetailWindow()
       
   157     {      
       
   158     }
       
   159 
       
   160 void CMsgDetailWindow::ConstructL()
       
   161     {
       
   162     CreateWindowL();
       
   163     TSize windowSize(KWindowWidth, KWindowHeight);
       
   164     SetSizeWithoutNotification( windowSize );
       
   165     Hide();
       
   166     }
       
   167 
       
   168 void CMsgDetailWindow::Draw(const TRect& /*aRect*/) const
       
   169     {
       
   170     // Clear the window background.
       
   171     CWindowGc& gc = SystemGc();
       
   172     gc.Clear(Rect());
       
   173     }
       
   174 
       
   175 //  End of File