ICS

QicsTable Documentation Set

QicsGrid.h

Go to the documentation of this file.
00001 /*********************************************************************
00002 **
00003 ** Copyright (C) 2002-2006 Integrated Computer Solutions, Inc
00004 ** All rights reserved.
00005 **
00006 ** This file is part of the QicsTable Product.
00007 **
00008 **********************************************************************/
00009 
00010 #ifndef _QicsGrid_H
00011 #define _QicsGrid_H
00012 
00013 #include <QPainter>
00014 #include <QList>
00015 
00016 #include <QicsGridInfo.h>
00017 #include <QicsRegion.h>
00018 #include <QicsCellStyle.h>
00019 #include <QicsGridStyle.h>
00020 #include <QicsCellDisplay.h>
00021 #include <QicsICell.h>
00022 
00023 
00026 
00027 #include <QVector>
00028 
00035 class QicsPositionList
00036 {
00037 public:
00038     typedef const int *iterator;
00039 
00040     QicsPositionList()  { setFirstIndex(0); init(); }
00041     QicsPositionList(int base)  { setFirstIndex(base); init(); }
00042 
00043     inline int firstIndex(void) const  { return myBase; }
00044     inline void setFirstIndex(int base)  { myBase = base; }
00045 
00046     inline int lastIndex(void) const { return myBase + size() - 1; }
00047 
00048     inline void push_back(const int &val)
00049     { myPositions.push_back(val); }
00050 
00051     inline int at(int idx) const
00052     {
00053         if ((idx >= myBase) && (idx-myBase<size()))
00054             return (myPositions.at(idx - myBase));
00055         else
00056             return -1;
00057     }
00058     inline int operator[](int idx) const { return at(idx); }
00059 
00060     inline void clear(void) { myPositions.clear(); }
00061 
00062     inline int size(void) const { return myPositions.size(); }
00063 
00064     inline iterator begin(void) const { return myPositions.begin(); }
00065     inline iterator end(void) const { return myPositions.end(); }
00066 
00067     inline int firstVisible(void) const
00068     {
00069         for (int i = firstIndex(); i <= lastIndex(); ++i)
00070         if (at(i) >= 0) return i;
00071 
00072         return -1;
00073     }
00074 
00075     inline int lastVisible(void) const
00076     {
00077         for (int i = lastIndex(); i >= firstIndex(); --i)
00078         if (at(i) >= 0) return i;
00079 
00080         return -1;
00081     }
00082 
00083 protected:
00084     void init(void) { myPositions.reserve(50); }
00085     QVector<int> myPositions;
00086     int myBase;
00087 };
00088 
00091 
00092 
00114 
00115 
00118 
00119 class QICS_EXPORT QicsGrid: public Qics {
00120 
00121 public:
00127     QicsGrid(QicsGridInfo &info,
00128                 int top_row = 0,
00129                 int left_column = 0);
00133     virtual ~QicsGrid();
00134 
00138     inline QicsGridInfo &gridInfo(void) const { return myInfo; }
00139 
00145     virtual void setViewport(const QicsRegion &reg);
00146 
00152     virtual QicsRegion viewport(void) const;
00153 
00160     bool isCellValid(int row, int col) const;
00161 
00169     QRect cellDimensions(int row, int col, bool with_spans) const;
00170 
00175     QRect cellDimensions(const QicsICell &cell, bool with_spans) const
00176     { return (cellDimensions(cell.row(), cell.column(), with_spans)); }
00177 
00185     virtual QicsRegion currentViewport(void) const;
00186 
00200     virtual bool requestCellOverflow(const QicsRegion &cur_area,
00201                      const QRect &cur_rect,
00202                      QicsRegion &new_area,
00203                      QRect &new_rect);
00204 
00211     virtual void acceptCellOverflow(QicsRegion &area);
00212 
00217     int modelColumnIndex(int column) const;
00218 
00223     int modelRowIndex(int row) const;
00224 
00234     virtual void orderRowsBy(QVector<int> columns,
00235                  QicsSortOrder order = Qics::Ascending,
00236                  DataItemComparator func = 0);
00237 
00243     virtual void orderColumnsBy(QVector<int> rows,
00244                 QicsSortOrder order = Qics::Ascending,
00245                 DataItemComparator func = 0);
00246 
00251     void dumpPositions(void) const;
00252 
00253 protected:
00254 
00259     inline QicsDataModel *dataModel(void) const
00260     { return (myInfo.dataModel()); }
00261 
00266     inline QicsStyleManager &styleManager(void) const
00267     { return (*(myInfo.styleManager())); }
00268 
00273     inline QicsDimensionManager &dimensionManager(void) const
00274     { return (*(myInfo.dimensionManager())); }
00275 
00280     inline QicsMappedDimensionManager &mappedDM(void) const
00281     { return (*(myInfo.mappedDM())); }
00282 
00287     inline QicsSelectionManager &selectionManager(void) const
00288     { return (*(myInfo.selectionManager())); }
00289 
00290 
00297     virtual QRect drawRegion(const QicsRegion &region, QPainter *painter, bool drawCellBordersOnly);
00298 
00305     virtual void drawGridLines(const QicsRegion &reg, QPainter *painter);
00306 
00316     virtual QRect drawCell(int row, int col, int x, int y,
00317               bool look_for_overflower, QPainter *painter, bool drawBorderOnly);
00318 
00330     virtual bool prepareToDraw(int row, int col, const QRect &rect,
00331                    QPainter *painter);
00332 
00340     virtual const QicsDataItem *cellValue(int row, int col) const;
00341 
00347     QicsICell computeCellPositions(const QRect &bounds,
00348                    const QicsICell &start,
00349                    QicsIndexType indexType = Qics::RowAndColumnIndex);
00350 
00355     QicsCellDisplay *cellDisplay(int row, int col) const;
00356 
00358 
00363     QicsGridInfo &myInfo;
00364 
00369     QicsRegion myViewport;
00370 
00371     QicsPositionList myRowPositions;
00376     QicsPositionList myColumnPositions;
00377 
00383     QicsICellQVL myAlreadyDrawnCells;
00384 
00389     QicsRegionV myOverflows;
00390 
00395     QicsMainGrid *myMainGrid;
00396 
00401     QicsCell *myCell;
00402 
00407     QicsRow *myRow;
00412     QicsColumn *myColumn;
00413 
00415 
00420     int myTopRow;
00421 
00426     int myLeftColumn;
00427 
00433     int myBottomRow;
00434 
00440     int myFullyVisibleBottomRow;
00446     int myRightColumn;
00447 
00453     int myFullyVisibleRightColumn;
00454 };
00455 
00456 #endif /* _QicsGrid_H --- Do not add anything past this line */

All trademarks and copyrights on this page are properties of their respective owners.
The rest is copyright 1999-2006 Integrated Computer Solutions, Inc.