The usual fix for PCH-less compilation after the last commit.
[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/frame.h" // Just for wxFRAME_SHAPED.
28 #include "wx/nonownedwnd.h"
29 #include "wx/region.h"
30 #endif // WX_PRECOMP
31
32 #include "wx/gtk/private.h"
33
34 #include <gdk/gdk.h>
35
36 namespace
37 {
38
39 // helper
40 bool do_shape_combine_region(GdkWindow* window, const wxRegion& region)
41 {
42 if (window)
43 {
44 if (region.IsEmpty())
45 {
46 gdk_window_shape_combine_mask(window, NULL, 0, 0);
47 }
48 else
49 {
50 gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0);
51 return true;
52 }
53 }
54 return false;
55 }
56
57 } // anonymous namespace
58
59
60 // ============================================================================
61 // wxNonOwnedWindow implementation
62 // ============================================================================
63
64 void wxNonOwnedWindow::GTKHandleRealized()
65 {
66 wxNonOwnedWindowBase::GTKHandleRealized();
67
68 if (HasFlag(wxFRAME_SHAPED))
69 SetShape(m_shape);
70 }
71
72 bool wxNonOwnedWindow::SetShape(const wxRegion& region)
73 {
74 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
75 wxT("Shaped windows must be created with the wxFRAME_SHAPED style."));
76
77 if ( gtk_widget_get_realized(m_widget) )
78 {
79 if ( m_wxwindow )
80 do_shape_combine_region(gtk_widget_get_window(m_wxwindow), region);
81
82 return do_shape_combine_region(gtk_widget_get_window(m_widget), region);
83 }
84 else // not realized yet
85 {
86 // store the shape to set, it will be really set once we're realized
87 m_shape = region;
88
89 // we don't know if we're going to succeed or fail, be optimistic by
90 // default
91 return true;
92 }
93 }