]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/nonownedwnd.h | |
3 | // Purpose: declares wxNonTopLevelWindow class | |
4 | // Author: Vaclav Slavik | |
5 | // Modified by: | |
6 | // Created: 2006-12-24 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2006 TT-Solutions | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_NONOWNEDWND_H_ | |
13 | #define _WX_NONOWNEDWND_H_ | |
14 | ||
15 | #include "wx/window.h" | |
16 | ||
17 | // Styles that can be used with any wxNonOwnedWindow: | |
18 | #define wxFRAME_SHAPED 0x0010 // Create a window that is able to be shaped | |
19 | ||
20 | class WXDLLIMPEXP_FWD_CORE wxGraphicsPath; | |
21 | ||
22 | // ---------------------------------------------------------------------------- | |
23 | // wxNonOwnedWindow: a window that is not a child window of another one. | |
24 | // ---------------------------------------------------------------------------- | |
25 | ||
26 | class WXDLLIMPEXP_CORE wxNonOwnedWindowBase : public wxWindow | |
27 | { | |
28 | public: | |
29 | // Set the shape of the window to the given region. | |
30 | // Returns true if the platform supports this feature (and the | |
31 | // operation is successful.) | |
32 | bool SetShape(const wxRegion& region) | |
33 | { | |
34 | // This style is in fact only needed by wxOSX/Carbon so once we don't | |
35 | // use this port any more, we could get rid of this requirement, but | |
36 | // for now you must specify wxFRAME_SHAPED for SetShape() to work on | |
37 | // all platforms. | |
38 | wxCHECK_MSG | |
39 | ( | |
40 | HasFlag(wxFRAME_SHAPED), false, | |
41 | wxS("Shaped windows must be created with the wxFRAME_SHAPED style.") | |
42 | ); | |
43 | ||
44 | return region.IsEmpty() ? DoClearShape() : DoSetRegionShape(region); | |
45 | } | |
46 | ||
47 | #if wxUSE_GRAPHICS_CONTEXT | |
48 | // Set the shape using the specified path. | |
49 | bool SetShape(const wxGraphicsPath& path) | |
50 | { | |
51 | wxCHECK_MSG | |
52 | ( | |
53 | HasFlag(wxFRAME_SHAPED), false, | |
54 | wxS("Shaped windows must be created with the wxFRAME_SHAPED style.") | |
55 | ); | |
56 | ||
57 | return DoSetPathShape(path); | |
58 | } | |
59 | #endif // wxUSE_GRAPHICS_CONTEXT | |
60 | ||
61 | ||
62 | // Overridden base class methods. | |
63 | // ------------------------------ | |
64 | ||
65 | virtual void AdjustForParentClientOrigin(int& WXUNUSED(x), int& WXUNUSED(y), | |
66 | int WXUNUSED(sizeFlags) = 0) const | |
67 | { | |
68 | // Non owned windows positions don't need to be adjusted for parent | |
69 | // client area origin so simply do nothing here. | |
70 | } | |
71 | ||
72 | virtual void InheritAttributes() | |
73 | { | |
74 | // Non owned windows don't inherit attributes from their parent window | |
75 | // (if the parent frame is red, it doesn't mean that all dialogs shown | |
76 | // by it should be red as well), so don't do anything here neither. | |
77 | } | |
78 | ||
79 | protected: | |
80 | virtual bool DoClearShape() | |
81 | { | |
82 | return false; | |
83 | } | |
84 | ||
85 | virtual bool DoSetRegionShape(const wxRegion& WXUNUSED(region)) | |
86 | { | |
87 | return false; | |
88 | } | |
89 | ||
90 | #if wxUSE_GRAPHICS_CONTEXT | |
91 | virtual bool DoSetPathShape(const wxGraphicsPath& WXUNUSED(path)) | |
92 | { | |
93 | return false; | |
94 | } | |
95 | #endif // wxUSE_GRAPHICS_CONTEXT | |
96 | }; | |
97 | ||
98 | #if defined(__WXDFB__) | |
99 | #include "wx/dfb/nonownedwnd.h" | |
100 | #elif defined(__WXGTK20__) | |
101 | #include "wx/gtk/nonownedwnd.h" | |
102 | #elif defined(__WXMAC__) | |
103 | #include "wx/osx/nonownedwnd.h" | |
104 | #elif defined(__WXMSW__) && !defined(__WXWINCE__) | |
105 | #include "wx/msw/nonownedwnd.h" | |
106 | #else | |
107 | // No special class needed in other ports, they can derive both wxTLW and | |
108 | // wxPopupWindow directly from wxWindow and don't implement SetShape(). | |
109 | class wxNonOwnedWindow : public wxNonOwnedWindowBase | |
110 | { | |
111 | }; | |
112 | #endif | |
113 | ||
114 | #endif // _WX_NONOWNEDWND_H_ |