Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QRasterWindowSurface Class Reference

#include <qwindowsurface_raster_p.h>

Inheritance diagram for QRasterWindowSurface:
QWindowSurface QTraceWindowSurface

Public Functions

void beginPaint (const QRegion &rgn)
 This function is called before painting onto the surface begins, with the region in which the painting will occur. More...
 
WindowSurfaceFeatures features () const
 
void flush (QWidget *widget, const QRegion &region, const QPoint &offset)
 Flushes the given region from the specified widget onto the screen. More...
 
QPaintDevicepaintDevice ()
 Implement this function to return the appropriate paint device. More...
 
 QRasterWindowSurface (QWidget *widget, bool setDefaultSurface=true)
 
bool scroll (const QRegion &area, int dx, int dy)
 Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative. More...
 
void setGeometry (const QRect &rect)
 Sets the currently allocated area to be the given rect. More...
 
 ~QRasterWindowSurface ()
 
- Public Functions inherited from QWindowSurface
virtual QImagebuffer (const QWidget *widget)
 Returns a QImage pointer which represents the actual buffer the widget is drawn into or 0 if this is unavailable. More...
 
virtual void endPaint (const QRegion &)
 This function is called after painting onto the surface has ended, with the region in which the painting was performed. More...
 
QRect geometry () const
 Returns the currently allocated area on the screen. More...
 
virtual QPixmap grabWidget (const QWidget *widget, const QRect &rectangle=QRect()) const
 Returns a QPixmap generated from the part of the backing store corresponding to widget. More...
 
bool hasFeature (WindowSurfaceFeature feature) const
 
virtual QPoint offset (const QWidget *widget) const
 Returns the offset of widget in the coordinates of this window surface. More...
 
 QWindowSurface (QWidget *window, bool setDefaultSurface=true)
 Constructs an empty surface for the given top-level window. More...
 
QRect rect (const QWidget *widget) const
 Returns the rectangle for widget in the coordinates of this window surface. More...
 
void setStaticContents (const QRegion &region)
 
QRegion staticContents () const
 
QWidgetwindow () const
 Returns a pointer to the top-level window associated with this surface. More...
 
virtual ~QWindowSurface ()
 Destroys this surface. More...
 

Private Functions

void prepareBuffer (QImage::Format format, QWidget *widget)
 
void syncX ()
 

Properties

QScopedPointer< QRasterWindowSurfacePrivated_ptr
 

Additional Inherited Members

- Public Types inherited from QWindowSurface
enum  WindowSurfaceFeature { PartialUpdates = 0x00000001, PreservedContents = 0x00000002, StaticContents = 0x00000004, AllFeatures = 0xffffffff }
 
- Protected Functions inherited from QWindowSurface
bool hasStaticContents () const
 

Detailed Description

Definition at line 101 of file qwindowsurface_raster_p.h.

Constructors and Destructors

◆ QRasterWindowSurface()

QRasterWindowSurface::QRasterWindowSurface ( QWidget widget,
bool  setDefaultSurface = true 
)

Definition at line 91 of file qwindowsurface_raster.cpp.

92  : QWindowSurface(window, setDefaultSurface), d_ptr(new QRasterWindowSurfacePrivate)
93 {
94 #ifdef Q_WS_X11
95  d_ptr->gc = XCreateGC(X11->display, window->handle(), 0, 0);
96 #ifndef QT_NO_XRENDER
97  d_ptr->translucentBackground = X11->use_xrender
98  && window->x11Info().depth() == 32;
99 #endif
100 #ifndef QT_NO_MITSHM
101  d_ptr->needsSync = false;
102 #endif
103 #endif
104  d_ptr->image = 0;
105  d_ptr->inSetGeometry = false;
106 
107 #ifdef QT_MAC_USE_COCOA
108  needsFlush = false;
109  regionToFlush = QRegion();
110 #endif // QT_MAC_USE_COCOA
111 }
int depth() const
Returns the color depth (bits per pixel) of the X display.
const QX11Info & x11Info() const
Returns information about the configuration of the X display used to display the widget.
#define X11
Definition: qt_x11_p.h:724
QScopedPointer< QRasterWindowSurfacePrivate > d_ptr
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QWindowSurface(QWidget *window, bool setDefaultSurface=true)
Constructs an empty surface for the given top-level window.
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.

◆ ~QRasterWindowSurface()

QRasterWindowSurface::~QRasterWindowSurface ( )

Definition at line 114 of file qwindowsurface_raster.cpp.

