Added wxRegion version of wxWindowDC::SetClippingRegion
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1098 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -533,11 +533,15 @@ whether text will be drawn with a background colour or not.
|
|||||||
|
|
||||||
\func{void}{SetClippingRegion}{\param{long}{ x}, \param{long}{ y}, \param{long}{ width}, \param{long}{ height}}
|
\func{void}{SetClippingRegion}{\param{long}{ x}, \param{long}{ y}, \param{long}{ width}, \param{long}{ height}}
|
||||||
|
|
||||||
Sets the clipping region for the DC. The clipping region is a rectangular area
|
\func{void}{SetClippingRegion}{\param{const wxRegion\&}{ region}}
|
||||||
to which drawing is restricted. Possible uses for the clipping region are for clipping text
|
|
||||||
|
Sets the clipping region for the DC. The clipping region is an area
|
||||||
|
to which drawing is restricted. Possible uses for the clipping region are for clipping text
|
||||||
or for speeding up window redraws when only a known area of the screen is damaged.
|
or for speeding up window redraws when only a known area of the screen is damaged.
|
||||||
|
|
||||||
See also \helpref{wxDC::DestroyClippingRegion}{wxdcdestroyclippingregion}.
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxDC::DestroyClippingRegion}{wxdcdestroyclippingregion}, \helpref{wxRegion}{wxregion}
|
||||||
|
|
||||||
\membersection{wxDC::SetPalette}\label{wxdcsetpalette}
|
\membersection{wxDC::SetPalette}\label{wxdcsetpalette}
|
||||||
|
|
||||||
|
@@ -79,6 +79,8 @@ Here are the steps required:
|
|||||||
extra files to use the wxWindows makefiles. You can find these
|
extra files to use the wxWindows makefiles. You can find these
|
||||||
files in ports/mingw32 on the ftp site or CD-ROM, as extra.zip.
|
files in ports/mingw32 on the ftp site or CD-ROM, as extra.zip.
|
||||||
These should be extracted to the Mingw32 directory.
|
These should be extracted to the Mingw32 directory.
|
||||||
|
IMPORTANT: also see mingw32.txt in this directory (docs/msw)
|
||||||
|
about a fix that has to be applied to a Mingw32 header file.
|
||||||
|
|
||||||
- Modify the file wx/src/cygnus.bat (or mingw32.bat or mingegcs.bat)
|
- Modify the file wx/src/cygnus.bat (or mingw32.bat or mingegcs.bat)
|
||||||
to set up appropriate variables, if necessary mounting drives.
|
to set up appropriate variables, if necessary mounting drives.
|
||||||
|
@@ -89,6 +89,7 @@ class WXDLLEXPORT wxWindowDC: public wxDC
|
|||||||
virtual void SetPalette( const wxPalette& palette );
|
virtual void SetPalette( const wxPalette& palette );
|
||||||
|
|
||||||
virtual void SetClippingRegion( long x, long y, long width, long height );
|
virtual void SetClippingRegion( long x, long y, long width, long height );
|
||||||
|
virtual void SetClippingRegion( const wxRegion& region );
|
||||||
virtual void DestroyClippingRegion(void);
|
virtual void DestroyClippingRegion(void);
|
||||||
|
|
||||||
virtual void DrawSpline( wxList *points );
|
virtual void DrawSpline( wxList *points );
|
||||||
|
@@ -158,6 +158,7 @@ public:
|
|||||||
{
|
{
|
||||||
SetClippingRegion(rect.x, rect.y, rect.width, rect.height);
|
SetClippingRegion(rect.x, rect.y, rect.width, rect.height);
|
||||||
}
|
}
|
||||||
|
virtual void SetClippingRegion(const wxRegion& region);
|
||||||
|
|
||||||
virtual void SetPalette(const wxPalette& palette);
|
virtual void SetPalette(const wxPalette& palette);
|
||||||
#if WXWIN_COMPATIBILITY
|
#if WXWIN_COMPATIBILITY
|
||||||
|
@@ -101,6 +101,9 @@ public:
|
|||||||
bool Combine(long x, long y, long width, long height, wxRegionOp op);
|
bool Combine(long x, long y, long width, long height, wxRegionOp op);
|
||||||
bool Combine(const wxRegion& region, wxRegionOp op);
|
bool Combine(const wxRegion& region, wxRegionOp op);
|
||||||
bool Combine(const wxRect& rect, wxRegionOp op);
|
bool Combine(const wxRect& rect, wxRegionOp op);
|
||||||
|
|
||||||
|
// Get internal region handle
|
||||||
|
WXHRGN GetHRGN() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxRegionIterator : public wxObject {
|
class WXDLLEXPORT wxRegionIterator : public wxObject {
|
||||||
|
@@ -85,6 +85,7 @@ class WXDLLEXPORT wxWindowDC: public wxDC
|
|||||||
virtual void SetPalette( const wxPalette& palette );
|
virtual void SetPalette( const wxPalette& palette );
|
||||||
|
|
||||||
virtual void SetClippingRegion( long x, long y, long width, long height );
|
virtual void SetClippingRegion( long x, long y, long width, long height );
|
||||||
|
virtual void SetClippingRegion( const wxRegion& region ) ;
|
||||||
virtual void DestroyClippingRegion(void);
|
virtual void DestroyClippingRegion(void);
|
||||||
|
|
||||||
virtual void DrawSpline( wxList *points );
|
virtual void DrawSpline( wxList *points );
|
||||||
|
@@ -15,7 +15,7 @@ WXDIR = ../..
|
|||||||
# this central makefile.
|
# this central makefile.
|
||||||
include $(WXDIR)/src/makeg95.env
|
include $(WXDIR)/src/makeg95.env
|
||||||
|
|
||||||
OBJECTS = $(OBJDIR)/test.$(OBJSUFF)
|
OBJECTS = $(OBJDIR)/test.$(OBJSUFF) $(OBJDIR)/test_resources.$(OBJSUFF)
|
||||||
|
|
||||||
all: $(OBJDIR) test$(GUISUFFIX)$(EXESUFF)
|
all: $(OBJDIR) test$(GUISUFFIX)$(EXESUFF)
|
||||||
|
|
||||||
@@ -24,14 +24,16 @@ wx:
|
|||||||
$(OBJDIR):
|
$(OBJDIR):
|
||||||
mkdir $(OBJDIR)
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
test$(GUISUFFIX)$(EXESUFF): $(OBJDIR)/test.$(OBJSUFF) test.res $(WXLIB)
|
test$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB)
|
||||||
$(CC) $(LDFLAGS) -o test$(GUISUFFIX)$(EXESUFF) $(OBJDIR)/test.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS)
|
$(CC) $(LDFLAGS) -o test$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
|
||||||
$(RSRC) test.$(RESSUFF) test.exe
|
|
||||||
|
|
||||||
$(OBJDIR)/test.$(OBJSUFF): test.$(SRCSUFF)
|
$(OBJDIR)/test.$(OBJSUFF): test.$(SRCSUFF)
|
||||||
$(CC) -c $(CPPFLAGS) -o $@ test.$(SRCSUFF)
|
$(CC) -c $(CPPFLAGS) -o $@ test.$(SRCSUFF)
|
||||||
|
|
||||||
test.res: test.rc
|
$(OBJDIR)/test_resources.o: test.rc
|
||||||
|
$(RESCOMP) -i test.rc -o $(OBJDIR)/test_resources.o $(RESFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJECTS) test$(GUISUFFIX).exe core *.rsc *.res
|
rm -f $(OBJECTS) test$(GUISUFFIX).exe core *.rsc *.res
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2045,6 +2045,34 @@ void wxWindowDC::SetClippingRegion( long x, long y, long width, long height )
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void wxWindowDC::SetClippingRegion( const wxRegion& region )
|
||||||
|
{
|
||||||
|
wxRect box = region.GetBox();
|
||||||
|
|
||||||
|
wxDC::SetClippingRegion( box.x, box.y, box.width, box.height );
|
||||||
|
|
||||||
|
if (m_userRegion)
|
||||||
|
XDestroyRegion ((Region) m_userRegion);
|
||||||
|
m_userRegion = (WXRegion) XCreateRegion ();
|
||||||
|
|
||||||
|
XUnionRegion((Region) m_userRegion, (Region) region.GetXRegion(), (Region) m_userRegion);
|
||||||
|
|
||||||
|
SetDCClipping ();
|
||||||
|
|
||||||
|
// Needs to work differently for Pixmap: without this,
|
||||||
|
// there's a nasty (Display*) m_display bug. 8/12/94
|
||||||
|
if (m_window && m_window->GetBackingPixmap())
|
||||||
|
{
|
||||||
|
XRectangle rects[1];
|
||||||
|
rects[0].x = XLOG2DEV_2(box.x);
|
||||||
|
rects[0].y = YLOG2DEV_2(box.y);
|
||||||
|
rects[0].width = XLOG2DEVREL(box.width);
|
||||||
|
rects[0].height = YLOG2DEVREL(box.height);
|
||||||
|
XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void wxWindowDC::DestroyClippingRegion(void)
|
void wxWindowDC::DestroyClippingRegion(void)
|
||||||
{
|
{
|
||||||
wxDC::DestroyClippingRegion();
|
wxDC::DestroyClippingRegion();
|
||||||
|
@@ -206,9 +206,7 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
|
|||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO combine region
|
return FALSE;
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
|
bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
|
||||||
|
@@ -181,6 +181,22 @@ void wxDC::SetClippingRegion(long cx, long cy, long cw, long ch)
|
|||||||
DoClipping((WXHDC) m_hDC);
|
DoClipping((WXHDC) m_hDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxDC::SetClippingRegion(const wxRegion& region)
|
||||||
|
{
|
||||||
|
if (!region.GetHRGN())
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxRect box = region.GetBox();
|
||||||
|
|
||||||
|
m_clipping = TRUE;
|
||||||
|
m_clipX1 = box.x;
|
||||||
|
m_clipY1 = box.y;
|
||||||
|
m_clipX2 = box.x + box.width;
|
||||||
|
m_clipY2 = box.y + box.height;
|
||||||
|
|
||||||
|
ExtSelectClipRgn((HDC) m_hDC, (HRGN) region.GetHRGN(), RGN_AND);
|
||||||
|
}
|
||||||
|
|
||||||
void wxDC::DoClipping(WXHDC dc)
|
void wxDC::DoClipping(WXHDC dc)
|
||||||
{
|
{
|
||||||
if (m_clipping && dc)
|
if (m_clipping && dc)
|
||||||
@@ -194,11 +210,14 @@ void wxDC::DestroyClippingRegion(void)
|
|||||||
{
|
{
|
||||||
if (m_clipping && m_hDC)
|
if (m_clipping && m_hDC)
|
||||||
{
|
{
|
||||||
|
// TODO: this should restore the previous clipping region,
|
||||||
|
// so that OnPaint processing works correctly, and the update clipping region
|
||||||
|
// doesn't get destroyed after the first DestroyClippingRegion.
|
||||||
HRGN rgn = CreateRectRgn(0, 0, 32000, 32000);
|
HRGN rgn = CreateRectRgn(0, 0, 32000, 32000);
|
||||||
SelectClipRgn((HDC) m_hDC, rgn);
|
SelectClipRgn((HDC) m_hDC, rgn);
|
||||||
DeleteObject(rgn);
|
DeleteObject(rgn);
|
||||||
}
|
}
|
||||||
m_clipping = FALSE;
|
m_clipping = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDC::CanDrawBitmap(void) const
|
bool wxDC::CanDrawBitmap(void) const
|
||||||
|
@@ -288,6 +288,14 @@ wxRegionContain wxRegion::Contains(const wxRect& rect) const
|
|||||||
return Contains(x, y, w, h);
|
return Contains(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get internal region handle
|
||||||
|
WXHRGN wxRegion::GetHRGN() const
|
||||||
|
{
|
||||||
|
if (!m_refData)
|
||||||
|
return (WXHRGN) 0;
|
||||||
|
return (WXHRGN) M_REGION;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// //
|
// //
|
||||||
// wxRegionIterator //
|
// wxRegionIterator //
|
||||||
|
@@ -449,8 +449,19 @@ void wxWindowDC::SetClippingRegion( long x, long y, long width, long height )
|
|||||||
{
|
{
|
||||||
wxDC::SetClippingRegion( x, y, width, height );
|
wxDC::SetClippingRegion( x, y, width, height );
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void wxWindowDC::SetClippingRegion( const wxRegion& region )
|
||||||
|
{
|
||||||
|
wxRect box = region.GetBox();
|
||||||
|
|
||||||
|
wxDC::SetClippingRegion( box.x, box.y, box.width, box.height );
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
void wxWindowDC::DestroyClippingRegion(void)
|
void wxWindowDC::DestroyClippingRegion(void)
|
||||||
{
|
{
|
||||||
wxDC::DestroyClippingRegion();
|
wxDC::DestroyClippingRegion();
|
||||||
|
Reference in New Issue
Block a user