1.1 --- a/epoc32/include/grdstd.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/grdstd.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,753 @@
1.4 -grdstd.h
1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#if !defined(__GRDSTD_H__)
1.21 +#define __GRDSTD_H__
1.22 +
1.23 +#if !defined(__E32STD_H__)
1.24 +#include <e32std.h>
1.25 +#endif
1.26 +#if !defined(__GDI_H__)
1.27 +#include <gdi.h>
1.28 +#endif
1.29 +#if !defined(__GRDCELLS_H__)
1.30 +#include <grdcells.h>
1.31 +#endif
1.32 +#if !defined(__GRDDEF_H__)
1.33 +#include <grddef.h>
1.34 +#endif
1.35 +
1.36 +
1.37 +
1.38 +class MGridTable
1.39 +/** An interface that can be implemented to provide row and column information.
1.40 +
1.41 +Note that for grids that have indefinite row boundaries, an implementation
1.42 +is mandatory.
1.43 +
1.44 +A concrete implementation is passed to a CGridLay object through its CGridLay::ConstructL()
1.45 +functions or its CGridLay::SetGridTable() function.
1.46 +
1.47 +@publishedAll
1.48 +@released */
1.49 + {
1.50 +public:
1.51 + enum
1.52 + {
1.53 + /** The number of rows returned by the default implementation of RowExtent(). */
1.54 + EDefaultRowExtent=20,
1.55 + /** The number of columns returned by the default implementation of ColumnExtent(). */
1.56 + EDefaultColumnExtent=20
1.57 + };
1.58 +public:
1.59 + IMPORT_C virtual TBool RequestRow(TInt aRow,TInt& aReturnRow) const;//If used should be derived from
1.60 + IMPORT_C virtual TInt RowExtent() const;
1.61 + IMPORT_C virtual TInt ColumnExtent() const;
1.62 + };
1.63 +
1.64 +
1.65 +////////////////////////->
1.66 +
1.67 +class TGridColors
1.68 +/** The grid colour specification.
1.69 +
1.70 +An object of this type encapsulates the colours to be used when drawing a
1.71 +grid cell.
1.72 +
1.73 +@publishedAll
1.74 +@released
1.75 +@see CGridLabelImg */
1.76 + {
1.77 +public:
1.78 + IMPORT_C TGridColors();
1.79 + IMPORT_C TGridColors(TRgb aForeground, TRgb aBackground, TRgb aLines, TRgb aLabelSeparators);
1.80 +public:
1.81 + /** The foreground colour. */
1.82 + TRgb iForeground;
1.83 + /** The background colour. */
1.84 + TRgb iBackground;
1.85 + /** The colour of lines. */
1.86 + TRgb iLines;
1.87 + /** The colour of label separators. */
1.88 + TRgb iLabelSeparators;
1.89 +// TRgb iEdge;
1.90 + };
1.91 +////////////////////////->
1.92 +
1.93 +
1.94 +class RReadStream;
1.95 +class RWriteStream;
1.96 +class CStreamStore;
1.97 +class CGridImg;
1.98 +class CSparseMap;
1.99 +
1.100 +
1.101 +class CGridLay : public CBase
1.102 +/** Handles the layout of a grid, and controls how columns, rows and selections
1.103 +appear.
1.104 +
1.105 +@publishedAll
1.106 +@released */
1.107 + {
1.108 + friend class CGridImg;
1.109 +public:
1.110 + /** Defines the order in which pages are printed. */
1.111 + enum TPageOrder
1.112 + {
1.113 + /** All pages in a horizontal line are drawn before starting on the next horizontal
1.114 + line. */
1.115 + ERightThenDown,
1.116 + /** All pages in a vertical line are drawn before starting on the next vertical
1.117 + line to the right. */
1.118 + EDownThenRight
1.119 + };
1.120 + /** Indicates whether the size of the grid should be adjusted when columns and
1.121 + rows are inserted or deleted. */
1.122 + enum TFixGridRange
1.123 + {
1.124 + /** The grid range should not be adjusted on insertion or deletion of rows and/or columns. */
1.125 + EFixGridRange,
1.126 + /** The grid range can be adjusted on insertion or deletion of rows and/or columns. */
1.127 + EAdjustGridRange
1.128 + };
1.129 +public:
1.130 + IMPORT_C CGridLay(MGraphicsDeviceMap* aGraphicsDeviceMap);
1.131 + IMPORT_C void ConstructL(CGridLay* aGridLay,CGridImg* aGridImg);//Constructs Partial Copy
1.132 + IMPORT_C void ConstructL(const MGridTable *aGridTable,CGridImg *aGridImg,TInt aNoOfRows,TInt aNoOfCols);
1.133 + IMPORT_C void ConstructL(const MGridTable *aGridTable,CGridImg *aGridImg,TInt aNoOfCols);
1.134 + IMPORT_C virtual ~CGridLay();
1.135 +
1.136 + IMPORT_C TPoint PageScroll(TMoveDirectionAndAmount aPageScroll);
1.137 + IMPORT_C TPoint ExposeCell(const TCellRef &aCell);
1.138 + IMPORT_C TPoint ExposeCellToTopLeft(const TCellRef &aCell);
1.139 +
1.140 + IMPORT_C void SetGridImgL(CGridImg* aGridImg);
1.141 + inline void SetGridTable(const MGridTable* aGridTable);
1.142 + inline TRangeRef VisibleRange() const;
1.143 + IMPORT_C void SetVisibleRange(const TCellRef& aTopLeftCell);
1.144 + inline TRangeRef TitleRange() const;
1.145 + inline TRangeRef GridRange() const;
1.146 + IMPORT_C void SetGraphicsDeviceMap(MGraphicsDeviceMap* aGraphicsDeviceMap);
1.147 + IMPORT_C void SetGridToDefault();
1.148 +
1.149 + IMPORT_C TInt ColumnWidthInTwips(TInt aCol) const;
1.150 + IMPORT_C void SetColumnWidthInTwipsL(TInt aCol,TInt aWidthInTwips);
1.151 + IMPORT_C TInt SetColumnWidthInTwipsL(TInt aStartCol,TInt aEndCol,TInt aWidthInTwips);
1.152 + IMPORT_C TInt DefaultColumnWidthInTwips() const;
1.153 + IMPORT_C void SetDefaultColumnWidthInTwips(TInt aWidthInTwips);
1.154 + IMPORT_C void SetColumnWidthsToDefault();
1.155 + IMPORT_C TInt MinColumnWidthInPixels() const;
1.156 + IMPORT_C void SetMinColumnWidthInPixels(TInt aWidthInPixels);
1.157 + IMPORT_C TInt ColumnWidthOfSelectedInTwips() const;
1.158 + IMPORT_C void SetColumnWidthOfSelectedInTwipsL(TInt aWidthInTwips);
1.159 + IMPORT_C TInt RowHeightInTwips(TInt aRow) const;
1.160 + IMPORT_C void SetRowHeightInTwipsL(TInt aRow,TInt aHeightInTwips);
1.161 + IMPORT_C TInt SetRowHeightInTwipsL(TInt aStartRow,TInt aEndRow,TInt aHeightInTwips);
1.162 + IMPORT_C TInt DefaultRowHeightInTwips() const;
1.163 + IMPORT_C void SetDefaultRowHeightInTwips(TInt aHeightInTwips);
1.164 + IMPORT_C void SetRowHeightsToDefault();
1.165 + IMPORT_C TInt MinRowHeightInPixels() const;
1.166 + IMPORT_C void SetMinRowHeightInPixels(TInt aHeightInPixels);
1.167 + IMPORT_C TInt RowHeightOfSelectedInTwips() const;
1.168 + IMPORT_C void SetRowHeightOfSelectedInTwipsL(TInt aHeightInTwips);
1.169 + IMPORT_C void RecalcPixelSparseMaps();
1.170 + IMPORT_C void InsertDeleteColumns(TInt aStartCol,TInt aNoOfCols,
1.171 + TFixGridRange aFixGridRange=EFixGridRange);
1.172 + IMPORT_C void InsertDeleteRows(TInt aStartRow,TInt aNoOfRows,
1.173 + TFixGridRange aFixGridRange=EFixGridRange);
1.174 +
1.175 + inline TBool IsSideLabels() const;
1.176 + IMPORT_C void SetSideLabels(TBool aState);
1.177 + inline TBool IsTopLabels() const;
1.178 + IMPORT_C void SetTopLabels(TBool aState);
1.179 + inline TBool IsVerticalGridLines() const;
1.180 + IMPORT_C void SetVerticalGridLines(TBool aState);
1.181 + inline TBool IsHorizontalGridLines() const;
1.182 + IMPORT_C void SetHorizontalGridLines(TBool aState);
1.183 + inline TBool IsGridLabelSeparators() const;
1.184 + IMPORT_C void SetGridLabelSeparators(TBool aState);
1.185 + inline TBool IsColumnBursting() const;
1.186 + IMPORT_C void SetColumnBursting(TBool aState);
1.187 + inline TBool IsCursorVisible() const;
1.188 + IMPORT_C void SetCursorVisible(TBool aVisible);
1.189 + inline TBool IsHighlightVisible() const;
1.190 + IMPORT_C void SetHighlightVisible(TBool aVisible);
1.191 + inline TBool IsRowPermanentlySelected() const;
1.192 + IMPORT_C void SetRowPermanentlySelectedL(TBool aState);
1.193 + inline TBool IsTitleLines() const;
1.194 + inline TBool IsHorizontalTitleLine() const;
1.195 + inline TBool IsVerticalTitleLine() const;
1.196 + IMPORT_C void SetTitleLinesL(TBool aState);
1.197 + IMPORT_C void SetTitleLinesL(const TCellRef& aCellRef);
1.198 + IMPORT_C void ToggleTitleLinesL();
1.199 + inline TBool IsIndefiniteRowBoundaries() const;
1.200 + inline TBool IsUniformRowHeight() const;
1.201 + IMPORT_C void SetUniformRowHeight(TBool aState);
1.202 + inline TBool IsUniformColumnWidth() const;
1.203 + IMPORT_C void SetUniformColumnWidth(TBool aState);
1.204 + inline TBool IsTopLabelDragDisabled() const;
1.205 + IMPORT_C void SetTopLabelDragDisabled(TBool aState);
1.206 + inline TBool IsSideLabelDragDisabled() const;
1.207 + IMPORT_C void SetSideLabelDragDisabled(TBool aState);
1.208 + inline TBool IsPrintedLabels() const;
1.209 + IMPORT_C void SetPrintedLabels(TBool aState);
1.210 + inline TBool IsPrintedGridLines() const;
1.211 + IMPORT_C void SetPrintedGridLines(TBool aState);
1.212 + inline TBool IsEncroachingCellBorders() const;
1.213 + IMPORT_C void SetEncroachingCellBorders(TBool aState);
1.214 + inline TBool IsRowSelectionDisabled() const;
1.215 + IMPORT_C void SetRowSelectionDisabled(TBool aState);
1.216 + inline TBool IsColumnSelectionDisabled() const;
1.217 + IMPORT_C void SetColumnSelectionDisabled(TBool aState);
1.218 + inline TBool IsAutoClearGridCells() const;
1.219 + IMPORT_C void SetAutoClearGridCells(TBool aState);
1.220 + inline TBool IsPageBreakLinesHidden() const;
1.221 + IMPORT_C void SetPageBreakLinesHidden(TBool aState);
1.222 + inline TBool HasChanged() const;
1.223 + inline void SetHasChanged(TBool aHasChanged);
1.224 + inline void SetGridEdgeColor(TRgb aColor);
1.225 +
1.226 + IMPORT_C TInt MinVisibleFromRow() const;
1.227 + IMPORT_C TInt MinVisibleFromColumn() const;
1.228 + IMPORT_C void ResetVisibleToRow();
1.229 + IMPORT_C void ResetVisibleToColumn();
1.230 + IMPORT_C void ResetVisibleToCell();
1.231 + IMPORT_C TInt RowExtent() const;
1.232 + IMPORT_C TInt ColumnExtent() const;
1.233 +
1.234 + IMPORT_C TInt RowToYVal(TInt aRow) const;
1.235 + IMPORT_C TInt RowToYVal(TInt aStartRow,TInt aEndRow) const;
1.236 + IMPORT_C TInt VisibleRowToYVal(TInt aRow) const;
1.237 + IMPORT_C TInt TitleRowToYVal(TInt aTitleRow) const;
1.238 + IMPORT_C TInt ColumnToXVal(TInt aCol) const;
1.239 + IMPORT_C TInt ColumnToXVal(TInt aStartCol,TInt aEndCol) const;
1.240 + IMPORT_C TInt VisibleColumnToXVal(TInt aCol) const;
1.241 + IMPORT_C TInt TitleColumnToXVal(TInt aTitleCol) const;
1.242 + IMPORT_C TInt YValToRow(TInt aYVal) const;
1.243 + IMPORT_C TInt YValToRow(TInt aStartRow,TInt aDisp) const;
1.244 + IMPORT_C TInt YValToTitleRow(TInt aYVal) const;
1.245 + IMPORT_C TInt XValToColumn(TInt aXVal) const;
1.246 + IMPORT_C TInt XValToColumn(TInt aStartCol,TInt aDisp) const;
1.247 + IMPORT_C TInt XValToTitleColumn(TInt aXVal) const;
1.248 + IMPORT_C TCellRef PointToCell(const TPoint &aPoint) const;
1.249 + IMPORT_C TCellRef PointToCell(const TCellRef &aStartCell,const TPoint &aPointDisp) const;
1.250 + IMPORT_C TPoint CellToPoint(const TCellRef &aCell) const;
1.251 + IMPORT_C TPoint CellToPoint(const TCellRef &aStartCell,const TCellRef &aEndCell) const;
1.252 + IMPORT_C TPoint TitleCellToPoint(const TCellRef& aTitleCell) const;
1.253 + IMPORT_C TRect CellToRect(const TCellRef& aCell) const;
1.254 + IMPORT_C TInt YValToNearestRow(TInt aStartRow,TInt aDisp) const;
1.255 + IMPORT_C TInt XValToNearestColumn(TInt aStartCol,TInt aDisp) const;
1.256 + IMPORT_C TSize TopLeftTitleRangeSize() const;
1.257 +
1.258 + IMPORT_C void PaginateL();
1.259 + IMPORT_C void ClearPagination();
1.260 + IMPORT_C void NotifyPaginationOutOfDateL();
1.261 + inline TBool IsPaginated() const;
1.262 + IMPORT_C TRangeRef PageToRange(TInt aPageNo,TPageOrder aPageOrder) const;
1.263 + inline void SetPrintRange(const TRangeRef& aPrintRange);
1.264 + IMPORT_C TInt NoOfPages() const;
1.265 + IMPORT_C void SetPageSizeInTwipsL(const TSize& aPageSize);
1.266 + inline TSize PageSizeInTwips() const;
1.267 + inline TBool IsAutoPagination() const;
1.268 + IMPORT_C void SetAutoPagination(TBool aState);
1.269 + IMPORT_C TBool IsHardRowPageBreak(TInt aRow) const;
1.270 + IMPORT_C TBool IsHardColumnPageBreak(TInt aCol) const;
1.271 + IMPORT_C void SetHardRowPageBreakL(TInt aRow);
1.272 + IMPORT_C void ClearHardRowPageBreakL(TInt aRow);
1.273 + IMPORT_C void SetHardColumnPageBreakL(TInt aCol);
1.274 + IMPORT_C void ClearHardColumnPageBreakL(TInt aCol);
1.275 + IMPORT_C void ClearAllHardPageBreaksL();
1.276 +
1.277 + IMPORT_C void ExternalizeL(RWriteStream &aStream) const;
1.278 + IMPORT_C void InternalizeL(RReadStream &aStream);
1.279 + IMPORT_C TStreamId StoreL(CStreamStore& aStore) const;
1.280 + IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aStreamId);
1.281 +////////////////////////->
1.282 +// Setting the grid colors
1.283 + IMPORT_C void SetGridColors(TGridColors aColors);
1.284 +// Getting the grid colors
1.285 + IMPORT_C const TGridColors& GridColors() const;
1.286 +////////////////////////->
1.287 +private:
1.288 + void SetIndefiniteRowBoundaries(TBool aState);
1.289 + inline TBool IsVisibleToRowFullyVisible() const;
1.290 + void SetVisibleToRowFullyVisible(TBool aState);
1.291 + inline TBool IsVisibleToColumnFullyVisible() const;
1.292 + void SetVisibleToColumnFullyVisible(TBool aState);
1.293 + TInt ColumnWidthInPixels(TInt aCol) const;
1.294 + void SetColumnWidthInPixelsL(TInt aCol,TInt aWidthInPixels);
1.295 + void PreCheckColumnWidthChange(TInt aCol,TBool aNonZeroWidth);
1.296 + void PostCheckColumnWidthChange(TInt aCol,TBool aNonZeroWidth);
1.297 + TInt DefaultColumnWidthInPixels() const;
1.298 + void SetDefaultColumnWidthInPixels(TInt aWidthInPixels);
1.299 + TInt RowHeightInPixels(TInt aRow) const;
1.300 + void SetRowHeightInPixelsL(TInt aRow,TInt aHeightInPixels);
1.301 + void PreCheckRowHeightChange(TInt aRow,TBool aNonZeroHeight);
1.302 + void PostCheckRowHeightChange(TInt aRow,TBool aNonZeroHeight);
1.303 + TInt DefaultRowHeightInPixels() const;
1.304 + void SetDefaultRowHeightInPixels(TInt aHeightInPixels);
1.305 + TPoint CalcOffsetBetweenCells(const TCellRef& aCell1,const TCellRef& aCell2) const;
1.306 + TBool LimitRow(TInt& aRow) const;
1.307 + TBool LimitColumn(TInt &aColumn) const;
1.308 + void LimitRow(TInt& aRow,TInt aLowerLimit,TInt aUpperLimit) const;
1.309 + void LimitColumn(TInt& aCol,TInt aLowerLimit,TInt aUpperLimit) const;
1.310 + TBool LimitCell(TCellRef& aCell) const;
1.311 + void LimitRowToVisible(TInt& aRow) const;
1.312 + void LimitColumnToVisible(TInt& aCol) const;
1.313 + void LimitCellToVisible(TCellRef& aCell) const;
1.314 + TBool IsCellOutOfVisibleRange(const TCellRef &aCell) const;
1.315 + TBool IsCellOutOfGridRange(const TCellRef& aCell) const;
1.316 + void StepRowForward(TInt& aRow) const;
1.317 + void StepRowBackward(TInt& aRow) const;
1.318 + void StepColumnForward(TInt& aCol) const;
1.319 + void StepColumnBackward(TInt& aCol) const;
1.320 + void CalcVisibleFromRow(TInt aVisibleToRow,TInt& aNewVisibleFromRow) const;
1.321 + TBool CalcVisibleToRow(TInt aVisibleFromRow,TInt& aNewVisibleToRow) const;
1.322 + void CalcVisibleFromColumn(TInt aVisibleToCol,TInt& aNewVisibleFromCol) const;
1.323 + TBool CalcVisibleToColumn(TInt aVisibleFromCol,TInt& aNewVisibleToCol) const;
1.324 + TInt CalcVisibleFromRowAfterPageScroll(TMoveDirectionAndAmount aPageScroll) const;
1.325 + TInt CalcVisibleFromColumnAfterPageScroll(TMoveDirectionAndAmount aPageScroll) const;
1.326 + TCellRef CalcVisibleFromCellAfterPageScroll(TMoveDirectionAndAmount aPageScroll) const;
1.327 + TBool FindNextRowPageBreak(TInt aSearchStart,TInt& aFoundRow) const;
1.328 + TBool FindNextColumnPageBreak(TInt aSearchStart,TInt& aFoundCol) const;
1.329 + void DoMainPaginationLoopL(TInt aPageSpan,CSparseMap* aCellSpanMap,CSparseMap* aPageMap,
1.330 + CArrayFix<TInt>* aHardPageBreaks,TInt aStartId);
1.331 + TBool RequestRow(TInt aRow,TInt& aReturnRow) const;
1.332 +
1.333 + void ConstructL(const MGridTable *aGridTable,CGridImg *aGridImg,const TRangeRef& aGridRange);
1.334 +//private:
1.335 +private:
1.336 + enum
1.337 + {
1.338 + EMaxArrayChanges=256,
1.339 + EInitialDefaultRowHeightInTwips = 300,
1.340 + EInitialDefaultColumnWidthInTwips = 900
1.341 + };
1.342 + enum
1.343 + {
1.344 + EIsTopLabels = 0x1,
1.345 + EIsSideLabels = 0x2,
1.346 + EIsHorizontalGridLines = 0x4,
1.347 + EIsVerticalGridLines = 0x8,
1.348 + EIsColumnBursting = 0x10,
1.349 + EIsCursorVisible = 0x20,
1.350 + EIsRowPermanentlySelected = 0x40,
1.351 + EIsHorizontalTitleLine = 0x80,
1.352 + EIsVerticalTitleLine = 0x100,
1.353 + EIsIndefiniteRowBoundaries = 0x200,
1.354 + EIsUniformRowHeight = 0x400,
1.355 + EIsUniformColumnWidth = 0x800,
1.356 + EIsTopLabelDragDisabled = 0x1000,
1.357 + EIsSideLabelDragDisabled = 0x2000,
1.358 + EIsPaginated = 0x4000,
1.359 + EIsAutoPagination = 0x8000,
1.360 + EIsPrintedLabels = 0x10000,
1.361 + EIsPrintedGridLines = 0x20000,
1.362 + EIsVisibleToRowFullyVisible = 0x40000,
1.363 + EIsVisibleToColumnFullyVisible = 0x80000,
1.364 + EIsEncroachingCellBorders = 0x100000,
1.365 + EIsColumnSelectionDisabled = 0x200000,
1.366 + EIsRowSelectionDisabled = 0x400000,
1.367 + EIsAutoClearGridCells = 0x800000,
1.368 + EIsGridLabelSeparators = 0x1000000,
1.369 + EIsHighlightVisible = 0x2000000,
1.370 + EIsPageBreakLinesHidden = 0x4000000
1.371 + };
1.372 +private:
1.373 + const MGridTable* iGridTable;
1.374 + const MGraphicsDeviceMap* iGraphicsDeviceMap; //*
1.375 + CGridImg* iGridImg; //*
1.376 +// persistent
1.377 + TRangeRef iGridRange; //*
1.378 + TRangeRef iVisibleRange;
1.379 + TRangeRef iTitleRange;
1.380 + CSparseMap* iColumnWidthMap; //*
1.381 + CSparseMap* iRowHeightMap; //*
1.382 + CSparseMap* iColumnPageMap; //*
1.383 + CSparseMap* iRowPageMap; //*
1.384 + CArrayFix<TInt>* iHardRowPageBreaks;
1.385 + CArrayFix<TInt>* iHardColumnPageBreaks;
1.386 + TRgb iGridEdgeColor;
1.387 + TInt iMinRowHeightInPixels;
1.388 + TInt iMinColumnWidthInPixels;
1.389 + TSize iPageSizeInTwips; //*
1.390 + TUint32 iFlags; //* Starred items are used in printing
1.391 +////////////////////////->
1.392 + TGridColors iColors;
1.393 +////////////////////////->
1.394 +// End of persistent data
1.395 + TBool iHasChanged;
1.396 + };
1.397 +
1.398 +
1.399 +
1.400 +
1.401 +class CGridLabelImg : public CBase
1.402 +/** Draws a grid cell's label.
1.403 +
1.404 +@publishedAll
1.405 +@released */
1.406 + {
1.407 + friend class CGridImg;
1.408 +public:
1.409 + IMPORT_C virtual ~CGridLabelImg();
1.410 + IMPORT_C void ConstructL();
1.411 + inline void SetGraphicsDeviceMap(MGraphicsDeviceMap* aGraphicsDeviceMap);
1.412 + inline TFontSpec FontSpec() const;
1.413 + IMPORT_C void ReleaseFont();
1.414 + IMPORT_C void NotifyGraphicsDeviceMapChangeL();
1.415 + inline void SetGridColors(const TGridColors& aGridColors);
1.416 +protected:
1.417 + IMPORT_C CGridLabelImg(const TFontSpec& aFontSpec,MGraphicsDeviceMap* aGraphicsDeviceMap);
1.418 +////////////////////////->
1.419 + IMPORT_C void DrawTopLeftLabelL(CGraphicsContext* aGc,const TRect& aRect, TRgb aColor) const;
1.420 +////////////////////////->
1.421 +private:
1.422 + /** Draws a row label.
1.423 +
1.424 + @publishedAll
1.425 + @released
1.426 + @param aGc The graphics context to be used.
1.427 + @param aRow The row for which the label is to be drawn.
1.428 + @param aRect The rectangle in which the label is to be drawn. */
1.429 + virtual void DrawRowLabelL(CGraphicsContext* aGc,TInt aRow,const TRect& aRect) const=0;
1.430 + /** Draws a column label.
1.431 +
1.432 + @publishedAll
1.433 + @released
1.434 + @param aGc The graphics context to be used.
1.435 + @param aCol The column for which the label is to be drawn.
1.436 + @param aRect The rectangle in which the label is to be drawn. */
1.437 + virtual void DrawColLabelL(CGraphicsContext* aGc,TInt aCol,const TRect& aRect) const=0;
1.438 + IMPORT_C virtual void DrawTopLeftLabelL(CGraphicsContext* aGc,const TRect& aRect) const;
1.439 + IMPORT_C virtual TInt SideLabelWidthInPixels(TInt aStartRow,TInt aEndRow) const;
1.440 + IMPORT_C virtual TInt TopLabelHeightInPixels() const;
1.441 + IMPORT_C virtual void DrawRowCursorL(CGraphicsContext* aGc,const TRect& aRect) const;
1.442 +protected:
1.443 + enum
1.444 + {
1.445 + /** The default width of side labels, in twips.
1.446 +
1.447 + This is used by the default implementation of SideLabelWidthInPixels(). */
1.448 + EDefaultSideLabelWidthInTwips=300,
1.449 + /** The default height of top labels, in twips.
1.450 +
1.451 + This is used by the default implementation of TopLabelHeightInPixels(). */
1.452 + EDefaultTopLabelHeightInTwips=300
1.453 + };
1.454 +protected:
1.455 + /** The nearest font to that specified in the font specification. */
1.456 + CFont* iFont;
1.457 + /** The font specification in device independent terms. */
1.458 + TFontSpec iFontSpec;
1.459 + /** The graphics device map, an interface for mapping between twips and device-specific
1.460 + units. */
1.461 + MGraphicsDeviceMap* iGraphicsDeviceMap;
1.462 + /** The grid colour specification. */
1.463 + TGridColors iGridColors;
1.464 +private:
1.465 + TInt iSpare;
1.466 + };
1.467 +
1.468 +
1.469 +class CGridCellImg : public CBase
1.470 +/** Draws a grid cell's contents.
1.471 +
1.472 +@publishedAll
1.473 +@released */
1.474 + {
1.475 + friend class CGridImg;
1.476 +public:
1.477 + IMPORT_C virtual ~CGridCellImg();
1.478 + inline TInt BurstColOffset() const;
1.479 + inline TInt BurstLeft() const;
1.480 + inline TInt BurstRight() const;
1.481 + inline TBool IsHorizontalGridLines() const;
1.482 + inline TBool IsVerticalGridLines() const;
1.483 + inline void SetGridColors(const TGridColors& aGridColors);
1.484 +protected:
1.485 + IMPORT_C CGridCellImg();
1.486 +private:
1.487 + /** Draws the contents of the specified cell.
1.488 +
1.489 + @publishedAll
1.490 + @released
1.491 + @param aGc The graphics context to be used.
1.492 + @param aCell The cell whose contents are to be drawn.
1.493 + @param aDrawRect The rectangle in which the cell is to be drawn.
1.494 + @param aClipRect The rectangle to which drawing is clipped. */
1.495 + virtual void DrawL(CGraphicsContext* aGc,const TCellRef& aCell,const TRect& aDrawRect,
1.496 + const TRect& aClipRect) const=0;
1.497 + IMPORT_C virtual TInt DataWidthInPixelsL(const TCellRef& aCell) const;
1.498 + IMPORT_C virtual TBool DoesCellContainDataL(const TCellRef& aCell) const;
1.499 +// reserved virtual function
1.500 + IMPORT_C virtual void Reserved_1();
1.501 +private:
1.502 + void SetBurstingData(TInt aBurstColOffset=0,TInt aBurstLeft=0,TInt aBurstRight=0);
1.503 +private:
1.504 + enum { EIsHorizontalGridLines = 0x1, EIsVerticalGridLines = 0x2 };
1.505 +protected:
1.506 + /** The grid colour specification. */
1.507 + TGridColors iGridColors;
1.508 +private:
1.509 + TInt iBurstColOffset;
1.510 + TInt iBurstLeft;
1.511 + TInt iBurstRight;
1.512 + TUint32 iGridLineFlags;
1.513 + };
1.514 +
1.515 +
1.516 +class MGridCursorMoveCallBack
1.517 +/** An interface to a callback function that is intended to be called whenever
1.518 +there is a change to the cursor position.
1.519 +
1.520 +If such a callback is needed, a concrete implementation is defined, instantiated
1.521 +and passed to CGridImg::SetCursorMoveCallBack().
1.522 +
1.523 +@publishedAll
1.524 +@released */
1.525 + {
1.526 +public:
1.527 + /** Deals with the change to the cursor position.
1.528 +
1.529 + This function is called immediately before exiting the following functions:
1.530 + CGridImg::SetCursorPosL(), CGridImg::SetAnchorPosL(), CGridImg::MoveCursorL(),CGridImg::ResetSelectedL(),
1.531 + CGridImg::AddRangeToSelectedL(), CGridImg::AddRegionToSelectedL(), CGridImg::AddRowToSelectedL(),
1.532 + CGridImg::AddColToSelectedL().
1.533 +
1.534 + The function is commonly used to do any necessary redrawing. */
1.535 + virtual void HandleCursorMoveL()=0;
1.536 + };
1.537 +
1.538 +class RWindow;
1.539 +class CWindowGc;
1.540 +
1.541 +
1.542 +class CGridImg : public CBase
1.543 +/** Draws the contents of the grid.
1.544 +
1.545 +@publishedAll
1.546 +@released
1.547 +*/
1.548 + {
1.549 + friend class CGridLay;
1.550 +public:
1.551 + enum
1.552 + {
1.553 + /** Indicates that the selection state is to be maintained.
1.554 +
1.555 + If a region of cells is selected, then this selection is to be kept.
1.556 +
1.557 + Typically, this is set by a control when a drag operation is in
1.558 + progress and the shift modifier key is also pressed. */
1.559 + EIsWithSelect=0x0001,
1.560 + /** Indicates that the control modifier key has been pressed. */
1.561 + EIsWithControl=0x0002,
1.562 + /** Indicates that a drag operation is in progress. */
1.563 + EIsWithDrag=0x0004,
1.564 + /** Indicates that the cursor is the edge of the grid. */
1.565 + EIsAtBoundary=0x0008,
1.566 + /** Indicates that a new cell is being selected, without dragging. */
1.567 + EIsAbsoluteMove=0x0010,
1.568 + /** Indicates that a whole row is selected. */
1.569 + EIsRowSelected=0x0020,
1.570 + /** Indicates that a whole column is selected.
1.571 +
1.572 + This also means that the label cell for the column is included in the selection. */
1.573 + EIsColumnSelected=0x0040
1.574 + };
1.575 + enum
1.576 + {
1.577 + /** Defines a scale value of 100.
1.578 +
1.579 + Scale factor values are divided into this value to calculate
1.580 + drawing points, rectangles etc. */
1.581 + EScaleOneToOne=100
1.582 + };
1.583 +
1.584 + enum TSelectType
1.585 + {
1.586 + /** Indicates that an existing selected region is to be reset (i.e. emptied) before
1.587 + adding a new region. */
1.588 + ESelectOverwrite,
1.589 + /** Indicates that a new region is to be appended to any existing selected region. */
1.590 + ESelectAppend
1.591 + };
1.592 +public:
1.593 + IMPORT_C virtual ~CGridImg();
1.594 + IMPORT_C static CGridImg* NewL(CGraphicsDevice* aGraphicsDevice,CGridCellImg* aGridCellImg,CGridLay* aGridLay);
1.595 + IMPORT_C static CGridImg* NewL(CGridCellImg* aGridCellImg,CGridLay* aGridLay); //Creates Partial GridImg
1.596 + inline void SetGridLay(CGridLay* aGridLay);
1.597 + inline void SetWindow(RWindow* aWin);
1.598 +////////////////////////->
1.599 + IMPORT_C void SetGridLabelImg(CGridLabelImg* aGridLabelImg);
1.600 +////////////////////////->
1.601 + inline void SetCursorMoveCallBack(MGridCursorMoveCallBack* aCursorMoveCallBack);
1.602 + inline const CGridCellRegion* Selected() const;
1.603 + inline const CGridLabelImg* GridLabelImg() const;
1.604 +
1.605 + IMPORT_C void ScrollL(const TPoint &aOffset);
1.606 + IMPORT_C void MoveCursorL(TMoveDirectionAndAmount aCursorMove,TUint aSelectState);
1.607 + IMPORT_C void SetCursorWithPointerL(const TPoint& aPoint,TUint aFlagList);
1.608 + IMPORT_C void ResetSelectedL();
1.609 + IMPORT_C void AddRangeToSelectedL(const TRangeRef& aRange,TSelectType aType=ESelectOverwrite);
1.610 + IMPORT_C void AddRegionToSelectedL(const CArrayFix<TRangeRef>* aCellRegion,TSelectType aType=ESelectOverwrite);
1.611 + IMPORT_C void AddRowToSelectedL(TInt aRow,TSelectType aType=ESelectOverwrite);
1.612 + IMPORT_C void AddColToSelectedL(TInt aCol,TSelectType aType=ESelectOverwrite);
1.613 + IMPORT_C void DrawL(CGraphicsContext* aGc) const;
1.614 + IMPORT_C void DrawL(CGraphicsContext* aGc,const TRect& aRect) const;
1.615 + IMPORT_C void DrawCellL(const TCellRef& aCell) const;
1.616 + IMPORT_C void DrawRangeL(const TRangeRef& aRange) const;
1.617 + IMPORT_C void DrawSelectedL() const;
1.618 + IMPORT_C void DrawTitleLines() const;
1.619 + IMPORT_C void ClearTitleLineRegionL(const TPoint& aCrossPoint) const;
1.620 + IMPORT_C void PrintGridLinesAndCellsInRangeL(CGraphicsContext* aPrinterGc,const TRangeRef& aRange,
1.621 + TInt aScaleFactor) const;
1.622 +
1.623 + inline TCellRef CursorPos() const;
1.624 + IMPORT_C void SetCursorPosL(const TCellRef& aCursorPos);
1.625 + inline TCellRef NewCursorPos() const;
1.626 + inline TCellRef AnchorPos() const;
1.627 + IMPORT_C void SetAnchorPosL(const TCellRef& aAnchorPos);
1.628 + inline TRect GridRect() const;
1.629 + IMPORT_C void SetGridRect(const TRect& aNewRect);
1.630 + IMPORT_C void SetPrintGridRect(const TRect& aPrintRect);
1.631 + inline TPoint TitlePoint() const;
1.632 + inline TPoint MainPoint() const;
1.633 + inline TRect MainRect() const;
1.634 + IMPORT_C void ResetReferencePoints();
1.635 + IMPORT_C void NotifyGridRangeResize();
1.636 +
1.637 + IMPORT_C void CheckSideLabelWidthAndScrollL();
1.638 + IMPORT_C TInt CheckSideLabelWidth();
1.639 + IMPORT_C TInt SideLabelWidthInPixels() const;
1.640 + IMPORT_C TInt MaxSideLabelWidthInPixels() const;
1.641 + IMPORT_C TInt TopLabelHeightInPixels() const;
1.642 + IMPORT_C void FinishLabelDragL();
1.643 + IMPORT_C TBool StartLabelDrag(const TPoint &aPoint);
1.644 + IMPORT_C TBool UpdateLabelDrag(const TPoint &aPoint);
1.645 + IMPORT_C TBool StartLabelResize(TBool aIsColumnLabel, TInt aIndex);
1.646 + IMPORT_C TBool UpdateLabelResize(TInt aDelta);
1.647 + IMPORT_C void FinishLabelResizeL(TBool aResize);
1.648 +private:
1.649 + enum TDragDim {EXDrag,EYDrag,ENoDrag};
1.650 + enum TRefPoint {ETitleRef,EMainRef};
1.651 + enum TDragDraw {EDragDrawWithBitmap,EDragDrawWithoutBitmap};
1.652 + enum TArrows {EBothArrows,ESecondArrowOnly};
1.653 + enum
1.654 + {
1.655 + EIsLabelDraggingIgnored = 0x1,
1.656 + EIsSidewaysScrollIgnored = 0x2
1.657 + };
1.658 +private:
1.659 + void DrawResizingDragHiglights(const TRect& aRect);
1.660 + void DrawAllGridLabelsL() const;
1.661 + void DrawTopLeftGridLabelL() const;
1.662 + void DrawTopGridLabelsL(TInt aStartCol,TInt aEndCol,TRefPoint aXRef=EMainRef) const;
1.663 + void DrawSideGridLabelsL(TInt aStartRow,TInt aEndRow,TRefPoint aYRef=EMainRef) const;
1.664 + void DrawSideGridLabelIfOnScreenL(TInt aRow) const;
1.665 + void DrawAllGridLinesAndCellsL() const;
1.666 + void DrawGridLinesAndCellsInRangeL(const TRangeRef& aRange,const TRect& aClipRect,
1.667 + TRefPoint aXRef=EMainRef,TRefPoint aYRef=EMainRef) const;
1.668 + void DrawCellsToGcL(CGraphicsContext* aGc,const TRangeRef& aRange,const TRect& aClipRect,
1.669 + const TPoint& aStartPoint,TInt aScaleFactor=EScaleOneToOne) const;
1.670 + void DrawBurstingCellL(CGraphicsContext* aGc,const TCellRef& aCell,const TRect& aRect,const TRect& aClipRect,
1.671 + TInt aScaleFactor,TInt aBurstLeft,const TCellRef& aBurstCell) const;
1.672 + TInt CalcBurstLeftL(TCellRef& aBurstCell,TInt aScaleFactor) const;
1.673 + TInt CalcBurstRightL(const TCellRef& aCell,TInt aExcessRight,TInt aScaleFactor) const;
1.674 + void DrawVerticalTitleLine() const;
1.675 + void DrawHorizontalTitleLine() const;
1.676 + void BeginRedrawAndDrawL() const;
1.677 + void BeginRedrawAndDrawL(const TRect& aRect) const;
1.678 +
1.679 + void AppendTotalHighlightRegionL(TRegion& aRegion) const;
1.680 + void AppendPartialHighlightRegionL(TRegion& aRegion,const TRect& aClipRect,
1.681 + TRefPoint aXRef=EMainRef,TRefPoint aYRef=EMainRef) const;
1.682 + void RemoveRowLabelFromRegionL(TInt aRow,TRegion& aRegion) const;
1.683 + void HighlightMinRegionL(const TRegion &aOldRegion,const TRegion &aNewRegion);
1.684 + void HighlightRegion(const TRegion &aRegion) const;
1.685 + void HighlightNewRegionFromOldL(const TRegion& aOldRegion);
1.686 + void DrawCursorOrRegionL(TUint aMoveFlags);
1.687 + void UpdateSelectedRegion(TInt aSelectCount,TUint aMoveFlags);
1.688 + void AddLabelToRegionL(TUint aMoveFlags);
1.689 + void StartSelectedRegionL(TUint aMoveFlags);
1.690 + TBool ScanColumnsForDrag(TInt aFromColumn,TInt aToColumn,TInt aPointerPos,TInt& aPrevious,TInt& aCurrent);
1.691 + TBool ScanRowsForDrag(TInt aFromRow,TInt aToRow,TInt aPointerPos,TInt& aPrevious,TInt& aCurrent);
1.692 + void DrawDraggingHighlight(const TRect aLine,TDragDraw aDragDraw);
1.693 + void DrawArrowsToInMemoryBitmap(TArrows aArrows);
1.694 + TPoint RelativeCellToPoint(const TCellRef& aCell,TRefPoint aXRef=EMainRef,
1.695 + TRefPoint aYRef=EMainRef) const;
1.696 + TCellRef RelativePointToCell(const TPoint& aPoint,TRefPoint aXRef=EMainRef,
1.697 + TRefPoint aYRef=EMainRef) const;
1.698 + TRect PartialCellRectL(const TCellRef& aCell,const TRect& aClipRect,
1.699 + TRefPoint aXRef=EMainRef,TRefPoint aYRef=EMainRef) const;
1.700 + TRect PartialRangeRect(const TRangeRef& aRange,const TRect& aClipRect,
1.701 + TRefPoint aXRef=EMainRef,TRefPoint aYRef=EMainRef) const;
1.702 + void CreateGc(CGraphicsContext* aGc);
1.703 + void DeleteGc();
1.704 + static void CleanupGc(TAny* aObject);
1.705 + void ResetGcToDefault(CGraphicsContext* aGc) const;
1.706 + void ScaleDown(TPoint& aPoint,TInt aScaleFactor) const;
1.707 + void ConstructSelectedL(const TRangeRef& aGridRange);
1.708 +
1.709 + CGridImg(CGraphicsDevice* aGraphicsDevice,CGridCellImg* aGridCellImg,CGridLay* aGridLay);
1.710 + CGridImg(CGridCellImg* aGridCellImg,CGridLay* aGridLay);
1.711 + void ConstructL();
1.712 +
1.713 +////////////////////////->
1.714 + void SetGridColors(const TGridColors& aGridColors);
1.715 +////////////////////////->
1.716 +private:
1.717 + TRect iGridRect;
1.718 + TPoint iTitlePoint;
1.719 + TPoint iMainPoint;
1.720 + TCellRef iCursorPos; // Persisted
1.721 + TCellRef iNewCursorPos;
1.722 + TCellRef iAnchorPos;
1.723 +
1.724 + CGraphicsDevice* iGraphicsDevice;
1.725 + CGraphicsContext* iGcPtr;
1.726 + CWindowGc* iGc;
1.727 + RWindow* iWin;
1.728 + CGridCellImg* iGridCellImg; //*
1.729 + CGridLabelImg* iGridLabelImg; //*
1.730 + CGridLay* iGridLay; //* Starred items are used in printing
1.731 + CGridCellRegion* iSelected;
1.732 + MGridCursorMoveCallBack* iCursorMoveCallBack;
1.733 + TBool iDrawResizeLines;
1.734 + TInt iDragLabel;
1.735 + TInt iCurrentDragPos;
1.736 + TInt iDragDiff;
1.737 + TInt iDragFlags;
1.738 + TDragDim iDragDim;
1.739 + CFbsBitmap* iDragBmp;
1.740 + TRefPoint iXRefPoint;
1.741 + TRefPoint iYRefPoint;
1.742 + };
1.743 +
1.744 +
1.745 +class TGridUtils
1.746 +/** A collection of Grid utilities.
1.747 +
1.748 +@publishedAll
1.749 +@released */
1.750 + {
1.751 +public:
1.752 + IMPORT_C static void FillRect(CGraphicsContext* aGc,TRgb aColor,const TRect &aRect);
1.753 + };
1.754 +
1.755 +
1.756 +#include <grdstd.inl>
1.757 +#endif