Added wxTLW::SetShape and implementations for wxGTK, wxMSW and an

empty stub for wxMac.
Added some generic helpers and a new ctor to wxRegion.
Added samples/shaped.
(Backport to 2.4 from 2.5)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-03-29 19:03:04 +00:00
parent 9f5fc44733
commit 8c879ff9c5
38 changed files with 971 additions and 614 deletions

1032
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -5301,7 +5301,7 @@ if test "$wxUSE_GUI" = "yes"; then
dnl ipc, mfc, nativdlg, oleauto, ownerdrw dnl ipc, mfc, nativdlg, oleauto, ownerdrw
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS artprov controls dialogs \ SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS artprov controls dialogs \
drawing dynamic erase event exec font image \ drawing dynamic erase event exec font image \
minimal propsize rotate widgets" minimal propsize rotate shaped widgets"
dnl this is needed to be able to find AFM files dnl this is needed to be able to find AFM files
CPPFLAGS="$CPPFLAGS \$(EXTRADEFS) \$(APPEXTRADEFS)" CPPFLAGS="$CPPFLAGS \$(EXTRADEFS) \$(APPEXTRADEFS)"

View File

@@ -217,6 +217,7 @@ protocol.cpp Common Socket,Base
quantize.cpp Common quantize.cpp Common
radiocmn.cpp Common NotMac radiocmn.cpp Common NotMac
regex.cpp Common Base regex.cpp Common Base
rgncmn.cpp Common
resource.cpp Common resource.cpp Common
sckaddr.cpp Common Socket,Base sckaddr.cpp Common Socket,Base
sckfile.cpp Common Socket,Base sckfile.cpp Common Socket,Base

View File

@@ -529,6 +529,17 @@ Note that it is not possible to call this function twice for the same frame obje
\helpref{wxFrame::GetMenuBar}{wxframegetmenubar}, \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}. \helpref{wxFrame::GetMenuBar}{wxframegetmenubar}, \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}.
\membersection{wxFrame::SetShape}\label{wxframesetshape}
\func{bool}{SetShape}{\param{const wxRegion&}{ region}}
If the platform supports it, sets the shape of the window to that
depicted by \it{region}. The system will not display or
respond to any mouse event for the pixels that lie outside of the
region. To reset the window to the normal rectangular shape simply
call \it{SetShape} again with an empty region. Returns TRUE if the
operation is successful.
\membersection{wxFrame::SetStatusBar}\label{wxframesetstatusbar} \membersection{wxFrame::SetStatusBar}\label{wxframesetstatusbar}
\func{void}{SetStatusBar}{\param{wxStatusBar*}{ statusBar}} \func{void}{SetStatusBar}{\param{wxStatusBar*}{ statusBar}}

View File

@@ -48,6 +48,14 @@ provided array. {\it fillStyle} parameter may have values
{\bf NB:} This constructor is only implemented for Win32 and GTK+ wxWindows ports. {\bf NB:} This constructor is only implemented for Win32 and GTK+ wxWindows ports.
\func{}{wxRegion}{\param{const wxBitmap&}{ bmp},
\param{const wxColour&}{ transColour = wxNullColour},
\param{int}{ tolerance = 0}}
Constructs a region using the non-transparent pixels of a bitmap. See
\helpref{Union}{wxregionunion} for more details.
\membersection{wxRegion::\destruct{wxRegion}} \membersection{wxRegion::\destruct{wxRegion}}
\func{}{\destruct{wxRegion}}{\void} \func{}{\destruct{wxRegion}}{\void}
@@ -85,6 +93,13 @@ The return value is one of wxOutRegion, wxPartRegion and wxInRegion.
On Windows, only wxOutRegion and wxInRegion are returned; a value wxInRegion then indicates that On Windows, only wxOutRegion and wxInRegion are returned; a value wxInRegion then indicates that
all or some part of the region is contained in this region. all or some part of the region is contained in this region.
\membersection{wxRegion::ConvertToBitmap}\label{wxregionconverttobitmap}
\constfunc{wxBitmap}{ConvertToBitmap}{}
Convert the region to a black and white bitmap with the black pixels
being inside the region.
\membersection{wxRegion::GetBox}\label{wxregiongetbox} \membersection{wxRegion::GetBox}\label{wxregiongetbox}
\constfunc{void}{GetBox}{\param{long\& }{x}, \param{long\& }{y}, \param{long\& }{width}, \param{long\& }{height}} \constfunc{void}{GetBox}{\param{long\& }{x}, \param{long\& }{y}, \param{long\& }{width}, \param{long\& }{height}}
@@ -168,6 +183,15 @@ Finds the union of this region and another, rectangular region.
Finds the union of this region and another region. Finds the union of this region and another region.
\func{bool}{Union}{\param{const wxBitmap&}{ bmp},
\param{const wxColour&}{ transColour = wxNullColour},
\param{int}{ tolerance = 0}}
Finds the union of this region and the the non-transparent pixels of a
bitmap. If the bitmap has a mask then it will be used, otherwise the
colour to be treated as transparent may be specified, along with an
optional colour tolerance value.
\wxheading{Return value} \wxheading{Return value}
{\tt TRUE} if successful, {\tt FALSE} otherwise. {\tt TRUE} if successful, {\tt FALSE} otherwise.

