TGQt.h

Go to the documentation of this file.
00001 // @(#)root/qt:$Id: TGQt.h 30386 2009-09-23 19:06:28Z brun $
00002 // Author: Valeri Fine   21/01/2002
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * Copyright (C) 2002 by Valeri Fine.                                    *
00007  * All rights reserved.                                                  *
00008  *                                                                       *
00009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00011  *************************************************************************/
00012 
00013 #ifndef ROOT_TGQt
00014 #define ROOT_TGQt
00015 
00016 
00017 //////////////////////////////////////////////////////////////////////////
00018 //                                                                      //
00019 // TGQt                                                                 //
00020 //                                                                      //
00021 // Interface to low level Qt GUI. This class gives an access            //
00022 // to the basic Qt graphics, pixmap, text and font handling routines.   //
00023 //                                                                      //
00024 //////////////////////////////////////////////////////////////////////////
00025 
00026 #include "TQtRConfig.h"
00027 
00028 #ifndef __CINT__
00029 #include <vector>
00030 #include <map>
00031 
00032 #include <qobject.h>
00033 #include <QMap>
00034 #include <QColor>
00035 #include <QCursor>
00036 #include <QPainter>
00037 #include <QRect>
00038 #include <qnamespace.h>
00039 
00040 #include <QtGui/QPixmap>
00041 #include <QtCore/QEvent>
00042 #include <QtCore/QVector>
00043 
00044 #include <QtGui/QFontDatabase>
00045 
00046 #include "TQtClientGuard.h"
00047 
00048 #else
00049   class QObject;
00050   class QEvent;
00051 #endif  /* CINT */
00052 
00053 class QPainter;
00054 class QPen;
00055 class QMarker;
00056 //class  QFont;
00057 class QPaintDevice;
00058 class QTextCodec;
00059 class QPoint;
00060 class QString;
00061 class QSize;
00062 class QColor;
00063 
00064 
00065 #include "TVirtualX.h"
00066 #include "TQtEmitter.h"
00067 
00068 class TQtMarker;
00069 
00070 class TQtPen;
00071 class TQtSwitch;
00072 class TQtBrush;
00073 class TQtCommand;
00074 class TFileHandler;
00075 class TQtApplication;
00076 class TQtClientFilter;
00077 class TQtEventQueue;
00078 class TQtPadFont;
00079 class TQtPen;
00080 class TQtPainter;
00081 class TQtFeedBackWidget;
00082 
00083 //#define TRACE_TGQt() fprintf(stdout, "TGQt::%s() %d\n", __FUNCTION__, __LINE__)
00084 class TQtTextProxy {
00085 private:
00086     TQtTextProxy(const TQtTextProxy&);
00087     void operator=(const TQtTextProxy&);
00088 protected:
00089     TQtTextProxy(){;}
00090 public:
00091     virtual  ~TQtTextProxy(){;}
00092     virtual void clear() = 0;
00093 
00094     bool setContent(const char *text, QString *errorMsg = 0,
00095                     int *errorLine = 0, int *errorColumn = 0);
00096     virtual bool setContent(const QString &text, QString *errorMsg   = 0,
00097                     int *errorLine = 0, int *errorColumn = 0) = 0;
00098     virtual bool setMmlContent(const QString &text, QString *errorMsg   = 0,
00099                     int *errorLine = 0, int *errorColumn = 0) = 0;
00100     virtual void paint(QPainter *p,unsigned int x, unsigned int y) const  = 0;
00101     virtual unsigned int width() const = 0; 
00102     virtual unsigned int height()    const = 0;
00103 
00104     virtual void setFont(Font_t fontnumber) = 0;
00105 
00106     virtual int baseFontPointSize() const   = 0;
00107     virtual void setBaseFontPointSize(int size) = 0;
00108     virtual void setForegroundColor(const QColor &) = 0;
00109     virtual bool isMine() const { return false;};
00110     virtual TQtTextProxy *Clone() = 0;
00111 };
00112 inline bool TQtTextProxy::setContent(const char *text, QString *errorMsg,
00113                     int *errorLine, int *errorColumn )
00114 { return setContent(QString(text),errorMsg, errorLine, errorColumn); }
00115 
00116 class TGQt  : public TVirtualX  {
00117 
00118 #ifndef __CINT__
00119    friend class TQtObject;
00120    friend class TQtWindowsObject;
00121    friend class TQtPixmapObject;
00122    friend class TPadOpenGLView;
00123    friend class TQtWidget;
00124    friend class TQtClientWidget;
00125    friend class TQtImage;
00126    friend class TQtClientGuard;
00127    friend class TQtClientFilter;
00128    friend class TQtSynchPainting;
00129    friend class TQtToggleFeedBack;
00130    friend class TQtColorSelect;
00131    friend class TQt16ColorSelector;
00132    friend class TQtPen; 
00133    friend class TQtBrush; 
00134    friend class TQtPainter;
00135    friend class TQtTextProxy;
00136 
00137 protected:
00138    enum DEFWINDOWID { kDefault=1 };
00139    QPaintDevice *fSelectedWindow;      // Pointer to the current "paintdevice: PixMap, Widget etc"
00140    QPaintDevice *fPrevWindow;          // Pointer to the previous "Window"
00141    Int_t         fDisplayOpened;
00142    TQtPainter     *fQPainter;
00143    TQtEmitter    fEmitter;             // object to emit Qt signals on behalf of TVirtualX
00144    static TVirtualX     *fgTQt;        // The hiden poiner to foolish  ROOT TPluginManager
00145 
00146    void        *fhEvent;               // The event object to synch threads
00147 
00148    QVector<QCursor *>      fCursors;
00149    ECursor         fCursor;            // Current cursor number;
00150 
00151    Style_t      fMarkerStyle;
00152 
00153    Int_t        fTextAlignH;         //Text Alignment Horizontal
00154    Int_t        fTextAlignV;         //Text Alignment Vertical
00155    Float_t      fCharacterUpX;       //Character Up vector along X
00156    Float_t      fCharacterUpY;       //Character Up vector along Y
00157    Int_t        fTextFontModified;   // Mark whether the text font has been modified
00158    Float_t      fTextMagnitude;      //Text Magnitude
00159 
00160 //   Common HANDLES of the graphics attributes for all HIGZ windows
00161 
00162    TQtBrush  *fQBrush;
00163    TQtPen    *fQPen;
00164    TQtMarker *fQtMarker;
00165    TQtPadFont *fQFont;
00166    QPainter::CompositionMode  fDrawMode;
00167 
00168    typedef QMap<QPaintDevice *,QRect> TQTCLIPMAP;
00169    TQTCLIPMAP fClipMap;
00170 
00171 //
00172 //  Colors staff
00173 //
00174 
00175 //   QMemArray<QColor> QMap<Key, T>::const_iterator;
00176     QMap<Color_t,QColor*> fPallete;
00177     TQtClientFilter *fQClientFilter;
00178     TQtEventQueue   *fQClientFilterBuffer;
00179     TQtClientGuard       fQClientGuard;  // guard TQtClientWibdget against of dead pointers
00180     TQtPixmapGuard       fQPixmapGuard;  // guard TQtClientWibdget against of dead pointers
00181     typedef std::map<ULong_t, QColor * > COLORMAP;
00182     COLORMAP fColorMap;  // to back the TG widgets
00183     TQtClientWidget       *fPointerGrabber;
00184     QTextCodec            *fCodec;            // The Current text decoder
00185     QString                fFontTextCode;     // The default code text code page (from the Gui.DefaultFont)
00186     const char            *fSymbolFontFamily; // the name of the font to substiute the non-standard "Symbol"
00187     Int_t                 fQtEventHasBeenProcessed; // Flag whether the events were processed
00188     Bool_t                fFeedBackMode;      // TCanvas feedback mode 
00189     TQtFeedBackWidget    *fFeedBackWidget;    // The dedicated widget for TCanvas feedback mode
00190     Bool_t                fBlockRGB;          // Protect against color double setting
00191     Bool_t                fUseTTF;            // Flag whether ROOT font has a priority
00192     
00193     static TQtTextProxy   *fgTextProxy;       // proxy for the custom text rendering engine
00194 //
00195 //   Text management
00196 //
00197 
00198    //Qt::AlignmentFlags fTextAlign;
00199 
00200    // void  SetTextFont(const char *fontname, Int_t italic, Int_t bold);
00201    Int_t CreatROOTThread();
00202    void  DeleteSelectedObj();
00203 
00204 //  Qt methods
00205    static QRect GetQRect(QPaintDevice &dev);
00206    int  UpdateColor(int cindex);
00207    QPaintDevice *GetDoubleBuffer(QPaintDevice *dev);
00208 
00209 #endif
00210    static Int_t   RegisterWid(QPaintDevice *wid);   // register QWidget for the embedded TCanvas
00211    static Int_t   UnRegisterWid(QPaintDevice *wid); // unregister QWidget of the TCanvas
00212    static Bool_t  IsRegistered(QPaintDevice *wid);  // Check whether the object has been registered
00213 private:
00214    TGQt& operator=(const TGQt&);
00215 public:
00216 
00217     TGQt();
00218     TGQt(const TGQt &vx): TVirtualX(vx) { MayNotUse("TGQt(const TGQt &)"); }   // without dict does not compile? (rdm)
00219     TGQt(const char *name, const char *title);
00220     virtual ~TGQt();
00221 // Include the base TVirtualX class interface
00222 #include "TVirtualX.interface.h"
00223 #ifndef __CINT__
00224 // extracted methods
00225     virtual QPaintDevice *GetSelectedWindow(){ return fSelectedWindow; }
00226     virtual void      SetFillStyleIndex( Int_t style, Int_t fasi);
00227     virtual void      SetMarkerType( Int_t type, Int_t n, TPoint *xy );
00228     virtual void      SetTitle(const char *title);
00229     virtual void      CopyPixmap(const QPixmap &p, Int_t px1, Int_t py1);
00230     virtual void      SetTextDecoder(const char * /*textDeocerName*/){;}  // for the future
00231     virtual const QTextCodec *GetTextDecoder();
00232 #endif
00233 // obsolete methods
00234         virtual void      PutByte(Byte_t b);
00235 // ---------------------------------------------
00236 
00237    virtual Bool_t       IsHandleValid(Window_t id);
00238 
00239 
00240    // static methods:
00241    static TQtApplication *CreateQtApplicationImp();
00242    static Int_t          iwid(QPaintDevice *wid);
00243    static QPaintDevice  *iwid(Int_t wid);
00244    static QPaintDevice  *iwid(Window_t wid);
00245 #ifndef __CINT__
00246 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,0)
00247    static QPixmap       *MakeIcon(Int_t indx);
00248 #endif
00249    static TVirtualX     *GetVirtualX();
00250    static QWidget       *winid(Window_t id);
00251    static QWidget       *wid(Window_t id);
00252    static Window_t       wid(TQtClientWidget *widget);
00253    static Window_t       rootwid(QPaintDevice *dev);
00254    static void           PrintEvent(Event_t &);
00255    static QString        SetFileName(const QString &fileName);
00256    static QString        GetNewFileName(const QString &fileNamePrototype);
00257    static TQtTextProxy  *TextProxy();
00258    static void           SetTextProxy(TQtTextProxy  *proxy);
00259 
00260    void SetQClientFilter(TQtClientFilter *filter) {fQClientFilter = filter;}
00261    TQtClientFilter  *QClientFilter() const {return fQClientFilter;}
00262    QColor QtColor(ULong_t pixel);
00263    void SendDestroyEvent(TQtClientWidget *) const;
00264 
00265    TQtEmitter *Emitter(){ return &fEmitter;}
00266 #endif
00267 // Future interface :
00268    virtual void      SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b, Float_t a);
00269    virtual void      SetAlpha(Int_t cindex, Float_t a);
00270    virtual void      GetRGBA(Int_t cindex, Float_t &r, Float_t &g, Float_t &b, Float_t &a);
00271    virtual Float_t   GetAlpha(Int_t cindex);
00272    virtual const QColor& ColorIndex(Color_t indx) const;
00273 
00274    virtual Int_t LoadQt(const char *shareLibFileName);
00275    static void PostQtEvent(QObject *receiver, QEvent *event);
00276    virtual Int_t processQtEvents(Int_t maxtime=300); //milliseconds
00277    // temporary this should be moved to the QTGL interface
00278    private:
00279       static int fgCoinFlag; // no coin viewer;
00280       static int fgCoinLoaded; // no coin viewer;
00281    public:
00282       static int CoinFlag();
00283       static void SetCoinFlag(int flag);
00284       static void SetCoinLoaded();
00285       static Int_t IsCoinLoaded();
00286 #ifndef __CINT__
00287       static QString RootFileFormat(const char *selector);
00288       static QString RootFileFormat(const QString &selector);
00289       static QString QtFileFormat(const char *selector);
00290       static QString QtFileFormat(const QString &selector);
00291 #endif
00292 
00293 #ifndef Q_MOC_RUN
00294    ClassDef(TGQt,0)  //Interface to Qt GUI
00295 #endif
00296 
00297 };
00298 
00299 R__EXTERN  TGQt *gQt;
00300 
00301 
00302 #endif

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