Index of QT classes

ROOT Qt-layer classes


// @(#)root/qt:$Name:  $:$Id: TQtWidget.h,v 1.45 2007/01/23 17:47:43 fine Exp $
// Author: Valeri Fine   21/01/2002
/****************************************************************************
**
** Copyright (C) 2002 by Valeri Fine.  All rights reserved.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
*****************************************************************************/

#ifndef ROOT_TQtWidget
#define ROOT_TQtWidget

// Definition of TQtWidget class
// "double-buffered" widget

#include <assert.h>
#include "Rtypes.h"
#include "TCanvas.h"

#ifndef __CINT__
#  include <qwidget.h>
#  if (QT_VERSION > 0x039999)
//Added by qt3to4:
#     include <QMouseEvent>
#     include <QCustomEvent>
#     include <QShowEvent>
#     include <QFocusEvent>
#     include <QKeyEvent>
#     include <QResizeEvent>
#     include <QEvent>
#     include <QPaintEvent>
#  endif
#  include <qpixmap.h>
#else
  // List of the fake classes to the fake RootCint happy.
  class QWidget;
  class QPixmap;
  class QMouseEvent;
  class QFocusEvent;
  class QCustomEvent;
  class QKeyEvent;
  class QShowEvent;
  class QPaintEvent;
  class QResizeEvent;
  class QSize;  
  class QString;
  class QEvent;
  class QSizePolicy;
#endif
  class TApplication;
//
// TQtWidget is a custom QWidget to back ROOT TCanvas.
//
// It can be used within Qt-based program and with Qt Designer as a "regular"
// Qt QWidget to create the Qt widget wihe builtin TCanvas'
//
enum EEventTrackingBits {
       kMousePressEvent       = BIT(0), // emit signal as soon as TCanvas processed QMouseEvent* )">mousePressEvent       QMouseEvent
       kMouseMoveEvent        = BIT(1), // emit signal as soon as TCanvas processed QMouseEvent* )">mouseMoveEvent        QMouseEvent
       kMouseReleaseEvent     = BIT(2), // emit signal as soon as TCanvas processed QMouseEvent* )">mouseReleaseEvent     QMouseEvent
       kMouseDoubleClickEvent = BIT(3), // emit signal as soon as TCanvas processed QMouseEvent* )">mouseDoubleClickEvent QMouseEvent
       kKeyPressEvent         = BIT(4), // emit signal as soon as TCanvas processed QKeyEvent* )">keyPressEvent         QKeyEvent
       kEnterEvent            = BIT(5), // emit signal as soon as TCanvas processed QEvent* )">enterEvent            QEvent
       kLeaveEvent            = BIT(6)  // emit signal as soon as TCanvas processed QEvent* )">leaveEvent            QEvent
};

//___________________________________________________________________
class TQtWidgetBuffer : public QPixmap
{
  private:
    QWidget *fWidget;

  public:
    TQtWidgetBuffer(QWidget *w=0) :  QPixmap(), fWidget(w)
    { if (w) resize(w->size()); }
    inline QRect rect () const { return fWidget->rect();}
};
//___________________________________________________________________
class  TQtWidget : public QWidget {
#ifndef __CINT__   
 Q_OBJECT
#endif
private:
		void operator=(const TQtWidget&);
      TQtWidget(const TQtWidget&);
   //----- Private bits, clients can only test but not change them
   UInt_t         fBits;       //bit field status word
   enum {
      kBitMask       = 0x00ffffff
   };
public:
   enum {
      kEXITSIZEMOVE,
      kENTERSIZEMOVE,
      kFORCESIZE
   };
#ifndef __CINT__
   TQtWidget( QWidget* parent=0, const char* name=0, Qt::WFlags f=Qt::WStyle_NoBorder, bool embedded=TRUE);
#else
  TQtWidget( QWidget* parent=0);
#endif  
  virtual ~TQtWidget();
  void SetCanvas(TCanvas *c)                 { fCanvas = c;}
  inline TCanvas  *GetCanvas() const         { return fCanvas;}
  inline QPixmap  &QPixmap& TQtWidget::GetBuffer() or overloads">GetBuffer()               { return fPixmapID;}
  inline const QPixmap  &QPixmap& TQtWidget::GetBuffer() or overloads">GetBuffer()  const  { return fPixmapID;}