View File

@@ -71,6 +71,14 @@ public:
} }
wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
wxRegion( const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
~wxRegion(); ~wxRegion();
wxRegion( const wxRegion& region ) wxRegion( const wxRegion& region )
@@ -114,6 +122,19 @@ public:
wxRegionContain Contains(const wxPoint& pt) const; wxRegionContain Contains(const wxPoint& pt) const;
wxRegionContain Contains(const wxRect& rect) const; wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. If the bitmap has a mask then it will be used,
// otherwise the colour to be treated as transparent may be specified,
// along with an optional tolerance value.
bool Union(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
public: public:
// Init with GdkRegion, set ref count to 2 so that // Init with GdkRegion, set ref count to 2 so that
// the C++ class will not destroy the region! // the C++ class will not destroy the region!

View File

@@ -60,6 +60,8 @@ public:
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
virtual bool IsFullScreen() const { return m_fsIsShowing; }; virtual bool IsFullScreen() const { return m_fsIsShowing; };
virtual bool SetShape(const wxRegion& region);
virtual bool Show(bool show = TRUE); virtual bool Show(bool show = TRUE);
virtual void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );

View File

@@ -71,6 +71,14 @@ public:
} }
wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
wxRegion( const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
~wxRegion(); ~wxRegion();
wxRegion( const wxRegion& region ) wxRegion( const wxRegion& region )
@@ -114,6 +122,19 @@ public:
wxRegionContain Contains(const wxPoint& pt) const; wxRegionContain Contains(const wxPoint& pt) const;
wxRegionContain Contains(const wxRect& rect) const; wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. If the bitmap has a mask then it will be used,
// otherwise the colour to be treated as transparent may be specified,
// along with an optional tolerance value.
bool Union(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
public: public:
// Init with GdkRegion, set ref count to 2 so that // Init with GdkRegion, set ref count to 2 so that
// the C++ class will not destroy the region! // the C++ class will not destroy the region!

View File

@@ -60,6 +60,8 @@ public:
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
virtual bool IsFullScreen() const { return m_fsIsShowing; }; virtual bool IsFullScreen() const { return m_fsIsShowing; };
virtual bool SetShape(const wxRegion& region);
virtual bool Show(bool show = TRUE); virtual bool Show(bool show = TRUE);
virtual void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );

View File

@@ -45,6 +45,13 @@ public:
wxRegion(const wxRect& rect); wxRegion(const wxRect& rect);
wxRegion( WXHRGN hRegion ); wxRegion( WXHRGN hRegion );
wxRegion(); wxRegion();
wxRegion( const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
~wxRegion(); ~wxRegion();
//# Copying //# Copying
@@ -110,6 +117,18 @@ public:
// Does the region contain the rectangle rect? // Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const; wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. If the bitmap has a mask then it will be used,
// otherwise the colour to be treated as transparent may be specified,
// along with an optional tolerance value.
bool Union(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
// Internal // Internal
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);

View File

@@ -58,6 +58,8 @@ public:
virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); } virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); }
virtual void Restore(); virtual void Restore();
virtual bool SetShape(const wxRegion& region);
virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style) = wxFULLSCREEN_ALL) virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style) = wxFULLSCREEN_ALL)
{ return FALSE; } { return FALSE; }
virtual bool IsFullScreen() const { return FALSE; } virtual bool IsFullScreen() const { return FALSE; }

