calendarui/views/src/calencontainerlayoutmanager.cpp
branchRCL_3
changeset 66 bd7edf625bdd
child 67 1539a383d7b6
equal deleted inserted replaced
65:12af337248b1 66:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 2007 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:   Manages preview pane, info bar and toolbar for calendar views
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // Include files
       
    21 #include "calendarui_debug.h"                   // Debug macros
       
    22 #include "calencontainerlayoutmanager.h"        // CCalenContainerLayoutManager
       
    23 #include "calenpreview.h"                       // CCalenPreview
       
    24 #include "calennativeview.h"                    // CCalenNativeView
       
    25 #include "CalenUid.h"
       
    26 #include <aknappui.h>                           // CAknAppUi
       
    27 #include <AknUtils.h>                           // AknLayoutUtils
       
    28 #include <akntoolbar.h>                         // CAknToolbar
       
    29 
       
    30 // ----------------------------------------------------------------------------
       
    31 // CCalenContainerLayoutManager::NewL
       
    32 // First stage construction
       
    33 // ----------------------------------------------------------------------------
       
    34 CCalenContainerLayoutManager* CCalenContainerLayoutManager::NewL(
       
    35                     MCalenServices& aServices, CCalenContainer& aContainer )
       
    36     {
       
    37     TRACE_ENTRY_POINT;
       
    38 
       
    39     CCalenContainerLayoutManager* self = new( ELeave )
       
    40                         CCalenContainerLayoutManager( aServices, aContainer );
       
    41 
       
    42     CleanupStack::PushL( self );
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop( self );
       
    45 
       
    46     TRACE_EXIT_POINT;
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // CCalenContainerLayoutManager::ConstructL
       
    52 // Second stage construction
       
    53 // ----------------------------------------------------------------------------
       
    54 void CCalenContainerLayoutManager::ConstructL()
       
    55     {
       
    56     TRACE_ENTRY_POINT;
       
    57 
       
    58     iLayoutFlags.ClearAll();
       
    59     GetLayoutAndExtensionL();
       
    60 
       
    61     TRACE_EXIT_POINT;
       
    62     }
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // CCalenNativeViewExtension::~CCalenNativeViewExtension
       
    66 // Destructor
       
    67 // ----------------------------------------------------------------------------
       
    68 CCalenContainerLayoutManager::~CCalenContainerLayoutManager()
       
    69     {
       
    70     TRACE_ENTRY_POINT;
       
    71     TRACE_EXIT_POINT;
       
    72     }
       
    73 
       
    74 // ----------------------------------------------------------------------------
       
    75 // CCalenContainerLayoutManager::CCalenContainerLayoutManager
       
    76 // Constructor
       
    77 // ----------------------------------------------------------------------------
       
    78 CCalenContainerLayoutManager::CCalenContainerLayoutManager(
       
    79                 MCalenServices& aServices, CCalenContainer& aContainer )
       
    80                     : iContainer( aContainer ), iServices( aServices )
       
    81     {
       
    82     TRACE_ENTRY_POINT;
       
    83     TRACE_EXIT_POINT;
       
    84     }
       
    85 
       
    86 // ----------------------------------------------------------------------------
       
    87 // CCalenContainerLayoutManager::LayoutFlags
       
    88 // Returns the layout type for the container.
       
    89 // ----------------------------------------------------------------------------
       
    90 TBitFlags CCalenContainerLayoutManager::LayoutFlags()
       
    91     {
       
    92     TRACE_ENTRY_POINT;
       
    93 
       
    94     TRACE_EXIT_POINT;
       
    95     return iLayoutFlags;
       
    96     }
       
    97 
       
    98 // ----------------------------------------------------------------------------
       
    99 // CCalenContainerLayoutManager::ControlOrNull
       
   100 // Returns a pointer to the available secondary control, or NULL if none is
       
   101 // available. The secondary control may be either an info bar or a preview pane
       
   102 // ----------------------------------------------------------------------------
       
   103 CCoeControl* CCalenContainerLayoutManager::ControlOrNull()
       
   104     {
       
   105     TRACE_ENTRY_POINT;
       
   106     CCoeControl* control( NULL );
       
   107 
       
   108     if ( iLayoutFlags.IsSet( ECalenContainerInfobar ) )
       
   109         {
       
   110         control = iInfobar;
       
   111         }
       
   112 
       
   113     TRACE_EXIT_POINT;
       
   114     return control;
       
   115     }
       
   116 
       
   117 // ----------------------------------------------------------------------------
       
   118 // CCalenContainerLayoutManager::ToolbarOrNull
       
   119 // Returns a pointer to the available toolbar, or NULL if none is
       
   120 // available. The toolbar is owned by the appui.
       
   121 // ----------------------------------------------------------------------------
       
   122 CAknToolbar* CCalenContainerLayoutManager::ToolbarOrNull()
       
   123     {
       
   124     TRACE_ENTRY_POINT;
       
   125 
       
   126     TRACE_EXIT_POINT;
       
   127     return iToolbar;
       
   128     }
       
   129 
       
   130 // ----------------------------------------------------------------------------
       
   131 // CCalenContainerLayoutManager::GetLayoutAndExtensionL
       
   132 // Determins which layout should be used and initialises the extension if one
       
   133 // is available
       
   134 // ----------------------------------------------------------------------------
       
   135 void CCalenContainerLayoutManager::GetLayoutAndExtensionL()
       
   136     {
       
   137     TRACE_ENTRY_POINT;
       
   138 
       
   139     iLayoutFlags.ClearAll();
       
   140 
       
   141     // See if a toolbar is available
       
   142     CheckToolbarL();
       
   143 
       
   144     // See if preview pane is available
       
   145     CheckPreviewL();
       
   146 
       
   147     CheckInfobarL();
       
   148     
       
   149     TRACE_EXIT_POINT;
       
   150     }
       
   151 
       
   152 // ----------------------------------------------------------------------------
       
   153 // CCalenContainerLayoutManager::CheckPreviewL
       
   154 // Checks to see if a preview pane is available in the current resolution
       
   155 // and orientation
       
   156 // ----------------------------------------------------------------------------
       
   157 void CCalenContainerLayoutManager::CheckPreviewL()
       
   158     {
       
   159     TRACE_ENTRY_POINT;
       
   160 
       
   161     TRect previewRect = iContainer.PreviewRectL();
       
   162     if (!iContainer.PreviewRectL().IsEmpty() && iContainer.PreviewPane())
       
   163         {
       
   164         iLayoutFlags.Set( ECalenContainerPreview );        
       
   165         }
       
   166     
       
   167     
       
   168 
       
   169     TRACE_EXIT_POINT;
       
   170     }
       
   171 
       
   172 // ----------------------------------------------------------------------------
       
   173 // CCalenContainerLayoutManager::CheckInfobarL
       
   174 // Checks to see if an info bar is available from a customisation plugin
       
   175 // This will not be checked if a preview pane is available
       
   176 // ----------------------------------------------------------------------------
       
   177 void CCalenContainerLayoutManager::CheckInfobarL()
       
   178     {
       
   179     TRACE_ENTRY_POINT;
       
   180 
       
   181     TRect infobarRect = iContainer.InfoBarRectL(
       
   182                                 iLayoutFlags.IsSet( ECalenContainerToolbar ) );
       
   183 
       
   184      if ( !infobarRect.IsEmpty()  )
       
   185         {
       
   186          //Ask the services for an info bar if it exists.
       
   187          
       
   188          CCoeControl* infoBarControl  = iServices.Infobar( infobarRect  );
       
   189          if(!infoBarControl )
       
   190             {
       
   191              iServices.IssueNotificationL(ECalenNotifyCheckPluginUnloading);
       
   192              iInfobar = NULL;
       
   193             }
       
   194          else 
       
   195             {
       
   196             iInfobar = infoBarControl;
       
   197             // If the infobar exists, set the container window and activate.
       
   198             iLayoutFlags.Set( ECalenContainerInfobar );           
       
   199             iInfobar->SetContainerWindowL( iContainer );
       
   200             }
       
   201        }
       
   202      // For ToDo View, issue ECalenNotifyCheckPluginUnloading explicitly as it will not enter above 'if' loop
       
   203      // This change is made only for language variants that have plugins
       
   204      else if(iContainer.View()->Id() == KUidCalenTodoView)
       
   205          {
       
   206          TLanguage language = User::Language();
       
   207          CCoeControl* infoBarCtrl  = iServices.Infobar( infobarRect  );
       
   208          switch(language)
       
   209              {
       
   210              case ELangThai:
       
   211              case ELangTaiwanChinese:
       
   212              case ELangHongKongChinese:
       
   213              case ELangPrcChinese:
       
   214              case ELangVietnamese:
       
   215                  if(!infoBarCtrl)
       
   216 	                 {
       
   217 	                 iServices.IssueNotificationL(ECalenNotifyCheckPluginUnloading);
       
   218 	               	 }
       
   219                  break;
       
   220              default:
       
   221                 break;
       
   222              }
       
   223          }
       
   224 
       
   225     TRACE_EXIT_POINT;
       
   226     }
       
   227 
       
   228 // ----------------------------------------------------------------------------
       
   229 // CCalenContainerLayoutManager::CheckToolbarL
       
   230 // Checks to see if a toolbar should be used in the current layout
       
   231 // and resolution.  The toolbar should always be available if touch support
       
   232 // is enabled.
       
   233 // ----------------------------------------------------------------------------
       
   234 void CCalenContainerLayoutManager::CheckToolbarL()
       
   235     {
       
   236     TRACE_ENTRY_POINT;
       
   237 
       
   238     if ( AknLayoutUtils::PenEnabled() )
       
   239         {
       
   240         CAknAppUi* appUi = (CAknAppUi*)CEikonEnv::Static()->EikAppUi();
       
   241         iToolbar = appUi->CurrentPopupToolbar();
       
   242         if( iToolbar )
       
   243             {
       
   244             iLayoutFlags.Set( ECalenContainerToolbar );
       
   245             }
       
   246         }
       
   247      else
       
   248      	{
       
   249      	iLayoutFlags.Clear( ECalenContainerInfobar );	
       
   250      	}
       
   251 
       
   252     TRACE_EXIT_POINT;
       
   253     }
       
   254     
       
   255 // ----------------------------------------------------------------------------
       
   256 // CCalenContainerLayoutManager::HandleResourceChange
       
   257 // Dump any extensions and recheck
       
   258 // ----------------------------------------------------------------------------    
       
   259 void CCalenContainerLayoutManager::HandleResourceChange( TInt /*aType*/ )
       
   260     { 
       
   261     TRACE_ENTRY_POINT;
       
   262     
       
   263     PIM_TRAPD_HANDLE( GetLayoutAndExtensionL() );
       
   264     
       
   265     TRACE_EXIT_POINT;
       
   266     }
       
   267 
       
   268     
       
   269 // ----------------------------------------------------------------------------
       
   270 // CCalenContainerLayoutManager::SetToolbarVisibility
       
   271 // Set the toolbar to be visible or hidden.  If no toolbar is available does 
       
   272 // nothing.
       
   273 // ----------------------------------------------------------------------------
       
   274 void CCalenContainerLayoutManager::SetToolbarVisibility( TBool aVisible )
       
   275     {
       
   276     TRACE_ENTRY_POINT;
       
   277     
       
   278     if ( iToolbar )
       
   279         {
       
   280         iToolbar->SetToolbarVisibility( aVisible, aVisible);
       
   281         }
       
   282     
       
   283     TRACE_EXIT_POINT;    
       
   284     }    
       
   285 // End of file
       
   286