  // overloaded methods
  virtual void adjustSize();
  virtual void resize (int w, int h);
  virtual void erase ();
  bool    IsDoubleBuffered() { return fDoubleBufferOn; }
  void    SetDoubleBuffer(bool on=TRUE){ fDoubleBufferOn = on;}
  virtual void SetSaveFormat(const char *format);

protected:
   friend class TGQt;
   TCanvas         *fCanvas;
   TQtWidgetBuffer  fPixmapID; // Double buffer of this widget
   bool        fPaint;
   bool        fSizeChanged;
   bool        fDoubleBufferOn;
   bool        fEmbedded;
   QSize       QSize TQtWidget::fSizeHint">fSizeHint;
   QWidget    *QWidget* TQtWidget::fWrapper">fWrapper;
   QString     QString TQtWidget::fSaveFormat">fSaveFormat;
   void QWidget* wrapper)">SetRootID(QWidget *wrapper);
   QWidget *QWidget* TQtWidget::GetRootID()">GetRootID() const;
   virtual void EmitCanvasPainted() { emit CanvasPainted(); }
   TCanvas  *Canvas();
   bool paintFlag(bool mode=TRUE);
   void AdjustBufferSize();

   // overloaded QWidget methods
   bool paintingActive () const;

   virtual void QEvent* )">enterEvent       ( QEvent *      );
   virtual void QCustomEvent* )">customEvent      ( QCustomEvent *);
   virtual void QFocusEvent* )">focusInEvent     ( QFocusEvent * );
   virtual void QFocusEvent* )">focusOutEvent    ( QFocusEvent * );
   virtual void QEvent* )">leaveEvent       ( QEvent *      );
   virtual void QMouseEvent* )">mouseDoubleClickEvent(QMouseEvent* );
   virtual void QMouseEvent* )">mouseMoveEvent   ( QMouseEvent * );
   virtual void QMouseEvent* )">mousePressEvent  ( QMouseEvent * );
   virtual void QMouseEvent* )">mouseReleaseEvent( QMouseEvent * );
   virtual void QKeyEvent* )">keyPressEvent    ( QKeyEvent *   );
   virtual void QKeyEvent* )">keyReleaseEvent  ( QKeyEvent *   );
   virtual void QShowEvent* )">showEvent        ( QShowEvent *  );
   virtual void QPaintEvent* )">paintEvent       ( QPaintEvent * );
   virtual void QResizeEvent* )">resizeEvent      ( QResizeEvent *);
   //  Layout methods:
   virtual void        QSize& size)">SetSizeHint (const QSize &size);
public:
   virtual QSize       QSize TQtWidget::sizeHint()">sizeHint () const;        // returns the preferred size of the widget.
   virtual QSize       QSize TQtWidget::minimumSizeHint()">minimumSizeHint () const; // returns the smallest size the widget can have.
   virtual QSizePolicy QSizePolicy TQtWidget::sizePolicy()">sizePolicy () const;      // returns a QSizePolicy; a value describing the space requirements of the
protected:
   // -- A special event handler
   virtual void exitSizeEvent ();
   virtual void QResizeEvent* e)">stretchWidget(QResizeEvent *e);
public:
   //----- bit manipulation (a'la TObject )
   void     SetBit     (UInt_t f, Bool_t set);
   void     SetBit     (UInt_t f);
   void     ResetBit   (UInt_t f);
   Bool_t   TestBit    (UInt_t f) const;
   Int_t    TestBits   (UInt_t f) const;
   void     InvertBit  (UInt_t f);
   void     EmitSignal (UInt_t f);
   void     EmitTestedSignal();
   UInt_t   GetAllBits() const;
   void     SetAllBits(UInt_t f);
   
public:
   // Static method to inmitate ROOT as needed
   static TApplication *InitRint(Bool_t prompt=kFALSE, const char *appClassName="QtRint", int *argc=0, char **argv=0,
          void *options = 0, int numOptions = 0, Bool_t noLogo = kFALSE);
   //  Proxy methods to access the TCanvas selected TObject 
   //  and last processed ROOT TCanvas event
   Int_t             GetEvent()       const;
   Int_t             GetEventX()      const;
   Int_t             GetEventY()      const;
   TObject          *GetSelected()    const;
   Int_t             GetSelectedX()   const;
   Int_t             GetSelectedY()   const;
   TVirtualPad      *GetSelectedPad() const;

   //----- bit Qt signal emitting the Qt signal to track mouse movement
   void     EnableSignalEvents  (UInt_t f);
   void     DisableSignalEvents (UInt_t f);
   Bool_t   IsSignalEventEnabled(UInt_t f) const;
   
   static TCanvas   *Canvas(TQtWidget *widget);
   static TQtWidget *Canvas(const TCanvas *canvas);
   static TQtWidget *Canvas(Int_t id);