View File

@@ -41,6 +41,12 @@ public:
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect); wxRegion(const wxRect& rect);
wxRegion(const MGLRegion& region); wxRegion(const MGLRegion& region);
wxRegion( const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
wxRegion(); wxRegion();
~wxRegion(); ~wxRegion();
@@ -97,6 +103,19 @@ public:
// Does the region contain the rectangle rect? // Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const; wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. If the bitmap has a mask then it will be used,
// otherwise the colour to be treated as transparent may be specified,
// along with an optional tolerance value.
bool Union(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
// implementation from now on: // implementation from now on:
const MGLRegion& GetMGLRegion() const; const MGLRegion& GetMGLRegion() const;

View File

@@ -48,6 +48,12 @@ public:
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect); wxRegion(const wxRect& rect);
wxRegion(); wxRegion();
wxRegion( const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
~wxRegion(); ~wxRegion();
//# Copying //# Copying
@@ -101,6 +107,18 @@ public:
// Does the region contain the rectangle rect? // Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const; wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. If the bitmap has a mask then it will be used,
// otherwise the colour to be treated as transparent may be specified,
// along with an optional tolerance value.
bool Union(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
// Internal // Internal
bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op); bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
bool Combine(const wxRegion& region, wxRegionOp op); bool Combine(const wxRegion& region, wxRegionOp op);

View File

@@ -48,6 +48,12 @@ public:
wxRegion(const wxRect& rect); wxRegion(const wxRect& rect);
wxRegion(WXHRGN hRegion); // Hangs on to this region wxRegion(WXHRGN hRegion); // Hangs on to this region
wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
wxRegion( const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
virtual ~wxRegion(); virtual ~wxRegion();
@@ -108,6 +114,18 @@ public:
// Does the region contain the rectangle rect? // Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const; wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. If the bitmap has a mask then it will be used,
// otherwise the colour to be treated as transparent may be specified,
// along with an optional tolerance value.
bool Union(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
// Internal // Internal
bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op); bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
bool Combine(const wxRegion& region, wxRegionOp op); bool Combine(const wxRegion& region, wxRegionOp op);

View File

@@ -58,6 +58,8 @@ public:
virtual void SetIcons(const wxIconBundle& icons ); virtual void SetIcons(const wxIconBundle& icons );
virtual void Restore(); virtual void Restore();
virtual bool SetShape(const wxRegion& region);
virtual bool Show(bool show = TRUE); virtual bool Show(bool show = TRUE);
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);

View File

@@ -73,6 +73,14 @@ public:
} }
wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
wxRegion( const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
~wxRegion(); ~wxRegion();
wxRegion( const wxRegion& region ) { Ref(region); } wxRegion( const wxRegion& region ) { Ref(region); }
@@ -114,6 +122,19 @@ public:
wxRegionContain Contains(const wxPoint& pt) const; wxRegionContain Contains(const wxPoint& pt) const;
wxRegionContain Contains(const wxRect& rect) const; wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. If the bitmap has a mask then it will be used,
// otherwise the colour to be treated as transparent may be specified,
// along with an optional tolerance value.
bool Union(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
public: public:
WXRegion *GetX11Region() const; WXRegion *GetX11Region() const;

12
samples/configure vendored
View File

@@ -693,15 +693,21 @@ trap 'rm -fr `echo "
mobile/Makefile mobile/Makefile
mobile/wxedit/Makefile mobile/wxedit/Makefile
mobile/styles/Makefile mobile/styles/Makefile
multimon/Makefile
nativedlg/Makefile
newgrid/Makefile newgrid/Makefile
notebook/Makefile notebook/Makefile
oleauto/Makefile
ownerdrw/Makefile
png/Makefile png/Makefile
printing/Makefile printing/Makefile
proplist/Makefile proplist/Makefile
propsize/Makefile propsize/Makefile
regtest/Makefile
resource/Makefile resource/Makefile
rotate/Makefile rotate/Makefile
sashtest/Makefile sashtest/Makefile
shaped/Makefile
scroll/Makefile scroll/Makefile
scrollsub/Makefile scrollsub/Makefile
sockets/Makefile sockets/Makefile
@@ -847,15 +853,21 @@ CONFIG_FILES=\${CONFIG_FILES-"Makefile
mobile/Makefile mobile/Makefile
mobile/wxedit/Makefile mobile/wxedit/Makefile
mobile/styles/Makefile mobile/styles/Makefile
multimon/Makefile
nativedlg/Makefile
newgrid/Makefile newgrid/Makefile
notebook/Makefile notebook/Makefile
oleauto/Makefile
ownerdrw/Makefile
png/Makefile png/Makefile
printing/Makefile printing/Makefile
proplist/Makefile proplist/Makefile
propsize/Makefile propsize/Makefile
regtest/Makefile
resource/Makefile resource/Makefile
rotate/Makefile rotate/Makefile
sashtest/Makefile sashtest/Makefile
shaped/Makefile
scroll/Makefile scroll/Makefile
scrollsub/Makefile scrollsub/Makefile
sockets/Makefile sockets/Makefile

View File

@@ -77,6 +77,7 @@ AC_OUTPUT([
resource/Makefile resource/Makefile
rotate/Makefile rotate/Makefile
sashtest/Makefile sashtest/Makefile
shaped/Makefile
scroll/Makefile scroll/Makefile
scrollsub/Makefile scrollsub/Makefile
sockets/Makefile sockets/Makefile

View File

@@ -42,7 +42,6 @@
#endif #endif
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/image.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private classes // private classes
@@ -155,7 +154,7 @@ ShapedFrame::ShapedFrame()
m_bmp = wxBitmap("star.png", wxBITMAP_TYPE_PNG); m_bmp = wxBitmap("star.png", wxBITMAP_TYPE_PNG);
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight())); SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
SetToolTip(wxT("Right-click to exit")); SetToolTip(wxT("Right-click to exit"));
#ifdef __WXMSW__ #ifdef __wxMSW__
// On wxGTK we can't do this yet because the window hasn't been created // On wxGTK we can't do this yet because the window hasn't been created
// yet so we wait until the EVT_WINDOW_CREATE event happens. On wxMSW it // yet so we wait until the EVT_WINDOW_CREATE event happens. On wxMSW it
// has been created so we set the shape now. // has been created so we set the shape now.

View File

@@ -102,6 +102,7 @@ ALL_HEADERS = \
datetime.inl \ datetime.inl \
datstrm.h \ datstrm.h \
db.h \ db.h \
dbkeyg.h \
dbtable.h \ dbtable.h \
dde.h \ dde.h \
debug.h \ debug.h \

View File

@@ -142,6 +142,7 @@ ALL_SOURCES = \
common/radiocmn.cpp \ common/radiocmn.cpp \
common/regex.cpp \ common/regex.cpp \
common/resource.cpp \ common/resource.cpp \
common/rgncmn.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckfile.cpp \ common/sckfile.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -730,6 +731,7 @@ COMMONOBJS = \
radiocmn.o \ radiocmn.o \
regex.o \ regex.o \
resource.o \ resource.o \
rgncmn.o \
sckaddr.o \ sckaddr.o \
sckfile.o \ sckfile.o \
sckipc.o \ sckipc.o \

View File

@@ -987,4 +987,43 @@ void wxTopLevelWindowGTK::RemoveGrab()
} }
} }
// helper
static bool do_shape_combine_region(GdkWindow* window, const wxRegion& region)
{
if (window)
{
if (region.IsEmpty())
{
gdk_window_shape_combine_mask(window, NULL, 0, 0);
}
else
{
#ifdef __WXGTK20__
gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0);
#else
wxBitmap bmp = region.ConvertToBitmap();
bmp.SetMask(new wxMask(bmp, *wxWHITE));
GdkBitmap* mask = bmp.GetMask()->GetBitmap();
gdk_window_shape_combine_mask(window, mask, 0, 0);
#endif
return TRUE;
}
}
return FALSE;
}
bool wxTopLevelWindowGTK::SetShape(const wxRegion& region)
{
GdkWindow *window = NULL;
if (m_wxwindow)
{
window = GTK_PIZZA(m_wxwindow)->bin_window;
do_shape_combine_region(window, region);
}
window = m_widget->window;
return do_shape_combine_region(window, region);
}
// vi:sts=4:sw=4:et // vi:sts=4:sw=4:et

