|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implements the CSheetLableImg class which is used as a Grid Label |
|
15 // for Grid0Step.\n |
|
16 // Provides handlers to draw a row label,column label,to draw the text in the cell |
|
17 // as well as calculate the side label width.\n |
|
18 // |
|
19 // |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent - Internal Symbian test code |
|
24 */ |
|
25 |
|
26 #include <e32std.h> |
|
27 #include <gdi.h> |
|
28 #include <grdstd.h> |
|
29 #include "TIMG0.H" |
|
30 #include <w32std.h> |
|
31 |
|
32 |
|
33 #define KRgbGridLabelShadows TRgb(85,85,85) |
|
34 /** |
|
35 Constructor for CSheetLabelImg.\n |
|
36 Used as a Grid Label for GRID0Step.\n |
|
37 * |
|
38 */ |
|
39 CSheetLabelImg::CSheetLabelImg(const TFontSpec& aFontSpec,MGraphicsDeviceMap* aGraphicsDeviceMap) |
|
40 : CGridLabelImg(aFontSpec,aGraphicsDeviceMap) |
|
41 { |
|
42 } |
|
43 /** |
|
44 Auxiliary Function for T-Grid0Step-RunTestStepL.\n |
|
45 Function which draws the Label for each row of the grid table.\n |
|
46 */ |
|
47 void CSheetLabelImg::DrawRowLabelL(CGraphicsContext* aGc,TInt aRow,const TRect &aRect) const |
|
48 { |
|
49 TBuf<32> buf; |
|
50 buf.Num(aRow+1); |
|
51 DrawText(aGc,buf,aRect); |
|
52 } |
|
53 /** |
|
54 Auxiliary Function for T-Grid0Step-RunTestStepL.\n |
|
55 Function which draws the Label for each column of the grid table.\n |
|
56 */ |
|
57 void CSheetLabelImg::DrawColLabelL(CGraphicsContext* aGc,TInt aCol,const TRect &aRect) const |
|
58 { |
|
59 TBuf<32> buf; |
|
60 if (aCol>25) |
|
61 buf.Append(aCol/26+'A'-1); |
|
62 buf.Append(aCol%26+'A'); |
|
63 DrawText(aGc,buf,aRect); |
|
64 } |
|
65 /** |
|
66 Auxiliary Function for T-Grid0Step-RunTestStepL.\n |
|
67 Function to draw the text.\n |
|
68 Invokes the DrawText of CGraphicsContext to Draw the specified |
|
69 text at a given position using the parameters supplied.\n |
|
70 The Pen and brush settings are configured before drawing the text.\n |
|
71 */ |
|
72 void CSheetLabelImg::DrawText(CGraphicsContext* aGc,const TDesC& aDes,const TRect& aRect) const |
|
73 { |
|
74 // aGc->SetPenColor(KRgbGridBackground); |
|
75 aGc->SetPenColor(iGridColors.iBackground); |
|
76 aGc->DrawLine(aRect.iTl,TPoint(aRect.iBr.iX,aRect.iTl.iY)); |
|
77 aGc->DrawLine(aRect.iTl,TPoint(aRect.iTl.iX,aRect.iBr.iY)); |
|
78 TRect rect=aRect; |
|
79 rect.iTl+=TPoint(1,1); |
|
80 TInt offset = rect.Height()-iFont->DescentInPixels(); |
|
81 // aGc->SetPenColor(KRgbGridForeground); |
|
82 aGc->SetPenColor(iGridColors.iForeground); |
|
83 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
84 aGc->SetBrushColor(KRgbGridLabels); |
|
85 aGc->UseFont(iFont); |
|
86 aGc->DrawText(aDes,rect,offset,CGraphicsContext::ECenter); |
|
87 aGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
88 } |
|
89 /** |
|
90 Auxiliary Function for T-Grid0Step-RunTestStepL.\n |
|
91 Function that draws the top left label of the grid table.\n |
|
92 Sets the Pen colour using SetPenColor API of CGraphicsContext class.\n |
|
93 Set the x and y co-ordinates and Invokes the DrawLine of CGraphicsContext to |
|
94 draw a straight line between the points.\n |
|
95 Calls the static implementation of FillRect in TGridUtils to |
|
96 fill the rectangle with the specified colour(KRgbGridLabels).\n |
|
97 */ |
|
98 void CSheetLabelImg::DrawTopLeftLabelL(CGraphicsContext* aGc,const TRect& aRect) const |
|
99 { |
|
100 TRect rect=aRect; |
|
101 for (TInt ii=0;ii<2;ii++) |
|
102 { |
|
103 // aGc->SetPenColor(KRgbGridBackground); |
|
104 aGc->SetPenColor(iGridColors.iBackground); |
|
105 TPoint finish(rect.iBr.iX,rect.iTl.iY); |
|
106 aGc->DrawLine(rect.iTl,finish); |
|
107 finish.SetXY(rect.iTl.iX,rect.iBr.iY); |
|
108 aGc->DrawLine(rect.iTl,finish); |
|
109 aGc->SetPenColor(KRgbGridLabelShadows); |
|
110 TPoint start(rect.iTl.iX+1,rect.iBr.iY-1); |
|
111 finish.SetXY(rect.iBr.iX,rect.iBr.iY-1); |
|
112 aGc->DrawLine(start,finish); |
|
113 start.SetXY(rect.iBr.iX-1,rect.iBr.iY-2); |
|
114 finish.SetXY(rect.iBr.iX-1,rect.iTl.iY); |
|
115 aGc->DrawLine(start,finish); |
|
116 rect.Shrink(1,1); |
|
117 } |
|
118 TGridUtils::FillRect(aGc,KRgbGridLabels,rect); |
|
119 } |
|
120 /** |
|
121 Auxiliary Function for T-Grid0Step-RunTestStepL.\n |
|
122 Draw function for the row cursor of the gridcell.\n |
|
123 */ |
|
124 void CSheetLabelImg::DrawRowCursorL(CGraphicsContext* aGc,const TRect& aRect) const |
|
125 { |
|
126 aGc->DrawText(_L(">"),aRect,(aRect.Height()+iFont->AscentInPixels())/2,CGraphicsContext::ERight); |
|
127 } |
|
128 /** |
|
129 Auxiliary Function for T-Grid0Step-RunTestStepL.\n |
|
130 Gets the width of the side label.\n |
|
131 @return The width of the side label in pixels.\n |
|
132 */ |
|
133 TInt CSheetLabelImg::SideLabelWidthInPixels(TInt aStartRow,TInt aEndRow) const |
|
134 { |
|
135 TInt maxLen=Max(Abs(aStartRow),Abs(aEndRow)); |
|
136 if (maxLen<9) |
|
137 maxLen=9; //Single digit labels must be same width as double digit labels |
|
138 TBuf<32> buf; |
|
139 buf.Num(maxLen+1); |
|
140 return (iFont->TextWidthInPixels(buf) |
|
141 + iGraphicsDeviceMap->HorizontalTwipsToPixels(ESideLabelMarginWidthInTwips)); |
|
142 } |
|
143 /** |
|
144 Constructor for the SheetCellImg class.\n |
|
145 */ |
|
146 CSheetCellImg::CSheetCellImg() |
|
147 { |
|
148 } |
|
149 /** |
|
150 Auxiliary Function for T-Grid0Step-RunTestStepL.\n |
|
151 Draw function for a particular cell in the Grid table.\n |
|
152 The function does nothing currently.\n |
|
153 */ |
|
154 void CSheetCellImg::DrawL(CGraphicsContext* /*aGc*/,const TCellRef& /*aCell*/,const TRect& /*aRect*/, |
|
155 const TRect& /*aClipRect*/) const |
|
156 {} |