File: nonownedwnd.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (113 lines) | stat: -rw-r--r-- 3,596 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/nonownedwnd.h
// Purpose:     declares wxNonTopLevelWindow class
// Author:      Vaclav Slavik
// Modified by:
// Created:     2006-12-24
// Copyright:   (c) 2006 TT-Solutions
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_NONOWNEDWND_H_
#define _WX_NONOWNEDWND_H_

#include "wx/window.h"

// Styles that can be used with any wxNonOwnedWindow:
#define wxFRAME_SHAPED          0x0010  // Create a window that is able to be shaped

class WXDLLIMPEXP_FWD_CORE wxGraphicsPath;

// ----------------------------------------------------------------------------
// wxNonOwnedWindow: a window that is not a child window of another one.
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxNonOwnedWindowBase : public wxWindow
{
public:
    // Set the shape of the window to the given region.
    // Returns true if the platform supports this feature (and the
    // operation is successful.)
    bool SetShape(const wxRegion& region)
    {
        // This style is in fact only needed by wxOSX/Carbon so once we don't
        // use this port any more, we could get rid of this requirement, but
        // for now you must specify wxFRAME_SHAPED for SetShape() to work on
        // all platforms.
        wxCHECK_MSG
        (
            HasFlag(wxFRAME_SHAPED), false,
            wxS("Shaped windows must be created with the wxFRAME_SHAPED style.")
        );

        return region.IsEmpty() ? DoClearShape() : DoSetRegionShape(region);
    }

#if wxUSE_GRAPHICS_CONTEXT
    // Set the shape using the specified path.
    bool SetShape(const wxGraphicsPath& path)
    {
        wxCHECK_MSG
        (
            HasFlag(wxFRAME_SHAPED), false,
            wxS("Shaped windows must be created with the wxFRAME_SHAPED style.")
        );

        return DoSetPathShape(path);
    }
#endif // wxUSE_GRAPHICS_CONTEXT


    // Overridden base class methods.
    // ------------------------------

    virtual void AdjustForParentClientOrigin(int& WXUNUSED(x), int& WXUNUSED(y),
                                             int WXUNUSED(sizeFlags) = 0) const
    {
        // Non owned windows positions don't need to be adjusted for parent
        // client area origin so simply do nothing here.
    }

    virtual void InheritAttributes()
    {
        // Non owned windows don't inherit attributes from their parent window
        // (if the parent frame is red, it doesn't mean that all dialogs shown
        // by it should be red as well), so don't do anything here neither.
    }

protected:
    virtual bool DoClearShape()
    {
        return false;
    }

    virtual bool DoSetRegionShape(const wxRegion& WXUNUSED(region))
    {
        return false;
    }

#if wxUSE_GRAPHICS_CONTEXT
    virtual bool DoSetPathShape(const wxGraphicsPath& WXUNUSED(path))
    {
        return false;
    }
#endif // wxUSE_GRAPHICS_CONTEXT
};

#if defined(__WXDFB__)
    #include "wx/dfb/nonownedwnd.h"
#elif defined(__WXGTK20__)
    #include "wx/gtk/nonownedwnd.h"
#elif defined(__WXMAC__)
    #include "wx/osx/nonownedwnd.h"
#elif defined(__WXMSW__) && !defined(__WXWINCE__)
    #include "wx/msw/nonownedwnd.h"
#else
    // No special class needed in other ports, they can derive both wxTLW and
    // wxPopupWindow directly from wxWindow and don't implement SetShape().
    class wxNonOwnedWindow : public wxNonOwnedWindowBase
    {
    };
#endif

#endif // _WX_NONOWNEDWND_H_