TGQt.cxx

Go to the documentation of this file.
00001 // @(#)root/qt:$Id: TGQt.cxx 36275 2010-10-11 08:05:21Z brun $
00002 // Author: Valeri Fine   21/01/2002
00003 /*************************************************************************
00004  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00005  * Copyright (C) 2002 by Valeri Fine.                                    *
00006  * All rights reserved.                                                  *
00007  *                                                                      *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TGQt                                                                 //
00015 //                                                                      //
00016 // This class is the basic interface to the Qt graphics system. It is   //
00017 // an implementation of the abstract TVirtualX class.                   //
00018 //                                                                      //
00019 //////////////////////////////////////////////////////////////////////////
00020 
00021 #if defined(HAVE_CONFIG) || defined (R__HAVE_CONFIG)
00022 # include "config.h"
00023 #endif
00024 #ifdef R__QTWIN32
00025 #include <process.h>
00026 #endif
00027 
00028 #include <assert.h>
00029 
00030 //  Qt include files
00031 
00032 #include <QApplication>
00033 #include <QWidget>
00034 #include <QPolygon>
00035 #include <QEvent>
00036 #include <QImageWriter>
00037 #include <QVector>
00038 #include <QStack>
00039 #include <QFrame>
00040 #include <QPicture>
00041 #include <QDebug>
00042 
00043 #include <qpixmap.h>
00044 #include <qcursor.h>
00045 #include <qdesktopwidget.h>
00046 #include <qimage.h>
00047 #include <qfontmetrics.h>
00048 #include <qdialog.h>
00049 #include <qlineedit.h>
00050 #include <qfileinfo.h>
00051 #include <qtextcodec.h>
00052 #include <qdir.h>
00053 
00054 #include "TROOT.h"
00055 #include "TMath.h"
00056 #include "TColor.h"
00057 #include "TEnv.h"
00058 #include "TQtPen.h"
00059 
00060 #include "TQtApplication.h"
00061 #include "TQtWidget.h"
00062 #include "TGQt.h"
00063 #include "TQtBrush.h"
00064 #include "TQtClientFilter.h"
00065 #include "TQtEventQueue.h"
00066 #include "TQtSymbolCodec.h"
00067 #include "TQtLock.h"
00068 #include "TQtPadFont.h"
00069 #include "TStyle.h"
00070 #include "TObjString.h"
00071 #include "TObjArray.h"
00072 
00073 #include "TSystem.h"
00074 #ifdef R__QTWIN32
00075 #  include "TWinNTSystem.h"
00076 #  include "Win32Constants.h"
00077 #  include <Winuser.h>
00078 #else
00079 # ifdef R__QTX11
00080 #  include <X11/Xlib.h>
00081 # endif
00082 #endif
00083 
00084 #include "TSysEvtHandler.h"
00085 #include "TQtMarker.h"
00086 
00087 #include "TImage.h"
00088 #include "TError.h"
00089 
00090 TGQt *gQt=0;
00091 TVirtualX *TGQt::fgTQt = 0; // to remember the pointer foolishing ROOT PluginManager later.
00092 TQtTextProxy  *TGQt::fgTextProxy = 0; // The pointer to the custom text proxy;
00093 class TQtTextCloneProxy {
00094 private:
00095    TQtTextProxy *fProxy;
00096    void *operator new(size_t);
00097    TQtTextCloneProxy(const TQtTextCloneProxy&);
00098    void operator=(const TQtTextCloneProxy&);
00099 public:
00100    TQtTextCloneProxy()  : fProxy(0) 
00101    {
00102       if ( TGQt::TextProxy())
00103          fProxy = TGQt::TextProxy()->Clone();
00104    }
00105    inline ~TQtTextCloneProxy() { delete fProxy; }
00106    inline TQtTextProxy *operator->() { return fProxy;}
00107 };
00108 
00109 #define NoOperation (QPaintDevice *)(-1)
00110 
00111 // static const int kDefault=2;
00112 //__________________________________________________________________
00113 static QWidget *IsWidget(QPaintDevice *d)
00114 { return  dynamic_cast<QWidget *>(d);   }
00115 
00116 //__________________________________________________________________
00117 static QPixmap *IsPixmap(QPaintDevice *d)
00118 { return dynamic_cast<QPixmap *>(d); }
00119 //__________________________________________________________________
00120 QString TGQt::SetFileName(const QString &fileName)
00121 {
00122    // Set the file pattern
00123    QFileInfo  fi(fileName);
00124    QString saveFileMoviePattern =
00125             fi.path()+"/" + fi.completeBaseName()+ "_%04d" + "." + fi.suffix();
00126    return saveFileMoviePattern;
00127 }
00128 //__________________________________________________________________
00129 QString TGQt::GetNewFileName(const QString &fileNamePrototype)
00130 {
00131    // Find the filename for the given "fileNamePrototype"
00132    TString flN = fileNamePrototype.toStdString().c_str();
00133    gSystem->ExpandPathName(flN);
00134    QString fileName = (const char *)flN;
00135 
00136    Int_t counter = 0;
00137    QString formatPattern = SetFileName(fileName);
00138    while (gSystem->AccessPathName(fileName.toStdString().c_str())==0) {
00139       fileName = QString().sprintf(formatPattern.toStdString().c_str(),counter++);
00140    }
00141    return  fileName;
00142 }
00143 //______________________________________________________________________________
00144 //
00145 //  custom TQtPainter
00146 //______________________________________________________________________________
00147 class TQtPainter : public QPainter {
00148 private:
00149     TGQt *fVirtualX;
00150 protected:
00151    inline void UpdateBrush() { setBrush(*fVirtualX->fQBrush); }
00152    inline void UpdatePen()   { setPen(*fVirtualX->fQPen);     }
00153    inline void UpdateFont()  { setFont(*fVirtualX->fQFont);
00154                                fVirtualX->fTextFontModified = 0;
00155                              }
00156 public:
00157    enum  { kNone        = 0,
00158            kUseFeedBack = 1,
00159            kUpdateFont  = 2,
00160            kUpdateBrush = 4,
00161            kUpdatePen   = 8
00162    };
00163    TQtPainter() : QPainter (), fVirtualX(0) {}
00164    TQtPainter(QPaintDevice * dev) : QPainter ( dev ), fVirtualX(0) {}
00165    TQtPainter( TGQt *dev, unsigned int useFeedBack=kUpdateBrush | kUpdatePen ) : fVirtualX(0) 
00166    {  begin(dev,useFeedBack);                                       }
00167    ~TQtPainter () { fVirtualX->fQPainter = 0; }
00168    bool begin ( TGQt *dev, unsigned int useFeedBack);
00169 };
00170 //______________________________________________________________________________
00171 //
00172 //   class TQtFeedBackWidget to back the TCanvas FeedBack mode
00173 //______________________________________________________________________________
00174 class TQtFeedBackWidget : public QFrame {
00175    QPixmap   *fPixBuffer;
00176    QPixmap   *fGrabBuffer;
00177    TQtWidget *fParentWidget;
00178 protected:
00179    virtual void hideEvent (QHideEvent *ev) {
00180       // hide the feedback widget and remove the buffer
00181       delete fPixBuffer;  fPixBuffer  = 0;  
00182       delete fGrabBuffer; fGrabBuffer = 0;
00183       QFrame::hideEvent(ev);
00184       if (fParentWidget) {
00185          fParentWidget->SetIgnoreLeaveEnter(0);         
00186          SetParent(0);  // reparent // it is dangerous thing to do inside of the event processing
00187       }
00188    }
00189    virtual void paintEvent(QPaintEvent *ev) {
00190       if (fPixBuffer) {
00191          QRect rc = ev->rect();
00192          {
00193             QPainter p(this);
00194             p.setClipRect(rc);
00195             p.drawPixmap(0,0,*fPixBuffer);
00196          }
00197          ClearBuffer();
00198       } else if (fGrabBuffer) {
00199          QRect rc = ev->rect(); 
00200          QPainter p(this);
00201          p.setClipRect(rc);
00202          p.drawPixmap(rc,*fGrabBuffer);
00203       }
00204       QFrame::paintEvent(ev);
00205    }
00206 public:
00207    TQtFeedBackWidget(QWidget *mother=0, Qt::WindowFlags f=0)  : QFrame(mother,f)
00208       ,fPixBuffer(0),fGrabBuffer(0),fParentWidget(0)
00209    {
00210       // Create the feedback widget
00211       setAttribute(Qt::WA_NoSystemBackground); 
00212       setEnabled(false);
00213       setBackgroundRole(QPalette::Window);
00214       setAutoFillBackground(false);
00215       QPalette  p = palette();
00216       p.setBrush(QPalette::Window, Qt::transparent);
00217       setPalette(p);
00218       setMouseTracking(true);
00219    }
00220    virtual ~TQtFeedBackWidget() 
00221    {
00222       fParentWidget = 0;
00223       delete fPixBuffer; fPixBuffer   = 0;
00224       delete fGrabBuffer; fGrabBuffer = 0;
00225    }
00226    void SetParent(TQtWidget *w) {
00227       setParent(fParentWidget = w);
00228    }
00229    void Hide() {
00230       if (fParentWidget) {
00231          fParentWidget->SetIgnoreLeaveEnter(0);         
00232          SetParent(0);  // reparent
00233       }
00234    }
00235    void Show() {
00236       // Protect (Qt >= 4.5.x) TCanvas  against of 
00237       // the confusing mouseMoveEvent
00238       if (fParentWidget) fParentWidget->SetIgnoreLeaveEnter(2);
00239       QFrame::show();
00240       if (fParentWidget) fParentWidget->SetIgnoreLeaveEnter();
00241    }
00242    QPaintDevice *PixBuffer() {
00243       // Create the feedback buffer if needed
00244       if (fParentWidget ) {
00245          // resize the feedback
00246          QSize canvasSize = fParentWidget->size();
00247          setGeometry(QRect(QPoint(0,0),canvasSize));
00248          if ( !fPixBuffer  || (fPixBuffer->size() != canvasSize) ) {
00249             delete fPixBuffer;
00250             fPixBuffer = new QPixmap(canvasSize);
00251             ClearBuffer();
00252          }
00253       }
00254       return  fPixBuffer;
00255    }
00256     QPaintDevice *GrabBuffer(QSize &s) { 
00257       // Create the feedback buffer to grab the parent TPad image
00258       if (fParentWidget ) {
00259          // resize the feedback
00260           if ( !fPixBuffer  || (fPixBuffer->size() != s) ) {
00261             delete fPixBuffer;
00262             fPixBuffer = new QPixmap(s);
00263             ClearBuffer();
00264          }
00265       }
00266       return  fPixBuffer;
00267    }
00268    void ClearBuffer() {
00269       // Fill the feedback buffer with the transparent background
00270       fPixBuffer->fill(Qt::transparent);
00271    }
00272    void SetGeometry(int xp,int yp, int w, int h, TQtWidget *src=0)
00273    {
00274        // Set the feedback widget position and geometry
00275        if (isHidden() && src ) {
00276           // grab the parent window and move the feedback 
00277           delete fGrabBuffer; fGrabBuffer = 0;
00278           QPixmap *canvas = src->GetOffScreenBuffer();
00279           if (canvas && w > 4 &&  h > 4 ) {
00280              fGrabBuffer = new QPixmap(canvas->copy(xp,yp,w,h));
00281           }
00282        }
00283        setGeometry(xp,yp,w,h);
00284    }
00285 };
00286 
00287 //______________________________________________________________________________
00288 //
00289 //   class TQtFeedBackWidget to back the TCanvas FeedBack mode
00290 //______________________________________________________________________________
00291 
00292 class TQtToggleFeedBack {
00293    TGQt *fGQt;
00294    TQtPainter  fFeedBackPainter;
00295 
00296 public:
00297    TQtToggleFeedBack(TGQt *gqt) : fGQt(gqt)
00298    {
00299       // activate temporary TQtFeedBackWidget widget buffer
00300       if (fGQt->fFeedBackMode && fGQt->fFeedBackWidget->isHidden()) {
00301          fGQt->fFeedBackWidget->Show();
00302       }
00303    }
00304    ~TQtToggleFeedBack()
00305    {
00306       // Update the "feedback" widget
00307      if (fFeedBackPainter.isActive() ) fFeedBackPainter.end();
00308      if (fGQt->fFeedBackMode && fGQt->fFeedBackWidget) 
00309      {   fGQt->fFeedBackWidget->update();                   }
00310    }
00311    TQtPainter &painter() {
00312       // activate return  the "feedback" painter
00313       if (!fFeedBackPainter.isActive()) {
00314          fFeedBackPainter.begin(fGQt, TQtPainter::kUseFeedBack 
00315                                     | TQtPainter::kUpdatePen 
00316                                     | TQtPainter::kUpdateBrush);
00317          if (fGQt->fFeedBackMode) {
00318             fFeedBackPainter.setPen(QColor(128,128,128,128));// Qt::white);// darkGray);
00319         }
00320      }
00321      return fFeedBackPainter; 
00322    }
00323 };
00324 
00325 //______________________________________________________________________________
00326 //
00327 //  custom TQtPainter
00328 //______________________________________________________________________________
00329 inline bool TQtPainter::begin ( TGQt *dev, unsigned int useFeedBack)
00330 {
00331   // Activate return  the "feedback" painter 
00332   bool res = false;
00333   if (dev && (dev->fSelectedWindow != NoOperation)) {
00334      fVirtualX = dev;
00335      QPaintDevice *src= 0;
00336      if ( (useFeedBack & kUseFeedBack) && dev->fFeedBackMode
00337                      && dev->fFeedBackWidget
00338                      && dev->fFeedBackWidget) 
00339      { src = dev->fFeedBackWidget->PixBuffer(); }
00340      else {
00341         src = dev->fSelectedWindow;
00342         if ( src->devType() ==  QInternal::Widget)
00343         {
00344            TQtWidget *theWidget =  (TQtWidget *)src;
00345           // Substitute the widget with its internal buffer
00346            src = theWidget->SetBuffer().Buffer();
00347         }
00348      }
00349      if (!(res= QPainter::begin(src)) ) {
00350         Error("TGQt::Begin()","Can not create Qt painter for win=0x%lx dev=0x%lx\n",(Long_t)src,(Long_t)dev);
00351         assert(0);
00352      } else {
00353         dev->fQPainter = (TQtPainter*)-1;
00354         UpdatePen();
00355         UpdateBrush();
00356         UpdateFont();
00357         TGQt::TQTCLIPMAP::iterator it= (dev->fClipMap).find(src);
00358         QRect clipRect;
00359         if (it != (dev->fClipMap).end())  {
00360            clipRect = it.value();
00361            setClipRect(clipRect);
00362            setClipping(TRUE);
00363         }
00364         if (src->devType() ==  QInternal::Image )
00365                  setCompositionMode(dev->fDrawMode);
00366      }
00367   }
00368   return res;
00369 }
00370 
00371 
00372 //----- Terminal Input file handler --------------------------------------------
00373 //______________________________________________________________________________
00374 class TQtEventInputHandler : public TTimer {
00375 protected: // singleton
00376    TQtEventInputHandler() : TTimer(340) {  }
00377    static TQtEventInputHandler *gfQtEventInputHandler;
00378 public:
00379 
00380    static TQtEventInputHandler *Instance() {
00381      if (!gfQtEventInputHandler)
00382        gfQtEventInputHandler =  new  TQtEventInputHandler();
00383        gfQtEventInputHandler->Start(240);
00384        return gfQtEventInputHandler;
00385    }
00386    Bool_t Notify()     {
00387       Timeout();       // emit Timeout() signal
00388       Bool_t ret = gQt->processQtEvents();
00389       Start(240);
00390       Reset();
00391       return  ret;
00392    }
00393    Bool_t ReadNotify() { return Notify(); }
00394 };
00395 
00396 TQtEventInputHandler *TQtEventInputHandler::gfQtEventInputHandler = 0;
00397 //______________________________________________________________________________
00398 //  static methods:
00399 //______________________________________________________________________________
00400 //______________________________________________________________________________
00401 //  static methods:
00402 // kNone    =  no window
00403 // kDefault =  means default desktopwindow
00404 //  else the pointer to the QPaintDevice
00405 
00406 class TQWidgetCollection {
00407  private:
00408    QStack<int>             fFreeWindowsIdStack;
00409    QVector<QPaintDevice *> fWidgetCollection;
00410    Int_t                    fIDMax;       //  current max id
00411    Int_t                    fIDTotalMax;  // life-time max id
00412 protected:
00413    //______________________________________________________________________________
00414    inline  Int_t SetMaxId(Int_t newId)
00415    {
00416       fIDMax =  newId;
00417       if (newId>fIDTotalMax) {
00418          fIDTotalMax  = newId;
00419          fWidgetCollection.resize(fIDTotalMax+1);
00420       }
00421       return fIDMax;
00422    }
00423 
00424  public:
00425    //______________________________________________________________________________
00426    TQWidgetCollection () : fIDMax(-1), fIDTotalMax(-1)
00427    {
00428        // mark the position before kNone and between kNone and kDefault
00429        // as "free position" if any
00430        int kDefault = 1;
00431        assert(!kNone);
00432        SetMaxId (kDefault);
00433        fWidgetCollection[kNone]    = (QPaintDevice*)0;
00434        fWidgetCollection[kDefault] = (QPaintDevice *)QApplication::desktop();
00435    }
00436 
00437    //______________________________________________________________________________
00438    inline Int_t GetFreeId(QPaintDevice *device) {
00439 
00440       Int_t Id = 0;
00441       if (!fFreeWindowsIdStack.isEmpty() ) {
00442          Id = fFreeWindowsIdStack.pop();
00443          if (Id > fIDMax ) SetMaxId ( Id );
00444       } else {
00445          Id = fWidgetCollection.count();
00446          assert(fIDMax <= Id  );
00447          SetMaxId ( Id );
00448       }
00449       fWidgetCollection[Id] = device;
00450       // fprintf(stderr," add %p as %d max Id = %d \n", device, Id,fIDMax);
00451       return Id;
00452    }
00453    //______________________________________________________________________________
00454    inline Int_t RemoveByPointer(QPaintDevice *device)
00455    {
00456       // method to provide the ROOT "cast" from (QPaintDevice*) to ROOT windows "id"
00457       Int_t intWid = kNone;             // TGQt::iwid(device);
00458       if ((ULong_t) device != (ULong_t) -1) {
00459           intWid = find( device);
00460           if ( intWid != -1 && 
00461              fWidgetCollection[intWid]) {
00462              fWidgetCollection[intWid] = (QPaintDevice *)(-1);
00463              fFreeWindowsIdStack.push(intWid);
00464              if (fIDMax == intWid) SetMaxId(--fIDMax);
00465           } else {
00466              intWid = kNone;
00467           }
00468       }
00469       return intWid;
00470    }
00471 
00472    //______________________________________________________________________________
00473    inline const QPaintDevice *DeleteById(Int_t Id)
00474    {
00475      QPaintDevice *device = fWidgetCollection[Id];
00476      if (device) {
00477         delete device;
00478         fWidgetCollection[Id] = (QPaintDevice *)(-1);
00479         fFreeWindowsIdStack.push(Id);
00480         if (fIDMax == Id) SetMaxId(--fIDMax);
00481      }
00482      //return device; this was a huge bug
00483      return 0;
00484    }
00485    //______________________________________________________________________________
00486    inline const QPaintDevice *ReplaceById(Int_t Id, QPaintDevice *newDev)
00487    {
00488       if (newDev) {
00489         // delete the old definition
00490         delete fWidgetCollection[Id];
00491         // add the new one instead
00492         fWidgetCollection[Id] = newDev;
00493       } else {
00494          DeleteById(Id);
00495       }
00496       return newDev;
00497    }
00498 
00499    //______________________________________________________________________________
00500    inline uint count() const { return fWidgetCollection.count();}
00501    //______________________________________________________________________________
00502    inline uint MaxId() const { return fIDMax;}
00503    //______________________________________________________________________________
00504    inline uint MaxTotalId() const { return fIDTotalMax;}
00505    //______________________________________________________________________________
00506    inline int find(const QPaintDevice *device, uint i=0) const
00507    { 
00508       return fWidgetCollection.indexOf((QPaintDevice*)device,i); 
00509    }
00510    //______________________________________________________________________________
00511    inline QPaintDevice *operator[](int i) const {return fWidgetCollection[i];}
00512 };
00513 TQWidgetCollection *fWidgetArray = 0;
00514 //______________________________________________________________________________
00515 QPaintDevice *TGQt::iwid(Window_t wd)
00516 {
00517    // Convert ROOT Widget Id to the Qt QPaintDevice pointer
00518    QPaintDevice *topDevice = 0;
00519    if ( wd != kNone )   {
00520        topDevice = (wd == kDefault) ?
00521               (QPaintDevice *)QApplication::desktop()
00522              :
00523               (QPaintDevice*)wd;
00524    }
00525    return topDevice;
00526 }
00527 
00528 //______________________________________________________________________________
00529 Int_t         TGQt::iwid(QPaintDevice *wd)
00530 {
00531    // method to provide the ROOT "cast" from (QPaintDevice*) to ROOT windows "id"
00532    Int_t intWid = kNone;
00533        // look up the widget
00534    if ((ULong_t) wd == (ULong_t) -1) intWid = -1;
00535    else {
00536       intWid = fWidgetArray->find(wd);
00537       assert(intWid != -1);
00538       // if (intWid == -1) intWid = Int_t(wd);
00539    }
00540    return intWid;
00541 }
00542 
00543 //______________________________________________________________________________
00544 QPaintDevice *TGQt::iwid(Int_t wd)
00545 {
00546    // method to restore (cast) the QPaintDevice object pointer from  ROOT windows "id"
00547    QPaintDevice *topDevice = 0;
00548    if (0 <= wd && wd <= int(fWidgetArray->MaxId()) )
00549      topDevice = (*fWidgetArray)[wd];
00550      if (topDevice == (QPaintDevice *)(-1) ) topDevice = 0;
00551    else {
00552      assert(wd <= Int_t(fWidgetArray->MaxTotalId()));
00553      // this is allowed from the embedded TCanvas dtor only.
00554      //  at this point "wd" may have been destroyed
00555      //-- vf topDevice = (QPaintDevice *)wd;
00556    }
00557    return topDevice;
00558 }
00559 
00560 //______________________________________________________________________________
00561 QWidget      *TGQt::winid(Window_t id)
00562 {
00563    // returns the top level QWidget for the ROOT widget
00564    return (id != kNone)? TGQt::wid(id)->topLevelWidget():0;
00565 }
00566 
00567 //______________________________________________________________________________
00568 Window_t    TGQt::wid(TQtClientWidget *widget)
00569 {
00570    return rootwid(widget);
00571 }
00572 //______________________________________________________________________________
00573 Window_t    TGQt::rootwid(QPaintDevice *dev)
00574 {
00575    return Window_t(dev);
00576 }
00577 //______________________________________________________________________________
00578 QWidget      *TGQt::wid(Window_t id)
00579 {
00580    // method to restore (dynamic cast) the QWidget object pointer (if any) from  ROOT windows "id"
00581    QPaintDevice *dev = 0;
00582    if (id == (Window_t)kNone || id == (Window_t)(-1) ) return (QWidget *)dev;
00583    if ( id <= fWidgetArray->MaxId() )
00584       dev = (*fWidgetArray)[id];
00585    else
00586       dev = (QPaintDevice *)id;
00587 
00588 
00589 #if 0
00590      if ( dev->devType() != QInternal::Widget) {
00591         fprintf(stderr," %s %i type=%d QInternal::Widget = %d id =%x id = %d\n", "TGQt::wid", __LINE__
00592            , dev->devType()
00593            , QInternal::Widget, id, id );
00594 //           , (const char *)dev->name(), (const char *)dev->className(), QInternal::Widget);
00595    }
00596 #endif
00597    assert(dev->devType() == QInternal::Widget);
00598    return (QWidget *)dev;
00599 }
00600 
00601 //______________________________________________________________________________
00602 void TGQt::PrintEvent(Event_t &ev)
00603 {
00604    // Dump trhe ROOT Event_t structure to debug the code
00605 
00606    //EGEventType fType;              // of event (see EGEventTypes)
00607    //Window_t    fWindow;            // window reported event is relative to
00608    //Time_t      fTime;              // time event event occured in ms
00609    //Int_t       fX, fY;             // pointer x, y coordinates in event window
00610    //Int_t       fXRoot, fYRoot;     // coordinates relative to root
00611    //UInt_t      fCode;              // key or button code
00612    //UInt_t      fState;             // key or button mask
00613    //UInt_t      fWidth, fHeight;    // width and height of exposed area
00614    //Int_t       fCount;             // if non-zero, at least this many more exposes
00615    //Bool_t      fSendEvent;         // true if event came from SendEvent
00616    //Handle_t    fHandle;            // general resource handle (used for atoms or windows)
00617    //Int_t       fFormat;            // Next fields only used by kClientMessageEvent
00618    //Long_t      fUser[5];           // 5 longs can be used by client message events
00619    //                                // NOTE: only [0], [1] and [2] may be used.
00620    //                                // [1] and [2] may contain >32 bit quantities
00621    //                                // (i.e. pointers on 64 bit machines)
00622    qDebug() << "----- Window "<<  TGQt::wid(ev.fWindow) << TGQt::wid(ev.fWindow) << " " << TGQt::wid(ev.fWindow)-> objectName();
00623    fprintf(stderr,"event type =  %x, key or button code %d \n", ev.fType, ev.fCode);
00624    fprintf(stderr,"fX, fY, fXRoot, fYRoot = %d %d  :: %d %d\n", ev.fX, ev.fY,ev.fXRoot, ev.fYRoot);
00625 }
00626 
00627 int TGQt::fgCoinFlag = 0; // no current coin viewer;
00628 int TGQt::fgCoinLoaded = 0; // coint viewer DLL has not been loaded
00629 
00630 //______________________________________________________________________________
00631 int TGQt::CoinFlag()
00632 {
00633   // return the Coin/QGL viewer flag safely
00634    TQtLock lock;
00635    int ret = fgCoinFlag;
00636    return ret;
00637 }
00638 
00639 //______________________________________________________________________________
00640 void TGQt::SetCoinFlag(int flag)
00641 {
00642   // Set the Coin/QGL viewer flag safely
00643    TQtLock lock;
00644    fgCoinFlag=flag;
00645 }
00646 
00647 //______________________________________________________________________________
00648 void TGQt::SetCoinLoaded() {  fgCoinLoaded = 1; }
00649 
00650 //______________________________________________________________________________
00651 Int_t TGQt::IsCoinLoaded(){ return fgCoinLoaded;}
00652 
00653 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,0)
00654 //______________________________________________________________________________
00655 QPixmap *TGQt::MakeIcon(Int_t i)
00656 {
00657 //  Create the Qt QPixamp from the WIN32 system icon (for WIN32 only)
00658    QPixmap *tempIcon = NULL;
00659    if (i) { /* just to suspend the warning under UNIX */ }
00660 #ifdef R__QTWIN32
00661    HICON largeIcon[1];
00662    HICON smallIcon[1];
00663    HICON icon = ((TWinNTSystem *)gSystem)->GetNormalIcon(i);
00664 #if 0
00665    int numIcons = ::ExtractIconEx(
00666     "c:\winnt\explorer.exe",
00667     0,
00668     largeIcon,
00669     smallIcon,
00670     1);
00671    if (numIcons > 0)
00672    {
00673 #endif
00674    tempIcon =new QPixmap (GetSystemMetrics(SM_CXSMICON),
00675                           GetSystemMetrics(SM_CYSMICON));
00676    HDC dc = tempIcon->handle();
00677    DrawIcon (dc, 0, 0, icon);
00678 #else
00679 # ifdef ROOTICONPATH
00680    gSystem->ExpandPathName(ROOTICONPATH);
00681 # else
00682    gSystem->ExpandPathName("$ROOTSYS/icons/");
00683 //   tempIcon =new QPixmap (16,16),
00684 # endif
00685 #endif
00686    return tempIcon;
00687 }
00688 #endif
00689 
00690 
00691 ClassImp(TGQt)
00692 
00693 //____________________________________________________
00694 //
00695 //   Some static methods
00696 //______________________________________________________________________________
00697 QString TGQt::RootFileFormat(const char *selector)
00698 {  return RootFileFormat(QString(selector)); }
00699 
00700 //______________________________________________________________________________
00701 QString TGQt::RootFileFormat(const QString &selector)
00702 {
00703    // Define whether the input string contains any pattern
00704    // that matches the ROOT image formats
00705    // those Qt library can not provide
00706    QString saveType;
00707    QString defExtension[] = {"cpp","cxx","eps","svg","root","pdf","ps","xml"
00708 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,13,0)
00709                              ,"gif"
00710 #endif
00711                              ,"C"};
00712    UInt_t nExt = sizeof(defExtension)/sizeof(const char *);
00713     UInt_t i = 0;
00714    for (i=0; i < nExt; i++) {
00715       if (selector.contains(defExtension[i], Qt::CaseSensitive)) {
00716          saveType = defExtension[i];
00717          break;
00718       }
00719    }
00720    if (saveType.contains("C",Qt::CaseInsensitive)) saveType= "cxx";
00721    return saveType;
00722 }
00723 
00724 //______________________________________________________________________________
00725 QString TGQt::QtFileFormat(const char *selector)
00726 { return QtFileFormat(QString(selector)); }
00727 
00728 //______________________________________________________________________________
00729 QString TGQt::QtFileFormat(const QString &selector)
00730 {
00731    // returns Qt file format
00732    //
00733    // if no suitable format found and the selector is empty
00734    // the default PNG format is returned
00735    //
00736    // a special treatment of the "gif" format.
00737    // If "gif" is not provided with the local Qt installation
00738    // replace "gif" format with "png" one
00739    //
00740    QString saveType="PNG"; // it is the default format
00741    if (!selector.isEmpty())  {
00742       QList<QByteArray> formats =  QImageWriter::supportedImageFormats();
00743       QList<QByteArray>::const_iterator j;
00744       for (j = formats.constBegin(); j != formats.constEnd(); ++j)
00745       {
00746          QString nextFormat =  *j;
00747          // Trick to count both "jpeg" and "jpg" extenstion
00748          QString checkString = selector.contains("jpg",Qt::CaseInsensitive) ? "JPEG" : selector;
00749          if (checkString.contains(nextFormat,Qt::CaseInsensitive) ) {
00750             saveType = nextFormat;
00751             break;
00752          }
00753       }
00754       // a special treatment of the "gif" format.
00755       // If "gif" is not provided with the local Qt installation
00756       // replace "gif" format with "png" one
00757       // -- if (saveType.isEmpty() && selector.contains("gif",FALSE)) saveType="PNG";
00758    }
00759    return saveType;
00760 }
00761 
00762 //______________________________________________________________________________
00763 TQtApplication *TGQt::CreateQtApplicationImp()
00764 {
00765    // The method to instantiate the QApplication if needed
00766    static TQtApplication *app = 0;
00767    if (!app) {
00768       //    app = new TQtApplication(gApplication->ApplicationName(),gApplication->Argc(),gApplication->Argv());
00769       static TString argvString (
00770 #ifdef ROOTBINDIR
00771                                  ROOTBINDIR "/root.exe"
00772 #else
00773                                  "$ROOTSYS/bin/root.exe"
00774 #endif
00775                                  );
00776       gSystem->ExpandPathName(argvString);
00777       static char *argv[] = {(char *)argvString.Data()};
00778       static int nArg = 1;
00779       app = new TQtApplication("Qt",nArg,argv);
00780    }
00781    return app;
00782 }
00783 
00784 //______________________________________________________________________________
00785 void TGQt::PostQtEvent(QObject *receiver, QEvent *event)
00786 {
00787    // Qt announced that QThread::postEvent to become obsolete and
00788    // we have to switch to the QAppication instead.
00789   QApplication::postEvent(receiver,event);
00790 }
00791 
00792 //______________________________________________________________________________
00793 TGQt::TGQt() : TVirtualX(),fDisplayOpened(kFALSE),fQPainter(0),fhEvent ()
00794 ,fQBrush(),fQPen(),fQtMarker(),fQFont(),fQClientFilter(),fQClientFilterBuffer(0)
00795 ,fPointerGrabber(),fCodec(0),fSymbolFontFamily("Symbol"),fQtEventHasBeenProcessed(0)
00796 ,fFeedBackMode(kFALSE),fFeedBackWidget(0),fBlockRGB(kFALSE),fUseTTF(kTRUE)      
00797 {
00798    //*-*-*-*-*-*-*-*-*-*-*-*Default Constructor *-*-*-*-*-*-*-*-*-*-*-*-*-*-*
00799    //*-*                    ===================
00800    assert(!fgTQt);
00801    fgTQt = this;
00802    gQt   = this;
00803    fSelectedWindow = fPrevWindow = NoOperation;
00804 }
00805 
00806 //______________________________________________________________________________
00807 TGQt::TGQt(const char *name, const char *title) : TVirtualX(name,title),fDisplayOpened(kFALSE)
00808 ,fQPainter(0),fhEvent(),fCursors(kNumCursors),fQClientFilter(0),fQClientFilterBuffer(0),fPointerGrabber(0)
00809 ,fCodec(0),fSymbolFontFamily("Symbol"),fQtEventHasBeenProcessed(0)
00810 ,fFeedBackMode(kFALSE),fFeedBackWidget(0),fBlockRGB(kFALSE),fUseTTF(kTRUE)
00811 {
00812    //*-*-*-*-*-*-*-*-*-*-*-*-*-*Normal Constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
00813    //*-*                        ==================                              *-*
00814    assert(!fgTQt);
00815    fgTQt = this;
00816    gQt   = this;
00817    fSelectedWindow = fPrevWindow = NoOperation;
00818    CreateQtApplicationImp();
00819    Init();
00820 }
00821 
00822 //______________________________________________________________________________
00823 TGQt::~TGQt()
00824 {
00825    //*-*-*-*-*-*-*-*-*-*-*-*Default Destructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
00826    //*-*                    ==================
00827    {  // critical section
00828       TQtLock lock;
00829       gVirtualX = gGXBatch;
00830       gROOT->SetBatch();
00831       // clear the color map
00832       QMap<Color_t,QColor*>::const_iterator it;
00833       for (it = fPallete.begin();it !=fPallete.end();++it) {
00834          QColor *c = *it; delete c;
00835       }
00836        qDeleteAll(fCursors.begin(), fCursors.end());
00837 
00838       delete fQClientFilter;       fQClientFilter = 0;
00839       delete fQClientFilterBuffer; fQClientFilterBuffer = 0;
00840       delete fgTextProxy;          fgTextProxy = 0;
00841  // ---     delete fQPainter; fQPainter = 0;
00842    }
00843    // Stop GUI thread
00844    TQtApplication::Terminate();
00845    // fprintf(stderr, "TGQt::~TGQt()<------\n");
00846 }
00847 
00848 //______________________________________________________________________________
00849 Bool_t TGQt::Init(void* /*display*/)
00850 {
00851    //*-*-*-*-*-*-*-*-*-*-*-*-*-*Qt GUI initialization-*-*-*-*-*-*-*-*-*-*-*-*-*-*
00852    //*-*                        ========================                      *-*
00853    fprintf(stderr,"** $Id: TGQt.cxx 36275 2010-10-11 08:05:21Z brun $ this=%p\n",this);
00854 #ifndef R__QTWIN32
00855    extern void qt_x11_set_global_double_buffer(bool);
00856 //   qt_x11_set_global_double_buffer(false);
00857 #endif
00858 
00859    if(fDisplayOpened)   return fDisplayOpened;
00860    fSelectedWindow = fPrevWindow = NoOperation;
00861    fTextAlignH      = 1;
00862    fTextAlignV      = 1;
00863    fTextMagnitude   = 1;
00864    fCharacterUpX    = 1;
00865    fCharacterUpY    = 1;
00866    fDrawMode        = QPainter::CompositionMode_Source; // Qt::CopyROP;
00867    fTextFontModified = 0;
00868 
00869    fTextAlign   = 0;
00870    fTextSize    = -1;
00871    fTextFont    = -1;
00872    fLineWidth   = -1;
00873    fFillColor   = -1;
00874    fLineColor   = -1;
00875    fLineStyle   = -1;
00876    fMarkerSize  = -1;
00877    fMarkerStyle = -1;
00878 
00879    //
00880    // Retrieve the application instance
00881    //
00882 
00883    // --   fHInstance = GetModuleHandle(NULL);
00884 
00885    //
00886    // Create cursors
00887    //
00888    // Qt::BlankCursor - blank/invisible cursor
00889    // Qt::BitmapCursor
00890 
00891    fCursors[kBottomLeft]  = new QCursor(Qt::SizeBDiagCursor); // diagonal resize (/) LoadCursor(NULL, IDC_SIZENESW);// (display, XC_bottom_left_corner);
00892    fCursors[kBottomRight] = new QCursor(Qt::SizeFDiagCursor); // diagonal resize (\) LoadCursor(NULL, IDC_SIZENWSE);// (display, XC_bottom_right_corner);
00893    fCursors[kTopLeft]     = new QCursor(Qt::SizeFDiagCursor); // diagonal resize (\)  (display, XC_top_left_corner);
00894    fCursors[kTopRight]    = new QCursor(Qt::SizeBDiagCursor); // diagonal resize (/) LoadCursor(NULL, IDC_SIZENESW);// (display, XC_top_right_corner);
00895    //fCursors[kBottomSide] = new QCursor(Qt::SplitHCursor);    // - horziontal splitting LoadCursor(NULL, IDC_SIZENS);  // (display, XC_bottom_side);
00896    //fCursors[kLeftSide]   = new QCursor(Qt::SplitVCursor);    // - vertical splitting LoadCursor(NULL, IDC_SIZEWE);  // (display, XC_left_side);
00897    //fCursors[kTopSide]    = new QCursor(Qt::SplitHCursor);    // - horziontal splitting LoadCursor(NULL, IDC_SIZENS);  // (display, XC_top_side);
00898    //fCursors[kRightSide]  = new QCursor(Qt::SplitVCursor);    // - vertical splitting LoadCursor(NULL, IDC_SIZEWE);  // (display, XC_right_side);
00899    fCursors[kBottomSide]  = new QCursor(Qt::SizeVerCursor);   // - horziontal splitting LoadCursor(NULL, IDC_SIZENS);  // (display, XC_bottom_side);
00900    fCursors[kLeftSide]    = new QCursor(Qt::SizeHorCursor);   // - vertical splitting LoadCursor(NULL, IDC_SIZEWE);  // (display, XC_left_side);
00901    fCursors[kTopSide]     = new QCursor(Qt::SizeVerCursor);   // - horziontal splitting LoadCursor(NULL, IDC_SIZENS);  // (display, XC_top_side);
00902    fCursors[kRightSide]   = new QCursor(Qt::SizeHorCursor);   // - vertical splitting LoadCursor(NULL, IDC_SIZEWE);  // (display, XC_right_side);
00903 
00904    fCursors[kMove]        = new QCursor(Qt::SizeAllCursor);   //  all directions resize LoadCursor(NULL, IDC_SIZEALL); // (display, XC_fleur);
00905    fCursors[kCross]       = new QCursor(Qt::CrossCursor);     // - crosshair LoadCursor(NULL, IDC_CROSS);   // (display, XC_tcross);
00906    fCursors[kArrowHor]    = new QCursor(Qt::SizeHorCursor);   //   horizontal resize LoadCursor(NULL, IDC_SIZEWE);  // (display, XC_sb_h_double_arrow);
00907    fCursors[kArrowVer]    = new QCursor(Qt::SizeVerCursor);   //  vertical resize LoadCursor(NULL, IDC_SIZENS)  (display, XC_sb_v_double_arrow);
00908    fCursors[kHand]        = new QCursor(Qt::PointingHandCursor); //  a pointing hand LoadCursor(NULL, IDC_NO);      // (display, XC_hand2);
00909    fCursors[kRotate]      = new QCursor(Qt::ForbiddenCursor); // - a slashed circle LoadCursor(NULL, IDC_ARROW);    // (display, XC_exchange);
00910    fCursors[kPointer]     = new QCursor(Qt::ArrowCursor);     // standard arrow cursor  / (display, XC_left_ptr);
00911    fCursors[kArrowRight]  = new QCursor(Qt::UpArrowCursor);   // - upwards arrow LoadCursor(NULL, IDC_ARROW);   // XC_arrow
00912    fCursors[kCaret]       = new QCursor(Qt::IBeamCursor);     //  ibeam/text entry LoadCursor(NULL, IDC_IBEAM);   // XC_xterm
00913    fCursors[kWatch]       = new QCursor(Qt::WaitCursor);      //
00914 
00915    // The default cursor
00916 
00917    fCursor = kCross;
00918 
00919    // Qt object used to paint the canvas
00920    fQPen     = new TQtPen;
00921    fQBrush   = new TQtBrush;
00922    fQtMarker = new TQtMarker;
00923    fQFont    = new TQtPadFont();
00924    // ((TGQt *)TGQt::GetVirtualX())->SetQClientFilter(
00925    fQClientFilter = new TQtClientFilter();
00926 
00927    //  Query the default font for Widget decoration.
00928    fFontTextCode = "ISO8859-1";
00929    const char *default_font =
00930       gEnv->GetValue("Gui.DefaultFont",  "-adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
00931    QFont *dfFont = (QFont *)LoadQueryFont(default_font);
00932    QApplication::setFont(*dfFont);
00933    delete dfFont;
00934    //  define the font code page
00935    QString fontName(default_font);
00936    fFontTextCode = fontName.section('-',13). toUpper();
00937    if  ( fFontTextCode.isEmpty() ) fFontTextCode = "ISO8859-5";
00938 #ifndef R__QTWIN32
00939    // Check whether "Symbol" font is available
00940     QFontDatabase fdb;
00941     QString fontFamily;
00942     QStringList families = fdb.families();
00943     Bool_t symbolFontFound = kFALSE;
00944     Bool_t isXdfSupport = !gSystem->Getenv("QT_X11_NO_FONTCONFIG");
00945     for ( QStringList::Iterator f = families.begin(); f != families.end(); ++f ) {
00946         // qDebug() << "Next Symbol font family found:" << *f << fdb.writingSystems(*f);
00947        if ( (isXdfSupport && (*f).contains(fSymbolFontFamily)
00948              && fdb.writingSystems(*f).contains(QFontDatabase::Symbol)
00949          )  || (!isXdfSupport && ((*f) == fSymbolFontFamily)) )
00950         {
00951            symbolFontFound = kTRUE;
00952            qDebug() << "Symbol font family found: " <<  *f;
00953            if (*f == "Standard Symbols L") { fontFamily = *f; break; }
00954         }
00955     }
00956 
00957     if (isXdfSupport && !symbolFontFound) {
00958 // Load the local ROOT font
00959        QString fontdir =
00960 #ifdef TTFFONTDIR
00961                 TTFFONTDIR
00962 #else
00963                   "$ROOOTSYS/fonts"
00964 #endif
00965         ;
00966         QString symbolFontFile = fontdir + "/" + QString(fSymbolFontFamily).toLower() + ".ttf";
00967         symbolFontFound = QFontDatabase::addApplicationFont(symbolFontFile);
00968     }
00969     if (!symbolFontFound) {
00970         fprintf(stderr, "The font \"symbol.ttf\" was not installed yet\n");
00971          //  provide the replacement and the codec
00972         fontFamily = fSymbolFontFamily = "Arial";
00973         qDebug() << " Substitute it with \""<<fontFamily <<"\"";
00974         qDebug() << " Make sure your local \"~/.fonts.conf\" or \"/etc/fonts/fonts.conf\" file points to \""
00975                  << 
00976 #ifdef TTFFONTDIR
00977                 TTFFONTDIR
00978 #else
00979                 "$ROOOTSYS/fonts"
00980 #endif
00981                 << "\" directory to get the proper support for ROOT TLatex class";
00982         // create a custom codec
00983         new QSymbolCodec();
00984     }
00985     if (symbolFontFound) TQtPadFont::SetSymbolFontFamily(fontFamily.toAscii().data());
00986 #endif
00987 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0)
00988        fUseTTF=gEnv->GetValue("Qt.Screen.TTF",kFALSE);
00989 #else
00990        fUseTTF=gEnv->GetValue("Qt.Screen.TTF",kTRUE);
00991 #endif
00992    //  printf(" TGQt::Init finsihed\n");
00993    // Install filter for the desktop
00994    // QApplication::desktop()->installEventFilter(QClientFilter());
00995    fWidgetArray =  new TQWidgetCollection();
00996    fDisplayOpened = kTRUE;
00997    TQtEventInputHandler::Instance();
00998    // Add $QTDIR include  path to the  list of includes for ACliC
00999    // make sure Qt SDK does exist.
01000    if (gSystem->Getenv("QTDIR")) {
01001       TString qtdir = "$(QTDIR)/include/";
01002       // Expand the QTDIR first to avoid the cross-platform issue
01003       gSystem->ExpandPathName(qtdir);
01004       TString testQtHeader = qtdir + "Qt/qglobal.h";
01005       if (!gSystem->AccessPathName((const char *)testQtHeader) ) {
01006          void *qtdirHandle = gSystem->OpenDirectory(qtdir);
01007          if (qtdirHandle) {
01008             TString incpath = " -I"; incpath+=qtdir;
01009             while(const char *nextQtInclude = gSystem->GetDirEntry(qtdirHandle)) {
01010                // Skip the hidden directories including the current "." and parent ".."
01011                if (nextQtInclude[0] != '.')  {
01012                      incpath += " -I"; incpath+=qtdir; incpath+=nextQtInclude;
01013                }
01014             }
01015             gSystem->FreeDirectory(qtdirHandle);
01016             gSystem->AddIncludePath((const char*)incpath);
01017          }
01018 #ifdef R__WIN32
01019          QString libPath = gSystem->GetLinkedLibs();
01020          // detect the exact name of the Qt library
01021          TString qtlibdir= "$(QTDIR)";
01022          qtlibdir += QDir::separator().toAscii();
01023          qtlibdir += "lib";
01024 
01025          gSystem->ExpandPathName(qtlibdir);
01026          QDir qtdir((const char*)qtlibdir);
01027          if (qtdir.isReadable ()) {
01028             QStringList qtLibFile =  qtdir.entryList(QStringList("Q*4.lib"),QDir::Files);
01029             QStringListIterator libFiles(qtLibFile);
01030             if (libFiles.hasNext()) {
01031                libPath += " -LIBPATH:\"";libPath += qtlibdir;  libPath += "\" ";
01032 #if 0
01033                while (libFiles.hasNext()) {
01034                   QString nf = libFiles.next();
01035                   if (nf.contains("d4")) continue; // skip the debug version of the libraries
01036                   libPath += nf.toLocal8Bit().constData();
01037                   libPath += " ";
01038                }
01039 #else
01040                   libPath += "QtCore4.lib QtGui4.lib QtOpenGL4.lib Qt3Support4.lib";
01041 #endif
01042                gSystem->SetLinkedLibs(libPath.toAscii().data());
01043             }
01044          } else {
01045             qWarning(" Can not open the QTDIR %s",(const char*)qtlibdir);
01046          }
01047 #endif
01048       }
01049    }
01050    TString newPath =
01051 # ifdef CINTINCDIR
01052       CINTINCDIR
01053 # else
01054    "$(ROOTSYS)/cint/"
01055 # endif
01056      ; newPath += "include";
01057 #ifndef R__WIN32
01058    newPath += ":";
01059 #else
01060    newPath += ";";
01061 #endif
01062    newPath += gSystem->GetDynamicPath();
01063    gSystem->SetDynamicPath(newPath.Data());
01064    return fDisplayOpened;
01065 }
01066 
01067 //______________________________________________________________________________
01068 Int_t TGQt::CreatROOTThread()
01069 {
01070 //*-*-*-*-*dummy*-*-*-*-*-*-*-*-*
01071 //*-*
01072   return 0;
01073 }
01074 //______________________________________________________________________________
01075 Int_t  TGQt::RegisterWid(QPaintDevice *wd)
01076 {
01077  // register QWidget for the embedded TCanvas
01078    Int_t id = fWidgetArray->find(wd);
01079    if (id == -1) id = fWidgetArray->GetFreeId(wd);
01080    return id;
01081 }
01082 //______________________________________________________________________________
01083 Int_t  TGQt::UnRegisterWid(QPaintDevice *wd)
01084 {
01085    // unregister QWidget to the TCanvas
01086    // return  = Root registration Id or zero if the wd was not registered
01087    return fWidgetArray->RemoveByPointer(wd);
01088 }
01089 //______________________________________________________________________________
01090 Bool_t  TGQt::IsRegistered(QPaintDevice *wd)
01091 {
01092    // Check whether the object has been registered
01093    return fWidgetArray->find(wd) == -1 ? kFALSE : kTRUE;
01094 }
01095 //______________________________________________________________________________
01096 Int_t TGQt::InitWindow(ULong_t window)
01097 {
01098    //*-*
01099    //*-*  if window == 0 InitWindow creates his own instance of  TQtWindowsObject object
01100    //*-*
01101    //*-*  Create a new windows
01102    //*-*
01103    // window is QWidget
01104    TQtWidget *wd    = 0;
01105    QWidget   *parent = 0;
01106    if (window <= fWidgetArray->MaxId() )
01107       parent = dynamic_cast<TQtWidget *> (iwid(int     (window)));
01108    else {
01109       QPaintDevice *dev = dynamic_cast<QPaintDevice *>(iwid(Window_t(window)));
01110       parent = dynamic_cast<QWidget *>(dev);
01111    }
01112 
01113  //     QWidget *parent = (window == kDefault) ? 0 : dynamic_cast<QWidget *>(iwid(window));
01114  //   QWidget *parent = (window == kDefault) ? 0 : (QWidget *)iwid(window);
01115    wd = new TQtWidget(parent,"virtualx",Qt::FramelessWindowHint,FALSE);
01116    wd->setCursor(*fCursors[kCross]);
01117    Int_t id = fWidgetArray->GetFreeId(wd);
01118    // The default mode is the double buffer mode
01119    wd->SetDoubleBuffer(1);
01120    // fprintf(stderr," TGQt::InitWindow %d id=%d device=%p buffer=%p\n",window,id,wd,&wd->GetBuffer());
01121    return id;
01122 }
01123 
01124 //______________________________________________________________________________
01125 Int_t TGQt::OpenPixmap(UInt_t w, UInt_t h)
01126 {
01127    //*-*  Create a new pixmap object
01128    QPixmap *obj =  new QPixmap(w,h);
01129    // fprintf(stderr," TGQt::OpenPixmap %d %d %p\n",w,h,obj);
01130    return fWidgetArray->GetFreeId(obj);
01131    // return iwid(obj);
01132 }
01133 
01134 //______________________________________________________________________________
01135 const QColor &TGQt::ColorIndex(Color_t ic) const
01136 {
01137    // Define the QColor object by ROOT color index
01138    QColor *colorBuffer=0;
01139    static QColor unknownColor;
01140    // There are three different ways in ROOT to define RGB.
01141    // It took 4 months to figure out.
01142    // See #ifndef R_WIN32 with  TColor::SetRGB method
01143    if (!fPallete.contains(ic)) {
01144        Warning("ColorIndex","Unknown color. No RGB component for the index %d was defined\n",ic);
01145        return unknownColor;
01146    } else {
01147       // Make sure the alpha channel was set properly
01148       // due lack of the TVirtualX interface to account it elsewhere
01149       TColor *myColor = gROOT->GetColor(ic);
01150       Float_t a = myColor->GetAlpha();
01151       colorBuffer = fPallete[ic];
01152       if (TMath::Abs(colorBuffer->alphaF() - a) > 0.01) {
01153          colorBuffer->setAlphaF(a);
01154       }
01155    }
01156    return *colorBuffer;
01157 }
01158 
01159 //______________________________________________________________________________
01160 UInt_t TGQt::ExecCommand(TGWin32Command* /*command*/)
01161 {
01162    // deprecated
01163    fprintf(stderr,"** Error **:  TGQt::ExecCommand no implementation\n");
01164    return 0;
01165 }
01166 
01167 //______________________________________________________________________________
01168 void TGQt::SetDoubleBufferOFF()
01169 {
01170    // deprecated
01171    fprintf(stderr,"** Error **:  TGQt::SetDoubleBufferOFF no implementation\n");
01172 }
01173 
01174 //______________________________________________________________________________
01175 void TGQt::SetDoubleBufferON()
01176 {
01177    // deprecated
01178    fprintf(stderr,"** Error **:  TGQt::SetDoubleBufferON no implementation\n");
01179 }
01180 
01181 //______________________________________________________________________________
01182 void TGQt::GetPlanes(Int_t &nplanes){
01183 //*-*-*-*-*-*-*-*-*-*-*-*Get maximum number of planes*-*-*-*-*-*-*-*-*-*-*-*-*
01184 //*-*                    ============================
01185 //*-*  nplanes     : number of bit planes
01186 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
01187    nplanes  = QPixmap::defaultDepth();
01188 }
01189 
01190 //______________________________________________________________________________
01191 void  TGQt::ClearWindow()
01192 {
01193    // Clear current window.
01194    if (fSelectedWindow && fSelectedWindow != NoOperation)
01195    {
01196       if (IsWidget(fSelectedWindow)) {
01197          ((TQtWidget *)fSelectedWindow)->Erase();
01198       } else if (IsPixmap(fSelectedWindow) ) {
01199          ((QPixmap *)fSelectedWindow)->fill(fQBrush->color()); // Qt::transparent);
01200       } else {
01201          TQtPainter p(this);
01202          p.eraseRect(GetQRect(*fSelectedWindow));
01203       }
01204    }
01205 }
01206 
01207 //______________________________________________________________________________
01208 void  TGQt::ClosePixmap()
01209 {
01210    // Delete the current pixmap.
01211    DeleteSelectedObj();
01212 }
01213 
01214 //______________________________________________________________________________
01215 void  TGQt::CloseWindow()
01216 {
01217    // Delete the current window.
01218    DeleteSelectedObj();
01219 }
01220 
01221 //______________________________________________________________________________
01222 void  TGQt::DeleteSelectedObj()
01223 {
01224     // Delete the current Qt object
01225   if (fSelectedWindow->devType() == QInternal::Widget) {
01226      TQtWidget *canvasWidget = dynamic_cast<TQtWidget *>(fSelectedWindow);
01227      if (canvasWidget) {
01228         canvasWidget->ResetCanvas();
01229      }
01230      QWidget *wrapper = 0;
01231      if (canvasWidget && (wrapper=canvasWidget->GetRootID())) {
01232         wrapper->hide();
01233         DestroyWindow(rootwid(wrapper) );
01234      } else {
01235         // check whether we are still registered
01236         if(UnRegisterWid(fSelectedWindow) != (Int_t) kNone) {
01237            ((QWidget *)fSelectedWindow)->hide();
01238            ((QWidget *)fSelectedWindow)->close();
01239         }
01240      }
01241   } else {
01242      UnRegisterWid(fSelectedWindow);
01243      delete  fSelectedWindow;
01244   }
01245   fClipMap.remove(fSelectedWindow);
01246   fSelectedWindow = 0;
01247   fPrevWindow     = 0;
01248 }
01249 
01250 //______________________________________________________________________________
01251 QRect TGQt::GetQRect(QPaintDevice &dev)
01252 {
01253    // Define the rectangle of the current ROOT selection
01254   QRect res(0,0,0,0);
01255 
01256   switch (dev.devType() ) {
01257   case QInternal::Widget:
01258     res = ((TQtWidget*)&dev)->rect();
01259     break;
01260 
01261   default:
01262      res.setSize(QSize(dev.width(),dev.height()));
01263      break;
01264   };
01265   return res;
01266 }
01267 
01268 //______________________________________________________________________________
01269 void  TGQt::CopyPixmap(int wd, int xpos, int ypos)
01270 {
01271    // Copy the pixmap wd at the position xpos, ypos in the current window.
01272 
01273    if (!wd || (wd == -1) ) return;
01274    QPaintDevice *dev = iwid(wd);
01275    assert(dev->devType() == QInternal::Pixmap);
01276    QPixmap *src = (QPixmap *)dev;
01277      //  QPixmap *src = (QPixmap *)(QPaintDevice *)wd;
01278      //  fprintf(stderr," TGQt::CopyPixmap Selected = %p, Buffer = %p, wd = %p\n",
01279      //  fSelectedWindow,fSelectedBuffer,iwid(wd));
01280    if (fSelectedWindow )
01281    {
01282       QPaintDevice *dst = fSelectedWindow;
01283       if (dst == (QPaintDevice *)-1) {
01284          Error("TGQt::CopyPixmap","Wrong TGuiFactory implementation was provided. Please, check your plugin settings");
01285          assert(dst != (QPaintDevice *)-1);
01286       }
01287       bool itIsWidget = fSelectedWindow->devType() == QInternal::Widget;
01288       TQtWidget *theWidget = 0;
01289       if (itIsWidget) { 
01290           theWidget =  (TQtWidget *)fSelectedWindow;
01291           dst = theWidget->GetOffScreenBuffer();
01292       }
01293       { 
01294         QPainter paint(dst);
01295         paint.drawPixmap(xpos,ypos,*src);
01296       }
01297       Emitter()->EmitPadPainted(src);
01298       if (theWidget)  theWidget->EmitCanvasPainted();
01299    }
01300 }
01301 //______________________________________________________________________________
01302 void TGQt::CopyPixmap(const QPixmap &src, Int_t xpos, Int_t ypos)
01303 {
01304    // Copy the pixmap p at the position xpos, ypos in the current window.
01305    if (fSelectedWindow )
01306    {
01307       QPaintDevice *dst = fSelectedWindow;
01308       QPainter paint(dst); paint.drawPixmap(xpos,ypos,src);
01309    }
01310 }
01311 //______________________________________________________________________________
01312 void TGQt::CreateOpenGLContext(int wd)
01313 {
01314  // Create OpenGL context for win windows (for "selected" Window by default)
01315  // printf(" TGQt::CreateOpenGLContext for wd = %x fSelected= %x, threadID= %d \n",wd,fSelectedWindow,
01316  //    GetCurrentThreadId());
01317   if (!wd || (wd == -1) ) return;
01318 
01319 #ifdef QtGL
01320     if (!wd)
01321     {
01322       SafeCallWin32
01323          ->W32_CreateOpenGL();
01324     }
01325     else
01326     {
01327       SafeCallW32(((TQtSwitch *)wd))
01328          ->W32_CreateOpenGL();
01329     }
01330 #endif
01331 
01332 }
01333 
01334 //______________________________________________________________________________
01335 void TGQt::DeleteOpenGLContext(int wd)
01336 {
01337   // Delete OpenGL context for win windows (for "selected" Window by default)
01338   if (!wd || (wd == -1) ) return;
01339 
01340 #ifdef QtGL
01341     if (!wd)
01342     {
01343       SafeCallWin32
01344          ->W32_DeleteOpenGL();
01345     }
01346     else
01347     {
01348       SafeCallW32(((TQtSwitch *)wd))
01349          ->W32_DeleteOpenGL();
01350     }
01351 #endif
01352 }
01353 
01354 //______________________________________________________________________________
01355 void  TGQt::DrawBox(int x1, int y1, int x2, int y2, EBoxMode mode)
01356 {
01357    // Draw a box.
01358    // mode=0 hollow  (kHollow)
01359    // mode=1 solid   (kSolid)
01360 #if QT_VERSION < 0x40000
01361    static const int Q3=1;
01362 #else
01363    // Read: http://doc.trolltech.com/4.3/porting4.html
01364    // "In Qt 4, the result of drawing a QRect with
01365    //  a pen width of 1 pixel is 1 pixel wider and
01366    //  1 pixel taller than in Qt 3 "
01367 
01368    static const int Q3=0;
01369 #endif
01370    if (!fSelectedWindow ) return;
01371    TQtLock lock;
01372    // Some workaround to fix issue from TBox::ExecuteEvent case pC. 
01373    // The reason of the problem has not been found yet.
01374    // By some reason TBox::ExecuteEvent messes y2 and y1
01375    if (y2 > y1) {
01376            // swap them :-(()
01377            int swap = y1; 
01378            y1=y2; y2=swap;
01379    }
01380    if (x1 > x2) {
01381            // swap them :-(()
01382            int swap = x1; 
01383            x1=x2; x2=swap;
01384    }
01385    if ( (fSelectedWindow->devType() ==  QInternal::Widget) && fFeedBackMode && fFeedBackWidget) {
01386       fFeedBackWidget->SetGeometry(x1,y2,x2-x1,y1-y2,(TQtWidget *)fSelectedWindow);
01387       if (fFeedBackWidget->isHidden() ) fFeedBackWidget->Show();
01388       return;
01389    }
01390 
01391    if ((mode == kHollow) || (fQBrush->style() == Qt::NoBrush) )
01392    { 
01393       TQtPainter p(this,TQtPainter::kUpdatePen);
01394       p.setBrush(Qt::NoBrush);
01395       p.drawRect(x1,y2,x2-x1+Q3,y1-y2+Q3);
01396    } else if (fQBrush->GetColor().alpha() ) {
01397       TQtPainter p(this);
01398       if (fQBrush->style() != Qt::SolidPattern) p.setPen(fQBrush->GetColor());
01399       p.fillRect(x1,y2,x2-x1,y1-y2,*fQBrush);
01400    }
01401 }
01402 
01403 //______________________________________________________________________________
01404 void  TGQt::DrawCellArray(int x1, int y1, int x2, int y2, int nx, int ny, int *ic)
01405 {
01406    // Draw a cell array.
01407    // x1,y1        : left down corner
01408    // x2,y2        : right up corner
01409    // nx,ny        : array size
01410    // ic           : array
01411    //
01412    // Draw a cell array. The drawing is done with the pixel precision
01413    // if (X2-X1)/NX (or Y) is not a exact pixel number the position of
01414    // the top rigth corner may be wrong.
01415 
01416    TQtLock lock;
01417    if (fSelectedWindow)
01418    {
01419       int i,j,icol,ix,w,h,current_icol,lh;
01420 
01421       current_icol = -1;
01422       w            = TMath::Max((x2-x1)/(nx),1);
01423       h            = TMath::Max((y1-y2)/(ny),1);
01424       lh           = y1-y2;
01425       ix           = x1;
01426 
01427       if (w+h == 2)
01428       {
01429          //*-*  The size of the box is equal a single pixel
01430          TQtPainter p(this,TQtPainter::kUpdatePen);
01431          for ( i=x1; i<x1+nx; i++){
01432             for (j = 0; j<ny; j++){
01433                icol = ic[i+(nx*j)];
01434                if (current_icol != icol) {
01435                   current_icol = icol;
01436                   p.setPen(ColorIndex(current_icol));
01437                }
01438                p.drawPoint(i,y1-j);
01439             }
01440          }
01441       }
01442       else
01443       {
01444          //*-* The shape of the box is a rectangle
01445          QRect box(x1,y1,w,h);
01446          TQtPainter p(this,TQtPainter::kNone);
01447          for ( i=0; i<nx; i++ ) {
01448             for ( j=0; j<ny; j++ ) {
01449                icol = ic[i+(nx*j)];
01450                if(icol != current_icol){
01451                   current_icol = icol;
01452                   p.setBrush(ColorIndex(current_icol));
01453                }
01454                p.drawRect(box);
01455                box.translate(0,-h);   // box.top -= h;
01456             }
01457             box.translate(w,lh);
01458          }
01459       }
01460    }
01461 }
01462 
01463 //______________________________________________________________________________
01464 void  TGQt::DrawFillArea(int n, TPoint *xy)
01465 {
01466    // Fill area described by polygon.
01467    // n         : number of points
01468    // xy(2,n)   : list of points
01469 
01470    TQtLock lock;
01471    if (fSelectedWindow && n>0)
01472    {
01473       TQtPainter p(this);
01474       if (fQBrush->style() == Qt::SolidPattern) p.setPen(Qt::NoPen);
01475       QPolygon qtPoints(n);
01476       TPoint *rootPoint = xy;
01477       for (int i =0;i<n;i++,rootPoint++) qtPoints.setPoint(i,rootPoint->fX,rootPoint->fY);
01478       p.drawPolygon(qtPoints);
01479    }
01480 }
01481 
01482 //______________________________________________________________________________
01483 void  TGQt::DrawLine(int x1, int y1, int x2, int y2)
01484 {
01485    // Draw a line.
01486    // x1,y1        : begin of line
01487    // x2,y2        : end of line
01488 
01489   TQtLock lock;
01490   if (fSelectedWindow) {
01491      TQtToggleFeedBack  feedBack(this);
01492      feedBack.painter().drawLine(x1,y1,x2,y2);
01493 #if 0
01494      if (x1> 1000) {
01495         // Qt 4.5.x bug
01496        qDebug() << "TGQt::DrawLine " << " x1=" << x1 
01497                                    << " y1=" << y1
01498                                    << " x2=" << x2
01499                                    << " y2=" << y2;
01500        //assert(0 && "Weird coordinate");
01501      }
01502 #endif
01503   }
01504 }
01505 
01506 //______________________________________________________________________________
01507 void  TGQt::DrawPolyLine(int n, TPoint *xy)
01508 {
01509    // Draw a line through all points.
01510    // n         : number of points
01511    // xy        : list of points
01512 
01513   TQtLock lock;
01514   if (fSelectedWindow)  {
01515      TQtToggleFeedBack  feedBack(this);
01516      QPolygon qtPoints(n);
01517      TPoint *rootPoint = xy;
01518      for (int i =0;i<n;i++,rootPoint++) qtPoints.setPoint(i,rootPoint->fX,rootPoint->fY);
01519      feedBack.painter().drawPolyline(qtPoints);
01520   }
01521 }
01522 
01523 //______________________________________________________________________________
01524 void  TGQt::DrawPolyMarker(int n, TPoint *xy)
01525 {
01526    // Draw n markers with the current attributes at position x, y.
01527    // n    : number of markers to draw
01528    // xy   : x,y coordinates of markers
01529    TQtLock lock;
01530    if (fSelectedWindow) {
01531       TQtPainter p(this,TQtPainter::kNone);
01532                 fQtMarker->DrawPolyMarker(p,n,xy);
01533    }
01534 }
01535 //______________________________________________________________________________
01536 TQtTextProxy  *TGQt::TextProxy()
01537 {
01538    // Get the text proxy implementation pointer
01539    return fgTextProxy;
01540 }
01541 //______________________________________________________________________________
01542 void  TGQt::SetTextProxy(TQtTextProxy  *proxy)
01543 {
01544    // Set the text proxy implementation pointer
01545    fgTextProxy = proxy;
01546 }
01547 
01548 //______________________________________________________________________________
01549 void  TGQt::DrawText(int x, int y, float angle, float mgn, const char *text, TVirtualX::ETextMode /*mode*/)
01550 {
01551 
01552    // Draw a text string using current font.
01553    // mode       : drawing mode
01554    // mode=0     : the background is not drawn (kClear)
01555    // mode=1     : the background is drawn (kOpaque)
01556    // x,y        : text position
01557    // angle      : text angle
01558    // mgn        : magnification factor
01559    // text       : text string
01560 
01561 
01562    // fprintf(stderr,"TGQt::DrawText: %s\n", text);
01563    if (text && text[0]) {
01564       TQtLock lock;
01565       fQFont->SetTextMagnify(mgn);
01566       TQtPainter p(this,TQtPainter::kUpdateFont);
01567       p.setPen(ColorIndex(fTextColor));
01568       p.setBrush(ColorIndex(fTextColor));
01569       unsigned int w=0;unsigned int h=0; unsigned int d = 0;
01570       bool textProxy = false;
01571       TQtTextCloneProxy proxy;
01572       if (fgTextProxy) {
01573          proxy->clear();
01574          QFontInfo fi(*fQFont);
01575          proxy->setBaseFontPointSize(fi.pointSize());
01576          proxy->setForegroundColor(ColorIndex(fTextColor));
01577          if ( ( textProxy = proxy->setContent(text) ) ) {
01578              w = proxy->width();
01579              h = proxy->height();
01580          }
01581       } 
01582       if (!textProxy) {
01583          QFontMetrics metrics(*fQFont);
01584          QRect bRect = metrics.boundingRect(text);
01585          w = bRect.width();
01586          h = bRect.height();
01587          d = metrics.descent();
01588       }
01589       p.translate(x,y);
01590       if (TMath::Abs(angle) > 0.1 ) p.rotate(-angle);
01591       int dx =0; int dy =0;
01592       
01593       switch( fTextAlignH ) {
01594            case 2: dx = -int(w/2);                  // h center;
01595               break;
01596            case 3: dx = -int(w);                    //  Right;
01597               break;
01598       };
01599       switch( fTextAlignV ) {
01600           case 2: dy = h/2 - d; // v center // metrics.strikeOutPos();
01601              break;
01602           case 3: dy = h   - d; // AlignTop;
01603       };
01604       if (textProxy)
01605          proxy->paint(&p,dx,-dy);
01606       else
01607          p.drawText (dx, dy, GetTextDecoder()->toUnicode (text));
01608    }
01609 }
01610 
01611 //______________________________________________________________________________
01612 void  TGQt::GetCharacterUp(Float_t &chupx, Float_t &chupy)
01613 {
01614    // Return character up vector.
01615 
01616    TQtLock lock;
01617    chupx = fCharacterUpX;
01618    chupy = fCharacterUpY;
01619 }
01620 
01621 //______________________________________________________________________________
01622 QPaintDevice *TGQt::GetDoubleBuffer(QPaintDevice *dev)
01623 {
01624    // Query the pointer to the dev offscreen buffer if any
01625 
01626    QPaintDevice *buffer = 0;
01627    if (dev) {
01628        TQtWidget *widget = dynamic_cast<TQtWidget *>(dev);
01629        buffer = widget && widget->IsDoubleBuffered() ? widget->SetBuffer().Buffer() : 0;
01630    }
01631    return buffer;
01632 }
01633 //______________________________________________________________________________
01634 Int_t  TGQt::GetDoubleBuffer(Int_t wd)
01635 {
01636    // Query the double buffer value for the window wd.
01637    // return pointer to the off-screen buffer if any
01638 
01639    if (wd == -1 || wd == kDefault ) return 0;
01640    assert(0);
01641    QPaintDevice *dev = iwid(wd);
01642    TQtWidget *widget = dynamic_cast<TQtWidget *>(dev);
01643    return  Int_t(widget && widget->IsDoubleBuffered());
01644 }
01645 
01646 //______________________________________________________________________________
01647 void  TGQt::GetGeometry(int wd, int &x, int &y, unsigned int &w, unsigned int &h)
01648 {
01649    // Returns the global cooordinate of the window "wd"
01650    QRect devSize(0,0,0,0);
01651    if( wd == -1 || wd == 0 || wd == kDefault)
01652    {
01653       QDesktopWidget *d = QApplication::desktop();
01654       devSize.setWidth (d->width() );
01655       devSize.setHeight(d->height());
01656    } else {
01657       QPaintDevice  *dev = iwid(wd);
01658       if (dev) {
01659          if ( dev->devType() == QInternal::Widget) {
01660             TQtWidget &thisWidget = *(TQtWidget *)dev;
01661             if (thisWidget.GetRootID() ) {
01662                // we are using the ROOT Gui factory
01663                devSize = thisWidget.parentWidget()->geometry();
01664             } else{
01665                devSize = thisWidget.geometry();
01666             }
01667             devSize.moveTopLeft(thisWidget.mapToGlobal(QPoint(0,0)));
01668          } else {
01669             devSize = GetQRect(*dev);
01670          }
01671       }
01672    }
01673    x = devSize.left();
01674    y = devSize.top();
01675    w = devSize.width();
01676    h = devSize.height();
01677  //  fprintf(stderr," 2. TGQt::GetGeometry %d %d %d %d %d\n", wd, x,y,w,h);
01678 }
01679 
01680 //______________________________________________________________________________
01681 const char *TGQt::DisplayName(const char *){ return "localhost"; }
01682 
01683 //______________________________________________________________________________
01684 ULong_t  TGQt::GetPixel(Color_t cindex)
01685 {
01686    // Return pixel value associated to specified ROOT color number.
01687    // see: GQTGUI.cxx:QtColor() also
01688    ULong_t rootPixel = 0;
01689    const QColor &color = ColorIndex(UpdateColor(cindex));
01690 #ifdef R__WIN32
01691    rootPixel =                    ( color.blue () & 255 );
01692    rootPixel = (rootPixel << 8) | ( color.green() & 255 ) ;
01693    rootPixel = (rootPixel << 8) | ( color.red  () & 255 );
01694 #else
01695    rootPixel =                    ( color.red ()  & 255 );
01696    rootPixel = (rootPixel << 8) | ( color.green() & 255 ) ;
01697    rootPixel = (rootPixel << 8) | ( color.blue  ()& 255 );
01698 #endif
01699    return rootPixel;
01700 }
01701 
01702 //______________________________________________________________________________
01703 void  TGQt::GetRGB(int index, float &r, float &g, float &b)
01704 {
01705    // Get rgb values for color "index".
01706    r = g = b = 0;
01707    TQtLock lock;
01708    if (fSelectedWindow != NoOperation) {
01709       qreal R,G,B;
01710       const QColor &color = *fPallete[index];
01711       color.getRgbF(&R,&G,&B);
01712       r = R; g = G; b = G;
01713    }
01714 }
01715 
01716 //______________________________________________________________________________
01717 const QTextCodec *TGQt::GetTextDecoder()
01718 {
01719    static  QTextCodec  *fGreekCodec = 0;
01720    QTextCodec  *codec = 0;
01721    if (!fCodec) {
01722       fCodec =  QTextCodec::codecForName(fFontTextCode.toAscii()); //CP1251
01723       if (!fCodec)
01724          fCodec=QTextCodec::codecForLocale();
01725       else
01726          QTextCodec::setCodecForLocale(fCodec);
01727    }
01728    codec = fCodec;
01729    if (fTextFont/10 == 12 ) {
01730         // We expect the Greek letters and should apply the right Codec
01731       if (!fGreekCodec) {
01732          if (QString(fSymbolFontFamily).contains("Symbol")) {
01733             fGreekCodec = (fFontTextCode == "ISO8859-1") ? fCodec:
01734                           QTextCodec::codecForName("ISO8859-1"); //iso8859-1
01735          } else {
01736             fGreekCodec  = QTextCodec::codecForName("symbol"); // ISO8859-7
01737          }
01738       }
01739       if (fGreekCodec) codec=fGreekCodec;
01740    }
01741    return codec;
01742 }
01743 
01744 //______________________________________________________________________________
01745 Float_t      TGQt::GetTextMagnitude(){return fTextMagnitude;}
01746 
01747 //______________________________________________________________________________
01748 void         TGQt::SetTextMagnitude(Float_t mgn){ fTextMagnitude = mgn;}
01749 
01750 //______________________________________________________________________________
01751 void  TGQt::GetTextExtent(unsigned int &w, unsigned int &h, char *mess)
01752 {
01753    // Return the size of a character string.
01754    // iw          : text width
01755    // ih          : text height
01756    // mess        : message
01757 
01758    TQtLock lock;
01759    if (fQFont) {
01760       bool textProxy = false;
01761       if (fgTextProxy) {
01762          TQtTextCloneProxy proxy;
01763          proxy->clear();
01764          QFontInfo fi(*fQFont);
01765          proxy->setBaseFontPointSize(fi.pointSize());
01766          if ( (textProxy = proxy->setContent(mess)) ) {
01767             w = proxy->width();
01768             h = proxy->height();
01769          }
01770       }
01771       if (!textProxy) {
01772          QSize textSize = QFontMetrics(*fQFont).size(Qt::TextSingleLine,GetTextDecoder()->toUnicode(mess)) ;
01773          w = textSize.width();
01774          h = (unsigned int)(textSize.height());
01775       }
01776       // qDebug() << "  TGQt::GetTextExtent  w=" <<w <<" h=" << h << "font = " 
01777       //         << fTextFont << " size =" << fTextSize 
01778       //         << mess;
01779    }
01780 }
01781 //______________________________________________________________________________
01782 Int_t TGQt::GetFontAscent() const
01783 {
01784    // Returns ascent of the current font (in pixels).
01785    // The ascent of a font is the distance from the baseline 
01786    // to the highest position characters extend to
01787    Int_t ascent = 0;
01788    if (fQFont) {
01789       QFontMetrics fm(*fQFont);
01790       ascent = fm.ascent(); //+fm.descent();
01791    }
01792    return ascent;
01793 }
01794 
01795 //______________________________________________________________________________
01796 Int_t TGQt::GetFontDescent() const 
01797 { 
01798    // Returns the descent of the current font (in pixels.
01799    // The descent is the distance from the base line 
01800    // to the lowest point characters extend to.
01801    Int_t descent = 0;
01802    if (fQFont) {
01803       QFontMetrics fm(*fQFont);
01804       descent = fm.descent();
01805    }
01806    return descent;
01807 }
01808 
01809 //______________________________________________________________________________
01810 Bool_t  TGQt::HasTTFonts() const {return fUseTTF;}
01811 
01812 //______________________________________________________________________________
01813 void  TGQt::MoveWindow(Int_t wd, Int_t x, Int_t y)
01814 {
01815    // Move the window wd.
01816    // wd  : Window identifier.
01817    // x    : x new window position
01818    // y    : y new window position
01819 
01820    if (wd != -1 && wd != 0 && wd != kDefault)
01821    {
01822       QPaintDevice *widget = iwid(wd);
01823       assert(widget->devType() == QInternal::Widget );
01824       ((TQtWidget *)widget)->move(x,y);
01825    }
01826 }
01827 
01828 //______________________________________________________________________________
01829 void  TGQt::PutByte(Byte_t )
01830 { // deprecated
01831 }
01832 
01833 //______________________________________________________________________________
01834 void  TGQt::QueryPointer(int &ix, int &iy)
01835 {
01836    // Query pointer position.
01837    // ix       : X coordinate of pointer
01838    // iy       : Y coordinate of pointer
01839    QPoint pos = QCursor::pos();
01840    ix = pos.x(); iy = pos.y();
01841 }
01842 
01843 //______________________________________________________________________________
01844 Pixmap_t TGQt::ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t id)
01845 {
01846    // If id is NULL - loads the specified gif file at position [x0,y0] in the
01847    // current window. Otherwise creates pixmap from gif file
01848 
01849    Int_t thisId = 0;
01850    QPixmap *pix = new QPixmap( QString (file) );
01851    if ( pix->isNull () ) { delete pix; pix = 0;         }
01852    else {
01853       thisId=fWidgetArray->GetFreeId(pix);
01854       if (!id ) { CopyPixmap(thisId,x0,y0); fWidgetArray->DeleteById(thisId); thisId = 0;}
01855    }
01856    return thisId;
01857 }
01858 
01859 //______________________________________________________________________________
01860 Int_t  TGQt::RequestLocator(Int_t /*mode*/, Int_t /*ctyp*/, Int_t &/*x*/, Int_t &/*y*/)
01861 {
01862    // deprecated
01863    return 0;
01864 }
01865 //______________________________________________________________________________
01866   class requestString : public QDialog {
01867   public:
01868     QString   fText;
01869     QLineEdit fEdit;
01870     requestString(const char *text="") : QDialog(0
01871           , Qt::FramelessWindowHint 
01872           | Qt::WindowStaysOnTopHint
01873           | Qt::Popup)
01874           , fText(text),fEdit(this)
01875     {
01876        setModal(true);
01877        connect(&fEdit,SIGNAL( returnPressed () ), this, SLOT( accept() ));
01878     }
01879     ~requestString(){;}
01880   };
01881 //______________________________________________________________________________
01882 Int_t  TGQt::RequestString(int x, int y, char *text)
01883 {
01884 //*-*-*-*-*-*-*-*-*-*-*-*Request string*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
01885 //*-*                    ==============
01886 //*-*  x,y         : position where text is displayed
01887 //*-*  text        : text displayed (input), edited text (output)
01888 //*-*
01889 //*-*  Request string:
01890 //*-*  text is displayed and can be edited with Emacs-like keybinding
01891 //*-*  return termination code (0 for ESC, 1 for RETURN)
01892 //*-*
01893 //*-*  Return value:
01894 //*-*
01895 //*-*    0     -  input was canceled
01896 //*-*    1     -  input was Ok
01897 //*-*
01898 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
01899   int  res = QDialog::Rejected;
01900   if (fSelectedWindow->devType() == QInternal::Widget ) {
01901      TQtWidget *w = (TQtWidget *)fSelectedWindow;
01902      static requestString reqDialog;
01903      reqDialog.fEdit.setText(QString(text).trimmed());
01904      int yFrame = reqDialog.frameGeometry().height() - reqDialog.geometry().height() + reqDialog.fontMetrics().height();
01905      reqDialog.move(w->mapToGlobal(QPoint(x,y-yFrame)));
01906      if (QClientFilter() && QClientFilter()->PointerGrabber() ) {
01907         // suspend the mouse grabbing for a while
01908 //        QClientFilter()->SetPointerGrabber(0);
01909         QClientFilter()->PointerGrabber()->DisactivateGrabbing();
01910      }
01911      res = reqDialog.exec();
01912      if (res == QDialog::Accepted ) {
01913         // save the currect test font to select the proper codec
01914         Font_t textFontSave =  fTextFont;
01915         fTextFont = 62;
01916         QByteArray obr = GetTextDecoder()->fromUnicode(reqDialog.fEdit.text());
01917         const char *r = obr.constData();
01918         qstrcpy(text, (const char *)r);
01919         // restore the font
01920         fTextFont = textFontSave;
01921      }
01922      reqDialog.hide();
01923      if (QClientFilter() && QClientFilter()->PointerGrabber()) {
01924         // Restore the grabbing
01925 //        QClientFilter()->SetPointerGrabber(fPointerGrabber);
01926         QClientFilter()->PointerGrabber()->ActivateGrabbing();
01927      }
01928   }
01929   return res == QDialog::Accepted ? 1 : 0;
01930 }
01931 
01932 //______________________________________________________________________________
01933 void  TGQt::RescaleWindow(int wd, UInt_t w, UInt_t h)
01934 {
01935    // Rescale the window wd.
01936    // wd  : Window identifier
01937    // w    : Width
01938    // h    : Heigth
01939 
01940    TQtLock lock;
01941    if (wd && wd != -1 && wd != kDefault )
01942    {
01943       QPaintDevice *widget = iwid(wd);
01944       if (widget->devType() == QInternal::Widget )
01945       {
01946          if (QSize(w,h) != ((TQtWidget *)widget)->size()) {
01947             // fprintf(stderr," TGQt::RescaleWindow(int wd, UInt_t w=%d, UInt_t h=%d)\n",w,h);
01948             ((TQtWidget *)widget)->resize(w,h);
01949          }
01950       }
01951    }
01952 }
01953 
01954 //______________________________________________________________________________
01955 Int_t  TGQt::ResizePixmap(int wd, UInt_t w, UInt_t h)
01956 {
01957    // Resize a pixmap.
01958    // wd : pixmap to be resized
01959    // w,h : Width and height of the pixmap
01960 
01961    TQtLock lock;
01962    if (wd && wd != -1 && wd != kDefault )
01963    {
01964       QPaintDevice *pixmap = iwid(wd);
01965       if (pixmap->devType() == QInternal::Pixmap )
01966       {
01967          if (QSize(w,h) != ((QPixmap *)pixmap)->size()) {
01968              QPixmap *newpix =  new QPixmap(w,h);
01969              newpix->fill();
01970              fWidgetArray->ReplaceById(wd,newpix);
01971              if (fSelectedWindow == pixmap) fSelectedWindow = newpix;
01972             // fprintf(stderr," \n --- > Pixmap has been resized ,< --- \t  %p\n",pixmap);
01973          }
01974       }
01975    }
01976    return 1;
01977 }
01978 
01979 //______________________________________________________________________________
01980 void  TGQt::ResizeWindow(int /* wd */)
01981 {
01982    // Resize the current window if necessary.
01983    // No implementation is required under Qt.
01984 
01985    return;
01986 }
01987 
01988 //______________________________________________________________________________
01989 void   TGQt::SelectPixmap(Int_t qpixid){ SelectWindow(qpixid);}
01990 
01991 //______________________________________________________________________________
01992 void  TGQt::SelectWindow(int wd)
01993 {
01994    // Select window to which subsequent output is directed.
01995    // fprintf(stderr," TGQt::SelectWindow %d \n", wd);
01996    // Don't select things twice
01997    QPaintDevice *dev = 0;
01998    if (wd == -1 || wd == (int) kNone) {
01999        fSelectedWindow = NoOperation;
02000       //return;
02001    } else {
02002       dev = iwid(wd);
02003       fSelectedWindow = dev ? dev : NoOperation;
02004    }
02005    if (fPrevWindow != fSelectedWindow) 
02006       fPrevWindow     = fSelectedWindow;
02007 }
02008 
02009 //______________________________________________________________________________
02010 void  TGQt::SetCharacterUp(Float_t chupx, Float_t chupy)
02011 {
02012    // Set character up vector.
02013 
02014    TQtLock lock;
02015    if (chupx == fCharacterUpX  && chupy == fCharacterUpY) {
02016 
02017       return;
02018    }
02019 
02020    if      (chupx == 0  && chupy == 0)  fTextAngle = 0;
02021    else if (chupx == 0  && chupy == 1)  fTextAngle = 0;
02022    else if (chupx == -1 && chupy == 0)  fTextAngle = 90;
02023    else if (chupx == 0  && chupy == -1) fTextAngle = 180;
02024    else if (chupx == 1  && chupy ==  0) fTextAngle = 270;
02025    else {
02026       fTextAngle = ((TMath::ACos(chupx/TMath::Sqrt(chupx*chupx +chupy*chupy))*180.)/3.14159)-90;
02027       if (chupy < 0) fTextAngle = 180 - fTextAngle;
02028       if (TMath::Abs(fTextAngle) < 0.01) fTextAngle = 0;
02029    }
02030 
02031    fCharacterUpX = chupx;
02032    fCharacterUpY = chupy;
02033 }
02034 
02035 //______________________________________________________________________________
02036 void  TGQt::SetClipOFF(Int_t /*wd*/)
02037 {
02038    // Turn off the clipping for the window wd.
02039    // deprecated
02040    // fQPainter->setClipping(FALSE);
02041 }
02042 
02043 //______________________________________________________________________________
02044 void  TGQt::SetClipRegion(int wd, int x, int y, UInt_t w, UInt_t h)
02045 {
02046    // Set clipping region for the window wd.
02047    // wd        : Window indentifier
02048    // x,y        : origin of clipping rectangle
02049    // w,h        : size of clipping rectangle;
02050 
02051    QRect rect(x,y,w,h);
02052    TQtLock lock;
02053    fClipMap.remove(iwid(wd));
02054    fClipMap.insert(iwid(wd),rect);
02055 }
02056 
02057 //____________________________________________________________________________
02058 void  TGQt::SetCursor(Int_t wd, ECursor cursor)
02059 {
02060    // Set the cursor.
02061    fCursor = cursor;
02062    if (wd && wd != -1 && wd != kDefault)
02063    {
02064       QPaintDevice *widget = iwid(wd);
02065       if ( TQtWidget *w = (TQtWidget *)IsWidget(widget) )
02066          w->setCursor(*fCursors[fCursor]);
02067    }
02068 }
02069 
02070 //______________________________________________________________________________
02071 void  TGQt::SetDoubleBuffer(int wd, int mode)
02072 {
02073    // Set the double buffer on/off on window wd.
02074    // wd  : Window identifier.
02075    //        999 means all the opened windows.
02076    // mode : 1 double buffer is on
02077    //        0 double buffer is off
02078    if (wd == -1 || wd == kDefault) return;
02079    QPaintDevice *dev = iwid(wd);
02080    TQtWidget *widget = 0;
02081    if (dev && (widget = (TQtWidget *)IsWidget(dev) ))  {
02082       widget->SetDoubleBuffer(mode);
02083       // fprintf(stderr," TGQt::SetDoubleBuffer \n");
02084    }
02085 }
02086 
02087 //______________________________________________________________________________
02088 void  TGQt::SetDrawMode(TVirtualX::EDrawMode mode)
02089 {
02090    // Set the drawing mode.
02091    // mode : drawing mode
02092 
02093    // Map EDrawMode    { kCopy = 1, kXor, kInvert };
02094    Bool_t feedBack =  (mode==kInvert);
02095    if (feedBack != fFeedBackMode) {
02096       fFeedBackMode = feedBack;
02097       if (fFeedBackMode) {
02098          // create
02099          if (!fFeedBackWidget) {
02100             fFeedBackWidget = new TQtFeedBackWidget;
02101             fFeedBackWidget->setFrameStyle(QFrame::Box);
02102          }
02103          // This makes no sense on X11 yet due the  
02104          // TQtWidget::setAttribute(Qt::WA_PaintOnScreen) flag
02105          // TQtWidget keeps painting itself over the feedback windows. Wierd !!!
02106          // reparent if needed
02107          fFeedBackWidget->SetParent(0);
02108          fFeedBackWidget->SetParent((TQtWidget *)fSelectedWindow);
02109       } else if (fFeedBackWidget) {
02110          fFeedBackWidget->Hide();
02111       }
02112    }
02113 #if 0
02114    QPainter::CompositionMode newMode = QPainter::CompositionMode_Source;
02115    switch (mode) {
02116     case kCopy:   newMode = QPainter::CompositionMode_Source; break;
02117     case kXor:    newMode = QPainter::CompositionMode_Xor;  break;
02118     case kInvert: newMode = QPainter::CompositionMode_Destination;  break;
02119     default:      newMode = QPainter::CompositionMode_Source; break;
02120    };
02121    if (newMode != fDrawMode)
02122    {
02123       fDrawMode = newMode;
02124 //      if (fQPainter->isActive() && (fQPainter->device()->devType() !=  QInternal::Widget ))
02125       if (fQPainter->isActive() && (fQPainter->device()->devType() ==  QInternal::Image ))
02126       {
02127          fQPainter->setCompositionMode(fDrawMode);
02128      }
02129      // sfprintf(stderr,"TGQt::SetDrawMode \n");
02130    }
02131 #endif
02132 }
02133 
02134 //______________________________________________________________________________
02135 void  TGQt::SetFillColor(Color_t cindex)
02136 {
02137    // Set color index for fill areas.
02138 
02139    if (fFillColor != cindex )
02140       fQBrush->SetColor(fFillColor = UpdateColor(cindex));
02141 }
02142 
02143 //______________________________________________________________________________
02144 void  TGQt::SetFillStyle(Style_t fstyle)
02145 {
02146    // Set fill area style.
02147    // fstyle   : compound fill area interior style
02148    //    fstyle = 1000*interiorstyle + styleindex
02149 
02150   //  The current fill area color is used to paint some pixels in a small
02151   //  rectangle the other pixels are not paint.
02152   //    Olivier Couet
02153   //            Thursday, July 14, 2005
02154 
02155    if (fFillStyle != fstyle)
02156       fQBrush->SetStyle(fFillStyle = fstyle);
02157 }
02158 
02159 //______________________________________________________________________________
02160 void TGQt::SetFillStyleIndex( Int_t style, Int_t fasi )
02161 {
02162    // Set fill area style index.
02163 
02164    SetFillStyle(1000*style + fasi);
02165 }
02166 
02167 //______________________________________________________________________________
02168 void  TGQt::SetLineColor(Color_t cindex)
02169 {
02170 //*-*-*-*-*-*-*-*-*-*-*Set color index for lines*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02171 //*-*                  =========================
02172 //*-*  cindex    : color index
02173 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02174 
02175   if (fLineColor != cindex) {
02176     fLineColor = UpdateColor(cindex);
02177     if (fLineColor >= 0) fQPen->SetLineColor(fLineColor);
02178   }
02179 }
02180 
02181 //______________________________________________________________________________
02182 void  TGQt::SetLineType(int n, int*dash)
02183 {
02184 //*-*-*-*-*-*-*-*-*-*-*Set line style-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02185 //*-*                  ==============
02186 //*-*    Set line style:
02187 //*-*    if n < 0 use pre-defined Windows style:
02188 //*-*         0 - solid lines
02189 //*-*        -1 - solid lines
02190 //*-*        -2 - dash line
02191 //*-*        -3 - dot  line
02192 //*-*        -4 - dash-dot line
02193 //*-*        -5 - dash-dot-dot line
02194 //*-*     < -6 - solid line
02195 //*-*
02196 //*-*    if n > 0 use dashed lines described by DASH(N)
02197 //*-*    e.g. n=4,DASH=(6,3,1,3) gives a dashed-dotted line with dash length 6
02198 //*-*    and a gap of 7 between dashes
02199 //*-*
02200    fQPen->SetLineType(n,dash);
02201 }
02202 
02203 //______________________________________________________________________________
02204 void  TGQt::SetLineStyle(Style_t linestyle)
02205 {
02206 //*-*-*-*-*-*-*-*-*-*-*Set line style-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02207 //*-*                  ==============
02208 //*-*    Use pre-defined Windows style:
02209 //*-*    linestyle =
02210 //*-*         0 - solid lines
02211 //*-*        -1 - solid lines
02212 //*-*        -2 - dash line
02213 //*-*        -3 - dot  line
02214 //*-*        -4 - dash-dot line
02215 //*-*        -5 - dash-dot-dot line
02216 //*-*      < -6 - solid line
02217 //*-*
02218 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02219    // Copy/Paste from TGX11::SetLineStyle (it is called "subclassing")
02220    // Set line style.
02221 
02222    if (fLineStyle != linestyle) { //set style index only if different
02223       fLineStyle = linestyle;
02224       fQPen->SetLineStyle(linestyle);
02225    }
02226 }
02227 
02228 //______________________________________________________________________________
02229 void  TGQt::SetLineWidth(Width_t width)
02230 {
02231    //*-*-*-*-*-*-*-*-*-*-*Set line width*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02232    //*-*                  ==============
02233    //*-*  width   : line width in pixels
02234    //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02235    if (width==1) width =0;
02236    if (fLineWidth != width) {
02237       fLineWidth = width;
02238       if (fLineWidth >= 0 ) fQPen->SetLineWidth(fLineWidth);
02239    }
02240 }
02241 
02242 //______________________________________________________________________________
02243 void  TGQt::SetMarkerColor( Color_t cindex)
02244 {
02245    //*-*-*-*-*-*-*-*-*-*-*Set color index for markers*-*-*-*-*-*-*-*-*-*-*-*-*-*
02246    //*-*                  ===========================
02247    //*-*  cindex : color index defined my IXSETCOL
02248    //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02249 
02250         if (fQtMarker->GetColor() != cindex)            
02251                 fQtMarker->SetColor(fMarkerColor = UpdateColor(cindex));
02252 }
02253 
02254 //______________________________________________________________________________
02255 void  TGQt::SetMarkerSize(Float_t markersize)
02256 {
02257    //*-*-*-*-*-*-*-*-*-*-*Set marker size index for markers*-*-*-*-*-*-*-*-*-*-*-*-*-*
02258    //*-*                  =================================
02259    //*-*  msize  : marker scale factor
02260    //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02261 
02262    if (markersize != fMarkerSize) {
02263 
02264       fMarkerSize = markersize;
02265       if (markersize >= 0) {
02266          SetMarkerStyle(-fMarkerStyle);
02267       }
02268    }
02269 }
02270 
02271 //______________________________________________________________________________
02272 void  TGQt::SetMarkerStyle(Style_t markerstyle){
02273    //*-*-*-*-*-*-*-*-*-*-*Set marker style*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02274    //*-*                  ================
02275 
02276    if (fMarkerStyle == markerstyle) return;
02277    TPoint shape[15];
02278    markerstyle  = TMath::Abs(markerstyle);
02279    if (markerstyle%1000 >= 31) return;
02280    fMarkerStyle = markerstyle%1000;
02281    Style_t penWidth = markerstyle-fMarkerStyle;
02282    Int_t im = Int_t(4*fMarkerSize + 0.5);
02283    switch (fMarkerStyle) {
02284 
02285 case 2:
02286    //*-*--- + shaped marker
02287    shape[0].SetX(-im); shape[0].SetY( 0);
02288    shape[1].SetX(im);  shape[1].SetY( 0);
02289    shape[2].SetX(0) ;  shape[2].SetY( -im);
02290    shape[3].SetX(0) ;  shape[3].SetY( im);
02291    SetMarkerType(4+penWidth,4,shape);
02292    break;
02293 
02294 case 3:
02295    //*-*--- * shaped marker
02296    shape[0].SetX(-im);  shape[0].SetY(  0);
02297    shape[1].SetX( im);  shape[1].SetY(  0);
02298    shape[2].SetX(  0);  shape[2].SetY(-im);
02299    shape[3].SetX(  0);  shape[3].SetY( im);
02300    im = Int_t(0.707*Float_t(im) + 0.5);
02301    shape[4].SetX(-im);  shape[4].SetY(-im);
02302    shape[5].SetX( im);  shape[5].SetY( im);
02303    shape[6].SetX(-im);  shape[6].SetY( im);
02304    shape[7].SetX( im);  shape[7].SetY(-im);
02305    SetMarkerType(4+penWidth,8,shape);
02306    break;
02307 
02308 case 4:
02309 case 24:
02310    //*-*--- O shaped marker
02311    SetMarkerType(0+penWidth,im*2,shape);
02312    break;
02313 
02314 case 5:
02315    //*-*--- X shaped marker
02316    im = Int_t(0.707*Float_t(im) + 0.5);
02317    shape[0].SetX(-im);  shape[0].SetY(-im);
02318    shape[1].SetX( im);  shape[1].SetY( im);
02319    shape[2].SetX(-im);  shape[2].SetY( im);
02320    shape[3].SetX( im);  shape[3].SetY(-im);
02321    SetMarkerType(4+penWidth,4,shape);
02322    break;
02323 
02324 case  6:
02325    //*-*--- + shaped marker (with 1 pixel)
02326    shape[0].SetX(-1);  shape[0].SetY( 0);
02327    shape[1].SetX( 1);  shape[1].SetY( 0);
02328    shape[2].SetX( 0);  shape[2].SetY(-1);
02329    shape[3].SetX( 0);  shape[3].SetY( 1);
02330    SetMarkerType(4+penWidth,4,shape);
02331    break;
02332 
02333 case 7:
02334    //*-*--- . shaped marker (with 9 pixel)
02335    shape[0].SetX(-1);  shape[0].SetY( 1);
02336    shape[1].SetX( 1);  shape[1].SetY( 1);
02337    shape[2].SetX(-1);  shape[2].SetY( 0);
02338    shape[3].SetX( 1);  shape[3].SetY( 0);
02339    shape[4].SetX(-1);  shape[4].SetY(-1);
02340    shape[5].SetX( 1);  shape[5].SetY(-1);
02341    SetMarkerType(4+penWidth,6,shape);
02342    break;
02343 case  8:
02344 case 20:
02345    //*-*--- O shaped marker (filled)
02346    SetMarkerType(1,im*2,shape);
02347    break;
02348 case 21:      //*-*- here start the old HIGZ symbols
02349    //*-*--- HIGZ full square
02350    shape[0].SetX(-im);  shape[0].SetY(-im);
02351    shape[1].SetX( im);  shape[1].SetY(-im);
02352    shape[2].SetX( im);  shape[2].SetY( im);
02353    shape[3].SetX(-im);  shape[3].SetY( im);
02354    //     shape[4].SetX(-im);  shape[4].SetY(-im);
02355    SetMarkerType(3,4,shape);
02356    break;
02357 case 22:
02358    //*-*--- HIGZ full triangle up
02359    shape[0].SetX(-im);  shape[0].SetY( im);
02360    shape[1].SetX( im);  shape[1].SetY( im);
02361    shape[2].SetX(  0);  shape[2].SetY(-im);
02362    //     shape[3].SetX(-im);  shape[3].SetY( im);
02363    SetMarkerType(3,3,shape);
02364    break;
02365 case 23:
02366    //*-*--- HIGZ full triangle down
02367    shape[0].SetX(  0);  shape[0].SetY( im);
02368    shape[1].SetX( im);  shape[1].SetY(-im);
02369    shape[2].SetX(-im);  shape[2].SetY(-im);
02370    //     shape[3].SetX(  0);  shape[3].SetY( im);
02371    SetMarkerType(3,3,shape);
02372    break;
02373 case 25:
02374    //*-*--- HIGZ open square
02375    shape[0].SetX(-im);  shape[0].SetY(-im);
02376    shape[1].SetX( im);  shape[1].SetY(-im);
02377    shape[2].SetX( im);  shape[2].SetY( im);
02378    shape[3].SetX(-im);  shape[3].SetY( im);
02379    //     shape[4].SetX(-im);  shape[4].SetY(-im);
02380    SetMarkerType(2+penWidth,4,shape);
02381    break;
02382 case 26:
02383    //*-*--- HIGZ open triangle up
02384    shape[0].SetX(-im);  shape[0].SetY( im);
02385    shape[1].SetX( im);  shape[1].SetY( im);
02386    shape[2].SetX(  0);  shape[2].SetY(-im);
02387    //     shape[3].SetX(-im);  shape[3].SetY( im);
02388    SetMarkerType(2+penWidth,3,shape);
02389    break;
02390 case 27: {
02391    //*-*--- HIGZ open losange
02392    Int_t imx = Int_t(2.66*fMarkerSize + 0.5);
02393    shape[0].SetX(-imx); shape[0].SetY( 0);
02394    shape[1].SetX(  0);  shape[1].SetY(-im);
02395    shape[2].SetX(imx);  shape[2].SetY( 0);
02396    shape[3].SetX(  0);  shape[3].SetY( im);
02397    //     shape[4].SetX(-imx); shape[4].SetY( 0);
02398    SetMarkerType(2+penWidth,4,shape);
02399    break;
02400          }
02401 case 28: {
02402    //*-*--- HIGZ open cross
02403    Int_t imx = Int_t(1.33*fMarkerSize + 0.5);
02404    shape[0].SetX(-im);  shape[0].SetY(-imx);
02405    shape[1].SetX(-imx); shape[1].SetY(-imx);
02406    shape[2].SetX(-imx); shape[2].SetY( -im);
02407    shape[3].SetX(imx);  shape[3].SetY( -im);
02408    shape[4].SetX(imx);  shape[4].SetY(-imx);
02409    shape[5].SetX( im);  shape[5].SetY(-imx);
02410    shape[6].SetX( im);  shape[6].SetY( imx);
02411    shape[7].SetX(imx);  shape[7].SetY( imx);
02412    shape[8].SetX(imx);  shape[8].SetY( im);
02413    shape[9].SetX(-imx); shape[9].SetY( im);
02414    shape[10].SetX(-imx);shape[10].SetY(imx);
02415    shape[11].SetX(-im); shape[11].SetY(imx);
02416    //     shape[12].SetX(-im); shape[12].SetY(-imx);
02417    SetMarkerType(2+penWidth,12,shape);
02418    break;
02419          }
02420 case 29: {
02421    //*-*--- HIGZ full star pentagone
02422    Int_t im1 = Int_t(0.66*fMarkerSize + 0.5);
02423    Int_t im2 = Int_t(2.00*fMarkerSize + 0.5);
02424    Int_t im3 = Int_t(2.66*fMarkerSize + 0.5);
02425    Int_t im4 = Int_t(1.33*fMarkerSize + 0.5);
02426    shape[0].SetX(-im);  shape[0].SetY( im4);
02427    shape[1].SetX(-im2); shape[1].SetY(-im1);
02428    shape[2].SetX(-im3); shape[2].SetY( -im);
02429    shape[3].SetX(  0);  shape[3].SetY(-im2);
02430    shape[4].SetX(im3);  shape[4].SetY( -im);
02431    shape[5].SetX(im2);  shape[5].SetY(-im1);
02432    shape[6].SetX( im);  shape[6].SetY( im4);
02433    shape[7].SetX(im4);  shape[7].SetY( im4);
02434    shape[8].SetX(  0);  shape[8].SetY( im);
02435    shape[9].SetX(-im4); shape[9].SetY( im4);
02436    //     shape[10].SetX(-im); shape[10].SetY( im4);
02437    SetMarkerType(3+penWidth,10,shape);
02438    break;
02439          }
02440 
02441 case 30: {
02442    //*-*--- HIGZ open star pentagone
02443    Int_t im1 = Int_t(0.66*fMarkerSize + 0.5);
02444    Int_t im2 = Int_t(2.00*fMarkerSize + 0.5);
02445    Int_t im3 = Int_t(2.66*fMarkerSize + 0.5);
02446    Int_t im4 = Int_t(1.33*fMarkerSize + 0.5);
02447    shape[0].SetX(-im);  shape[0].SetY( im4);
02448    shape[1].SetX(-im2); shape[1].SetY(-im1);
02449    shape[2].SetX(-im3); shape[2].SetY( -im);
02450    shape[3].SetX(  0);  shape[3].SetY(-im2);
02451    shape[4].SetX(im3);  shape[4].SetY( -im);
02452    shape[5].SetX(im2);  shape[5].SetY(-im1);
02453    shape[6].SetX( im);  shape[6].SetY( im4);
02454    shape[7].SetX(im4);  shape[7].SetY( im4);
02455    shape[8].SetX(  0);  shape[8].SetY( im);
02456    shape[9].SetX(-im4); shape[9].SetY( im4);
02457    SetMarkerType(2+penWidth,10,shape);
02458    break;
02459          }
02460 
02461 case 31:
02462    //*-*--- HIGZ +&&x (kind of star)
02463    SetMarkerType(1,im*2,shape);
02464    break;
02465 default:
02466    //*-*--- single dot
02467    SetMarkerType(0+penWidth,0,shape);
02468    }
02469 }
02470 
02471 //______________________________________________________________________________
02472 void  TGQt::SetMarkerType( int type, int n, TPoint *xy )
02473 {
02474 //*-*-*-*-*-*-*-*-*-*-*Set marker type*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02475 //*-*                  ===============
02476 //*-*  type      : marker type
02477 //*-*  n         : length of marker description
02478 //*-*  xy        : list of points describing marker shape
02479 //*-*
02480 //*-*     if N.EQ.0 marker is a single point
02481 //*-*     if TYPE.EQ.0 marker is hollow circle of diameter N
02482 //*-*     if TYPE.EQ.1 marker is filled circle of diameter N
02483 //*-*     if TYPE.EQ.2 marker is a hollow polygon describe by line XY
02484 //*-*     if TYPE.EQ.3 marker is a filled polygon describe by line XY
02485 //*-*     if TYPE.EQ.4 marker is described by segmented line XY
02486 //*-*     e.g. TYPE=4,N=4,XY=(-3,0,3,0,0,-3,0,3) sets a plus shape of 7x7 pixels
02487 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02488      fQtMarker->SetMarker(n,xy,type);
02489 }
02490 
02491 //______________________________________________________________________________
02492 int  TGQt::UpdateColor(int cindex)
02493 {
02494    // [protected] update the color parameters if needed.
02495 #define BIGGEST_RGB_VALUE 255  // 65535
02496    //  if (fSelectedWindow == NoOperation) return;
02497    if (cindex >= 0 ) {
02498       //    if (cindex >= fPallete.size()) fPallete.resize(cindex+1);
02499       //    fPallete[cindex].setRgb((r*BIGGEST_RGB_VALUE)
02500       if (!fPallete.contains(cindex)) {
02501          // qDebug() << "TGQt::UpdateRGB: Add the new index:" << cindex;
02502          fBlockRGB = kTRUE; // to eliminate a recursive setting via TGQt::SetRGB()
02503          TColor *rootColor = gROOT->GetColor(cindex);
02504          fBlockRGB = kFALSE;
02505          if (rootColor) {
02506              float r,g,b,a;
02507              rootColor->GetRGB(r,g,b);
02508              a= rootColor->GetAlpha();
02509 
02510              fPallete[cindex] =  new QColor(
02511                 int(r*BIGGEST_RGB_VALUE+0.5)
02512                ,int(g*BIGGEST_RGB_VALUE+0.5)
02513                ,int(b*BIGGEST_RGB_VALUE+0.5)
02514                ,int(a*BIGGEST_RGB_VALUE+0.5)
02515             );
02516          }
02517       }
02518    }
02519    return cindex;
02520 }
02521 //______________________________________________________________________________
02522 void  TGQt::SetRGB(int cindex, float r, float g, float b)
02523 {
02524 #define BIGGEST_RGB_VALUE 255  // 65535
02525    //  if (fSelectedWindow == NoOperation) return;
02526    if ( !fBlockRGB && cindex >= 0 ) {
02527       //    if (cindex >= fPallete.size()) fPallete.resize(cindex+1);
02528       //    fPallete[cindex].setRgb((r*BIGGEST_RGB_VALUE)
02529        // qDebug() << "TGQt::SetRGB: Add the new index: " << cindex;
02530        QMap<Color_t,QColor*>::iterator i = fPallete.find(cindex);
02531        if (i != fPallete.end()) {
02532           delete i.value();
02533           fPallete.erase(i);
02534        }
02535        fPallete[cindex] =  new QColor(
02536           int(r*BIGGEST_RGB_VALUE+0.5)
02537          ,int(g*BIGGEST_RGB_VALUE+0.5)
02538          ,int(b*BIGGEST_RGB_VALUE+0.5)
02539          );
02540    }
02541 }
02542 //______________________________________________________________________________
02543 void  TGQt::SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b, Float_t a)
02544 {
02545    // Set the color with the alpha component (supported wuth Qt 4 only)
02546    SetRGB(cindex, r, g,b);
02547    SetAlpha(cindex,a);
02548 }
02549 //______________________________________________________________________________
02550 void  TGQt::SetAlpha(Int_t cindex, Float_t a)
02551 {
02552    // Add  the alpha component (supported with Qt 4 only)
02553    if (cindex < 0 || a < 0 ) return;
02554    QColor *color = fPallete[cindex];
02555    if (color) color->setAlphaF(a);
02556 
02557 }
02558 //______________________________________________________________________________
02559 void  TGQt::GetRGBA(Int_t cindex, Float_t &r, Float_t &g, Float_t &b, Float_t &a)
02560 {
02561    // Return RGBA components for the color cindex
02562    GetRGB(cindex,r,g,b);
02563    a = GetAlpha(cindex);
02564 }
02565 //______________________________________________________________________________
02566 Float_t TGQt::GetAlpha(Int_t cindex)
02567 {
02568    // Return Alpha component for the color cindex
02569    if (cindex < 0 ) return 1.0;
02570    const QColor *color = fPallete[cindex];
02571    return (Float_t)color->alphaF();
02572 }
02573 //______________________________________________________________________________
02574 void  TGQt::SetTextAlign(Short_t talign)
02575 {
02576    //*-*-*-*-*-*-*-*-*-*-*Set text alignment*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02577    //*-*                  ==================
02578    //*-*  txalh   : horizontal text alignment
02579    //*-*  txalv   : vertical text alignment
02580    //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02581 
02582    Int_t txalh = talign/10;
02583    Int_t txalv = talign%10;
02584 
02585    fTextAlignH = txalh;
02586    fTextAlignV = txalv;
02587 
02588    fTextAlign = Qt::AlignLeft;
02589    switch( txalh ) {
02590 
02591   case 2:
02592      fTextAlign |= Qt::AlignHCenter;
02593      break;
02594 
02595   case 3:
02596      fTextAlign |= Qt::AlignRight;
02597      break;
02598 
02599   default:
02600      fTextAlign |= Qt::AlignLeft;
02601    }
02602 
02603    switch( txalv ) {
02604 
02605   case 1:
02606      fTextAlign |= Qt::AlignBottom;
02607      break;
02608 
02609   case 2:
02610      fTextAlign |= Qt::AlignVCenter;
02611      break;
02612 
02613   case 3:
02614      fTextAlign |= Qt::AlignTop;
02615      break;
02616 
02617   default:
02618      fTextAlign = Qt::AlignBottom;
02619    }
02620 }
02621 
02622 //______________________________________________________________________________
02623 void  TGQt::SetTextColor(Color_t cindex)
02624 {
02625    //*-*-*-*-*-*-*-*-*-*-*Set color index for text*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02626    //*-*                  ========================
02627    //*-*  cindex    : color index defined my IXSETCOL
02628    //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02629 
02630    if (fTextColor == cindex) return;
02631    fTextColor = UpdateColor(cindex);
02632    if (cindex < 0) return;
02633 }
02634 
02635 //______________________________________________________________________________
02636 Int_t  TGQt::SetTextFont(char* /*fontname*/, TVirtualX::ETextSetMode /*mode*/)
02637 {
02638    // Set text font to specified name.
02639    // mode       : loading flag
02640    // mode=kCheck = 0     : search if the font exist (kCheck)
02641    // mode= kLoad = 1     : search the font and load it if it exists (kLoad)
02642    // font       : font name
02643    //
02644    // Set text font to specified name. This function returns 0 if
02645    // the specified font is found, 1 if not.
02646 
02647    // Qt takes care to make sure the proper font is loaded and scaled.
02648    return 0;
02649 }
02650 
02651 //______________________________________________________________________________
02652 void  TGQt::SetTextFont(Font_t fontnumber)
02653 {
02654    //*-*-*-*-*-*-*-*-*-*-*-*-*Set current text font number*-*-*-*-*-*-*-*-*-*-*-*
02655    //*-*                      ===========================
02656    //*-*  List of the currently supported fonts (screen and PostScript)
02657    //*-*  =============================================================
02658    //*-*   Font ID       X11                       Win32 TTF       lfItalic  lfWeight x 10
02659    //*-*        1 : times-medium-i-normal      "Times New Roman"      1           5
02660    //*-*        2 : times-bold-r-normal        "Times New Roman"      0           8
02661    //*-*        3 : times-bold-i-normal        "Times New Roman"      1           8
02662    //*-*        4 : helvetica-medium-r-normal  "Arial"                0           5
02663    //*-*        5 : helvetica-medium-o-normal  "Arial"                1           5
02664    //*-*        6 : helvetica-bold-r-normal    "Arial"                0           8
02665    //*-*        7 : helvetica-bold-o-normal    "Arial"                1           8
02666    //*-*        8 : courier-medium-r-normal    "Courier New"          0           5
02667    //*-*        9 : courier-medium-o-normal    "Courier New"          1           5
02668    //*-*       10 : courier-bold-r-normal      "Courier New"          0           8
02669    //*-*       11 : courier-bold-o-normal      "Courier New"          1           8
02670    //*-*       12 : symbol-medium-r-normal     "Symbol"               0           6
02671    //*-*       13 : times-medium-r-normal      "Times New Roman"      0           5
02672    //*-*       14 :                            "Wingdings"            0           5
02673 
02674    if ( fTextFont == fontnumber) return;
02675    fTextFont = fontnumber;
02676    if (fTextFont == -1) {
02677       fTextFontModified = 1;
02678       return;
02679    }
02680    fQFont->SetTextFont(fontnumber);
02681    fTextFontModified = 1;
02682 }
02683 
02684 //______________________________________________________________________________
02685 void  TGQt::SetTextSize(Float_t textsize)
02686 {
02687    //*-*-*-*-*-*-*-*-*-*-*-*-*Set current text size*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
02688    //*-*                      =====================
02689    if ( fTextSize != textsize ) {
02690       fTextSize = textsize;
02691       if (fTextSize > 0) {
02692          fQFont->SetTextSize(textsize);
02693          fTextFontModified = 1;
02694       }
02695    }
02696 }
02697 
02698 //______________________________________________________________________________
02699 void  TGQt::SetTitle(const char *title)
02700 {
02701    //*-*-*-*-*-*-*-*-*-*-*-*-*Set title of the object*-*-*-*-*-*-*-*-*-*-*-*-*-*
02702    //*-*                      =======================
02703    if (fSelectedWindow->devType() == QInternal::Widget)
02704    {
02705       ((TQtWidget *)fSelectedWindow)->topLevelWidget()-> setWindowTitle(GetTextDecoder()->toUnicode(title));
02706    }
02707 }
02708 
02709 //______________________________________________________________________________
02710 void  TGQt::UpdateWindow(int mode)
02711 {
02712    // Update display.
02713    // mode : (1) update
02714    //        (0) sync
02715 
02716    if (fSelectedWindow && mode != 2 ) {
02717       ((TQtWidget *)fSelectedWindow)->paintFlag();
02718       ((TQtWidget *)fSelectedWindow)->repaint();
02719 #ifndef R__WIN32
02720       // X11 needs "repaint" operation to be forced by some reason
02721 //      qDebug() <<  " TGQt::UpdateWindow " 
02722 //               <<  " Please check whether the \"" 
02723 //               <<  "QCoreApplication::processEvents(QEventLoop::ExcludeUserInput | QEventLoop::ExcludeSocketNotifiers, 200);"
02724 //               << "\" still needed !!!";
02725 #endif
02726    }
02727 }
02728 
02729 //______________________________________________________________________________
02730 Int_t  TGQt::WriteGIF(char *name)
02731 {
02732    //
02733    // Writes the current active window into pixmap file.
02734    // The format is defined by the file name extension
02735    // like "png","jpg","bmp"  . . .
02736    // If no extension is provided the "png" format is used by default
02737    //
02738    // Returns 1 in case of success,
02739    //         0 otherwise
02740    // Note: this method may not produce the expected result been called
02741    // ----  from the ROOT prompt by simple reason:
02742    //       The active window will be console window
02743    //       rather the last selected ROOT canvas.
02744    //
02745    WritePixmap(iwid(fSelectedWindow),UInt_t(-1),UInt_t(-1),name);
02746    return kTRUE;
02747 }
02748 
02749 //______________________________________________________________________________
02750 void  TGQt::WritePixmap(int wd, UInt_t w, UInt_t h, char *pxname)
02751 {
02752    // Write the pixmap wd in the bitmap file pxname in JPEG.
02753    // wd         : Pixmap address
02754    // w,h         : Width and height of the pixmap.
02755    //               if w = h = -1 the size of the pimxap is equal the size the wd size
02756    // pxname      : pixmap file name
02757    //               The format is defined by the file name extension
02758    //               like "png","jpg","bmp"  . . .
02759    //               If no or some unknown extension is provided then
02760    //               the "png" format is used by default
02761    // --
02762    // Take in account the special ROOT filename syntax 26.12.2006 vf
02763    //               "gif+NN" - an animated GIF file is produced, where NN is delay in 10ms units
02764 
02765    if (!wd || (wd == -1) ) return;
02766 
02767    QPaintDevice &dev = *iwid(wd);
02768    QPixmap grabWidget;
02769    QPixmap *pix=0;
02770    switch (dev.devType()) {
02771    case QInternal::Widget: {
02772         TQtWidget *thisWidget = (TQtWidget*)&dev;
02773         if (thisWidget->IsDoubleBuffered() ) {
02774            pix = ((const TQtWidget*)&dev)->GetOffScreenBuffer();
02775         } else {
02776            // Grab the widget rectangle area directly from the screen
02777            // The image may contain the "alien" pieces !
02778            grabWidget = QPixmap::grabWindow(thisWidget->winId());
02779            pix = &grabWidget;
02780         }
02781      }
02782      break;
02783 
02784    case QInternal::Pixmap: {
02785       pix = (QPixmap *)&dev;
02786       break;
02787                           }
02788    case QInternal::Picture:
02789    case QInternal::Printer:
02790    default: assert(0);
02791      break;
02792    };
02793    if (pix) {
02794       // Create intermediate pixmap to stretch the original one if any
02795       QPixmap *finalPixmap = 0;
02796       if ( ( (h == w) && (w == UInt_t(-1) ) ) || ( QSize(w,h) == pix->size()) ) {
02797          finalPixmap = new QPixmap(*pix);
02798       }  else  {
02799          finalPixmap = new QPixmap(pix->scaled(w,h));
02800       }
02801       // Detect the special case "gif+"
02802       QString fname = pxname;
02803       int plus = fname.indexOf("+");
02804       if (plus>=0) fname = fname.left(plus);
02805 
02806       //  define the file extension
02807       QString saveType = QtFileFormat(QFileInfo(fname).suffix());
02808       //Info("WritePixmap"," type %s name = %s plus =  %d\n", (const char *)saveType,
02809       //   (const char*) fname, plus);
02810       if (saveType.isEmpty()) saveType="PNG";
02811 
02812       else if (QFileInfo(fname).suffix() == "gif") {
02813          // TrollTech doesn't allow the  GIF writting due
02814          // the patent problem.
02815          Int_t saver = gErrorIgnoreLevel;
02816          gErrorIgnoreLevel = kFatal;
02817          TImage *img = TImage::Create();
02818          if (img) {
02819             img->SetImage(Pixmap_t(rootwid(finalPixmap)),0);
02820             img->WriteImage(pxname,
02821 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,13,0)
02822                   plus>=0 ? TImage::kAnimGif: TImage::kGif);
02823 #else
02824                   TImage::kGif);
02825 #endif
02826             delete img;
02827          }
02828          gErrorIgnoreLevel = saver;
02829       } else {
02830          if (plus>=0) fname = GetNewFileName(fname);
02831          finalPixmap->save(fname,saveType.toAscii().data());
02832       }
02833       delete finalPixmap;
02834    }
02835 }
02836 
02837 //______________________________________________________________________________
02838 TVirtualX *TGQt::GetVirtualX(){ return fgTQt;}
02839 
02840 //______________________________________________________________________________
02841 Int_t TGQt::LoadQt(const char *shareLibFileName)
02842 {
02843    // Make sure we load the GUI DLL from the gui thread
02844    return gSystem->Load(shareLibFileName);
02845 }
02846 
02847 //______________________________________________________________________________
02848 Int_t TGQt::processQtEvents(Int_t maxtime)
02849 {
02850    // Force processing the Qt events only without entering the ROOT event loop
02851    QCoreApplication::processEvents(QEventLoop::AllEvents,maxtime);
02852    // QEventLoop::ExcludeUserInput QEventLoop::ExcludeSocketNotifiers
02853    return 0;
02854  }

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