uifw/uiklaf/src/lafmsg.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 // lafmsg.cpp
       
    18 //
       
    19 //
       
    20 //
       
    21 
       
    22 #include <uiklaf/private/lafmsg.h>
       
    23 #include <gulfont.h>
       
    24 #include <uiklaf/private/lafenv.h>
       
    25 #include "LAFSTD.H"
       
    26 #include <gulcolor.h>
       
    27 
       
    28 
       
    29 enum
       
    30 	{
       
    31 	EGapAboveText=3,
       
    32 	EGapBelowText=2,
       
    33 	EGapLeftOfText=2,
       
    34 	EGapRightOfText=2
       
    35 	};
       
    36 
       
    37 
       
    38 enum
       
    39 	{
       
    40 	EWindowOffsetVertical=6,
       
    41 	EWindowOffsetHorizontal=0
       
    42 	};
       
    43 
       
    44 
       
    45 enum
       
    46 	{
       
    47 	EInfoMsgWinDuration=25*100000,
       
    48 	EBusyMsgWinInitialDelay=10*100000
       
    49 	};
       
    50 
       
    51 EXPORT_C LafMsgWin::TDisplayParameters::TDisplayParameters(TDes& aTextToDisplay)
       
    52 	:iTextToDisplay(aTextToDisplay)
       
    53 	{
       
    54 	/** Message window position. */
       
    55 	iMsgWinPosition.iX = 0;
       
    56 	iMsgWinPosition.iY = 0;
       
    57 
       
    58     /** Message window size. */
       
    59 	iMsgWinSize.iWidth = 176;
       
    60 	iMsgWinSize.iHeight = 50;
       
    61 
       
    62     /** Message window margins. */
       
    63     iMsgWinBorders.iTop = 5;
       
    64     iMsgWinBorders.iBottom = 5;
       
    65     iMsgWinBorders.iLeft = 5;
       
    66     iMsgWinBorders.iRight = 5;
       
    67 
       
    68     /** Message window alignment. */
       
    69 	TGulAlignment iDisplayCorner = EHRightVTop;
       
    70      
       
    71     }
       
    72 
       
    73 /**
       
    74  * This method sets the shadow on the blank window which the Info Message or Busy 
       
    75  * message is contained in.
       
    76  */
       
    77 EXPORT_C void LafMsgWin::SetUpBlankWindow(RBlankWindow& aBlankWindow)
       
    78 	{//static
       
    79 	aBlankWindow.SetShadowHeight(0);
       
    80 	aBlankWindow.SetShadowDisabled(ETrue);
       
    81 	}
       
    82 
       
    83 /**
       
    84  * This method completes the intitialisation of the LafMsgWin. This method should
       
    85  * set a font and call constructL on aMessageWin.
       
    86  */
       
    87 EXPORT_C void LafMsgWin::CompleteMessageWinConstructionL(RMessageWindow& aMessageWin,const MLafEnv& aEnv)
       
    88 	{//static
       
    89 	TLogicalFont logicalFont(TLogicalFont::EView, TLogicalFont::ENormal, TZoomFactor());
       
    90 	const CFbsFont& font=*(CFbsFont*)aEnv.Font(logicalFont);
       
    91 	aMessageWin.ConstructL(EGapAboveText+font.AscentInPixels(), font.Handle(), aEnv.Color(EColorMsgWinBackground), aEnv.Color(EColorMsgWinForeground));
       
    92 	}
       
    93 
       
    94 EXPORT_C void LafMsgWin::HandleResourceChange(RMessageWindow& aMessageWin,const MLafEnv& aEnv)
       
    95 	{//static
       
    96 	aMessageWin.SetBackgroundColor(aEnv.Color(EColorMsgWinBackground));
       
    97 	aMessageWin.SetTextColor(aEnv.Color(EColorMsgWinForeground));
       
    98 	}
       
    99 
       
   100 /**
       
   101  * This method should truncate the text in aParams.iTextToDisplay if this is needed on the 
       
   102  * device. It should also set aParms.iMsgWinSize and aParams.iMsgWinPosition of the message,
       
   103  * depending on the corner aParams.iDisplayCorner, and the font for the device.
       
   104  * aParams.iClientRect is provided for devices that wish to set the position relative to the
       
   105  * client rect of the application rather than the screen rect.
       
   106  */
       
   107 EXPORT_C void LafMsgWin::ConfigureText(TDisplayParameters& aParams,const MLafEnv& aEnv)
       
   108 	{//static
       
   109 	TLogicalFont logicalFont(TLogicalFont::EView, TLogicalFont::ENormal, TZoomFactor());
       
   110 	const CFont& font=*aEnv.Font(logicalFont);
       
   111 	
       
   112 	aParams.iMsgWinSize=TSize(aParams.iMsgWinBorders.iLeft+aParams.iMsgWinBorders.iRight+EGapLeftOfText+EGapRightOfText+font.TextWidthInPixels(aParams.iTextToDisplay),
       
   113 				aParams.iMsgWinBorders.iTop+aParams.iMsgWinBorders.iBottom+EGapAboveText+EGapBelowText+font.HeightInPixels());
       
   114 	aParams.iMsgWinPosition=aParams.iDisplayCorner.InnerTopLeft(aParams.iEnv->ScreenDevice()->SizeInPixels(), aParams.iMsgWinSize);
       
   115 	switch (aParams.iDisplayCorner.HAlignment())
       
   116 		{
       
   117 	case EHLeft:
       
   118 		aParams.iMsgWinPosition.iX+=EWindowOffsetHorizontal;
       
   119 		break;
       
   120 	case EHCenter:
       
   121 		break;
       
   122 	case EHRight:
       
   123 		aParams.iMsgWinPosition.iX-=EWindowOffsetHorizontal;
       
   124 		break;
       
   125 #if defined(_DEBUG)
       
   126 	default:
       
   127 		Panic(ELafPanicMsgWinBadHorizontalAlignment);
       
   128 		break;
       
   129 #endif
       
   130 		}
       
   131 	switch (aParams.iDisplayCorner.VAlignment())
       
   132 		{
       
   133 	case EVTop:
       
   134 		aParams.iMsgWinPosition.iY+=EWindowOffsetVertical;
       
   135 		break;
       
   136 	case EVCenter:
       
   137 		break;
       
   138 	case EVBottom:
       
   139 		aParams.iMsgWinPosition.iY-=EWindowOffsetVertical;
       
   140 		break;
       
   141 #if defined(_DEBUG)
       
   142 	default:
       
   143 		Panic(ELafPanicMsgWinBadVerticalAlignment);
       
   144 		break;
       
   145 #endif
       
   146 		}
       
   147 	}
       
   148 
       
   149 /**
       
   150  * Returns the duration (in microseconds), which the info message should be displayed for.
       
   151  *
       
   152  * @since App-Framework_6.1
       
   153  */
       
   154 EXPORT_C TTimeIntervalMicroSeconds32 LafInfoMsgWin::DefaultDuration()
       
   155 	{
       
   156 	return EInfoMsgWinDuration;
       
   157 	}
       
   158 
       
   159 /**
       
   160  * Returns the duration (in microseconds), after which the busy message should initially appear.
       
   161  *
       
   162  * @since App-Framework_6.1
       
   163  */
       
   164 EXPORT_C TTimeIntervalMicroSeconds32 LafBusyMsgWin::DefaultInitialDelay()
       
   165 	{
       
   166 	return EBusyMsgWinInitialDelay;
       
   167 	}