Qt 4.8
Functions
qregion_win.cpp File Reference
#include "qatomic.h"
#include "qbitmap.h"
#include "qbuffer.h"
#include "qimage.h"
#include "qpolygon.h"
#include "qregion.h"
#include "qt_windows.h"
#include "qpainterpath.h"

Go to the source code of this file.

Functions

static void qt_add_rect (HRGN &winRegion, QRect r)
 
QRegion qt_region_from_HRGN (HRGN rgn)
 
HRGN qt_tryCreateRegion (QRegion::RegionType type, int left, int top, int right, int bottom)
 
void qt_win_dispose_rgn (HRGN r)
 

Function Documentation

◆ qt_add_rect()

static void qt_add_rect ( HRGN &  winRegion,
QRect  r 
)
static

Definition at line 116 of file qregion_win.cpp.

Referenced by QRegion::ensureHandle().

117 {
118  HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height());
119  if (rgn) {
120  HRGN dest = CreateRectRgn(0,0,0,0);
121  int result = CombineRgn(dest, winRegion, rgn, RGN_OR);
122  if (result) {
123  DeleteObject(winRegion);
124  winRegion = dest;
125  }
126  DeleteObject(rgn);
127  }
128 }
int left() const
Returns the x-coordinate of the rectangle's left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int top() const
Returns the y-coordinate of the rectangle's top edge.
Definition: qrect.h:243
int y() const
Returns the y-coordinate of the rectangle's top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle's left edge.
Definition: qrect.h:252

◆ qt_region_from_HRGN()

QRegion qt_region_from_HRGN ( HRGN  rgn)

Definition at line 80 of file qregion_win.cpp.

Referenced by QWindowsXPStylePrivate::region().

81 {
82  int numBytes = GetRegionData(rgn, 0, 0);
83  if (numBytes == 0)
84  return QRegion();
85 
86  char *buf = new char[numBytes];
87  if (buf == 0)
88  return QRegion();
89 
90  RGNDATA *rd = reinterpret_cast<RGNDATA*>(buf);
91  if (GetRegionData(rgn, numBytes, rd) == 0) {
92  delete [] buf;
93  return QRegion();
94  }
95 
96  QRegion region;
97  RECT *r = reinterpret_cast<RECT*>(rd->Buffer);
98  for (uint i = 0; i < rd->rdh.nCount; ++i) {
99  QRect rect;
100  rect.setCoords(r->left, r->top, r->right - 1, r->bottom - 1);
101  ++r;
102  region |= rect;
103  }
104 
105  delete [] buf;
106 
107  return region;
108 }
unsigned int uint
Definition: qglobal.h:996
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ qt_tryCreateRegion()

HRGN qt_tryCreateRegion ( QRegion::RegionType  type,
int  left,
int  top,
int  right,
int  bottom 
)

Definition at line 55 of file qregion_win.cpp.

Referenced by qt_grab_cursor(), and QtWndProc().

56 {
57  const int tries = 10;
58  for (int i = 0; i < tries; ++i) {
59  HRGN region = 0;
60  switch (type) {
61  case QRegion::Rectangle:
62  region = CreateRectRgn(left, top, right, bottom);
63  break;
64  case QRegion::Ellipse:
65 #ifndef Q_OS_WINCE
66  region = CreateEllipticRgn(left, top, right, bottom);
67 #endif
68  break;
69  }
70  if (region) {
71  if (GetRegionData(region, 0, 0))
72  return region;
73  else
74  DeleteObject(region);
75  }
76  }
77  return 0;
78 }
int type
Definition: qmetatype.cpp:239
QTextStream & right(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) on stream and returns stream...
QTextStream & left(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) on stream and returns stream...

◆ qt_win_dispose_rgn()

void qt_win_dispose_rgn ( HRGN  r)

Definition at line 110 of file qregion_win.cpp.

Referenced by QRegion::cleanUp().

111 {
112  if (r)
113  DeleteObject(r);
114 }