Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Examples  

qdbtbasecell.h

00001 #ifndef _QDBTBASECELL_H
00002 #define _QDBTBASECELL_H
00003 
00004 #include <qdbt/qdbtglobal.h>
00005 #include <qdbt/qdbtsingleton.h>
00006 
00007 class QColor;
00008 class QFont;
00009 class QFontMetrics;
00010 class QKeyEvent;
00011 class QMouseEvent;
00012 class QPainter;
00013 class QRect;
00014 class QString;
00015 class QWidget;
00016 
00017 class QdbtBaseTabular;
00018 class QdbtLineEdit;
00019 class QdbtTable;
00020 class QdbtPImpl;
00021 class QdbtEditorBase;
00022 
00023 class QDBT_EXPORT QdbtBaseCell
00024 {
00025   short _cellFlags;
00026 
00031   friend class QdbtTable;
00032   friend class QdbtEditorBase;
00033 
00034 public:
00035   virtual ~QdbtBaseCell();
00036 
00037   virtual QdbtBaseCell *clone( QdbtBaseTabular * ) const = 0;
00038 
00039   virtual int widthHint( const QFontMetrics &fm ) const;
00040   virtual int heightHint( const QFontMetrics &fm ) const;
00041 
00042   virtual const QColor &color( QdbtBaseTabular * ) const;
00043   virtual const QColor &background( QdbtBaseTabular * ) const;
00044 
00045   virtual QString text() const;
00046 
00047   virtual void setEditable( bool state );
00048   bool isEditable() const;
00049 
00050   virtual void paint( QPainter *p, QdbtBaseTabular *t, const QRect & r,
00051                       bool selected, bool editing = FALSE );
00052   virtual void paintFocus( QPainter *p, QdbtBaseTabular *t, const QRect & r,
00053                            bool selected, bool editing = FALSE );
00054 
00055   virtual QRect getTextArea() const;
00056   virtual QRect getEditArea( int width ) const;
00057 
00058   void rightButtonClicked( QdbtBaseTabular *tab, int row, int col ) const;
00059 
00060 protected:
00061   QdbtBaseCell();
00062 
00063   virtual QWidget *editor( QdbtBaseTabular * ) const;
00064   
00065   virtual bool beginEdit( QdbtBaseTabular *, int row, int col,
00066                           const QRect cellGeometry ) const;
00067   virtual bool acceptEdit( QdbtBaseTabular *, int row, int col );
00068   virtual bool cancelEdit( QdbtBaseTabular *, int row, int col );
00069 
00070   virtual bool mouseEvent( QdbtBaseTabular *, int row, int col,
00071                            QMouseEvent *e, const QRect cellGeometry );
00072   virtual bool keyEvent( QdbtBaseTabular *, int row, int col,
00073                          QKeyEvent *e, const QRect cellGeometry );
00074 
00075 
00076   virtual void setEditorEnabled( QdbtBaseTabular *, bool ) const;
00077 
00078   virtual void moveEditor( QdbtBaseTabular *, const QRect cellGeometry ) const;
00079   
00080   bool aboutToBeEdited( QdbtBaseTabular * ) const;
00081   void notifyOnEditResult( QdbtBaseTabular *tab, int row, int col,
00082                            int result, QString oldText );
00083   QFont font( QdbtBaseTabular * ) const;
00084   bool prepareEditor( QdbtBaseTabular * tab, const QRect & geom ) const;
00085   bool cleanupEditor( QdbtBaseTabular * tab ) const;
00086   
00087   static int MASK_EDITABLE;
00088   static int MASK_SELECTABLE;
00089   static int MASK_SELECTED;
00090   static int bw;
00091 
00092 private:
00093   const QdbtPImpl * pimpl( QdbtBaseTabular * tab ) const;
00094 };
00095 
00096 
00097 class QDBT_EXPORT QdbtNoCell : public QdbtBaseCell
00098 {
00099 public:
00100   QdbtNoCell() : QdbtBaseCell()
00101     {
00102     }
00103   QdbtNoCell( const QdbtNoCell & ) : QdbtBaseCell()
00104     {
00105     }
00106   virtual ~QdbtNoCell()
00107     {
00108     }
00109   
00110   inline virtual QString text() const
00111     {
00112       return "";
00113     }
00114   
00115 protected:
00116   virtual void paint( QPainter *p, QdbtBaseTabular *t, const QRect & r,
00117                       bool selected, bool editing = FALSE );
00118   virtual QdbtBaseCell *clone( QdbtBaseTabular * ) const
00119     {
00120       return new QdbtNoCell( *this );
00121     }
00122 };
00123 
00124 #endif

Generated on Mon Apr 22 12:21:53 2002 for QdbtTabular by doxygen1.2.15-20020421