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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__GRDSTD_H__)
19 #if !defined(__E32STD_H__)
22 #if !defined(__GDI_H__)
25 #if !defined(__GRDCELLS_H__)
28 #if !defined(__GRDDEF_H__)
35 /** An interface that can be implemented to provide row and column information.
37 Note that for grids that have indefinite row boundaries, an implementation
40 A concrete implementation is passed to a CGridLay object through its CGridLay::ConstructL()
41 functions or its CGridLay::SetGridTable() function.
49 /** The number of rows returned by the default implementation of RowExtent(). */
51 /** The number of columns returned by the default implementation of ColumnExtent(). */
52 EDefaultColumnExtent=20
55 IMPORT_C virtual TBool RequestRow(TInt aRow,TInt& aReturnRow) const;//If used should be derived from
56 IMPORT_C virtual TInt RowExtent() const;
57 IMPORT_C virtual TInt ColumnExtent() const;
61 ////////////////////////->
64 /** The grid colour specification.
66 An object of this type encapsulates the colours to be used when drawing a
74 IMPORT_C TGridColors();
75 IMPORT_C TGridColors(TRgb aForeground, TRgb aBackground, TRgb aLines, TRgb aLabelSeparators);
77 /** The foreground colour. */
79 /** The background colour. */
81 /** The colour of lines. */
83 /** The colour of label separators. */
84 TRgb iLabelSeparators;
87 ////////////////////////->
97 class CGridLay : public CBase
98 /** Handles the layout of a grid, and controls how columns, rows and selections
104 friend class CGridImg;
106 /** Defines the order in which pages are printed. */
109 /** All pages in a horizontal line are drawn before starting on the next horizontal
112 /** All pages in a vertical line are drawn before starting on the next vertical
113 line to the right. */
116 /** Indicates whether the size of the grid should be adjusted when columns and
117 rows are inserted or deleted. */
120 /** The grid range should not be adjusted on insertion or deletion of rows and/or columns. */
122 /** The grid range can be adjusted on insertion or deletion of rows and/or columns. */
126 IMPORT_C CGridLay(MGraphicsDeviceMap* aGraphicsDeviceMap);
127 IMPORT_C void ConstructL(CGridLay* aGridLay,CGridImg* aGridImg);//Constructs Partial Copy
128 IMPORT_C void ConstructL(const MGridTable *aGridTable,CGridImg *aGridImg,TInt aNoOfRows,TInt aNoOfCols);
129 IMPORT_C void ConstructL(const MGridTable *aGridTable,CGridImg *aGridImg,TInt aNoOfCols);
130 IMPORT_C virtual ~CGridLay();
132 IMPORT_C TPoint PageScroll(TMoveDirectionAndAmount aPageScroll);
133 IMPORT_C TPoint ExposeCell(const TCellRef &aCell);
134 IMPORT_C TPoint ExposeCellToTopLeft(const TCellRef &aCell);
136 IMPORT_C void SetGridImgL(CGridImg* aGridImg);
137 inline void SetGridTable(const MGridTable* aGridTable);
138 inline TRangeRef VisibleRange() const;
139 IMPORT_C void SetVisibleRange(const TCellRef& aTopLeftCell);
140 inline TRangeRef TitleRange() const;
141 inline TRangeRef GridRange() const;
142 IMPORT_C void SetGraphicsDeviceMap(MGraphicsDeviceMap* aGraphicsDeviceMap);
143 IMPORT_C void SetGridToDefault();
145 IMPORT_C TInt ColumnWidthInTwips(TInt aCol) const;
146 IMPORT_C void SetColumnWidthInTwipsL(TInt aCol,TInt aWidthInTwips);
147 IMPORT_C TInt SetColumnWidthInTwipsL(TInt aStartCol,TInt aEndCol,TInt aWidthInTwips);
148 IMPORT_C TInt DefaultColumnWidthInTwips() const;
149 IMPORT_C void SetDefaultColumnWidthInTwips(TInt aWidthInTwips);
150 IMPORT_C void SetColumnWidthsToDefault();
151 IMPORT_C TInt MinColumnWidthInPixels() const;
152 IMPORT_C void SetMinColumnWidthInPixels(TInt aWidthInPixels);
153 IMPORT_C TInt ColumnWidthOfSelectedInTwips() const;
154 IMPORT_C void SetColumnWidthOfSelectedInTwipsL(TInt aWidthInTwips);
155 IMPORT_C TInt RowHeightInTwips(TInt aRow) const;
156 IMPORT_C void SetRowHeightInTwipsL(TInt aRow,TInt aHeightInTwips);
157 IMPORT_C TInt SetRowHeightInTwipsL(TInt aStartRow,TInt aEndRow,TInt aHeightInTwips);
158 IMPORT_C TInt DefaultRowHeightInTwips() const;
159 IMPORT_C void SetDefaultRowHeightInTwips(TInt aHeightInTwips);
160 IMPORT_C void SetRowHeightsToDefault();
161 IMPORT_C TInt MinRowHeightInPixels() const;
162 IMPORT_C void SetMinRowHeightInPixels(TInt aHeightInPixels);
163 IMPORT_C TInt RowHeightOfSelectedInTwips() const;
164 IMPORT_C void SetRowHeightOfSelectedInTwipsL(TInt aHeightInTwips);
165 IMPORT_C void RecalcPixelSparseMaps();
166 IMPORT_C void InsertDeleteColumns(TInt aStartCol,TInt aNoOfCols,
167 TFixGridRange aFixGridRange=EFixGridRange);
168 IMPORT_C void InsertDeleteRows(TInt aStartRow,TInt aNoOfRows,
169 TFixGridRange aFixGridRange=EFixGridRange);
171 inline TBool IsSideLabels() const;
172 IMPORT_C void SetSideLabels(TBool aState);
173 inline TBool IsTopLabels() const;
174 IMPORT_C void SetTopLabels(TBool aState);
175 inline TBool IsVerticalGridLines() const;
176 IMPORT_C void SetVerticalGridLines(TBool aState);
177 inline TBool IsHorizontalGridLines() const;
178 IMPORT_C void SetHorizontalGridLines(TBool aState);
179 inline TBool IsGridLabelSeparators() const;
180 IMPORT_C void SetGridLabelSeparators(TBool aState);
181 inline TBool IsColumnBursting() const;
182 IMPORT_C void SetColumnBursting(TBool aState);
183 inline TBool IsCursorVisible() const;
184 IMPORT_C void SetCursorVisible(TBool aVisible);
185 inline TBool IsHighlightVisible() const;
186 IMPORT_C void SetHighlightVisible(TBool aVisible);
187 inline TBool IsRowPermanentlySelected() const;
188 IMPORT_C void SetRowPermanentlySelectedL(TBool aState);
189 inline TBool IsTitleLines() const;
190 inline TBool IsHorizontalTitleLine() const;
191 inline TBool IsVerticalTitleLine() const;
192 IMPORT_C void SetTitleLinesL(TBool aState);
193 IMPORT_C void SetTitleLinesL(const TCellRef& aCellRef);
194 IMPORT_C void ToggleTitleLinesL();
195 inline TBool IsIndefiniteRowBoundaries() const;
196 inline TBool IsUniformRowHeight() const;
197 IMPORT_C void SetUniformRowHeight(TBool aState);
198 inline TBool IsUniformColumnWidth() const;
199 IMPORT_C void SetUniformColumnWidth(TBool aState);
200 inline TBool IsTopLabelDragDisabled() const;
201 IMPORT_C void SetTopLabelDragDisabled(TBool aState);
202 inline TBool IsSideLabelDragDisabled() const;
203 IMPORT_C void SetSideLabelDragDisabled(TBool aState);
204 inline TBool IsPrintedLabels() const;
205 IMPORT_C void SetPrintedLabels(TBool aState);
206 inline TBool IsPrintedGridLines() const;
207 IMPORT_C void SetPrintedGridLines(TBool aState);
208 inline TBool IsEncroachingCellBorders() const;
209 IMPORT_C void SetEncroachingCellBorders(TBool aState);
210 inline TBool IsRowSelectionDisabled() const;
211 IMPORT_C void SetRowSelectionDisabled(TBool aState);
212 inline TBool IsColumnSelectionDisabled() const;
213 IMPORT_C void SetColumnSelectionDisabled(TBool aState);
214 inline TBool IsAutoClearGridCells() const;
215 IMPORT_C void SetAutoClearGridCells(TBool aState);
216 inline TBool IsPageBreakLinesHidden() const;
217 IMPORT_C void SetPageBreakLinesHidden(TBool aState);
218 inline TBool HasChanged() const;
219 inline void SetHasChanged(TBool aHasChanged);
220 inline void SetGridEdgeColor(TRgb aColor);
222 IMPORT_C TInt MinVisibleFromRow() const;
223 IMPORT_C TInt MinVisibleFromColumn() const;
224 IMPORT_C void ResetVisibleToRow();
225 IMPORT_C void ResetVisibleToColumn();
226 IMPORT_C void ResetVisibleToCell();
227 IMPORT_C TInt RowExtent() const;
228 IMPORT_C TInt ColumnExtent() const;
230 IMPORT_C TInt RowToYVal(TInt aRow) const;
231 IMPORT_C TInt RowToYVal(TInt aStartRow,TInt aEndRow) const;
232 IMPORT_C TInt VisibleRowToYVal(TInt aRow) const;
233 IMPORT_C TInt TitleRowToYVal(TInt aTitleRow) const;
234 IMPORT_C TInt ColumnToXVal(TInt aCol) const;
235 IMPORT_C TInt ColumnToXVal(TInt aStartCol,TInt aEndCol) const;
236 IMPORT_C TInt VisibleColumnToXVal(TInt aCol) const;
237 IMPORT_C TInt TitleColumnToXVal(TInt aTitleCol) const;
238 IMPORT_C TInt YValToRow(TInt aYVal) const;
239 IMPORT_C TInt YValToRow(TInt aStartRow,TInt aDisp) const;
240 IMPORT_C TInt YValToTitleRow(TInt aYVal) const;
241 IMPORT_C TInt XValToColumn(TInt aXVal) const;
242 IMPORT_C TInt XValToColumn(TInt aStartCol,TInt aDisp) const;
243 IMPORT_C TInt XValToTitleColumn(TInt aXVal) const;
244 IMPORT_C TCellRef PointToCell(const TPoint &aPoint) const;
245 IMPORT_C TCellRef PointToCell(const TCellRef &aStartCell,const TPoint &aPointDisp) const;
246 IMPORT_C TPoint CellToPoint(const TCellRef &aCell) const;
247 IMPORT_C TPoint CellToPoint(const TCellRef &aStartCell,const TCellRef &aEndCell) const;
248 IMPORT_C TPoint TitleCellToPoint(const TCellRef& aTitleCell) const;
249 IMPORT_C TRect CellToRect(const TCellRef& aCell) const;
250 IMPORT_C TInt YValToNearestRow(TInt aStartRow,TInt aDisp) const;
251 IMPORT_C TInt XValToNearestColumn(TInt aStartCol,TInt aDisp) const;
252 IMPORT_C TSize TopLeftTitleRangeSize() const;
254 IMPORT_C void PaginateL();
255 IMPORT_C void ClearPagination();
256 IMPORT_C void NotifyPaginationOutOfDateL();
257 inline TBool IsPaginated() const;
258 IMPORT_C TRangeRef PageToRange(TInt aPageNo,TPageOrder aPageOrder) const;
259 inline void SetPrintRange(const TRangeRef& aPrintRange);
260 IMPORT_C TInt NoOfPages() const;
261 IMPORT_C void SetPageSizeInTwipsL(const TSize& aPageSize);
262 inline TSize PageSizeInTwips() const;
263 inline TBool IsAutoPagination() const;
264 IMPORT_C void SetAutoPagination(TBool aState);
265 IMPORT_C TBool IsHardRowPageBreak(TInt aRow) const;
266 IMPORT_C TBool IsHardColumnPageBreak(TInt aCol) const;
267 IMPORT_C void SetHardRowPageBreakL(TInt aRow);
268 IMPORT_C void ClearHardRowPageBreakL(TInt aRow);
269 IMPORT_C void SetHardColumnPageBreakL(TInt aCol);
270 IMPORT_C void ClearHardColumnPageBreakL(TInt aCol);
271 IMPORT_C void ClearAllHardPageBreaksL();
273 IMPORT_C void ExternalizeL(RWriteStream &aStream) const;
274 IMPORT_C void InternalizeL(RReadStream &aStream);
275 IMPORT_C TStreamId StoreL(CStreamStore& aStore) const;
276 IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aStreamId);
277 ////////////////////////->
278 // Setting the grid colors
279 IMPORT_C void SetGridColors(TGridColors aColors);
280 // Getting the grid colors
281 IMPORT_C const TGridColors& GridColors() const;
282 ////////////////////////->
284 void SetIndefiniteRowBoundaries(TBool aState);
285 inline TBool IsVisibleToRowFullyVisible() const;
286 void SetVisibleToRowFullyVisible(TBool aState);
287 inline TBool IsVisibleToColumnFullyVisible() const;
288 void SetVisibleToColumnFullyVisible(TBool aState);
289 TInt ColumnWidthInPixels(TInt aCol) const;
290 void SetColumnWidthInPixelsL(TInt aCol,TInt aWidthInPixels);
291 void PreCheckColumnWidthChange(TInt aCol,TBool aNonZeroWidth);
292 void PostCheckColumnWidthChange(TInt aCol,TBool aNonZeroWidth);
293 TInt DefaultColumnWidthInPixels() const;
294 void SetDefaultColumnWidthInPixels(TInt aWidthInPixels);
295 TInt RowHeightInPixels(TInt aRow) const;
296 void SetRowHeightInPixelsL(TInt aRow,TInt aHeightInPixels);
297 void PreCheckRowHeightChange(TInt aRow,TBool aNonZeroHeight);
298 void PostCheckRowHeightChange(TInt aRow,TBool aNonZeroHeight);
299 TInt DefaultRowHeightInPixels() const;
300 void SetDefaultRowHeightInPixels(TInt aHeightInPixels);
301 TPoint CalcOffsetBetweenCells(const TCellRef& aCell1,const TCellRef& aCell2) const;
302 TBool LimitRow(TInt& aRow) const;
303 TBool LimitColumn(TInt &aColumn) const;
304 void LimitRow(TInt& aRow,TInt aLowerLimit,TInt aUpperLimit) const;
305 void LimitColumn(TInt& aCol,TInt aLowerLimit,TInt aUpperLimit) const;
306 TBool LimitCell(TCellRef& aCell) const;
307 void LimitRowToVisible(TInt& aRow) const;
308 void LimitColumnToVisible(TInt& aCol) const;
309 void LimitCellToVisible(TCellRef& aCell) const;
310 TBool IsCellOutOfVisibleRange(const TCellRef &aCell) const;
311 TBool IsCellOutOfGridRange(const TCellRef& aCell) const;
312 void StepRowForward(TInt& aRow) const;
313 void StepRowBackward(TInt& aRow) const;
314 void StepColumnForward(TInt& aCol) const;
315 void StepColumnBackward(TInt& aCol) const;
316 void CalcVisibleFromRow(TInt aVisibleToRow,TInt& aNewVisibleFromRow) const;
317 TBool CalcVisibleToRow(TInt aVisibleFromRow,TInt& aNewVisibleToRow) const;
318 void CalcVisibleFromColumn(TInt aVisibleToCol,TInt& aNewVisibleFromCol) const;
319 TBool CalcVisibleToColumn(TInt aVisibleFromCol,TInt& aNewVisibleToCol) const;
320 TInt CalcVisibleFromRowAfterPageScroll(TMoveDirectionAndAmount aPageScroll) const;
321 TInt CalcVisibleFromColumnAfterPageScroll(TMoveDirectionAndAmount aPageScroll) const;
322 TCellRef CalcVisibleFromCellAfterPageScroll(TMoveDirectionAndAmount aPageScroll) const;
323 TBool FindNextRowPageBreak(TInt aSearchStart,TInt& aFoundRow) const;
324 TBool FindNextColumnPageBreak(TInt aSearchStart,TInt& aFoundCol) const;
325 void DoMainPaginationLoopL(TInt aPageSpan,CSparseMap* aCellSpanMap,CSparseMap* aPageMap,
326 CArrayFix<TInt>* aHardPageBreaks,TInt aStartId);
327 TBool RequestRow(TInt aRow,TInt& aReturnRow) const;
329 void ConstructL(const MGridTable *aGridTable,CGridImg *aGridImg,const TRangeRef& aGridRange);
334 EMaxArrayChanges=256,
335 EInitialDefaultRowHeightInTwips = 300,
336 EInitialDefaultColumnWidthInTwips = 900
342 EIsHorizontalGridLines = 0x4,
343 EIsVerticalGridLines = 0x8,
344 EIsColumnBursting = 0x10,
345 EIsCursorVisible = 0x20,
346 EIsRowPermanentlySelected = 0x40,
347 EIsHorizontalTitleLine = 0x80,
348 EIsVerticalTitleLine = 0x100,
349 EIsIndefiniteRowBoundaries = 0x200,
350 EIsUniformRowHeight = 0x400,
351 EIsUniformColumnWidth = 0x800,
352 EIsTopLabelDragDisabled = 0x1000,
353 EIsSideLabelDragDisabled = 0x2000,
354 EIsPaginated = 0x4000,
355 EIsAutoPagination = 0x8000,
356 EIsPrintedLabels = 0x10000,
357 EIsPrintedGridLines = 0x20000,
358 EIsVisibleToRowFullyVisible = 0x40000,
359 EIsVisibleToColumnFullyVisible = 0x80000,
360 EIsEncroachingCellBorders = 0x100000,
361 EIsColumnSelectionDisabled = 0x200000,
362 EIsRowSelectionDisabled = 0x400000,
363 EIsAutoClearGridCells = 0x800000,
364 EIsGridLabelSeparators = 0x1000000,
365 EIsHighlightVisible = 0x2000000,
366 EIsPageBreakLinesHidden = 0x4000000
369 const MGridTable* iGridTable;
370 const MGraphicsDeviceMap* iGraphicsDeviceMap; //*
371 CGridImg* iGridImg; //*
373 TRangeRef iGridRange; //*
374 TRangeRef iVisibleRange;
375 TRangeRef iTitleRange;
376 CSparseMap* iColumnWidthMap; //*
377 CSparseMap* iRowHeightMap; //*
378 CSparseMap* iColumnPageMap; //*
379 CSparseMap* iRowPageMap; //*
380 CArrayFix<TInt>* iHardRowPageBreaks;
381 CArrayFix<TInt>* iHardColumnPageBreaks;
383 TInt iMinRowHeightInPixels;
384 TInt iMinColumnWidthInPixels;
385 TSize iPageSizeInTwips; //*
386 TUint32 iFlags; //* Starred items are used in printing
387 ////////////////////////->
389 ////////////////////////->
390 // End of persistent data
397 class CGridLabelImg : public CBase
398 /** Draws a grid cell's label.
403 friend class CGridImg;
405 IMPORT_C virtual ~CGridLabelImg();
406 IMPORT_C void ConstructL();
407 inline void SetGraphicsDeviceMap(MGraphicsDeviceMap* aGraphicsDeviceMap);
408 inline TFontSpec FontSpec() const;
409 IMPORT_C void ReleaseFont();
410 IMPORT_C void NotifyGraphicsDeviceMapChangeL();
411 inline void SetGridColors(const TGridColors& aGridColors);
413 IMPORT_C CGridLabelImg(const TFontSpec& aFontSpec,MGraphicsDeviceMap* aGraphicsDeviceMap);
414 ////////////////////////->
415 IMPORT_C void DrawTopLeftLabelL(CGraphicsContext* aGc,const TRect& aRect, TRgb aColor) const;
416 ////////////////////////->
418 /** Draws a row label.
422 @param aGc The graphics context to be used.
423 @param aRow The row for which the label is to be drawn.
424 @param aRect The rectangle in which the label is to be drawn. */
425 virtual void DrawRowLabelL(CGraphicsContext* aGc,TInt aRow,const TRect& aRect) const=0;
426 /** Draws a column label.
430 @param aGc The graphics context to be used.
431 @param aCol The column for which the label is to be drawn.
432 @param aRect The rectangle in which the label is to be drawn. */
433 virtual void DrawColLabelL(CGraphicsContext* aGc,TInt aCol,const TRect& aRect) const=0;
434 IMPORT_C virtual void DrawTopLeftLabelL(CGraphicsContext* aGc,const TRect& aRect) const;
435 IMPORT_C virtual TInt SideLabelWidthInPixels(TInt aStartRow,TInt aEndRow) const;
436 IMPORT_C virtual TInt TopLabelHeightInPixels() const;
437 IMPORT_C virtual void DrawRowCursorL(CGraphicsContext* aGc,const TRect& aRect) const;
441 /** The default width of side labels, in twips.
443 This is used by the default implementation of SideLabelWidthInPixels(). */
444 EDefaultSideLabelWidthInTwips=300,
445 /** The default height of top labels, in twips.
447 This is used by the default implementation of TopLabelHeightInPixels(). */
448 EDefaultTopLabelHeightInTwips=300
451 /** The nearest font to that specified in the font specification. */
453 /** The font specification in device independent terms. */
455 /** The graphics device map, an interface for mapping between twips and device-specific
457 MGraphicsDeviceMap* iGraphicsDeviceMap;
458 /** The grid colour specification. */
459 TGridColors iGridColors;
465 class CGridCellImg : public CBase
466 /** Draws a grid cell's contents.
471 friend class CGridImg;
473 IMPORT_C virtual ~CGridCellImg();
474 inline TInt BurstColOffset() const;
475 inline TInt BurstLeft() const;
476 inline TInt BurstRight() const;
477 inline TBool IsHorizontalGridLines() const;
478 inline TBool IsVerticalGridLines() const;
479 inline void SetGridColors(const TGridColors& aGridColors);
481 IMPORT_C CGridCellImg();
483 /** Draws the contents of the specified cell.
487 @param aGc The graphics context to be used.
488 @param aCell The cell whose contents are to be drawn.
489 @param aDrawRect The rectangle in which the cell is to be drawn.
490 @param aClipRect The rectangle to which drawing is clipped. */
491 virtual void DrawL(CGraphicsContext* aGc,const TCellRef& aCell,const TRect& aDrawRect,
492 const TRect& aClipRect) const=0;
493 IMPORT_C virtual TInt DataWidthInPixelsL(const TCellRef& aCell) const;
494 IMPORT_C virtual TBool DoesCellContainDataL(const TCellRef& aCell) const;
495 // reserved virtual function
496 IMPORT_C virtual void Reserved_1();
498 void SetBurstingData(TInt aBurstColOffset=0,TInt aBurstLeft=0,TInt aBurstRight=0);
500 enum { EIsHorizontalGridLines = 0x1, EIsVerticalGridLines = 0x2 };
502 /** The grid colour specification. */
503 TGridColors iGridColors;
505 TInt iBurstColOffset;
508 TUint32 iGridLineFlags;
512 class MGridCursorMoveCallBack
513 /** An interface to a callback function that is intended to be called whenever
514 there is a change to the cursor position.
516 If such a callback is needed, a concrete implementation is defined, instantiated
517 and passed to CGridImg::SetCursorMoveCallBack().
523 /** Deals with the change to the cursor position.
525 This function is called immediately before exiting the following functions:
526 CGridImg::SetCursorPosL(), CGridImg::SetAnchorPosL(), CGridImg::MoveCursorL(),CGridImg::ResetSelectedL(),
527 CGridImg::AddRangeToSelectedL(), CGridImg::AddRegionToSelectedL(), CGridImg::AddRowToSelectedL(),
528 CGridImg::AddColToSelectedL().
530 The function is commonly used to do any necessary redrawing. */
531 virtual void HandleCursorMoveL()=0;
538 class CGridImg : public CBase
539 /** Draws the contents of the grid.
545 friend class CGridLay;
549 /** Indicates that the selection state is to be maintained.
551 If a region of cells is selected, then this selection is to be kept.
553 Typically, this is set by a control when a drag operation is in
554 progress and the shift modifier key is also pressed. */
555 EIsWithSelect=0x0001,
556 /** Indicates that the control modifier key has been pressed. */
557 EIsWithControl=0x0002,
558 /** Indicates that a drag operation is in progress. */
560 /** Indicates that the cursor is the edge of the grid. */
561 EIsAtBoundary=0x0008,
562 /** Indicates that a new cell is being selected, without dragging. */
563 EIsAbsoluteMove=0x0010,
564 /** Indicates that a whole row is selected. */
565 EIsRowSelected=0x0020,
566 /** Indicates that a whole column is selected.
568 This also means that the label cell for the column is included in the selection. */
569 EIsColumnSelected=0x0040
573 /** Defines a scale value of 100.
575 Scale factor values are divided into this value to calculate
576 drawing points, rectangles etc. */
582 /** Indicates that an existing selected region is to be reset (i.e. emptied) before
583 adding a new region. */
585 /** Indicates that a new region is to be appended to any existing selected region. */
589 IMPORT_C virtual ~CGridImg();
590 IMPORT_C static CGridImg* NewL(CGraphicsDevice* aGraphicsDevice,CGridCellImg* aGridCellImg,CGridLay* aGridLay);
591 IMPORT_C static CGridImg* NewL(CGridCellImg* aGridCellImg,CGridLay* aGridLay); //Creates Partial GridImg
592 inline void SetGridLay(CGridLay* aGridLay);
593 inline void SetWindow(RWindow* aWin);
594 ////////////////////////->
595 IMPORT_C void SetGridLabelImg(CGridLabelImg* aGridLabelImg);
596 ////////////////////////->
597 inline void SetCursorMoveCallBack(MGridCursorMoveCallBack* aCursorMoveCallBack);
598 inline const CGridCellRegion* Selected() const;
599 inline const CGridLabelImg* GridLabelImg() const;
601 IMPORT_C void ScrollL(const TPoint &aOffset);
602 IMPORT_C void MoveCursorL(TMoveDirectionAndAmount aCursorMove,TUint aSelectState);
603 IMPORT_C void SetCursorWithPointerL(const TPoint& aPoint,TUint aFlagList);
604 IMPORT_C void ResetSelectedL();
605 IMPORT_C void AddRangeToSelectedL(const TRangeRef& aRange,TSelectType aType=ESelectOverwrite);
606 IMPORT_C void AddRegionToSelectedL(const CArrayFix<TRangeRef>* aCellRegion,TSelectType aType=ESelectOverwrite);
607 IMPORT_C void AddRowToSelectedL(TInt aRow,TSelectType aType=ESelectOverwrite);
608 IMPORT_C void AddColToSelectedL(TInt aCol,TSelectType aType=ESelectOverwrite);
609 IMPORT_C void DrawL(CGraphicsContext* aGc) const;
610 IMPORT_C void DrawL(CGraphicsContext* aGc,const TRect& aRect) const;
611 IMPORT_C void DrawCellL(const TCellRef& aCell) const;
612 IMPORT_C void DrawRangeL(const TRangeRef& aRange) const;
613 IMPORT_C void DrawSelectedL() const;
614 IMPORT_C void DrawTitleLines() const;
615 IMPORT_C void ClearTitleLineRegionL(const TPoint& aCrossPoint) const;
616 IMPORT_C void PrintGridLinesAndCellsInRangeL(CGraphicsContext* aPrinterGc,const TRangeRef& aRange,
617 TInt aScaleFactor) const;
619 inline TCellRef CursorPos() const;
620 IMPORT_C void SetCursorPosL(const TCellRef& aCursorPos);
621 inline TCellRef NewCursorPos() const;
622 inline TCellRef AnchorPos() const;
623 IMPORT_C void SetAnchorPosL(const TCellRef& aAnchorPos);
624 inline TRect GridRect() const;
625 IMPORT_C void SetGridRect(const TRect& aNewRect);
626 IMPORT_C void SetPrintGridRect(const TRect& aPrintRect);
627 inline TPoint TitlePoint() const;
628 inline TPoint MainPoint() const;
629 inline TRect MainRect() const;
630 IMPORT_C void ResetReferencePoints();
631 IMPORT_C void NotifyGridRangeResize();
633 IMPORT_C void CheckSideLabelWidthAndScrollL();
634 IMPORT_C TInt CheckSideLabelWidth();
635 IMPORT_C TInt SideLabelWidthInPixels() const;
636 IMPORT_C TInt MaxSideLabelWidthInPixels() const;
637 IMPORT_C TInt TopLabelHeightInPixels() const;
638 IMPORT_C void FinishLabelDragL();
639 IMPORT_C TBool StartLabelDrag(const TPoint &aPoint);
640 IMPORT_C TBool UpdateLabelDrag(const TPoint &aPoint);
641 IMPORT_C TBool StartLabelResize(TBool aIsColumnLabel, TInt aIndex);
642 IMPORT_C TBool UpdateLabelResize(TInt aDelta);
643 IMPORT_C void FinishLabelResizeL(TBool aResize);
645 enum TDragDim {EXDrag,EYDrag,ENoDrag};
646 enum TRefPoint {ETitleRef,EMainRef};
647 enum TDragDraw {EDragDrawWithBitmap,EDragDrawWithoutBitmap};
648 enum TArrows {EBothArrows,ESecondArrowOnly};
651 EIsLabelDraggingIgnored = 0x1,
652 EIsSidewaysScrollIgnored = 0x2
655 void DrawResizingDragHiglights(const TRect& aRect);
656 void DrawAllGridLabelsL() const;
657 void DrawTopLeftGridLabelL() const;
658 void DrawTopGridLabelsL(TInt aStartCol,TInt aEndCol,TRefPoint aXRef=EMainRef) const;
659 void DrawSideGridLabelsL(TInt aStartRow,TInt aEndRow,TRefPoint aYRef=EMainRef) const;
660 void DrawSideGridLabelIfOnScreenL(TInt aRow) const;
661 void DrawAllGridLinesAndCellsL() const;
662 void DrawGridLinesAndCellsInRangeL(const TRangeRef& aRange,const TRect& aClipRect,
663 TRefPoint aXRef=EMainRef,TRefPoint aYRef=EMainRef) const;
664 void DrawCellsToGcL(CGraphicsContext* aGc,const TRangeRef& aRange,const TRect& aClipRect,
665 const TPoint& aStartPoint,TInt aScaleFactor=EScaleOneToOne) const;
666 void DrawBurstingCellL(CGraphicsContext* aGc,const TCellRef& aCell,const TRect& aRect,const TRect& aClipRect,
667 TInt aScaleFactor,TInt aBurstLeft,const TCellRef& aBurstCell) const;
668 TInt CalcBurstLeftL(TCellRef& aBurstCell,TInt aScaleFactor) const;
669 TInt CalcBurstRightL(const TCellRef& aCell,TInt aExcessRight,TInt aScaleFactor) const;
670 void DrawVerticalTitleLine() const;
671 void DrawHorizontalTitleLine() const;
672 void BeginRedrawAndDrawL() const;
673 void BeginRedrawAndDrawL(const TRect& aRect) const;
675 void AppendTotalHighlightRegionL(TRegion& aRegion) const;
676 void AppendPartialHighlightRegionL(TRegion& aRegion,const TRect& aClipRect,
677 TRefPoint aXRef=EMainRef,TRefPoint aYRef=EMainRef) const;
678 void RemoveRowLabelFromRegionL(TInt aRow,TRegion& aRegion) const;
679 void HighlightMinRegionL(const TRegion &aOldRegion,const TRegion &aNewRegion);
680 void HighlightRegion(const TRegion &aRegion) const;
681 void HighlightNewRegionFromOldL(const TRegion& aOldRegion);
682 void DrawCursorOrRegionL(TUint aMoveFlags);
683 void UpdateSelectedRegion(TInt aSelectCount,TUint aMoveFlags);
684 void AddLabelToRegionL(TUint aMoveFlags);
685 void StartSelectedRegionL(TUint aMoveFlags);
686 TBool ScanColumnsForDrag(TInt aFromColumn,TInt aToColumn,TInt aPointerPos,TInt& aPrevious,TInt& aCurrent);
687 TBool ScanRowsForDrag(TInt aFromRow,TInt aToRow,TInt aPointerPos,TInt& aPrevious,TInt& aCurrent);
688 void DrawDraggingHighlight(const TRect aLine,TDragDraw aDragDraw);
689 void DrawArrowsToInMemoryBitmap(TArrows aArrows);
690 TPoint RelativeCellToPoint(const TCellRef& aCell,TRefPoint aXRef=EMainRef,
691 TRefPoint aYRef=EMainRef) const;
692 TCellRef RelativePointToCell(const TPoint& aPoint,TRefPoint aXRef=EMainRef,
693 TRefPoint aYRef=EMainRef) const;
694 TRect PartialCellRectL(const TCellRef& aCell,const TRect& aClipRect,
695 TRefPoint aXRef=EMainRef,TRefPoint aYRef=EMainRef) const;
696 TRect PartialRangeRect(const TRangeRef& aRange,const TRect& aClipRect,
697 TRefPoint aXRef=EMainRef,TRefPoint aYRef=EMainRef) const;
698 void CreateGc(CGraphicsContext* aGc);
700 static void CleanupGc(TAny* aObject);
701 void ResetGcToDefault(CGraphicsContext* aGc) const;
702 void ScaleDown(TPoint& aPoint,TInt aScaleFactor) const;
703 void ConstructSelectedL(const TRangeRef& aGridRange);
705 CGridImg(CGraphicsDevice* aGraphicsDevice,CGridCellImg* aGridCellImg,CGridLay* aGridLay);
706 CGridImg(CGridCellImg* aGridCellImg,CGridLay* aGridLay);
709 ////////////////////////->
710 void SetGridColors(const TGridColors& aGridColors);
711 ////////////////////////->
716 TCellRef iCursorPos; // Persisted
717 TCellRef iNewCursorPos;
720 CGraphicsDevice* iGraphicsDevice;
721 CGraphicsContext* iGcPtr;
724 CGridCellImg* iGridCellImg; //*
725 CGridLabelImg* iGridLabelImg; //*
726 CGridLay* iGridLay; //* Starred items are used in printing
727 CGridCellRegion* iSelected;
728 MGridCursorMoveCallBack* iCursorMoveCallBack;
729 TBool iDrawResizeLines;
731 TInt iCurrentDragPos;
735 CFbsBitmap* iDragBmp;
736 TRefPoint iXRefPoint;
737 TRefPoint iYRefPoint;
742 /** A collection of Grid utilities.
748 IMPORT_C static void FillRect(CGraphicsContext* aGc,TRgb aColor,const TRect &aRect);
752 #include <grdstd.inl>