idlehomescreen/widgetmanager/src/wmdetailsdlg.cpp
branchRCL_3
changeset 19 79311d856354
parent 18 d05a55b217df
equal deleted inserted replaced
18:d05a55b217df 19:79311d856354
    28 #include <aknlayoutscalable_avkon.cdl.h>
    28 #include <aknlayoutscalable_avkon.cdl.h>
    29 #include <aknlayoutscalable_apps.cdl.h>
    29 #include <aknlayoutscalable_apps.cdl.h>
    30 #include <AknsBasicBackgroundControlContext.h>
    30 #include <AknsBasicBackgroundControlContext.h>
    31 #include <AknMarqueeControl.h>
    31 #include <AknMarqueeControl.h>
    32 #include <widgetmanagerview.rsg>
    32 #include <widgetmanagerview.rsg>
       
    33 
    33 #include "widgetmanager.hrh"
    34 #include "widgetmanager.hrh"
    34 #include "wmdetailsdlg.h"
    35 #include "wmdetailsdlg.h"
       
    36 #include "wmimageconverter.h"
    35 
    37 
    36 
    38 
    37 // CONSTANTS
    39 // CONSTANTS
    38 
    40 
    39 
    41 
    45 //
    47 //
    46 CWmDetailsDlg* CWmDetailsDlg::NewL(
    48 CWmDetailsDlg* CWmDetailsDlg::NewL(
    47 			const TDesC& aName,
    49 			const TDesC& aName,
    48 	        const TDesC& aDescription,
    50 	        const TDesC& aDescription,
    49 	        TBool  aCanBeAdded,
    51 	        TBool  aCanBeAdded,
    50             const CFbsBitmap* aLogoBmp,
    52             const TDesC& aIconStr,
    51             const CFbsBitmap* aLogoMask )
    53             const CFbsBitmap& aDefaultIcon,
       
    54             const CFbsBitmap& aDefaultIconMask )
    52     {
    55     {
    53     CWmDetailsDlg* self = new ( ELeave ) CWmDetailsDlg( aCanBeAdded );
    56     CWmDetailsDlg* self = new ( ELeave ) CWmDetailsDlg( aCanBeAdded );
    54     CleanupStack::PushL( self );
    57     CleanupStack::PushL( self );
    55     self->ConstructL( aName, aDescription, aLogoBmp, aLogoMask );
    58     self->ConstructL( 
       
    59             aName, 
       
    60             aDescription, 
       
    61             aIconStr, 
       
    62             aDefaultIcon, 
       
    63             aDefaultIconMask );
    56     CleanupStack::Pop( self );
    64     CleanupStack::Pop( self );
    57     return self;
    65     return self;
    58     }
    66     }
    59 
    67 
    60 // ---------------------------------------------------------
    68 // ---------------------------------------------------------
    61 // CWmDetailsDlg::CWmDetailsDlg
    69 // CWmDetailsDlg::CWmDetailsDlg
    62 // ---------------------------------------------------------
    70 // ---------------------------------------------------------
    63 //
    71 //
    64 CWmDetailsDlg::CWmDetailsDlg( TBool  aCanBeAdded )
    72 CWmDetailsDlg::CWmDetailsDlg( TBool aCanBeAdded )
    65     : CAknDialog(),
    73     : CAknDialog(),
    66     iCanBeAdded( aCanBeAdded ),
    74     iCanBeAdded( aCanBeAdded ),
    67     iNeedToScroll( EFalse )
    75     iNeedToScroll( EFalse )
    68     {
    76     {
    69     iBorder = TGulBorder::ERaisedControl;    
    77     iBorder = TGulBorder::ERaisedControl;    
    83     delete iName;
    91     delete iName;
    84     delete iDescription;
    92     delete iDescription;
    85     delete iLogoBmp;
    93     delete iLogoBmp;
    86     delete iLogoMask;
    94     delete iLogoMask;
    87     delete iBgContext;
    95     delete iBgContext;
       
    96     delete iImageConverter;
    88     }
    97     }
    89 
    98 
    90 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
    91 // CWmDetailsDlg::ExecuteLD
   100 // CWmDetailsDlg::ExecuteLD
    92 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
   108 // ---------------------------------------------------------
   117 // ---------------------------------------------------------
   109 //
   118 //
   110 void CWmDetailsDlg::ConstructL(
   119 void CWmDetailsDlg::ConstructL(
   111 			const TDesC& aName,
   120 			const TDesC& aName,
   112 	        const TDesC& aDescription,
   121 	        const TDesC& aDescription,
   113             const CFbsBitmap* aLogoBmp,
   122 	        const TDesC& aIconStr,
   114             const CFbsBitmap* aLogoMask )
   123 	        const CFbsBitmap& aDefaultIcon,
   115     {
   124 	        const CFbsBitmap& aDefaultIconMask )
   116     if ( !aLogoBmp )
   125     {
   117         {
       
   118         User::Leave( KErrArgument );
       
   119         }
       
   120  
   126  
   121 	CAknDialog::ConstructL( R_AVKON_DIALOG_EMPTY_MENUBAR );
   127 	CAknDialog::ConstructL( R_AVKON_DIALOG_EMPTY_MENUBAR );
   122     
   128     
   123 	iBgContext = CAknsBasicBackgroundControlContext::NewL( 
   129 	iBgContext = CAknsBasicBackgroundControlContext::NewL( 
   124 	        KAknsIIDQsnFrPopupCenter, TRect(0,0,1,1), EFalse);
   130 	        KAknsIIDQsnFrPopupCenter, TRect(0,0,1,1), EFalse);
   125 
   131 
   126 	iName = aName.AllocL();
   132 	iName = aName.AllocL();
   127 	iDescription = aDescription.AllocL();
   133 	iDescription = aDescription.AllocL();
   128 
       
   129 	// create bitmap and duplicate handle
       
   130 	iLogoBmp = new ( ELeave ) CFbsBitmap;
       
   131     TSize newSize = TSize( aLogoBmp->SizeInPixels().iWidth ,
       
   132                            aLogoBmp->SizeInPixels().iHeight );
       
   133     User::LeaveIfError( iLogoBmp->Create( newSize, aLogoBmp->DisplayMode() ) );    
       
   134     User::LeaveIfError( iLogoBmp->Duplicate( aLogoBmp->Handle() ) );
       
   135 	
   134 	
   136     if ( aLogoMask )
   135 	iImageConverter = CWmImageConverter::NewL();
   137         {
   136 	
   138         iLogoMask = new ( ELeave ) CFbsBitmap;
   137     // Main window
   139         newSize = TSize( aLogoMask->SizeInPixels().iWidth ,
   138     TRect mainPane;
   140                          aLogoMask->SizeInPixels().iHeight );
   139     AknLayoutUtils::LayoutMetricsRect(
   141         User::LeaveIfError( iLogoMask->Create( newSize, aLogoMask->DisplayMode() ) );    
   140             AknLayoutUtils::EApplicationWindow, mainPane );
   142         User::LeaveIfError( iLogoMask->Duplicate( aLogoMask->Handle() ) );
   141     
       
   142     // Dialog
       
   143     TAknLayoutRect dlgWindowRect;
       
   144     TAknWindowLineLayout dlgWindow = AknLayoutScalable_Apps
       
   145                ::popup_wgtman_window().LayoutLine();
       
   146     dlgWindowRect.LayoutRect( mainPane, dlgWindow );
       
   147     
       
   148     // Heading
       
   149     TAknLayoutRect layoutRect;
       
   150     TAknWindowLineLayout headingPane = AknLayoutScalable_Apps
       
   151                ::wgtman_heading_pane().LayoutLine();        
       
   152     layoutRect.LayoutRect( dlgWindowRect.Rect(), headingPane );
       
   153     
       
   154     // Icon
       
   155     TAknLayoutRect iconRect;
       
   156     TAknWindowLineLayout icongrapichs = AknLayoutScalable_Apps
       
   157             ::wgtman_heading_pane_g1().LayoutLine();
       
   158     iconRect.LayoutRect( layoutRect.Rect(), icongrapichs );
       
   159     
       
   160     iImageConverter->HandleIconString( 
       
   161             iconRect.Rect().Size(), 
       
   162             aIconStr, 
       
   163             iLogoBmp, 
       
   164             iLogoMask );
       
   165     
       
   166     // if icon creation fails use defaults
       
   167     if ( !iLogoBmp || !iLogoMask )
       
   168         {
       
   169 		delete iLogoBmp; iLogoBmp = NULL;
       
   170 		delete iLogoMask; iLogoMask = NULL;
       
   171 
       
   172 		iLogoBmp = new ( ELeave ) CFbsBitmap;        
       
   173 		iLogoMask = new ( ELeave ) CFbsBitmap;  
       
   174 
       
   175 		TSize size = iconRect.Rect().Size();
       
   176 		User::LeaveIfError(
       
   177                 iLogoBmp->Create( size, aDefaultIcon.DisplayMode() ) );
       
   178         User::LeaveIfError( 
       
   179                 iLogoMask->Create( size, aDefaultIconMask.DisplayMode() ) );
       
   180         
       
   181         iLogoBmp->Duplicate( aDefaultIcon.Handle() );
       
   182         iLogoMask->Duplicate( aDefaultIconMask.Handle() );
       
   183         
       
   184         // Resize default icons only when they are really needed
       
   185         AknIconUtils::SetSize( 
       
   186                 iLogoBmp, size, EAspectRatioPreserved );
       
   187         AknIconUtils::SetSize( 
       
   188                 iLogoMask, size, EAspectRatioPreserved );
   143         }
   189         }
   144     
   190     
   145     iEikonEnv->AddWindowShadow( static_cast<CCoeControl*>(this) );
   191     iEikonEnv->AddWindowShadow( static_cast<CCoeControl*>(this) );
   146     }
   192     }
   147 
   193 
   310         TAknWindowLineLayout rtePane = AknLayoutScalable_Apps
   356         TAknWindowLineLayout rtePane = AknLayoutScalable_Apps
   311                    ::wgtman_list_pane().LayoutLine();
   357                    ::wgtman_list_pane().LayoutLine();
   312         layoutRect.LayoutRect( rect, contentPane );
   358         layoutRect.LayoutRect( rect, contentPane );
   313         AknLayoutUtils::LayoutControl( iRtEditor, layoutRect.Rect(), rtePane );
   359         AknLayoutUtils::LayoutControl( iRtEditor, layoutRect.Rect(), rtePane );
   314         CEikScrollBarFrame* sbFrame = iRtEditor->ScrollBarFrame();
   360         CEikScrollBarFrame* sbFrame = iRtEditor->ScrollBarFrame();
   315         if ( sbFrame && sbFrame->VScrollBarVisibility() != CEikScrollBarFrame::EOff )
   361         if ( sbFrame && 
       
   362             sbFrame->ScrollBarVisibility( 
       
   363                     CEikScrollBar::EVertical ) != CEikScrollBarFrame::EOff &&
       
   364             sbFrame->VerticalScrollBar()->IsVisible() )
   316             {
   365             {
   317             CEikScrollBar* scrollBar = sbFrame->VerticalScrollBar();
   366             CEikScrollBar* scrollBar = sbFrame->VerticalScrollBar();
   318             TAknWindowLineLayout scrollPane = AknLayoutScalable_Apps
   367             TAknWindowLineLayout scrollPane = AknLayoutScalable_Apps
   319                            ::scroll_pane_cp036().LayoutLine();
   368                            ::scroll_pane_cp036().LayoutLine();
   320             AknLayoutUtils::LayoutControl( scrollBar, layoutRect.Rect(), scrollPane );
   369             AknLayoutUtils::LayoutControl( scrollBar, layoutRect.Rect(), scrollPane );
   413     TAknLayoutRect layoutRect;
   462     TAknLayoutRect layoutRect;
   414     TAknWindowLineLayout headingPane = AknLayoutScalable_Apps
   463     TAknWindowLineLayout headingPane = AknLayoutScalable_Apps
   415                ::wgtman_heading_pane().LayoutLine();        
   464                ::wgtman_heading_pane().LayoutLine();        
   416     layoutRect.LayoutRect( rect, headingPane );
   465     layoutRect.LayoutRect( rect, headingPane );
   417 
   466 
       
   467     TAknLayoutRect logoLayout;
       
   468         logoLayout.LayoutRect( layoutRect.Rect(),AknLayoutScalable_Apps
       
   469                 ::wgtman_heading_pane_g1().LayoutLine() );
       
   470         
   418     if( iLogoBmp && iLogoMask )
   471     if( iLogoBmp && iLogoMask )
   419         {
   472         {
   420         TAknLayoutRect logoLayout;
   473         gc.DrawBitmapMasked( logoLayout.Rect(), 
   421         logoLayout.LayoutRect( layoutRect.Rect(),AknLayoutScalable_Apps
   474                 iLogoBmp, 
   422                 ::wgtman_heading_pane_g1().LayoutLine() );        
   475                 TRect(TPoint(0, 0), iLogoBmp->SizeInPixels()), 
   423         logoLayout.DrawImage( gc, iLogoBmp, iLogoMask );
   476                 iLogoMask, 
       
   477                 EFalse );
   424         }
   478         }
   425     
   479     
   426     AknsUtils::GetCachedColor( 
   480     AknsUtils::GetCachedColor( 
   427                     skin, color, 
   481                     skin, color, 
   428                     KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
   482                     KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
   521 // ---------------------------------------------------------
   575 // ---------------------------------------------------------
   522 //
   576 //
   523 void CWmDetailsDlg::FocusChanged( TDrawNow aDrawNow )
   577 void CWmDetailsDlg::FocusChanged( TDrawNow aDrawNow )
   524     {
   578     {
   525     CCoeControl::FocusChanged( aDrawNow );
   579     CCoeControl::FocusChanged( aDrawNow );
   526     if ( IsFocused() )
   580     ( IsFocused() ? StartMarquee() : StopMarquee() );
   527         {
       
   528         StartMarquee();
       
   529         }
       
   530     else
       
   531         {
       
   532         StopMarquee();
       
   533         }
       
   534     }
   581     }
   535 
   582 
   536 
   583 
   537 // End of File
   584 // End of File
   538 
   585