115 {
116 #ifdef Q_WS_X11
117  XFreeGC(X11->display, d_ptr->gc);
118 #endif
119  if (d_ptr->image)
120  delete d_ptr->image;
121 }
#define X11
Definition: qt_x11_p.h:724
QScopedPointer< QRasterWindowSurfacePrivate > d_ptr

Functions

◆ beginPaint()

void QRasterWindowSurface::beginPaint ( const QRegion region)
virtual

This function is called before painting onto the surface begins, with the region in which the painting will occur.

See also
endPaint(), paintDevice()

Reimplemented from QWindowSurface.

Reimplemented in QTraceWindowSurface.

Definition at line 140 of file qwindowsurface_raster.cpp.

Referenced by QTraceWindowSurface::beginPaint().

141 {
142 #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
143  syncX();
144 #endif
145 
146 #if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
147  if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) {
148 #if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
151 #endif
152  QPainter p(&d_ptr->image->image);
153  p.setCompositionMode(QPainter::CompositionMode_Source);
154  const QVector<QRect> rects = rgn.rects();
155  const QColor blank = Qt::transparent;
156  for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
157  p.fillRect(*it, blank);
158  }
159  }
160 #else
161  Q_UNUSED(rgn);
162 #endif
163 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
#define it(className, varName)
void prepareBuffer(QImage::Format format, QWidget *widget)
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:250
QScopedPointer< QRasterWindowSurfacePrivate > d_ptr
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:247
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.

◆ features()

QWindowSurface::WindowSurfaceFeatures QRasterWindowSurface::features ( ) const
virtual

Reimplemented from QWindowSurface.

Definition at line 415 of file qwindowsurface_raster.cpp.

◆ flush()

void QRasterWindowSurface::flush ( QWidget widget,
const QRegion region,
const QPoint offset 
)
virtual

Flushes the given region from the specified widget onto the screen.

Note that the offset parameter is currently unused.

Implements QWindowSurface.

Definition at line 165 of file qwindowsurface_raster.cpp.

