messagingappbase/msgeditor/mediacontrolsrc/MsgFrameControl.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005 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 *       MsgEditor Frame control.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "MsgFrameControl.h"
       
    23 
       
    24 #include <coeutils.h>               // for ConeUtils::FileExists
       
    25 #include <MsgEditorCommon.h>
       
    26 
       
    27 #include <AknUtils.h>
       
    28 #include <AknsUtils.h>
       
    29 #include <AknsDrawUtils.h>
       
    30 #include <aknlayoutscalable_apps.cdl.h>
       
    31 #include <aknlayoutscalable_avkon.cdl.h>
       
    32 
       
    33 // ==========================================================
       
    34 
       
    35 // EXTERNAL DATA STRUCTURES
       
    36 
       
    37 // EXTERNAL FUNCTION PROTOTYPES
       
    38 
       
    39 // CONSTANTS
       
    40 
       
    41 // MACROS
       
    42 
       
    43 // LOCAL CONSTANTS AND MACROS
       
    44 
       
    45 // MODULE DATA STRUCTURES
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 
       
    49 // ================= MEMBER FUNCTIONS =======================
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // CMsgFrameControl::CMsgFrameControl
       
    53 //
       
    54 // Constructor
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CMsgFrameControl::CMsgFrameControl()
       
    58     {
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CMsgFrameControl::NewL
       
    64 //
       
    65 // Constructor
       
    66 // ---------------------------------------------------------
       
    67 //
       
    68 CMsgFrameControl* CMsgFrameControl::NewL( const CCoeControl& aParent )
       
    69     {
       
    70     CMsgFrameControl* self = new( ELeave ) CMsgFrameControl;
       
    71     
       
    72     CleanupStack::PushL( self );
       
    73     self->ConstructL( aParent );
       
    74     CleanupStack::Pop( self );
       
    75     
       
    76     return self;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CMsgFrameControl::ConstructL
       
    81 //
       
    82 // Constructor
       
    83 // ---------------------------------------------------------
       
    84 //
       
    85 void CMsgFrameControl::ConstructL( const CCoeControl& aParent )
       
    86     {
       
    87     SetContainerWindowL( aParent );
       
    88         
       
    89     SetFrameSize();
       
    90     
       
    91     MakeVisible( EFalse );
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CMsgFrameControl::~CMsgFrameControl
       
    96 //
       
    97 // Destructor
       
    98 // ---------------------------------------------------------
       
    99 //
       
   100 CMsgFrameControl::~CMsgFrameControl()
       
   101     {
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CMsgFrameControl::SetImageSize
       
   106 //
       
   107 // ---------------------------------------------------------
       
   108 //
       
   109 void CMsgFrameControl::SetImageSize( const TSize& aSize )
       
   110     {
       
   111     iFrameSize = aSize + iFrameBorderSize;
       
   112     iImageSizeSet = ETrue;
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------
       
   116 // CMsgFrameControl::FrameSize
       
   117 //
       
   118 // ---------------------------------------------------------
       
   119 //
       
   120 TSize CMsgFrameControl::FrameSize() const
       
   121     {
       
   122     return iFrameSize;
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------
       
   126 // CMsgFrameControl::Draw
       
   127 //
       
   128 // ---------------------------------------------------------
       
   129 //
       
   130 void CMsgFrameControl::Draw( const TRect& aRect ) const
       
   131     {
       
   132     if ( !iImageSizeSet )
       
   133         {
       
   134         return;
       
   135         }
       
   136 
       
   137     CWindowGc& gc = SystemGc();
       
   138     gc.SetClippingRect( aRect );
       
   139 
       
   140     // Center the actual "frameRect" inside the "Rect()"
       
   141     TRect frameRect( Rect().iTl, iFrameSize );
       
   142     frameRect.Move( ( Rect().Width() - iFrameSize.iWidth ) / 2,
       
   143                     ( Rect().Height() - iFrameSize.iHeight ) / 2 );
       
   144 
       
   145     TAknLayoutRect tl;
       
   146     tl.LayoutRect( frameRect, AknLayoutScalable_Avkon::input_focus_pane_g2().LayoutLine() );
       
   147     
       
   148     TAknLayoutRect br;
       
   149     br.LayoutRect( frameRect, AknLayoutScalable_Avkon::input_focus_pane_g5().LayoutLine() );
       
   150     
       
   151     TRect innerRect = TRect( frameRect.iTl.iX + tl.Rect().Width(),
       
   152                              frameRect.iTl.iY + tl.Rect().Height(),
       
   153                              frameRect.iBr.iX - br.Rect().Width(),
       
   154                              frameRect.iBr.iY - br.Rect().Height() );
       
   155 
       
   156     TBool drawn = AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(),
       
   157                                             gc,
       
   158                                             frameRect,
       
   159                                             innerRect, 
       
   160                                             KAknsIIDQsnFrInput, 
       
   161                                             KAknsIIDNone );        
       
   162     if ( !drawn )
       
   163         {
       
   164         gc.SetPenColor( KRgbGray );
       
   165         TRect rect = frameRect;
       
   166         rect.iTl.iX += 1;
       
   167         rect.iTl.iY += 1;
       
   168         gc.DrawRect( rect );
       
   169         gc.SetPenColor( KRgbBlack );
       
   170         rect.iTl.iX -= 1;
       
   171         rect.iTl.iY -= 1;
       
   172         rect.iBr.iX -= 1;
       
   173         rect.iBr.iY -= 1;
       
   174         gc.DrawRect( rect );
       
   175         }
       
   176     }
       
   177 
       
   178 // ---------------------------------------------------------
       
   179 // CMsgFrameControl::HandleResourceChange
       
   180 // ---------------------------------------------------------
       
   181 //
       
   182 void CMsgFrameControl::HandleResourceChange( TInt aType )
       
   183     {
       
   184     CCoeControl::HandleResourceChange( aType ); 
       
   185     
       
   186     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   187         {
       
   188         SetFrameSize();
       
   189         }
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------
       
   193 // CMsgFrameControl::SetFrameSize
       
   194 // ---------------------------------------------------------
       
   195 //
       
   196 void CMsgFrameControl::SetFrameSize()
       
   197     {
       
   198     TRect dataPane = MsgEditorCommons::MsgDataPane();
       
   199     TAknLayoutRect iconLayout;
       
   200     iconLayout.LayoutRect( dataPane,
       
   201                            AknLayoutScalable_Apps::msg_data_pane_g4().LayoutLine() );
       
   202                            
       
   203     TAknLayoutRect frameLayout;
       
   204     frameLayout.LayoutRect( dataPane,
       
   205                             AknLayoutScalable_Apps::qrid_highlight_pane_cp011( 0 ).LayoutLine() );
       
   206     iFrameBorderSize = TPoint( iconLayout.Rect().iTl - frameLayout.Rect().iTl ).AsSize();
       
   207     // "Multiply" by two:
       
   208     iFrameBorderSize += iFrameBorderSize;
       
   209     }
       
   210 
       
   211 //  End of File