TQtClientWidget.h

Go to the documentation of this file.
00001 // @(#)root/qt:$Id: TQtClientWidget.h 28205 2009-04-14 19:38:00Z brun $
00002 /*************************************************************************
00003  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00004  * Copyright (C) 2002 by Valeri Fine.                                    *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 #ifndef ROOT_TQtClientWidget
00012 #define ROOT_TQtClientWidget
00013 
00014 
00015 #ifndef __CINT__
00016 # include <QKeySequence>
00017 # include <QFrame>
00018 # include <QCursor>
00019 # include <map>
00020 #else
00021   class QFrame;
00022   class QColor;
00023   class QPixmap;
00024 #endif
00025   
00026 #include "GuiTypes.h"
00027 
00028 //________________________________________________________________________
00029 //
00030 // TQtClientWidget  is a QFrame implemantation backing  ROOT TGWindow objects
00031 // It tries to mimic the X11 Widget behaviour, that kind the ROOT Gui relies on heavily.
00032 //________________________________________________________________________
00033 
00034 class QCursor;
00035 class QCloseEvent;
00036 class QPaintEvent;
00037 class TQtClientGuard;
00038 class TQtWidget;
00039 class QShortcut;
00040 class TGWindow;
00041 
00042 class TQtClientWidget: public QFrame {
00043 #ifndef __CINT__
00044      Q_OBJECT
00045 #endif
00046 
00047 private:
00048          void  operator=(const TQtClientWidget&);
00049          TQtClientWidget(const TQtClientWidget&);
00050 protected:
00051 
00052        UInt_t fGrabButtonMask;        // modifier button mask for TVirtualX::GrabButton
00053        UInt_t fGrabEventPointerMask;  // input event mask for TVirtualX::GrabPointer
00054        UInt_t fGrabEventButtonMask;   // input event mask for TVirtualX::GrabButton
00055        UInt_t fSelectEventMask;       // input mask for SelectInput
00056        UInt_t fSaveSelectInputMask;   // To save dutinr the grabbing the selectInput
00057        EMouseButton fButton;
00058 #ifndef __CINT__
00059        std::map<QKeySequence,QShortcut*>  fGrabbedKey;
00060 #endif
00061        Bool_t   fPointerOwner;
00062        QCursor *fNormalPointerCursor;
00063        QCursor *fGrabPointerCursor;
00064        QCursor *fGrabButtonCursor;
00065        bool     fIsClosing;
00066        bool     fDeleteNotify;
00067        TQtClientGuard  *fGuard;
00068        TQtWidget       *fCanvasWidget;
00069        TGWindow *fMyRootWindow;  // back pointer to the host window object
00070        QColor   *fEraseColor;    // Color to paint widget background with our PainEvent
00071        QPixmap  *fErasePixmap;   // pixmap to paint widget background with our PainEvent
00072        friend class TQtClientGuard;
00073        friend class TGQt;
00074 #ifndef __CINT__
00075       TQtClientWidget(TQtClientGuard *guard, QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
00076 #else
00077       TQtClientWidget(TQtClientGuard *guard, QWidget* parent=0, const char* name=0, WFlags f=0);
00078 #endif
00079       void SetCanvasWidget(TQtWidget *widget);
00080       virtual void paintEvent       ( QPaintEvent * );
00081 public:
00082     enum {kRemove = -1, kTestKey = 0, kInsert = 1};
00083     virtual ~TQtClientWidget();
00084     virtual void closeEvent(QCloseEvent *ev);
00085     virtual void setEraseColor(const QColor &color);
00086     virtual void setErasePixmap (const QPixmap &pixmap);
00087     bool   DeleteNotify();
00088     TQtWidget *GetCanvasWidget() const;
00089     void   GrabEvent(Event_t &ev,bool own=TRUE);
00090 //    Q3Accel *HasAccel() const ;
00091     bool   IsClosing();
00092     bool   IsGrabbed       (Event_t &ev);
00093     bool   IsGrabPointerSelected(UInt_t evmask) const;
00094     bool   IsGrabButtonSelected (UInt_t evmask) const;
00095     TQtClientWidget *IsKeyGrabbed(const Event_t &ev);
00096     UInt_t IsEventSelected (UInt_t evmask) const;
00097     bool   IsGrabOwner()   { return fPointerOwner;}
00098     void   SetAttributeEventMask(UInt_t evmask);
00099     void   SetButtonMask   (UInt_t modifier=kAnyModifier,EMouseButton button=kAnyButton);
00100     void   SetClosing(bool flag=kTRUE);
00101     void   SetCursor();
00102     void   SetCursor(Cursor_t cursor);
00103     void   SetDeleteNotify(bool flag=true);
00104     void   SetButtonEventMask(UInt_t evmask,Cursor_t cursor=0);
00105     void   SelectInput       (UInt_t evmask);
00106     Bool_t SetKeyMask        (Int_t keycode = 0, UInt_t modifier=kAnyModifier,int insert=kInsert);
00107     void   UnSetButtonMask   (bool dtor=false);
00108     void   UnSetKeyMask(Int_t keycode = 0, UInt_t modifier=kAnyModifier);
00109     QCursor *GrabButtonCursor() const;
00110     QCursor *GrabPointerCursor() const;
00111     UInt_t ButtonMask  ()    const;
00112     UInt_t ButtonEventMask() const;
00113     UInt_t SelectEventMask() const;
00114     EMouseButton Button()    const;
00115     UInt_t PointerMask ()    const;
00116 #ifndef __CINT__
00117 protected slots:
00118       void Disconnect();
00119 #endif
00120 public slots:
00121     virtual void Accelerate();
00122 #ifndef Q_MOC_RUN
00123     ClassDef(TQtClientWidget,0) // QFrame implementation backing  ROOT TGWindow objects
00124 #endif
00125 };
00126 
00127 //______________________________________________________________________________
00128 inline bool TQtClientWidget::DeleteNotify(){return fDeleteNotify; }
00129 
00130 //______________________________________________________________________________
00131 inline TQtWidget *TQtClientWidget::GetCanvasWidget() const
00132 { return fCanvasWidget;}
00133 //______________________________________________________________________________
00134 //inline Q3Accel *TQtClientWidget::HasAccel() const 
00135 //{  return fGrabbedKey; }
00136 
00137 //______________________________________________________________________________
00138 inline bool  TQtClientWidget::IsClosing(){ return fIsClosing; }
00139 
00140 //______________________________________________________________________________
00141 inline UInt_t TQtClientWidget::IsEventSelected (UInt_t evmask) const
00142 {
00143    //if (evmask & (kButtonPressMask | kButtonMotionMask) )
00144    //   fprintf(stderr,"TQtClientWidget::IsEventSelected event %x, mask %x. match %x\n"
00145    //   , evmask, fSelectEventtMask, evmask & (kButtonPressMask | kButtonMotionMask));
00146    return  (evmask & fSelectEventMask); //  || (IsGrabPointerSelected(evmask)) ;
00147 }
00148 
00149 //______________________________________________________________________________
00150 inline void TQtClientWidget::SetCursor()
00151 { // Set this widget pre-defined cursor
00152    if (fNormalPointerCursor) setCursor(*fNormalPointerCursor);
00153 }
00154 //______________________________________________________________________________
00155 inline void TQtClientWidget::SetCursor(Cursor_t crsr)
00156 {
00157    // Change the pre-define curos shape and set it
00158    fNormalPointerCursor = (QCursor *)crsr;
00159    SetCursor();
00160 }
00161 
00162 //______________________________________________________________________________
00163 inline void  TQtClientWidget::SetClosing(bool flag) { fIsClosing = flag;}
00164 //______________________________________________________________________________
00165 inline void  TQtClientWidget::SetDeleteNotify(bool flag){fDeleteNotify = flag;}
00166 
00167 //______________________________________________________________________________
00168 inline void TQtClientWidget::SetAttributeEventMask(UInt_t evmask) { SelectInput (evmask);}
00169 
00170 //______________________________________________________________________________
00171 inline void TQtClientWidget::SetButtonEventMask(UInt_t evmask,Cursor_t crsr)
00172 { fGrabEventButtonMask = evmask; fGrabButtonCursor =(QCursor *) crsr; }
00173 
00174 //______________________________________________________________________________
00175 inline EMouseButton TQtClientWidget::Button() const { return fButton;          }
00176 
00177 //______________________________________________________________________________
00178 inline UInt_t TQtClientWidget::ButtonEventMask() const { return fGrabEventButtonMask;}
00179 
00180 //______________________________________________________________________________
00181 inline UInt_t TQtClientWidget::ButtonMask()  const { return fGrabButtonMask;   }
00182 
00183 //______________________________________________________________________________
00184 inline UInt_t TQtClientWidget::PointerMask() const { return fGrabEventPointerMask;}
00185 
00186 //______________________________________________________________________________
00187 inline UInt_t TQtClientWidget::SelectEventMask() const {return fSelectEventMask;}
00188 
00189 //______________________________________________________________________________
00190 inline QCursor *TQtClientWidget::GrabButtonCursor() const
00191 {      return   fGrabButtonCursor;                                                }
00192 
00193 //______________________________________________________________________________
00194 inline QCursor *TQtClientWidget::GrabPointerCursor() const
00195 {      return   fGrabPointerCursor;                                                }
00196 
00197 //______________________________________________________________________________
00198 inline bool TQtClientWidget::IsGrabPointerSelected(UInt_t evmask) const
00199 {  return  evmask & PointerMask(); }
00200 
00201 //______________________________________________________________________________
00202 inline bool  TQtClientWidget::IsGrabButtonSelected (UInt_t evmask) const
00203 { return  evmask & ButtonEventMask(); }
00204 
00205 #endif

Generated on Tue Jul 5 14:14:32 2011 for ROOT_528-00b_version by  doxygen 1.5.1