public slots:
   virtual void cd();
   virtual void cd(int subpadnumber);
   void Disconnect();
   void Refresh();
   virtual bool QString& fileName) or overloads">Save(const QString &fileName) const;
   virtual bool QString& fileName) or overloads">Save(const char    *fileName) const;
   virtual bool QString& fileName) or overloads">Save(const QString &fileName,const char *format,int quality=60) const;
   virtual bool QString& fileName) or overloads">Save(const char    *fileName,const char *format,int quality=60) const;
#ifndef __CINT__
signals:
   // emit the Qt signal when the double buffer of the TCamvas has been filled up
   void CanvasPainted();  // Signal the TCanvas has been painted onto the screen
   void Saved(bool ok);   // Signal the TCanvas has been saved into the file
   void RootEventProcessed(TObject *selected, unsigned int event, TCanvas *c);
#endif

#ifndef Q_MOC_RUN
//MOC_SKIP_BEGIN
   ClassDef(TQtWidget,0) // QWidget to back ROOT TCanvas (Can be used with Qt designer)
//MOC_SKIP_END
#endif
};

//______________________________________________________________________________
inline void TQtWidget::AdjustBufferSize()
   {  if (fPixmapID.size() != size() ) fPixmapID.resize(size()); }

//______________________________________________________________________________
inline bool TQtWidget::paintingActive () const {
  return QWidget::paintingActive() || fPixmapID.paintingActive();
}
//______________________________________________________________________________
inline void TQtWidget::QWidget* wrapper)">SetRootID(QWidget *wrapper) { QWidget* TQtWidget::fWrapper">fWrapper = wrapper;}
//______________________________________________________________________________
inline QWidget *TQtWidget::QWidget* TQtWidget::GetRootID()">GetRootID() const { return QWidget* TQtWidget::fWrapper">fWrapper;}

//______________________________________________________________________________
//
//  Proxy methods to access the TCanvas selected TObject
//  and last processed event
//______________________________________________________________________________
inline Int_t        TQtWidget::GetEvent()       const { return GetCanvas()->GetEvent();       }
//______________________________________________________________________________
inline Int_t        TQtWidget::GetEventX()      const { return GetCanvas()->GetEventX();      }
//______________________________________________________________________________
inline Int_t        TQtWidget::GetEventY()      const { return GetCanvas()->GetEventY();      }
//______________________________________________________________________________
inline TObject     *TQtWidget::GetSelected()    const { return GetCanvas()->GetSelected();    }
//______________________________________________________________________________
inline Int_t        TQtWidget::GetSelectedX()   const { return GetCanvas()->GetSelectedX();   }
//______________________________________________________________________________
inline Int_t        TQtWidget::GetSelectedY()   const { return GetCanvas()->GetSelectedY();   }
//______________________________________________________________________________
inline TVirtualPad *TQtWidget::GetSelectedPad() const { return GetCanvas()->GetSelectedPad(); }

//----- bit manipulation
inline UInt_t TQtWidget::GetAllBits() const       { return fBits;                       }
inline void   TQtWidget::SetAllBits(UInt_t f)     { fBits = f;                          }
inline void   TQtWidget::SetBit(UInt_t f)         { fBits |= f & kBitMask;              }
inline void   TQtWidget::ResetBit(UInt_t f)       { fBits &= ~(f & kBitMask);           }
inline Bool_t TQtWidget::TestBit(UInt_t f) const  { return (Bool_t) ((fBits & f) != 0); }
inline Int_t  TQtWidget::TestBits(UInt_t f) const { return (Int_t) (fBits & f);         }
inline void   TQtWidget::InvertBit(UInt_t f)      { fBits ^= f & kBitMask;              }
   
inline void   TQtWidget::EnableSignalEvents  (UInt_t f){ SetBit  (f); }
inline void   TQtWidget::DisableSignalEvents (UInt_t f){ ResetBit(f); }
inline Bool_t TQtWidget::IsSignalEventEnabled(UInt_t f) const { return TestBit (f); }
inline void   TQtWidget::EmitSignal(UInt_t f)  {if (IsSignalEventEnabled(f)) EmitTestedSignal();}

#endif

Qt/ROOT page - ROOT page - Class index - Class Hierarchy - Top of the page - Qt docs

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to QtROOT support, or contact the developers with any questions or problems regarding ROOT.