166 {
168 
169  // Not ready for painting yet, bail out. This can happen in
170  // QWidget::create_sys()
171  if (!d->image || rgn.rectCount() == 0)
172  return;
173 
174 #ifdef Q_WS_WIN
175  QRect br = rgn.boundingRect();
176 
177 #ifndef Q_WS_WINCE
178  if (!qt_widget_private(window())->isOpaque
179  && window()->testAttribute(Qt::WA_TranslucentBackground)
180  && (qt_widget_private(window())->data.window_flags & Qt::FramelessWindowHint))
181  {
182  QRect r = window()->frameGeometry();
183  QPoint frameOffset = qt_widget_private(window())->frameStrut().topLeft();
184  QRect dirtyRect = br.translated(offset + frameOffset);
185 
186  SIZE size = {r.width(), r.height()};
187  POINT ptDst = {r.x(), r.y()};
188  POINT ptSrc = {0, 0};
189  BLENDFUNCTION blend = {AC_SRC_OVER, 0, (BYTE)(255.0 * window()->windowOpacity()), Q_AC_SRC_ALPHA};
190  RECT dirty = {dirtyRect.x(), dirtyRect.y(),
191  dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
192  Q_UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, d->image->hdc, &ptSrc, 0, &blend, Q_ULW_ALPHA, &dirty};
193  ptrUpdateLayeredWindowIndirect(window()->internalWinId(), &info);
194  } else
195 #endif
196  {
197  QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
198 
199  HDC widget_dc = widget->getDC();
200 
201  QRect wbr = br.translated(-wOffset);
202  BitBlt(widget_dc, wbr.x(), wbr.y(), wbr.width(), wbr.height(),
203  d->image->hdc, br.x() + offset.x(), br.y() + offset.y(), SRCCOPY);
204  widget->releaseDC(widget_dc);
205  }
206 
207 #ifndef QT_NO_DEBUG
208  static bool flush = !qgetenv("QT_FLUSH_WINDOWSURFACE").isEmpty();
209  if (flush) {
210  SelectObject(qt_win_display_dc(), GetStockObject(BLACK_BRUSH));
211  Rectangle(qt_win_display_dc(), 0, 0, d->image->width() + 2, d->image->height() + 2);
212  BitBlt(qt_win_display_dc(), 1, 1, d->image->width(), d->image->height(),
213  d->image->hdc, 0, 0, SRCCOPY);
214  }
215 #endif
216 
217 #endif
218 
219 #ifdef Q_WS_X11
220  extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp
221  extern QWidgetData* qt_widget_data(QWidget *);
222  QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
223 
224  if (widget->window() != window()) {
225  XFreeGC(X11->display, d_ptr->gc);
226  d_ptr->gc = XCreateGC(X11->display, widget->handle(), 0, 0);
227  }
228 
229  QRegion wrgn(rgn);
230  if (!wOffset.isNull())
231  wrgn.translate(-wOffset);
232 
233  if (wrgn.rectCount() != 1) {
234  int num;
235  XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
236  XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded);
237  }
238 
239  QPoint widgetOffset = offset + wOffset;
240  QRect clipRect = widget->rect().translated(widgetOffset).intersected(d_ptr->image->image.rect());
241 
242  QRect br = rgn.boundingRect().translated(offset).intersected(clipRect);
243  QPoint wpos = br.topLeft() - widgetOffset;
244 
245 #ifndef QT_NO_MITSHM
246  if (d_ptr->image->xshmpm) {
247  XCopyArea(X11->display, d_ptr->image->xshmpm, widget->handle(), d_ptr->gc,
248  br.x(), br.y(), br.width(), br.height(), wpos.x(), wpos.y());
249  d_ptr->needsSync = true;
250  } else if (d_ptr->image->xshmimg) {
251  XShmPutImage(X11->display, widget->handle(), d_ptr->gc, d_ptr->image->xshmimg,
252  br.x(), br.y(), wpos.x(), wpos.y(), br.width(), br.height(), False);
253  d_ptr->needsSync = true;
254  } else
255 #endif
256  {
257  int depth = widget->x11Info().depth();
258  const QImage &src = d->image->image;
259  if (src.format() != QImage::Format_RGB32 || depth < 24 || X11->bppForDepth.value(depth) != 32) {
260  Q_ASSERT(src.depth() >= 16);
261  const QImage sub_src(src.scanLine(br.y()) + br.x() * (uint(src.depth()) / 8),
262  br.width(), br.height(), src.bytesPerLine(), src.format());
264  data->xinfo = widget->x11Info();
265  data->fromImage(sub_src, Qt::NoOpaqueDetection);
266  QPixmap pm = QPixmap(data);
267  XCopyArea(X11->display, pm.handle(), widget->handle(), d_ptr->gc, 0 , 0 , br.width(), br.height(), wpos.x(), wpos.y());
268  } else {
269  // qpaintengine_x11.cpp
270  extern void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth);
271  qt_x11_drawImage(br, wpos, src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), depth);
272  }
273  }
274 
275  if (wrgn.rectCount() != 1)
276  XSetClipMask(X11->display, d_ptr->gc, XNone);
277 #endif // FALCON
278 
279 #ifdef Q_WS_MAC
280 
281  Q_UNUSED(offset);
282 
283  // This is mainly done for native components like native "open file" dialog.
284  if (widget->testAttribute(Qt::WA_DontShowOnScreen)) {
285  return;
286  }
287 
288 #ifdef QT_MAC_USE_COCOA
289 
290  this->needsFlush = true;
291  this->regionToFlush += rgn;
292 
293  // The actual flushing will be processed in [view drawRect:rect]
294  qt_mac_setNeedsDisplay(widget);
295 
296 #else
297  // Get a context for the widget.
298  CGContextRef context;
299  CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
300  QDBeginCGContext(port, &context);
301  CGContextRetain(context);
302  CGContextSaveGState(context);
303 
304  // Flip context.
305  CGContextTranslateCTM(context, 0, widget->height());
306  CGContextScaleCTM(context, 1, -1);
307 
308  // Clip to region.
309  const QVector<QRect> &rects = rgn.rects();
310  for (int i = 0; i < rects.size(); ++i) {
311  const QRect &rect = rects.at(i);
312  CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
313  }
314  CGContextClip(context);
315 
316  QRect r = rgn.boundingRect().intersected(d->image->image.rect());
317  const CGRect area = CGRectMake(r.x(), r.y(), r.width(), r.height());
318  CGImageRef image = CGBitmapContextCreateImage(d->image->cg);
319  CGImageRef subImage = CGImageCreateWithImageInRect(image, area);
320 
321  qt_mac_drawCGImage(context, &area, subImage);
322 
323  CGImageRelease(subImage);
324  CGImageRelease(image);
325 
326  QDEndCGContext(port, &context);
327 
328  // Restore context.
329  CGContextRestoreGState(context);
330  CGContextRelease(context);
331 #endif // QT_MAC_USE_COCOA
332 
333 #endif // Q_WS_MAC
334 
335 #ifdef Q_OS_SYMBIAN
336  Q_UNUSED(widget);
337  Q_UNUSED(rgn);
338  Q_UNUSED(offset);
339 #endif
340 }
double d
Definition: qnumeric_p.h:62
int depth() const
Returns the color depth (bits per pixel) of the X display.
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
double windowOpacity
The level of opacity for the window.
Definition: qwidget.h:201
PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect
static mach_timebase_info_data_t info
#define BYTE
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
void releaseDC(HDC) const
Releases the HDC hdc acquired by a previous call to getDC().
Definition: qwidget.cpp:11862
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const QX11Info & x11Info() const
Returns information about the configuration of the X display used to display the widget.
QRect frameGeometry
geometry of the widget relative to its parent including any window frame
Definition: qwidget.h:159
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
Q_GUI_EXPORT void * qt_getClipRects(const QRegion &r, int &num)
struct CGImage * CGImageRef
Qt::HANDLE handle() const
Returns the pixmap&#39;s handle to the device context.
Definition: qpixmap.cpp:1299
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
Definition: qimage.cpp:1603
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
#define Q_D(Class)
Definition: qglobal.h:2482
#define Q_AC_SRC_ALPHA
#define SIZE(large, small, mini)
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QScopedPointer< QRasterWindowSurfacePrivate > d_ptr
The Rectangle item provides a filled rectangle with an optional border.
QRect frameStrut() const
Definition: qwidget.cpp:12607
void flush(QWidget *widget, const QRegion &region, const QPoint &offset)
Flushes the given region from the specified widget onto the screen.
bool isNull() const
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
Definition: qpoint.h:125
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
QRect wrect
Definition: qwidget.h:145
void * visual() const
Returns the current visual.
Q_GUI_EXPORT HDC qt_win_display_dc()
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth)
struct CGRect CGRect
struct _XDisplay Display
Definition: qwindowdefs.h:115
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
#define Q_ULW_ALPHA
struct _XGC * GC
Definition: qwindowdefs.h:117
HDC getDC() const
Returns the window system handle of the widget, for low-level access.
Definition: qwidget.cpp:11849
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
struct CGContext * CGContextRef
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
Q_GUI_EXPORT QWidgetData * qt_qwidget_data(QWidget *widget)
Definition: qwidget.cpp:12915
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886
static int area(const QSize &s)
Definition: qicon.cpp:155
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintDevice()

