|
1 // Copyright (c) 1997-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 // The member variables of the class CGridImg are as follows:- |
|
15 // iGridRect - the coordinates of the rectangle containing the grid. |
|
16 // iTitlePoint - The point at the top left of the grid not including the labels |
|
17 // iMainPoint - The point at which the visible range starts (usually == iTitlePoint) |
|
18 // iCursorPos - the cell reference of the current cursor position. |
|
19 // iNewCursorPos - the proposed cell reference of the position that |
|
20 // the cursor would occupy after a keypress. |
|
21 // iAnchorPos - the cell reference of the position that the cursor must |
|
22 // return to after a series of selected movements have been made. |
|
23 // iGcPtr - a pointer to the current graphics context. |
|
24 // iGc - the internal grid image Gc |
|
25 // *iWin - a pointer to the current active window. |
|
26 // *iGridLay, *iGridCellImg, *iGridLabelImg - allow access to the data in these |
|
27 // other classes. |
|
28 // *iSelected - allows access to the class that stores the array of selected ranges |
|
29 // *iCursorMoveCallBack - a pointer to call back to an app after a cursor move |
|
30 // iDragLabel - store the index of the label currently being dragged |
|
31 // iCurrentDragPos - Stores the position of the label prior to it being dragged |
|
32 // iDragDiff - Stores the distance between the second drag label and the pointer while a label drag is in progress |
|
33 // iDragDim - Simply stores the dimension in which a label drag is in (X,Y or none) |
|
34 // iDragBmp - Stores the bitmap of the dragged labels during a drag. |
|
35 // iXRefPoint,iYRefPoint - Remembers which part of the grid the last pointer event was in. This is used in the |
|
36 // SetCursorWithPointer() function logic. |
|
37 // |
|
38 // |
|
39 |
|
40 #include "GRDSTD.H" |
|
41 #include "GRDPANIC.H" |
|
42 |
|
43 #if !defined(__WINC__) |
|
44 #include <w32std.h> |
|
45 #endif |
|
46 |
|
47 const TInt KArrowLength = 11; |
|
48 const TInt KArrowBreadth = 11; |
|
49 const TInt KArrowSeparation = 11; |
|
50 |
|
51 GLDEF_C void Panic(TGridPanic aPanic) |
|
52 { |
|
53 _LIT(KGridPanic,"GRIDIMG"); |
|
54 User::Panic(KGridPanic,aPanic); |
|
55 } |
|
56 |
|
57 EXPORT_C void TGridUtils::FillRect(CGraphicsContext* aGc,TRgb aColor,const TRect &aRect) |
|
58 /** Fills the specified rectangle with the specified colour. |
|
59 |
|
60 @param aGc The graphics context to be used. |
|
61 @param aColor The colour which is to fill the rectangle. |
|
62 @param aRect The rectangle to be filled. |
|
63 @panic GRIDIMG 0 In debug mode only, if the pointer to the graphics context |
|
64 is Null. */ |
|
65 { |
|
66 __ASSERT_DEBUG(aGc!=NULL,Panic(EGridImgInvalidGC)); |
|
67 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
68 aGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
69 aGc->SetBrushColor(aColor); |
|
70 aGc->DrawRect(aRect); |
|
71 aGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
72 aGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
73 } |
|
74 |
|
75 // |
|
76 |
|
77 EXPORT_C CGridCellImg::CGridCellImg() |
|
78 : iBurstColOffset(0), |
|
79 iBurstLeft(0), |
|
80 iBurstRight(0), |
|
81 iGridLineFlags(EIsHorizontalGridLines|EIsVerticalGridLines) |
|
82 /** Default constructor. */ |
|
83 { |
|
84 } |
|
85 |
|
86 EXPORT_C CGridCellImg::~CGridCellImg() |
|
87 /** Destructor. */ |
|
88 { |
|
89 } |
|
90 |
|
91 |
|
92 EXPORT_C TInt CGridCellImg::DataWidthInPixelsL(const TCellRef& /*aCell*/) const |
|
93 /** Gets the width of the data contained in the specified cell. |
|
94 @publishedAll |
|
95 @released |
|
96 @param aCell The cell to be tested. |
|
97 @return The width of the data, in pixels. The default implementation returns zero.*/ |
|
98 { |
|
99 return 0; |
|
100 } |
|
101 |
|
102 EXPORT_C TBool CGridCellImg::DoesCellContainDataL(const TCellRef& /*aCell*/) const |
|
103 /** Tests whether the specified cell contains data. |
|
104 @publishedAll |
|
105 @released |
|
106 @param aCell The cell to be tested. |
|
107 @return True, if the cell contains data; false, otherwise. The default implementation returns true.*/ |
|
108 { |
|
109 return ETrue; |
|
110 } |
|
111 |
|
112 EXPORT_C void CGridCellImg::Reserved_1() |
|
113 { |
|
114 // No implementation yet |
|
115 } |
|
116 |
|
117 void CGridCellImg::SetBurstingData(TInt aBurstColOffset,TInt aBurstLeft,TInt aBurstRight) |
|
118 { |
|
119 iBurstColOffset=aBurstColOffset; |
|
120 iBurstLeft=aBurstLeft; |
|
121 iBurstRight=aBurstRight; |
|
122 } |
|
123 |
|
124 // |
|
125 |
|
126 EXPORT_C CGridLabelImg::CGridLabelImg(const TFontSpec& aFontSpec,MGraphicsDeviceMap* aGraphicsDeviceMap) |
|
127 : iFontSpec(aFontSpec), |
|
128 iGraphicsDeviceMap(aGraphicsDeviceMap) |
|
129 /** Constructor taking specified parameters. |
|
130 |
|
131 @param aFontSpec A font specification in device independent terms. |
|
132 @param aGraphicsDeviceMap An interface for mapping between twips and device-specific |
|
133 units. */ |
|
134 { |
|
135 } |
|
136 |
|
137 EXPORT_C CGridLabelImg::~CGridLabelImg() |
|
138 /** Destructor. |
|
139 |
|
140 Releases resources before the object is destroyed. Specifically, it releases |
|
141 the font acquired when the object was constructed. */ |
|
142 { |
|
143 if (iGraphicsDeviceMap && iFont) |
|
144 iGraphicsDeviceMap->ReleaseFont(iFont); |
|
145 } |
|
146 |
|
147 EXPORT_C void CGridLabelImg::ConstructL() |
|
148 /** Implements the second phase of two-phase construction. |
|
149 |
|
150 Specifically, it gets the nearest font to that specified in the font specification |
|
151 passed to the constructor. */ |
|
152 { |
|
153 NotifyGraphicsDeviceMapChangeL(); |
|
154 } |
|
155 |
|
156 |
|
157 EXPORT_C void CGridLabelImg::DrawTopLeftLabelL(CGraphicsContext* aGc,const TRect& aRect) const |
|
158 /** Fills the specified rectangle with a colour. |
|
159 |
|
160 The default implementation fills the specified rectangle with the background |
|
161 colour value as defined by the grid colour specification in iGridColors. |
|
162 @publishedAll |
|
163 @released |
|
164 @param aGc The graphics context to be used. |
|
165 @param aRect The rectangle to be filled. |
|
166 @see TGridColors */ |
|
167 { |
|
168 // TGridUtils::FillRect(aGc,KGridBackgroundColor,aRect); |
|
169 //-> |
|
170 TGridUtils::FillRect(aGc, iGridColors.iBackground, aRect); |
|
171 } |
|
172 |
|
173 EXPORT_C void CGridLabelImg::DrawTopLeftLabelL(CGraphicsContext* aGc,const TRect& aRect, TRgb aColor) const |
|
174 /** Fills the specified rectangle with the specified colour. |
|
175 |
|
176 @param aGc The graphics context to be used. |
|
177 @param aRect The rectangle to be filled. |
|
178 @param aColor The colour which is to fill the rectangle. */ |
|
179 { |
|
180 TGridUtils::FillRect(aGc, aColor, aRect); |
|
181 } |
|
182 //-> |
|
183 |
|
184 |
|
185 EXPORT_C TInt CGridLabelImg::SideLabelWidthInPixels(TInt /*aStartRow*/,TInt /*aEndRow*/) const |
|
186 /** Gets the width of the side labels. |
|
187 @publishedAll |
|
188 @released |
|
189 @param aStartRow A start row. The default implementation does not use this value, |
|
190 but a derived class can use this to define the start of a range of rows, |
|
191 which may be useful if side labels have variable widths. |
|
192 @param aEndRow An end row. The default implementation does not use this value, |
|
193 but a derived class can use this to define the end of a range of rows, |
|
194 which may be useful if side labels have variable widths. |
|
195 @return The width value, in pixels. The default implementation returns the |
|
196 pixel value corresponding to the twips value EDefaultSideLabelWidthInTwips, |
|
197 as converted by the graphics device map function MGraphicsDeviceMap::HorizontalTwipsToPixels(). */ |
|
198 { |
|
199 __ASSERT_DEBUG(iGraphicsDeviceMap!=NULL,Panic(EGridNullGraphicsDeviceMap)); |
|
200 return iGraphicsDeviceMap->HorizontalTwipsToPixels(EDefaultSideLabelWidthInTwips); |
|
201 } |
|
202 |
|
203 EXPORT_C TInt CGridLabelImg::TopLabelHeightInPixels() const |
|
204 /** Gets the height of the top labels. |
|
205 @publishedAll |
|
206 @released |
|
207 @return The height value, in pixels. The default implementation returns the |
|
208 pixel value corresponding to the twips value EDefaultTopLabelHeightInTwips, |
|
209 as converted by the graphics device map function MGraphicsDeviceMap::VerticalTwipsToPixels(). */ |
|
210 { |
|
211 __ASSERT_DEBUG(iGraphicsDeviceMap!=NULL,Panic(EGridNullGraphicsDeviceMap)); |
|
212 return iGraphicsDeviceMap->VerticalTwipsToPixels(EDefaultTopLabelHeightInTwips); |
|
213 } |
|
214 |
|
215 EXPORT_C void CGridLabelImg::DrawRowCursorL(CGraphicsContext* /*aGc*/,const TRect& /*aRect*/) const |
|
216 /** Draws a cursor to identify a row. |
|
217 |
|
218 The default implementation is empty. |
|
219 @publishedAll |
|
220 @released |
|
221 @param aGc The graphics context to be used. |
|
222 @param aRect The rectangle in which the cursor is to be drawn. */ |
|
223 // |
|
224 // To be overridden from if used |
|
225 // |
|
226 {} |
|
227 |
|
228 EXPORT_C void CGridLabelImg::ReleaseFont() |
|
229 // |
|
230 // Should be called before any change in the zoom factor device |
|
231 /** Releases the font. |
|
232 |
|
233 This is called by the destructor, and should be called before calling SetGraphicsDeviceMap(). |
|
234 |
|
235 @see ConstructL() */ |
|
236 { |
|
237 __ASSERT_DEBUG(iGraphicsDeviceMap!=NULL,Panic(EGridNullGraphicsDeviceMap)); |
|
238 iGraphicsDeviceMap->ReleaseFont(iFont); |
|
239 iFont=NULL; |
|
240 } |
|
241 |
|
242 EXPORT_C void CGridLabelImg::NotifyGraphicsDeviceMapChangeL() |
|
243 /** Deals with the result of changing the graphics device map, i.e. the interface |
|
244 for mapping between twips and device-specific units. |
|
245 |
|
246 The function releases the existing font, and then tries to get the nearest |
|
247 font to that specified in the font specification. |
|
248 |
|
249 @see ConstructL() |
|
250 @see SetGraphicsDeviceMap() */ |
|
251 { |
|
252 ReleaseFont(); |
|
253 User::LeaveIfError(iGraphicsDeviceMap->GetNearestFontInTwips(iFont,iFontSpec)); |
|
254 } |
|
255 |
|
256 // |
|
257 |
|
258 EXPORT_C CGridImg* CGridImg::NewL(CGridCellImg* aGridCellImg,CGridLay* aGridLay) |
|
259 /** Creates a new grid image object suitable for printing. |
|
260 |
|
261 @param aGridCellImg A pointer to an object that draws the contents of a |
|
262 single cell. |
|
263 @param aGridLay A pointer to the object that controls the layout of rows and |
|
264 columns. |
|
265 @return A pointer to the new grid image object. */ |
|
266 { |
|
267 //-> |
|
268 CGridImg* self = new(ELeave) CGridImg(aGridCellImg,aGridLay); |
|
269 if (aGridLay && aGridCellImg) |
|
270 aGridCellImg->SetGridColors(aGridLay->GridColors()); |
|
271 return self; |
|
272 //-> |
|
273 // return new(ELeave) CGridImg(aGridCellImg,aGridLay); |
|
274 } |
|
275 |
|
276 CGridImg::CGridImg(CGridCellImg* aGridCellImg,CGridLay* aGridLay) |
|
277 // |
|
278 // Construct a partial gridImg object for printing with the same data as the passed gridImg |
|
279 // and a handle to the passed gridLay |
|
280 : iGridCellImg(aGridCellImg), |
|
281 iGridLay(aGridLay) |
|
282 { |
|
283 } |
|
284 |
|
285 EXPORT_C CGridImg* CGridImg::NewL(CGraphicsDevice* aGraphicsDevice,CGridCellImg* aGridCellImg,CGridLay* aGridLay) |
|
286 /** Creates a new grid image object. |
|
287 |
|
288 @param aGraphicsDevice The graphics device to be used for drawing. |
|
289 @param aGridCellImg A pointer to an object that draws the contents of a single |
|
290 cell. |
|
291 @param aGridLay A pointer to the object that controls the layout of rows and |
|
292 columns. |
|
293 @return A pointer to the new grid image object. */ |
|
294 { |
|
295 CGridImg* self=new(ELeave) CGridImg(aGraphicsDevice,aGridCellImg,aGridLay); |
|
296 CleanupStack::PushL(self); |
|
297 //-> |
|
298 if (aGridLay && aGridCellImg) |
|
299 aGridCellImg->SetGridColors(aGridLay->GridColors()); |
|
300 //-> |
|
301 self->ConstructL(); |
|
302 CleanupStack::Pop(); |
|
303 return self; |
|
304 } |
|
305 |
|
306 CGridImg::CGridImg(CGraphicsDevice *aGraphicsDevice,CGridCellImg *aGridCellImg,CGridLay* aGridLay) |
|
307 : iGraphicsDevice(aGraphicsDevice), |
|
308 iGridCellImg(aGridCellImg), |
|
309 iGridLay(aGridLay), |
|
310 iDragLabel(0), |
|
311 iCurrentDragPos(0), |
|
312 iDragDiff(0), |
|
313 iDragFlags(0), |
|
314 iDragDim(ENoDrag), |
|
315 iXRefPoint(EMainRef), |
|
316 iYRefPoint(EMainRef) |
|
317 { |
|
318 } |
|
319 |
|
320 void CGridImg::ConstructL() |
|
321 { |
|
322 #if !defined(__WINC__) |
|
323 if (iGraphicsDevice) |
|
324 User::LeaveIfError(iGraphicsDevice->CreateContext((CGraphicsContext*&)iGc)); |
|
325 #endif |
|
326 } |
|
327 |
|
328 EXPORT_C CGridImg::~CGridImg() |
|
329 /** Destructor. |
|
330 |
|
331 Frees resources before destruction of the object. */ |
|
332 { |
|
333 #if !defined(__WINC__) |
|
334 delete iGc; |
|
335 delete iDragBmp; |
|
336 #endif |
|
337 delete iSelected; |
|
338 } |
|
339 |
|
340 void CGridImg::ConstructSelectedL(const TRangeRef& aGridRange) |
|
341 { |
|
342 delete iSelected; |
|
343 iSelected=NULL; // in case next line fails |
|
344 iSelected = CGridCellRegion::NewL(aGridRange); |
|
345 } |
|
346 |
|
347 void CGridImg::CreateGc(CGraphicsContext* aGc) |
|
348 { |
|
349 __ASSERT_DEBUG(iGcPtr==NULL,Panic(EGridImgInvalidGC)); |
|
350 iGcPtr=aGc; |
|
351 #if !defined(__WINC__) |
|
352 if (iGcPtr==iGc) |
|
353 iGc->Activate(*iWin); |
|
354 #endif |
|
355 } |
|
356 |
|
357 void CGridImg::DeleteGc() |
|
358 { |
|
359 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
360 #if !defined(__WINC__) |
|
361 if (iGcPtr==iGc) |
|
362 iGc->Deactivate(); |
|
363 #endif |
|
364 iGcPtr=NULL; |
|
365 } |
|
366 |
|
367 void CGridImg::DrawAllGridLabelsL() const |
|
368 // Draw all the grid labels |
|
369 { |
|
370 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
371 DrawTopLeftGridLabelL(); |
|
372 TRangeRef titleRange=iGridLay->TitleRange(); |
|
373 if (iGridLay->IsHorizontalTitleLine()) |
|
374 DrawSideGridLabelsL(titleRange.iFrom.iRow,titleRange.iTo.iRow-1,ETitleRef); |
|
375 if (iGridLay->IsVerticalTitleLine()) |
|
376 DrawTopGridLabelsL(titleRange.iFrom.iCol,titleRange.iTo.iCol-1,ETitleRef); |
|
377 TRangeRef visRange=iGridLay->VisibleRange(); |
|
378 DrawTopGridLabelsL(visRange.iFrom.iCol,visRange.iTo.iCol); |
|
379 DrawSideGridLabelsL(visRange.iFrom.iRow,visRange.iTo.iRow); |
|
380 } |
|
381 |
|
382 void CGridImg::DrawTopLeftGridLabelL() const |
|
383 // Draw top left corner label |
|
384 { |
|
385 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
386 if (iGridLay->IsTopLabels() && iGridLay->IsSideLabels()) |
|
387 { |
|
388 TRect rect(iGridRect.iTl,iTitlePoint); |
|
389 if (iGridLay->IsGridLabelSeparators()) |
|
390 { |
|
391 rect.Resize(-1,-1); |
|
392 //-> |
|
393 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
394 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
395 //-> |
|
396 TPoint start(rect.iTl.iX,rect.iBr.iY); |
|
397 TPoint finish(rect.iBr.iX+1,rect.iBr.iY); |
|
398 iGcPtr->DrawLine(start,finish); |
|
399 start.SetXY(rect.iBr.iX,rect.iTl.iY); |
|
400 iGcPtr->DrawLine(start,rect.iBr); |
|
401 } |
|
402 //-> |
|
403 // iGridLabelImg->DrawTopLeftLabelL(iGcPtr,rect); |
|
404 iGridLabelImg->DrawTopLeftLabelL(iGcPtr, rect, iGridLay->GridColors().iBackground); |
|
405 //-> |
|
406 } |
|
407 } |
|
408 |
|
409 void CGridImg::DrawTopGridLabelsL(TInt aStartCol,TInt aEndCol,TRefPoint aXRef) const |
|
410 // Draws all the top grid labels within the specified column range |
|
411 { |
|
412 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
413 if (!iGridLay->IsTopLabels() || iGridLabelImg==NULL) |
|
414 return; |
|
415 TInt separatorCorr=(iGridLay->IsGridLabelSeparators()) ? 1 : 0; |
|
416 TRect rect; |
|
417 rect.iTl.iY=iGridRect.iTl.iY; |
|
418 rect.iBr.iY=iTitlePoint.iY-separatorCorr; |
|
419 rect.iTl.iX=((aXRef==ETitleRef) ? iGridLay->TitleColumnToXVal(aStartCol) : |
|
420 iGridLay->ColumnToXVal(aStartCol)); |
|
421 rect.iBr.iX=rect.iTl.iX-separatorCorr; |
|
422 TBool doGrayFill=EFalse; |
|
423 TRangeRef visRange=iGridLay->VisibleRange(); |
|
424 if (aEndCol>=visRange.iTo.iCol) |
|
425 { |
|
426 aEndCol=visRange.iTo.iCol; |
|
427 if (aEndCol>iGridLay->GridRange().iTo.iCol) |
|
428 { |
|
429 aEndCol--; |
|
430 doGrayFill=ETrue; |
|
431 } |
|
432 } |
|
433 iGcPtr->SetClippingRect(TRect(iTitlePoint.iX,iGridRect.iTl.iY,iGridRect.iBr.iX,iTitlePoint.iY)); |
|
434 if (iGridLay->IsGridLabelSeparators()) |
|
435 { |
|
436 for (TInt ii=aStartCol;ii<=aEndCol;ii++) |
|
437 { |
|
438 rect.iBr.iX+=iGridLay->ColumnWidthInPixels(ii); |
|
439 iGridLabelImg->DrawColLabelL(iGcPtr,ii,rect); |
|
440 rect.iTl.iX=rect.iBr.iX; |
|
441 //-> |
|
442 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
443 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
444 //-> |
|
445 iGcPtr->DrawLine(rect.iTl,rect.iBr); |
|
446 rect.iTl.iX++; |
|
447 } |
|
448 } |
|
449 else |
|
450 { |
|
451 for (TInt ii=aStartCol;ii<=aEndCol;ii++) |
|
452 { |
|
453 rect.iBr.iX+=iGridLay->ColumnWidthInPixels(ii); |
|
454 iGridLabelImg->DrawColLabelL(iGcPtr,ii,rect); |
|
455 rect.iTl.iX=rect.iBr.iX; |
|
456 } |
|
457 } |
|
458 if (doGrayFill) |
|
459 { |
|
460 TGridUtils::FillRect(iGcPtr,iGridLay->iGridEdgeColor, |
|
461 TRect(rect.iTl.iX,rect.iTl.iY,iGridRect.iBr.iX,rect.iBr.iY+separatorCorr)); |
|
462 } |
|
463 if (iGridLay->IsGridLabelSeparators()) |
|
464 { |
|
465 rect.iBr.iX++; |
|
466 //-> |
|
467 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
468 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
469 iGcPtr->DrawLine(TPoint(iTitlePoint.iX,rect.iBr.iY),rect.iBr); |
|
470 //-> |
|
471 } |
|
472 iGcPtr->CancelClippingRect(); |
|
473 } |
|
474 |
|
475 void CGridImg::DrawSideGridLabelsL(TInt aStartRow,TInt aEndRow,TRefPoint aYRef) const |
|
476 { |
|
477 // |
|
478 // Draw all the side grid labels within the specified row range |
|
479 // |
|
480 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
481 if (!iGridLay->IsSideLabels() || iGridLabelImg==NULL) |
|
482 return; |
|
483 TInt separatorCorr=(iGridLay->IsGridLabelSeparators()) ? 1 : 0; |
|
484 TRect rect; |
|
485 rect.iTl.iX=iGridRect.iTl.iX; |
|
486 rect.iBr.iX=iTitlePoint.iX-separatorCorr; |
|
487 rect.iTl.iY=((aYRef==ETitleRef) ? iGridLay->TitleRowToYVal(aStartRow) : |
|
488 iGridLay->RowToYVal(aStartRow)); |
|
489 TInt startY=rect.iTl.iY; |
|
490 rect.iBr.iY=rect.iTl.iY-separatorCorr; |
|
491 TBool doGrayFill=EFalse; |
|
492 TRangeRef visRange=iGridLay->VisibleRange(); |
|
493 if (aEndRow>=visRange.iTo.iRow) |
|
494 { |
|
495 aEndRow=visRange.iTo.iRow; |
|
496 TInt reqRow; |
|
497 if (iGridLay->RequestRow(aEndRow,reqRow)) |
|
498 { |
|
499 if (aEndRow!=reqRow) |
|
500 { |
|
501 aEndRow--; |
|
502 doGrayFill=ETrue; |
|
503 } |
|
504 } |
|
505 else |
|
506 { |
|
507 aEndRow=aStartRow-1; // guarantees not to go into loop |
|
508 doGrayFill=ETrue; |
|
509 } |
|
510 } |
|
511 iGcPtr->SetClippingRect(TRect(iGridRect.iTl.iX,iTitlePoint.iY,iTitlePoint.iX,iGridRect.iBr.iY)); |
|
512 if (iGridLay->IsGridLabelSeparators()) |
|
513 { |
|
514 for (TInt ii=aStartRow;ii<=aEndRow;ii++) |
|
515 { |
|
516 rect.iBr.iY+=iGridLay->RowHeightInPixels(ii); |
|
517 iGridLabelImg->DrawRowLabelL(iGcPtr,ii,rect); |
|
518 if (ii==iCursorPos.iRow) |
|
519 iGridLabelImg->DrawRowCursorL(iGcPtr,rect); |
|
520 rect.iTl.iY=rect.iBr.iY; |
|
521 //-> |
|
522 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
523 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
524 //-> |
|
525 iGcPtr->DrawLine(rect.iTl,rect.iBr); |
|
526 rect.iTl.iY++; |
|
527 } |
|
528 } |
|
529 else |
|
530 { |
|
531 for (TInt ii=aStartRow;ii<=aEndRow;ii++) |
|
532 { |
|
533 rect.iBr.iY+=iGridLay->RowHeightInPixels(ii); |
|
534 iGridLabelImg->DrawRowLabelL(iGcPtr,ii,rect); |
|
535 if (ii==iCursorPos.iRow) |
|
536 iGridLabelImg->DrawRowCursorL(iGcPtr,rect); |
|
537 rect.iTl.iY=rect.iBr.iY; |
|
538 } |
|
539 } |
|
540 if (doGrayFill) |
|
541 { |
|
542 TGridUtils::FillRect(iGcPtr,iGridLay->iGridEdgeColor, |
|
543 TRect(rect.iTl.iX,rect.iTl.iY,rect.iBr.iX+separatorCorr,iGridRect.iBr.iY)); |
|
544 } |
|
545 if (iGridLay->IsGridLabelSeparators()) |
|
546 { |
|
547 rect.iBr.iY++; |
|
548 //-> |
|
549 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
550 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
551 //-> |
|
552 iGcPtr->DrawLine(TPoint(rect.iBr.iX,startY),rect.iBr); |
|
553 } |
|
554 iGcPtr->CancelClippingRect(); |
|
555 } |
|
556 |
|
557 void CGridImg::DrawSideGridLabelIfOnScreenL(TInt aRow) const |
|
558 { |
|
559 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
560 TBool doDraw=EFalse; |
|
561 TRefPoint refPoint=EMainRef; |
|
562 TRangeRef visRange=iGridLay->VisibleRange(); |
|
563 if (aRow>=visRange.iFrom.iRow && aRow<=visRange.iTo.iRow) |
|
564 doDraw=ETrue; |
|
565 else if (iGridLay->IsHorizontalTitleLine()) |
|
566 { |
|
567 TRangeRef titleRange=iGridLay->TitleRange(); |
|
568 if (aRow>=titleRange.iFrom.iRow && aRow<titleRange.iTo.iRow) |
|
569 { |
|
570 doDraw=ETrue; |
|
571 refPoint=ETitleRef; |
|
572 } |
|
573 } |
|
574 if (doDraw) |
|
575 DrawSideGridLabelsL(aRow,aRow,refPoint); |
|
576 } |
|
577 |
|
578 EXPORT_C void CGridImg::DrawTitleLines() const |
|
579 /** Draws the title lines. */ |
|
580 { |
|
581 #if !defined(__WINC__) |
|
582 ((CGridImg*)this)->CreateGc(iGc); |
|
583 DrawVerticalTitleLine(); |
|
584 DrawHorizontalTitleLine(); |
|
585 ((CGridImg*)this)->DeleteGc(); |
|
586 #endif |
|
587 } |
|
588 |
|
589 EXPORT_C void CGridImg::ClearTitleLineRegionL(const TPoint& aCrossPoint) const |
|
590 /** Clears the region where the the title lines are. |
|
591 |
|
592 @param aCrossPoint Any point within the title region. */ |
|
593 { |
|
594 TRect rect(Max(aCrossPoint.iX-1,iTitlePoint.iX),iTitlePoint.iY, |
|
595 aCrossPoint.iX,iGridRect.iBr.iY); |
|
596 BeginRedrawAndDrawL(rect); |
|
597 rect.SetRect(iTitlePoint.iX,Max(aCrossPoint.iY-1,iTitlePoint.iY), |
|
598 iGridRect.iBr.iX,aCrossPoint.iY); |
|
599 BeginRedrawAndDrawL(rect); |
|
600 } |
|
601 |
|
602 void CGridImg::DrawVerticalTitleLine() const |
|
603 { |
|
604 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
605 if (iMainPoint.iX>iTitlePoint.iX) |
|
606 { |
|
607 //-> |
|
608 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
609 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
610 //-> |
|
611 iGcPtr->DrawLine(TPoint(iMainPoint.iX-1,iTitlePoint.iY-1), |
|
612 TPoint(iMainPoint.iX-1,iGridRect.iBr.iY)); |
|
613 } |
|
614 } |
|
615 |
|
616 void CGridImg::DrawHorizontalTitleLine() const |
|
617 { |
|
618 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
619 if (iMainPoint.iY>iTitlePoint.iY) |
|
620 { |
|
621 //-> |
|
622 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
623 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
624 //-> |
|
625 iGcPtr->DrawLine(TPoint(iTitlePoint.iX-1,iMainPoint.iY-1), |
|
626 TPoint(iGridRect.iBr.iX,iMainPoint.iY-1)); |
|
627 } |
|
628 } |
|
629 |
|
630 void CGridImg::DrawAllGridLinesAndCellsL() const |
|
631 // Draws all the grid lines and cells |
|
632 { |
|
633 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
634 TRangeRef visRange=iGridLay->VisibleRange(); |
|
635 if (iGridLay->IsEncroachingCellBorders()) |
|
636 { |
|
637 if (iGridLay->IsVisibleToRowFullyVisible()) |
|
638 visRange.iTo.iRow++; |
|
639 if (iGridLay->IsVisibleToColumnFullyVisible()) |
|
640 visRange.iTo.iCol++; |
|
641 } |
|
642 TRect clippingRect; |
|
643 TRangeRef titleRange=iGridLay->TitleRange(); |
|
644 TBool isHorizontalTitleLine=iGridLay->IsHorizontalTitleLine(); |
|
645 TBool isVerticalTitleLine=iGridLay->IsVerticalTitleLine(); |
|
646 TRangeRef range; |
|
647 if (isHorizontalTitleLine && isVerticalTitleLine) |
|
648 { |
|
649 clippingRect.SetRect(iTitlePoint,iMainPoint); |
|
650 DrawGridLinesAndCellsInRangeL(titleRange,clippingRect,ETitleRef,ETitleRef); |
|
651 } |
|
652 if (isHorizontalTitleLine) |
|
653 { |
|
654 clippingRect.SetRect(iMainPoint.iX,iTitlePoint.iY,iGridRect.iBr.iX,iMainPoint.iY); |
|
655 range.SetRange(titleRange.iFrom.iRow,visRange.iFrom.iCol, |
|
656 titleRange.iTo.iRow,visRange.iTo.iCol); |
|
657 DrawGridLinesAndCellsInRangeL(range,clippingRect,EMainRef,ETitleRef); |
|
658 } |
|
659 if (isVerticalTitleLine) |
|
660 { |
|
661 clippingRect.SetRect(iTitlePoint.iX,iMainPoint.iY,iMainPoint.iX,iGridRect.iBr.iY); |
|
662 range.SetRange(visRange.iFrom.iRow,titleRange.iFrom.iCol, |
|
663 visRange.iTo.iRow,titleRange.iTo.iCol); |
|
664 DrawGridLinesAndCellsInRangeL(range,clippingRect,ETitleRef,EMainRef); |
|
665 } |
|
666 clippingRect.SetRect(iMainPoint,iGridRect.iBr); |
|
667 DrawGridLinesAndCellsInRangeL(visRange,clippingRect); |
|
668 } |
|
669 |
|
670 void CGridImg::DrawGridLinesAndCellsInRangeL(const TRangeRef& aRange,const TRect& aClipRect, |
|
671 TRefPoint aXRef,TRefPoint aYRef) const |
|
672 // Draws the grid cells for the given cell range |
|
673 { |
|
674 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
675 TRect rangeRect; |
|
676 if (aYRef==ETitleRef) |
|
677 { |
|
678 rangeRect.iTl.iY=iGridLay->TitleRowToYVal(aRange.iFrom.iRow); |
|
679 rangeRect.iBr.iY=iMainPoint.iY-1; |
|
680 } |
|
681 else |
|
682 { |
|
683 rangeRect.iTl.iY=iGridLay->RowToYVal(aRange.iFrom.iRow); |
|
684 rangeRect.iBr.iY=iGridRect.iBr.iY; |
|
685 } |
|
686 if (aXRef==ETitleRef) |
|
687 { |
|
688 rangeRect.iTl.iX=iGridLay->TitleColumnToXVal(aRange.iFrom.iCol); |
|
689 rangeRect.iBr.iX=iMainPoint.iX-1; |
|
690 } |
|
691 else |
|
692 { |
|
693 rangeRect.iTl.iX=iGridLay->ColumnToXVal(aRange.iFrom.iCol); |
|
694 rangeRect.iBr.iX=iGridRect.iBr.iX; |
|
695 } |
|
696 |
|
697 TInt endCol=aRange.iTo.iCol; |
|
698 TBool doRightFill=EFalse; |
|
699 TRangeRef visRange=iGridLay->VisibleRange(); |
|
700 if (endCol>=visRange.iTo.iCol) |
|
701 { |
|
702 endCol=visRange.iTo.iCol; |
|
703 if (endCol>iGridLay->GridRange().iTo.iCol) |
|
704 { |
|
705 endCol--; |
|
706 doRightFill=ETrue; |
|
707 } |
|
708 } |
|
709 TInt endRow=aRange.iTo.iRow; |
|
710 TBool doBottomFill=EFalse; |
|
711 if (endRow>=visRange.iTo.iRow) |
|
712 { |
|
713 endRow=visRange.iTo.iRow; |
|
714 TInt reqRow; |
|
715 if (iGridLay->RequestRow(endRow,reqRow)) |
|
716 { |
|
717 if (endRow!=reqRow) |
|
718 { |
|
719 endRow--; |
|
720 doBottomFill=ETrue; |
|
721 } |
|
722 } |
|
723 else |
|
724 { |
|
725 endRow=aRange.iFrom.iRow-1; |
|
726 doBottomFill=ETrue; |
|
727 } |
|
728 } |
|
729 //-> |
|
730 iGcPtr->SetPenColor((iGcPtr->Device()->DisplayMode()==EGray2) ? KRgbBlack : iGridLay->GridColors().iLines); // To workaround a problem when printing gray lines |
|
731 // iGcPtr->SetPenColor((iGcPtr->Device()->DisplayMode()==EGray2) ? KRgbBlack : KRgbGridLines); // To workaround a problem when printing gray lines |
|
732 //-> |
|
733 TRect rect; |
|
734 rect.iTl.iX=rect.iBr.iX=rangeRect.iTl.iX-1; |
|
735 if (iGridLay->IsVerticalGridLines()) |
|
736 { |
|
737 rect.iTl.iY=rangeRect.iTl.iY; |
|
738 rect.iBr.iY=(doBottomFill) ? iGridLay->RowToYVal(endRow+1) : rangeRect.iBr.iY; |
|
739 } |
|
740 TInt startCol=aRange.iFrom.iCol; |
|
741 TInt pageCol=KMaxTInt; |
|
742 if (!iGridLay->IsPageBreakLinesHidden()) |
|
743 iGridLay->FindNextColumnPageBreak(startCol,pageCol); |
|
744 iGcPtr->SetClippingRect(aClipRect); |
|
745 for (;startCol<=endCol;startCol++) |
|
746 { |
|
747 rect.Move(iGridLay->ColumnWidthInPixels(startCol),0); |
|
748 if (startCol==pageCol) |
|
749 { |
|
750 TPoint start(rect.iTl.iX,iTitlePoint.iY); |
|
751 TPoint end(rect.iBr.iX,rangeRect.iBr.iY); |
|
752 //-> |
|
753 iGcPtr->SetPenColor(iGridLay->GridColors().iBackground); |
|
754 // iGcPtr->SetPenColor(KRgbGridBackground); |
|
755 //-> |
|
756 iGcPtr->DrawLine(start,end); |
|
757 //-> |
|
758 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
759 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
760 //-> |
|
761 iGcPtr->SetPenStyle((iGridLay->IsHardColumnPageBreak(pageCol+1)) |
|
762 ? CGraphicsContext::EDotDashPen : CGraphicsContext::EDashedPen); |
|
763 iGcPtr->DrawLine(start,end); |
|
764 iGcPtr->SetPenStyle(CGraphicsContext::ESolidPen); |
|
765 //-> |
|
766 iGcPtr->SetPenColor((iGcPtr->Device()->DisplayMode()==EGray2) ? KRgbBlack : iGridLay->GridColors().iLines); |
|
767 // iGcPtr->SetPenColor((iGcPtr->Device()->DisplayMode()==EGray2) ? KRgbBlack : KRgbGridLines); |
|
768 //-> |
|
769 iGridLay->FindNextColumnPageBreak(startCol+1,pageCol); |
|
770 } |
|
771 else |
|
772 iGcPtr->DrawLine(rect.iTl,rect.iBr); |
|
773 } |
|
774 if (doRightFill) |
|
775 { |
|
776 TGridUtils::FillRect(iGcPtr,iGridLay->iGridEdgeColor, |
|
777 TRect(rect.iTl.iX+1,rangeRect.iTl.iY,iGridRect.iBr.iX,rangeRect.iBr.iY)); |
|
778 } |
|
779 |
|
780 rect.iTl.iY=rect.iBr.iY=rangeRect.iTl.iY-1; |
|
781 if (iGridLay->IsHorizontalGridLines()) |
|
782 { |
|
783 rect.iTl.iX=rangeRect.iTl.iX; |
|
784 rect.iBr.iX=(doRightFill) ? iGridLay->ColumnToXVal(endCol+1) : rangeRect.iBr.iX; |
|
785 } |
|
786 TInt startRow=aRange.iFrom.iRow; |
|
787 TInt pageRow=KMaxTInt; |
|
788 if (!iGridLay->IsPageBreakLinesHidden()) |
|
789 iGridLay->FindNextRowPageBreak(startRow,pageRow); |
|
790 for (;startRow<=endRow;startRow++) |
|
791 { |
|
792 rect.Move(0,iGridLay->RowHeightInPixels(startRow)); |
|
793 if (startRow==pageRow) |
|
794 { |
|
795 TPoint start(iTitlePoint.iX,rect.iTl.iY); |
|
796 TPoint end(rangeRect.iBr.iX,rect.iBr.iY); |
|
797 //-> |
|
798 iGcPtr->SetPenColor(iGridLay->GridColors().iBackground); |
|
799 // iGcPtr->SetPenColor(KRgbGridBackground); |
|
800 //-> |
|
801 iGcPtr->DrawLine(start,end); |
|
802 //-> |
|
803 iGcPtr->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
804 // iGcPtr->SetPenColor(KRgbGridLabelSeparators); |
|
805 //-> |
|
806 iGcPtr->SetPenStyle((iGridLay->IsHardRowPageBreak(pageRow+1)) |
|
807 ? CGraphicsContext::EDotDashPen : CGraphicsContext::EDashedPen); |
|
808 iGcPtr->DrawLine(start,end); |
|
809 iGcPtr->SetPenStyle(CGraphicsContext::ESolidPen); |
|
810 //-> |
|
811 iGcPtr->SetPenColor((iGcPtr->Device()->DisplayMode()==EGray2) ? KRgbBlack : iGridLay->GridColors().iLines); |
|
812 // iGcPtr->SetPenColor((iGcPtr->Device()->DisplayMode()==EGray2) ? KRgbBlack : KRgbGridLines); |
|
813 //-> |
|
814 iGridLay->FindNextRowPageBreak(startRow+1,pageRow); |
|
815 } |
|
816 else |
|
817 iGcPtr->DrawLine(rect.iTl,rect.iBr); |
|
818 } |
|
819 if (doBottomFill) |
|
820 { |
|
821 TGridUtils::FillRect(iGcPtr,iGridLay->iGridEdgeColor, |
|
822 TRect(rangeRect.iTl.iX,rect.iTl.iY+1,rangeRect.iBr.iX,iGridRect.iBr.iY)); |
|
823 } |
|
824 iGcPtr->CancelClippingRect(); |
|
825 DrawCellsToGcL(iGcPtr,aRange,aClipRect,rangeRect.iTl); |
|
826 } |
|
827 |
|
828 void CGridImg::DrawCellsToGcL(CGraphicsContext* aGc,const TRangeRef& aRange,const TRect& aClipRect, |
|
829 const TPoint& aStartPoint,TInt aScaleFactor) const |
|
830 { |
|
831 TCellRef startCell=aRange.iFrom; |
|
832 if (!iGridLay->LimitCell(startCell)) |
|
833 return; // Nothing to draw |
|
834 TCellRef endCell = aRange.iTo; |
|
835 iGridLay->LimitCell(endCell); |
|
836 TRect rect; |
|
837 TInt yPos=aStartPoint.iY; |
|
838 rect.iTl.iY = yPos*EScaleOneToOne/aScaleFactor; |
|
839 TCellRef cell = aRange.iFrom; |
|
840 TInt horzLineCorr=(iGridLay->IsHorizontalGridLines()) ? 1 : 0; |
|
841 TInt vertLineCorr=(iGridLay->IsVerticalGridLines()) ? 1 : 0; |
|
842 iGridCellImg->iGridLineFlags=0; |
|
843 if (horzLineCorr) |
|
844 iGridCellImg->iGridLineFlags|=CGridCellImg::EIsHorizontalGridLines; |
|
845 if (vertLineCorr) |
|
846 iGridCellImg->iGridLineFlags|=CGridCellImg::EIsVerticalGridLines; |
|
847 for (;cell.iRow<=endCell.iRow;cell.iRow++) |
|
848 { |
|
849 TInt xPos=aStartPoint.iX; |
|
850 rect.iTl.iX=xPos*EScaleOneToOne/aScaleFactor; |
|
851 yPos+=iGridLay->RowHeightInPixels(cell.iRow); |
|
852 rect.iBr.iY = yPos*EScaleOneToOne/aScaleFactor-vertLineCorr; |
|
853 cell.iCol=aRange.iFrom.iCol; |
|
854 if (iGridLay->IsColumnBursting()) |
|
855 { |
|
856 if (cell.iCol<=endCell.iCol) |
|
857 { |
|
858 xPos+=iGridLay->ColumnWidthInPixels(cell.iCol); |
|
859 rect.iBr.iX = xPos*EScaleOneToOne/aScaleFactor-horzLineCorr; |
|
860 TCellRef burstCell=cell; |
|
861 TInt burstLeft=CalcBurstLeftL(burstCell,aScaleFactor); |
|
862 DrawBurstingCellL(aGc,cell,rect,aClipRect,aScaleFactor,burstLeft,burstCell); |
|
863 burstLeft+=rect.Width()+horzLineCorr; |
|
864 rect.iTl.iX=rect.iBr.iX+horzLineCorr; |
|
865 for (cell.iCol++;cell.iCol<=endCell.iCol;cell.iCol++) |
|
866 { |
|
867 xPos+=iGridLay->ColumnWidthInPixels(cell.iCol); |
|
868 rect.iBr.iX = xPos*EScaleOneToOne/aScaleFactor-horzLineCorr; |
|
869 if (iGridCellImg->DoesCellContainDataL(cell)) |
|
870 { |
|
871 burstLeft=0; |
|
872 burstCell.iCol=cell.iCol; |
|
873 } |
|
874 DrawBurstingCellL(aGc,cell,rect,aClipRect,aScaleFactor,burstLeft,burstCell); |
|
875 burstLeft+=rect.Width()+horzLineCorr; |
|
876 rect.iTl.iX=rect.iBr.iX+horzLineCorr; |
|
877 } |
|
878 } |
|
879 } |
|
880 else |
|
881 { |
|
882 for (;cell.iCol<=endCell.iCol;cell.iCol++) |
|
883 { |
|
884 xPos+=iGridLay->ColumnWidthInPixels(cell.iCol); |
|
885 rect.iBr.iX = xPos*EScaleOneToOne/aScaleFactor-horzLineCorr; |
|
886 iGridCellImg->DrawL(aGc,cell,rect,aClipRect); |
|
887 rect.iTl.iX=rect.iBr.iX+horzLineCorr; |
|
888 } |
|
889 } |
|
890 rect.iTl.iY=rect.iBr.iY+vertLineCorr; |
|
891 } |
|
892 ResetGcToDefault(aGc); |
|
893 } |
|
894 |
|
895 void CGridImg::DrawBurstingCellL(CGraphicsContext* aGc,const TCellRef& aCell,const TRect& aRect,const TRect& aClipRect, |
|
896 TInt aScaleFactor,TInt aBurstLeft,const TCellRef& aBurstCell) const |
|
897 { |
|
898 TInt burstDataWidth=iGridCellImg->DataWidthInPixelsL(aBurstCell); |
|
899 if (burstDataWidth<=aBurstLeft) |
|
900 iGridCellImg->DrawL(aGc,aCell,aRect,aClipRect); |
|
901 else |
|
902 { |
|
903 TInt excessRight=burstDataWidth-aBurstLeft-aRect.Width(); |
|
904 iGridCellImg->SetBurstingData(aCell.iCol-aBurstCell.iCol,aBurstLeft, |
|
905 CalcBurstRightL(aCell,excessRight,aScaleFactor)); |
|
906 iGridCellImg->DrawL(aGc,aCell,aRect,aClipRect); |
|
907 iGridCellImg->SetBurstingData(); |
|
908 } |
|
909 } |
|
910 |
|
911 TInt CGridImg::CalcBurstLeftL(TCellRef& aBurstCell,TInt aScaleFactor) const |
|
912 { |
|
913 enum { EMaxNumberChecked = 20 }; |
|
914 const TInt limit=Max(aBurstCell.iCol-EMaxNumberChecked,iGridLay->GridRange().iFrom.iCol); |
|
915 TInt burstLeft=0; |
|
916 while (aBurstCell.iCol>limit && !iGridCellImg->DoesCellContainDataL(aBurstCell)) |
|
917 { |
|
918 burstLeft+=iGridLay->ColumnWidthInPixels(--aBurstCell.iCol); |
|
919 } |
|
920 return burstLeft*EScaleOneToOne/aScaleFactor; |
|
921 } |
|
922 |
|
923 TInt CGridImg::CalcBurstRightL(const TCellRef& aCell,TInt aExcessRight,TInt aScaleFactor) const |
|
924 { |
|
925 TInt limit=iGridLay->GridRange().iTo.iCol; |
|
926 TInt burstRight=0; |
|
927 TInt scaledBurstRight=0; |
|
928 for (TCellRef forwardCell(aCell.iRow,aCell.iCol+1);forwardCell.iCol<=limit;forwardCell.iCol++) |
|
929 { |
|
930 TInt width=iGridLay->ColumnWidthInPixels(forwardCell.iCol); |
|
931 if (iGridCellImg->DoesCellContainDataL(forwardCell) || scaledBurstRight>aExcessRight) |
|
932 { |
|
933 break; |
|
934 } |
|
935 burstRight+=width; |
|
936 scaledBurstRight=burstRight*EScaleOneToOne/aScaleFactor; |
|
937 } |
|
938 return scaledBurstRight; |
|
939 } |
|
940 |
|
941 EXPORT_C void CGridImg::DrawCellL(const TCellRef &aCell) const |
|
942 /** Draws the content of the specified cell. |
|
943 |
|
944 @param aCell The cell to be drawn. */ |
|
945 { |
|
946 TRect rect=PartialCellRectL(aCell,MainRect()); |
|
947 TRect clipRect; |
|
948 TBool isHorizontalTitleLine=iGridLay->IsHorizontalTitleLine(); |
|
949 TBool isVerticalTitleLine=iGridLay->IsVerticalTitleLine(); |
|
950 if (isHorizontalTitleLine && isVerticalTitleLine) |
|
951 { |
|
952 clipRect.SetRect(iTitlePoint,iMainPoint); |
|
953 rect.BoundingRect(PartialCellRectL(aCell,clipRect,ETitleRef,ETitleRef)); |
|
954 } |
|
955 if (isHorizontalTitleLine) |
|
956 { |
|
957 clipRect.SetRect(iMainPoint.iX,iTitlePoint.iY,iGridRect.iBr.iX,iMainPoint.iY); |
|
958 rect.BoundingRect(PartialCellRectL(aCell,clipRect,EMainRef,ETitleRef)); |
|
959 } |
|
960 if (isVerticalTitleLine) |
|
961 { |
|
962 clipRect.SetRect(iTitlePoint.iX,iMainPoint.iY,iMainPoint.iX,iGridRect.iBr.iY); |
|
963 rect.BoundingRect(PartialCellRectL(aCell,clipRect,ETitleRef,EMainRef)); |
|
964 } |
|
965 BeginRedrawAndDrawL(rect); |
|
966 } |
|
967 |
|
968 TRect CGridImg::PartialCellRectL(const TCellRef& aCell,const TRect& aClipRect, |
|
969 TRefPoint aXRef,TRefPoint aYRef) const |
|
970 { |
|
971 TRect rect; |
|
972 rect.iTl=RelativeCellToPoint(aCell,aXRef,aYRef); |
|
973 rect.iBr=rect.iTl+iGridLay->CellToPoint(aCell,aCell+TCellRef(1,1)); |
|
974 if (iGridLay->IsColumnBursting()) |
|
975 { |
|
976 TInt limit=iGridLay->GridRange().iTo.iCol; |
|
977 for (TCellRef forwardCell(aCell.iRow,aCell.iCol+1);rect.iBr.iX<iGridRect.iBr.iX && forwardCell.iCol<=limit;forwardCell.iCol++) |
|
978 { |
|
979 if (iGridCellImg->DoesCellContainDataL(forwardCell)) |
|
980 break; |
|
981 rect.iBr.iX+=iGridLay->ColumnWidthInPixels(forwardCell.iCol); |
|
982 } |
|
983 } |
|
984 rect.iTl-=TPoint(2,2); //For cell borders |
|
985 rect.Intersection(aClipRect); |
|
986 return rect; |
|
987 } |
|
988 |
|
989 EXPORT_C void CGridImg::DrawRangeL(const TRangeRef& aRange) const |
|
990 /** Draws the rectangle corresponding to the specified range. |
|
991 |
|
992 @param aRange The range to be drawn. */ |
|
993 { |
|
994 TRect rect=PartialRangeRect(aRange,MainRect()); |
|
995 TRect clipRect; |
|
996 TBool isHorizontalTitleLine=iGridLay->IsHorizontalTitleLine(); |
|
997 TBool isVerticalTitleLine=iGridLay->IsVerticalTitleLine(); |
|
998 if (isHorizontalTitleLine && isVerticalTitleLine) |
|
999 { |
|
1000 clipRect.SetRect(iTitlePoint,iMainPoint); |
|
1001 rect.BoundingRect(PartialRangeRect(aRange,clipRect,ETitleRef,ETitleRef)); |
|
1002 } |
|
1003 if (isHorizontalTitleLine) |
|
1004 { |
|
1005 clipRect.SetRect(iMainPoint.iX,iTitlePoint.iY,iGridRect.iBr.iX,iMainPoint.iY); |
|
1006 rect.BoundingRect(PartialRangeRect(aRange,clipRect,EMainRef,ETitleRef)); |
|
1007 } |
|
1008 if (isVerticalTitleLine) |
|
1009 { |
|
1010 clipRect.SetRect(iTitlePoint.iX,iMainPoint.iY,iMainPoint.iX,iGridRect.iBr.iY); |
|
1011 rect.BoundingRect(PartialRangeRect(aRange,clipRect,ETitleRef,EMainRef)); |
|
1012 } |
|
1013 BeginRedrawAndDrawL(rect); |
|
1014 } |
|
1015 |
|
1016 TRect CGridImg::PartialRangeRect(const TRangeRef& aRange,const TRect& aClipRect, |
|
1017 TRefPoint aXRef,TRefPoint aYRef) const |
|
1018 { |
|
1019 TRect rect; |
|
1020 rect.iTl=RelativeCellToPoint(aRange.iFrom,aXRef,aYRef); |
|
1021 rect.iBr=rect.iTl+iGridLay->CellToPoint(aRange.iFrom,aRange.iTo+TCellRef(1,1)); |
|
1022 if (iGridLay->IsColumnBursting()) |
|
1023 rect.iBr.iX=iGridRect.iBr.iX; |
|
1024 rect.iTl-=TPoint(2,2); //For cell borders |
|
1025 rect.Intersection(aClipRect); |
|
1026 return rect; |
|
1027 } |
|
1028 |
|
1029 EXPORT_C void CGridImg::DrawSelectedL() const |
|
1030 /** Draws the currently selected region. */ |
|
1031 { |
|
1032 TInt count=iSelected->Count(); |
|
1033 if (count==0) |
|
1034 DrawCellL(iCursorPos); |
|
1035 else if (count==1) |
|
1036 DrawRangeL((*iSelected)[0]); |
|
1037 else |
|
1038 BeginRedrawAndDrawL(); |
|
1039 } |
|
1040 |
|
1041 #if defined(__WINC__) |
|
1042 void CGridImg::HighlightMinRegionL(const TRegion& /*aOldRegion*/,const TRegion& /*aNewRegion*/) |
|
1043 {} |
|
1044 #else |
|
1045 |
|
1046 void CGridImg::HighlightMinRegionL(const TRegion& aOldRegion,const TRegion& aNewRegion) |
|
1047 // |
|
1048 // Highlights the minimum necessary region to get from the old to the new region |
|
1049 // |
|
1050 { |
|
1051 RRegion unionRegion; |
|
1052 unionRegion.Copy(aOldRegion); |
|
1053 unionRegion.Union(aNewRegion); |
|
1054 RRegion tempRegion; |
|
1055 tempRegion.Copy(aOldRegion); |
|
1056 tempRegion.Intersect(aNewRegion); |
|
1057 unionRegion.SubRegion(tempRegion); |
|
1058 tempRegion.Close(); |
|
1059 unionRegion.Tidy(); |
|
1060 if (unionRegion.CheckError()) |
|
1061 { |
|
1062 unionRegion.Close(); |
|
1063 User::Leave(KErrNoMemory); |
|
1064 } |
|
1065 CreateGc(iGc); |
|
1066 HighlightRegion(unionRegion); |
|
1067 DeleteGc(); |
|
1068 unionRegion.Close(); |
|
1069 } |
|
1070 #endif |
|
1071 |
|
1072 void CGridImg::HighlightRegion(const TRegion &aRegion) const |
|
1073 { |
|
1074 // |
|
1075 // Fills each of the rectangles in the passed region one by one |
|
1076 // |
|
1077 __ASSERT_DEBUG(iGcPtr!=NULL,Panic(EGridImgInvalidGC)); |
|
1078 TInt count=aRegion.Count(); |
|
1079 if (count) |
|
1080 { |
|
1081 iGcPtr->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
|
1082 iGcPtr->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1083 for (TInt ii=0;ii<count;ii++) |
|
1084 iGcPtr->DrawRect(aRegion[ii]); |
|
1085 iGcPtr->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1086 iGcPtr->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1087 } |
|
1088 } |
|
1089 |
|
1090 TPoint CGridImg::RelativeCellToPoint(const TCellRef& aCell, |
|
1091 TRefPoint aXRef,TRefPoint aYRef) const |
|
1092 { |
|
1093 TPoint ret; |
|
1094 ret.iX=(aXRef==ETitleRef) ? iGridLay->TitleColumnToXVal(aCell.iCol) : |
|
1095 iGridLay->ColumnToXVal(aCell.iCol); |
|
1096 ret.iY=(aYRef==ETitleRef) ? iGridLay->TitleRowToYVal(aCell.iRow) : |
|
1097 iGridLay->RowToYVal(aCell.iRow); |
|
1098 return ret; |
|
1099 } |
|
1100 |
|
1101 TCellRef CGridImg::RelativePointToCell(const TPoint& aPoint, |
|
1102 TRefPoint aXRef,TRefPoint aYRef) const |
|
1103 { |
|
1104 TCellRef ret; |
|
1105 ret.iCol=(aXRef==ETitleRef) ? iGridLay->XValToTitleColumn(aPoint.iX) : |
|
1106 iGridLay->XValToColumn(aPoint.iX); |
|
1107 ret.iRow=(aYRef==ETitleRef) ? iGridLay->YValToTitleRow(aPoint.iY) : |
|
1108 iGridLay->YValToRow(aPoint.iY); |
|
1109 return ret; |
|
1110 } |
|
1111 |
|
1112 void CGridImg::AppendPartialHighlightRegionL(TRegion& aRegion,const TRect& aClipRect, |
|
1113 TRefPoint aXRef,TRefPoint aYRef) const |
|
1114 // |
|
1115 // returns ETrue if there's an error in the region manipulation |
|
1116 { |
|
1117 TInt count=iSelected->Count(); |
|
1118 if (!count) |
|
1119 { |
|
1120 if (iGridLay->IsCursorVisible()) |
|
1121 { |
|
1122 if (iGridLay->IsCellOutOfGridRange(iCursorPos)) |
|
1123 return; |
|
1124 TRect cursor(RelativeCellToPoint(iCursorPos,aXRef,aYRef),TSize(0,0)); |
|
1125 cursor.iBr.iX+=iGridLay->ColumnWidthInPixels(iCursorPos.iCol); |
|
1126 cursor.iBr.iY+=iGridLay->RowHeightInPixels(iCursorPos.iRow); |
|
1127 |
|
1128 TRegionFix<4> region; |
|
1129 region.AddRect(TRect(cursor.iTl.iX-2,cursor.iTl.iY-2,cursor.iBr.iX+1,cursor.iTl.iY+1)); |
|
1130 region.AddRect(TRect(cursor.iTl.iX-2,cursor.iBr.iY-2,cursor.iBr.iX+1,cursor.iBr.iY+1)); |
|
1131 region.AddRect(TRect(cursor.iTl.iX-2,cursor.iTl.iY+1,cursor.iTl.iX+1,cursor.iBr.iY-2)); |
|
1132 region.AddRect(TRect(cursor.iBr.iX-2,cursor.iTl.iY+1,cursor.iBr.iX+1,cursor.iBr.iY-2)); |
|
1133 region.ClipRect(aClipRect); |
|
1134 aRegion.Union(region); |
|
1135 } |
|
1136 } |
|
1137 else if (iGridLay->IsHighlightVisible()) |
|
1138 { |
|
1139 for (TInt ii=0;ii<count;ii++) |
|
1140 { |
|
1141 TRangeRef range=(*iSelected)[ii]; |
|
1142 if (!iGridLay->LimitCell(range.iFrom)) |
|
1143 continue; |
|
1144 iGridLay->LimitCell(range.iTo); |
|
1145 TRect rect; |
|
1146 rect.iTl=RelativeCellToPoint(range.iFrom,aXRef,aYRef); |
|
1147 rect.iBr=RelativeCellToPoint(range.iTo+TCellRef(1,1),aXRef,aYRef); |
|
1148 rect.Resize(-1,-1); |
|
1149 rect.Shrink(1,1); |
|
1150 rect.Intersection(aClipRect); |
|
1151 if (iSelected->IsColSelected(range.iFrom.iCol,ii) && |
|
1152 (iTitlePoint.iY==iMainPoint.iY || aYRef==ETitleRef) && |
|
1153 !iGridLay->IsColumnSelectionDisabled()) |
|
1154 { |
|
1155 rect.iTl.iY=Min(rect.iTl.iY,iGridRect.iTl.iY+1); |
|
1156 } |
|
1157 if (iSelected->IsRowSelected(range.iFrom.iRow,ii) && |
|
1158 (iTitlePoint.iX==iMainPoint.iX || aXRef==ETitleRef) && |
|
1159 !iGridLay->IsRowSelectionDisabled()) |
|
1160 { |
|
1161 rect.iTl.iX=Min(rect.iTl.iX,iGridRect.iTl.iX+1); |
|
1162 } |
|
1163 aRegion.AddRect(rect); |
|
1164 } |
|
1165 if (iGridLay->IsCursorVisible()) |
|
1166 { |
|
1167 if (!iGridLay->IsCellOutOfGridRange(iAnchorPos)) |
|
1168 { |
|
1169 TRect anchorRect=(TRect(RelativeCellToPoint(iAnchorPos,aXRef,aYRef),TSize(0,0))); |
|
1170 anchorRect.iBr.iX+=iGridLay->ColumnWidthInPixels(iAnchorPos.iCol); |
|
1171 anchorRect.iBr.iY+=iGridLay->RowHeightInPixels(iAnchorPos.iRow); |
|
1172 anchorRect.Resize(-1,-1); |
|
1173 anchorRect.Shrink(2,2); |
|
1174 anchorRect.Intersection(aClipRect); |
|
1175 aRegion.SubRect(anchorRect); |
|
1176 } |
|
1177 } |
|
1178 } |
|
1179 if (aRegion.CheckError()) |
|
1180 User::Leave(KErrNoMemory); |
|
1181 } |
|
1182 |
|
1183 void CGridImg::AppendTotalHighlightRegionL(TRegion &aRegion) const |
|
1184 { |
|
1185 // |
|
1186 // Creates the total selected region by summing all the rectangles |
|
1187 // of the cursor or the highlighted regions (including the anchor) |
|
1188 // |
|
1189 TRect clipRect=MainRect(); |
|
1190 AppendPartialHighlightRegionL(aRegion,clipRect); |
|
1191 TBool isHorizontalTitleLine=iGridLay->IsHorizontalTitleLine(); |
|
1192 TBool isVerticalTitleLine=iGridLay->IsVerticalTitleLine(); |
|
1193 if (isHorizontalTitleLine && isVerticalTitleLine) |
|
1194 { |
|
1195 clipRect.SetRect(iTitlePoint,iMainPoint-TPoint(1,1)); |
|
1196 if (clipRect.IsNormalized()) |
|
1197 AppendPartialHighlightRegionL(aRegion,clipRect,ETitleRef,ETitleRef); |
|
1198 } |
|
1199 if (isHorizontalTitleLine) |
|
1200 { |
|
1201 clipRect.SetRect(iMainPoint.iX,iTitlePoint.iY,iGridRect.iBr.iX,iMainPoint.iY-1); |
|
1202 if (clipRect.IsNormalized()) |
|
1203 AppendPartialHighlightRegionL(aRegion,clipRect,EMainRef,ETitleRef); |
|
1204 } |
|
1205 if (isVerticalTitleLine) |
|
1206 { |
|
1207 clipRect.SetRect(iTitlePoint.iX,iMainPoint.iY,iMainPoint.iX-1,iGridRect.iBr.iY); |
|
1208 if (clipRect.IsNormalized()) |
|
1209 AppendPartialHighlightRegionL(aRegion,clipRect,ETitleRef,EMainRef); |
|
1210 } |
|
1211 } |
|
1212 |
|
1213 void CGridImg::RemoveRowLabelFromRegionL(TInt aRow,TRegion& aRegion) const |
|
1214 // |
|
1215 // Returns ETrue if error |
|
1216 { |
|
1217 TInt tlY=iGridLay->VisibleRowToYVal(aRow); |
|
1218 if (tlY<0) |
|
1219 return; // Not on screen |
|
1220 TRect rect(iGridRect.iTl.iX,tlY,iTitlePoint.iX,tlY+iGridLay->RowHeightInPixels(aRow)); |
|
1221 aRegion.SubRect(rect); |
|
1222 if (aRegion.CheckError()) |
|
1223 User::Leave(KErrNoMemory); |
|
1224 } |
|
1225 |
|
1226 void CGridImg::CleanupGc(TAny* aObject) |
|
1227 { |
|
1228 ((CGridImg*)aObject)->DeleteGc(); |
|
1229 } |
|
1230 |
|
1231 EXPORT_C void CGridImg::DrawL(CGraphicsContext* aGc) const |
|
1232 /** Draws the entire grid and its contents. |
|
1233 |
|
1234 @param aGc The graphics context to be used for drawing. */ |
|
1235 { |
|
1236 ((CGridImg*)this)->CreateGc(aGc); |
|
1237 iGcPtr->SetClippingRect(iGridRect); //Needed because of border round grid |
|
1238 ResetGcToDefault(iGcPtr); |
|
1239 CleanupStack::PushL(TCleanupItem(CleanupGc,(CGridImg*)this)); |
|
1240 DrawAllGridLabelsL(); |
|
1241 iGcPtr->Reset(); |
|
1242 if (iGridLay->IsAutoClearGridCells()) |
|
1243 //-> |
|
1244 TGridUtils::FillRect(iGcPtr, iGridLay->GridColors().iBackground, TRect(iTitlePoint,iGridRect.iBr)); |
|
1245 // TGridUtils::FillRect(iGcPtr,KRgbGridBackground,TRect(iTitlePoint,iGridRect.iBr)); |
|
1246 //-> |
|
1247 DrawAllGridLinesAndCellsL(); //Handles its own clipping |
|
1248 RRegion region; |
|
1249 CleanupClose<RRegion>::PushL(region); |
|
1250 AppendTotalHighlightRegionL(region); |
|
1251 CleanupStack::Pop(2); // region + gc cleanup |
|
1252 HighlightRegion(region); |
|
1253 region.Close(); |
|
1254 DrawVerticalTitleLine(); |
|
1255 DrawHorizontalTitleLine(); |
|
1256 ((CGridImg*)this)->DeleteGc(); |
|
1257 CONST_CAST(CGridImg*,this)->DrawResizingDragHiglights(iGridRect); |
|
1258 } |
|
1259 |
|
1260 #if !defined(__WINC__) |
|
1261 LOCAL_C void EndRedraw(TAny* aObject) |
|
1262 { |
|
1263 ((RWindow*)aObject)->EndRedraw(); |
|
1264 } |
|
1265 #endif |
|
1266 |
|
1267 void CGridImg::BeginRedrawAndDrawL() const |
|
1268 { |
|
1269 #if !defined(__WINC__) |
|
1270 iWin->Invalidate(); |
|
1271 iWin->BeginRedraw(); |
|
1272 CleanupStack::PushL(TCleanupItem(EndRedraw,iWin)); |
|
1273 DrawL(iGc); |
|
1274 CleanupStack::PopAndDestroy(); |
|
1275 #endif |
|
1276 } |
|
1277 |
|
1278 EXPORT_C void CGridImg::DrawL(CGraphicsContext* aGc,const TRect& aRect) const |
|
1279 /** Draws the grid and its contents that are visible within the specified |
|
1280 rectangle. |
|
1281 |
|
1282 @param aGc The graphics context to be used for drawing. |
|
1283 @param aRect Drawing of the grid is restricted to this rectangle. */ |
|
1284 { |
|
1285 if (aRect.Contains(iGridRect.iTl) && aRect.Contains(iGridRect.iBr)) |
|
1286 { |
|
1287 DrawL(aGc); |
|
1288 return; |
|
1289 } |
|
1290 ((CGridImg*)this)->CreateGc(aGc); |
|
1291 ResetGcToDefault(iGcPtr); |
|
1292 |
|
1293 TRangeRef titleRange=iGridLay->TitleRange(); |
|
1294 TBool isHorizontalTitleLine=iGridLay->IsHorizontalTitleLine(); |
|
1295 TBool isVerticalTitleLine=iGridLay->IsVerticalTitleLine(); |
|
1296 TRect clippingRect(iGridRect.iTl,iMainPoint); //Top left quarter of grid |
|
1297 CleanupStack::PushL(TCleanupItem(CleanupGc,(CGridImg*)this)); |
|
1298 if (aRect.Intersects(clippingRect)) |
|
1299 { |
|
1300 clippingRect.Intersection(aRect); |
|
1301 iGcPtr->SetClippingRect(clippingRect); |
|
1302 DrawTopLeftGridLabelL(); |
|
1303 if (isVerticalTitleLine) |
|
1304 DrawTopGridLabelsL(titleRange.iFrom.iCol,titleRange.iTo.iCol-1,ETitleRef); |
|
1305 if (isHorizontalTitleLine) |
|
1306 { |
|
1307 DrawSideGridLabelsL(titleRange.iFrom.iRow,titleRange.iTo.iRow,ETitleRef); |
|
1308 } |
|
1309 iGcPtr->Reset(); |
|
1310 if (isVerticalTitleLine && isHorizontalTitleLine) |
|
1311 { |
|
1312 clippingRect.SetRect(iTitlePoint,iMainPoint); |
|
1313 clippingRect.Intersection(aRect); |
|
1314 if (iGridLay->IsAutoClearGridCells()) |
|
1315 //-> |
|
1316 TGridUtils::FillRect(iGcPtr, iGridLay->GridColors().iBackground, clippingRect); |
|
1317 // TGridUtils::FillRect(iGcPtr,KRgbGridBackground,clippingRect); |
|
1318 //-> |
|
1319 DrawGridLinesAndCellsInRangeL(titleRange,clippingRect,ETitleRef,ETitleRef); |
|
1320 } |
|
1321 } |
|
1322 |
|
1323 TInt borderCorr=(iGridLay->IsEncroachingCellBorders()) ? 1 : 0; |
|
1324 TRangeRef range; |
|
1325 clippingRect.SetRect(iMainPoint.iX,iGridRect.iTl.iY,iGridRect.iBr.iX,iMainPoint.iY);//Top right quarter |
|
1326 if (aRect.Intersects(clippingRect)) |
|
1327 { |
|
1328 clippingRect.Intersection(aRect); |
|
1329 iGcPtr->SetClippingRect(clippingRect); |
|
1330 range.iFrom.iCol=iGridLay->XValToColumn(clippingRect.iTl.iX); |
|
1331 range.iTo.iCol=iGridLay->XValToColumn(clippingRect.iBr.iX+borderCorr); |
|
1332 DrawTopGridLabelsL(range.iFrom.iCol,range.iTo.iCol); |
|
1333 iGcPtr->Reset(); |
|
1334 if (isHorizontalTitleLine) |
|
1335 { |
|
1336 range.iFrom.iRow=titleRange.iFrom.iRow; |
|
1337 range.iTo.iRow=titleRange.iTo.iRow; |
|
1338 clippingRect.SetRect(iMainPoint.iX,iTitlePoint.iY,iGridRect.iBr.iX,iMainPoint.iY); |
|
1339 clippingRect.Intersection(aRect); |
|
1340 if (iGridLay->IsAutoClearGridCells()) |
|
1341 //-> |
|
1342 TGridUtils::FillRect(iGcPtr,iGridLay->GridColors().iBackground,clippingRect); |
|
1343 // TGridUtils::FillRect(iGcPtr,KRgbGridBackground,clippingRect); |
|
1344 //-> |
|
1345 DrawGridLinesAndCellsInRangeL(range,clippingRect,EMainRef,ETitleRef); |
|
1346 } |
|
1347 } |
|
1348 |
|
1349 clippingRect.SetRect(iGridRect.iTl.iX,iMainPoint.iY,iMainPoint.iX,iGridRect.iBr.iY);//Bottom left quarter |
|
1350 if (aRect.Intersects(clippingRect)) |
|
1351 { |
|
1352 clippingRect.Intersection(aRect); |
|
1353 iGcPtr->SetClippingRect(clippingRect); |
|
1354 range.iFrom.iRow=iGridLay->YValToRow(clippingRect.iTl.iY); |
|
1355 range.iTo.iRow=iGridLay->YValToRow(clippingRect.iBr.iY+borderCorr); |
|
1356 DrawSideGridLabelsL(range.iFrom.iRow,range.iTo.iRow); |
|
1357 iGcPtr->Reset(); |
|
1358 if (isVerticalTitleLine) |
|
1359 { |
|
1360 range.iFrom.iCol=titleRange.iFrom.iCol; |
|
1361 range.iTo.iCol=titleRange.iTo.iCol; |
|
1362 clippingRect.SetRect(iTitlePoint.iX,iMainPoint.iY,iMainPoint.iX,iGridRect.iBr.iY); |
|
1363 clippingRect.Intersection(aRect); |
|
1364 if (iGridLay->IsAutoClearGridCells()) |
|
1365 //-> |
|
1366 TGridUtils::FillRect(iGcPtr,iGridLay->GridColors().iBackground,clippingRect); |
|
1367 // TGridUtils::FillRect(iGcPtr,KRgbGridBackground,clippingRect); |
|
1368 //-> |
|
1369 DrawGridLinesAndCellsInRangeL(range,clippingRect,ETitleRef,EMainRef); |
|
1370 } |
|
1371 } |
|
1372 |
|
1373 clippingRect.SetRect(iMainPoint,iGridRect.iBr); //Bottom right(main) quarter of grid |
|
1374 if (aRect.Intersects(clippingRect)) |
|
1375 { |
|
1376 clippingRect.Intersection(aRect); |
|
1377 range.iFrom = iGridLay->PointToCell(clippingRect.iTl); |
|
1378 range.iTo = iGridLay->PointToCell(clippingRect.iBr+TPoint(borderCorr,borderCorr)); |
|
1379 if (iGridLay->IsAutoClearGridCells()) |
|
1380 //-> |
|
1381 TGridUtils::FillRect(iGcPtr,iGridLay->GridColors().iBackground,clippingRect); |
|
1382 // TGridUtils::FillRect(iGcPtr,KRgbGridBackground,clippingRect); |
|
1383 //-> |
|
1384 DrawGridLinesAndCellsInRangeL(range,clippingRect); |
|
1385 } |
|
1386 clippingRect=iGridRect; |
|
1387 clippingRect.Intersection(aRect); |
|
1388 iGcPtr->SetClippingRect(clippingRect); |
|
1389 RRegion region; |
|
1390 CleanupClose<RRegion>::PushL(region); |
|
1391 AppendTotalHighlightRegionL(region); |
|
1392 CleanupStack::Pop(2); // region + gc cleanup |
|
1393 HighlightRegion(region); |
|
1394 region.Close(); |
|
1395 DrawVerticalTitleLine(); |
|
1396 DrawHorizontalTitleLine(); |
|
1397 iGcPtr->CancelClippingRect(); |
|
1398 ((CGridImg*)this)->DeleteGc(); |
|
1399 CONST_CAST(CGridImg*,this)->DrawResizingDragHiglights(aRect); |
|
1400 } |
|
1401 |
|
1402 #if defined(__WINC__) |
|
1403 void CGridImg::BeginRedrawAndDrawL(const TRect& /*aRect*/) const |
|
1404 {} // shouldn't be called under WINC |
|
1405 #else |
|
1406 |
|
1407 void CGridImg::BeginRedrawAndDrawL(const TRect& aRect) const |
|
1408 { |
|
1409 iWin->Invalidate(aRect); |
|
1410 iWin->BeginRedraw(aRect); |
|
1411 CleanupStack::PushL(TCleanupItem(EndRedraw,iWin)); |
|
1412 DrawL(iGc,aRect); |
|
1413 CleanupStack::PopAndDestroy(); |
|
1414 } |
|
1415 #endif |
|
1416 |
|
1417 EXPORT_C void CGridImg::PrintGridLinesAndCellsInRangeL(CGraphicsContext* aPrinterGc,const TRangeRef& aRange, |
|
1418 TInt aScaleFactor) const |
|
1419 // |
|
1420 // Assumes aPrinterGc is active for drawing to |
|
1421 /** Prints the grid lines and cells in the specified range. |
|
1422 |
|
1423 @param aPrinterGc The printer graphics context. |
|
1424 @param aRange The cell range. |
|
1425 @param aScaleFactor The scale factor. A value of: 2, scales down by a half; |
|
1426 4, scales down by a quarter, etc. */ |
|
1427 { |
|
1428 __ASSERT_DEBUG(aPrinterGc!=NULL,Panic(EGridImgInvalidGC)); |
|
1429 |
|
1430 TRangeRef visRange=iGridLay->VisibleRange(); |
|
1431 TPoint endPoint=iGridLay->CellToPoint(visRange.iTo+TCellRef(1,1)); |
|
1432 TRect borderRect(iGridRect.iTl,endPoint); |
|
1433 TPoint titlePoint=iTitlePoint; |
|
1434 if (aScaleFactor!=EScaleOneToOne) |
|
1435 { |
|
1436 ScaleDown(borderRect.iTl,aScaleFactor); |
|
1437 ScaleDown(borderRect.iBr,aScaleFactor); |
|
1438 ScaleDown(titlePoint,aScaleFactor); |
|
1439 } |
|
1440 borderRect.iTl-=TPoint(1,1); |
|
1441 TPoint realTlPoint=iGridLay->CellToPoint(aRange.iFrom); |
|
1442 TBool doColumns=aRange.iTo.iCol>=aRange.iFrom.iCol; |
|
1443 TBool doRows=aRange.iTo.iRow>=aRange.iFrom.iRow; |
|
1444 TBool printBorderRect=EFalse; |
|
1445 if (iGridLay->IsPrintedLabels()) |
|
1446 { |
|
1447 TBool isSideLabels=iGridLay->IsSideLabels(); |
|
1448 TBool isTopLabels=iGridLay->IsTopLabels(); |
|
1449 if (isSideLabels && isTopLabels && aRange.iFrom==visRange.iFrom) // i.e. is top band |
|
1450 { |
|
1451 TRect rect(iGridRect.iTl,iTitlePoint); |
|
1452 ScaleDown(rect.iTl,aScaleFactor); |
|
1453 ScaleDown(rect.iBr,aScaleFactor); |
|
1454 rect.Resize(-1,-1); |
|
1455 //-> |
|
1456 // iGridLabelImg->DrawTopLeftLabelL(aPrinterGc,rect); |
|
1457 iGridLabelImg->DrawTopLeftLabelL(aPrinterGc, rect, iGridLay->GridColors().iBackground); |
|
1458 //-> |
|
1459 printBorderRect=ETrue; |
|
1460 } |
|
1461 if (isTopLabels && doColumns) |
|
1462 { |
|
1463 TInt realPos=realTlPoint.iX; |
|
1464 TRect line(realPos*EScaleOneToOne/aScaleFactor,borderRect.iTl.iY+1,0,titlePoint.iY-1); |
|
1465 for (TInt ii=aRange.iFrom.iCol;ii<aRange.iTo.iCol;ii++) |
|
1466 { |
|
1467 realPos+=iGridLay->ColumnWidthInPixels(ii); |
|
1468 line.iBr.iX=realPos*EScaleOneToOne/aScaleFactor-1; |
|
1469 iGridLabelImg->DrawColLabelL(aPrinterGc,ii,line); |
|
1470 line.iTl.iX=line.iBr.iX; |
|
1471 //-> |
|
1472 aPrinterGc->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
1473 // aPrinterGc->SetPenColor(KRgbGridLabelSeparators); |
|
1474 //-> |
|
1475 aPrinterGc->DrawLine(line.iTl,line.iBr); |
|
1476 line.iTl.iX++; |
|
1477 } |
|
1478 realPos+=iGridLay->ColumnWidthInPixels(aRange.iTo.iCol); |
|
1479 line.iBr.iX=realPos*EScaleOneToOne/aScaleFactor-1; |
|
1480 iGridLabelImg->DrawColLabelL(aPrinterGc,aRange.iTo.iCol,line); |
|
1481 //-> |
|
1482 aPrinterGc->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
1483 // aPrinterGc->SetPenColor(KRgbGridLabelSeparators); |
|
1484 //-> |
|
1485 aPrinterGc->DrawLine(TPoint(borderRect.iTl.iX,titlePoint.iY-1), |
|
1486 TPoint(borderRect.iBr.iX,titlePoint.iY-1)); |
|
1487 printBorderRect=ETrue; |
|
1488 } |
|
1489 if (isSideLabels && doRows) |
|
1490 { |
|
1491 TInt realPos=realTlPoint.iY; |
|
1492 TRect line(borderRect.iTl.iX+1,realPos*EScaleOneToOne/aScaleFactor,titlePoint.iX-1,0); |
|
1493 for (TInt ii=aRange.iFrom.iRow;ii<aRange.iTo.iRow;ii++) |
|
1494 { |
|
1495 realPos+=iGridLay->RowHeightInPixels(ii); |
|
1496 line.iBr.iY=realPos*EScaleOneToOne/aScaleFactor-1; |
|
1497 iGridLabelImg->DrawRowLabelL(aPrinterGc,ii,line); |
|
1498 line.iTl.iY=line.iBr.iY; |
|
1499 //-> |
|
1500 aPrinterGc->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
1501 // aPrinterGc->SetPenColor(KRgbGridLabelSeparators); |
|
1502 //-> |
|
1503 aPrinterGc->DrawLine(line.iTl,line.iBr); |
|
1504 line.iTl.iY++; |
|
1505 } |
|
1506 realPos+=iGridLay->RowHeightInPixels(aRange.iTo.iRow); |
|
1507 line.iBr.iY=realPos*EScaleOneToOne/aScaleFactor-1; |
|
1508 iGridLabelImg->DrawRowLabelL(aPrinterGc,aRange.iTo.iRow,line); |
|
1509 //-> |
|
1510 aPrinterGc->SetPenColor(iGridLay->GridColors().iLabelSeparators); |
|
1511 // aPrinterGc->SetPenColor(KRgbGridLabelSeparators); |
|
1512 //-> |
|
1513 aPrinterGc->DrawLine(TPoint(titlePoint.iX-1,borderRect.iTl.iY), |
|
1514 TPoint(titlePoint.iX-1,borderRect.iBr.iY)); |
|
1515 printBorderRect=ETrue; |
|
1516 } |
|
1517 } |
|
1518 |
|
1519 if (iGridLay->IsPrintedGridLines()) |
|
1520 { |
|
1521 //-> |
|
1522 // aPrinterGc->SetPenColor(KRgbGridForeground); // prints black not gray as on screen |
|
1523 aPrinterGc->SetPenColor(iGridLay->GridColors().iForeground); // prints black not gray as on screen |
|
1524 //-> |
|
1525 if (iGridLay->IsVerticalGridLines() && doColumns) |
|
1526 { |
|
1527 TInt realPos=realTlPoint.iX; |
|
1528 TRect line(0,titlePoint.iY,0,borderRect.iBr.iY-1); |
|
1529 for (TInt ii=aRange.iFrom.iCol;ii<aRange.iTo.iCol;ii++) |
|
1530 { |
|
1531 realPos+=iGridLay->ColumnWidthInPixels(ii); |
|
1532 line.iTl.iX=line.iBr.iX=realPos*EScaleOneToOne/aScaleFactor-1; |
|
1533 aPrinterGc->DrawLine(line.iTl,line.iBr); |
|
1534 } |
|
1535 printBorderRect=ETrue; |
|
1536 } |
|
1537 if (iGridLay->IsHorizontalGridLines() && doRows) |
|
1538 { |
|
1539 TInt realPos=realTlPoint.iY; |
|
1540 TRect line(titlePoint.iX,0,borderRect.iBr.iX-1,0); |
|
1541 for (TInt ii=aRange.iFrom.iRow;ii<aRange.iTo.iRow;ii++) |
|
1542 { |
|
1543 realPos+=iGridLay->RowHeightInPixels(ii); |
|
1544 line.iTl.iY=line.iBr.iY=realPos*EScaleOneToOne/aScaleFactor-1; |
|
1545 aPrinterGc->DrawLine(line.iTl,line.iBr); |
|
1546 } |
|
1547 printBorderRect=ETrue; |
|
1548 } |
|
1549 } |
|
1550 if (printBorderRect) |
|
1551 { |
|
1552 //-> |
|
1553 // aPrinterGc->SetPenColor(KRgbGridForeground); |
|
1554 aPrinterGc->SetPenColor(iGridLay->GridColors().iForeground); |
|
1555 //-> |
|
1556 |
|
1557 aPrinterGc->DrawRect(borderRect); |
|
1558 } |
|
1559 if (doRows && doColumns) |
|
1560 DrawCellsToGcL(aPrinterGc,aRange,TRect(titlePoint,borderRect.iBr),realTlPoint,aScaleFactor); |
|
1561 } |
|
1562 |
|
1563 void CGridImg::ScaleDown(TPoint& aPoint,TInt aScaleFactor) const |
|
1564 { |
|
1565 aPoint.iX=aPoint.iX*EScaleOneToOne/aScaleFactor; |
|
1566 aPoint.iY=aPoint.iY*EScaleOneToOne/aScaleFactor; |
|
1567 } |
|
1568 |
|
1569 void CGridImg::ResetGcToDefault(CGraphicsContext* aGc) const |
|
1570 // |
|
1571 // Should be called if the gc may have changed outside CGridImg since the private |
|
1572 // functions assume these settings. |
|
1573 { |
|
1574 aGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
1575 aGc->SetPenSize(TSize(1,1)); |
|
1576 aGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1577 } |
|
1578 |
|
1579 EXPORT_C void CGridImg::SetCursorPosL(const TCellRef& aCursorPos) |
|
1580 /** Sets the new position of the cursor. |
|
1581 |
|
1582 This is the proposed position that the cursor would occupy after a keypress. |
|
1583 |
|
1584 @param aCursorPos The cell reference of the new cursor position. */ |
|
1585 { |
|
1586 iNewCursorPos=aCursorPos; |
|
1587 if (!iGridLay->LimitCell(iNewCursorPos)) |
|
1588 { |
|
1589 iNewCursorPos=iCursorPos; |
|
1590 return; |
|
1591 } |
|
1592 DrawCursorOrRegionL(EIsAbsoluteMove); |
|
1593 if (iCursorMoveCallBack) |
|
1594 iCursorMoveCallBack->HandleCursorMoveL(); |
|
1595 } |
|
1596 |
|
1597 EXPORT_C void CGridImg::SetAnchorPosL(const TCellRef& aAnchorPos) |
|
1598 /** Sets the cursor's anchor position. |
|
1599 |
|
1600 Note that the cursor's anchor position is unchanged if the specified position |
|
1601 lies outside the currently selected region. |
|
1602 |
|
1603 @param aAnchorPos The cell reference of the cursor's anchor position. */ |
|
1604 { |
|
1605 if (!iSelected->IsCellSelected(iAnchorPos)) |
|
1606 return; //Can't have the anchor outside the selection region |
|
1607 RRegion oldRegion; |
|
1608 CleanupClose<RRegion>::PushL(oldRegion); |
|
1609 AppendTotalHighlightRegionL(oldRegion); |
|
1610 iAnchorPos=aAnchorPos; |
|
1611 if (!iGridLay->LimitCell(iAnchorPos)) |
|
1612 { |
|
1613 oldRegion.Close(); |
|
1614 CleanupStack::Pop(); |
|
1615 return; |
|
1616 } |
|
1617 iNewCursorPos=iCursorPos=iAnchorPos; |
|
1618 HighlightNewRegionFromOldL(oldRegion); |
|
1619 oldRegion.Close(); |
|
1620 CleanupStack::Pop(); |
|
1621 if (iCursorMoveCallBack) |
|
1622 iCursorMoveCallBack->HandleCursorMoveL(); |
|
1623 } |
|
1624 |
|
1625 EXPORT_C void CGridImg::MoveCursorL(TMoveDirectionAndAmount aCursorMove,TUint aSelectState) |
|
1626 /** Moves the cursor to the specified position. |
|
1627 |
|
1628 The screen is scrolled as necessary. |
|
1629 |
|
1630 @param aCursorMove Defines the direction and the amount by which the cursor |
|
1631 is to be moved. |
|
1632 @param aSelectState Flag. If set to EIsWithSelect, then the cursor may become |
|
1633 part of the selected region. */ |
|
1634 { |
|
1635 TUint flagList=aSelectState&EIsWithSelect; //Filters out any other components |
|
1636 if (!flagList && iSelected->Count()) |
|
1637 iNewCursorPos = iAnchorPos; |
|
1638 TCellRef oldPos=iNewCursorPos; |
|
1639 TMoveDirectionAndAmount pageScroll=EMoveNone; |
|
1640 TRangeRef visRange=iGridLay->VisibleRange(); |
|
1641 TCellRef cellToExpose=visRange.iFrom; |
|
1642 TBool doExposeCol=EFalse; |
|
1643 TInt relCursorPos; |
|
1644 TInt amount; |
|
1645 switch (aCursorMove) |
|
1646 { |
|
1647 case EMoveRowUp: |
|
1648 iGridLay->StepRowBackward(--iNewCursorPos.iRow); |
|
1649 break; |
|
1650 case EMoveRowDown: |
|
1651 iGridLay->StepRowForward(++iNewCursorPos.iRow); |
|
1652 break; |
|
1653 case EMoveColumnLeft: |
|
1654 if (iGridLay->IsRowPermanentlySelected()) |
|
1655 { |
|
1656 --cellToExpose.iCol; |
|
1657 doExposeCol=ETrue; |
|
1658 } |
|
1659 else |
|
1660 iGridLay->StepColumnBackward(--iNewCursorPos.iCol); |
|
1661 break; |
|
1662 case EMoveColumnRight: |
|
1663 if (iGridLay->IsRowPermanentlySelected()) |
|
1664 { |
|
1665 cellToExpose.iCol=visRange.iTo.iCol; |
|
1666 if (iGridLay->IsVisibleToColumnFullyVisible() || visRange.iFrom.iCol==visRange.iTo.iCol) |
|
1667 cellToExpose.iCol++; |
|
1668 doExposeCol=ETrue; |
|
1669 } |
|
1670 else |
|
1671 iGridLay->StepColumnForward(++iNewCursorPos.iCol); |
|
1672 break; |
|
1673 case EMovePageUp: |
|
1674 relCursorPos=iGridLay->RowToYVal(visRange.iFrom.iRow,iNewCursorPos.iRow); |
|
1675 pageScroll=EMovePageDown; |
|
1676 amount=iGridLay->CalcVisibleFromRowAfterPageScroll(pageScroll); |
|
1677 if (amount!=visRange.iFrom.iRow) |
|
1678 { |
|
1679 TInt newCursorRow=iGridLay->YValToNearestRow(amount,relCursorPos); |
|
1680 if (newCursorRow>=iNewCursorPos.iRow) |
|
1681 iGridLay->StepRowBackward(--iNewCursorPos.iRow); |
|
1682 else |
|
1683 iNewCursorPos.iRow=newCursorRow; |
|
1684 } |
|
1685 else |
|
1686 iNewCursorPos.iRow=Min(visRange.iFrom.iRow,iNewCursorPos.iRow-1); |
|
1687 iGridLay->LimitRowToVisible(iNewCursorPos.iRow); |
|
1688 break; |
|
1689 case EMovePageDown: |
|
1690 relCursorPos=iGridLay->RowToYVal(visRange.iFrom.iRow,iNewCursorPos.iRow); |
|
1691 pageScroll=EMovePageUp; |
|
1692 amount=iGridLay->CalcVisibleFromRowAfterPageScroll(pageScroll); |
|
1693 if (amount!=visRange.iFrom.iRow) |
|
1694 { |
|
1695 TInt newCursorRow=iGridLay->YValToNearestRow(amount,relCursorPos); |
|
1696 if (newCursorRow<=iNewCursorPos.iRow) |
|
1697 iGridLay->StepRowForward(++iNewCursorPos.iRow); |
|
1698 else |
|
1699 iNewCursorPos.iRow=newCursorRow; |
|
1700 } |
|
1701 else |
|
1702 { |
|
1703 TInt corr=iGridLay->IsVisibleToRowFullyVisible() ? 0 : 1; |
|
1704 iNewCursorPos.iRow=Max(visRange.iTo.iRow-corr,iNewCursorPos.iRow+1); |
|
1705 } |
|
1706 break; |
|
1707 case EMovePageLeft: |
|
1708 relCursorPos=iGridLay->ColumnToXVal(visRange.iFrom.iCol,iNewCursorPos.iCol); |
|
1709 pageScroll=EMovePageRight; |
|
1710 amount=iGridLay->CalcVisibleFromColumnAfterPageScroll(pageScroll); |
|
1711 if (amount!=visRange.iFrom.iCol) |
|
1712 { |
|
1713 TInt newCursorColumn=iGridLay->XValToNearestColumn(amount,relCursorPos); |
|
1714 if (newCursorColumn>=iNewCursorPos.iCol) |
|
1715 iGridLay->StepColumnBackward(--iNewCursorPos.iCol); |
|
1716 else |
|
1717 iNewCursorPos.iCol=newCursorColumn; |
|
1718 } |
|
1719 else |
|
1720 iNewCursorPos.iCol=Min(visRange.iFrom.iCol,iNewCursorPos.iCol-1); |
|
1721 iGridLay->LimitColumnToVisible(iNewCursorPos.iCol); |
|
1722 break; |
|
1723 case EMovePageRight: |
|
1724 relCursorPos=iGridLay->ColumnToXVal(visRange.iFrom.iCol,iNewCursorPos.iCol); |
|
1725 pageScroll=EMovePageLeft; |
|
1726 amount=iGridLay->CalcVisibleFromColumnAfterPageScroll(pageScroll); |
|
1727 if (amount!=visRange.iFrom.iCol) |
|
1728 { |
|
1729 TInt newCursorColumn=iGridLay->XValToNearestColumn(amount,relCursorPos); |
|
1730 if (newCursorColumn<=iNewCursorPos.iCol) |
|
1731 iGridLay->StepColumnForward(++iNewCursorPos.iCol); |
|
1732 else |
|
1733 iNewCursorPos.iCol=newCursorColumn; |
|
1734 } |
|
1735 else |
|
1736 { |
|
1737 TInt corr=iGridLay->IsVisibleToColumnFullyVisible() ? 0 : 1; |
|
1738 iNewCursorPos.iCol=Max(visRange.iTo.iCol-corr,iNewCursorPos.iCol+1); |
|
1739 } |
|
1740 break; |
|
1741 case EMoveRowStart: |
|
1742 case EMoveColumnStart: |
|
1743 case EMoveHome: |
|
1744 if (aCursorMove!=EMoveColumnStart) |
|
1745 { |
|
1746 if (iGridLay->IsRowPermanentlySelected()) |
|
1747 { |
|
1748 cellToExpose.iCol=iGridLay->MinVisibleFromColumn(); |
|
1749 doExposeCol=ETrue; |
|
1750 } |
|
1751 else |
|
1752 { |
|
1753 iNewCursorPos.iCol=iGridLay->MinVisibleFromColumn(); |
|
1754 iGridLay->StepColumnForward(iNewCursorPos.iCol); |
|
1755 } |
|
1756 } |
|
1757 if (aCursorMove!=EMoveRowStart) |
|
1758 { |
|
1759 iNewCursorPos.iRow=(iGridLay->IsIndefiniteRowBoundaries()) |
|
1760 ? -KMaxTInt : iGridLay->MinVisibleFromRow(); |
|
1761 iGridLay->StepRowForward(iNewCursorPos.iRow); |
|
1762 } |
|
1763 break; |
|
1764 case EMoveRowEnd: |
|
1765 case EMoveColumnEnd: |
|
1766 case EMoveEnd: |
|
1767 { |
|
1768 TCellRef fromCell=iGridLay->GridRange().iFrom; |
|
1769 if (aCursorMove!=EMoveColumnEnd) |
|
1770 { |
|
1771 TInt lastCol=fromCell.iCol+iGridLay->ColumnExtent()-1; |
|
1772 if (iGridLay->IsRowPermanentlySelected()) |
|
1773 { |
|
1774 cellToExpose.iCol=lastCol; |
|
1775 doExposeCol=ETrue; |
|
1776 } |
|
1777 else |
|
1778 { |
|
1779 iNewCursorPos.iCol=lastCol; |
|
1780 iGridLay->StepColumnBackward(iNewCursorPos.iCol); |
|
1781 } |
|
1782 } |
|
1783 if (aCursorMove!=EMoveRowEnd) |
|
1784 { |
|
1785 iNewCursorPos.iRow=(iGridLay->IsIndefiniteRowBoundaries()) |
|
1786 ? KMaxTInt : fromCell.iRow+iGridLay->RowExtent()-1; |
|
1787 iGridLay->StepRowBackward(iNewCursorPos.iRow); |
|
1788 } |
|
1789 } |
|
1790 break; |
|
1791 default: |
|
1792 break; |
|
1793 } |
|
1794 iGridLay->LimitCell(iNewCursorPos); |
|
1795 if (oldPos==iNewCursorPos) |
|
1796 flagList|=EIsAtBoundary; |
|
1797 oldPos=iNewCursorPos; |
|
1798 DrawCursorOrRegionL(flagList); |
|
1799 TPoint offset; |
|
1800 if (pageScroll!=EMoveNone) |
|
1801 offset=iGridLay->PageScroll(pageScroll); |
|
1802 cellToExpose.iRow=iCursorPos.iRow; |
|
1803 if (!doExposeCol) |
|
1804 cellToExpose.iCol=iCursorPos.iCol; |
|
1805 if (iGridLay->IsCellOutOfVisibleRange(cellToExpose)) |
|
1806 { |
|
1807 visRange=iGridLay->VisibleRange(); |
|
1808 visRange.iTo.Offset(-1,-1); |
|
1809 iGridLay->StepRowBackward(visRange.iTo.iRow); |
|
1810 iGridLay->StepColumnBackward(visRange.iTo.iCol); |
|
1811 if (iSelected->IsColSelectedLastIndex(cellToExpose.iCol) && |
|
1812 !iGridLay->IsColumnSelectionDisabled()) |
|
1813 { |
|
1814 cellToExpose.iRow=visRange.iFrom.iRow; |
|
1815 } |
|
1816 if ((iSelected->IsRowSelectedLastIndex(cellToExpose.iRow) || iGridLay->IsRowPermanentlySelected()) |
|
1817 && !doExposeCol && !iGridLay->IsRowSelectionDisabled()) |
|
1818 { |
|
1819 cellToExpose.iCol=visRange.iFrom.iCol; |
|
1820 } |
|
1821 offset+=iGridLay->ExposeCell(cellToExpose); |
|
1822 } |
|
1823 ScrollL(offset); |
|
1824 if (iCursorMoveCallBack) |
|
1825 iCursorMoveCallBack->HandleCursorMoveL(); |
|
1826 } |
|
1827 |
|
1828 EXPORT_C void CGridImg::SetCursorWithPointerL(const TPoint &aPoint,TUint aFlagList) |
|
1829 /** Moves the cursor to an absolute position. |
|
1830 |
|
1831 @param aPoint The absolute position. |
|
1832 @param aFlagList Flag. Can be set to EIsWithDrag. */ |
|
1833 { |
|
1834 TRangeRef visRange(iGridLay->VisibleRange()); |
|
1835 TCellRef cellToExpose = visRange.iFrom; |
|
1836 if (iGridLay->IsVerticalTitleLine()) |
|
1837 { |
|
1838 if (aPoint.iX<iMainPoint.iX) |
|
1839 { |
|
1840 if (!(aFlagList&EIsWithDrag)) |
|
1841 iXRefPoint=ETitleRef; |
|
1842 } |
|
1843 else |
|
1844 { |
|
1845 if (iXRefPoint==ETitleRef && !iSelected->IsRowSelectedLastIndex(iCursorPos.iRow) |
|
1846 && (aFlagList&EIsWithDrag)) |
|
1847 { |
|
1848 cellToExpose.iCol=iGridLay->TitleRange().iTo.iCol; |
|
1849 } |
|
1850 iXRefPoint=EMainRef; |
|
1851 } |
|
1852 } |
|
1853 else |
|
1854 iXRefPoint=EMainRef; |
|
1855 if (iGridLay->IsHorizontalTitleLine()) |
|
1856 { |
|
1857 if (aPoint.iY<iMainPoint.iY) |
|
1858 { |
|
1859 if (!(aFlagList&EIsWithDrag)) |
|
1860 iYRefPoint=ETitleRef; |
|
1861 } |
|
1862 else |
|
1863 { |
|
1864 if (iYRefPoint==ETitleRef && !iSelected->IsColSelectedLastIndex(iCursorPos.iCol) |
|
1865 && (aFlagList&EIsWithDrag)) |
|
1866 { |
|
1867 cellToExpose.iRow=iGridLay->TitleRange().iTo.iRow; |
|
1868 } |
|
1869 iYRefPoint=EMainRef; |
|
1870 } |
|
1871 } |
|
1872 else |
|
1873 iYRefPoint=EMainRef; |
|
1874 TPoint offset=iGridLay->ExposeCellToTopLeft(cellToExpose); |
|
1875 ScrollL(offset); |
|
1876 |
|
1877 if (aPoint.iY<iTitlePoint.iY) |
|
1878 { |
|
1879 if (iDragFlags&EIsLabelDraggingIgnored && aFlagList&EIsWithDrag) |
|
1880 return; |
|
1881 if (!(aFlagList&EIsWithDrag) || iSelected->IsColSelectedLastIndex(iCursorPos.iCol)) |
|
1882 { |
|
1883 if (iGridLay->IsColumnSelectionDisabled()) |
|
1884 { |
|
1885 iDragFlags|=EIsLabelDraggingIgnored; |
|
1886 return; |
|
1887 } |
|
1888 aFlagList|=EIsColumnSelected; |
|
1889 iDragFlags=iDragFlags&~EIsLabelDraggingIgnored; |
|
1890 } |
|
1891 } |
|
1892 if (aPoint.iX<iTitlePoint.iX) |
|
1893 { |
|
1894 if (iDragFlags&EIsLabelDraggingIgnored && aFlagList&EIsWithDrag) |
|
1895 return; |
|
1896 if (!(aFlagList&EIsWithDrag) || iSelected->IsRowSelectedLastIndex(iCursorPos.iRow)) |
|
1897 { |
|
1898 if (iGridLay->IsRowPermanentlySelected() && !(aFlagList&EIsWithDrag)) |
|
1899 iDragFlags|=EIsSidewaysScrollIgnored; |
|
1900 else if (iGridLay->IsRowSelectionDisabled()) |
|
1901 { |
|
1902 iDragFlags|=EIsLabelDraggingIgnored; |
|
1903 return; |
|
1904 } |
|
1905 else |
|
1906 aFlagList|=EIsRowSelected; |
|
1907 iDragFlags=iDragFlags&~EIsLabelDraggingIgnored; |
|
1908 } |
|
1909 } |
|
1910 else |
|
1911 { |
|
1912 iDragFlags=iDragFlags&~EIsSidewaysScrollIgnored; |
|
1913 if (aPoint.iY>=iTitlePoint.iY) //ie not on the labels |
|
1914 iDragFlags=iDragFlags&~EIsLabelDraggingIgnored; |
|
1915 } |
|
1916 iNewCursorPos=RelativePointToCell(aPoint,iXRefPoint,iYRefPoint); |
|
1917 iGridLay->LimitCell(iNewCursorPos); |
|
1918 if (iCursorPos==iNewCursorPos && !iSelected->Count() && |
|
1919 !(aFlagList&(EIsRowSelected|EIsColumnSelected|EIsWithControl))) |
|
1920 { |
|
1921 return; // Don't need to do anything in this case |
|
1922 } |
|
1923 |
|
1924 cellToExpose = iNewCursorPos; |
|
1925 if (iSelected->IsColSelectedLastIndex(iCursorPos.iCol) && (aFlagList&EIsWithDrag)) |
|
1926 cellToExpose.iRow = visRange.iFrom.iRow; |
|
1927 if ((iSelected->IsRowSelectedLastIndex(iCursorPos.iRow) && (aFlagList&EIsWithDrag) |
|
1928 && !iGridLay->IsRowPermanentlySelected()) || iDragFlags&EIsSidewaysScrollIgnored) |
|
1929 { |
|
1930 cellToExpose.iCol = visRange.iFrom.iCol; |
|
1931 } |
|
1932 TBool expose = EFalse; |
|
1933 if (aFlagList&EIsWithDrag) |
|
1934 { |
|
1935 if ((aPoint.iX<iMainPoint.iX && iXRefPoint==EMainRef) || aPoint.iX>iGridRect.iBr.iX) |
|
1936 expose=ETrue; |
|
1937 else |
|
1938 cellToExpose.iCol=visRange.iFrom.iCol; |
|
1939 if ((aPoint.iY<iMainPoint.iY && iYRefPoint==EMainRef) || aPoint.iY>iGridRect.iBr.iY) |
|
1940 expose=ETrue; |
|
1941 else |
|
1942 cellToExpose.iRow=visRange.iFrom.iRow; |
|
1943 } |
|
1944 |
|
1945 aFlagList|=EIsAbsoluteMove; |
|
1946 DrawCursorOrRegionL(aFlagList); |
|
1947 if (expose) |
|
1948 { |
|
1949 offset=iGridLay->ExposeCell(cellToExpose); |
|
1950 ScrollL(offset); |
|
1951 } |
|
1952 if (iCursorMoveCallBack) |
|
1953 iCursorMoveCallBack->HandleCursorMoveL(); |
|
1954 } |
|
1955 |
|
1956 EXPORT_C void CGridImg::ResetSelectedL() |
|
1957 /** Clears the selected region. */ |
|
1958 { |
|
1959 if (!iSelected->Count()) |
|
1960 return; |
|
1961 RRegion oldRegion; |
|
1962 CleanupClose<RRegion>::PushL(oldRegion); |
|
1963 AppendTotalHighlightRegionL(oldRegion); |
|
1964 iNewCursorPos=iCursorPos=iAnchorPos; |
|
1965 iSelected->Reset(); |
|
1966 HighlightNewRegionFromOldL(oldRegion); |
|
1967 oldRegion.Close(); |
|
1968 CleanupStack::Pop(); |
|
1969 if (iCursorMoveCallBack) |
|
1970 iCursorMoveCallBack->HandleCursorMoveL(); |
|
1971 } |
|
1972 |
|
1973 EXPORT_C void CGridImg::AddRangeToSelectedL(const TRangeRef& aRange,TSelectType aType) |
|
1974 /** Adds the specified range to, or replaces, the currently selected region. |
|
1975 |
|
1976 The range can be added to the existing selected region or it can replace the |
|
1977 existing selected region. |
|
1978 |
|
1979 @param aRange The range to be added. |
|
1980 @param aType Indicates whether the existing selected region is to be reset |
|
1981 (i.e. emptied) before adding the new range. */ |
|
1982 { |
|
1983 RRegion oldRegion; |
|
1984 CleanupClose<RRegion>::PushL(oldRegion); |
|
1985 AppendTotalHighlightRegionL(oldRegion); |
|
1986 if (aType==ESelectOverwrite) |
|
1987 iSelected->Reset(); |
|
1988 iNewCursorPos=iCursorPos=aRange.iTo; |
|
1989 iAnchorPos=aRange.iFrom; |
|
1990 iSelected->AddCellRangeL(aRange); |
|
1991 HighlightNewRegionFromOldL(oldRegion); |
|
1992 oldRegion.Close(); |
|
1993 CleanupStack::Pop(); |
|
1994 if (iCursorMoveCallBack) |
|
1995 iCursorMoveCallBack->HandleCursorMoveL(); |
|
1996 } |
|
1997 |
|
1998 EXPORT_C void CGridImg::AddRegionToSelectedL(const CArrayFix<TRangeRef>* aCellRegion,TSelectType aType) |
|
1999 /** Adds the specified region to, or replaces, the currently selected region. |
|
2000 |
|
2001 The region can be added to the existing selected region, or it can replace |
|
2002 the existing selected region. |
|
2003 |
|
2004 @param aCellRegion A set of ranges that form the region to be added. |
|
2005 @param aType Indicates whether the existing selected region is to be reset |
|
2006 (i.e. emptied) before adding the new region. */ |
|
2007 { |
|
2008 RRegion oldRegion; |
|
2009 CleanupClose<RRegion>::PushL(oldRegion); |
|
2010 AppendTotalHighlightRegionL(oldRegion); |
|
2011 if (aType==ESelectOverwrite) |
|
2012 iSelected->Reset(); |
|
2013 TInt count=aCellRegion->Count(); |
|
2014 if (!count) |
|
2015 iNewCursorPos=iCursorPos=iAnchorPos=iGridLay->GridRange().iFrom; |
|
2016 else |
|
2017 { |
|
2018 TRangeRef lastRange=(*aCellRegion)[count-1]; |
|
2019 iNewCursorPos=iCursorPos=lastRange.iTo; |
|
2020 iAnchorPos=lastRange.iFrom; |
|
2021 for (TInt ii=0;ii<count;ii++) |
|
2022 iSelected->AddCellRangeL((*aCellRegion)[ii]); |
|
2023 } |
|
2024 HighlightNewRegionFromOldL(oldRegion); |
|
2025 oldRegion.Close(); |
|
2026 CleanupStack::Pop(); |
|
2027 if (iCursorMoveCallBack) |
|
2028 iCursorMoveCallBack->HandleCursorMoveL(); |
|
2029 } |
|
2030 |
|
2031 EXPORT_C void CGridImg::AddRowToSelectedL(TInt aRow,TSelectType aType) |
|
2032 /** Adds a row to, or replaces, the currently selected region. |
|
2033 |
|
2034 The row can be added to the existing selected region, or it can replace the |
|
2035 existing selected region. |
|
2036 |
|
2037 @param aRow The row to be added. |
|
2038 @param aType Indicates whether the existing selected region is to be reset |
|
2039 (i.e. emptied) before adding the new region. */ |
|
2040 { |
|
2041 RRegion oldRegion; |
|
2042 CleanupClose<RRegion>::PushL(oldRegion); |
|
2043 AppendTotalHighlightRegionL(oldRegion); |
|
2044 if (aType==ESelectOverwrite) |
|
2045 iSelected->Reset(); |
|
2046 iAnchorPos.iRow=iCursorPos.iRow=iNewCursorPos.iRow=aRow; |
|
2047 iAnchorPos.iCol=iGridLay->VisibleRange().iFrom.iCol; |
|
2048 iNewCursorPos.iCol=iCursorPos.iCol=iGridLay->GridRange().iTo.iCol; |
|
2049 iSelected->AddRowL(aRow); |
|
2050 HighlightNewRegionFromOldL(oldRegion); |
|
2051 oldRegion.Close(); |
|
2052 CleanupStack::Pop(); |
|
2053 if (iCursorMoveCallBack) |
|
2054 iCursorMoveCallBack->HandleCursorMoveL(); |
|
2055 } |
|
2056 |
|
2057 EXPORT_C void CGridImg::AddColToSelectedL(TInt aCol,TSelectType aType) |
|
2058 /** Adds a column to, or replaces, the currently selected region. |
|
2059 |
|
2060 The column can be added to the existing selected region, or it can replace |
|
2061 the existing selected region. |
|
2062 |
|
2063 @param aCol The column to be added. |
|
2064 @param aType Indicates whether the existing selected region is to be reset |
|
2065 (i.e. emptied) before adding the new region. */ |
|
2066 { |
|
2067 RRegion oldRegion; |
|
2068 CleanupClose<RRegion>::PushL(oldRegion); |
|
2069 AppendTotalHighlightRegionL(oldRegion); |
|
2070 if (aType==ESelectOverwrite) |
|
2071 iSelected->Reset(); |
|
2072 iAnchorPos.iCol=iCursorPos.iCol=iNewCursorPos.iCol=aCol; |
|
2073 iAnchorPos.iRow=iGridLay->VisibleRange().iFrom.iRow; |
|
2074 iNewCursorPos.iRow=iCursorPos.iRow=iGridLay->GridRange().iTo.iRow; |
|
2075 iSelected->AddColL(aCol); |
|
2076 HighlightNewRegionFromOldL(oldRegion); |
|
2077 oldRegion.Close(); |
|
2078 CleanupStack::Pop(); |
|
2079 if (iCursorMoveCallBack) |
|
2080 iCursorMoveCallBack->HandleCursorMoveL(); |
|
2081 } |
|
2082 |
|
2083 void CGridImg::HighlightNewRegionFromOldL(const TRegion& aOldRegion) |
|
2084 // |
|
2085 // returns ETrue if there's an error |
|
2086 { |
|
2087 RRegion newRegion; |
|
2088 CleanupClose<RRegion>::PushL(newRegion); |
|
2089 AppendTotalHighlightRegionL(newRegion); |
|
2090 HighlightMinRegionL(aOldRegion,newRegion); |
|
2091 CleanupStack::Pop(); |
|
2092 newRegion.Close(); |
|
2093 } |
|
2094 |
|
2095 EXPORT_C void CGridImg::CheckSideLabelWidthAndScrollL() |
|
2096 /** Checks the side label width and, if changed, scrolls the screen. */ |
|
2097 { |
|
2098 TInt offset=CheckSideLabelWidth(); |
|
2099 #if !defined(__WINC__) |
|
2100 if (offset) |
|
2101 { |
|
2102 TRect rect(iGridRect.iTl.iX,iGridRect.iTl.iY,iTitlePoint.iX-1,iGridRect.iBr.iY); |
|
2103 iWin->Scroll(iGridRect,TPoint(offset,0)); |
|
2104 BeginRedrawAndDrawL(rect); |
|
2105 if (offset<0) |
|
2106 { |
|
2107 rect.SetRect(iGridRect.iBr.iX+offset,iGridRect.iTl.iY,iGridRect.iBr.iX,iGridRect.iBr.iY); |
|
2108 BeginRedrawAndDrawL(rect); |
|
2109 } |
|
2110 } |
|
2111 #endif |
|
2112 } |
|
2113 |
|
2114 EXPORT_C TInt CGridImg::CheckSideLabelWidth() |
|
2115 /** Checks whether there has been a change in the width of the side label. |
|
2116 |
|
2117 @return The difference between the new width and the old width (new width |
|
2118 - old width). */ |
|
2119 { |
|
2120 if (iGridLay->IsSideLabels()) |
|
2121 { |
|
2122 TInt oldWidth=iTitlePoint.iX-iGridRect.iTl.iX; |
|
2123 TInt newWidth=SideLabelWidthInPixels(); |
|
2124 if (oldWidth!=newWidth) |
|
2125 { |
|
2126 ResetReferencePoints(); |
|
2127 iGridLay->ResetVisibleToCell(); |
|
2128 return (newWidth-oldWidth); |
|
2129 } |
|
2130 } |
|
2131 return 0; |
|
2132 } |
|
2133 |
|
2134 EXPORT_C TInt CGridImg::SideLabelWidthInPixels() const |
|
2135 /** Gets the width of the side label. |
|
2136 |
|
2137 @return The width of the side label, in pixels. */ |
|
2138 { |
|
2139 if (iGridLabelImg==NULL) |
|
2140 return 0; |
|
2141 TRangeRef visRange=iGridLay->VisibleRange(); |
|
2142 if (!iGridLay->LimitRow(visRange.iFrom.iRow)) |
|
2143 return 0; |
|
2144 return iGridLabelImg->SideLabelWidthInPixels(visRange.iFrom.iRow,visRange.iTo.iRow); |
|
2145 } |
|
2146 |
|
2147 EXPORT_C TInt CGridImg::MaxSideLabelWidthInPixels() const |
|
2148 /** Gets the maximum width of the side label. |
|
2149 |
|
2150 @return The maximum width of the side label, in pixels. */ |
|
2151 { |
|
2152 if (iGridLabelImg==NULL) |
|
2153 return 0; |
|
2154 TInt firstRow; |
|
2155 if (!iGridLay->RequestRow(-KMaxTInt,firstRow)) |
|
2156 return 0; |
|
2157 return iGridLabelImg->SideLabelWidthInPixels(firstRow,firstRow+iGridLay->RowExtent()-1); |
|
2158 } |
|
2159 |
|
2160 EXPORT_C TInt CGridImg::TopLabelHeightInPixels() const |
|
2161 /** Gets the height of the top labels. |
|
2162 |
|
2163 @return The height of the top labels, in pixels. */ |
|
2164 { |
|
2165 if (iGridLabelImg==NULL) |
|
2166 return 0; |
|
2167 return iGridLabelImg->TopLabelHeightInPixels(); |
|
2168 } |
|
2169 |
|
2170 #if defined(__WINC__) |
|
2171 |
|
2172 // All these functions are inappropriate under WINC |
|
2173 EXPORT_C void CGridImg::FinishLabelDragL() |
|
2174 {} |
|
2175 |
|
2176 EXPORT_C TBool CGridImg::StartLabelDrag(const TPoint& /*aPoint*/) |
|
2177 { return EFalse; } |
|
2178 |
|
2179 TBool CGridImg::ScanColumnsForDrag(TInt /*aFromColumn*/,TInt /*aToColumn*/,TInt /*aPointerPos*/,TInt& /*aPrevious*/,TInt& /*aCurrent*/) |
|
2180 { return EFalse; } |
|
2181 |
|
2182 TBool CGridImg::ScanRowsForDrag(TInt /*aFromRow*/,TInt /*aToRow*/,TInt /*aPointerPos*/,TInt& /*aPrevious*/,TInt& /*aCurrent*/) |
|
2183 { return EFalse; } |
|
2184 |
|
2185 EXPORT_C TBool CGridImg::UpdateLabelDrag(const TPoint& /*aPoint*/) |
|
2186 { return EFalse; } |
|
2187 |
|
2188 void CGridImg::DrawArrowsToInMemoryBitmap(TArrows /*aArrows*/) |
|
2189 {} |
|
2190 |
|
2191 void CGridImg::DrawDraggingHighlight(const TRect /*aLine*/,TDragDraw /*aDragDraw*/) |
|
2192 {} |
|
2193 |
|
2194 EXPORT_C void CGridImg::ScrollL(const TPoint& /*aOffset*/) |
|
2195 {} |
|
2196 #else |
|
2197 |
|
2198 EXPORT_C void CGridImg::FinishLabelDragL() |
|
2199 /** Deals with the end of a drag operation. |
|
2200 |
|
2201 Typically, the function is called whan handling a pointer event in a control. |
|
2202 |
|
2203 The function removes the dotted drag line indicating a drag operation, and, |
|
2204 if necessary, updates the column width/row height, and then scrolls and redraws |
|
2205 the necessary regions. |
|
2206 |
|
2207 @see StartLabelDrag() */ |
|
2208 { |
|
2209 // |
|
2210 // Erases the two dotted drag lines if necessary, updates the column/row width/height then scrolls |
|
2211 // and redraws the necessary regions. The relevant member variables are also set to zero. |
|
2212 // |
|
2213 if (iDragDim == ENoDrag) |
|
2214 return; |
|
2215 TRect line1 = iGridRect; |
|
2216 TRect line2 = iGridRect; |
|
2217 TInt oldValue; |
|
2218 TInt prevDragPos; |
|
2219 TRangeRef titleRange=iGridLay->TitleRange(); |
|
2220 if (iDragDim == EXDrag) |
|
2221 { |
|
2222 prevDragPos = ((iGridLay->IsVerticalTitleLine() && iDragLabel<=titleRange.iTo.iCol) |
|
2223 ? iGridLay->TitleColumnToXVal(iDragLabel) : iGridLay->ColumnToXVal(iDragLabel))-1; |
|
2224 line1.iTl.iX = line1.iBr.iX = prevDragPos; |
|
2225 line2.iTl.iX = line2.iBr.iX = iCurrentDragPos; |
|
2226 oldValue = iGridLay->ColumnWidthInPixels(iDragLabel); |
|
2227 } |
|
2228 else |
|
2229 { |
|
2230 prevDragPos = ((iGridLay->IsHorizontalTitleLine() && iDragLabel<=titleRange.iTo.iRow) |
|
2231 ? iGridLay->TitleRowToYVal(iDragLabel) : iGridLay->RowToYVal(iDragLabel))-1; |
|
2232 line1.iTl.iY = line1.iBr.iY = prevDragPos; |
|
2233 line2.iTl.iY = line2.iBr.iY = iCurrentDragPos; |
|
2234 oldValue = iGridLay->RowHeightInPixels(iDragLabel); |
|
2235 } |
|
2236 CreateGc(iGc); |
|
2237 iGc->SetClippingRect(iGridRect); |
|
2238 DrawDraggingHighlight(line1,EDragDrawWithoutBitmap); |
|
2239 DrawDraggingHighlight(line2,EDragDrawWithBitmap); |
|
2240 delete iDragBmp; |
|
2241 iDragBmp=NULL; |
|
2242 DeleteGc(); |
|
2243 iCurrentDragPos = Max(iCurrentDragPos,prevDragPos); |
|
2244 TInt newValue = iCurrentDragPos-prevDragPos; |
|
2245 TInt minValue=(iDragDim==EXDrag) ? iGridLay->MinColumnWidthInPixels() : iGridLay->MinRowHeightInPixels(); |
|
2246 newValue=Max(newValue,minValue); |
|
2247 if (oldValue!=newValue) |
|
2248 { |
|
2249 TRect validRect=iGridRect; |
|
2250 TRect scrollRect=iGridRect; |
|
2251 TPoint offset; |
|
2252 TBool doScroll=EFalse; |
|
2253 TBool newPagination=EFalse; |
|
2254 TBool clearPagination=EFalse; |
|
2255 if (iGridLay->IsPaginated()) |
|
2256 { |
|
2257 if (!iGridLay->IsAutoPagination()) |
|
2258 clearPagination=ETrue; |
|
2259 newPagination=ETrue; |
|
2260 } |
|
2261 if (iDragDim==EXDrag) |
|
2262 { |
|
2263 if (iGridLay->IsUniformColumnWidth() || (iSelected->IsRangeSelected(iGridLay->GridRange()) |
|
2264 && !iGridLay->IsColumnSelectionDisabled())) |
|
2265 { |
|
2266 if (newValue==0) |
|
2267 goto DragEnd; |
|
2268 validRect.iTl.iX=iTitlePoint.iX; |
|
2269 iGridLay->SetDefaultColumnWidthInPixels(newValue); |
|
2270 iGridLay->SetColumnWidthsToDefault(); |
|
2271 } |
|
2272 else if (iSelected->IsColSelected(iDragLabel) && !iGridLay->IsColumnSelectionDisabled()) |
|
2273 { |
|
2274 validRect.iTl.iX=iTitlePoint.iX; |
|
2275 TInt count=iSelected->Count(); |
|
2276 for (TInt ii=0;ii<count;ii++) |
|
2277 { |
|
2278 TRangeRef range=(*iSelected)[ii]; |
|
2279 if (iSelected->IsColSelected(range.iFrom.iCol,ii)) |
|
2280 { |
|
2281 if ((range.iTo.iCol-range.iFrom.iCol)>CGridLay::EMaxArrayChanges) |
|
2282 continue; |
|
2283 for (;range.iFrom.iCol<=range.iTo.iCol;range.iFrom.iCol++) |
|
2284 iGridLay->SetColumnWidthInPixelsL(range.iFrom.iCol,newValue); |
|
2285 } |
|
2286 } |
|
2287 } |
|
2288 else |
|
2289 { |
|
2290 validRect.iTl.iX = (clearPagination) ? iTitlePoint.iX : |
|
2291 Max(prevDragPos-1,iTitlePoint.iX); |
|
2292 if (!iGridLay->IsColumnBursting() && !newPagination) |
|
2293 { |
|
2294 doScroll=ETrue; |
|
2295 validRect.iBr.iX = iCurrentDragPos+2; |
|
2296 scrollRect.iTl.iX=Max(Min(prevDragPos+oldValue+2,iCurrentDragPos+1),iTitlePoint.iX); |
|
2297 offset.iX = newValue-oldValue; |
|
2298 } |
|
2299 iGridLay->SetColumnWidthInPixelsL(iDragLabel,newValue); |
|
2300 } |
|
2301 } |
|
2302 else |
|
2303 { |
|
2304 if (iGridLay->IsUniformRowHeight() || (iSelected->IsRangeSelected(iGridLay->GridRange()) |
|
2305 && !iGridLay->IsRowSelectionDisabled())) |
|
2306 { |
|
2307 if (newValue==0) |
|
2308 goto DragEnd; |
|
2309 validRect.iTl.iY=iTitlePoint.iY; |
|
2310 iGridLay->SetDefaultRowHeightInPixels(newValue); |
|
2311 iGridLay->SetRowHeightsToDefault(); |
|
2312 } |
|
2313 else if (iSelected->IsRowSelected(iDragLabel) && !iGridLay->IsRowSelectionDisabled()) |
|
2314 { |
|
2315 validRect.iTl.iY=iTitlePoint.iY; |
|
2316 TInt count=iSelected->Count(); |
|
2317 for (TInt ii=0;ii<count;ii++) |
|
2318 { |
|
2319 TRangeRef range=(*iSelected)[ii]; |
|
2320 if (iSelected->IsRowSelected(range.iFrom.iRow,ii)) |
|
2321 { |
|
2322 if ((range.iTo.iRow-range.iFrom.iRow)>CGridLay::EMaxArrayChanges) |
|
2323 continue; |
|
2324 for (;range.iFrom.iRow<=range.iTo.iRow;range.iFrom.iRow++) |
|
2325 iGridLay->SetRowHeightInPixelsL(range.iFrom.iRow,newValue); |
|
2326 } |
|
2327 } |
|
2328 } |
|
2329 else |
|
2330 { |
|
2331 validRect.iTl.iY = (clearPagination) ? iTitlePoint.iY : |
|
2332 Max(prevDragPos-1,iTitlePoint.iY); |
|
2333 if (!newPagination) |
|
2334 { |
|
2335 doScroll=ETrue; |
|
2336 validRect.iBr.iY = iCurrentDragPos+2; |
|
2337 scrollRect.iTl.iY=Max(Min(prevDragPos+oldValue+2,iCurrentDragPos+1),iTitlePoint.iY); |
|
2338 offset.iY = newValue-oldValue; |
|
2339 } |
|
2340 iGridLay->SetRowHeightInPixelsL(iDragLabel,newValue); |
|
2341 } |
|
2342 } |
|
2343 iGridLay->NotifyPaginationOutOfDateL(); |
|
2344 if (doScroll) |
|
2345 iWin->Scroll(scrollRect,offset); |
|
2346 validRect.Intersection(iGridRect); |
|
2347 BeginRedrawAndDrawL(validRect); |
|
2348 if ((offset.iX<0 && !iGridLay->IsColumnBursting()) || offset.iY<0) |
|
2349 { |
|
2350 if (offset.iX<0) |
|
2351 { |
|
2352 validRect.iBr.iX = iGridRect.iBr.iX; |
|
2353 validRect.iTl.iX = validRect.iBr.iX+offset.iX; |
|
2354 } |
|
2355 else |
|
2356 { |
|
2357 validRect.iBr.iY = iGridRect.iBr.iY; |
|
2358 validRect.iTl.iY = validRect.iBr.iY+offset.iY; |
|
2359 } |
|
2360 BeginRedrawAndDrawL(validRect); |
|
2361 } |
|
2362 CheckSideLabelWidthAndScrollL(); |
|
2363 if (!newValue && !iSelected->Count()) |
|
2364 { |
|
2365 if (iDragDim==EXDrag) |
|
2366 { |
|
2367 if (iDragLabel==iCursorPos.iCol) |
|
2368 MoveCursorL(EMoveColumnRight,!EIsWithSelect); //2nd param=0 |
|
2369 } |
|
2370 else |
|
2371 { |
|
2372 if (iDragLabel==iCursorPos.iRow) |
|
2373 MoveCursorL(EMoveRowDown,!EIsWithSelect); |
|
2374 } |
|
2375 } |
|
2376 } |
|
2377 DragEnd: |
|
2378 iCurrentDragPos = iDragLabel = iDragDiff = 0; |
|
2379 iDragDim = ENoDrag; |
|
2380 } |
|
2381 |
|
2382 EXPORT_C TBool CGridImg::StartLabelResize(TBool aIsColumnLabel, TInt aIndex) |
|
2383 /** Begins the resizing of a column or a row. |
|
2384 |
|
2385 @param aIsColumnLabel Indicates whether a column or row is to be resized: |
|
2386 specify ETrue for a column; specify EFalse for a row. |
|
2387 @param aIndex Identifes the row or column to be resized. This value increases |
|
2388 from left to right for a column, and from top to bottom for a row. |
|
2389 @return True, if resizing has begun; false otherwise. */ |
|
2390 { |
|
2391 TInt widthOrHeight=0; |
|
2392 TRect line1 = iGridRect; |
|
2393 TRect line2 = iGridRect; |
|
2394 TRangeRef visibleRange=iGridLay->VisibleRange(); |
|
2395 iDragDim=ENoDrag; |
|
2396 if(aIsColumnLabel && aIndex>=visibleRange.iFrom.iCol && aIndex<visibleRange.iTo.iCol |
|
2397 && !iGridLay->IsTopLabelDragDisabled()) |
|
2398 { |
|
2399 iDragLabel=aIndex; |
|
2400 iDragDim = EXDrag; |
|
2401 line1.iTl.iX=line1.iBr.iX=iGridLay->ColumnToXVal(aIndex)-1; |
|
2402 widthOrHeight=iGridLay->ColumnWidthInPixels(aIndex); |
|
2403 iCurrentDragPos=line2.iTl.iX=line2.iBr.iX=line1.iTl.iX+widthOrHeight; |
|
2404 } |
|
2405 else if(!aIsColumnLabel && aIndex>=visibleRange.iFrom.iRow && |
|
2406 aIndex<visibleRange.iTo.iRow && !iGridLay->IsSideLabelDragDisabled()) |
|
2407 { |
|
2408 iDragLabel=aIndex; |
|
2409 iDragDim = EYDrag; |
|
2410 line1.iTl.iY=line1.iBr.iY=iGridLay->RowToYVal(aIndex)-1; |
|
2411 widthOrHeight=iGridLay->RowHeightInPixels(aIndex); |
|
2412 iCurrentDragPos=line2.iTl.iY=line2.iBr.iY=line1.iTl.iY+widthOrHeight; |
|
2413 } |
|
2414 if(iDragDim!=ENoDrag) |
|
2415 { |
|
2416 TArrows arrows=(widthOrHeight==0? ESecondArrowOnly : EBothArrows); |
|
2417 DrawArrowsToInMemoryBitmap(arrows); |
|
2418 TRect invalid = TRect(line1.iTl,line2.iBr); |
|
2419 if(iDragDim==EXDrag) |
|
2420 { |
|
2421 invalid.iTl.iX-=2; |
|
2422 invalid.iBr.iX+=KArrowLength+KArrowSeparation; |
|
2423 } |
|
2424 else |
|
2425 { |
|
2426 invalid.iTl.iY-=2; |
|
2427 invalid.iBr.iY+=KArrowLength+KArrowSeparation; |
|
2428 } |
|
2429 iWin->Invalidate(invalid); |
|
2430 iDrawResizeLines=ETrue; |
|
2431 return ETrue; |
|
2432 } |
|
2433 else |
|
2434 return EFalse; |
|
2435 } |
|
2436 |
|
2437 void CGridImg::DrawResizingDragHiglights(const TRect& aRect) |
|
2438 { |
|
2439 if(iDrawResizeLines) |
|
2440 { |
|
2441 TRect line1 = iGridRect; |
|
2442 TRect line2 = iGridRect; |
|
2443 if(iDragDim==EXDrag) |
|
2444 { |
|
2445 line1.iTl.iX=line1.iBr.iX=iGridLay->ColumnToXVal(iDragLabel)-1; |
|
2446 line2.iTl.iX=line2.iBr.iX=iCurrentDragPos; |
|
2447 } |
|
2448 else if(iDragDim==EYDrag) |
|
2449 { |
|
2450 line1.iTl.iY=line1.iBr.iY=iGridLay->RowToYVal(iDragLabel)-1; |
|
2451 line2.iTl.iY=line2.iBr.iY=iCurrentDragPos; |
|
2452 } |
|
2453 CreateGc(iGc); |
|
2454 TRect clip=aRect; |
|
2455 clip.Intersection(iGridRect); |
|
2456 iGc->SetClippingRect(clip); |
|
2457 DrawDraggingHighlight(line1,EDragDrawWithoutBitmap); |
|
2458 DrawDraggingHighlight(line2,EDragDrawWithBitmap); |
|
2459 DeleteGc(); |
|
2460 } |
|
2461 } |
|
2462 |
|
2463 EXPORT_C TBool CGridImg::UpdateLabelResize(TInt aDelta) |
|
2464 /** Changes the size of the row or column currently being resized. |
|
2465 |
|
2466 @param aDelta The amount, in pixels, by which the size of the row or column |
|
2467 is being changed. |
|
2468 @return True, if a row or column is being resized; false, otherwise. */ |
|
2469 { |
|
2470 if(iDragDim==ENoDrag) |
|
2471 return EFalse; |
|
2472 TRect line1 = iGridRect; |
|
2473 TRect line2 = iGridRect; |
|
2474 if (iDragDim == EXDrag) |
|
2475 { |
|
2476 TInt left=iGridLay->ColumnToXVal(iDragLabel); |
|
2477 line1.iTl.iX = line1.iBr.iX = iCurrentDragPos; |
|
2478 line2.iTl.iX = line2.iBr.iX = iCurrentDragPos = |
|
2479 Max(left,Min(iCurrentDragPos+aDelta,iGridRect.iBr.iX)); |
|
2480 } |
|
2481 else |
|
2482 { |
|
2483 TInt top=iGridLay->RowToYVal(iDragLabel); |
|
2484 line1.iTl.iY = line1.iBr.iY = iCurrentDragPos; |
|
2485 line2.iTl.iY = line2.iBr.iY = iCurrentDragPos = |
|
2486 Max(top,Min(iCurrentDragPos+aDelta,iGridRect.iBr.iY)); |
|
2487 } |
|
2488 if (line1!=line2) |
|
2489 { |
|
2490 CreateGc(iGc); |
|
2491 iGc->SetClippingRect(iGridRect); |
|
2492 DrawDraggingHighlight(line1,EDragDrawWithBitmap); |
|
2493 DrawDraggingHighlight(line2,EDragDrawWithBitmap); |
|
2494 DeleteGc(); |
|
2495 } |
|
2496 return ETrue; |
|
2497 } |
|
2498 |
|
2499 EXPORT_C void CGridImg::FinishLabelResizeL(TBool aResize) |
|
2500 /** Completes the resizing of a row or column. |
|
2501 |
|
2502 @param aResize ETrue, to complete the resizing of the row or column; EFalse, |
|
2503 if the row or column is to retain its original size. */ |
|
2504 { |
|
2505 iDrawResizeLines=EFalse; |
|
2506 if(iDragDim!=ENoDrag && aResize) |
|
2507 { |
|
2508 FinishLabelDragL(); |
|
2509 } |
|
2510 else if (iDragDim!=ENoDrag && !aResize) |
|
2511 { |
|
2512 TRect line1 = iGridRect; |
|
2513 TRect line2 = iGridRect; |
|
2514 if (iDragDim == EXDrag) |
|
2515 { |
|
2516 line1.iTl.iX = line1.iBr.iX = iCurrentDragPos; |
|
2517 line2.iTl.iX = line2.iBr.iX = iGridLay->ColumnToXVal(iDragLabel)-1; |
|
2518 } |
|
2519 else |
|
2520 { |
|
2521 line1.iTl.iY = line1.iBr.iY = iCurrentDragPos; |
|
2522 line2.iTl.iY = line2.iBr.iY = iGridLay->RowToYVal(iDragLabel)-1; |
|
2523 } |
|
2524 CreateGc(iGc); |
|
2525 iGc->SetClippingRect(iGridRect); |
|
2526 DrawDraggingHighlight(line1,EDragDrawWithBitmap); |
|
2527 DrawDraggingHighlight(line2,EDragDrawWithoutBitmap); |
|
2528 DeleteGc(); |
|
2529 } |
|
2530 } |
|
2531 |
|
2532 EXPORT_C TBool CGridImg::StartLabelDrag(const TPoint& aPoint) |
|
2533 /** Deals with the start of a drag operation. |
|
2534 |
|
2535 Typically, the function is called whan handling a pointer event in a control. |
|
2536 |
|
2537 The function checks that the pointer event is within 10 pixels of the boundary |
|
2538 between label cells, and draws a dotted line along the row or column boundary |
|
2539 together with pairs of arrows on either side of that line, and prepares for |
|
2540 the continuation or end of a drag operation on the boundary separating a row |
|
2541 or a column (to expand or contract that row or column). |
|
2542 |
|
2543 The dotted line is a visual indication that a drag operation is in progress. |
|
2544 |
|
2545 @param aPoint The position of the pointer event. |
|
2546 @return True, if the pointer event marks the start of a drag operation, and |
|
2547 dragging is permitted; false otherwise. */ |
|
2548 { |
|
2549 TBool action = EFalse; |
|
2550 TRect line1 = iGridRect; |
|
2551 TRect line2 = iGridRect; |
|
2552 TRangeRef titleRange=iGridLay->TitleRange(); |
|
2553 TRangeRef visibleRange=iGridLay->VisibleRange(); |
|
2554 TArrows arrows = EBothArrows; |
|
2555 if (aPoint.iY<iTitlePoint.iY-1 && !iGridLay->IsTopLabelDragDisabled()) |
|
2556 { |
|
2557 TInt previous = iTitlePoint.iX-1; |
|
2558 TInt current=0; |
|
2559 if (iGridLay->IsVerticalTitleLine()) |
|
2560 action = ScanColumnsForDrag(titleRange.iFrom.iCol,titleRange.iTo.iCol,aPoint.iX,previous,current); |
|
2561 if (!action) |
|
2562 action = ScanColumnsForDrag(visibleRange.iFrom.iCol,visibleRange.iTo.iCol,aPoint.iX,previous,current); |
|
2563 if (action) |
|
2564 { |
|
2565 line1.iTl.iX = line1.iBr.iX = previous; |
|
2566 line2.iTl.iX = line2.iBr.iX = iCurrentDragPos = current; |
|
2567 if (previous==current) |
|
2568 arrows=ESecondArrowOnly; |
|
2569 iDragDiff = aPoint.iX - current; |
|
2570 iDragDim = EXDrag; |
|
2571 } |
|
2572 } |
|
2573 else if (aPoint.iX<iTitlePoint.iX-1 && !iGridLay->IsSideLabelDragDisabled()) |
|
2574 { |
|
2575 TInt previous = iTitlePoint.iY-1; |
|
2576 TInt current=0; |
|
2577 if (iGridLay->IsHorizontalTitleLine()) |
|
2578 action = ScanRowsForDrag(titleRange.iFrom.iRow,titleRange.iTo.iRow,aPoint.iY,previous,current); |
|
2579 if (!action) |
|
2580 action = ScanRowsForDrag(visibleRange.iFrom.iRow,visibleRange.iTo.iRow,aPoint.iY,previous,current); |
|
2581 if (action) |
|
2582 { |
|
2583 line1.iTl.iY = line1.iBr.iY = previous; |
|
2584 line2.iTl.iY = line2.iBr.iY = iCurrentDragPos = current; |
|
2585 if (previous==current) |
|
2586 arrows=ESecondArrowOnly; |
|
2587 iDragDiff = aPoint.iY - current; |
|
2588 iDragDim = EYDrag; |
|
2589 } |
|
2590 } |
|
2591 if (action) |
|
2592 { |
|
2593 DrawArrowsToInMemoryBitmap(arrows); |
|
2594 CreateGc(iGc); |
|
2595 iGc->SetClippingRect(iGridRect); |
|
2596 DrawDraggingHighlight(line1,EDragDrawWithoutBitmap); |
|
2597 DrawDraggingHighlight(line2,EDragDrawWithBitmap); |
|
2598 DeleteGc(); |
|
2599 } |
|
2600 return action; |
|
2601 } |
|
2602 |
|
2603 const TInt KDragFactor = 5; |
|
2604 const TInt KMaxPenToLabel = 10; |
|
2605 const TInt KMinDraggingLength = 10; |
|
2606 |
|
2607 TBool CGridImg::ScanColumnsForDrag(TInt aFromColumn,TInt aToColumn,TInt aPointerPos,TInt& aPrevious,TInt& aCurrent) |
|
2608 { |
|
2609 TInt ii=aFromColumn; |
|
2610 if (!iGridLay->ColumnWidthInPixels(ii-1)) |
|
2611 --ii; |
|
2612 TInt width=iGridLay->ColumnWidthInPixels(ii++); |
|
2613 aCurrent=aPrevious+width; |
|
2614 TInt currentPenToLabel=(width>=KMinDraggingLength) ? Min(width/KDragFactor,(TInt)KMaxPenToLabel) : 0; |
|
2615 for (;ii<=aToColumn && aCurrent<iGridRect.iBr.iX;ii++) |
|
2616 { |
|
2617 iGridLay->StepColumnForward(ii); |
|
2618 width=iGridLay->ColumnWidthInPixels(ii); |
|
2619 TInt next=aCurrent+width; |
|
2620 TInt nextPenToLabel=(width>=KMinDraggingLength) ? Min(width/KDragFactor,(TInt)KMaxPenToLabel) : 0; |
|
2621 if (aPointerPos>aCurrent-currentPenToLabel && aPointerPos>Min(aPrevious+currentPenToLabel,aCurrent-1) |
|
2622 && aPointerPos<aCurrent+nextPenToLabel && aPointerPos<Max(next-nextPenToLabel,aCurrent)) |
|
2623 { |
|
2624 iDragLabel=ii-1; |
|
2625 if (aPointerPos<aCurrent) |
|
2626 iGridLay->StepColumnBackward(iDragLabel); |
|
2627 else if (iGridLay->ColumnWidthInPixels(iDragLabel)==0) |
|
2628 aPrevious=aCurrent; // reopen zero width column |
|
2629 return ETrue; |
|
2630 } |
|
2631 aPrevious=aCurrent; |
|
2632 aCurrent=next; |
|
2633 currentPenToLabel=nextPenToLabel; |
|
2634 } |
|
2635 return EFalse; |
|
2636 } |
|
2637 |
|
2638 TBool CGridImg::ScanRowsForDrag(TInt aFromRow,TInt aToRow,TInt aPointerPos,TInt& aPrevious,TInt& aCurrent) |
|
2639 { |
|
2640 TInt ii=aFromRow; |
|
2641 if (!iGridLay->RowHeightInPixels(ii-1)) |
|
2642 --ii; |
|
2643 TInt height=iGridLay->RowHeightInPixels(ii++); |
|
2644 aCurrent=aPrevious+height; |
|
2645 TInt currentPenToLabel=(height>=KMinDraggingLength) ? Min(height/KDragFactor,(TInt)KMaxPenToLabel) : 0; |
|
2646 for (;ii<=aToRow && aCurrent<iGridRect.iBr.iY;ii++) |
|
2647 { |
|
2648 iGridLay->StepRowForward(ii); |
|
2649 height=iGridLay->RowHeightInPixels(ii); |
|
2650 TInt next=aCurrent+height; |
|
2651 TInt nextPenToLabel=(height>=KMinDraggingLength) ? Min(height/KDragFactor,(TInt)KMaxPenToLabel) : 0; |
|
2652 if (aPointerPos>aCurrent-currentPenToLabel && aPointerPos>Min(aPrevious+currentPenToLabel,aCurrent-1) |
|
2653 && aPointerPos<aCurrent+nextPenToLabel && aPointerPos<Max(next-nextPenToLabel,aCurrent)) |
|
2654 { |
|
2655 iDragLabel=ii-1; |
|
2656 if (aPointerPos<aCurrent) |
|
2657 iGridLay->StepRowBackward(iDragLabel); |
|
2658 else if (iGridLay->RowHeightInPixels(iDragLabel)==0) |
|
2659 aPrevious=aCurrent; // reopen zero height row |
|
2660 return ETrue; |
|
2661 } |
|
2662 aPrevious=aCurrent; |
|
2663 aCurrent=next; |
|
2664 currentPenToLabel=nextPenToLabel; |
|
2665 } |
|
2666 return EFalse; |
|
2667 } |
|
2668 |
|
2669 EXPORT_C TBool CGridImg::UpdateLabelDrag(const TPoint& aPoint) |
|
2670 /** Deletes the dotted drag line and and redraws it at the new pointer position. |
|
2671 |
|
2672 Typically, the function is called whan handling a pointer event in a control. |
|
2673 |
|
2674 @param aPoint The position of the pointer event. |
|
2675 @return True, if a drag operation was in progress; false, otherwise. */ |
|
2676 { |
|
2677 if (iDragDim == ENoDrag) |
|
2678 return EFalse; |
|
2679 TRect line1 = iGridRect; |
|
2680 TRect line2 = iGridRect; |
|
2681 if (iDragDim == EXDrag) |
|
2682 { |
|
2683 line1.iTl.iX = line1.iBr.iX = iCurrentDragPos; |
|
2684 line2.iTl.iX = line2.iBr.iX = iCurrentDragPos = Min(aPoint.iX-iDragDiff,iGridRect.iBr.iX-1); |
|
2685 } |
|
2686 else |
|
2687 { |
|
2688 line1.iTl.iY = line1.iBr.iY = iCurrentDragPos; |
|
2689 line2.iTl.iY = line2.iBr.iY = iCurrentDragPos = Min(aPoint.iY-iDragDiff,iGridRect.iBr.iY-1); |
|
2690 } |
|
2691 if (line1!=line2) |
|
2692 { |
|
2693 CreateGc(iGc); |
|
2694 iGc->SetClippingRect(iGridRect); |
|
2695 DrawDraggingHighlight(line1,EDragDrawWithBitmap); |
|
2696 DrawDraggingHighlight(line2,EDragDrawWithBitmap); |
|
2697 DeleteGc(); |
|
2698 } |
|
2699 return ETrue; |
|
2700 } |
|
2701 |
|
2702 void CGridImg::DrawArrowsToInMemoryBitmap(TArrows aArrows) |
|
2703 { |
|
2704 const TInt KNoOfPoints = 3; |
|
2705 CFbsBitmapDevice* bmpDevice=NULL; |
|
2706 CGraphicsContext* bmpGc=NULL; |
|
2707 delete iDragBmp; |
|
2708 iDragBmp=NULL; |
|
2709 TRAPD(err, |
|
2710 iDragBmp = new(ELeave) CFbsBitmap; |
|
2711 TSize bmpSize; |
|
2712 if (iDragDim==EXDrag) |
|
2713 bmpSize.SetSize(2*KArrowLength+KArrowSeparation,KArrowBreadth); |
|
2714 else |
|
2715 bmpSize.SetSize(KArrowBreadth,2*KArrowLength+KArrowSeparation); |
|
2716 iDragBmp->Create(bmpSize,EGray2); |
|
2717 bmpDevice = CFbsBitmapDevice::NewL(iDragBmp); |
|
2718 CleanupStack::PushL(bmpDevice); |
|
2719 User::LeaveIfError(bmpDevice->CreateContext(bmpGc)); |
|
2720 CleanupStack::Pop(); // bmpDevice |
|
2721 ); |
|
2722 if (err!=KErrNone) |
|
2723 { |
|
2724 delete iDragBmp; |
|
2725 iDragBmp=NULL; |
|
2726 return; // No big deal - we just don't draw the arrows in low memory conditions |
|
2727 } |
|
2728 bmpGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2729 bmpGc->SetBrushColor(KRgbBlack); |
|
2730 TPoint arrow[KNoOfPoints]; |
|
2731 if (iDragDim==EXDrag) |
|
2732 { |
|
2733 if (aArrows==EBothArrows) |
|
2734 { |
|
2735 arrow[0].SetXY(KArrowLength-1,0); |
|
2736 arrow[1].SetXY(KArrowLength-1,KArrowBreadth-1); |
|
2737 arrow[2].SetXY(0,KArrowBreadth/2); |
|
2738 bmpGc->DrawPolygon(arrow,KNoOfPoints); |
|
2739 } |
|
2740 arrow[0].SetXY(KArrowLength+KArrowSeparation,0); |
|
2741 arrow[1].SetXY(arrow[0].iX,KArrowBreadth-1); |
|
2742 arrow[2].SetXY(arrow[1].iX+KArrowLength,KArrowBreadth/2); |
|
2743 bmpGc->DrawPolygon(arrow,KNoOfPoints); |
|
2744 } |
|
2745 else |
|
2746 { |
|
2747 if (aArrows==EBothArrows) |
|
2748 { |
|
2749 arrow[0].SetXY(KArrowBreadth/2,0); |
|
2750 arrow[1].SetXY(0,KArrowLength-1); |
|
2751 arrow[2].SetXY(KArrowBreadth-1,KArrowLength-1); |
|
2752 bmpGc->DrawPolygon(arrow,KNoOfPoints); |
|
2753 } |
|
2754 arrow[0].SetXY(0,KArrowLength+KArrowSeparation); |
|
2755 arrow[1].SetXY(KArrowBreadth-1,arrow[0].iY); |
|
2756 arrow[2].SetXY(KArrowBreadth/2,arrow[1].iY+KArrowLength); |
|
2757 bmpGc->DrawPolygon(arrow,KNoOfPoints); |
|
2758 } |
|
2759 delete bmpGc; |
|
2760 delete bmpDevice; |
|
2761 } |
|
2762 |
|
2763 void CGridImg::DrawDraggingHighlight(const TRect aLine,TDragDraw aDragDraw) |
|
2764 { |
|
2765 __ASSERT_DEBUG(iGcPtr==iGc,Panic(EGridImgInvalidGC)); // Can only call this using internal GC |
|
2766 iGc->SetDrawMode(CGraphicsContext::EDrawModeNOTXOR); |
|
2767 iGc->SetPenStyle(CGraphicsContext::EDottedPen); |
|
2768 iGc->DrawLine(aLine.iTl,aLine.iBr); |
|
2769 if (aDragDraw==EDragDrawWithoutBitmap || !iDragBmp) |
|
2770 return; |
|
2771 |
|
2772 const TInt KNoOfArrowsToDisplay = 4; |
|
2773 const TInt KMinArrowSeparation = 25; |
|
2774 TSize bmpSize=iDragBmp->SizeInPixels(); |
|
2775 if (iDragDim==EXDrag) |
|
2776 { |
|
2777 TInt separation=Max((aLine.iBr.iY-iTitlePoint.iY)/KNoOfArrowsToDisplay,KMinArrowSeparation); |
|
2778 TPoint point(aLine.iTl.iX-bmpSize.iWidth/2,iTitlePoint.iY+(separation-bmpSize.iHeight)/2); |
|
2779 while (point.iY<aLine.iBr.iY-separation/2) |
|
2780 { |
|
2781 iGc->BitBlt(point,iDragBmp); |
|
2782 point.iY+=separation; |
|
2783 } |
|
2784 } |
|
2785 else |
|
2786 { |
|
2787 TInt separation=Max((aLine.iBr.iX-iTitlePoint.iX)/KNoOfArrowsToDisplay,KMinArrowSeparation); |
|
2788 TPoint point(iTitlePoint.iX+(separation-bmpSize.iWidth)/2,aLine.iTl.iY-bmpSize.iHeight/2); |
|
2789 while (point.iX<aLine.iBr.iX-separation/2) |
|
2790 { |
|
2791 iGc->BitBlt(point,iDragBmp); |
|
2792 point.iX+=separation; |
|
2793 } |
|
2794 } |
|
2795 } |
|
2796 |
|
2797 EXPORT_C void CGridImg::ScrollL(const TPoint &aOffset) |
|
2798 /** Scrolls the grid by the specified number of pixels. |
|
2799 |
|
2800 Draws the minimum necessary, i.e. grid labels, grid lines, grid cells, selected |
|
2801 regions and the cursor. |
|
2802 |
|
2803 @param aOffset Scroll offset, in pixels. */ |
|
2804 { |
|
2805 if (!aOffset.iY && !aOffset.iX) |
|
2806 return; |
|
2807 TRect scrollRect; |
|
2808 TRect validRect; |
|
2809 TRegionFix<4> region; |
|
2810 if (aOffset.iX) |
|
2811 { |
|
2812 scrollRect=iGridRect; |
|
2813 scrollRect.iTl.iX=iMainPoint.iX; |
|
2814 validRect=scrollRect; |
|
2815 if (aOffset.iX>0) |
|
2816 validRect.iBr.iX = Min(validRect.iBr.iX,validRect.iTl.iX+aOffset.iX); |
|
2817 else |
|
2818 validRect.iTl.iX = Max(validRect.iTl.iX,validRect.iBr.iX+aOffset.iX); |
|
2819 iWin->Scroll(scrollRect, TPoint(aOffset.iX,0)); |
|
2820 region.AddRect(validRect); |
|
2821 } |
|
2822 if (aOffset.iY) |
|
2823 { |
|
2824 scrollRect=iGridRect; |
|
2825 scrollRect.iTl.iY=iMainPoint.iY; |
|
2826 validRect=scrollRect; |
|
2827 if (aOffset.iY>0) |
|
2828 validRect.iBr.iY = Min(validRect.iBr.iY,validRect.iTl.iY+aOffset.iY); |
|
2829 else |
|
2830 validRect.iTl.iY = Max(validRect.iTl.iY,validRect.iBr.iY+aOffset.iY); |
|
2831 iWin->Scroll(scrollRect, TPoint(0,aOffset.iY)); |
|
2832 region.AddRect(validRect); |
|
2833 } |
|
2834 region.Tidy(); |
|
2835 TInt end=region.Count(); |
|
2836 for (TInt ii=0;ii<end;ii++) |
|
2837 { |
|
2838 TRect rect=region[ii]; |
|
2839 BeginRedrawAndDrawL(rect); |
|
2840 } |
|
2841 CheckSideLabelWidthAndScrollL(); |
|
2842 } |
|
2843 #endif |
|
2844 |
|
2845 EXPORT_C void CGridImg::SetGridRect(const TRect& aNewRect) |
|
2846 /** Sets the rectangle that is to contain the grid. |
|
2847 |
|
2848 @param aNewRect The rectangle that is to contain the grid. */ |
|
2849 { |
|
2850 iGridRect = aNewRect; |
|
2851 ResetReferencePoints(); |
|
2852 } |
|
2853 |
|
2854 EXPORT_C void CGridImg::SetPrintGridRect(const TRect& aPrintGridRect) |
|
2855 /** Sets the rectangle that is to contain the grid for the purpose of printing. |
|
2856 |
|
2857 @param aPrintRect The rectangle that is to contain the grid. */ |
|
2858 { |
|
2859 iGridRect=aPrintGridRect; |
|
2860 iTitlePoint=iGridRect.iTl; |
|
2861 if (iGridLay->IsPrintedLabels()) |
|
2862 { |
|
2863 if (iGridLay->IsSideLabels()) |
|
2864 iTitlePoint.iX+=MaxSideLabelWidthInPixels(); |
|
2865 if (iGridLay->IsTopLabels()) |
|
2866 iTitlePoint.iY+=TopLabelHeightInPixels(); |
|
2867 } |
|
2868 iMainPoint=iTitlePoint; |
|
2869 } |
|
2870 |
|
2871 EXPORT_C void CGridImg::ResetReferencePoints() |
|
2872 /** Resets the reference points. |
|
2873 |
|
2874 The reference points are the mainpoint and the titlepoint, i.e the point at |
|
2875 which the visible range starts, and the point at the top left of the grid |
|
2876 not including the labels. */ |
|
2877 { |
|
2878 iTitlePoint=iGridRect.iTl; |
|
2879 if (iGridLay->IsSideLabels()) |
|
2880 iTitlePoint.iX+=SideLabelWidthInPixels(); |
|
2881 if (iGridLay->IsTopLabels()) |
|
2882 iTitlePoint.iY+=TopLabelHeightInPixels(); |
|
2883 iMainPoint=iTitlePoint+iGridLay->TopLeftTitleRangeSize(); |
|
2884 } |
|
2885 |
|
2886 EXPORT_C void CGridImg::NotifyGridRangeResize() |
|
2887 /** Resets the region boundary to the grid boundary. */ |
|
2888 { |
|
2889 iGridLay->LimitCell(iCursorPos); |
|
2890 iGridLay->LimitCell(iAnchorPos); |
|
2891 iSelected->ResizeBounds(iGridLay->iGridRange.iTo); |
|
2892 } |
|
2893 |
|
2894 //-> |
|
2895 EXPORT_C void CGridImg::SetGridLabelImg(CGridLabelImg* aGridLabelImg) |
|
2896 /** Sets an object that draws a cell label. |
|
2897 |
|
2898 @param aGridLabelImg A pointer to an object that draws a cell label. */ |
|
2899 { |
|
2900 iGridLabelImg = aGridLabelImg; |
|
2901 if (aGridLabelImg && iGridLay) |
|
2902 aGridLabelImg->SetGridColors(iGridLay->GridColors()); |
|
2903 } |
|
2904 |
|
2905 void CGridImg::SetGridColors(const TGridColors& aGridColors) |
|
2906 { |
|
2907 iGridLabelImg->SetGridColors(aGridColors); |
|
2908 iGridCellImg->SetGridColors(aGridColors); |
|
2909 } |
|
2910 //-> |