本文整理汇总了C++中wxRegion::GetWXHRGN方法的典型用法代码示例。如果您正苦于以下问题:C++ wxRegion::GetWXHRGN方法的具体用法?C++ wxRegion::GetWXHRGN怎么用?C++ wxRegion::GetWXHRGN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxRegion
的用法示例。
在下文中一共展示了wxRegion::GetWXHRGN方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetShape
bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
{
wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE,
_T("Shaped windows must be created with the wxFRAME_SHAPED style."));
#if TARGET_CARBON
// The empty region signifies that the shape should be removed from the
// window.
if ( region.IsEmpty() )
{
wxSize sz = GetClientSize();
wxRegion rgn(0, 0, sz.x, sz.y);
return SetShape(rgn);
}
// Make a copy of the region
RgnHandle shapeRegion = NewRgn();
CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );
// Dispose of any shape region we may already have
RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)MacGetWindowRef() );
if ( oldRgn )
DisposeRgn(oldRgn);
// Save the region so we can use it later
SetWRefCon((WindowRef)MacGetWindowRef(), (SInt32)shapeRegion);
// Tell the window manager that the window has changed shape
ReshapeCustomWindow((WindowRef)MacGetWindowRef());
return TRUE;
#else
return FALSE;
#endif
}
示例2: SetShape
bool wxSkinWindow::SetShape(const wxRegion& region)
{
#if defined(__WXMSW__) && !defined(__WXWINCE__)
// 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;
}
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;
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);
if (::SetWindowRgn(GetHwnd(), hrgn, TRUE) == 0)
{
wxLogLastError(_T("SetWindowRgn"));
return false;
}
return true;
#elif defined(__WXMAC__)
if ( region.IsEmpty() )
{
wxSize sz = GetClientSize();
wxRegion rgn(0, 0, sz.x, sz.y);
return SetShape(rgn);
}
// Make a copy of the region
RgnHandle shapeRegion = NewRgn();
CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );
// Dispose of any shape region we may already have
RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)GetHandle() );
if ( oldRgn )
DisposeRgn(oldRgn);
// Save the region so we can use it later
SetWRefCon((WindowRef)GetHandle(), (SInt32)shapeRegion);
// Tell the window manager that the window has changed shape
ReshapeCustomWindow((WindowRef)GetHandle());
return true;
#elif defined(__WXGTK__)
if(region.IsEmpty())
{
if(m_wxwindow && !GTK_WIDGET_NO_WINDOW(m_wxwindow))
gtk_widget_shape_combine_mask(m_wxwindow,NULL,0,0);
if(m_widget && !GTK_WIDGET_NO_WINDOW(m_widget))
gtk_widget_shape_combine_mask(m_widget,NULL,0,0);
}
else
{ wxBitmap bmp = region.ConvertToBitmap();
bmp.SetMask(new wxMask(bmp, *wxBLACK));
GdkBitmap* mask = bmp.GetMask()->GetBitmap();
if(m_wxwindow && !GTK_WIDGET_NO_WINDOW(m_wxwindow))
gtk_widget_shape_combine_mask(m_wxwindow,mask,0,0);
if(m_widget && !GTK_WIDGET_NO_WINDOW(m_widget))
gtk_widget_shape_combine_mask(m_widget,mask,0,0);
}
return true;
#else
return false;
#endif
}