1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/nonownedwnd.mm
3 // Purpose: non owned window for iphone
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: nonownedwnd.mm 48805 2007-09-19 14:52:25Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/osx/private.h"
16 #include "wx/nonownedwnd.h"
19 IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowIPhoneImpl , wxNonOwnedWindowImpl )
21 wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl( wxNonOwnedWindow* nonownedwnd) :
22 wxNonOwnedWindowImpl(nonownedwnd)
25 m_macFullScreenData = NULL;
28 wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl()
31 m_macFullScreenData = NULL;
34 wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl()
36 [m_macWindow release];
39 void wxNonOwnedWindowIPhoneImpl::Destroy()
41 wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) );
44 void wxNonOwnedWindowIPhoneImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
45 long style, long extraStyle, const wxString& name )
47 m_macWindow = [UIWindow alloc];
49 UIWindowLevel level = UIWindowLevelNormal;
51 // most styles are not supported on the iphone
53 if ( style & wxFRAME_TOOL_WINDOW )
55 level = UIWindowLevelAlert; ;
57 else if ( ( style & wxPOPUP_WINDOW ) )
59 level = UIWindowLevelAlert;;
61 else if ( ( style & wxCAPTION ) )
64 else if ( ( style & wxFRAME_DRAWER ) )
71 if ( ( style & wxSTAY_ON_TOP ) )
72 level = UIWindowLevelAlert;
73 CGRect r = CGRectMake( 0, 0, size.x, size.y) ;
75 [m_macWindow initWithFrame:r ];
77 [m_macWindow setWindowLevel:level];
78 // [m_macWindow makeKeyAndOrderFront:nil];
82 WXWindow wxNonOwnedWindowIPhoneImpl::GetWXWindow() const
87 void wxNonOwnedWindowIPhoneImpl::Raise()
91 void wxNonOwnedWindowIPhoneImpl::Lower()
95 bool wxNonOwnedWindowIPhoneImpl::Show(bool show)
97 [m_macWindow setHidden:(show ? NO : YES)];
100 //[m_macWindow orderFront: self];
101 [m_macWindow makeKeyWindow];
106 bool wxNonOwnedWindowIPhoneImpl::ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout)
111 void wxNonOwnedWindowIPhoneImpl::Update()
113 // TODO [m_macWindow displayIfNeeded];
116 bool wxNonOwnedWindowIPhoneImpl::SetTransparent(wxByte alpha)
118 [m_macWindow setAlpha:(CGFloat) alpha/255.0];
122 bool wxNonOwnedWindowIPhoneImpl::SetBackgroundColour(const wxColour& col )
127 void wxNonOwnedWindowIPhoneImpl::SetExtraStyle( long exStyle )
129 // no special styles supported
132 bool wxNonOwnedWindowIPhoneImpl::SetBackgroundStyle(wxBackgroundStyle style)
137 bool wxNonOwnedWindowIPhoneImpl::CanSetTransparent()
142 void wxNonOwnedWindowIPhoneImpl::MoveWindow(int x, int y, int width, int height)
144 CGRect r = CGRectMake( 0,0,width,height) ;
145 [m_macWindow setFrame:r];
148 void wxNonOwnedWindowIPhoneImpl::GetPosition( int &x, int &y ) const
150 CGRect r = [m_macWindow frame];
155 void wxNonOwnedWindowIPhoneImpl::GetSize( int &width, int &height ) const
157 CGRect rect = [m_macWindow frame];
158 width = rect.size.width;
159 height = rect.size.height;
162 void wxNonOwnedWindowIPhoneImpl::GetContentArea( int& left, int &right, int &width, int &height ) const
164 CGRect rect = [m_macWindow frame];
165 width = rect.size.width;
166 height = rect.size.height;
171 bool wxNonOwnedWindowIPhoneImpl::SetShape(const wxRegion& region)
176 void wxNonOwnedWindowIPhoneImpl::SetTitle( const wxString& title, wxFontEncoding encoding )
178 // TODO change title of app ?
181 bool wxNonOwnedWindowIPhoneImpl::IsMaximized() const
186 bool wxNonOwnedWindowIPhoneImpl::IsIconized() const
191 void wxNonOwnedWindowIPhoneImpl::Iconize( bool iconize )
195 void wxNonOwnedWindowIPhoneImpl::Maximize(bool maximize)
199 bool wxNonOwnedWindowIPhoneImpl::IsFullScreen() const
201 return m_macFullScreenData != NULL ;
204 bool wxNonOwnedWindowIPhoneImpl::ShowFullScreen(bool show, long style)
209 void wxNonOwnedWindowIPhoneImpl::RequestUserAttention(int WXUNUSED(flags))
213 void wxNonOwnedWindowIPhoneImpl::ScreenToWindow( int *x, int *y )
215 CGPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
216 p = [m_macWindow convertPoint:p fromWindow:nil];
223 void wxNonOwnedWindowIPhoneImpl::WindowToScreen( int *x, int *y )
225 CGPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
226 p = [m_macWindow convertPoint:p toWindow:nil];
233 wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
234 long style, long extraStyle, const wxString& name )
236 wxNonOwnedWindowImpl* now = new wxNonOwnedWindowIPhoneImpl( wxpeer );
237 now->Create( parent, pos, size, style , extraStyle, name );