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

#include <qwindowsurface_mac_p.h>

Inheritance diagram for QMacWindowSurface:
QWindowSurface

Public Functions

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...
 
 QMacWindowSurface (QWidget *widget)
 
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...
 
 ~QMacWindowSurface ()
 
- Public Functions inherited from QWindowSurface
virtual void beginPaint (const QRegion &)
 This function is called before painting onto the surface begins, with the region in which the painting will occur. More...
 
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...
 
virtual WindowSurfaceFeatures features () const
 
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...
 

Properties

QMacWindowSurfacePrivated_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 67 of file qwindowsurface_mac_p.h.

Constructors and Destructors

◆ QMacWindowSurface()

QMacWindowSurface::QMacWindowSurface ( QWidget widget)

Definition at line 56 of file qwindowsurface_mac.cpp.

58 {
59  d_ptr->widget = widget;
60 }
QPointer< QWidget > widget
QMacWindowSurfacePrivate * d_ptr
QWindowSurface(QWidget *window, bool setDefaultSurface=true)
Constructs an empty surface for the given top-level window.

◆ ~QMacWindowSurface()

QMacWindowSurface::~QMacWindowSurface ( )

Definition at line 62 of file qwindowsurface_mac.cpp.

63 {
64  delete d_ptr;
65 }
QMacWindowSurfacePrivate * d_ptr

Functions

◆ flush()

void QMacWindowSurface::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 72 of file qwindowsurface_mac.cpp.

73 {
74  Q_UNUSED(offset);
75 
76  // Get a context for the widget.
77 #ifndef QT_MAC_USE_COCOA
78  CGContextRef context;
79  CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
80  QDBeginCGContext(port, &context);
81 #else
83  CGContextRef context = qt_mac_graphicsContextFor(widget);
84 #endif
85  CGContextRetain(context);
86  CGContextSaveGState(context);
87 
88  // Flip context.
89  CGContextTranslateCTM(context, 0, widget->height());
90  CGContextScaleCTM(context, 1, -1);
91 
92  // Clip to region.
93  const QVector<QRect> &rects = rgn.rects();
94  for (int i = 0; i < rects.size(); ++i) {
95  const QRect &rect = rects.at(i);
96  CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
97  }
98  CGContextClip(context);
99 
100  // Draw the image onto the window.
101  const CGRect dest = CGRectMake(0, 0, widget->width(), widget->height());
102  const CGImageRef image = d_ptr->device.toMacCGImageRef();
103  qt_mac_drawCGImage(context, &dest, image);
104  CFRelease(image);
105 
106  // Restore context.
107  CGContextRestoreGState(context);
108 #ifndef QT_MAC_USE_COCOA
109  QDEndCGContext(port, &context);
110 #else
111  CGContextFlush(context);
112 #endif
113  CGContextRelease(context);
114 }
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
struct CGImage * CGImageRef
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
QMacWindowSurfacePrivate * d_ptr
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
struct CGRect CGRect
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
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
struct CGContext * CGContextRef
CGImageRef toMacCGImageRef() const
Creates a CGImageRef equivalent to the QPixmap.
#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

◆ paintDevice()

QPaintDevice * QMacWindowSurface::paintDevice ( )
virtual

Implement this function to return the appropriate paint device.

Implements QWindowSurface.

Definition at line 67 of file qwindowsurface_mac.cpp.

68 {
69  return &d_ptr->device;
70 }
QMacWindowSurfacePrivate * d_ptr

◆ scroll()

bool QMacWindowSurface::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.

Definition at line 124 of file qwindowsurface_mac.cpp.

125 {
126  if (d_ptr->device.size().isNull())
127  return false;
128 
130  const QRect rect(area.boundingRect());
131  const CGRect dest = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
132  QCFType<CGImageRef> subimage = CGImageCreateWithImageInRect(image, dest);
134  CGContextTranslateCTM(context, dx, dy);
135  qt_mac_drawCGImage(context, &dest, subimage);
136  return true;
137 }
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
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
QMacWindowSurfacePrivate * d_ptr
CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
Returns the CoreGraphics CGContextRef of the paint device.
struct CGRect CGRect
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
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
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
CGImageRef toMacCGImageRef() const
Creates a CGImageRef equivalent to the QPixmap.

◆ setGeometry()

void QMacWindowSurface::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 116 of file qwindowsurface_mac.cpp.

117 {
119  const QSize size = rect.size();
120  if (d_ptr->device.size() != size)
121  d_ptr->device = QPixmap(size);
122 }
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
QMacWindowSurfacePrivate * d_ptr
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

Properties

◆ d_ptr

QMacWindowSurfacePrivate* QMacWindowSurface::d_ptr
private

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