calendarui/views/src/calencontainerlayoutmanager.cpp
changeset 0 f979ecb2b13e
child 12 38571fd2a704
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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     // If no preview pane, check for an info bar
       
   148     if ( !iLayoutFlags.IsSet( ECalenContainerPreview ))
       
   149         {
       
   150         CheckInfobarL();
       
   151         }
       
   152 
       
   153     TRACE_EXIT_POINT;
       
   154     }
       
   155 
       
   156 // ----------------------------------------------------------------------------
       
   157 // CCalenContainerLayoutManager::CheckPreviewL
       
   158 // Checks to see if a preview pane is available in the current resolution
       
   159 // and orientation
       
   160 // ----------------------------------------------------------------------------
       
   161 void CCalenContainerLayoutManager::CheckPreviewL()
       
   162     {
       
   163     TRACE_ENTRY_POINT;
       
   164 
       
   165     TRect previewRect = iContainer.PreviewRectL();
       
   166     if ( !iContainer.PreviewRectL().IsEmpty() )
       
   167         {
       
   168         iLayoutFlags.Set( ECalenContainerPreview );
       
   169         iLayoutFlags.Clear( ECalenContainerInfobar );
       
   170         }
       
   171     
       
   172     
       
   173 
       
   174     TRACE_EXIT_POINT;
       
   175     }
       
   176 
       
   177 // ----------------------------------------------------------------------------
       
   178 // CCalenContainerLayoutManager::CheckInfobarL
       
   179 // Checks to see if an info bar is available from a customisation plugin
       
   180 // This will not be checked if a preview pane is available
       
   181 // ----------------------------------------------------------------------------
       
   182 void CCalenContainerLayoutManager::CheckInfobarL()
       
   183     {
       
   184     TRACE_ENTRY_POINT;
       
   185 
       
   186     TRect infobarRect = iContainer.InfoBarRectL(
       
   187                                 iLayoutFlags.IsSet( ECalenContainerToolbar ) );
       
   188 
       
   189      if ( !infobarRect.IsEmpty()  )
       
   190         {
       
   191          //Ask the services for an info bar if it exists.
       
   192          
       
   193          CCoeControl* infoBarControl  = iServices.Infobar( infobarRect  );
       
   194          if(!infoBarControl )
       
   195             {
       
   196              iServices.IssueNotificationL(ECalenNotifyCheckPluginUnloading);
       
   197              iInfobar = NULL;
       
   198             }
       
   199          else 
       
   200             {
       
   201             iInfobar = infoBarControl;
       
   202             // If the infobar exists, set the container window and activate.
       
   203             iLayoutFlags.Set( ECalenContainerInfobar );
       
   204             iLayoutFlags.Clear( ECalenContainerPreview );
       
   205             iInfobar->SetContainerWindowL( iContainer );
       
   206             }
       
   207        }
       
   208      // For ToDo View, issue ECalenNotifyCheckPluginUnloading explicitly as it will not enter above 'if' loop
       
   209      // This change is made only for language variants that have plugins
       
   210      else if(iContainer.View()->Id() == KUidCalenTodoView)
       
   211          {
       
   212          TLanguage language = User::Language();
       
   213          CCoeControl* infoBarCtrl  = iServices.Infobar( infobarRect  );
       
   214          switch(language)
       
   215              {
       
   216              case ELangThai:
       
   217              case ELangTaiwanChinese:
       
   218              case ELangHongKongChinese:
       
   219              case ELangPrcChinese:
       
   220              case ELangVietnamese:
       
   221                  if(!infoBarCtrl)
       
   222 	                 {
       
   223 	                 iServices.IssueNotificationL(ECalenNotifyCheckPluginUnloading);
       
   224 	               	 }
       
   225                  break;
       
   226              default:
       
   227                 break;
       
   228              }
       
   229          }
       
   230 
       
   231     TRACE_EXIT_POINT;
       
   232     }
       
   233 
       
   234 // ----------------------------------------------------------------------------
       
   235 // CCalenContainerLayoutManager::CheckToolbarL
       
   236 // Checks to see if a toolbar should be used in the current layout
       
   237 // and resolution.  The toolbar should always be available if touch support
       
   238 // is enabled.
       
   239 // ----------------------------------------------------------------------------
       
   240 void CCalenContainerLayoutManager::CheckToolbarL()
       
   241     {
       
   242     TRACE_ENTRY_POINT;
       
   243 
       
   244     if ( AknLayoutUtils::PenEnabled() )
       
   245         {
       
   246         CAknAppUi* appUi = (CAknAppUi*)CEikonEnv::Static()->EikAppUi();
       
   247         iToolbar = appUi->CurrentPopupToolbar();
       
   248         if( iToolbar )
       
   249             {
       
   250             iLayoutFlags.Set( ECalenContainerToolbar );
       
   251             }
       
   252         }
       
   253      else
       
   254      	{
       
   255      	iLayoutFlags.Clear( ECalenContainerInfobar );	
       
   256      	}
       
   257 
       
   258     TRACE_EXIT_POINT;
       
   259     }
       
   260     
       
   261 // ----------------------------------------------------------------------------
       
   262 // CCalenContainerLayoutManager::HandleResourceChange
       
   263 // Dump any extensions and recheck
       
   264 // ----------------------------------------------------------------------------    
       
   265 void CCalenContainerLayoutManager::HandleResourceChange( TInt /*aType*/ )
       
   266     { 
       
   267     TRACE_ENTRY_POINT;
       
   268     
       
   269     PIM_TRAPD_HANDLE( GetLayoutAndExtensionL() );
       
   270     
       
   271     TRACE_EXIT_POINT;
       
   272     }
       
   273 
       
   274     
       
   275 // ----------------------------------------------------------------------------
       
   276 // CCalenContainerLayoutManager::SetToolbarVisibility
       
   277 // Set the toolbar to be visible or hidden.  If no toolbar is available does 
       
   278 // nothing.
       
   279 // ----------------------------------------------------------------------------
       
   280 void CCalenContainerLayoutManager::SetToolbarVisibility( TBool aVisible )
       
   281     {
       
   282     TRACE_ENTRY_POINT;
       
   283     
       
   284     if ( iToolbar )
       
   285         {
       
   286         iToolbar->SetToolbarVisibility( aVisible, aVisible);
       
   287         }
       
   288     
       
   289     TRACE_EXIT_POINT;    
       
   290     }    
       
   291 // End of file
       
   292