00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <assert.h>
00014 #include "TGQt.h"
00015 #include "TQUserEvent.h"
00016 #include "TQtClientFilter.h"
00017 #include "TQtWidget.h"
00018 #include "TQtClientWidget.h"
00019 #include "TQtEventQueue.h"
00020 #include "TQtEventQueue.h"
00021 #include "TGWindow.h"
00022
00023
00024 #include "TROOT.h"
00025 #include "TEnv.h"
00026
00027 #include <qapplication.h>
00028 #include <qcursor.h>
00029 #include <qpixmap.h>
00030 #include <qbitmap.h>
00031 #include <qregion.h>
00032 #include <qclipboard.h>
00033
00034 #if QT_VERSION < 0x40000
00035 # include <qpaintdevicemetrics.h>
00036 # include <qobjectlist.h>
00037 # include <qcstring.h>
00038 #else
00039 # include <QByteArray>
00040 # include <QBoxLayout>
00041 # include <QKeyEvent>
00042 # include <QEvent>
00043 # include <QList>
00044 # include <QVBoxLayout>
00045 # include <QPolygon>
00046 # include <QDesktopWidget>
00047 # include <QDebug>
00048 # include <QPalette>
00049 # include <QColormap>
00050 # include <QIcon>
00051 # include <QSize>
00052 # include <QImage>
00053 # include <QLine>
00054 # include <QVector>
00055 #ifdef R__QTX11
00056 # include <QX11Info>
00057 #endif
00058 #endif
00059
00060 #include <qfontmetrics.h>
00061 #include <qpoint.h>
00062 #include <qpainter.h>
00063
00064 #include <qlayout.h>
00065 #include <qdatetime.h>
00066 #include <qtextcodec.h>
00067
00068 #include "TMath.h"
00069 #include "TQtBrush.h"
00070
00071 #include "TSystem.h"
00072 #include "KeySymbols.h"
00073
00074 #ifdef R__QTWIN32
00075 # include "TWinNTSystem.h"
00076 #else
00077 # ifdef R__QTX11
00078 # include <X11/Xlib.h>
00079 # endif
00080 #endif
00081
00082
00083 #include "TError.h"
00084
00085 #include "TGFrame.h"
00086 #include "TQtClientWidget.h"
00087
00088 static Window_t fgDefaultRootWindows = Window_t(-1);
00089
00090
00091 static TQtClientWidget* cwid(Window_t id) { return ((TQtClientWidget*)TGQt::wid(id)); }
00092
00093
00094
00095
00096
00097
00098
00099 class QtGContext : public QWidget {
00100 friend class TGQt;
00101 friend class TQtPainter;
00102 QtGContext(const QtGContext & );
00103 protected:
00104 Mask_t fMask;
00105 #if QT_VERSION < 0x40000
00106 Qt::RasterOp fROp;
00107 #else
00108 QPainter::CompositionMode fROp;
00109 #endif
00110 QPen fPen;
00111 QBrush fBrush;
00112 QPixmap *fTilePixmap;
00113 QPixmap *fStipple;
00114 QPoint fTileRect;
00115 QPoint fClipOrigin;
00116 QBitmap *fClipMask;
00117 QRegion fClipRegion;
00118 QFont *fFont;
00119 public:
00120 enum EContext { kROp =1, kPen, kBrush, kTilePixmap
00121 , kStipple, kTileRect,kClipOrigin,kClipMask,kClipRegion
00122 , kFont
00123 , kAllFields
00124 };
00125 QtGContext() : QWidget(0) ,fMask(0),fROp(), fPen(), fBrush(Qt::SolidPattern), fTilePixmap(0),fStipple(0),fClipMask(0),fFont(0) {}
00126 QtGContext(const GCValues_t &gval) : QWidget(0) ,fMask(0),fROp(), fPen(), fBrush(),fTilePixmap(0),fStipple(0),fClipMask(0),fFont(0){Copy(gval);}
00127 void Copy(const QtGContext &dst,Mask_t rootMask = 0xff);
00128 const QtGContext &Copy(const GCValues_t &gval);
00129 void DumpMask() const;
00130 bool HasValid(EContext bit) const { return TESTBIT (fMask , bit); }
00131 Mask_t Mask() const { return fMask; }
00132 void SetBackground(ULong_t background);
00133 void SetMask(Mask_t rootMask){ fMask = rootMask;}
00134 void SetForeground(ULong_t foreground);
00135 GContext_t gc() const { return (GContext_t)this; }
00136 operator GContext_t() const { return gc(); }
00137 const QtGContext &operator=(const GCValues_t &gval){ return Copy(gval);}
00138 QColor QtColor(ULong_t pixel) {return gQt->QtColor(pixel);}
00139
00140 };
00141
00142
00143 static QtGContext &qtcontext(GContext_t context) { return *(QtGContext *)context;}
00144
00145 QColor TGQt::QtColor(ULong_t pixel)
00146 {
00147
00148
00149
00150 static QColor black("black");
00151 #ifndef OLD
00152 return pixel ? QColormap::instance().colorAt(pixel) : black;
00153 #else
00154 if (pixel == 0) {
00155 QColormap cmap = QColormap::instance();
00156 pixel = cmap.pixel(black);
00157 }
00158 COLORMAP::iterator colorIterator;
00159
00160 if ((colorIterator = fColorMap.find(pixel)) != fColorMap.end()) {
00161 QColor *c = (*colorIterator).second;
00162 return *c;
00163 } else {
00164
00165
00166
00167 ColorStruct_t newColor;
00168 #ifdef R__WIN32
00169 newColor.fRed = (pixel & 255);
00170 pixel = pixel >> 8;
00171 newColor.fGreen = (pixel & 255);
00172 pixel = pixel >> 8;
00173 newColor.fBlue = (pixel & 255);
00174 #else
00175 newColor.fBlue = (pixel & 255);
00176 pixel = pixel >> 8;
00177 newColor.fGreen = (pixel & 255);
00178 pixel = pixel >> 8;
00179 newColor.fRed = (pixel & 255);
00180 #endif
00181 Colormap_t cmap=0;
00182 gVirtualX->AllocColor(cmap, newColor);
00183 return QtColor(newColor.fPixel);
00184 }
00185 #endif
00186 }
00187
00188 #ifdef CopyQTContext
00189 #define __saveCopyQTContext__ CopyQTContext
00190 #undef CopyQTContext
00191 #endif
00192
00193 #define CopyQTContext(member) \
00194 if (dst.HasValid(_NAME2_(k,member))&&TESTBIT(rootMask, _NAME2_(k,member))) { \
00195 SETBIT( fMask, _NAME2_(k,member)); \
00196 _NAME2_(f,member) = dst._NAME2_(f,member); \
00197 }
00198
00199 #if QT_VERSION < 0x40000
00200 void DumpROp(Qt::RasterOp op) {
00201 #else
00202 void DumpROp(QPainter::CompositionMode op) {
00203 #endif
00204
00205 QString s;
00206 switch (op) {
00207 #if QT_VERSION < 0x40000
00208 case Qt::ClearROP: s = "Qt::ClearROP -> dst = 0 "; break;
00209 case Qt::AndROP: s = "Qt::AndROP dst = src AND dst "; break;
00210 case Qt::AndNotROP: s = "Qt::AndNotROP dst = src AND (NOT dst) "; break;
00211 case Qt::CopyROP: s = "Qt::CopyROP dst = src "; break;
00212 case Qt::NotAndROP: s = "Qt::NotAndROP dst = (NOT src) AND dst"; break;
00213 case Qt::NorROP: s = "Qt::NorROP dst = NOT (src OR dst) "; break;
00214 case Qt::NopROP: s = "Qt::NopROP dst = dst "; break;
00215 case Qt::XorROP: s = "Qt::XorROP dst = src XOR dst "; break;
00216 case Qt::OrROP: s = "Qt::OrROP dst = src OR dst "; break;
00217 case Qt::NotXorROP: s = "Qt::NotXorROP dst = (NOT src) XOR dst // Qt::NotOrROP); // !!! This is not a GDK_EQUIV; !!!"; break;
00218 case Qt::NotROP: s = "Qt::NotROP dst = NOT dst "; break;
00219 case Qt::OrNotROP: s = "Qt::OrNotROP dst = src OR (NOT dst) "; break;
00220 case Qt::NotCopyROP:s = "Qt::NotCopyROP dst = NOT src "; break;
00221 case Qt::NotOrROP: s = "Qt::NotOrROP dst = (NOT src) OR dst "; break;
00222 case Qt::NandROP: s = "Qt::NandROP dst = NOT (src AND dst)"; break;
00223 case Qt::SetROP: s = "Qt::SetROP dst = 1"; break;
00224 default: s = "UNKNOWN"; break;
00225 #else
00226 case QPainter::CompositionMode_Clear: s = "Qt::ClearROP dst = 0 "; break;
00227
00228
00229 case QPainter::CompositionMode_Source: s = "Qt::CopyROP dst = src "; break;
00230
00231
00232 case QPainter::CompositionMode_Destination:s= "Qt::NopROP dst = dst "; break;
00233 case QPainter::CompositionMode_Xor: s = "Qt::XorROP dst = src XOR dst "; break;
00234
00235
00236
00237
00238
00239
00240
00241
00242 default: s = "UNKNOWN"; break;
00243 #endif
00244 }
00245 qDebug() << " Dump QT Composition mode Code: "
00246 <<op << " \""<< s << "\"";
00247 }
00248
00249
00250 #ifdef DumpGCMask
00251 #define __saveDumpGCMask__
00252 #undef DumpGCMask
00253 #endif
00254
00255 #define DumpGCMask(member) \
00256 if (HasValid(_NAME2_(k,member))) { \
00257 fprintf(stderr," mask bit : "); \
00258 fprintf(stderr, _QUOTE_(_NAME2_(k,member))); \
00259 fprintf(stderr," is defined\n"); }
00260 inline void QtGContext::DumpMask() const
00261 {
00262 fprintf(stderr," Dump QtGContext mask %x \n", fMask);
00263 DumpROp(fROp);
00264 DumpGCMask(ROp); DumpGCMask(Pen); DumpGCMask(Brush); DumpGCMask(TilePixmap);
00265 DumpGCMask(Stipple); DumpGCMask(TileRect);DumpGCMask(ClipOrigin);DumpGCMask(ClipMask);
00266 DumpGCMask(ClipRegion);DumpGCMask(Font);
00267 }
00268 #ifdef __saveDumpGCMask__
00269 #undef DumpGCMask
00270 #define DumpGCMask __saveDumpGCMask__
00271 #undef __saveDumpGCMask__
00272 #endif
00273
00274
00275 inline void QtGContext::Copy(const QtGContext &dst, Mask_t rootMask)
00276 {
00277
00278 CopyQTContext(ROp);
00279 CopyQTContext(Pen);
00280 CopyQTContext(Brush);
00281 CopyQTContext(TilePixmap);
00282 CopyQTContext(Stipple);
00283 CopyQTContext(TileRect);
00284 CopyQTContext(ClipOrigin);
00285 CopyQTContext(ClipMask);
00286 CopyQTContext(ClipRegion);
00287 CopyQTContext(Font);
00288
00289 }
00290 #ifdef __saveCopyQTContext__
00291 #undef CopyQTContext
00292 #define CopyQTContext __saveCopyQTContext__
00293 #undef __saveCopyQTContext__
00294 #endif
00295
00296 const QtGContext &QtGContext::Copy(const GCValues_t &gval)
00297 {
00298 if (!&gval) return *this;
00299
00300
00301 Mask_t rootMask = gval.fMask;
00302
00303 if ((rootMask & kGCFunction)) {
00304
00305 SETBIT(fMask, kROp);
00306 switch (gval.fFunction)
00307 {
00308 #if QT_VERSION < 0x40000
00309 case kGXclear:
00310 fROp = Qt::ClearROP;
00311 break;
00312 case kGXand:
00313 fROp = Qt::AndROP;
00314 break;
00315 case kGXandReverse:
00316 fROp = Qt::AndNotROP;
00317 break;
00318 case kGXcopy:
00319 fROp = Qt::CopyROP;
00320 break;
00321 case kGXandInverted:
00322 fROp = Qt::NotAndROP;
00323 break;
00324 case kGXnor:
00325 fROp = Qt::NorROP;
00326 break;
00327 case kGXnoop:
00328 fROp = Qt::NopROP;
00329 break;
00330 case kGXxor:
00331 fROp = Qt::XorROP;
00332 break;
00333 case kGXor:
00334 fROp = Qt::OrROP;
00335 break;
00336 case kGXequiv:
00337 fROp = Qt::NotXorROP;
00338 break;
00339 case kGXinvert:
00340 fROp = Qt::NotROP;
00341 break;
00342 case kGXorReverse:
00343 fROp = Qt::OrNotROP;
00344 break;
00345 case kGXcopyInverted:
00346 fROp = Qt::NotCopyROP;
00347 break;
00348 case kGXorInverted:
00349 fROp = Qt::NotOrROP;
00350 break;
00351 case kGXnand:
00352 fROp = Qt::NandROP;
00353 break;
00354 case kGXset:
00355 fROp = Qt::SetROP;
00356 break;
00357 #else
00358 case 0:
00359 #endif
00360 default:
00361 #if QT_VERSION < 0x40000
00362 fROp = Qt::CopyROP;
00363 break;
00364 #else
00365 fROp = QPainter::CompositionMode_Source;
00366 break;
00367 #endif
00368 }
00369
00370
00371 } else {
00372
00373 SETBIT(fMask, kROp);
00374 #if QT_VERSION < 0x40000
00375 fROp = Qt::CopyROP;
00376 #else
00377 fROp = QPainter::CompositionMode_Source;
00378 #endif
00379 };
00380
00381 if (rootMask & kGCSubwindowMode) {
00382 #if 0
00383 SETBIT(fMask,kXXX
00384 if (gval.fSubwindowMode == kIncludeInferiors)
00385 fSubwindow_mode = GDK_INCLUDE_INFERIORS;
00386 else
00387 fSubwindow_mode = GDK_CLIP_BY_CHILDREN
00388 #endif
00389 }
00390 if ((rootMask & kGCForeground)) {
00391
00392
00393 SetForeground(gval.fForeground);
00394
00395 }
00396 if ((rootMask & kGCBackground)) {
00397 SetBackground(gval.fBackground);
00398
00399 }
00400 if ((rootMask & kGCLineWidth)) {
00401 SETBIT(fMask,kPen);
00402 fPen.setWidth(gval.fLineWidth);
00403 }
00404 if ((rootMask & kGCLineStyle)) {
00405 SETBIT(fMask,kPen);
00406 Qt::PenStyle nextStyle = Qt::NoPen;
00407 switch (gval.fLineStyle)
00408 {
00409 case kLineSolid: nextStyle = Qt::SolidLine; break;
00410 case kLineOnOffDash: nextStyle = Qt::DashLine; break;
00411 case kLineDoubleDash: nextStyle = Qt::DashDotLine; break;
00412 };
00413 fPen.setStyle(nextStyle);
00414 }
00415 if ((rootMask & kGCCapStyle)) {
00416 SETBIT(fMask,kPen);
00417 Qt::PenCapStyle nextStyle = Qt::FlatCap;
00418 switch (gval.fCapStyle)
00419 {
00420 case kCapNotLast: nextStyle = Qt::FlatCap; break;
00421 case kCapButt: nextStyle = Qt::FlatCap; break;
00422 case kCapRound: nextStyle = Qt::RoundCap; break;
00423 case kCapProjecting: nextStyle = Qt::SquareCap; break;
00424 };
00425 fPen.setCapStyle(nextStyle);
00426 }
00427 if ((rootMask & kGCJoinStyle)) {
00428 SETBIT(fMask,kPen);
00429 Qt::PenJoinStyle nextStyle = Qt::MiterJoin;
00430 switch (gval.fJoinStyle)
00431 {
00432 case kJoinMiter: nextStyle = Qt::MiterJoin; break;
00433 case kJoinBevel: nextStyle = Qt::BevelJoin; break;
00434 case kJoinRound: nextStyle = Qt::RoundJoin; break;
00435 };
00436 fPen.setJoinStyle(nextStyle);
00437 }
00438 if ((rootMask & kGCFillStyle)) {
00439 SETBIT(fMask,kBrush);
00440 Qt::BrushStyle nextStyle = Qt::SolidPattern;
00441 switch (gval.fFillStyle)
00442 {
00443 case kFillTiled: nextStyle = Qt::Dense1Pattern; break;
00444 case kFillStippled: nextStyle = Qt::Dense6Pattern; break;
00445 case kFillOpaqueStippled: nextStyle = Qt::Dense7Pattern; break;
00446 case kFillSolid: default: nextStyle = Qt::SolidPattern; break;
00447 };
00448 fBrush.setStyle(nextStyle);
00449 }
00450 if ((rootMask & kGCTile)) {
00451 #ifdef QTDEBUG
00452 fprintf(stderr," kGCTile,%x, %p\n",rootMask,(QPixmap *) gval.fTile);
00453 #endif
00454 if ( gval.fTile != 0xFFFFFFFF ) {
00455 SETBIT(fMask,kTilePixmap);
00456 fTilePixmap = (QPixmap *) gval.fTile;
00457 }
00458 }
00459 if ((rootMask & kGCStipple)) {
00460
00461 SETBIT(fMask,kStipple);
00462 fStipple = (QPixmap *) gval.fStipple;
00463
00464 fBrush.setTexture(*fStipple);
00465 SETBIT(fMask, kROp);
00466 fROp = QPainter::CompositionMode_Xor;
00467 }
00468 if ((rootMask & kGCTileStipXOrigin)) {
00469 SETBIT(fMask,kTileRect);
00470 fTileRect.setX(gval.fTsXOrigin);
00471 }
00472 if ((rootMask & kGCTileStipYOrigin)) {
00473 SETBIT(fMask,kTileRect);
00474 fTileRect.setY(gval.fTsYOrigin);
00475 }
00476 if ((rootMask & kGCFont)) {
00477 SETBIT(fMask,kFont);
00478 setFont(*(QFont *) gval.fFont);
00479 fFont = (QFont *) gval.fFont;
00480
00481 }
00482 if ((rootMask & kGCGraphicsExposures)) {
00483 #if 0
00484 xmask |= GDK_GC_EXPOSURES;
00485 fGraphics_exposures = gval.fGraphicsExposures;
00486 #endif
00487 }
00488 if ((rootMask & kGCClipXOrigin)) {
00489
00490 SETBIT(fMask,kClipOrigin);
00491 fClipOrigin.setX(gval.fClipXOrigin);
00492 }
00493 if ((rootMask & kGCClipYOrigin)) {
00494 SETBIT(fMask,kClipOrigin);
00495 fClipOrigin.setY(gval.fClipYOrigin);
00496 }
00497 if ((rootMask & kGCClipMask)) {
00498 SETBIT(fMask,kClipMask);
00499 fClipMask = (QBitmap *) gval.fClipMask;
00500 }
00501 return *this;
00502 }
00503
00504 void QtGContext::SetBackground(ULong_t background)
00505 {
00506
00507 SETBIT(fMask,kBrush);
00508 QColor bg = QtColor(background);
00509 #if QT_VERSION < 0x40000
00510 setPaletteBackgroundColor(bg);
00511 setEraseColor(bg);
00512 #else
00513 QPalette pp=palette();
00514 pp.setColor(QPalette::Window,bg);
00515 setPalette(pp);
00516 #endif
00517 }
00518
00519 void QtGContext::SetForeground(ULong_t foreground)
00520 {
00521
00522
00523 SETBIT(fMask,kBrush);
00524 SETBIT(fMask,kPen);
00525 QColor bg = QtColor(foreground);
00526 QPalette pp = palette();
00527 pp.setColor(QPalette::WindowText, bg);
00528 setPalette(pp);
00529 fBrush.setColor(bg);
00530 fPen.setColor(bg);
00531 }
00532
00533
00534
00535
00536 class TQtPainter : public QPainter {
00537 public:
00538 #if QT_VERSION < 0x40000
00539 TQtPainter(const QPaintDevice * pd,const QtGContext &rootContext, Mask_t rootMask=0xff,bool unclipped = FALSE):
00540 QPainter(pd,unclipped){
00541 #else
00542 TQtPainter(QPaintDevice * pd,const QtGContext &rootContext, Mask_t rootMask=0xff,bool unclipped = FALSE):
00543 QPainter(pd){
00544 setClipping(!unclipped);
00545 #endif
00546 if (rootMask){}
00547 if (rootContext.HasValid(QtGContext::kROp)) {
00548 #if QT_VERSION < 0x40000
00549 setRasterOp (rootContext.fROp);
00550 #else
00551
00552 if (pd->devType() == QInternal::Image )
00553 setCompositionMode(rootContext.fROp);
00554 #endif
00555 }
00556 if (rootContext.HasValid(QtGContext::kPen)) {
00557 setPen(rootContext.fPen);
00558 }
00559 if (rootContext.HasValid(QtGContext::kBrush)) {
00560 setBrush(rootContext.fBrush);
00561 }
00562 if (rootContext.HasValid(QtGContext::kTilePixmap)) {
00563 setBrush(rootContext.fBrush);
00564 #ifdef QTDEBUG
00565 fprintf(stderr," NO special painter Qt implementation for TilePixmap option yet\n");
00566 #endif
00567 }
00568 if (rootContext.HasValid(QtGContext::kStipple)) {
00569 setBrush(rootContext.fBrush);
00570 }
00571 if (rootContext.HasValid(QtGContext::kTileRect)) {
00572 setBrush(rootContext.fBrush);
00573 #ifdef QTDEBUG
00574 fprintf(stderr," NO special painter Qt implementation for TileRect option yet\n");
00575 #endif
00576 }
00577 if (rootContext.HasValid(QtGContext::kClipOrigin)) {
00578
00579
00580 }
00581 if (rootContext.HasValid(QtGContext::kClipMask)) {
00582
00583 }
00584 if (rootContext.HasValid(QtGContext::kClipRegion)) {
00585 setClipRegion (rootContext.fClipRegion);
00586 }
00587 }
00588 };
00589
00590
00591
00592
00593 class TQtGrabPointerFilter : public QObject {
00594 protected:
00595 bool eventFilter( QObject *o, QEvent *e );
00596 };
00597
00598 bool TQtGrabPointerFilter::eventFilter( QObject *, QEvent *e)
00599 {
00600
00601 {
00602
00603 QKeyEvent *k = (QKeyEvent *)e;
00604 qDebug( "Ate key press %d", k->key() );
00605 return TRUE;
00606 }
00607
00608 return FALSE;
00609 }
00610
00611 class TXlfd {
00612
00613 public:
00614 QString fFontFoundry;
00615 QString fFontFamily;
00616 Int_t fIsFontBold;
00617 Int_t fIsFontItalic;
00618 Int_t fPointSize;
00619 Int_t fPixelSize;
00620
00621 TXlfd (const char* fontName) { Init(QString(fontName)); }
00622
00623
00624 TXlfd (const char* fontFamily, Int_t isFontBold, Int_t isFontItalic=-1)
00625 { Init(QString(fontFamily), isFontBold, isFontItalic); }
00626
00627
00628 TXlfd (const QString &fontFamily, Int_t isFontBold, Int_t isFontItalic)
00629 { Init(fontFamily, isFontBold, isFontItalic); }
00630
00631
00632 TXlfd (const QString &fontName) { Init(fontName); }
00633
00634
00635 inline void Init(const QString &fontName) {
00636
00637 fIsFontBold = fIsFontItalic = fPointSize = fPixelSize = -1;
00638 fFontFoundry = "*";
00639 fFontFamily = fontName.section('-',2,2);
00640
00641 QString fontWeight = fontName.section('-',3,3);
00642 if (fontWeight != "*")
00643 fIsFontBold = fontWeight.startsWith("bold") ? 1 : 0;
00644
00645 QString fontSlant = fontName.section('-',4,4);
00646 if (fontSlant != "*" )
00647 fIsFontItalic = ((fontSlant[0] == 'i') || (fontSlant[0] == 'o')) ? 1 : 0;
00648
00649 bool ok=true;
00650 QString fontPointSize = fontName.section('-',8,8);
00651 if (fontPointSize != "*")
00652 fPointSize = fontPointSize.toInt(&ok);
00653 if (!ok) fPointSize = -1;
00654
00655 QString fontPixelSize = fontName.section('-',7,7);
00656 if (fontPixelSize != "*")
00657 fPixelSize = fontPixelSize .toInt(&ok);
00658 if (!ok) fPixelSize = -1;
00659 }
00660
00661 inline void Init(const QString &fontFamily, Int_t isFontBold
00662 ,Int_t isFontItalic=-1, Int_t pointSize=-1, Int_t pixelSize=-1)
00663 {
00664 fFontFoundry = "*";
00665 fFontFamily = fontFamily;
00666 fIsFontBold = isFontBold; fIsFontItalic = isFontItalic;
00667 fPointSize = pointSize; fPixelSize = pixelSize;
00668
00669
00670 fPixelSize = SetPointSize(pointSize);
00671 if (fPixelSize == -1) fPixelSize = pixelSize;
00672 }
00673
00674 inline Int_t SetPointSize(Int_t pointSize)
00675 {
00676
00677 Int_t pixelSize = -1;
00678 fPointSize = pointSize;
00679 if (fPointSize > 0) {
00680 QFont sizeFont( fFontFamily, fPointSize, QFont::Normal, FALSE );
00681 pixelSize = sizeFont.pixelSize();
00682 }
00683 return pixelSize;
00684 }
00685
00686 inline bool operator==(const TXlfd &xlfd) const {
00687 return ( (fFontFamily == "*") || (xlfd.fFontFamily == "*") || ( fFontFamily == xlfd.fFontFamily) )
00688 && ( (fFontFoundry == "*") || (xlfd.fFontFoundry == "*") || ( fFontFoundry == xlfd.fFontFoundry) )
00689 && ( (fIsFontBold == -1 ) || (xlfd.fIsFontBold == -1 ) || ( fIsFontBold == xlfd.fIsFontBold) )
00690 && ( (fIsFontItalic== -1 ) || (xlfd.fIsFontItalic== -1 ) || ( fIsFontItalic == xlfd.fIsFontItalic))
00691 && ( (fPointSize == -1 ) || (xlfd.fPointSize == -1 ) || ( fPointSize == xlfd.fPointSize) )
00692 && ( (fPixelSize == -1 ) || (xlfd.fPixelSize == -1 ) || ( fPixelSize == xlfd.fPixelSize) );
00693 }
00694
00695 inline bool operator!=(const TXlfd &xlfd) const { return !operator==(xlfd); }
00696
00697 inline QString ToString() const
00698 {
00699 QString xLDF = "-";
00700 xLDF += fFontFoundry + "-";
00701 xLDF += fFontFamily + "-";
00702
00703
00704 QString weight_name = "*";
00705 if (fIsFontBold > -1)
00706 weight_name = fIsFontBold ? "bold" : "medium";
00707 xLDF += weight_name + "-";
00708
00709 QString slant_name = "*";
00710 if (fIsFontItalic > -1)
00711 slant_name = fIsFontItalic ? "i" : "r";
00712 xLDF += slant_name + "-";
00713
00714
00715
00716 xLDF += "*-*-";
00717
00718 QString pixelsize = "*";
00719 if (fPixelSize > -1)
00720 pixelsize = QString::number(fPixelSize);
00721 xLDF += pixelsize + "-";
00722
00723 QString pointsize = "*";
00724 if (fPointSize > -1)
00725 pointsize = QString::number(fPointSize);
00726 xLDF += pointsize + "-";
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736 xLDF += "*-*-*-*-";
00737
00738
00739
00740 xLDF += "ISO8859-1";
00741 return xLDF;
00742 }
00743 };
00744
00745
00746 void TGQt::SetOpacity(Int_t) { }
00747
00748 Window_t TGQt::GetWindowID(Int_t id) {
00749
00750 QPaintDevice *widDev = iwid(id);
00751 TQtWidget *canvasWidget = dynamic_cast<TQtWidget *>(iwid(id));
00752 if (widDev && !canvasWidget) {
00753
00754
00755 return rootwid(widDev);
00756 }
00757 assert(canvasWidget);
00758 TQtClientWidget *client = 0;
00759
00760 if (! (client = (TQtClientWidget *)canvasWidget->GetRootID() ) ) {
00761
00762 QWidget *parent = canvasWidget->parentWidget();
00763 client = (TQtClientWidget *)wid(CreateWindow(rootwid(parent)
00764 ,0,0,canvasWidget->width(),canvasWidget->height()
00765 ,0,0,0,0,0,0));
00766
00767 canvasWidget->setParent(client);
00768 QBoxLayout * l = new QVBoxLayout( client );
00769 l->addWidget( canvasWidget );
00770 l->setContentsMargins(0,0,0,0);
00771 canvasWidget->SetRootID(client);
00772 client->SetCanvasWidget(canvasWidget);
00773 canvasWidget->setMouseTracking(kFALSE);
00774 }
00775 return rootwid(client);
00776 }
00777
00778 Window_t TGQt::GetDefaultRootWindow() const
00779 {
00780 return kDefault;
00781 }
00782
00783 void TGQt::GetWindowAttributes(Window_t id, WindowAttributes_t &attr)
00784 {
00785
00786 if (id == kNone) return;
00787 const QWidget &thisWindow = *wid(id);
00788
00789 assert(&thisWindow);
00790 memset(&attr,0,sizeof(WindowAttributes_t));
00791 attr.fX = thisWindow.x();
00792 attr.fY = thisWindow.y();
00793 attr.fWidth = thisWindow.width ();
00794 attr.fHeight = thisWindow.height ();
00795 attr.fBorderWidth = (thisWindow.frameGeometry().width() - thisWindow.width())/2;
00796 attr.fClass = kInputOutput;
00797 attr.fRoot = Window_t(thisWindow.topLevelWidget () );
00798 #ifdef R__QTX11
00799 const QX11Info &info = thisWindow.x11Info();
00800 attr.fVisual = info.visual();
00801 #else
00802 attr.fVisual = 0;
00803 #endif
00804
00805 attr.fDepth = QPixmap::defaultDepth();
00806 attr.fColormap = 0;
00807 if (!thisWindow.isHidden()) {
00808 attr.fMapState = thisWindow.isVisible() ? kIsViewable : kIsUnviewable;
00809 } else {
00810 attr.fMapState = kIsUnmapped;
00811 }
00812 attr.fBackingStore = kNotUseful;
00813 attr.fSaveUnder = kFALSE;
00814 attr.fMapInstalled = kTRUE;
00815 attr.fOverrideRedirect = kFALSE;
00816 attr.fScreen = QApplication::desktop()->screen() ;
00817
00818
00819
00820
00821
00822 attr.fYourEventMask = 0;
00823
00824
00825 attr.fBitGravity = 0;
00826 attr.fWinGravity = 0;
00827 attr.fAllEventMasks = 0;
00828 attr.fDoNotPropagateMask = 0;
00829 }
00830
00831 Bool_t TGQt::ParseColor(Colormap_t , const char *cname, ColorStruct_t &color)
00832 {
00833
00834
00835
00836
00837
00838
00839
00840
00841 color.fPixel = 0;
00842 color.fRed = 0;
00843 color.fGreen = 0;
00844 color.fBlue = 0;
00845 color.fMask = kDoRed | kDoGreen | kDoBlue;
00846
00847 QColor thisColor(cname);
00848 if (thisColor.isValid() ) {
00849 QColormap cmap = QColormap::instance();
00850 color.fPixel = cmap.pixel(thisColor);
00851 color.fRed = thisColor.red();
00852 color.fGreen = thisColor.green();
00853 color.fBlue = thisColor.blue();
00854 }
00855
00856 return thisColor.isValid();
00857 }
00858
00859
00860 Bool_t TGQt::AllocColor(Colormap_t , ColorStruct_t &color)
00861 {
00862
00863
00864
00865
00866
00867
00868
00869 int cFactor=1;
00870 if (color.fRed>256 || color.fGreen>256 || color.fBlue>256 ){
00871 cFactor = 257;
00872 }
00873 QColor *thisColor = new QColor(
00874 (color.fRed >> (cFactor > 1? 8:0)) & 255
00875 ,(color.fGreen >> (cFactor > 1? 8:0)) & 255
00876 ,(color.fBlue >> (cFactor > 1? 8:0)) & 255);
00877 QColormap cmap = QColormap::instance();
00878 color.fPixel = cmap.pixel(*thisColor);
00879
00880
00881 #ifdef OLD
00882 fColorMap[color.fPixel] = thisColor;
00883 #endif
00884 return kTRUE;
00885 }
00886
00887 void TGQt::QueryColor(Colormap_t , ColorStruct_t &color)
00888 {
00889
00890
00891
00892
00893
00894
00895
00896 QColor c = QtColor(color.fPixel);
00897
00898 color.fRed = c.red() <<8;
00899 color.fGreen = c.green()<<8;
00900 color.fBlue = c.blue() <<8;
00901 }
00902
00903 void TGQt::NextEvent(Event_t &event)
00904 {
00905
00906
00907
00908
00909
00910 qApp->processEvents ();
00911 if (qApp->hasPendingEvents ()) QCoreApplication::sendPostedEvents();
00912 fQtEventHasBeenProcessed = 1;
00913
00914 memset(&event,0,sizeof(Event_t));
00915 event.fType = kOtherEvent;
00916 #ifndef R__QTGUITHREAD
00917 if (!fQClientFilterBuffer)
00918 fQClientFilterBuffer = fQClientFilter->Queue();
00919
00920 #endif
00921
00922
00923
00924
00925 if (fQClientFilterBuffer) {
00926 const Event_t *ev = fQClientFilterBuffer->dequeue ();
00927 if (ev) {
00928
00929
00930
00931 event = *ev; delete ev;
00932 if (gDebug > 3) fprintf(stderr," TGQt::NextEvent event type=%d win=%p\n", event.fType,(void *)event.fWindow);
00933 }
00934 }
00935 }
00936
00937 void TGQt::GetPasteBuffer(Window_t , Atom_t , TString &text, Int_t &nchar,
00938 Bool_t del)
00939 {
00940
00941
00942
00943
00944 text = "";
00945 nchar = 0;
00946 QClipboard *cb = QApplication::clipboard();
00947 QClipboard::Mode mode =
00948 cb->supportsSelection() ? QClipboard::Selection :QClipboard::Clipboard;
00949 text = cb->text(mode).toStdString().c_str();
00950 nchar = text.Length();
00951 if (del) cb->clear(mode);
00952 }
00953
00954
00955
00956 void TGQt::MapWindow(Window_t id)
00957 {
00958
00959 if (id == kNone || wid(fgDefaultRootWindows) == wid(id) || id == kDefault ) return;
00960
00961
00962 QWidget *wg = wid(id);
00963 if ( wg ) {
00964 if ( wg->isTopLevel () ){
00965 wg->showNormal();
00966 } else wg->show();
00967
00968 }
00969 }
00970
00971 void TGQt::MapSubwindows(Window_t id)
00972 {
00973
00974
00975
00976
00977
00978 if (id == kNone || id == kDefault) return;
00979
00980 const QObjectList &childList = wid(id)->children();
00981 int nSubWindows = 0;
00982 int nChild = 0;
00983 if (!childList.isEmpty () ) {
00984 nChild = childList.count();
00985 QListIterator<QObject *> next(childList);
00986 QObject *widget = 0;
00987 int childCounter = 0;
00988
00989 Bool_t updateUnable;
00990 if ( (updateUnable = wid(id)->updatesEnabled()) && nChild >0 )
00991 wid(id)->setUpdatesEnabled(FALSE);
00992 next.toBack();
00993 while (next.hasPrevious())
00994 {
00995 widget = next.previous();
00996 childCounter++;
00997 if (widget->isWidgetType ())
00998 {
00999 ((QWidget *)widget)->show();
01000 nSubWindows++;
01001 } else {
01002
01003
01004
01005 }
01006 }
01007 if (updateUnable && nChild >0 )
01008 wid(id)->setUpdatesEnabled(TRUE);
01009 }
01010 }
01011
01012 void TGQt::MapRaised(Window_t id)
01013 {
01014
01015
01016
01017
01018
01019
01020
01021 if (id == kNone || id == kDefault) return;
01022 #ifndef OLDQT25042003
01023
01024 QWidget *wg = wid(id);
01025 Bool_t updateUnable;
01026 if ( (updateUnable = wg->updatesEnabled()) )
01027 wg->setUpdatesEnabled(FALSE);
01028 RaiseWindow(id);
01029 MapWindow(id);
01030 do {
01031
01032 wg->setHidden (false);
01033 wg = wg->parentWidget();
01034 } while ( wg && (!wg->isVisible()) );
01035 if (updateUnable)
01036 wid(id)->setUpdatesEnabled(TRUE);
01037
01038 if (wid(id)->isTopLevel()) {
01039
01040
01041 }
01042 #else
01043 #if 0
01044 QWidget *wg = winid(id);
01045 wg->setHidden(false);
01046 wg->raise();
01047 wg->show();
01048 #ifdef R__QTWIN32
01049
01050 HWND h = wg->winId();
01051 SetWindowPos(h,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
01052 SetWindowPos(h,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE );
01053 #endif
01054 wg->showNormal();
01055 MapSubwindows(id);
01056
01057 #else
01058
01059
01060 MapWindow(id);
01061
01062 QWidget *wg = wid(id);
01063 if ( wg->isTopLevel() ) {
01064
01065 #ifdef R__QTWIN32
01066
01067 HWND h = wg->winId();
01068 SetWindowPos(h,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
01069 SetWindowPos(h,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE );
01070 #endif
01071 wg->showNormal();
01072 } else {
01073 do {
01074 wg->raise();
01075
01076 } while ( (! wg->isVisible() ) && (wg = wg->parentWidget()) );
01077 }
01078 #endif
01079 #endif
01080
01081 }
01082
01083 void TGQt::UnmapWindow(Window_t id)
01084 {
01085
01086
01087 if (id == kNone) return;
01088
01089 if (!wid(id)->isHidden()) wid(id)->hide();
01090
01091 }
01092
01093 void TGQt::DestroyWindow(Window_t id)
01094 {
01095
01096
01097 if (id == kNone || id == kDefault ) return;
01098 fQClientGuard.Delete(wid(id));
01099
01100 }
01101
01102 void TGQt::LowerWindow(Window_t id)
01103 {
01104
01105 if (id == kNone || id == kDefault ) return;
01106 wid(id)-> lower();
01107 }
01108
01109 void TGQt::MoveWindow(Window_t id, Int_t x, Int_t y)
01110 {
01111
01112
01113 if (id == kNone || id == kDefault ) return;
01114 wid(id)->move(x,y);
01115 }
01116
01117 void TGQt::MoveResizeWindow(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h)
01118 {
01119
01120
01121 if (id == kNone || id == kDefault ) return;
01122
01123 {
01124 wid(id)->setGeometry(x,y,w,h);
01125
01126 }
01127 }
01128
01129 void TGQt::ResizeWindow(Window_t id, UInt_t w, UInt_t h)
01130 {
01131
01132
01133 if (id == kNone || id == kDefault ) return;
01134
01135 {
01136 wid(id)->resize(w,h);
01137
01138 }
01139 }
01140
01141 void TGQt::IconifyWindow(Window_t id)
01142 {
01143
01144 if ( id == kNone || id == kDefault ) return;
01145 wid(id)->showMinimized();
01146 }
01147
01148
01149 Bool_t TGQt::NeedRedraw(ULong_t w, Bool_t force)
01150 {
01151
01152
01153
01154
01155
01156
01157
01158
01159 #if ROOT_VERSION_CODE >= ROOT_VERSION(9,15,9)
01160 if (!force)
01161 {
01162 assert(0);
01163 TGWindow *www =(TGWindow *)w;
01164 Window_t id = www->GetId();
01165 if (id) wid(id)->update();
01166 }
01167 return !force;
01168 #else
01169 if (w||force) {}
01170 return kFALSE;
01171 #endif
01172 }
01173
01174 void TGQt::RaiseWindow(Window_t id)
01175 {
01176
01177
01178
01179
01180 if ( id == kNone || id == kDefault ) return;
01181 #ifndef OLDQT23042004
01182 QWidget *wg = wid(id);
01183 wg->raise();
01184 #else
01185 MapWindow(id);
01186 QWidget *wg = wid(id);
01187
01188 if ( wg->isTopLevel() ) {
01189 QWidget *wg = ((TQtClientWidget *)wid(id))->topLevelWidget();
01190 #ifdef R__QTWIN32
01191
01192 HWND h = wg->winId();
01193 SetWindowPos(h,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
01194 SetWindowPos(h,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE );
01195 #endif
01196 wg->showNormal();
01197 } else {
01198 do {
01199 wg->raise();
01200 } while ( (!wg->isVisible()) && (wg = wg->parentWidget()) );
01201 wid(id)->show();
01202
01203 }
01204 #endif
01205 }
01206
01207 void TGQt::SetIconPixmap(Window_t id, Pixmap_t pix)
01208 {
01209
01210 if (id == kNone || id == kDefault || (pix==0) ) return;
01211 wid(id)->setWindowIcon(QIcon(*fQPixmapGuard.Pixmap(pix)));
01212 }
01213
01214 void TGQt::ReparentWindow(Window_t id, Window_t pid, Int_t x, Int_t y)
01215 {
01216
01217
01218
01219
01220
01221
01222 wid(id)->setParent(wid(pid));
01223 if (x || y) wid(id)->move(x,y);
01224 }
01225
01226
01227 void TGQt::SetWindowBackground(Window_t id, ULong_t color)
01228 {
01229
01230 if (id == kNone || id == kDefault ) return;
01231 TQtClientWidget *wd = dynamic_cast<TQtClientWidget*>(wid(id));
01232 if (wd) wd->setEraseColor(QtColor(color));
01233 }
01234
01235 void TGQt::SetWindowBackgroundPixmap(Window_t id, Pixmap_t pxm)
01236 {
01237
01238 if (pxm != kNone && id != kNone && id != kDefault ) {
01239 TQtClientWidget *wd = dynamic_cast<TQtClientWidget*>(wid(id));
01240 if (wd) wd->setErasePixmap (*fQPixmapGuard.Pixmap(pxm));
01241 }
01242 }
01243
01244 Window_t TGQt::CreateWindow(Window_t parent, Int_t x, Int_t y,
01245 UInt_t w, UInt_t h, UInt_t border,
01246 Int_t , UInt_t ,
01247 void *, SetWindowAttributes_t *attr,
01248 UInt_t wtype)
01249 {
01250
01251
01252 QWidget *pWidget = parent ? wid(parent):0;
01253
01254 if (pWidget == QApplication::desktop()) pWidget = 0;
01255 TQtClientWidget *win = 0;
01256
01257
01258 if ( wtype & kTransientFrame) {
01259 win = fQClientGuard.Create(pWidget,"TransientFrame");
01260 #if QT_VERSION < 0x40000
01261 win->setFrameShape(QFrame::Box);
01262 } else if (wtype & kMainFrame) {
01263 win = fQClientGuard.Create(pWidget,"MainFrame");
01264 win->setFrameShape(QFrame::WinPanel);
01265 } else if (wtype & kTempFrame) {
01266 win = fQClientGuard.Create(pWidget,"tooltip", Qt::WStyle_StaysOnTop | Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WX11BypassWM );
01267 win->setFrameStyle(QFrame::PopupPanel | QFrame::Plain);
01268 } else {
01269 win = fQClientGuard.Create(pWidget,"Other", Qt::WStyle_StaysOnTop | Qt::WStyle_Customize | Qt::WX11BypassWM | (wtype & kOwnBackground ? Qt::WNoAutoErase : 0));
01270 if (!pWidget) {
01271 win->setFrameStyle( QFrame::PopupPanel | QFrame::Plain );
01272
01273 }
01274 #else
01275 win->setFrameShape(QFrame::Box);
01276 } else if (wtype & kMainFrame) {
01277 win = fQClientGuard.Create(pWidget,"MainFrame");
01278 win->setFrameShape(QFrame::WinPanel);
01279 } else if (wtype & kTempFrame) {
01280 win = fQClientGuard.Create(pWidget,"tooltip"
01281 , Qt::ToolTip
01282 | Qt::Tool
01283 | Qt::X11BypassWindowManagerHint
01284 | Qt::FramelessWindowHint
01285 | Qt::WindowStaysOnTopHint );
01286 #if QT_VERSION >= 0x040400
01287 win->setAttribute(Qt::WA_X11NetWmWindowTypeToolTip);
01288 #endif
01289 win->setFrameStyle(QFrame::Box | QFrame::Plain);
01290 } else {
01291 win = fQClientGuard.Create(pWidget,"Other"
01292 , Qt::WindowStaysOnTopHint
01293 | Qt::X11BypassWindowManagerHint );
01294 if (!pWidget) {
01295 win->setFrameStyle(QFrame::WinPanel | QFrame::Plain);
01296
01297 }
01298 #endif
01299 }
01300
01301
01302
01303 if (QClientFilter()) {
01304 win->installEventFilter(QClientFilter());
01305 }
01306 if (border > 0)
01307 win->setContentsMargins((int)border,(int)border,(int)border,(int)border);
01308 if (attr) {
01309 if ((attr->fMask & kWABackPixmap))
01310 if (attr->fBackgroundPixmap != kNone && attr->fBackgroundPixmap != kParentRelative )
01311 {
01312 QPalette palette= win->palette();
01313 palette.setBrush(QPalette::Window, QBrush(*(QPixmap *)attr->fBackgroundPixmap));
01314 win->setErasePixmap(*(QPixmap *)attr->fBackgroundPixmap);
01315 win->setPalette(palette);
01316 win->setBackgroundRole(QPalette::Window);
01317 }
01318 if ((attr->fMask & kWABackPixel)) {
01319 QPalette palette= win->palette();
01320 palette.setColor(QPalette::Window, QtColor(attr->fBackgroundPixel));
01321 win->setEraseColor(QtColor(attr->fBackgroundPixel));
01322 win->setPalette(palette);
01323 win->setBackgroundRole(QPalette::Window);
01324 }
01325 if ( attr->fMask & kWAEventMask) {
01326
01327 win->SetAttributeEventMask(attr->fEventMask);
01328 }
01329 }
01330 MoveResizeWindow(rootwid(win),x,y,w,h);
01331 return rootwid(win);
01332 }
01333
01334 Int_t TGQt::OpenDisplay(const char *dpyName)
01335 {
01336
01337 if (dpyName){}
01338 #ifdef R__QTX11
01339 return ConnectionNumber( GetDisplay() );
01340 #else
01341 return 1;
01342 #endif
01343 }
01344
01345 void TGQt::CloseDisplay()
01346 {
01347
01348 qApp->closeAllWindows();
01349 }
01350
01351 Display_t TGQt::GetDisplay() const
01352 {
01353
01354
01355
01356
01357
01358
01359
01360 #ifdef R__QTX11
01361 return (Display_t)QX11Info::display();
01362 #else
01363
01364 return 0;
01365 #endif
01366 }
01367
01368 Visual_t TGQt::GetVisual() const
01369 {
01370
01371
01372
01373
01374
01375
01376
01377 #ifdef R__QTX11
01378 return (Visual_t) QX11Info::appVisual();
01379 #else
01380
01381 return 0;
01382 #endif
01383 }
01384
01385 Int_t TGQt::GetScreen() const
01386 {
01387
01388
01389
01390
01391
01392
01393
01394 #ifdef R__QTX11
01395 return QX11Info::appScreen();
01396 #else
01397
01398 return 0;
01399 #endif
01400 }
01401
01402 Int_t TGQt::GetDepth() const
01403 {
01404
01405 #ifdef R__QTX11
01406 return QX11Info::appDepth();
01407 #else
01408 return QPixmap::defaultDepth();
01409 #endif
01410 }
01411
01412 Colormap_t TGQt::GetColormap() const { return 0; }
01413
01414
01415 Atom_t TGQt::InternAtom(const char *atom_name, Bool_t )
01416 {
01417
01418
01419
01420
01421 const char *rootAtoms[] = { "WM_DELETE_WINDOW"
01422 , "_MOTIF_WM_HINTS"
01423 , "_ROOT_MESSAGE"
01424 , "_ROOT_CLIPBOARD"
01425 , "CLIPBOARD"
01426 , "" };
01427 int nSize = sizeof(rootAtoms)/sizeof(char *);
01428 nSize --;
01429 int i;
01430 for (i=0; (i<nSize) && ( strcmp(atom_name,rootAtoms[i])) ;i++){;}
01431
01432 return i;
01433 }
01434
01435 Window_t TGQt::GetParent(Window_t id) const
01436 {
01437
01438 if ( id == kNone || id == kDefault ) return id;
01439 QWidget *dadWidget = wid(id)->parentWidget();
01440 assert(dynamic_cast<TQtClientWidget*>(dadWidget));
01441 return rootwid(dadWidget);
01442 }
01443
01444 FontStruct_t TGQt::LoadQueryFont(const char *font_name)
01445 {
01446
01447
01448
01449
01450
01451 QString fontName(QString(font_name).trimmed());
01452 QFont *newFont = 0;
01453 if (fontName.toLower() == "qt-default") newFont = new QFont(QApplication::font());
01454 else {
01455 #ifdef R__UNIX
01456 newFont = new QFont();
01457 newFont->setRawName(fontName);
01458 #else
01459 QString fontFamily = fontName.section('-',1,2);
01460 int weight = QFont::Normal;
01461
01462 QString fontWeight = fontName.section('-',3,3);
01463 if (fontWeight.startsWith("bold")) weight = QFont::Bold;
01464
01465 bool italic = (fontName.section('-',4,4)[0] == 'i');
01466
01467
01468 bool ok;
01469 int fontSize=12;
01470 int fontPointSize = fontName.section('-',8,8).toInt(&ok);
01471 if (ok) fontSize = fontPointSize;
01472 newFont = new QFont(fontFamily,fontSize,weight,italic);
01473 if (!ok) {
01474 int fontPixelSize = fontName.section('-',7,7).toInt(&ok);
01475 if (ok)
01476 newFont->setPixelSize(int(TMath::Max(fontPixelSize,1)));
01477 }
01478 #endif
01479 newFont->setStyleHint(QFont::System,QFont::PreferDevice);
01480 }
01481
01482
01483 return FontStruct_t(newFont);
01484 }
01485
01486 FontH_t TGQt::GetFontHandle(FontStruct_t fs)
01487 {
01488
01489
01490
01491
01492 return (FontH_t)fs;
01493 }
01494
01495 void TGQt::DeleteFont(FontStruct_t fs)
01496 {
01497
01498 delete (QFont *)fs;
01499 }
01500
01501 GContext_t TGQt::CreateGC(Drawable_t , GCValues_t *gval)
01502 {
01503
01504
01505 QtGContext *context = 0;
01506 if (gval)
01507 context = new QtGContext(*gval);
01508 else
01509 context = new QtGContext();
01510
01511 return GContext_t(context);
01512 }
01513
01514 void TGQt::ChangeGC(GContext_t gc, GCValues_t *gval)
01515 {
01516
01517 qtcontext(gc) = *gval;
01518 }
01519
01520 void TGQt::CopyGC(GContext_t org, GContext_t dest, Mask_t mask)
01521 {
01522
01523
01524 qtcontext(dest).Copy(qtcontext(org),mask);
01525 }
01526
01527 void TGQt::DeleteGC(GContext_t gc)
01528 {
01529
01530 delete &qtcontext(gc);
01531 }
01532
01533 Cursor_t TGQt::CreateCursor(ECursor cursor)
01534 {
01535
01536 return Cursor_t(fCursors[cursor]);
01537 }
01538
01539 void TGQt::SetCursor(Window_t id, Cursor_t curid)
01540 {
01541
01542 if (id && id != Window_t(-1)) cwid(id)->SetCursor(curid);
01543
01544 }
01545
01546 Pixmap_t TGQt::CreatePixmap(Drawable_t , UInt_t w, UInt_t h)
01547 {
01548
01549
01550 QPixmap *p = fQPixmapGuard.Create(w, h);
01551 return Pixmap_t(rootwid(p));
01552 }
01553
01554 Pixmap_t TGQt::CreatePixmap(Drawable_t , const char *bitmap, UInt_t width,
01555 UInt_t height, ULong_t forecolor, ULong_t backcolor,
01556 Int_t depth)
01557 {
01558
01559
01560 QPixmap *p = 0;
01561 if (depth >1) {
01562 QBitmap bp = QBitmap::fromData(QSize(width, height),(const uchar*)bitmap);
01563 QBrush fillBrush(QtColor(backcolor), bp);
01564 p = fQPixmapGuard.Create(width,height,depth);
01565 QPainter pixFill(p);
01566 pixFill.setBackground(QtColor(backcolor));
01567 pixFill.setPen(QtColor(forecolor));
01568 pixFill.fillRect(0,0,width, height,fillBrush);
01569 } else {
01570 p = fQPixmapGuard.Create(width, height,(const uchar*)bitmap);
01571 }
01572 return Pixmap_t(rootwid(p));
01573 }
01574
01575 Pixmap_t TGQt::CreateBitmap(Drawable_t id, const char *bitmap,
01576 UInt_t width, UInt_t height)
01577 {
01578
01579 return CreatePixmap(id,bitmap,width,height, 1,0,1);
01580 }
01581
01582 void TGQt::DeletePixmap(Pixmap_t pmap)
01583 {
01584
01585 if (pmap != kNone )
01586 fQPixmapGuard.Delete((QPixmap *)iwid(pmap));
01587
01588 }
01589
01590 static inline void FillPixmapAttribute(QPixmap &pixmap, Pixmap_t &pict_mask
01591 , PictureAttributes_t & attr,TQtPixmapGuard &guard)
01592 {
01593
01594 attr.fWidth = pixmap.width();
01595 attr.fHeight = pixmap.height();
01596
01597 if ( !pixmap.mask().isNull() ) {
01598 QBitmap *pixmask = (QBitmap *)guard.Pixmap(pict_mask,kTRUE);
01599 if (pixmask) {
01600 *pixmask = pixmap.mask();
01601 } else {
01602 pixmask = guard.Create(pixmap.mask());
01603 pict_mask = Pixmap_t(TGQt::rootwid(pixmask));
01604 }
01605 } else {
01606 pict_mask = kNone;
01607 }
01608 }
01609
01610 Bool_t TGQt::CreatePictureFromFile( Drawable_t , const char *filename,
01611 Pixmap_t & pict,
01612 Pixmap_t &pict_mask,
01613 PictureAttributes_t & attr)
01614 {
01615
01616
01617
01618 QPixmap *pixmap = 0;
01619 if (pict != kNone )
01620 pixmap = fQPixmapGuard.Pixmap(pict);
01621 if (!pixmap) {
01622
01623 pixmap = fQPixmapGuard.Create(QString(filename));
01624
01625 pict = Pixmap_t(rootwid(pixmap));
01626 } else {
01627
01628 pixmap->load(QString(filename));
01629 }
01630 if (! pixmap->isNull() ) {
01631 FillPixmapAttribute(*pixmap,pict_mask,attr,fQPixmapGuard);
01632 } else {
01633 fQPixmapGuard.Delete(pixmap);
01634 pict= kNone;
01635 pixmap = 0;
01636 }
01637 return pixmap;
01638 }
01639
01640
01641 Bool_t TGQt::CreatePictureFromData(Drawable_t , char **data,
01642 Pixmap_t & pict,
01643 Pixmap_t &pict_mask,
01644 PictureAttributes_t & attr)
01645 {
01646
01647
01648
01649 QPixmap *pixmap = fQPixmapGuard.Pixmap(pict);
01650 if (!pixmap) {
01651 pixmap = fQPixmapGuard.Create((const char **)data);
01652 pict = Pixmap_t(rootwid(pixmap));
01653 } else {
01654 *pixmap = QPixmap ( (const char **)data);
01655 }
01656
01657 if (! pixmap->isNull() ) {
01658 FillPixmapAttribute(*pixmap,pict_mask,attr,fQPixmapGuard);
01659 } else {
01660 fQPixmapGuard.Delete(pixmap);
01661 pict= kNone;
01662 pixmap = 0;
01663 }
01664 return pixmap;
01665 }
01666
01667 Bool_t TGQt::ReadPictureDataFromFile(const char *fileName, char ***data)
01668 {
01669
01670
01671 QPixmap *pictureBuffer = fQPixmapGuard.Create(QString(fileName));
01672 if (pictureBuffer->isNull()){
01673 fQPixmapGuard.Delete(pictureBuffer);
01674 } else {
01675
01676 }
01677 if (!data)
01678 return gSystem->Load(fileName);
01679 else {
01680 fprintf(stderr, "I got no idea why do we need this trick yet!\n");
01681 }
01682 return kFALSE;
01683 }
01684
01685 void TGQt::DeletePictureData(void *data)
01686 {
01687
01688 fQPixmapGuard.Delete((QPixmap *)data);
01689 }
01690
01691 void TGQt::SetDashes(GContext_t , Int_t , const char * ,
01692 Int_t )
01693 {
01694
01695
01696
01697
01698
01699 }
01700
01701 Int_t TGQt::EventsPending() {
01702 #ifndef R__QTGUITHREAD
01703
01704 Int_t retCode = fQClientFilterBuffer ? fQClientFilterBuffer->count(): 0;
01705 if (fQtEventHasBeenProcessed) {
01706 fQtEventHasBeenProcessed++;
01707 if (fQtEventHasBeenProcessed > 2) fQtEventHasBeenProcessed = 0;
01708 } else retCode = qApp->hasPendingEvents();
01709 return retCode;
01710 #endif
01711
01712 if (fQClientFilterBuffer && fQClientFilterBuffer->isEmpty())
01713 {
01714
01715 #ifndef R__QTGUITHREAD
01716 if (qApp->hasPendingEvents ()) qApp->processEvents ();
01717 #else
01718 delete fQClientFilterBuffer;
01719 fQClientFilterBuffer = 0;
01720 #endif
01721
01722 }
01723 if (!fQClientFilterBuffer)
01724 fQClientFilterBuffer = fQClientFilter->Queue();
01725 return fQClientFilterBuffer ? fQClientFilterBuffer->count(): 0;
01726 }
01727
01728 void TGQt::Bell(Int_t percent)
01729 {
01730
01731 #ifdef R__QTWIN32
01732 DWORD dwFreq = 1000L;
01733 DWORD dwDuration = 100L+percent;
01734 Beep(dwFreq,dwDuration);
01735 #else
01736 if (percent) {}
01737 QApplication::beep ();
01738 #endif
01739 }
01740
01741 void TGQt::CopyArea(Drawable_t src, Drawable_t dest, GContext_t gc,
01742 Int_t src_x, Int_t src_y, UInt_t width,
01743 UInt_t height, Int_t dest_x, Int_t dest_y)
01744 {
01745
01746
01747
01748 assert(qtcontext(gc).HasValid(QtGContext::kROp));
01749
01750 if ( dest && src) {
01751
01752 QPixmap *pix = dynamic_cast<QPixmap*>(iwid(src));
01753 QBitmap *mask = qtcontext(gc).fClipMask;
01754 if (pix && mask && (qtcontext(gc).fMask & QtGContext::kClipMask)) {
01755 if ((pix->width() != mask->width()) || (pix->height() != mask->height()))
01756 {
01757
01758
01759 QBitmap rightMask = mask->copy(pix->rect());
01760 pix->setMask(rightMask);
01761 } else {
01762 pix->setMask(*mask);
01763 }
01764 TQtPainter copyArea(iwid(dest),qtcontext(gc));
01765 if (src==dest) {
01766 QPixmap tmp = pix->copy(src_x,src_y,width,height);
01767 copyArea.drawPixmap(dest_x,dest_y, tmp);
01768 } else {
01769 copyArea.drawPixmap(dest_x,dest_y, *pix, src_x,src_y,width,height);
01770 }
01771 } else {
01772 if (pix) {
01773 TQtPainter copyArea(iwid(dest),qtcontext(gc));
01774 if (src==dest) {
01775 QPixmap tmp = pix->copy(src_x,src_y,width,height);
01776 copyArea.drawPixmap(dest_x,dest_y, tmp);
01777 } else {
01778 copyArea.drawPixmap(dest_x,dest_y,*pix, src_x,src_y,width,height);
01779 }
01780 } else {
01781 QImage *im = dynamic_cast<QImage*>(iwid(src));
01782 if (im) {
01783 TQtPainter copyArea(iwid(dest),qtcontext(gc));
01784 copyArea.drawImage(dest_x,dest_y,*im, src_x,src_y,width,height);
01785 } else {
01786 QWidget *qw = dynamic_cast<QWidget*>(iwid(src));
01787 if (qw) {
01788 QPixmap pixw = QPixmap::grabWidget(qw, QRect(src_x,src_y,width,height));
01789 TQtPainter copyArea(iwid(dest),qtcontext(gc));
01790 copyArea.drawPixmap(dest_x,dest_y,pixw, src_x,src_y,width,height);
01791 } else {
01792 qDebug() << " TGQt::CopyArea: illegal image source. Should be either QPixmap or QImage";
01793 }
01794 }
01795 }
01796 }
01797 }
01798 }
01799
01800 void TGQt::ChangeWindowAttributes(Window_t id, SetWindowAttributes_t *attr)
01801 {
01802
01803
01804 if (!attr || (id == kNone) || (id == kDefault) ) return;
01805
01806 TQtClientWidget *p = dynamic_cast<TQtClientWidget *>(wid(id));
01807 assert(p);
01808 TQtClientWidget &f = *p;
01809
01810 if ( attr->fMask & kWABackPixmap) {
01811 switch (attr->fBackgroundPixmap) {
01812 case kNone:
01813 case kParentRelative:
01814 break;
01815 default:
01816 f.setErasePixmap (*(QPixmap *)attr->fBackgroundPixmap);
01817 break;
01818 };
01819 }
01820 if ( attr->fMask & kWABackPixel) {
01821
01822 f.setEraseColor(QtColor(attr->fBackgroundPixel));
01823 }
01824 if ( attr->fMask & kWABorderPixmap) {
01825
01826 }
01827 if ( attr->fMask & kWABorderPixel) {
01828
01829
01830 #if QT_VERSION < 0x40000
01831 f.setFrameStyle( QFrame::Box | QFrame::Plain );
01832 #else
01833 f.setFrameStyle( QFrame::Box );
01834 #endif
01835
01836 }
01837 if ( attr->fMask & kWABorderWidth) {
01838
01839 f.setLineWidth(attr->fBorderWidth);
01840
01841 }
01842 if ( attr->fMask & kWABitGravity) {
01843
01844 }
01845 if ( attr->fMask & kWAWinGravity) {
01846
01847 }
01848 if ( attr->fMask & kWABackingStore) {
01849
01850 }
01851 if ( attr->fMask & kWABackingPlanes) {
01852
01853 }
01854 if ( attr->fMask & kWABackingPixel) {
01855
01856 }
01857 if ( attr->fMask & kWAOverrideRedirect) {
01858
01859 }
01860 if ( attr->fMask & kWASaveUnder) {
01861
01862 }
01863 if ( attr->fMask & kWAEventMask) {
01864
01865 f.SetAttributeEventMask(attr->fEventMask);
01866 }
01867 if ( attr->fMask & kWADontPropagate) {
01868
01869 }
01870 if ( attr->fMask & kWAColormap) {
01871
01872 }
01873 if ( attr->fMask & kWACursor) {
01874
01875 if (fCursor != kNone) f.setCursor(*fCursors[fCursor]);
01876 else f.setCursor(QCursor(Qt::BlankCursor));
01877 }
01878 }
01879
01880 void TGQt::ChangeProperty(Window_t, Atom_t, Atom_t, UChar_t *, Int_t) { }
01881
01882 void TGQt::DrawLine(Drawable_t id, GContext_t gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
01883 {
01884
01885 TQtPainter p(iwid(id),qtcontext(gc));
01886 p.drawLine ( x1, y1, x2, y2 );
01887 }
01888
01889 void TGQt::ClearArea(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h)
01890 {
01891
01892 if (id == kNone || id == kDefault ) return;
01893 QPainter paint(iwid(id));
01894 paint.setBackgroundMode( Qt::OpaqueMode);
01895 TQtClientWidget *wd = dynamic_cast<TQtClientWidget*>(wid(id));
01896 const QColor *c = 0;
01897 const QPixmap *p = 0;
01898 #if QT_VERSION < 0x50000
01899 c = wd ? wd->fEraseColor : 0;
01900 p = wd ? wd->fErasePixmap : 0;
01901 const QColor &cr = *c;
01902 const QPixmap &pr = *p;
01903 #else
01904 const QColor &cr = wd ? wd->palette().color(QPalette::Window) : *c;
01905 c = wd ? &cr : 0;
01906 const QPixmap &pr = *p;
01907 #endif
01908 if (int(w) <=0) {
01909 qDebug() << "TGQt::ClearArea: *** wrong client are size: " << w <<" : " << Int_t(w);
01910 return;
01911 }
01912 if (p && c)
01913 paint.fillRect ( x, y, w, h, QBrush(cr,pr));
01914 else if (p)
01915 paint.fillRect ( x, y, w, h, QBrush(pr));
01916 else if (c)
01917 paint.fillRect ( x, y, w, h, cr);
01918 else {
01919 const QBrush &crw = wd->palette().brush(QPalette::Window);
01920 paint.fillRect ( x, y, w, h, crw);
01921 }
01922
01923 }
01924
01925 Bool_t TGQt::CheckEvent(Window_t, EGEventType, Event_t &)
01926 {
01927
01928
01929
01930
01931 return kFALSE;
01932 }
01933
01934 void TGQt::SendEvent(Window_t id, Event_t *ev)
01935 {
01936
01937
01938 if (ev && (ev->fType == kClientMessage || ev->fType == kDestroyNotify) && id != kNone )
01939 {
01940 TQUserEvent qEvent(*ev);
01941 static TQtClientWidget *gMessageDispatcherWidget = 0;
01942 if (!gMessageDispatcherWidget) {
01943 gMessageDispatcherWidget = fQClientGuard.Create(0,"messager");
01944 if (QClientFilter()) {
01945 gMessageDispatcherWidget->installEventFilter(QClientFilter());
01946 }
01947 }
01948 QObject * receiver = 0;
01949 if ( id != kDefault) {
01950 receiver = wid(id);
01951 } else {
01952 receiver = gMessageDispatcherWidget;
01953
01954 }
01955
01956
01957 QApplication::postEvent(receiver,new TQUserEvent(*ev));
01958 } else {
01959 if (ev) fprintf(stderr,"TQt::SendEvent:: unknown event %d for widget: %p\n",ev->fType,wid(id));
01960 }
01961 }
01962
01963 void TGQt::WMDeleteNotify(Window_t id)
01964 {
01965
01966 if (id == kNone || id == kDefault ) return;
01967 ((TQtClientWidget *)wid(id))->SetDeleteNotify();
01968
01969 }
01970
01971 void TGQt::SetKeyAutoRepeat(Bool_t) { }
01972
01973 void TGQt::GrabKey(Window_t id, Int_t keycode, UInt_t modifier, Bool_t grab)
01974 {
01975
01976
01977
01978
01979
01980
01981
01982 if (id == kNone) return;
01983
01984 if (grab ) {
01985 ((TQtClientWidget*)wid(id))->SetKeyMask(keycode,modifier);
01986 } else {
01987 ((TQtClientWidget*)wid(id))->UnSetKeyMask(keycode,modifier);
01988 }
01989 }
01990
01991 void TGQt::GrabButton(Window_t id, EMouseButton button, UInt_t modifier,
01992 UInt_t evmask, Window_t confine, Cursor_t cursor,
01993 Bool_t grab)
01994 {
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011 if (id == kNone) return;
02012 assert(confine==kNone);
02013 if (grab ) {
02014
02015 ((TQtClientWidget*)wid(id))->SetButtonMask(modifier,button);
02016 ((TQtClientWidget*)wid(id))->SetButtonEventMask(evmask,cursor);
02017 } else {
02018 ((TQtClientWidget*)wid(id))->UnSetButtonMask();
02019 }
02020 }
02021
02022
02023 void TGQt::GrabPointer(Window_t id, UInt_t evmask, Window_t confine,
02024 Cursor_t cursor, Bool_t grab, Bool_t owner_events)
02025 {
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047 assert(confine==kNone);
02048 TQtClientWidget *gw = (id == kNone) ? 0: cwid(id);
02049
02050 if (grab) {
02051 if ( !gw ) return;
02052 fPointerGrabber = gw;
02053
02054 } else {
02055 if (!gw) gw = fPointerGrabber;
02056
02057
02058 fPointerGrabber = 0;
02059 }
02060 TQtClientFilter *f = QClientFilter();
02061 if (f)
02062 f->GrabPointer(gw, evmask,0,(QCursor *)cursor, grab, owner_events);
02063 }
02064
02065 void TGQt::SetWindowName(Window_t id, char *name)
02066 {
02067
02068 if (id == kNone || id == kDefault ) return;
02069 winid(id)->setWindowTitle(name);
02070 }
02071
02072 void TGQt::SetIconName(Window_t id, char *name)
02073 {
02074
02075 if (id == kNone || id == kDefault ) return;
02076 winid(id)-> setWindowIconText(name);
02077 }
02078
02079 void TGQt::Warp(Int_t ix, Int_t iy, Window_t id) {
02080
02081
02082
02083
02084
02085 if (id == kNone) {}
02086 else {
02087 QCursor::setPos(wid(id)->mapToGlobal(QPoint(ix,iy)));
02088 }
02089 }
02090
02091 void TGQt::SetClassHints(Window_t, char *, char *)
02092 {
02093
02094 #ifdef QTDEBUG
02095 fprintf(stderr,"No implementation: TGQt::SetClassHints(Window_t, char *, char *)\n");
02096 #endif
02097 }
02098
02099 void TGQt::SetMWMHints(Window_t id, UInt_t , UInt_t ,
02100 UInt_t )
02101 {
02102
02103
02104
02105
02106
02107 enum EMWMHints {
02108
02109 kMWMFuncAll = BIT(0),
02110 kMWMFuncResize = BIT(1),
02111 kMWMFuncMove = BIT(2),
02112 kMWMFuncMinimize = BIT(3),
02113 kMWMFuncMaximize = BIT(4),
02114 kMWMFuncClose = BIT(5),
02115
02116
02117 kMWMInputModeless = 0,
02118 kMWMInputPrimaryApplicationModal = 1,
02119 kMWMInputSystemModal = 2,
02120 kMWMInputFullApplicationModal = 3,
02121
02122
02123 kMWMDecorAll = BIT(0),
02124 kMWMDecorBorder = BIT(1),
02125 kMWMDecorResizeH = BIT(2),
02126 kMWMDecorTitle = BIT(3),
02127 kMWMDecorMenu = BIT(4),
02128 kMWMDecorMinimize = BIT(5),
02129 kMWMDecorMaximize = BIT(6)
02130 };
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144 if (id == kNone || id == kDefault ) return;
02145
02146
02147 #ifdef QTDEBUG
02148 fprintf(stderr,"No implementation: TGQt::SetMWMHints(Window_t, UInt_t, UInt_t, UInt_t)\n");
02149 #endif
02150 }
02151
02152 void TGQt::SetWMPosition(Window_t id, Int_t x, Int_t y)
02153 {
02154
02155 if (id == kNone || id == kDefault ) return;
02156 #ifdef QTDEBUG
02157 fprintf(stderr,"No implementation: TGQt::SetWMPosition(Window_t id, Int_t x=%d, Int_t y=%d\n",x,y);
02158 #endif
02159 wid(id)->move(x,y);
02160 }
02161
02162 void TGQt::SetWMSize(Window_t id, UInt_t w, UInt_t h)
02163 {
02164
02165
02166
02167
02168 if (id == kNone || id == kDefault ) return;
02169
02170 wid(id)->setBaseSize(int(w),int(h));
02171
02172
02173
02174 }
02175
02176 void TGQt::SetWMSizeHints(Window_t id, UInt_t wmin, UInt_t hmin,
02177 UInt_t wmax, UInt_t hmax,
02178 UInt_t winc, UInt_t hinc)
02179 {
02180
02181
02182
02183
02184
02185
02186
02187 if (id == kNone || id == kDefault ) return;
02188 QWidget &w = *wid(id);
02189 w.setMinimumSize ( int(wmin), int(hmin) );
02190 w.setMaximumSize ( int(wmax), int(hmax) );
02191 w.setSizeIncrement( int(winc), int(hinc) );
02192 }
02193
02194 void TGQt::SetWMState(Window_t id, EInitialState )
02195 {
02196
02197
02198 if (id == kNone || id == kDefault ) return;
02199 #ifdef QTDEBUG
02200 fprintf(stderr,"No implementation: TGQt::SetWMState( . . . )\n");
02201 #endif
02202 }
02203
02204 void TGQt::SetWMTransientHint(Window_t id, Window_t )
02205 {
02206
02207
02208
02209 if (id == kNone || id == kDefault ) return;
02210 #ifdef QTDEBUG
02211 fprintf(stderr,"No implementation: TGQt::SetWMTransientHint( . . . )\n");
02212 #endif
02213 }
02214
02215 void TGQt::DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
02216 const char *s, Int_t len)
02217 {
02218
02219 if (id == kNone) return;
02220
02221 if (s && s[0] && len) {
02222 TQtPainter paint(iwid(id),qtcontext(gc));
02223
02224 QPalette pl = qtcontext(gc).palette();
02225 const QColor &fontColor = pl.color(QPalette::WindowText);
02226 paint.setPen(fontColor);
02227 paint.setBrush(fontColor);
02228 if (qtcontext(gc).fFont) paint.setFont(*qtcontext(gc).fFont);
02229
02230 paint.drawText (x, y, GetTextDecoder()->toUnicode(s).left(len));
02231 }
02232 }
02233
02234 Int_t TGQt::TextWidth(FontStruct_t font, const char *s, Int_t len)
02235 {
02236
02237
02238 Int_t textWidth = 0;
02239 if (len >0 && s && s[0] != 0 ) {
02240 QFontMetrics metric(*(QFont *)font);
02241 char* str = new char[len+1];
02242 memcpy(str,s,len); str[len]=0;
02243 QString qstr(s);
02244 delete [] str;
02245 textWidth = metric.width(qstr,len);
02246
02247 }
02248 return textWidth;
02249 }
02250
02251 void TGQt::GetFontProperties(FontStruct_t fs, Int_t &max_ascent, Int_t &max_descent)
02252 {
02253
02254
02255
02256
02257
02258 QFontMetrics metrics(*(QFont *)fs);
02259 max_ascent = metrics.ascent ();
02260 max_descent = metrics.descent();
02261 }
02262
02263 void TGQt::GetGCValues(GContext_t gc, GCValues_t &gval)
02264 {
02265
02266
02267
02268
02269 assert(gval.fMask == kGCFont);
02270 gval.fFont = (FontStruct_t)qtcontext(gc).fFont;
02271 }
02272
02273 FontStruct_t TGQt::GetFontStruct(FontH_t fh) { return (FontStruct_t)fh; }
02274
02275 void TGQt::ClearWindow(Window_t id)
02276 {
02277
02278 if (id == kNone || id == kDefault ) return;
02279 QPainter paint(iwid(id));
02280 paint.setBackgroundMode( Qt::OpaqueMode);
02281 TQtClientWidget *wd = dynamic_cast<TQtClientWidget*>(wid(id));
02282 const QColor *c = 0;
02283 const QPixmap *p = 0;
02284 #if QT_VERSION < 0x50000
02285 c = wd ? wd->fEraseColor : 0;
02286 p = wd ? wd->fErasePixmap : 0;
02287 const QColor &cr = *c;
02288 const QPixmap &pr = *p;
02289 #else
02290 const QColor &cr = wd ? wd->palette().color(QPalette::Window) : *c;
02291 c = wd ? &cr : 0;
02292 const QPixmap &pr = *p;
02293 #endif
02294 if (p && c )
02295 paint.fillRect(wd->rect(),QBrush(cr,pr));
02296 else if (p)
02297 paint.fillRect(wd->rect(),QBrush(pr));
02298 else if (c)
02299 paint.fillRect(wd->rect(), cr);
02300 else {
02301 const QBrush &brw = wd->palette().brush(QPalette::Window);
02302 paint.fillRect ( wd->rect(), brw);
02303 }
02304 }
02305
02306
02307 struct KeyQSymbolMap_t {
02308 Qt::Key fQKeySym;
02309 EKeySym fKeySym;
02310 };
02311
02312
02313
02314
02315 static KeyQSymbolMap_t gKeyQMap[] = {
02316 {Qt::Key_Escape, kKey_Escape},
02317 {Qt::Key_Tab, kKey_Tab},
02318 {Qt::Key_Backtab, kKey_Backtab},
02319 {Qt::Key_Backspace, kKey_Backspace},
02320 {Qt::Key_Return, kKey_Return},
02321 {Qt::Key_Insert, kKey_Insert},
02322 {Qt::Key_Delete, kKey_Delete},
02323 {Qt::Key_Pause, kKey_Pause},
02324 {Qt::Key_Print, kKey_Print},
02325 {Qt::Key_SysReq, kKey_SysReq},
02326 {Qt::Key_Home, kKey_Home},
02327 {Qt::Key_End, kKey_End},
02328 {Qt::Key_Left, kKey_Left},
02329 {Qt::Key_Up, kKey_Up},
02330 {Qt::Key_Right, kKey_Right},
02331 {Qt::Key_Down, kKey_Down},
02332 {Qt::Key_PageUp, kKey_Prior},
02333 {Qt::Key_PageDown, kKey_Next},
02334 {Qt::Key_Shift, kKey_Shift},
02335 {Qt::Key_Control, kKey_Control},
02336 {Qt::Key_Meta, kKey_Meta},
02337 {Qt::Key_Alt, kKey_Alt},
02338 {Qt::Key_CapsLock, kKey_CapsLock},
02339 {Qt::Key_NumLock , kKey_NumLock},
02340 {Qt::Key_ScrollLock, kKey_ScrollLock},
02341 {Qt::Key_Space, kKey_Space},
02342 {Qt::Key_Tab, kKey_Tab},
02343 {Qt::Key_Enter, kKey_Enter},
02344 {Qt::Key_Equal, kKey_Equal},
02345 {Qt::Key_F1, kKey_F1 },
02346 {Qt::Key_F2, kKey_F2 },
02347 {Qt::Key_F3, kKey_F3 },
02348 {Qt::Key_F4, kKey_F4 },
02349 {Qt::Key_PageUp, kKey_PageUp },
02350 {Qt::Key_PageDown, kKey_PageDown },
02351 {Qt::Key(0), (EKeySym) 0}
02352 };
02353
02354 static inline Int_t MapKeySym(int key, bool toQt=true)
02355 {
02356 for (int i = 0; gKeyQMap[i].fKeySym; i++) {
02357 if (toQt) {
02358 if (key == gKeyQMap[i].fKeySym ) {
02359 return UInt_t(gKeyQMap[i].fQKeySym);
02360 }
02361 } else {
02362 if (key == gKeyQMap[i].fQKeySym) {
02363 return UInt_t(gKeyQMap[i].fKeySym);
02364 }
02365 }
02366 }
02367 #if 0
02368 UInt_t text;
02369 QByteArray r = gQt->GetTextDecoder()->fromUnicode(qev.text());
02370 qstrlcpy((char *)&text, (const char *)r,1);
02371 return text;
02372 #else
02373 return key;
02374 #endif
02375 }
02376
02377 Int_t TGQt::KeysymToKeycode(UInt_t keysym) {
02378
02379
02380
02381 return Int_t(MapKeySym(keysym));
02382 }
02383
02384 void TGQt::FillRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
02385 UInt_t w, UInt_t h)
02386 {
02387 if (id == kNone) return;
02388
02389 TQtPainter paint(iwid(id),qtcontext(gc));
02390 if (qtcontext(gc).HasValid(QtGContext::kTileRect) ) {
02391 paint.drawTiledPixmap(x,y,w,h,*qtcontext(gc).fTilePixmap);
02392 } else {
02393 if (qtcontext(gc).HasValid(QtGContext::kStipple)) {
02394
02395 if (qtcontext(gc).HasValid(QtGContext::kBrush) ) {
02396
02397
02398 QPalette pl = qtcontext(gc).palette();
02399 const QColor &fontColor = pl.color(QPalette::WindowText);
02400 paint.setPen(fontColor);
02401 } else {
02402 paint.setBackground(Qt::white);
02403 paint.setPen(Qt::black);
02404 }
02405 paint.setBackgroundMode( Qt::OpaqueMode);
02406 }
02407
02408 if (qtcontext(gc).fBrush.style() == Qt::NoBrush) qtcontext(gc).fBrush.setStyle(Qt::SolidPattern);
02409 paint.fillRect ( x, y, w, h, qtcontext(gc).fBrush );
02410 }
02411 }
02412
02413 void TGQt::DrawRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
02414 UInt_t w, UInt_t h)
02415 {
02416 if (id == kNone) return;
02417
02418 TQtPainter paint(iwid(id),qtcontext(gc));
02419 paint.setBrush(Qt::NoBrush);
02420 paint.drawRect ( x, y, w, h);
02421 }
02422
02423 void TGQt::DrawSegments(Drawable_t id, GContext_t gc, Segment_t * seg, Int_t nseg)
02424 {
02425
02426 if (id == kNone) return;
02427 TQtPainter paint(iwid(id),qtcontext(gc));
02428 QVector<QLine> segments(nseg);
02429 for (int i=0;i<nseg;i++)
02430 segments.push_back(QLine(seg[i].fX1, seg[i].fY1,seg[i].fX2, seg[i].fY2));
02431 paint.drawLines (segments);
02432 }
02433
02434 void TGQt::SelectInput(Window_t id, UInt_t evmask)
02435 {
02436
02437
02438
02439
02440
02441
02442
02443
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478
02479
02480
02481 ((TQtClientWidget*)wid(id))->SelectInput(evmask);
02482 }
02483
02484 Window_t TGQt::GetInputFocus()
02485 {
02486
02487 TQtClientWidget *focus = 0;
02488 QWidget *f = qApp->focusWidget ();
02489 if (f) {
02490 focus = dynamic_cast<TQtClientWidget*>(f);
02491 if (!focus) return 0;
02492 }
02493 return wid(focus);
02494 }
02495
02496 void TGQt::SetInputFocus(Window_t id)
02497 {
02498
02499 if (id == kNone || id == kDefault ) return;
02500 wid(id)->setFocus ();
02501 }
02502
02503 void TGQt::LookupString(Event_t *ev, char *tmp, Int_t , UInt_t &keysym)
02504 {
02505
02506
02507
02508
02509
02510 keysym = ev->fCode;
02511
02512
02513 if (ev->fState & kKeyControlMask) keysym -= keysym > 'Z' ? 96 :64;
02514
02515 *tmp = keysym; tmp++;
02516 *tmp = '\0';
02517 }
02518
02519 void TGQt::TranslateCoordinates(Window_t src, Window_t dest,
02520 Int_t src_x, Int_t src_y,
02521 Int_t & dest_x, Int_t & dest_y,
02522 Window_t & child)
02523 {
02524
02525
02526
02527
02528 QWidget *wSrc = wid(src);
02529 QWidget *wDst = wid(dest);
02530 child = kNone;
02531
02532 Int_t destX;
02533 Int_t destY;
02534
02535 if (!wSrc) wSrc = QApplication::desktop();
02536 if (!wDst) wDst = QApplication::desktop();
02537 assert(wSrc && wDst);
02538 if (src == dest) {
02539 destX = src_x; destY= src_y;
02540 } else {
02541 QPoint mapped = wDst->mapFromGlobal(wSrc->mapToGlobal(QPoint(src_x,src_y)));
02542 destX = mapped.x(); destY = mapped.y();
02543 }
02544 TQtClientWidget* tmpW = dynamic_cast<TQtClientWidget*>(wDst->childAt ( destX, destY));
02545 if (tmpW) {
02546 child = wid(tmpW);
02547 }
02548 dest_x = destX; dest_y = destY;
02549
02550 }
02551
02552 void TGQt::GetWindowSize(Drawable_t id, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
02553 {
02554
02555
02556
02557 x = y = 0;
02558 if (id == kNone || id == kDefault )
02559 {
02560 QDesktopWidget *d = QApplication::desktop();
02561 w = d->width();
02562 h = d->height();
02563 } else {
02564 QPixmap *thePix = dynamic_cast<QPixmap*>(iwid(id) );
02565 if (thePix) {
02566
02567 w = thePix->width();
02568 h = thePix->height();
02569 } else {
02570 TQtClientWidget* theWidget = dynamic_cast<TQtClientWidget*>( wid(id) );
02571 if (theWidget) {
02572 const QRect &gWidget=theWidget->frameGeometry ();
02573
02574 x = gWidget.x();
02575 y = gWidget.y();
02576 w = gWidget.width();
02577 h = gWidget.height();
02578 } else {
02579 QDesktopWidget *d = QApplication::desktop();
02580 w = d->width();
02581 h = d->height();
02582 }
02583 }
02584 }
02585 }
02586
02587 void TGQt::FillPolygon(Window_t id, GContext_t gc, Point_t *points, Int_t npnt)
02588 {
02589
02590
02591
02592
02593
02594
02595 if (id == kNone) return;
02596 if (npnt > 1) {
02597 TQtPainter paint(iwid(id),qtcontext(gc));
02598 #if QT_VERSION < 0x40000
02599 QPointArray pa(npnt);
02600 #else
02601 QPolygon pa(npnt);
02602 #endif
02603 Int_t x = points[0].fX;
02604 Int_t y = points[0].fY;
02605 pa.setPoint(0,x,y);
02606 for (int i=1;i<npnt;i++) pa.setPoint(i,points[i].fX,points[i].fY);
02607 paint.drawConvexPolygon (pa);
02608 }
02609 }
02610
02611 void TGQt::QueryPointer(Window_t id, Window_t &rootw, Window_t &childw,
02612 Int_t &root_x, Int_t &root_y, Int_t &win_x,
02613 Int_t &win_y, UInt_t &mask)
02614 {
02615
02616 if (id == kNone) return;
02617
02618 QPoint position = QCursor::pos();
02619 QWidget *thisWidget = wid(id);
02620 QWidget *topWiget = thisWidget->topLevelWidget();
02621
02622
02623
02624 QPoint rootPosition = topWiget->mapFromGlobal( position );
02625 root_x = rootPosition.x(); root_y = rootPosition.y();
02626 rootw = rootwid(topWiget);
02627
02628
02629
02630 QPoint win_pos = thisWidget->mapFromGlobal( position );
02631 win_x = win_pos.x(); win_y = win_pos.y();
02632
02633 TQtClientWidget *ch = (TQtClientWidget * )thisWidget->childAt (win_x,win_y);
02634 childw = ch ? wid(ch): kNone;
02635
02636
02637
02638
02639
02640
02641
02642
02643
02644
02645
02646
02647
02648
02649
02650
02651
02652 mask = 0;
02653 }
02654
02655 void TGQt::SetBackground(GContext_t gc, ULong_t background)
02656 {
02657
02658
02659
02660
02661 qtcontext(gc).SetBackground(background);
02662 }
02663
02664
02665 void TGQt::SetForeground(GContext_t gc, ULong_t foreground)
02666 {
02667
02668
02669
02670
02671 qtcontext(gc).SetForeground(foreground);
02672 }
02673
02674 void TGQt::SetClipRectangles(GContext_t gc, Int_t x, Int_t y,
02675 Rectangle_t * recs, Int_t n)
02676 {
02677
02678
02679
02680
02681 if (n <=0 ) return;
02682 Region_t clip = CreateRegion();
02683 for (int i=0;i<n;i++)
02684 UnionRectWithRegion(recs,clip,clip);
02685 ((QRegion *)clip)->translate(x,y);
02686 qtcontext(gc).fClipRegion = *(QRegion *)clip;
02687 SETBIT(qtcontext(gc).fMask,QtGContext::kClipRegion);
02688 DestroyRegion(clip);
02689 }
02690
02691 void TGQt::Update(Int_t mode)
02692 {
02693
02694
02695
02696 if (mode)
02697 #ifdef R__QTX11
02698 QApplication::syncX (); else
02699 #else
02700 {}
02701 #endif
02702 QApplication::flush ();
02703 }
02704
02705
02706
02707
02708
02709
02710
02711
02712 Region_t TGQt::CreateRegion()
02713 {
02714
02715
02716 QRegion *reg = new QRegion();
02717 return (Region_t) reg;
02718 }
02719
02720 void TGQt::DestroyRegion(Region_t reg)
02721 {
02722
02723
02724 delete (QRegion*) reg;
02725 }
02726
02727 void TGQt::UnionRectWithRegion(Rectangle_t *rect, Region_t src, Region_t dest)
02728 {
02729
02730
02731 if( !rect || src == 0 || dest == 0 )
02732 return;
02733
02734 QRegion rc(QRect( rect->fX, rect->fY, rect->fWidth, rect->fHeight ));
02735 QRegion &rSrc = *(QRegion*) src;
02736 QRegion &rDest = *(QRegion*) dest;
02737
02738 rDest = rSrc + rc;
02739 }
02740
02741 Region_t TGQt::PolygonRegion(Point_t *points, Int_t np, Bool_t winding)
02742 {
02743
02744
02745 if( np<0 || !points )
02746 return 0;
02747
02748 QPolygon pa;
02749 pa.resize( np );
02750 for(int i=0; i<np; i++)
02751 pa.setPoint( i, points[i].fX, points[i].fY );
02752
02753 return (Region_t) new QRegion( pa, winding?Qt::WindingFill:Qt::OddEvenFill );
02754 }
02755
02756 void TGQt::UnionRegion(Region_t rega, Region_t regb, Region_t result)
02757 {
02758
02759
02760
02761 if( !rega || !regb || !result )
02762 return;
02763
02764 QRegion& a = *(QRegion*) rega;
02765 QRegion& b = *(QRegion*) regb;
02766 QRegion& r = *(QRegion*) result;
02767
02768 r = a + b;
02769 }
02770
02771 void TGQt::IntersectRegion(Region_t rega, Region_t regb, Region_t result)
02772 {
02773
02774
02775
02776 if( !rega || !regb || !result )
02777 return;
02778
02779 QRegion& a = *(QRegion*) rega;
02780 QRegion& b = *(QRegion*) regb;
02781 QRegion& r = *(QRegion*) result;
02782
02783 r = a & b;
02784 }
02785
02786 void TGQt::SubtractRegion(Region_t rega, Region_t regb, Region_t result)
02787 {
02788
02789
02790 if( !rega || !regb || !result )
02791 return;
02792
02793 QRegion& a = *(QRegion*) rega;
02794 QRegion& b = *(QRegion*) regb;
02795 QRegion& r = *(QRegion*) result;
02796
02797 r = a - b;
02798 }
02799
02800 void TGQt::XorRegion(Region_t rega, Region_t regb, Region_t result)
02801 {
02802
02803
02804 if( !rega || !regb || !result )
02805 return;
02806
02807 QRegion& a = *(QRegion*) rega;
02808 QRegion& b = *(QRegion*) regb;
02809 QRegion& r = *(QRegion*) result;
02810
02811 r = a ^ b;
02812 }
02813
02814 Bool_t TGQt::EmptyRegion(Region_t reg)
02815 {
02816
02817
02818 if( !reg )
02819 return true;
02820
02821 QRegion& r = *(QRegion*) reg;
02822
02823 return r.isEmpty();
02824 }
02825
02826 Bool_t TGQt::PointInRegion(Int_t x, Int_t y, Region_t reg)
02827 {
02828
02829 if( !reg )
02830 return false;
02831
02832 QRegion& r = *(QRegion*) reg;
02833 return r.contains( QPoint(x, y) );
02834 }
02835
02836 Bool_t TGQt::EqualRegion(Region_t rega, Region_t regb)
02837 {
02838
02839
02840 if( !rega || !regb )
02841 return false;
02842
02843 QRegion& a = *(QRegion*) rega;
02844 QRegion& b = *(QRegion*) regb;
02845
02846 return (a == b);
02847 }
02848
02849 void TGQt::GetRegionBox(Region_t reg, Rectangle_t *rect)
02850 {
02851
02852
02853 if( !reg || !rect )
02854 return;
02855
02856 QRegion& r = *(QRegion*) reg;
02857 QRect rc = r.boundingRect();
02858
02859 rect->fX = rc.x();
02860 rect->fY = rc.y();
02861 rect->fWidth = rc.width();
02862 rect->fHeight = rc.height();
02863 }
02864
02865 char **TGQt::ListFonts(const char *fontname, Int_t max, Int_t &count)
02866 {
02867
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906
02907
02908
02909
02910
02911
02912
02913
02914
02915
02916
02917
02918
02919
02920
02921
02922
02923
02924
02925
02926
02927
02928
02929
02930
02931 count = 0;
02932 TXlfd patternFont(fontname);
02933 QFontDatabase fdb;
02934 QStringList xlFonts;
02935 QStringList families = fdb.families();
02936 for ( QStringList::Iterator f = families.begin(); f != families.end(); ++f ) {
02937 QString family = *f;
02938 QStringList styles = fdb.styles( family );
02939 for ( QStringList::Iterator s = styles.begin(); s != styles.end(); ++s ) {
02940 QString style = *s;
02941
02942 Int_t bold = fdb.bold (family, style);
02943 Int_t italic = fdb.italic(family, style);
02944 TXlfd currentFont(family,bold,italic);
02945 if (currentFont != patternFont) continue;
02946
02947 QList<int> sizes = fdb.pointSizes( family, style );
02948 for ( int points=0 ; points < sizes.size()
02949 && (Int_t)xlFonts.size() < max; ++points )
02950 {
02951 currentFont.SetPointSize(sizes[points]);
02952 if (currentFont == patternFont ) xlFonts.push_back(currentFont.ToString());
02953 }
02954 }
02955 }
02956 count = xlFonts.size();
02957 char **listFont = 0;
02958 if (count) {
02959 char **list = listFont = new char*[count+1]; list[count] = 0;
02960 for ( QStringList::Iterator it = xlFonts.begin(); it != xlFonts.end(); ++it ) {
02961 int fntln = (*it).length();
02962 char *nextFont = new char[fntln+1];
02963 *list = nextFont; list++;
02964 memcpy(nextFont,(*it).toStdString().c_str(),fntln);
02965 nextFont[fntln]=0;
02966 }
02967 }
02968 return listFont;
02969 }
02970
02971
02972 void TGQt::FreeFontNames(char ** fontlist)
02973 {
02974
02975
02976 char ** list = fontlist;
02977 while (*list) { delete [] *list; list++; }
02978 delete [] fontlist;
02979 }
02980
02981
02982 Drawable_t TGQt::CreateImage(UInt_t width, UInt_t height)
02983 {
02984
02985
02986
02987
02988
02989 QImage *image = new QImage(width,height,QImage::Format_ARGB32);
02990 return Drawable_t(image);
02991 }
02992
02993
02994 void TGQt::GetImageSize(Drawable_t id, UInt_t &width, UInt_t &height)
02995 {
02996
02997 QImage *image = (QImage *)id;
02998 if (image) {
02999 width = image->width();
03000 height = image->height();
03001 }
03002 }
03003
03004
03005 void TGQt::PutPixel(Drawable_t id, Int_t x, Int_t y, ULong_t pixel)
03006 {
03007
03008
03009
03010
03011
03012
03013
03014 QImage *image = (QImage *)id;
03015 if (image) image->setPixel(x,y,QtColor(pixel).rgb());
03016 }
03017
03018
03019 void TGQt::PutImage(Drawable_t id, GContext_t gc,Drawable_t img, Int_t dx, Int_t dy,
03020 Int_t x, Int_t y, UInt_t w, UInt_t h)
03021 {
03022
03023
03024
03025
03026
03027
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038
03039
03040 const QImage *image = (QImage *)img;
03041 if (image) {
03042 TQtPainter pnt(iwid(id),qtcontext(gc));
03043 Qt::ImageConversionFlag conversionFlags=Qt::AutoColor;
03044 pnt.drawImage(dx,dy, *image, x,y,w,h,conversionFlags);
03045
03046
03047
03048
03049
03050
03051
03052
03053
03054
03055
03056
03057
03058
03059
03060
03061
03062
03063
03064
03065
03066
03067
03068
03069
03070
03071
03072
03073
03074
03075
03076
03077
03078
03079
03080
03081
03082
03083
03084
03085
03086 }
03087 }
03088
03089
03090 void TGQt::DeleteImage(Drawable_t img)
03091 {
03092
03093 delete (QImage *)img;
03094 }
03095
03096 #if ROOT_VERSION_CODE < ROOT_VERSION(4,01,02)
03097
03098 ULong_t TGQt::GetWinDC(Window_t wind)
03099 {
03100
03101 return (wind == kNone) ? 0 : ULong_t(wid(wind)->handle());
03102 }
03103 #endif
03104
03105
03106 Bool_t TGQt::IsHandleValid(Window_t )
03107 {
03108 return true;
03109
03110
03111
03112 }
03113
03114
03115 void TGQt::SendDestroyEvent(TQtClientWidget *widget) const
03116 {
03117
03118 Event_t destroyEvent;
03119 memset(&destroyEvent,0,sizeof(Event_t));
03120 destroyEvent.fType = kDestroyNotify;
03121 destroyEvent.fWindow = rootwid(widget);
03122 destroyEvent.fSendEvent = kTRUE;
03123 destroyEvent.fTime = QTime::currentTime().msec();
03124
03125
03126 ((TGQt *)this)->SendEvent(TGQt::kDefault,&destroyEvent);
03127 }
03128
03129
03130
03131
03132
03133
03134 unsigned char *TGQt::GetColorBits(Drawable_t rootWid, Int_t x, Int_t y, UInt_t w, UInt_t h)
03135 {
03136
03137
03138
03139
03140
03141
03142
03143
03144
03145 if (!rootWid || (int(rootWid) == -1) ) return 0;
03146
03147 QPaintDevice &dev = *iwid(rootWid);
03148 QPixmap *pix=0;
03149 switch (dev.devType()) {
03150 case QInternal::Widget:
03151 pix = ((TQtWidget*)&dev)->GetOffScreenBuffer();
03152 break;
03153
03154 case QInternal::Pixmap: {
03155 pix = (QPixmap *)&dev;
03156 break;
03157 }
03158 case QInternal::Picture:
03159 case QInternal::Printer:
03160
03161 default: assert(0);
03162 break;
03163 };
03164
03165 if (pix) {
03166
03167 QSize imageSize;
03168 if ( (h == w) && (w == UInt_t(-1) ) ) {
03169 w = pix->size().width();
03170 h = pix->size().height();
03171 }
03172 imageSize.setWidth(w);
03173 imageSize.setHeight(h);
03174
03175 QImage img(w,h,QImage::Format_ARGB32);
03176 QPainter p(&img);
03177 p.drawPixmap(QPoint(0,0),*pix,QRect(x,y,w,h));
03178 if (!img.isNull()) {
03179 UInt_t *bits = new UInt_t[w*h];
03180 UInt_t *ibits = (UInt_t *)img.bits();
03181
03182 int idx = y;
03183 int iii = 0;
03184 for (UInt_t j = 0; j < h; j++) {
03185 for (UInt_t i = 0; i < w; i++) {
03186 bits[iii + i] = ibits[idx + x + i];
03187 }
03188 idx += w;
03189 iii += w;
03190 }
03191 return (unsigned char *)bits;
03192 }
03193 }
03194
03195 return 0;
03196 }
03197
03198
03199
03200 Pixmap_t TGQt::CreatePixmapFromData(unsigned char * bits, UInt_t width,
03201 UInt_t height)
03202 {
03203
03204
03205
03206
03207
03208
03209 QImage img(bits, width, height, QImage::Format_ARGB32);
03210 QPixmap *p = new QPixmap(QPixmap::fromImage (img));
03211 fQPixmapGuard.Add(p);
03212 return Pixmap_t(rootwid(p));
03213 }
03214
03215
03216 Window_t TGQt::GetCurrentWindow() const
03217 {
03218
03219 fprintf(stderr, " Qt layer is not ready for GetCurrentWindow \n");
03220 assert(0);
03221
03222 return (Window_t)(fSelectedWindow);
03223 }
03224
03225
03226 Int_t TGQt::SupportsExtension(const char *extensionName) const
03227 {
03228
03229
03230
03231 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,27,1)
03232 return TVirtualX::SupportsExtension(extensionName);
03233 #else
03234 if (extensionName) {}
03235 return -1;
03236 #endif
03237 }
03238
03239
03240 void TGQt::DeleteProperty(Window_t, Atom_t&)
03241 {
03242
03243
03244
03245
03246 }
03247
03248
03249 Int_t TGQt::GetProperty(Window_t, Atom_t, Long_t, Long_t, Bool_t, Atom_t,
03250 Atom_t*, Int_t*, ULong_t*, ULong_t*, unsigned char**)
03251 {
03252
03253
03254
03255
03256
03257 return 0;
03258 }
03259
03260
03261 void TGQt::ChangeActivePointerGrab(Window_t, UInt_t, Cursor_t)
03262 {
03263
03264
03265
03266
03267 }
03268
03269
03270 void TGQt::ConvertSelection(Window_t, Atom_t&, Atom_t&, Atom_t&, Time_t&)
03271 {
03272
03273
03274
03275 }
03276
03277
03278 Bool_t TGQt::SetSelectionOwner(Window_t, Atom_t&)
03279 {
03280
03281
03282 return kFALSE;
03283 }
03284
03285
03286 void TGQt::ChangeProperties(Window_t, Atom_t, Atom_t, Int_t, UChar_t *, Int_t)
03287 {
03288
03289
03290
03291 }
03292
03293
03294 void TGQt::SetDNDAware(Window_t, Atom_t *)
03295 {
03296
03297
03298
03299 }
03300
03301
03302 void TGQt::SetTypeList(Window_t, Atom_t, Atom_t *)
03303 {
03304
03305
03306 }
03307
03308
03309 Window_t TGQt::FindRWindow(Window_t, Window_t, Window_t, int, int, int)
03310 {
03311
03312
03313
03314 return kNone;
03315 }
03316
03317
03318 Bool_t TGQt::IsDNDAware(Window_t, Atom_t *)
03319 {
03320
03321
03322
03323 return kFALSE;
03324 }
03325
03326
03327