]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/nonownedwnd.cpp
20f05258e3eb8169cc74c18840a29725bd156d60
[wxWidgets.git] / src / gtk / nonownedwnd.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/nonownedwnd.cpp
3 // Purpose: wxGTK implementation of wxNonOwnedWindow.
4 // Author: Vadim Zeitlin
5 // Created: 2011-10-12
6 // RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #ifndef WX_PRECOMP
27 #include "wx/string.h"
28 #endif // WX_PRECOMP
29
30 #include "wx/gtk/private.h"
31
32 #include <gdk/gdk.h>
33
34 namespace
35 {
36
37 // helper
38 bool do_shape_combine_region(GdkWindow* window, const wxRegion& region)
39 {
40 if (window)
41 {
42 if (region.IsEmpty())
43 {
44 gdk_window_shape_combine_mask(window, NULL, 0, 0);
45 }
46 else
47 {
48 gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0);
49 return true;
50 }
51 }
52 return false;
53 }
54
55 } // anonymous namespace
56
57
58 // ============================================================================
59 // wxNonOwnedWindow implementation
60 // ============================================================================
61
62 void wxNonOwnedWindow::GTKHandleRealized()
63 {
64 wxNonOwnedWindowBase::GTKHandleRealized();
65
66 if (HasFlag(wxFRAME_SHAPED))
67 SetShape(m_shape);
68 }
69
70 bool wxNonOwnedWindow::SetShape(const wxRegion& region)
71 {
72 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
73 wxT("Shaped windows must be created with the wxFRAME_SHAPED style."));
74
75 if ( gtk_widget_get_realized(m_widget) )
76 {
77 if ( m_wxwindow )
78 do_shape_combine_region(gtk_widget_get_window(m_wxwindow), region);
79
80 return do_shape_combine_region(gtk_widget_get_window(m_widget), region);
81 }
82 else // not realized yet
83 {
84 // store the shape to set, it will be really set once we're realized
85 m_shape = region;
86
87 // we don't know if we're going to succeed or fail, be optimistic by
88 // default
89 return true;
90 }
91 }