View File

@@ -142,6 +142,7 @@ ALL_SOURCES = \
common/radiocmn.cpp \ common/radiocmn.cpp \
common/regex.cpp \ common/regex.cpp \
common/resource.cpp \ common/resource.cpp \
common/rgncmn.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckfile.cpp \ common/sckfile.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -730,6 +731,7 @@ COMMONOBJS = \
radiocmn.o \ radiocmn.o \
regex.o \ regex.o \
resource.o \ resource.o \
rgncmn.o \
sckaddr.o \ sckaddr.o \
sckfile.o \ sckfile.o \
sckipc.o \ sckipc.o \

View File

@@ -987,4 +987,43 @@ void wxTopLevelWindowGTK::RemoveGrab()
} }
} }
// helper
static bool do_shape_combine_region(GdkWindow* window, const wxRegion& region)
{
if (window)
{
if (region.IsEmpty())
{
gdk_window_shape_combine_mask(window, NULL, 0, 0);
}
else
{
#ifdef __WXGTK20__
gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0);
#else
wxBitmap bmp = region.ConvertToBitmap();
bmp.SetMask(new wxMask(bmp, *wxWHITE));
GdkBitmap* mask = bmp.GetMask()->GetBitmap();
gdk_window_shape_combine_mask(window, mask, 0, 0);
#endif
return TRUE;
}
}
return FALSE;
}
bool wxTopLevelWindowGTK::SetShape(const wxRegion& region)
{
GdkWindow *window = NULL;
if (m_wxwindow)
{
window = GTK_PIZZA(m_wxwindow)->bin_window;
do_shape_combine_region(window, region);
}
window = m_widget->window;
return do_shape_combine_region(window, region);
}
// vi:sts=4:sw=4:et // vi:sts=4:sw=4:et

