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 <qframe.h>
00014 #include <qpainter.h>
00015 #include <qptrlist.h>
00016 
00017 #include <QicsGridInfo.h>
00018 #include <QicsRegion.h>
00019 #include <QicsCellStyle.h>
00020 #include <QicsGridStyle.h>
00021 #include <QicsCellDisplay.h>
00022 #include <QicsICell.h>
00023 
00024 
00027 
00028 #include <qvaluevector.h>
00029 
00030 class QicsPositionList
00031 {
00032 public:
00033     typedef const int *iterator;
00034 
00035     QicsPositionList()  { setFirstIndex(0); init(); }
00036     QicsPositionList(int base)  { setFirstIndex(base); init(); }
00037     
00038     inline int firstIndex(void) const  { return myBase; }
00039     inline void setFirstIndex(int base)  { myBase = base; }
00040 
00041     inline int lastIndex(void) const { return myBase + size() - 1; }
00042 
00043     inline void push_back(const int &val)
00044     { myPositions.push_back(val); }
00045 
00046     inline int at(int idx) const
00047     { return (myPositions.at(idx - myBase)); }
00048 
00049     inline int operator[](int idx) const { return at(idx); }
00050 
00051     inline void clear(void) { myPositions.clear(); }
00052 
00053     inline int size(void) const { return myPositions.size(); }
00054 
00055     inline iterator begin(void) const { return myPositions.begin(); }
00056     inline iterator end(void) const { return myPositions.end(); }
00057 
00058     inline int firstVisible(void) const
00059     {
00060         for (int i = firstIndex(); i <= lastIndex(); ++i)
00061         if (at(i) >= 0) return i;
00062 
00063         return -1;
00064     }
00065 
00066     inline int lastVisible(void) const
00067     {
00068         for (int i = lastIndex(); i >= firstIndex(); --i)
00069         if (at(i) >= 0) return i;
00070 
00071         return -1;
00072     }
00073           
00074 protected:
00075     void init(void) { myPositions.reserve(50); }
00076     QValueVector<int> myPositions;
00077     int myBase; 
00078 };
00079 
00082 
00083 
00105 class QICS_EXPORT QicsGrid: public Qics {
00106 
00107 public:
00113     QicsGrid(QicsGridInfo &info);
00117     virtual ~QicsGrid();
00118 
00122     inline QicsGridInfo &gridInfo(void) const { return myInfo; }
00123 
00129     virtual void setViewport(const QicsRegion &reg);
00130 
00136     virtual QicsRegion viewport(void) const;
00137 
00144     bool isCellValid(int row, int col) const;
00145 
00153     QRect cellDimensions(int row, int col, bool with_spans) const;
00154 
00159     QRect cellDimensions(const QicsICell &cell, bool with_spans) const
00160     { return (cellDimensions(cell.row(), cell.column(), with_spans)); }
00161 
00169     virtual QicsRegion currentViewport(void) const;
00170 
00184     virtual bool requestCellOverflow(const QicsRegion &cur_area,
00185                      const QRect &cur_rect,
00186                      QicsRegion &new_area,
00187                      QRect &new_rect);
00188 
00195     virtual void acceptCellOverflow(QicsRegion &area);
00196 
00201     int modelColumnIndex(int column) const;
00202 
00207     int modelRowIndex(int row) const;
00208 
00218     virtual void orderRowsBy(int column,
00219                  QicsSortOrder order = Ascending,
00220                  DataItemComparator func = 0);
00221 
00227     virtual void orderColumnsBy(int row,
00228                 QicsSortOrder order = Ascending,
00229                 DataItemComparator func = 0);
00230 
00234     void dumpPositions(void) const;
00235 
00236 protected:
00237 
00241     inline QicsDataModel *dataModel(void) const
00242     { return (myInfo.dataModel()); }
00243 
00247     inline QicsStyleManager &styleManager(void) const
00248     { return (*(myInfo.styleManager())); }
00249 
00253     inline QicsDimensionManager &dimensionManager(void) const
00254     { return (*(myInfo.dimensionManager())); }
00255 
00259     inline QicsMappedDimensionManager &mappedDM(void) const
00260     { return (*(myInfo.mappedDM())); }
00261 
00265     inline QicsSelectionManager &selectionManager(void) const
00266     { return (*(myInfo.selectionManager())); }
00267 
00268 
00274     virtual void drawRegion(const QicsRegion &region, QPainter *painter);
00275 
00281     virtual void drawGridLines(const QicsRegion &reg, QPainter *painter);
00282 
00291     virtual void drawCell(int row, int col, int x, int y,
00292               bool look_for_overflower, QPainter *painter);
00293 
00304     virtual bool prepareToDraw(int row, int col, const QRect &rect,
00305                    QPainter *painter);
00306     
00313     virtual const QicsDataItem *cellValue(int row, int col) const;
00314 
00319     QicsICell computeCellPositions(const QRect &bounds,
00320                    const QicsICell &start);
00321 
00325     QicsCellDisplay *cellDisplay(int row, int col) const;
00326 
00328 
00332     QicsGridInfo &myInfo;
00333         
00337     QicsRegion myViewport;
00338 
00339     QicsPositionList myRowPositions;
00343     QicsPositionList myColumnPositions;
00344 
00349     QicsICellQVL myAlreadyDrawnCells;
00350 
00354     QicsRegionV myOverflows;
00355 
00359     QicsMainGrid *myMainGrid;
00360 
00364     QicsCell *myCell;
00365 
00369     QicsRow *myRow;
00373     QicsColumn *myColumn;
00374 };
00375 
00376 #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.