QPaintDevice * QRasterWindowSurface::paintDevice ( )
virtual

Implement this function to return the appropriate paint device.

Implements QWindowSurface.

Reimplemented in QTraceWindowSurface.

Definition at line 124 of file qwindowsurface_raster.cpp.

Referenced by QTraceWindowSurface::endPaint().

125 {
126  return &d_ptr->image->image;
127 }
QScopedPointer< QRasterWindowSurfacePrivate > d_ptr

◆ prepareBuffer()

void QRasterWindowSurface::prepareBuffer ( QImage::Format  format,
QWidget widget 
)
private

Definition at line 420 of file qwindowsurface_raster.cpp.

Referenced by beginPaint(), and setGeometry().

421 {
423 
424  int width = window()->width();
425  int height = window()->height();
426  if (d->image) {
427  width = qMax(d->image->width(), width);
428  height = qMax(d->image->height(), height);
429  }
430 
431  if (width == 0 || height == 0) {
432  delete d->image;
433  d->image = 0;
434  return;
435  }
436 
437  QNativeImage *oldImage = d->image;
438 
439  d->image = new QNativeImage(width, height, format, false, widget);
440 
441  if (oldImage && d->inSetGeometry && hasStaticContents()) {
442  // Make sure we use the const version of bits() (no detach).
443  const uchar *src = const_cast<const QImage &>(oldImage->image).bits();
444  uchar *dst = d->image->image.bits();
445 
446  const int srcBytesPerLine = oldImage->image.bytesPerLine();
447  const int dstBytesPerLine = d->image->image.bytesPerLine();
448  const int bytesPerPixel = oldImage->image.depth() >> 3;
449 
450  QRegion staticRegion(staticContents());
451  // Make sure we're inside the boundaries of the old image.
452  staticRegion &= QRect(0, 0, oldImage->image.width(), oldImage->image.height());
453  const QVector<QRect> &rects = staticRegion.rects();
454  const QRect *srcRect = rects.constData();
455 
456  // Copy the static content of the old image into the new one.
457  int numRectsLeft = rects.size();
458  do {
459  const int bytesOffset = srcRect->x() * bytesPerPixel;
460  const int dy = srcRect->y();
461 
462  // Adjust src and dst to point to the right offset.
463  const uchar *s = src + dy * srcBytesPerLine + bytesOffset;
464  uchar *d = dst + dy * dstBytesPerLine + bytesOffset;
465  const int numBytes = srcRect->width() * bytesPerPixel;
466 
467  int numScanLinesLeft = srcRect->height();
468  do {
469  ::memcpy(d, s, numBytes);
470  d += dstBytesPerLine;
471  s += srcBytesPerLine;
472  } while (--numScanLinesLeft);
473 
474  ++srcRect;
475  } while (--numRectsLeft);
476  }
477 
478  delete oldImage;
479 }
double d
Definition: qnumeric_p.h:62
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
static int bytesPerPixel(QImage::Format format)
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
unsigned char uchar
Definition: qglobal.h:994
bool hasStaticContents() const
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
QRegion staticContents() const
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.

