ICS

QicsTable Documentation Set

QicsCellDisplay.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 _QICSCELLDISPLAY_H
00011 #define _QICSCELLDISPLAY_H
00012 
00013 #include <QicsNamespace.h>
00014 #include <QicsDataItem.h>
00015 #include <QicsGridInfo.h>
00016 
00017 #include <QPainter>
00018 #include <QString>
00019 #include <QEvent>
00020 #include <QList>
00021 #include <QKeyEvent>
00022 #include <QMouseEvent>
00023 
00024 class QicsStyleManager;
00025 class QicsDataItem;
00026 class QicsGrid;
00027 class QicsScreenGrid;
00028 
00029 class QicsCell;
00030 class QicsRow;
00031 class QicsColumn;
00032 class QicsMainGrid;
00033 
00034 // The abstract base class for all cell display objects
00035 
00050 
00051 
00054 
00055 
00056 class QICS_EXPORT QicsCellDisplay: public Qics {
00057 public:
00061     QicsCellDisplay();
00062 
00066     virtual ~QicsCellDisplay();
00067 
00078     virtual void displayCell(QicsGrid *grid, int row, int col,
00079                  const QicsDataItem *itm,
00080                  QRect &rect, QPainter *painter) = 0;
00081 
00094     virtual void startEdit(QicsScreenGrid *grid, int row, int col,
00095                const QicsDataItem *itm) = 0;
00096 
00107     virtual void moveEdit(QicsScreenGrid *grid, int row, int col,
00108               const QRect &rect) = 0;
00109 
00116     virtual void hideEdit(QicsScreenGrid *grid) = 0;
00117 
00126     virtual void endEdit(QicsScreenGrid *grid, int row, int col) = 0;
00127 
00138     virtual bool handleMouseEvent(QicsScreenGrid *grid, int row, int col,
00139                   QMouseEvent *me);
00140 
00151     virtual bool handleKeyEvent(QicsScreenGrid *grid, int row, int col,
00152                 QKeyEvent *ke);
00153 
00162     virtual QSize sizeHint(QicsGrid *grid, int row, int col,
00163                const QicsDataItem *itm) = 0;
00164 
00169     virtual bool editWhenCurrent(void) const = 0;
00170 
00175     inline virtual bool needsVisibilityNotification(void) const { return false; }
00176 
00185     virtual bool isEmpty(QicsGridInfo *info, int row, int col,
00186              const QicsDataItem *itm) const = 0;
00187 
00197     virtual QString tooltipText(QicsGridInfo *info, int row, int col,
00198                 const QicsDataItem *itm, const QRect &rect) const;
00199 
00200 protected:
00214     virtual void drawBackground(QicsGridInfo *info, int row, int col,
00215                 const QRect &rect, const QPalette &pal,
00216                 QPainter *painter,
00217                 bool is_current = false, bool is_selected = false);
00218 
00231     virtual void drawBorder(QicsGridInfo *info, int row, int col,
00232                 const QRect &rect, const QPalette &pal,
00233                 QPainter *painter,
00234                 bool is_current = false, bool is_selected = false);
00235 
00247     virtual bool isCellSelected(QicsGridInfo *info, int row, int col);
00248 
00260     virtual QPalette cellPalette(QicsGridInfo *info,
00261                        int row, int col,
00262                        bool for_printer = false);
00275     virtual QRect displayableCellArea(QicsGridInfo *ginfo,
00276                       int row, int col,
00277                       const QRect &cr_full, 
00278                       bool consider_margin = true,
00279                       bool consider_border = true) const;
00280 
00281 protected:
00282     QPointer<QicsCell>     myCell;
00283     QPointer<QicsRow>      myRow;
00284     QPointer<QicsColumn>   myColumn;
00285     QPointer<QicsMainGrid> myGrid;
00286 };
00287 
00289 
00290 
00305 // An abstract class for all cell display objects that draw each cell,
00306 // and use a single entry widget
00307 
00308 class QICS_EXPORT QicsNoWidgetCellDisplay: public QicsCellDisplay {
00309 public:
00314     QicsNoWidgetCellDisplay();
00315 
00319     virtual ~QicsNoWidgetCellDisplay();
00320 
00324     virtual void startEdit(QicsScreenGrid *, int row, int col,
00325                const QicsDataItem *);
00329     virtual void moveEdit(QicsScreenGrid *, int row, int col, const QRect &rect);
00330 
00334     virtual void endEdit(QicsScreenGrid *grid, int row, int col);
00335 
00339     virtual void hideEdit(QicsScreenGrid *);
00340 
00341     inline virtual bool editWhenCurrent(void) const { return false; }
00342 };
00343 
00345 
00362 // An abstract class for all cell display objects that draw each cell,
00363 // and use a single entry widget
00364 
00365 class QICS_EXPORT QicsMovableEntryWidgetCellDisplay: public QicsCellDisplay {
00366 public:
00371     QicsMovableEntryWidgetCellDisplay();
00372 
00376     virtual ~QicsMovableEntryWidgetCellDisplay();
00377 
00378     virtual void moveEdit(QicsScreenGrid *, int row, int col, const QRect &rect);
00379     virtual void endEdit(QicsScreenGrid *, int row, int col);
00380     virtual void hideEdit(QicsScreenGrid *);
00381 
00382     inline virtual bool editWhenCurrent(void) const { return true; }
00383 
00384 protected:
00385 // A helper class for QicsMovableEntryWidgetCellDisplay
00386 
00398     class QicsEntryWidgetInfo {
00399     public:
00400     QicsEntryWidgetInfo() { myWidget = 0; myGrid = 0; myItem = 0;
00401                             myRow = -1; myCol = -1; }
00402     ~QicsEntryWidgetInfo() { delete myItem; }
00403 
00407     inline QWidget *widget(void) const { return myWidget; }
00411     inline void setWidget(QWidget *w) { myWidget = w; }
00415     inline QicsScreenGrid *grid(void) const { return myGrid; }
00419     inline void setGrid(QicsScreenGrid *grid) { myGrid = grid; }
00423     inline int row(void) const { return myRow; }
00427     inline void setRow(int row) { myRow = row; }
00431     inline int column(void) const { return myCol; }
00435     inline void setColumn(int col) { myCol = col; }
00439     inline QicsDataItem *item(void) const { return myItem; }
00443     inline void setItem(QicsDataItem *item) { delete myItem; myItem = item; }
00444 
00445     protected:
00446     QWidget *myWidget;
00447     QicsScreenGrid *myGrid;
00448     int myRow;
00449     int myCol;
00450     QicsDataItem *myItem;
00451     };
00452 
00453     typedef QList<QicsEntryWidgetInfo*> QicsEntryWidgetInfoPL;
00454 
00460     virtual QWidget *newEntryWidget(QicsScreenGrid *grid) = 0;
00464     QicsEntryWidgetInfo *getInfoFromGrid(QicsScreenGrid *grid);
00468     QicsEntryWidgetInfo *getInfoFromEntry(const QWidget *widget);
00469 
00479     virtual QRect entryWidgetRect(QicsGridInfo *ginfo, int row, int col,
00480                   QRect cell_rect);
00481 
00486     QicsEntryWidgetInfoPL myEntryList;
00487 };
00488 
00489 #endif /* _QICSCELLDISPLAY_H */
00490 
00491 
00492 

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