View File

@@ -139,6 +139,7 @@ ALL_SOURCES = \
common/quantize.cpp \ common/quantize.cpp \
common/regex.cpp \ common/regex.cpp \
common/resource.cpp \ common/resource.cpp \
common/rgncmn.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckfile.cpp \ common/sckfile.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -759,6 +760,7 @@ COMMONOBJS = \
quantize.o \ quantize.o \
regex.o \ regex.o \
resource.o \ resource.o \
rgncmn.o \
sckaddr.o \ sckaddr.o \
sckfile.o \ sckfile.o \
sckipc.o \ sckipc.o \

View File

@@ -787,3 +787,7 @@ void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackgro
SetPort( formerPort ) ; SetPort( formerPort ) ;
} }
bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
{
return FALSE;
}

View File

@@ -139,6 +139,7 @@ ALL_SOURCES = \
common/quantize.cpp \ common/quantize.cpp \
common/regex.cpp \ common/regex.cpp \
common/resource.cpp \ common/resource.cpp \
common/rgncmn.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckfile.cpp \ common/sckfile.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -759,6 +760,7 @@ COMMONOBJS = \
quantize.o \ quantize.o \
regex.o \ regex.o \
resource.o \ resource.o \
rgncmn.o \
sckaddr.o \ sckaddr.o \
sckfile.o \ sckfile.o \
sckipc.o \ sckipc.o \

View File

@@ -787,3 +787,7 @@ void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackgro
SetPort( formerPort ) ; SetPort( formerPort ) ;
} }
bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
{
return FALSE;
}

View File

@@ -144,6 +144,7 @@ ALL_SOURCES = \
common/radiocmn.cpp \ common/radiocmn.cpp \
common/regex.cpp \ common/regex.cpp \
common/resource.cpp \ common/resource.cpp \
common/rgncmn.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckfile.cpp \ common/sckfile.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -655,6 +656,7 @@ COMMONOBJS = \
radiocmn.o \ radiocmn.o \
regex.o \ regex.o \
resource.o \ resource.o \
rgncmn.o \
sckaddr.o \ sckaddr.o \
sckfile.o \ sckfile.o \
sckipc.o \ sckipc.o \

View File

@@ -186,6 +186,7 @@ COMMONOBJS = &
radiocmn.obj & radiocmn.obj &
regex.obj & regex.obj &
resource.obj & resource.obj &
rgncmn.obj &
sckaddr.obj & sckaddr.obj &
sckfile.obj & sckfile.obj &
sckipc.obj & sckipc.obj &
@@ -822,6 +823,9 @@ regex.obj: $(COMMDIR)\regex.cpp
resource.obj: $(COMMDIR)\resource.cpp resource.obj: $(COMMDIR)\resource.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $< *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
rgncmn.obj: $(COMMDIR)\rgncmn.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
sckaddr.obj: $(COMMDIR)\sckaddr.cpp sckaddr.obj: $(COMMDIR)\sckaddr.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $< *$(CCC) $(CPPFLAGS) $(IFLAGS) $<

View File

@@ -142,6 +142,7 @@ ALL_SOURCES = \
common/radiocmn.cpp \ common/radiocmn.cpp \
common/regex.cpp \ common/regex.cpp \
common/resource.cpp \ common/resource.cpp \
common/rgncmn.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckfile.cpp \ common/sckfile.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -721,6 +722,7 @@ COMMONOBJS = \
radiocmn.o \ radiocmn.o \
regex.o \ regex.o \
resource.o \ resource.o \
rgncmn.o \
sckaddr.o \ sckaddr.o \
sckfile.o \ sckfile.o \
sckipc.o \ sckipc.o \

View File

@@ -127,6 +127,7 @@ ALL_SOURCES = \
common/radiocmn.cpp \ common/radiocmn.cpp \
common/regex.cpp \ common/regex.cpp \
common/resource.cpp \ common/resource.cpp \
common/rgncmn.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckfile.cpp \ common/sckfile.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -797,6 +798,7 @@ COMMONOBJS = \
radiocmn.o \ radiocmn.o \
regex.o \ regex.o \
resource.o \ resource.o \
rgncmn.o \
sckaddr.o \ sckaddr.o \
sckfile.o \ sckfile.o \
sckipc.o \ sckipc.o \

View File

@@ -724,6 +724,47 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
return TRUE; return TRUE;
} }
bool wxTopLevelWindowMSW::SetShape(const wxRegion& region)
{
// The empty region signifies that the shape should be removed from the
// window.
if ( region.IsEmpty() )
{
if (::SetWindowRgn(GetHwnd(), NULL, TRUE) == 0)
{
wxLogLastError(_T("SetWindowRgn"));
return FALSE;
}
return TRUE;
}
// Windows takes ownership of the region, so
// we'll have to make a copy of the region to give to it.
DWORD noBytes = ::GetRegionData(GetHrgnOf(region), 0, NULL);
RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
::GetRegionData(GetHrgnOf(region), noBytes, rgnData);
HRGN hrgn = ::ExtCreateRegion(NULL, noBytes, rgnData);
delete[] (char*) rgnData;
// SetWindowRgn expects the region to be in coordinants
// relative to the window, not the client area. Figure
// out the offset, if any.
RECT rect;
DWORD dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
::GetClientRect(GetHwnd(), &rect);
::AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
::OffsetRgn(hrgn, -rect.left, -rect.top);
// Now call the shape API with the new region.
if (::SetWindowRgn(GetHwnd(), hrgn, TRUE) == 0)
{
wxLogLastError(_T("SetWindowRgn"));
return FALSE;
}
return TRUE;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTopLevelWindow event handling // wxTopLevelWindow event handling
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -872,3 +913,4 @@ HWND wxTLWHiddenParentModule::GetHWND()
return ms_hwnd; return ms_hwnd;
} }

View File