◆ scroll()

bool QRasterWindowSurface::scroll ( const QRegion area,
int  dx,
int  dy 
)
virtual

Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.

Returns true if the area was scrolled successfully; false otherwise.

Reimplemented from QWindowSurface.

Reimplemented in QTraceWindowSurface.

Definition at line 384 of file qwindowsurface_raster.cpp.

385 {
386 #ifdef Q_WS_WIN
388 
389  if (!d->image || !d->image->hdc)
390  return false;
391 
392  QRect rect = area.boundingRect();
393  BitBlt(d->image->hdc, rect.x()+dx, rect.y()+dy, rect.width(), rect.height(),
394  d->image->hdc, rect.x(), rect.y(), SRCCOPY);
395 
396  return true;
397 #else
399 
400  if (!d->image || d->image->image.isNull())
401  return false;
402 
403 #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
404  syncX();
405 #endif
406 
407  const QVector<QRect> rects = area.rects();
408  for (int i = 0; i < rects.size(); ++i)
409  qt_scrollRectInImage(d->image->image, rects.at(i), QPoint(dx, dy));
410 
411  return true;
412 #endif
413 }
double d
Definition: qnumeric_p.h:62
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ setGeometry()

void QRasterWindowSurface::setGeometry ( const QRect rect)
virtual

Sets the currently allocated area to be the given rect.

This function is called whenever area covered by the top-level window changes.

See also
geometry()

Reimplemented from QWindowSurface.

Definition at line 342 of file qwindowsurface_raster.cpp.

343 {
346  d->inSetGeometry = true;
347  if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height()) {
348 #if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
349 #ifndef Q_WS_WIN
351 #else
353 #endif
355  else
356 #endif
358  }
359  d->inSetGeometry = false;
360 
361 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
362  QMainWindow* mWindow = qobject_cast<QMainWindow*>(window());
363  if (mWindow) {
364  QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
365  QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList;
366 
367  for (int i = 0; i < toolbarList.size(); ++i) {
368  QToolBar* toolbar = toolbarList.at(i);
369  if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) {
370  QWidget* tbWidget = (QWidget*) toolbar;
371  if (tbWidget->d_func()->unifiedSurface) {
372  tbWidget->d_func()->unifiedSurface->setGeometry(rect);
373  }
374  }
375  }
376  }
377 #endif // Q_WS_MAC && QT_MAC_USE_COCOA
378 
379 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
double d
Definition: qnumeric_p.h:62
Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void prepareBuffer(QImage::Format format, QWidget *widget)
static QImage::Format systemFormat()
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
NSToolbar * toolbar
QScopedPointer< QRasterWindowSurfacePrivate > d_ptr
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
QList< QToolBar * > qtoolbarsInUnifiedToolbarList
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ syncX()

void QRasterWindowSurface::syncX ( )
private

Definition at line 130 of file qwindowsurface_raster.cpp.

Referenced by beginPaint(), and scroll().

131 {
132  // delay writing to the backbuffer until we know for sure X is done reading from it
133  if (d_ptr->needsSync) {
134  XSync(X11->display, false);
135  d_ptr->needsSync = false;
136  }
137 }
#define X11
Definition: qt_x11_p.h:724
QScopedPointer< QRasterWindowSurfacePrivate > d_ptr

Properties

◆ d_ptr

QScopedPointer<QRasterWindowSurfacePrivate> QRasterWindowSurface::d_ptr
private

The documentation for this class was generated from the following files: