calendarui/commonutils/src/calennavilabel.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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:  Navigation label
       
    15 *
       
    16 */
       
    17 
       
    18 //debug
       
    19 #include "calendarui_debug.h"
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <AknUtils.h>
       
    25 #include <AknStatuspaneUtils.h>
       
    26 #include <aknnavide.h>
       
    27 #include <calennavilabel.h>
       
    28 
       
    29 #include <aknlayoutscalable_avkon.cdl.h>
       
    30 // ---------------------------------------------------------
       
    31 // CCalenNaviLabel::SetLabelObserver
       
    32 // (other items were commented in a header).
       
    33 // ---------------------------------------------------------
       
    34 //
       
    35 EXPORT_C void CCalenNaviLabel::SetLabelObserver(MCCalenNaviLabelObserver* aObserver)
       
    36     {
       
    37     TRACE_ENTRY_POINT;
       
    38     
       
    39     iLabelObserver = aObserver;
       
    40     
       
    41     TRACE_EXIT_POINT;
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------
       
    45 // CCalenNaviLabel::HandlePointerEventL
       
    46 // Handles pointer events in navi label
       
    47 // (other items were commented in a header).
       
    48 // ---------------------------------------------------------
       
    49 //
       
    50 EXPORT_C void CCalenNaviLabel::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
    51     {
       
    52     TRACE_ENTRY_POINT;
       
    53 
       
    54     if(AknLayoutUtils::PenEnabled())
       
    55         {
       
    56         switch(aPointerEvent.iType)
       
    57             {
       
    58             case TPointerEvent::EDrag:
       
    59             case TPointerEvent::EButtonRepeat:
       
    60                 if(!Rect().Contains(aPointerEvent.iPosition))
       
    61                     {
       
    62                     IgnoreEventsUntilNextPointerUp();
       
    63                     Window().CancelPointerRepeatEventRequest();
       
    64                     }
       
    65                 break;
       
    66             case TPointerEvent::EButton1Down:
       
    67                 {
       
    68                 Window().CancelPointerRepeatEventRequest();
       
    69                 TRect repeatRect;
       
    70                 TInt event;
       
    71                 TRect labelRect(Rect());
       
    72                 TBool repeat(ETrue);
       
    73                 
       
    74                 TInt indexR = 0;
       
    75                 // Is battery pane visible in current layout
       
    76                 if (AknStatuspaneUtils::IdleLayoutActive())
       
    77                     {
       
    78                     indexR = 1;
       
    79                     }
       
    80                 TAknTextLineLayout layout = 
       
    81                     AknLayout::Navi_pane_texts_Line_1( indexR );
       
    82                 
       
    83                 if (AknStatuspaneUtils::FlatLayoutActive()) 
       
    84                     {
       
    85                     TAknWindowLineLayout screenLayout = AknLayout::screen();
       
    86                     TRect screenRect = screenLayout.Rect(); 
       
    87                     
       
    88                     TAknWindowLineLayout tmpLayout = 
       
    89                         AknLayoutScalable_Avkon::navi_pane(2).LayoutLine();
       
    90                     TAknLayoutRect naviRect;        
       
    91                     naviRect.LayoutRect(screenRect, tmpLayout);        
       
    92                     
       
    93                     if(naviRect.Rect().Width() > Rect().Width())
       
    94                         layout = AknLayoutScalable_Avkon::navi_text_pane_srt_t1().LayoutLine();
       
    95                     }
       
    96                 const CFont* font = AknLayoutUtils::FontFromId(layout.FontId());
       
    97                 TInt txtWidth = font->TextWidthInPixels(*Text());
       
    98                 TInt space = (labelRect.Width() - txtWidth) / 2;
       
    99                 
       
   100                 if(aPointerEvent.iPosition.iX < labelRect.iTl.iX + 5)
       
   101                     {
       
   102                     repeatRect.SetRect(labelRect.iTl.iX - 10, labelRect.iTl.iY,
       
   103                                        labelRect.iTl.iX + 5, labelRect.iBr.iY);
       
   104                     event = MCCalenNaviLabelObserver::ECCalenNaviLabelEventLeft;
       
   105                     }
       
   106                 else if(aPointerEvent.iPosition.iX > labelRect.iBr.iX - 7)
       
   107                     {
       
   108                     repeatRect.SetRect(labelRect.iBr.iX - 7, labelRect.iTl.iY,
       
   109                                        labelRect.iBr.iX + 10, labelRect.iBr.iY);
       
   110                     event = MCCalenNaviLabelObserver::ECCalenNaviLabelEventRight;
       
   111                     }
       
   112                 else if(aPointerEvent.iPosition.iX > labelRect.iTl.iX + space &&
       
   113                         aPointerEvent.iPosition.iX < labelRect.iBr.iX - space)
       
   114                     {
       
   115                     repeat = EFalse;
       
   116                     event = MCCalenNaviLabelObserver::ECCalenNaviLabelGo;
       
   117                     }
       
   118                 else
       
   119 	                {
       
   120 	                return; 
       
   121 	                }
       
   122                 
       
   123                 if(iLabelObserver)
       
   124                     {
       
   125                     iLabelObserver->HandleNaviLabelEventL(event);
       
   126                     if(repeat)
       
   127                         Window().RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(500000),
       
   128                                                            repeatRect);
       
   129                     }
       
   130                 break;
       
   131                 }
       
   132             case TPointerEvent::EButton1Up:
       
   133                 Window().CancelPointerRepeatEventRequest();
       
   134                 break;
       
   135                 
       
   136             }
       
   137         }
       
   138     
       
   139     TRACE_EXIT_POINT;
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------
       
   143 // CCalenNaviLabel::CCalenNaviLabel
       
   144 // (other items were commented in a header).
       
   145 // ---------------------------------------------------------
       
   146 //
       
   147 EXPORT_C CCalenNaviLabel::CCalenNaviLabel( )
       
   148     {
       
   149     TRACE_ENTRY_POINT;
       
   150     TRACE_EXIT_POINT;
       
   151     }
       
   152     
       
   153 // ---------------------------------------------------------
       
   154 // CCalenNaviLabel::~CCalenNaviLabel
       
   155 // (other items were commented in a header).
       
   156 // ---------------------------------------------------------
       
   157 //
       
   158 EXPORT_C CCalenNaviLabel::~CCalenNaviLabel( )
       
   159     {
       
   160     TRACE_ENTRY_POINT;
       
   161     TRACE_EXIT_POINT;
       
   162     }
       
   163 
       
   164 
       
   165 // End of file