1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/nonownedwnd.h
3 // Purpose: declares wxNonOwnedWindow class
4 // Author: Stefan Csomor
7 // Copyright: (c) 2008 Stefan Csomor
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_MAC_NONOWNEDWND_H_
12 #define _WX_MAC_NONOWNEDWND_H_
14 #include "wx/window.h"
16 #include "wx/graphics.h"
18 #if wxUSE_SYSTEM_OPTIONS
19 #define wxMAC_WINDOW_PLAIN_TRANSITION wxT("mac.window-plain-transition")
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 // This class represents "non-owned" window. A window is owned by another
27 // window if it has a parent and is positioned within the parent. For example,
28 // wxFrame is non-owned, because even though it can have a parent, it's
29 // location is independent of it. This class is for internal use only, it's
30 // the base class for wxTopLevelWindow and wxPopupWindow.
32 class wxNonOwnedWindowImpl
;
34 class WXDLLIMPEXP_CORE wxNonOwnedWindow
: public wxNonOwnedWindowBase
37 // constructors and such
38 wxNonOwnedWindow() { Init(); }
40 wxNonOwnedWindow(wxWindow
*parent
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
45 const wxString
& name
= wxPanelNameStr
)
49 (void)Create(parent
, id
, pos
, size
, style
, name
);
52 bool Create(wxWindow
*parent
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
57 const wxString
& name
= wxPanelNameStr
);
59 bool Create(wxWindow
*parent
, WXWindow nativeWindow
);
61 virtual ~wxNonOwnedWindow();
63 virtual void SubclassWin(WXWindow nativeWindow
);
64 virtual void UnsubclassWin();
66 virtual wxPoint
GetClientAreaOrigin() const;
68 // implement base class pure virtuals
70 virtual bool SetTransparent(wxByte alpha
);
71 virtual bool CanSetTransparent();
73 virtual bool SetBackgroundStyle(wxBackgroundStyle style
);
75 virtual void Update();
77 WXWindow
GetWXWindow() const ;
78 static wxNonOwnedWindow
* GetFromWXWindow( WXWindow win
);
80 // implementation from now on
81 // --------------------------
83 // These accessors are Mac-specific and don't exist in other ports.
84 const wxRegion
& GetShape() const { return m_shape
; }
85 #if wxUSE_GRAPHICS_CONTEXT
86 const wxGraphicsPath
& GetShapePath() { return m_shapePath
; }
87 #endif // wxUSE_GRAPHICS_CONTEXT
89 // activation hooks only necessary for MDI Implementation
90 static void MacDelayedDeactivation(long timestamp
);
91 virtual void MacActivate( long timestamp
, bool inIsActivating
) ;
93 virtual void SetWindowStyleFlag(long flags
);
97 virtual bool Show( bool show
= true );
99 virtual void SetExtraStyle(long exStyle
) ;
101 virtual bool SetBackgroundColour( const wxColour
&colour
);
103 wxNonOwnedWindowImpl
* GetNonOwnedPeer() const { return m_nowpeer
; }
105 #if wxOSX_USE_COCOA_OR_IPHONE
106 // override the base class method to return an NSWindow instead of NSView
107 virtual void *OSXGetViewOrWindow() const;
110 // osx specific event handling common for all osx-ports
112 virtual void HandleActivated( double timestampsec
, bool didActivate
);
113 virtual void HandleResized( double timestampsec
);
114 virtual void HandleMoved( double timestampsec
);
115 virtual void HandleResizing( double timestampsec
, wxRect
* rect
);
117 void WindowWasPainted();
119 virtual bool Destroy();
122 // common part of all ctors
125 virtual void DoGetPosition( int *x
, int *y
) const;
126 virtual void DoGetSize( int *width
, int *height
) const;
127 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
128 virtual void DoGetClientSize(int *width
, int *height
) const;
130 virtual bool OSXShowWithEffect(bool show
,
134 virtual bool DoClearShape();
135 virtual bool DoSetRegionShape(const wxRegion
& region
);
136 #if wxUSE_GRAPHICS_CONTEXT
137 virtual bool DoSetPathShape(const wxGraphicsPath
& path
);
138 #endif // wxUSE_GRAPHICS_CONTEXT
140 virtual void WillBeDestroyed();
142 wxNonOwnedWindowImpl
* m_nowpeer
;
144 // wxWindowMac* m_macFocus ;
146 static wxNonOwnedWindow
*s_macDeactivateWindow
;
149 static clock_t s_lastFlush
;
152 #if wxUSE_GRAPHICS_CONTEXT
153 wxGraphicsPath m_shapePath
;
154 #endif // wxUSE_GRAPHICS_CONTEXT
157 // list of all frames and modeless dialogs
158 extern WXDLLIMPEXP_DATA_CORE(wxWindowList
) wxModelessWindows
;
161 #endif // _WX_MAC_NONOWNEDWND_H_