notepad/notepad1/LibSrc/NpdEditorLaf.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:  Implementation of paper lines of Notepad/Template Editor.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <AknUtils.h>
       
    21 #include <NpdLib.rsg>
       
    22 #include <barsread.h>
       
    23 #include <applayout.cdl.h>
       
    24 #include <eikrted.h>    // for CRichTextEditor
       
    25 #include <aknlayoutscalable_apps.cdl.h>
       
    26 #include <aknappui.h>
       
    27 #include "NpdEditorLaf.h"
       
    28 #include "NpdEdwin.h"
       
    29 #include "NpdLibPanic.h"
       
    30 
       
    31 
       
    32 const TInt KNotepadEditorLines(6);
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CNotepadEditorLaf::CNotepadEditorLaf
       
    38 // public Constructor
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CNotepadEditorLaf::CNotepadEditorLaf(CEikDialog* aParent)
       
    42     : CNotepadViewerLaf(aParent)
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CNotepadEditorLaf::~CNotepadEditorLaf
       
    48 // Destructor
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CNotepadEditorLaf::~CNotepadEditorLaf()
       
    52     {
       
    53     iRects.Close();
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CNotepadEditorLaf::AddRectsAndLayout
       
    58 // from CNotepadViewerLaf (called from SizeChanged)
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 void CNotepadEditorLaf::AddRectsAndLayout(const TRect& aRect, RRegion& aRegion)
       
    62     {
       
    63     CNotepadViewerLaf::AddRectsAndLayout(aRect, aRegion);
       
    64 	TAknLayoutRect mainNotesPane;
       
    65 	TAknLayoutRect lineLayout;
       
    66 	TAknLayoutRect line;
       
    67 	TAknLayoutScalableParameterLimits textLimits ;
       
    68 
       
    69 	if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
    70 		{
       
    71 		TRect tempMainPane;
       
    72 		TRect statusPane;
       
    73 		AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,tempMainPane);
       
    74 		AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,statusPane);
       
    75 		TRect mainPane(TPoint(0, 0), tempMainPane.Size());
       
    76 		mainNotesPane.LayoutRect(mainPane, AknLayoutScalable_Apps::main_notes_pane().LayoutLine());
       
    77 		lineLayout.LayoutRect(mainNotesPane.Rect(),AknLayoutScalable_Apps::list_notes_pane().LayoutLine());
       
    78 		textLimits = AknLayoutScalable_Apps::list_notes_text_pane_ParamLimits();
       
    79 		}
       
    80 	TInt lineCount = textLimits.LastRow() - textLimits.FirstRow() + 1;
       
    81 	// The array iRects should be reset, when there is a change 
       
    82 	// in the no of lines after a layout switch
       
    83 	if ( iRects.Count() != lineCount )
       
    84 		{
       
    85 		iRects.Reset();
       
    86    		for (TInt j(textLimits.FirstRow()); j <= textLimits.LastRow(); j++)
       
    87 			{
       
    88     		iRects.Append(TAknLayoutRect());
       
    89 			}
       
    90 		}
       
    91 	if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
    92 		{
       
    93 		for ( TInt i(textLimits.FirstRow()); i <= textLimits.LastRow(); i++ )
       
    94 			{
       
    95 			line.LayoutRect(lineLayout.Rect(),AknLayoutScalable_Apps::list_notes_text_pane(i).LayoutLine());
       
    96 			iRects[i].LayoutRect(line.Rect() ,AknLayoutScalable_Apps::list_notes_text_pane_g1().LayoutLine());
       
    97 			aRegion.AddRect(iRects[i].Rect());
       
    98 			}
       
    99 		}
       
   100 	else
       
   101 		{
       
   102 		for ( TInt i(0); i < KNotepadEditorLines; i++ )
       
   103 			{
       
   104 			iRects[i].LayoutRect(aRect,AppLayout::Note_writing_layout_elements_Line_5(i));
       
   105 			aRegion.AddRect(iRects[i].Rect());
       
   106 			}
       
   107 		}
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CNotepadEditorLaf::ConstructFromResourceL
       
   112 // from CCoeControl
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CNotepadEditorLaf::ConstructFromResourceL(TResourceReader& aReader)
       
   116     {
       
   117 	TAknLayoutScalableParameterLimits textLimits ;  
       
   118     CNotepadViewerLaf::ConstructFromResourceL(aReader); 
       
   119     
       
   120     if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   121 		{
       
   122 		textLimits = AknLayoutScalable_Apps::list_notes_text_pane_ParamLimits();
       
   123 	    for (TInt i(textLimits.FirstRow()); i <= textLimits.LastRow(); i++)
       
   124 		    {
       
   125 	        User::LeaveIfError(iRects.Append(TAknLayoutRect()));
       
   126 			}
       
   127 		}
       
   128 	else
       
   129 		{
       
   130     	for (TInt i(0); i < KNotepadEditorLines; i++)
       
   131         	{
       
   132         	User::LeaveIfError(iRects.Append(TAknLayoutRect()));
       
   133         	}
       
   134 		}
       
   135     }
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // CNotepadEditorLaf::Draw
       
   139 // from CCoeControl
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void CNotepadEditorLaf::Draw(const TRect& aRect) const
       
   143     {
       
   144     CNotepadViewerLaf::Draw(aRect);
       
   145     CWindowGc& gc = SystemGc();
       
   146     for ( TInt i(iRects.Count() - 1); i >= 0; i-- )
       
   147         {
       
   148         iRects[i].DrawRect(gc);
       
   149         }
       
   150     }
       
   151 
       
   152 // End of File