@@ -175,6 +175,7 @@ ALL_SOURCES = \
common/radiocmn.cpp \ common/radiocmn.cpp \
common/regex.cpp \ common/regex.cpp \
common/resource.cpp \ common/resource.cpp \
common/rgncmn.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckfile.cpp \ common/sckfile.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -744,6 +745,7 @@ COMMONOBJS = \
radiocmn.o \ radiocmn.o \
regex.o \ regex.o \
resource.o \ resource.o \
rgncmn.o \
sckaddr.o \ sckaddr.o \
sckfile.o \ sckfile.o \
sckipc.o \ sckipc.o \

View File

@@ -13,7 +13,7 @@ from distutils.command.install_data import install_data
# flags and values that affect this script # flags and values that affect this script
#---------------------------------------------------------------------- #----------------------------------------------------------------------
VERSION = "2.4.0.7" VERSION = "2.4.0.8p1"
DESCRIPTION = "Cross platform GUI toolkit for Python" DESCRIPTION = "Cross platform GUI toolkit for Python"
AUTHOR = "Robin Dunn" AUTHOR = "Robin Dunn"
AUTHOR_EMAIL = "Robin Dunn <robin@alldunn.com>" AUTHOR_EMAIL = "Robin Dunn <robin@alldunn.com>"

View File

@@ -517,10 +517,10 @@ def EVT_SASH_DRAGGED_RANGE(win, id1, id2, func):
win.Connect(id1, id2, wxEVT_SASH_DRAGGED, func) win.Connect(id1, id2, wxEVT_SASH_DRAGGED, func)
def EVT_QUERY_LAYOUT_INFO(win, func): def EVT_QUERY_LAYOUT_INFO(win, func):
win.Connect(-1, -1, wxEVT_EVT_QUERY_LAYOUT_INFO, func) win.Connect(-1, -1, wxEVT_QUERY_LAYOUT_INFO, func)
def EVT_CALCULATE_LAYOUT(win, func): def EVT_CALCULATE_LAYOUT(win, func):
win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func) win.Connect(-1, -1, wxEVT_CALCULATE_LAYOUT, func)
#wxSplitterWindow #wxSplitterWindow
@@ -730,7 +730,7 @@ def wxCallAfter(callable, *args, **kw):
global _wxCallAfterId global _wxCallAfterId
if _wxCallAfterId is None: if _wxCallAfterId is None:
_wxCallAfterId = wxNewId() _wxCallAfterId = wxNewEventType()
app.Connect(-1, -1, _wxCallAfterId, app.Connect(-1, -1, _wxCallAfterId,
lambda event: apply(event.callable, event.args, event.kw) ) lambda event: apply(event.callable, event.args, event.kw) )
evt = wxPyEvent() evt = wxPyEvent()

View File

@@ -116,6 +116,12 @@ public:
virtual void SetTitle(const wxString& title); virtual void SetTitle(const wxString& title);
virtual wxString GetTitle() const; virtual wxString GetTitle() const;
// Set the shape of the window to the given region.
// Returns TRUE if the platform supports this feature (and the operation
// is successful.)
virtual bool SetShape(const wxRegion& region);
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -1043,8 +1043,12 @@ public:
#ifndef __WXMAC__ #ifndef __WXMAC__
%name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE); %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE);
#endif #endif
%name(wxRegionFromBitmap)wxRegion(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
~wxRegion(); ~wxRegion();
void Clear(); void Clear();
#ifndef __WXMAC__ #ifndef __WXMAC__
bool Offset(wxCoord x, wxCoord y); bool Offset(wxCoord x, wxCoord y);
@@ -1074,6 +1078,18 @@ public:
bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height); bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
%name(XorRect)bool Xor(const wxRect& rect); %name(XorRect)bool Xor(const wxRect& rect);
%name(XorRegion)bool Xor(const wxRegion& region); %name(XorRegion)bool Xor(const wxRegion& region);
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
wxBitmap ConvertToBitmap();
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. If the bitmap has a mask then it will be used,
// otherwise the colour to be treated as transparent may be specified,
// along with an optional tolerance value.
%name(UnionBitmap)bool Union(const wxBitmap& bmp,
const wxColour& transColour = wxNullColour,
int tolerance = 0);
}; };
@@ -1103,6 +1119,7 @@ public:
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
%readonly %readonly
%{ %{
#if 0 #if 0