]> git.saurik.com Git - wxWidgets.git/blob - src/osx/iphone/nonownedwnd.mm
remove incorrect cast of wxString to char* (unnecessary and breaks wxUSE_STL build)
[wxWidgets.git] / src / osx / iphone / nonownedwnd.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/nonownedwnd.mm
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
19 IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowIPhoneImpl , wxNonOwnedWindowImpl )
20
21 wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl( wxNonOwnedWindow* nonownedwnd) :
22 wxNonOwnedWindowImpl(nonownedwnd)
23 {
24 m_macWindow = NULL;
25 m_macFullScreenData = NULL;
26 }
27
28 wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl()
29 {
30 m_macWindow = NULL;
31 m_macFullScreenData = NULL;
32 }
33
34 wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl()
35 {
36 [m_macWindow release];
37 }
38
39 void wxNonOwnedWindowIPhoneImpl::Destroy()
40 {
41 wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) );
42 }
43
44 void wxNonOwnedWindowIPhoneImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
45 long style, long extraStyle, const wxString& name )
46 {
47 m_macWindow = [UIWindow alloc];
48
49 UIWindowLevel level = UIWindowLevelNormal;
50
51 // most styles are not supported on the iphone
52
53 if ( style & wxFRAME_TOOL_WINDOW )
54 {
55 level = UIWindowLevelAlert; ;
56 }
57 else if ( ( style & wxPOPUP_WINDOW ) )
58 {
59 level = UIWindowLevelAlert;;
60 }
61 else if ( ( style & wxCAPTION ) )
62 {
63 }
64 else if ( ( style & wxFRAME_DRAWER ) )
65 {
66 }
67 else
68 {
69 }
70
71 if ( ( style & wxSTAY_ON_TOP ) )
72 level = UIWindowLevelAlert;
73 CGRect r = CGRectMake( 0, 0, size.x, size.y) ;
74
75 [m_macWindow initWithFrame:r ];
76
77 [m_macWindow setWindowLevel:level];
78 // [m_macWindow makeKeyAndOrderFront:nil];
79 }
80
81
82 WXWindow wxNonOwnedWindowIPhoneImpl::GetWXWindow() const
83 {
84 return m_macWindow;
85 }
86
87 void wxNonOwnedWindowIPhoneImpl::Raise()
88 {
89 }
90
91 void wxNonOwnedWindowIPhoneImpl::Lower()
92 {
93 }
94
95 bool wxNonOwnedWindowIPhoneImpl::Show(bool show)
96 {
97 [m_macWindow setHidden:(show ? NO : YES)];
98 if ( show )
99 {
100 //[m_macWindow orderFront: self];
101 [m_macWindow makeKeyWindow];
102 }
103 return true;
104 }
105
106 bool wxNonOwnedWindowIPhoneImpl::ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout)
107 {
108 return Show(show);
109 }
110
111 void wxNonOwnedWindowIPhoneImpl::Update()
112 {
113 // TODO [m_macWindow displayIfNeeded];
114 }
115
116 bool wxNonOwnedWindowIPhoneImpl::SetTransparent(wxByte alpha)
117 {
118 [m_macWindow setAlpha:(CGFloat) alpha/255.0];
119 return true;
120 }
121
122 bool wxNonOwnedWindowIPhoneImpl::SetBackgroundColour(const wxColour& col )
123 {
124 return true;
125 }
126
127 void wxNonOwnedWindowIPhoneImpl::SetExtraStyle( long exStyle )
128 {
129 // no special styles supported
130 }
131
132 bool wxNonOwnedWindowIPhoneImpl::SetBackgroundStyle(wxBackgroundStyle style)
133 {
134 return true;
135 }
136
137 bool wxNonOwnedWindowIPhoneImpl::CanSetTransparent()
138 {
139 return true;
140 }
141
142 void wxNonOwnedWindowIPhoneImpl::MoveWindow(int x, int y, int width, int height)
143 {
144 CGRect r = CGRectMake( 0,0,width,height) ;
145 [m_macWindow setFrame:r];
146 }
147
148 void wxNonOwnedWindowIPhoneImpl::GetPosition( int &x, int &y ) const
149 {
150 CGRect r = [m_macWindow frame];
151 x = r.origin.x;
152 y = r.origin.y;
153 }
154
155 void wxNonOwnedWindowIPhoneImpl::GetSize( int &width, int &height ) const
156 {
157 CGRect rect = [m_macWindow frame];
158 width = rect.size.width;
159 height = rect.size.height;
160 }
161
162 void wxNonOwnedWindowIPhoneImpl::GetContentArea( int& left, int &right, int &width, int &height ) const
163 {
164 CGRect rect = [m_macWindow frame];
165 width = rect.size.width;
166 height = rect.size.height;
167 left = 0;
168 right = 0;
169 }
170
171 bool wxNonOwnedWindowIPhoneImpl::SetShape(const wxRegion& region)
172 {
173 return false;
174 }
175
176 void wxNonOwnedWindowIPhoneImpl::SetTitle( const wxString& title, wxFontEncoding encoding )
177 {
178 // TODO change title of app ?
179 }
180
181 bool wxNonOwnedWindowIPhoneImpl::IsMaximized() const
182 {
183 return false;
184 }
185
186 bool wxNonOwnedWindowIPhoneImpl::IsIconized() const
187 {
188 return false;
189 }
190
191 void wxNonOwnedWindowIPhoneImpl::Iconize( bool iconize )
192 {
193 }
194
195 void wxNonOwnedWindowIPhoneImpl::Maximize(bool maximize)
196 {
197 }
198
199 bool wxNonOwnedWindowIPhoneImpl::IsFullScreen() const
200 {
201 return m_macFullScreenData != NULL ;
202 }
203
204 bool wxNonOwnedWindowIPhoneImpl::ShowFullScreen(bool show, long style)
205 {
206 return true;
207 }
208
209 void wxNonOwnedWindowIPhoneImpl::RequestUserAttention(int WXUNUSED(flags))
210 {
211 }
212
213 void wxNonOwnedWindowIPhoneImpl::ScreenToWindow( int *x, int *y )
214 {
215 CGPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
216 p = [m_macWindow convertPoint:p fromWindow:nil];
217 if ( x )
218 *x = p.x;
219 if ( y )
220 *y = p.y;
221 }
222
223 void wxNonOwnedWindowIPhoneImpl::WindowToScreen( int *x, int *y )
224 {
225 CGPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
226 p = [m_macWindow convertPoint:p toWindow:nil];
227 if ( x )
228 *x = p.x;
229 if ( y )
230 *y = p.y;
231 }
232
233 wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
234 long style, long extraStyle, const wxString& name )
235 {
236 wxNonOwnedWindowImpl* now = new wxNonOwnedWindowIPhoneImpl( wxpeer );
237 now->Create( parent, pos, size, style , extraStyle, name );
238 return now;
239 }