]> git.saurik.com Git - wxWidgets.git/blame - src/osx/iphone/nonownedwnd.mm
Fix signatures of various image handlers methods.
[wxWidgets.git] / src / osx / iphone / nonownedwnd.mm
CommitLineData
c16b2153 1/////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/cocoa/nonownedwnd.mm
c16b2153
SC
3// Purpose: non owned window for iphone
4// Author: Stefan Csomor
5// Modified by:
6// Created: 2008-06-20
7// RCS-ID: $Id: nonownedwnd.mm 48805 2007-09-19 14:52:25Z SC $
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#include "wx/osx/private.h"
15
16#include "wx/nonownedwnd.h"
17#include "wx/frame.h"
18
d3929256
SC
19CGRect wxToNSRect(UIView* parent, const wxRect& r )
20{
21 CGRect frame = parent ? [parent bounds] : [[UIScreen mainScreen] bounds];
22 int y = r.y;
23 int x = r.x ;
24 return CGRectMake(x, y, r.width , r.height);
25}
26
27wxRect wxFromNSRect( UIView* parent, const CGRect& rect )
28{
29 CGRect frame = parent ? [parent bounds] : [[UIScreen mainScreen] bounds];
30 int y = rect.origin.y;
31 int x = rect.origin.x;
32 return wxRect( x, y, rect.size.width, rect.size.height );
33}
34
35CGPoint wxToNSPoint( UIView* parent, const wxPoint& p )
36{
37 CGRect frame = parent ? [parent bounds] : [[UIScreen mainScreen] bounds];
38 int x = p.x ;
39 int y = p.y;
40 return CGPointMake(x, y);
41}
42
43wxPoint wxFromNSPoint( UIView* parent, const CGPoint& p )
44{
45 CGRect frame = parent ? [parent bounds] : [[UIScreen mainScreen] bounds];
46 int x = p.x;
47 int y = p.y;
48 return wxPoint( x, y);
49}
50
51
c16b2153
SC
52IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowIPhoneImpl , wxNonOwnedWindowImpl )
53
54wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl( wxNonOwnedWindow* nonownedwnd) :
55 wxNonOwnedWindowImpl(nonownedwnd)
56{
57 m_macWindow = NULL;
58 m_macFullScreenData = NULL;
59}
60
61wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl()
62{
63 m_macWindow = NULL;
64 m_macFullScreenData = NULL;
65}
66
67wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl()
68{
69 [m_macWindow release];
70}
71
72void wxNonOwnedWindowIPhoneImpl::Destroy()
73{
74 wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) );
75}
76
77void wxNonOwnedWindowIPhoneImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
78long style, long extraStyle, const wxString& name )
79{
80 m_macWindow = [UIWindow alloc];
81
82 UIWindowLevel level = UIWindowLevelNormal;
83
84 // most styles are not supported on the iphone
85
86 if ( style & wxFRAME_TOOL_WINDOW )
87 {
88 level = UIWindowLevelAlert; ;
89 }
90 else if ( ( style & wxPOPUP_WINDOW ) )
91 {
92 level = UIWindowLevelAlert;;
93 }
94 else if ( ( style & wxCAPTION ) )
95 {
96 }
97 else if ( ( style & wxFRAME_DRAWER ) )
98 {
99 }
100 else
101 {
102 }
103
104 if ( ( style & wxSTAY_ON_TOP ) )
105 level = UIWindowLevelAlert;
106 CGRect r = CGRectMake( 0, 0, size.x, size.y) ;
107
108 [m_macWindow initWithFrame:r ];
109
110 [m_macWindow setWindowLevel:level];
111 // [m_macWindow makeKeyAndOrderFront:nil];
112}
113
114
115WXWindow wxNonOwnedWindowIPhoneImpl::GetWXWindow() const
116{
117 return m_macWindow;
118}
119
120void wxNonOwnedWindowIPhoneImpl::Raise()
121{
122}
123
124void wxNonOwnedWindowIPhoneImpl::Lower()
125{
126}
127
128bool wxNonOwnedWindowIPhoneImpl::Show(bool show)
129{
130 [m_macWindow setHidden:(show ? NO : YES)];
131 if ( show )
132 {
133 //[m_macWindow orderFront: self];
134 [m_macWindow makeKeyWindow];
135 }
136 return true;
137}
138
139bool wxNonOwnedWindowIPhoneImpl::ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout)
140{
141 return Show(show);
142}
143
144void wxNonOwnedWindowIPhoneImpl::Update()
145{
146// TODO [m_macWindow displayIfNeeded];
147}
148
149bool wxNonOwnedWindowIPhoneImpl::SetTransparent(wxByte alpha)
150{
151 [m_macWindow setAlpha:(CGFloat) alpha/255.0];
152 return true;
153}
154
155bool wxNonOwnedWindowIPhoneImpl::SetBackgroundColour(const wxColour& col )
156{
157 return true;
158}
159
160void wxNonOwnedWindowIPhoneImpl::SetExtraStyle( long exStyle )
161{
162 // no special styles supported
163}
164
165bool wxNonOwnedWindowIPhoneImpl::SetBackgroundStyle(wxBackgroundStyle style)
166{
167 return true;
168}
169
170bool wxNonOwnedWindowIPhoneImpl::CanSetTransparent()
171{
172 return true;
173}
174
175void wxNonOwnedWindowIPhoneImpl::MoveWindow(int x, int y, int width, int height)
176{
d3929256 177 CGRect r = CGRectMake( x,y,width,height) ;
c16b2153
SC
178 [m_macWindow setFrame:r];
179}
180
181void wxNonOwnedWindowIPhoneImpl::GetPosition( int &x, int &y ) const
182{
183 CGRect r = [m_macWindow frame];
184 x = r.origin.x;
185 y = r.origin.y;
186}
187
188void wxNonOwnedWindowIPhoneImpl::GetSize( int &width, int &height ) const
189{
190 CGRect rect = [m_macWindow frame];
191 width = rect.size.width;
192 height = rect.size.height;
193}
194
d3929256 195void wxNonOwnedWindowIPhoneImpl::GetContentArea( int& left, int &top, int &width, int &height ) const
c16b2153 196{
d3929256 197 CGRect rect = [m_macWindow frame];
c16b2153
SC
198 width = rect.size.width;
199 height = rect.size.height;
d3929256
SC
200 left = rect.origin.x;
201 top = rect.origin.y;
c16b2153
SC
202}
203
204bool wxNonOwnedWindowIPhoneImpl::SetShape(const wxRegion& region)
205{
206 return false;
207}
208
209void wxNonOwnedWindowIPhoneImpl::SetTitle( const wxString& title, wxFontEncoding encoding )
210{
211// TODO change title of app ?
212}
213
214bool wxNonOwnedWindowIPhoneImpl::IsMaximized() const
215{
216 return false;
217}
218
219bool wxNonOwnedWindowIPhoneImpl::IsIconized() const
220{
221 return false;
222}
223
224void wxNonOwnedWindowIPhoneImpl::Iconize( bool iconize )
225{
226}
227
228void wxNonOwnedWindowIPhoneImpl::Maximize(bool maximize)
229{
230}
231
232bool wxNonOwnedWindowIPhoneImpl::IsFullScreen() const
233{
234 return m_macFullScreenData != NULL ;
235}
236
237bool wxNonOwnedWindowIPhoneImpl::ShowFullScreen(bool show, long style)
238{
239 return true;
240}
241
242void wxNonOwnedWindowIPhoneImpl::RequestUserAttention(int WXUNUSED(flags))
243{
244}
245
246void wxNonOwnedWindowIPhoneImpl::ScreenToWindow( int *x, int *y )
247{
248 CGPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
249 p = [m_macWindow convertPoint:p fromWindow:nil];
250 if ( x )
251 *x = p.x;
252 if ( y )
253 *y = p.y;
254}
255
256void wxNonOwnedWindowIPhoneImpl::WindowToScreen( int *x, int *y )
257{
258 CGPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
259 p = [m_macWindow convertPoint:p toWindow:nil];
260 if ( x )
261 *x = p.x;
262 if ( y )
263 *y = p.y;
264}
265
524c47aa
SC
266wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
267 long style, long extraStyle, const wxString& name )
268{
269 wxNonOwnedWindowImpl* now = new wxNonOwnedWindowIPhoneImpl( wxpeer );
270 now->Create( parent, pos, size, style , extraStyle, name );
271 return now;
272}