uifw/AvKon/src/aknnotecontrol.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
child 72 a5e7a4f63858
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
    47 #include <eikdialg.h>
    47 #include <eikdialg.h>
    48 #include <eikdialogext.h>
    48 #include <eikdialogext.h>
    49 #include <touchfeedback.h>
    49 #include <touchfeedback.h>
    50 
    50 
    51 #include <AknTasHook.h> // for testability hooks
    51 #include <AknTasHook.h> // for testability hooks
       
    52 
       
    53 #include "akntrace.h"
    52 const TInt KRate = 95;    // 95% similar rate
    54 const TInt KRate = 95;    // 95% similar rate
    53 const TInt KFullColor = 255;
    55 const TInt KFullColor = 255;
    54 
    56 
    55 // ---------------------------------------------
    57 // ---------------------------------------------
    56 // CONSTRUCTION - DESTRUCTION
    58 // CONSTRUCTION - DESTRUCTION
    71  *
    73  *
    72  * 
    74  * 
    73  */
    75  */
    74 EXPORT_C CAknNoteControl::~CAknNoteControl()
    76 EXPORT_C CAknNoteControl::~CAknNoteControl()
    75     {
    77     {
       
    78     _AKNTRACE_FUNC_ENTER;
    76     AKNTASHOOK_REMOVE();
    79     AKNTASHOOK_REMOVE();
    77     MTouchFeedback* feedback = MTouchFeedback::Instance();
    80     MTouchFeedback* feedback = MTouchFeedback::Instance();
    78     if ( feedback )
    81     if ( feedback )
    79         {
    82         {
    80         feedback->RemoveFeedbackForControl( this );
    83         feedback->RemoveFeedbackForControl( this );
    81         }
    84         }
    82 
    85 
    83     delete iAttributes;
    86     delete iAttributes;
    84     delete iLineWidths;
    87     delete iLineWidths;
       
    88     _AKNTRACE_FUNC_EXIT;
    85     }
    89     }
    86 
    90 
    87 void CAknNoteControl::ConstructFromResourceL(TResourceReader &aRes)
    91 void CAknNoteControl::ConstructFromResourceL(TResourceReader &aRes)
    88     {
    92     {
    89     
    93     
   126 
   130 
   127 // -----------------------------------------
   131 // -----------------------------------------
   128 //  CCOECONTROL METHODS
   132 //  CCOECONTROL METHODS
   129 // -----------------------------------------
   133 // -----------------------------------------
   130 void CAknNoteControl::Draw(const TRect& /*aRect*/) const
   134 void CAknNoteControl::Draw(const TRect& /*aRect*/) const
   131     {   
   135     {
       
   136     _AKNTRACE_FUNC_ENTER;
   132     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   137     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   133 
   138 
   134     MAknsControlContext* cc = iAttributes->iBgContext;
   139     MAknsControlContext* cc = iAttributes->iBgContext;
   135     
   140     
   136 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
   141 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
   185     }
   190     }
   186     if (iImageHasShadow)
   191     if (iImageHasShadow)
   187         {
   192         {
   188         iShadowRect.DrawRect( gc );
   193         iShadowRect.DrawRect( gc );
   189         }   
   194         }   
       
   195     _AKNTRACE_FUNC_EXIT;
   190     }
   196     }
   191     
   197     
   192 EXPORT_C void CAknNoteControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
   198 EXPORT_C void CAknNoteControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
   193     { 
   199     { 
   194     CAknControl::HandlePointerEventL(aPointerEvent); 
   200     CAknControl::HandlePointerEventL(aPointerEvent); 
   275  * Do not call this method when you need to do layout for reasons
   281  * Do not call this method when you need to do layout for reasons
   276  * different than the size or position of the control changing.
   282  * different than the size or position of the control changing.
   277  * Call Layout instead.
   283  * Call Layout instead.
   278  */
   284  */
   279 void CAknNoteControl::SizeChanged()
   285 void CAknNoteControl::SizeChanged()
   280     {  
   286     {
       
   287     _AKNTRACE_FUNC_ENTER;
   281     DoLayout();
   288     DoLayout();
       
   289     _AKNTRACE_FUNC_EXIT;
   282     }
   290     }
   283 
   291 
   284 /** 
   292 /** 
   285  * Code shared between SizeChanged() and Layout().
   293  * Code shared between SizeChanged() and Layout().
   286  *
   294  *
   287  */
   295  */
   288 void CAknNoteControl::DoLayout()
   296 void CAknNoteControl::DoLayout()
   289     {
   297     {
       
   298     _AKNTRACE_FUNC_ENTER;
       
   299     _AKNTRACE("iNoteLayout = %d", iNoteLayout);
   290     TextControl()->SetRect(LayoutRect());
   300     TextControl()->SetRect(LayoutRect());
   291     switch(iNoteLayout)
   301     switch(iNoteLayout)
   292         {
   302         {
   293     case EGeneralLayout:
   303     case EGeneralLayout:
   294         GeneralNoteLayout();
   304         GeneralNoteLayout();
   331                                ETouchFeedbackVibra );
   341                                ETouchFeedbackVibra );
   332             feedback->SetFeedbackArea( this, 0, Rect(), spec );
   342             feedback->SetFeedbackArea( this, 0, Rect(), spec );
   333             delete spec;
   343             delete spec;
   334             }
   344             }
   335         }
   345         }
       
   346     _AKNTRACE_FUNC_EXIT;
   336     }
   347     }
   337 
   348 
   338 /**
   349 /**
   339  *
   350  *
   340  * This is used by a dialog to layout the control correctly.
   351  * This is used by a dialog to layout the control correctly.
   341  *
   352  *
   342  */
   353  */
   343 void CAknNoteControl::WindowLayout( TAknWindowLineLayout& aLayout ) const
   354 void CAknNoteControl::WindowLayout( TAknWindowLineLayout& aLayout ) const
   344     {
   355     {
       
   356     _AKNTRACE_FUNC_ENTER;
       
   357     _AKNTRACE("iNoteLayout = %d", iNoteLayout);
   345     TIndex laf(NumberOfLines());
   358     TIndex laf(NumberOfLines());
   346     AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() );
   359     AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() );
   347     TInt variety( 0 );
   360     TInt variety( 0 );
   348     
   361     
   349     switch(iNoteLayout)
   362     switch(iNoteLayout)
   434             
   447             
   435             aLayout = AknLayoutScalable_Avkon::popup_note_window( variety +
   448             aLayout = AknLayoutScalable_Avkon::popup_note_window( variety +
   436                 laf.PopupNoteWindow() );
   449                 laf.PopupNoteWindow() );
   437             break;
   450             break;
   438         }
   451         }
       
   452     _AKNTRACE_FUNC_EXIT;
   439     }
   453     }
   440 
   454 
   441 /**
   455 /**
   442  * Return the note height 
   456  * Return the note height 
   443  *
   457  *
   655         for (TInt i=0; i < nLines; i++)
   669         for (TInt i=0; i < nLines; i++)
   656             {
   670             {
   657 
   671 
   658             AknLayoutUtils::LayoutLabel(TextControl()->Line(i),LayoutRect(),
   672             AknLayoutUtils::LayoutLabel(TextControl()->Line(i),LayoutRect(),
   659                 AKN_LAYOUT_TEXT_Note_with_an_image_pop_up_window_texts_Line_1(
   673                 AKN_LAYOUT_TEXT_Note_with_an_image_pop_up_window_texts_Line_1(
   660                 lafIndex.NWIPWindowTextsLine1L(i),lafIndex.NWIPWindowTextsLine1R(i),
   674                 lafIndex.NWIPWindowTextsLine1Left(i),lafIndex.NWIPWindowTextsLine1Right(i),
   661                 lafIndex.NWIPWindowTextsLine1B(i),lafIndex.NWIPWindowTextsLine1W(i)));
   675                 lafIndex.NWIPWindowTextsLine1B(i),lafIndex.NWIPWindowTextsLine1W(i)));
   662 
   676 
   663             if (!error)
   677             if (!error)
   664               {
   678               {
   665                 // Ignore error
   679                 // Ignore error
   900             TIndex lafIndex(KINMaxNumLines,Icon()!=NULL,imageSize);
   914             TIndex lafIndex(KINMaxNumLines,Icon()!=NULL,imageSize);
   901         
   915         
   902             for (TInt i=0; i < KINMaxNumLines; i++)
   916             for (TInt i=0; i < KINMaxNumLines; i++)
   903                 {
   917                 {
   904                 TAknTextLineLayout lay = AKN_LAYOUT_TEXT_Note_with_an_image_pop_up_window_texts_Line_1(
   918                 TAknTextLineLayout lay = AKN_LAYOUT_TEXT_Note_with_an_image_pop_up_window_texts_Line_1(
   905                     lafIndex.NWIPWindowTextsLine1L(i),lafIndex.NWIPWindowTextsLine1R(i),
   919                     lafIndex.NWIPWindowTextsLine1Left(i),lafIndex.NWIPWindowTextsLine1Right(i),
   906                     lafIndex.NWIPWindowTextsLine1B(i),lafIndex.NWIPWindowTextsLine1W(i));
   920                     lafIndex.NWIPWindowTextsLine1B(i),lafIndex.NWIPWindowTextsLine1W(i));
   907                 text.LayoutText(LayoutRect(), lay);
   921                 text.LayoutText(LayoutRect(), lay);
   908                 TInt width = text.TextRect().Width();
   922                 TInt width = text.TextRect().Width();
   909             
   923             
   910                 iLineWidths->AppendL(width,1);
   924                 iLineWidths->AppendL(width,1);
  1145  * @see CAknTextControl
  1159  * @see CAknTextControl
  1146  */
  1160  */
  1147 EXPORT_C void CAknNoteControl::ResetText()
  1161 EXPORT_C void CAknNoteControl::ResetText()
  1148     {
  1162     {
  1149     // This can not Leave so no need to use TRAP 
  1163     // This can not Leave so no need to use TRAP 
  1150     Attributes()->SetTextL(KNullDesC);
  1164     TRAP_IGNORE(Attributes()->SetTextL(KNullDesC));
  1151     Layout();
  1165     Layout();
  1152     }
  1166     }
  1153 
  1167 
  1154 /**
  1168 /**
  1155  * Set whole text for the note control.
  1169  * Set whole text for the note control.
  1180  * The dialog will not be resized. 
  1194  * The dialog will not be resized. 
  1181  *
  1195  *
  1182  */
  1196  */
  1183 EXPORT_C void CAknNoteControl::SetTextL(const TDesC& aText, TInt aLineNum)
  1197 EXPORT_C void CAknNoteControl::SetTextL(const TDesC& aText, TInt aLineNum)
  1184     {
  1198     {
       
  1199     _AKNTRACE_FUNC_ENTER;
  1185     TAknLayoutText textRect;
  1200     TAknLayoutText textRect;
  1186     
  1201     _AKNTRACE(_L("SetTextL = %S"), &aText);
  1187     if ( iNoteLayout == ENotificationWithGraphicsLayout || iNoteLayout == ETextualNotificationLayout )
  1202     if ( iNoteLayout == ENotificationWithGraphicsLayout || iNoteLayout == ETextualNotificationLayout )
  1188         {
  1203         {
  1189         textRect.LayoutText(LayoutRect(), AKN_LAYOUT_TEXT_Notification_pop_up_window_texts__text__Line_1(1));
  1204         textRect.LayoutText(LayoutRect(), AKN_LAYOUT_TEXT_Notification_pop_up_window_texts__text__Line_1(1));
  1190         }
  1205         }
  1191     else 
  1206     else 
  1195     
  1210     
  1196     const CFont *font = textRect.Font();    
  1211     const CFont *font = textRect.Font();    
  1197 
  1212 
  1198     Attributes()->SetTextL(aText, aLineNum, font, iLineWidths);
  1213     Attributes()->SetTextL(aText, aLineNum, font, iLineWidths);
  1199     Layout();
  1214     Layout();
       
  1215     _AKNTRACE_FUNC_EXIT;
  1200     }
  1216     }
  1201 
  1217 
  1202 /**
  1218 /**
  1203  * Set the number inside the note text. The text must have been 
  1219  * Set the number inside the note text. The text must have been 
  1204  * previously set via resource or via SetTextL and must have a
  1220  * previously set via resource or via SetTextL and must have a
  1461  * Return Left index into table "Note With Image Popup Window Texts Line 1"
  1477  * Return Left index into table "Note With Image Popup Window Texts Line 1"
  1462  * Index depends on number of text lines, whether or not there is a
  1478  * Index depends on number of text lines, whether or not there is a
  1463  * number type indication (NTI). See table in *.lay and
  1479  * number type indication (NTI). See table in *.lay and
  1464  * LAF specs for working out indexes.
  1480  * LAF specs for working out indexes.
  1465  */
  1481  */
  1466 TInt CAknNoteControl::TIndex::NWIPWindowTextsLine1L(TInt aLineNum) const
  1482 TInt CAknNoteControl::TIndex::NWIPWindowTextsLine1Left(TInt aLineNum) const
  1467     {
  1483     {
  1468     SelfTest();
  1484     SelfTest();
  1469     static const TInt  KNWIPWindowTextsLine1IndexL[2][3] = 
  1485     static const TInt  KNWIPWindowTextsLine1IndexLeft[2][3] = 
  1470     {   
  1486     {   
  1471         {0, 0, 0}, //NO NTI
  1487         {0, 0, 0}, //NO NTI
  1472         {0, 0, 2}  //NTI
  1488         {0, 0, 2}  //NTI
  1473     }; 
  1489     }; 
  1474     
  1490     
  1475     return KNWIPWindowTextsLine1IndexL[HasNtiIndex()][aLineNum];
  1491     return KNWIPWindowTextsLine1IndexLeft[HasNtiIndex()][aLineNum];
  1476     }
  1492     }
  1477 
  1493 
  1478 /**
  1494 /**
  1479  * Return Right index into table "Note With Image Popup Window Texts Line 1"
  1495  * Return Right index into table "Note With Image Popup Window Texts Line 1"
  1480  * Index depends on number of text lines and image size. 
  1496  * Index depends on number of text lines and image size. 
  1483  * Table has 3 dimensions:-
  1499  * Table has 3 dimensions:-
  1484  * - Dimension 1 is the line number
  1500  * - Dimension 1 is the line number
  1485  * - Dimension 2 is the image width  
  1501  * - Dimension 2 is the image width  
  1486  * - Dimension 3 is the image height 
  1502  * - Dimension 3 is the image height 
  1487  */
  1503  */
  1488 TInt CAknNoteControl::TIndex::NWIPWindowTextsLine1R(TInt aLineNum) const
  1504 TInt CAknNoteControl::TIndex::NWIPWindowTextsLine1Right(TInt aLineNum) const
  1489     {
  1505     {
  1490     SelfTest();
  1506     SelfTest();
  1491 
  1507 
  1492     static const TInt  KNWIPWindowTextsLine1IndexR[3][5][5] = 
  1508     static const TInt  KNWIPWindowTextsLine1IndexRight[3][5][5] = 
  1493     {   
  1509     {   
  1494         {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //FIRST LINE
  1510         {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //FIRST LINE
  1495         {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //SECOND LINE
  1511         {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //SECOND LINE
  1496         {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}, {0, 0, 0, 5, 5}, {0, 0, 0, 7, 7}, {0, 0, 0, 9, 9} }  //THIRD LINE
  1512         {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}, {0, 0, 0, 5, 5}, {0, 0, 0, 7, 7}, {0, 0, 0, 9, 9} }  //THIRD LINE
  1497     }; 
  1513     }; 
  1498     
  1514     
  1499     return KNWIPWindowTextsLine1IndexR[aLineNum][ImageWidthIndex()][ImageHeightIndex()];
  1515     return KNWIPWindowTextsLine1IndexRight[aLineNum][ImageWidthIndex()][ImageHeightIndex()];
  1500 
  1516 
  1501     }
  1517     }
  1502 
  1518 
  1503 /**
  1519 /**
  1504  * Return Bottom index into table "Note With Image Popup Window Texts Line 1"
  1520  * Return Bottom index into table "Note With Image Popup Window Texts Line 1"