]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.cpp | |
e766c8a9 | 3 | // Purpose: wxWindowMac |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
e9576ca5 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "window.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/setup.h" | |
17 | #include "wx/menu.h" | |
5fde6fcc | 18 | #include "wx/window.h" |
e9576ca5 SC |
19 | #include "wx/dc.h" |
20 | #include "wx/dcclient.h" | |
14c9cbdb | 21 | #include "wx/utils.h" |
e9576ca5 SC |
22 | #include "wx/app.h" |
23 | #include "wx/panel.h" | |
24 | #include "wx/layout.h" | |
25 | #include "wx/dialog.h" | |
03e11df5 GD |
26 | #include "wx/scrolbar.h" |
27 | #include "wx/statbox.h" | |
e9576ca5 SC |
28 | #include "wx/button.h" |
29 | #include "wx/settings.h" | |
30 | #include "wx/msgdlg.h" | |
31 | #include "wx/frame.h" | |
2f1ae414 | 32 | #include "wx/tooltip.h" |
c809f3be | 33 | #include "wx/statusbr.h" |
e9576ca5 | 34 | #include "wx/menuitem.h" |
4ac219f6 | 35 | #include "wx/spinctrl.h" |
e9576ca5 | 36 | #include "wx/log.h" |
467e3168 | 37 | #include "wx/geometry.h" |
00627198 | 38 | #include "wx/textctrl.h" |
e9576ca5 | 39 | |
facd6764 SC |
40 | #include "wx/toolbar.h" |
41 | #include "wx/dc.h" | |
42 | ||
7c551d95 SC |
43 | #if wxUSE_CARET |
44 | #include "wx/caret.h" | |
45 | #endif // wxUSE_CARET | |
46 | ||
db7a550b SC |
47 | #define MAC_SCROLLBAR_SIZE 15 |
48 | #define MAC_SMALL_SCROLLBAR_SIZE 11 | |
519cb848 | 49 | |
d497dca4 | 50 | #include "wx/mac/uma.h" |
66a09d47 SC |
51 | #ifndef __DARWIN__ |
52 | #include <Windows.h> | |
53 | #include <ToolUtils.h> | |
1d879215 DS |
54 | #include <Scrap.h> |
55 | #include <MacTextEditor.h> | |
66a09d47 | 56 | #endif |
519cb848 | 57 | |
41218df1 | 58 | #if TARGET_API_MAC_OSX |
facd6764 | 59 | #ifndef __HIVIEW__ |
8b573fb8 | 60 | #include <HIToolbox/HIView.h> |
facd6764 | 61 | #endif |
41218df1 | 62 | #endif |
facd6764 | 63 | |
e9576ca5 SC |
64 | #if wxUSE_DRAG_AND_DROP |
65 | #include "wx/dnd.h" | |
66 | #endif | |
67 | ||
68 | #include <string.h> | |
69 | ||
70 | extern wxList wxPendingDelete; | |
71 | ||
fc0daf84 SC |
72 | #ifdef __WXUNIVERSAL__ |
73 | IMPLEMENT_ABSTRACT_CLASS(wxWindowMac, wxWindowBase) | |
74 | #else // __WXMAC__ | |
75 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) | |
76 | #endif // __WXUNIVERSAL__/__WXMAC__ | |
77 | ||
2f1ae414 | 78 | #if !USE_SHARED_LIBRARY |
fc0daf84 SC |
79 | |
80 | BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase) | |
facd6764 SC |
81 | EVT_NC_PAINT(wxWindowMac::OnNcPaint) |
82 | EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground) | |
83 | // TODO EVT_PAINT(wxWindowMac::OnPaint) | |
5ca0d812 SC |
84 | EVT_SET_FOCUS(wxWindowMac::OnSetFocus) |
85 | EVT_KILL_FOCUS(wxWindowMac::OnSetFocus) | |
facd6764 | 86 | EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent) |
e9576ca5 SC |
87 | END_EVENT_TABLE() |
88 | ||
2f1ae414 | 89 | #endif |
e9576ca5 | 90 | |
94abc21f SC |
91 | #define wxMAC_DEBUG_REDRAW 0 |
92 | #ifndef wxMAC_DEBUG_REDRAW | |
93 | #define wxMAC_DEBUG_REDRAW 0 | |
94 | #endif | |
95 | ||
5ca0d812 | 96 | #define wxMAC_USE_THEME_BORDER 1 |
e9576ca5 | 97 | |
42ef83fa SC |
98 | // --------------------------------------------------------------------------- |
99 | // Utility Routines to move between different coordinate systems | |
100 | // --------------------------------------------------------------------------- | |
101 | ||
102 | /* | |
103 | * Right now we have the following setup : | |
104 | * a border that is not part of the native control is always outside the | |
105 | * control's border (otherwise we loose all native intelligence, future ways | |
106 | * may be to have a second embedding control responsible for drawing borders | |
107 | * and backgrounds eventually) | |
108 | * so all this border calculations have to be taken into account when calling | |
109 | * native methods or getting native oriented data | |
110 | * so we have three coordinate systems here | |
111 | * wx client coordinates | |
112 | * wx window coordinates (including window frames) | |
113 | * native coordinates | |
114 | */ | |
8b573fb8 | 115 | |
42ef83fa SC |
116 | // |
117 | // originating from native control | |
118 | // | |
119 | ||
120 | ||
121 | void wxMacNativeToWindow( const wxWindow* window , RgnHandle handle ) | |
122 | { | |
8b573fb8 | 123 | OffsetRgn( handle , window->MacGetLeftBorderSize() , window->MacGetTopBorderSize() ) ; |
42ef83fa SC |
124 | } |
125 | ||
126 | void wxMacNativeToWindow( const wxWindow* window , Rect *rect ) | |
127 | { | |
8b573fb8 | 128 | OffsetRect( rect , window->MacGetLeftBorderSize() , window->MacGetTopBorderSize() ) ; |
42ef83fa SC |
129 | } |
130 | ||
131 | // | |
132 | // directed towards native control | |
133 | // | |
134 | ||
135 | void wxMacWindowToNative( const wxWindow* window , RgnHandle handle ) | |
136 | { | |
8b573fb8 | 137 | OffsetRgn( handle , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() ); |
42ef83fa SC |
138 | } |
139 | ||
140 | void wxMacWindowToNative( const wxWindow* window , Rect *rect ) | |
141 | { | |
8b573fb8 | 142 | OffsetRect( rect , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() ) ; |
42ef83fa SC |
143 | } |
144 | ||
145 | ||
facd6764 SC |
146 | // --------------------------------------------------------------------------- |
147 | // Carbon Events | |
148 | // --------------------------------------------------------------------------- | |
8b573fb8 | 149 | |
facd6764 SC |
150 | extern long wxMacTranslateKey(unsigned char key, unsigned char code) ; |
151 | pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) ; | |
152 | ||
f1d527c1 SC |
153 | #if TARGET_API_MAC_OSX |
154 | ||
8b573fb8 | 155 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 |
c2697b87 SC |
156 | enum { |
157 | kEventControlVisibilityChanged = 157 | |
158 | }; | |
159 | #endif | |
160 | ||
f1d527c1 SC |
161 | #endif |
162 | ||
facd6764 SC |
163 | static const EventTypeSpec eventList[] = |
164 | { | |
f1d527c1 | 165 | { kEventClassControl , kEventControlHit } , |
facd6764 | 166 | #if TARGET_API_MAC_OSX |
73fe67bd SC |
167 | { kEventClassControl , kEventControlDraw } , |
168 | { kEventClassControl , kEventControlVisibilityChanged } , | |
169 | { kEventClassControl , kEventControlEnabledStateChanged } , | |
170 | { kEventClassControl , kEventControlHiliteChanged } , | |
f1d527c1 | 171 | { kEventClassControl , kEventControlSetFocusPart } , |
8b573fb8 VZ |
172 | |
173 | { kEventClassService , kEventServiceGetTypes }, | |
174 | { kEventClassService , kEventServiceCopy }, | |
175 | { kEventClassService , kEventServicePaste }, | |
176 | ||
177 | // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only | |
facd6764 | 178 | // { kEventClassControl , kEventControlBoundsChanged } , |
facd6764 SC |
179 | #endif |
180 | } ; | |
181 | ||
182 | static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) | |
183 | { | |
184 | OSStatus result = eventNotHandledErr ; | |
185 | ||
186 | wxMacCarbonEvent cEvent( event ) ; | |
8b573fb8 | 187 | |
facd6764 SC |
188 | ControlRef controlRef ; |
189 | wxWindowMac* thisWindow = (wxWindowMac*) data ; | |
190 | ||
191 | cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ; | |
192 | ||
193 | switch( GetEventKind( event ) ) | |
194 | { | |
f1d527c1 | 195 | #if TARGET_API_MAC_OSX |
facd6764 SC |
196 | case kEventControlDraw : |
197 | { | |
1e8cde71 | 198 | RgnHandle updateRgn = NULL ; |
055a486b | 199 | RgnHandle allocatedRgn = NULL ; |
1e8cde71 | 200 | wxRegion visRegion = thisWindow->MacGetVisibleRegion() ; |
8b573fb8 | 201 | if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr ) |
1e8cde71 SC |
202 | { |
203 | updateRgn = (RgnHandle) visRegion.GetWXHRGN() ; | |
204 | } | |
055a486b SC |
205 | else |
206 | { | |
207 | if ( thisWindow->MacGetLeftBorderSize() != 0 || thisWindow->MacGetTopBorderSize() != 0 ) | |
208 | { | |
209 | allocatedRgn = NewRgn() ; | |
210 | CopyRgn( updateRgn , allocatedRgn ) ; | |
42ef83fa SC |
211 | // hide the given region by the new region that must be shifted |
212 | wxMacNativeToWindow( thisWindow , allocatedRgn ) ; | |
213 | updateRgn = allocatedRgn ; | |
055a486b SC |
214 | } |
215 | } | |
facd6764 | 216 | |
8b573fb8 | 217 | #if 0 |
125c7984 | 218 | // in case we would need a coregraphics compliant background erase first |
bcbd6987 | 219 | // now usable to track redraws |
facd6764 SC |
220 | CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ; |
221 | if ( thisWindow->MacIsUserPane() ) | |
222 | { | |
bcbd6987 SC |
223 | static float color = 0.5 ; |
224 | static channel = 0 ; | |
8b573fb8 VZ |
225 | HIRect bounds; |
226 | HIViewGetBounds( controlRef, &bounds ); | |
227 | CGContextSetRGBFillColor( cgContext, channel == 0 ? color : 0.5 , | |
228 | channel == 1 ? color : 0.5 , channel == 2 ? color : 0.5 , 1 ); | |
229 | CGContextFillRect( cgContext, bounds ); | |
230 | color += 0.1 ; | |
231 | if ( color > 0.9 ) | |
232 | { | |
233 | color = 0.5 ; | |
234 | channel++ ; | |
235 | if ( channel == 3 ) | |
236 | channel = 0 ; | |
237 | } | |
facd6764 SC |
238 | } |
239 | #endif | |
bcbd6987 | 240 | if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) |
facd6764 | 241 | result = noErr ; |
055a486b SC |
242 | if ( allocatedRgn ) |
243 | DisposeRgn( allocatedRgn ) ; | |
facd6764 SC |
244 | } |
245 | break ; | |
73fe67bd SC |
246 | case kEventControlVisibilityChanged : |
247 | thisWindow->MacVisibilityChanged() ; | |
248 | break ; | |
249 | case kEventControlEnabledStateChanged : | |
250 | thisWindow->MacEnabledStateChanged() ; | |
251 | break ; | |
252 | case kEventControlHiliteChanged : | |
253 | thisWindow->MacHiliteChanged() ; | |
254 | break ; | |
f1d527c1 SC |
255 | case kEventControlSetFocusPart : |
256 | { | |
257 | Boolean focusEverything = false ; | |
258 | ControlPartCode controlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode ); | |
259 | if ( cEvent.GetParameter<Boolean>(kEventParamControlFocusEverything , &focusEverything ) == noErr ) | |
260 | { | |
261 | } | |
262 | if ( controlPart == kControlFocusNoPart ) | |
263 | { | |
264 | #if wxUSE_CARET | |
265 | if ( thisWindow->GetCaret() ) | |
266 | { | |
267 | thisWindow->GetCaret()->OnKillFocus(); | |
268 | } | |
269 | #endif // wxUSE_CARET | |
5ca0d812 | 270 | wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId()); |
f1d527c1 SC |
271 | event.SetEventObject(thisWindow); |
272 | thisWindow->GetEventHandler()->ProcessEvent(event) ; | |
273 | } | |
274 | else | |
275 | { | |
276 | // panel wants to track the window which was the last to have focus in it | |
277 | wxChildFocusEvent eventFocus(thisWindow); | |
278 | thisWindow->GetEventHandler()->ProcessEvent(eventFocus); | |
8b573fb8 | 279 | |
f1d527c1 SC |
280 | #if wxUSE_CARET |
281 | if ( thisWindow->GetCaret() ) | |
282 | { | |
283 | thisWindow->GetCaret()->OnSetFocus(); | |
284 | } | |
285 | #endif // wxUSE_CARET | |
286 | ||
287 | wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId()); | |
288 | event.SetEventObject(thisWindow); | |
289 | thisWindow->GetEventHandler()->ProcessEvent(event) ; | |
290 | } | |
64fec3ab SC |
291 | if ( thisWindow->MacIsUserPane() ) |
292 | result = noErr ; | |
f1d527c1 SC |
293 | } |
294 | break ; | |
295 | #endif | |
296 | case kEventControlHit : | |
297 | { | |
298 | result = thisWindow->MacControlHit( handler , event ) ; | |
299 | } | |
300 | break ; | |
facd6764 SC |
301 | default : |
302 | break ; | |
303 | } | |
304 | return result ; | |
305 | } | |
306 | ||
e4727773 SC |
307 | static pascal OSStatus wxMacWindowServiceEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
308 | { | |
309 | OSStatus result = eventNotHandledErr ; | |
310 | ||
311 | wxMacCarbonEvent cEvent( event ) ; | |
8b573fb8 | 312 | |
e4727773 SC |
313 | ControlRef controlRef ; |
314 | wxWindowMac* thisWindow = (wxWindowMac*) data ; | |
315 | wxTextCtrl* textCtrl = wxDynamicCast( thisWindow , wxTextCtrl ) ; | |
316 | cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ; | |
317 | ||
318 | switch( GetEventKind( event ) ) | |
319 | { | |
320 | case kEventServiceGetTypes : | |
321 | if( textCtrl ) | |
322 | { | |
323 | long from, to ; | |
324 | textCtrl->GetSelection( &from , &to ) ; | |
325 | ||
8b573fb8 | 326 | CFMutableArrayRef copyTypes = 0 , pasteTypes = 0; |
e4727773 SC |
327 | if( from != to ) |
328 | copyTypes = cEvent.GetParameter< CFMutableArrayRef >( kEventParamServiceCopyTypes , typeCFMutableArrayRef ) ; | |
329 | if ( textCtrl->IsEditable() ) | |
330 | pasteTypes = cEvent.GetParameter< CFMutableArrayRef >( kEventParamServicePasteTypes , typeCFMutableArrayRef ) ; | |
8b573fb8 VZ |
331 | |
332 | static const OSType textDataTypes[] = { kTXNTextData /* , 'utxt' , 'PICT', 'MooV', 'AIFF' */ }; | |
e4727773 SC |
333 | for ( size_t i = 0 ; i < WXSIZEOF(textDataTypes) ; ++i ) |
334 | { | |
335 | CFStringRef typestring = CreateTypeStringWithOSType(textDataTypes[i]); | |
336 | if ( typestring ) | |
337 | { | |
338 | if ( copyTypes ) | |
339 | CFArrayAppendValue (copyTypes, typestring) ; | |
340 | if ( pasteTypes ) | |
341 | CFArrayAppendValue (pasteTypes, typestring) ; | |
342 | CFRelease( typestring ) ; | |
343 | } | |
344 | } | |
345 | result = noErr ; | |
346 | } | |
347 | break ; | |
348 | case kEventServiceCopy : | |
349 | if ( textCtrl ) | |
350 | { | |
351 | long from, to ; | |
352 | textCtrl->GetSelection( &from , &to ) ; | |
353 | wxString val = textCtrl->GetValue() ; | |
354 | val = val.Mid( from , to - from ) ; | |
355 | ScrapRef scrapRef = cEvent.GetParameter< ScrapRef > ( kEventParamScrapRef , typeScrapRef ) ; | |
356 | verify_noerr( ClearScrap( &scrapRef ) ) ; | |
357 | verify_noerr( PutScrapFlavor( scrapRef , kTXNTextData , 0 , val.Length() , val.c_str() ) ) ; | |
358 | result = noErr ; | |
359 | } | |
360 | break ; | |
361 | case kEventServicePaste : | |
362 | if ( textCtrl ) | |
363 | { | |
364 | ScrapRef scrapRef = cEvent.GetParameter< ScrapRef > ( kEventParamScrapRef , typeScrapRef ) ; | |
365 | Size textSize, pastedSize ; | |
366 | verify_noerr( GetScrapFlavorSize (scrapRef, kTXNTextData, &textSize) ) ; | |
367 | textSize++ ; | |
368 | char *content = new char[textSize] ; | |
8b573fb8 | 369 | GetScrapFlavorData (scrapRef, kTXNTextData, &pastedSize, content ); |
e4727773 | 370 | content[textSize-1] = 0 ; |
8ef4d6e2 SC |
371 | #if wxUSE_UNICODE |
372 | textCtrl->WriteText( wxString( content , wxConvLocal ) ); | |
373 | #else | |
e4727773 | 374 | textCtrl->WriteText( wxString( content ) ) ; |
8ef4d6e2 | 375 | #endif |
e4727773 SC |
376 | delete[] content ; |
377 | result = noErr ; | |
378 | } | |
379 | break ; | |
380 | } | |
8b573fb8 | 381 | |
e4727773 | 382 | return result ; |
8b573fb8 | 383 | } |
e4727773 | 384 | |
facd6764 SC |
385 | pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
386 | { | |
af6b7b80 SC |
387 | EventRef formerEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ; |
388 | EventHandlerCallRef formerEventHandlerCallRef = (EventHandlerCallRef) wxTheApp->MacGetCurrentEventHandlerCallRef() ; | |
389 | wxTheApp->MacSetCurrentEvent( event , handler ) ; | |
facd6764 SC |
390 | OSStatus result = eventNotHandledErr ; |
391 | ||
392 | switch ( GetEventClass( event ) ) | |
393 | { | |
394 | case kEventClassControl : | |
395 | result = wxMacWindowControlEventHandler( handler, event, data ) ; | |
396 | break ; | |
e4727773 SC |
397 | case kEventClassService : |
398 | result = wxMacWindowServiceEventHandler( handler, event , data ) ; | |
facd6764 SC |
399 | default : |
400 | break ; | |
401 | } | |
af6b7b80 | 402 | wxTheApp->MacSetCurrentEvent( formerEvent, formerEventHandlerCallRef ) ; |
facd6764 SC |
403 | return result ; |
404 | } | |
405 | ||
406 | DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler ) | |
407 | ||
408 | // --------------------------------------------------------------------------- | |
409 | // UserPane events for non OSX builds | |
410 | // --------------------------------------------------------------------------- | |
8b573fb8 | 411 | |
facd6764 SC |
412 | static pascal void wxMacControlUserPaneDrawProc(ControlRef control, SInt16 part) |
413 | { | |
414 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
415 | wxCHECK_RET( win , wxT("Callback from unkown control") ) ; | |
416 | win->MacControlUserPaneDrawProc(part) ; | |
417 | } | |
418 | ||
419 | static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, Point where) | |
420 | { | |
421 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
422 | wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ; | |
423 | return win->MacControlUserPaneHitTestProc(where.h , where.v) ; | |
424 | } | |
425 | ||
426 | static pascal ControlPartCode wxMacControlUserPaneTrackingProc(ControlRef control, Point startPt, ControlActionUPP actionProc) | |
427 | { | |
428 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
429 | wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ; | |
430 | return win->MacControlUserPaneTrackingProc( startPt.h , startPt.v , (void*) actionProc) ; | |
431 | } | |
432 | ||
433 | static pascal void wxMacControlUserPaneIdleProc(ControlRef control) | |
434 | { | |
435 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
436 | wxCHECK_RET( win , wxT("Callback from unkown control") ) ; | |
437 | win->MacControlUserPaneIdleProc() ; | |
438 | } | |
439 | ||
440 | static pascal ControlPartCode wxMacControlUserPaneKeyDownProc(ControlRef control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers) | |
441 | { | |
442 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
443 | wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ; | |
444 | return win->MacControlUserPaneKeyDownProc(keyCode,charCode,modifiers) ; | |
445 | } | |
446 | ||
447 | static pascal void wxMacControlUserPaneActivateProc(ControlRef control, Boolean activating) | |
448 | { | |
449 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
450 | wxCHECK_RET( win , wxT("Callback from unkown control") ) ; | |
451 | win->MacControlUserPaneActivateProc(activating) ; | |
452 | } | |
453 | ||
454 | static pascal ControlPartCode wxMacControlUserPaneFocusProc(ControlRef control, ControlFocusPart action) | |
455 | { | |
456 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
457 | wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ; | |
458 | return win->MacControlUserPaneFocusProc(action) ; | |
459 | } | |
460 | ||
461 | static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control, ControlBackgroundPtr info) | |
462 | { | |
463 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
464 | wxCHECK_RET( win , wxT("Callback from unkown control") ) ; | |
465 | win->MacControlUserPaneBackgroundProc(info) ; | |
466 | } | |
467 | ||
8b573fb8 | 468 | void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part) |
facd6764 | 469 | { |
bcbd6987 SC |
470 | RgnHandle rgn = NewRgn() ; |
471 | GetClip( rgn ) ; | |
472 | wxMacWindowStateSaver sv( this ) ; | |
473 | SectRgn( rgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , rgn ) ; | |
474 | MacDoRedraw( rgn , 0 ) ; | |
475 | DisposeRgn( rgn ) ; | |
facd6764 SC |
476 | } |
477 | ||
8b573fb8 | 478 | wxInt16 wxWindowMac::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) |
facd6764 SC |
479 | { |
480 | return kControlNoPart ; | |
481 | } | |
482 | ||
8b573fb8 | 483 | wxInt16 wxWindowMac::MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) |
facd6764 SC |
484 | { |
485 | return kControlNoPart ; | |
486 | } | |
487 | ||
8b573fb8 | 488 | void wxWindowMac::MacControlUserPaneIdleProc() |
facd6764 SC |
489 | { |
490 | } | |
491 | ||
8b573fb8 | 492 | wxInt16 wxWindowMac::MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) |
facd6764 SC |
493 | { |
494 | return kControlNoPart ; | |
495 | } | |
496 | ||
8b573fb8 | 497 | void wxWindowMac::MacControlUserPaneActivateProc(bool activating) |
facd6764 SC |
498 | { |
499 | } | |
500 | ||
8b573fb8 | 501 | wxInt16 wxWindowMac::MacControlUserPaneFocusProc(wxInt16 action) |
facd6764 SC |
502 | { |
503 | return kControlNoPart ; | |
504 | } | |
505 | ||
8b573fb8 | 506 | void wxWindowMac::MacControlUserPaneBackgroundProc(void* info) |
facd6764 SC |
507 | { |
508 | } | |
509 | ||
510 | ControlUserPaneDrawUPP gControlUserPaneDrawUPP = NULL ; | |
511 | ControlUserPaneHitTestUPP gControlUserPaneHitTestUPP = NULL ; | |
512 | ControlUserPaneTrackingUPP gControlUserPaneTrackingUPP = NULL ; | |
513 | ControlUserPaneIdleUPP gControlUserPaneIdleUPP = NULL ; | |
514 | ControlUserPaneKeyDownUPP gControlUserPaneKeyDownUPP = NULL ; | |
515 | ControlUserPaneActivateUPP gControlUserPaneActivateUPP = NULL ; | |
516 | ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ; | |
517 | ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ; | |
e7549107 SC |
518 | |
519 | // =========================================================================== | |
520 | // implementation | |
521 | // =========================================================================== | |
522 | ||
71f2fb52 | 523 | #if KEY_wxList_DEPRECATED |
facd6764 SC |
524 | wxList wxWinMacControlList(wxKEY_INTEGER); |
525 | ||
526 | wxWindow *wxFindControlFromMacControl(ControlRef inControl ) | |
527 | { | |
528 | wxNode *node = wxWinMacControlList.Find((long)inControl); | |
529 | if (!node) | |
530 | return NULL; | |
531 | return (wxControl *)node->GetData(); | |
532 | } | |
533 | ||
534 | void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control) | |
535 | { | |
536 | // adding NULL ControlRef is (first) surely a result of an error and | |
537 | // (secondly) breaks native event processing | |
538 | wxCHECK_RET( inControl != (ControlRef) NULL, wxT("attempt to add a NULL WindowRef to window list") ); | |
539 | ||
540 | if ( !wxWinMacControlList.Find((long)inControl) ) | |
541 | wxWinMacControlList.Append((long)inControl, control); | |
542 | } | |
543 | ||
544 | void wxRemoveMacControlAssociation(wxWindow *control) | |
545 | { | |
546 | wxWinMacControlList.DeleteObject(control); | |
547 | } | |
71f2fb52 RN |
548 | #else |
549 | ||
550 | WX_DECLARE_HASH_MAP(ControlRef, wxWindow*, wxPointerHash, wxPointerEqual, MacControlMap); | |
551 | ||
552 | static MacControlMap wxWinMacControlList; | |
553 | ||
554 | wxWindow *wxFindControlFromMacControl(ControlRef inControl ) | |
555 | { | |
556 | MacControlMap::iterator node = wxWinMacControlList.find(inControl); | |
557 | ||
558 | return (node == wxWinMacControlList.end()) ? NULL : node->second; | |
559 | } | |
560 | ||
561 | void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control) | |
562 | { | |
563 | // adding NULL ControlRef is (first) surely a result of an error and | |
564 | // (secondly) breaks native event processing | |
565 | wxCHECK_RET( inControl != (ControlRef) NULL, wxT("attempt to add a NULL WindowRef to window list") ); | |
566 | ||
567 | wxWinMacControlList[inControl] = control; | |
568 | } | |
569 | ||
570 | void wxRemoveMacControlAssociation(wxWindow *control) | |
571 | { | |
572 | // iterate over all the elements in the class | |
573 | MacControlMap::iterator it; | |
574 | for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it ) | |
575 | { | |
576 | if ( it->second == control ) | |
577 | { | |
578 | wxWinMacControlList.erase(it); | |
579 | break; | |
580 | } | |
581 | } | |
582 | } | |
583 | #endif // deprecated wxList | |
facd6764 SC |
584 | |
585 | // UPP functions | |
586 | ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ; | |
587 | ||
588 | ControlColorUPP wxMacSetupControlBackgroundUPP = NULL ; | |
589 | ||
590 | // we have to setup the brush in the current port and return noErr | |
8b573fb8 | 591 | // or return an error code so that the control manager walks further up the |
facd6764 SC |
592 | // hierarchy to find a correct background |
593 | ||
594 | pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) | |
595 | { | |
596 | OSStatus status = paramErr ; | |
597 | switch( iMessage ) | |
598 | { | |
599 | case kControlMsgApplyTextColor : | |
600 | break ; | |
601 | case kControlMsgSetUpBackground : | |
602 | { | |
603 | wxWindow* wx = (wxWindow*) wxFindControlFromMacControl( iControl ) ; | |
604 | if ( wx != NULL ) | |
605 | { | |
db7a550b | 606 | /* |
facd6764 SC |
607 | const wxBrush &brush = wx->MacGetBackgroundBrush() ; |
608 | if ( brush.Ok() ) | |
609 | { | |
facd6764 | 610 | wxDC::MacSetupBackgroundForCurrentPort( brush ) ; |
db7a550b SC |
611 | */ |
612 | // this clipping is only needed for non HIView | |
8b573fb8 | 613 | |
facd6764 SC |
614 | RgnHandle clip = NewRgn() ; |
615 | int x = 0 , y = 0; | |
616 | ||
617 | wx->MacWindowToRootWindow( &x,&y ) ; | |
618 | CopyRgn( (RgnHandle) wx->MacGetVisibleRegion().GetWXHRGN() , clip ) ; | |
619 | OffsetRgn( clip , x , y ) ; | |
620 | SetClip( clip ) ; | |
621 | DisposeRgn( clip ) ; | |
622 | ||
623 | status = noErr ; | |
db7a550b | 624 | /* |
facd6764 SC |
625 | } |
626 | else if ( wx->MacIsUserPane() ) | |
627 | { | |
628 | // if we don't have a valid brush for such a control, we have to call the | |
629 | // setup of our parent ourselves | |
630 | status = SetUpControlBackground( (ControlRef) wx->GetParent()->GetHandle() , iDepth , iIsColor ) ; | |
631 | } | |
db7a550b | 632 | */ |
facd6764 SC |
633 | } |
634 | } | |
635 | break ; | |
636 | default : | |
637 | break ; | |
638 | } | |
639 | return status ; | |
640 | } | |
641 | ||
642 | ||
643 | pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode partCode ) ; | |
644 | pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode partCode ) | |
645 | { | |
646 | if ( partCode != 0) | |
647 | { | |
648 | wxWindow* wx = wxFindControlFromMacControl( control ) ; | |
649 | if ( wx ) | |
650 | { | |
651 | wx->MacHandleControlClick( (WXWidget) control , partCode , true /* stillDown */ ) ; | |
652 | } | |
653 | } | |
654 | } | |
e7549107 SC |
655 | |
656 | // ---------------------------------------------------------------------------- | |
facd6764 | 657 | // constructors and such |
e7549107 SC |
658 | // ---------------------------------------------------------------------------- |
659 | ||
94f9b1f0 | 660 | wxWindowMac::wxWindowMac() |
8b573fb8 VZ |
661 | { |
662 | Init(); | |
94f9b1f0 SC |
663 | } |
664 | ||
665 | wxWindowMac::wxWindowMac(wxWindowMac *parent, | |
666 | wxWindowID id, | |
667 | const wxPoint& pos , | |
668 | const wxSize& size , | |
669 | long style , | |
670 | const wxString& name ) | |
671 | { | |
672 | Init(); | |
673 | Create(parent, id, pos, size, style, name); | |
674 | } | |
675 | ||
e766c8a9 | 676 | void wxWindowMac::Init() |
519cb848 | 677 | { |
21fd5529 | 678 | m_peer = NULL ; |
79392158 | 679 | m_frozenness = 0 ; |
557d6f32 | 680 | #if WXWIN_COMPATIBILITY_2_4 |
e7549107 | 681 | m_backgroundTransparent = FALSE; |
557d6f32 | 682 | #endif |
e7549107 SC |
683 | |
684 | // as all windows are created with WS_VISIBLE style... | |
685 | m_isShown = TRUE; | |
686 | ||
6264b550 RR |
687 | m_hScrollBar = NULL ; |
688 | m_vScrollBar = NULL ; | |
facd6764 SC |
689 | m_macBackgroundBrush = wxNullBrush ; |
690 | ||
facd6764 | 691 | m_macIsUserPane = TRUE; |
8b573fb8 | 692 | |
facd6764 | 693 | // make sure all proc ptrs are available |
8b573fb8 | 694 | |
facd6764 SC |
695 | if ( gControlUserPaneDrawUPP == NULL ) |
696 | { | |
697 | gControlUserPaneDrawUPP = NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc ) ; | |
698 | gControlUserPaneHitTestUPP = NewControlUserPaneHitTestUPP( wxMacControlUserPaneHitTestProc ) ; | |
699 | gControlUserPaneTrackingUPP = NewControlUserPaneTrackingUPP( wxMacControlUserPaneTrackingProc ) ; | |
700 | gControlUserPaneIdleUPP = NewControlUserPaneIdleUPP( wxMacControlUserPaneIdleProc ) ; | |
701 | gControlUserPaneKeyDownUPP = NewControlUserPaneKeyDownUPP( wxMacControlUserPaneKeyDownProc ) ; | |
702 | gControlUserPaneActivateUPP = NewControlUserPaneActivateUPP( wxMacControlUserPaneActivateProc ) ; | |
703 | gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ; | |
704 | gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ; | |
705 | } | |
706 | if ( wxMacLiveScrollbarActionUPP == NULL ) | |
707 | { | |
708 | wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc ); | |
709 | } | |
710 | ||
711 | if ( wxMacSetupControlBackgroundUPP == NULL ) | |
712 | { | |
713 | wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ; | |
714 | } | |
715 | ||
c6f9fb05 SC |
716 | // we need a valid font for the encodings |
717 | wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); | |
e9576ca5 SC |
718 | } |
719 | ||
720 | // Destructor | |
e766c8a9 | 721 | wxWindowMac::~wxWindowMac() |
e9576ca5 | 722 | { |
7de59551 RD |
723 | SendDestroyEvent(); |
724 | ||
140f2012 | 725 | m_isBeingDeleted = TRUE; |
6ed71b4f | 726 | |
7ebf5540 SC |
727 | if ( m_peer ) |
728 | { | |
729 | // deleting a window while it is shown invalidates the region occupied by border or | |
730 | // focus | |
731 | int outerBorder = MacGetLeftBorderSize() ; | |
732 | if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() ) | |
8b573fb8 | 733 | outerBorder += 4 ; |
7ebf5540 SC |
734 | |
735 | if ( IsShown() && ( outerBorder > 0 ) ) | |
736 | { | |
737 | // as the borders are drawn on the parent we have to properly invalidate all these areas | |
738 | RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ; | |
8b573fb8 | 739 | |
7ebf5540 SC |
740 | Rect rect ; |
741 | ||
742 | m_peer->GetRect( &rect ) ; | |
743 | RectRgn( updateInner , &rect ) ; | |
744 | InsetRect( &rect , -outerBorder , -outerBorder ) ; | |
745 | RectRgn( updateOuter , &rect ) ; | |
746 | DiffRgn( updateOuter , updateInner ,updateOuter ) ; | |
8b573fb8 | 747 | wxPoint parent(0,0); |
7ebf5540 SC |
748 | GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ; |
749 | parent -= GetParent()->GetClientAreaOrigin() ; | |
750 | OffsetRgn( updateOuter , -parent.x , -parent.y ) ; | |
8b573fb8 | 751 | CopyRgn( updateOuter , updateTotal ) ; |
7ebf5540 SC |
752 | |
753 | GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ; | |
754 | DisposeRgn(updateOuter) ; | |
755 | DisposeRgn(updateInner) ; | |
756 | DisposeRgn(updateTotal) ; | |
757 | } | |
758 | } | |
759 | ||
d4380aaf SC |
760 | #ifndef __WXUNIVERSAL__ |
761 | // VS: make sure there's no wxFrame with last focus set to us: | |
762 | for ( wxWindow *win = GetParent(); win; win = win->GetParent() ) | |
763 | { | |
764 | wxFrame *frame = wxDynamicCast(win, wxFrame); | |
765 | if ( frame ) | |
766 | { | |
767 | if ( frame->GetLastFocus() == this ) | |
768 | { | |
769 | frame->SetLastFocus((wxWindow*)NULL); | |
770 | } | |
771 | break; | |
772 | } | |
773 | } | |
774 | #endif // __WXUNIVERSAL__ | |
8b573fb8 VZ |
775 | |
776 | // destroy children before destroying this window itself | |
777 | DestroyChildren(); | |
778 | ||
facd6764 SC |
779 | // wxRemoveMacControlAssociation( this ) ; |
780 | // If we delete an item, we should initialize the parent panel, | |
781 | // because it could now be invalid. | |
782 | wxWindow *parent = GetParent() ; | |
783 | if ( parent ) | |
784 | { | |
785 | if (parent->GetDefaultItem() == (wxButton*) this) | |
786 | parent->SetDefaultItem(NULL); | |
787 | } | |
21fd5529 | 788 | if ( m_peer && m_peer->Ok() ) |
facd6764 SC |
789 | { |
790 | // in case the callback might be called during destruction | |
791 | wxRemoveMacControlAssociation( this) ; | |
5ca0d812 SC |
792 | // we currently are not using this hook |
793 | // ::SetControlColorProc( *m_peer , NULL ) ; | |
794 | m_peer->Dispose() ; | |
facd6764 | 795 | } |
d4380aaf | 796 | |
facd6764 | 797 | if ( g_MacLastWindow == this ) |
6264b550 | 798 | { |
facd6764 | 799 | g_MacLastWindow = NULL ; |
6264b550 | 800 | } |
7de59551 | 801 | |
fd76aa8d SC |
802 | wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ; |
803 | if ( frame ) | |
804 | { | |
e40298d5 JS |
805 | if ( frame->GetLastFocus() == this ) |
806 | frame->SetLastFocus( NULL ) ; | |
fd76aa8d | 807 | } |
e7549107 | 808 | |
42683dfb SC |
809 | // delete our drop target if we've got one |
810 | #if wxUSE_DRAG_AND_DROP | |
811 | if ( m_dropTarget != NULL ) | |
812 | { | |
813 | delete m_dropTarget; | |
814 | m_dropTarget = NULL; | |
815 | } | |
816 | #endif // wxUSE_DRAG_AND_DROP | |
21fd5529 SC |
817 | delete m_peer ; |
818 | } | |
819 | ||
8b573fb8 VZ |
820 | WXWidget wxWindowMac::GetHandle() const |
821 | { | |
822 | return (WXWidget) m_peer->GetControlRef() ; | |
e9576ca5 SC |
823 | } |
824 | ||
facd6764 | 825 | |
5ca0d812 | 826 | void wxWindowMac::MacInstallEventHandler( WXWidget control ) |
facd6764 | 827 | { |
5ca0d812 SC |
828 | wxAssociateControlWithMacControl( (ControlRef) control , this ) ; |
829 | InstallControlEventHandler( (ControlRef) control , GetwxMacWindowEventHandlerUPP(), | |
8b573fb8 | 830 | GetEventTypeCount(eventList), eventList, this, |
facd6764 SC |
831 | (EventHandlerRef *)&m_macControlEventHandler); |
832 | ||
833 | } | |
834 | ||
e9576ca5 | 835 | // Constructor |
e766c8a9 | 836 | bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, |
e9576ca5 SC |
837 | const wxPoint& pos, |
838 | const wxSize& size, | |
839 | long style, | |
840 | const wxString& name) | |
841 | { | |
e766c8a9 | 842 | wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") ); |
e9576ca5 | 843 | |
e7549107 | 844 | if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) |
e9576ca5 SC |
845 | return FALSE; |
846 | ||
facd6764 | 847 | m_windowVariant = parent->GetWindowVariant() ; |
8b573fb8 | 848 | |
facd6764 SC |
849 | if ( m_macIsUserPane ) |
850 | { | |
851 | Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; | |
8b573fb8 | 852 | |
ebe86b1e | 853 | UInt32 features = 0 |
8b573fb8 VZ |
854 | | kControlSupportsEmbedding |
855 | // | kControlSupportsLiveFeedback | |
856 | // | kControlHasSpecialBackground | |
857 | // | kControlSupportsCalcBestRect | |
858 | // | kControlHandlesTracking | |
859 | | kControlSupportsFocus | |
860 | // | kControlWantsActivate | |
861 | // | kControlWantsIdle | |
862 | ; | |
ebe86b1e | 863 | |
21fd5529 | 864 | m_peer = new wxMacControl() ; |
5ca0d812 | 865 | ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , m_peer->GetControlRefAddr() ); |
8b573fb8 | 866 | |
facd6764 SC |
867 | |
868 | MacPostControlCreate(pos,size) ; | |
bcbd6987 | 869 | #if !TARGET_API_MAC_OSX |
5ca0d812 SC |
870 | m_peer->SetData<ControlUserPaneDrawUPP>(kControlEntireControl,kControlUserPaneDrawProcTag,&gControlUserPaneDrawUPP) ; |
871 | m_peer->SetData<ControlUserPaneHitTestUPP>(kControlEntireControl,kControlUserPaneHitTestProcTag,&gControlUserPaneHitTestUPP) ; | |
872 | m_peer->SetData<ControlUserPaneTrackingUPP>(kControlEntireControl,kControlUserPaneTrackingProcTag,&gControlUserPaneTrackingUPP) ; | |
873 | m_peer->SetData<ControlUserPaneIdleUPP>(kControlEntireControl,kControlUserPaneIdleProcTag,&gControlUserPaneIdleUPP) ; | |
874 | m_peer->SetData<ControlUserPaneKeyDownUPP>(kControlEntireControl,kControlUserPaneKeyDownProcTag,&gControlUserPaneKeyDownUPP) ; | |
875 | m_peer->SetData<ControlUserPaneActivateUPP>(kControlEntireControl,kControlUserPaneActivateProcTag,&gControlUserPaneActivateUPP) ; | |
876 | m_peer->SetData<ControlUserPaneFocusUPP>(kControlEntireControl,kControlUserPaneFocusProcTag,&gControlUserPaneFocusUPP) ; | |
877 | m_peer->SetData<ControlUserPaneBackgroundUPP>(kControlEntireControl,kControlUserPaneBackgroundProcTag,&gControlUserPaneBackgroundUPP) ; | |
8b573fb8 | 878 | #endif |
facd6764 | 879 | } |
e766c8a9 | 880 | #ifndef __WXUNIVERSAL__ |
14c9cbdb RD |
881 | // Don't give scrollbars to wxControls unless they ask for them |
882 | if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar))) || | |
883 | (IsKindOf(CLASSINFO(wxControl)) && ( style & wxHSCROLL || style & wxVSCROLL))) | |
6264b550 RR |
884 | { |
885 | MacCreateScrollBars( style ) ; | |
886 | } | |
e766c8a9 | 887 | #endif |
3dfafdb9 RD |
888 | |
889 | wxWindowCreateEvent event(this); | |
7e4a196e | 890 | GetEventHandler()->AddPendingEvent(event); |
3dfafdb9 | 891 | |
e9576ca5 SC |
892 | return TRUE; |
893 | } | |
894 | ||
08422003 SC |
895 | void wxWindowMac::MacChildAdded() |
896 | { | |
897 | if ( m_vScrollBar ) | |
898 | { | |
899 | m_vScrollBar->Raise() ; | |
900 | } | |
901 | if ( m_hScrollBar ) | |
902 | { | |
903 | m_hScrollBar->Raise() ; | |
904 | } | |
905 | ||
906 | } | |
907 | ||
facd6764 SC |
908 | void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size) |
909 | { | |
21fd5529 | 910 | wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ; |
facd6764 | 911 | |
5ca0d812 | 912 | m_peer->SetReference( (long) this ) ; |
488abb22 | 913 | GetParent()->AddChild(this); |
facd6764 | 914 | |
5ca0d812 | 915 | MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ); |
facd6764 SC |
916 | |
917 | ControlRef container = (ControlRef) GetParent()->GetHandle() ; | |
918 | wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ; | |
5ca0d812 | 919 | ::EmbedControl( m_peer->GetControlRef() , container ) ; |
08422003 | 920 | GetParent()->MacChildAdded() ; |
facd6764 SC |
921 | |
922 | // adjust font, controlsize etc | |
923 | DoSetWindowVariant( m_windowVariant ) ; | |
924 | ||
925 | #if !TARGET_API_MAC_OSX | |
8b573fb8 | 926 | // eventually we can fix some clipping issues be reactivating this hook |
facd6764 | 927 | //if ( m_macIsUserPane ) |
be346c26 | 928 | // SetControlColorProc( m_peer->GetControlRef() , wxMacSetupControlBackgroundUPP ) ; |
facd6764 | 929 | #endif |
5ca0d812 | 930 | m_peer->SetTitle( wxStripMenuCodes(m_label) ) ; |
facd6764 | 931 | |
facd6764 | 932 | if (!m_macIsUserPane) |
d3b5db4b RD |
933 | { |
934 | SetInitialBestSize(size); | |
facd6764 SC |
935 | } |
936 | ||
937 | SetCursor( *wxSTANDARD_CURSOR ) ; | |
facd6764 SC |
938 | } |
939 | ||
940 | void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant ) | |
941 | { | |
23176131 JS |
942 | // Don't assert, in case we set the window variant before |
943 | // the window is created | |
21fd5529 | 944 | // wxASSERT( m_peer->Ok() ) ; |
facd6764 | 945 | |
23176131 JS |
946 | m_windowVariant = variant ; |
947 | ||
21fd5529 | 948 | if (m_peer == NULL || !m_peer->Ok()) |
23176131 | 949 | return; |
facd6764 | 950 | |
8b573fb8 | 951 | ControlSize size ; |
facd6764 SC |
952 | ThemeFontID themeFont = kThemeSystemFont ; |
953 | ||
954 | // we will get that from the settings later | |
8b573fb8 | 955 | // and make this NORMAL later, but first |
facd6764 | 956 | // we have a few calculations that we must fix |
8b573fb8 | 957 | |
facd6764 SC |
958 | switch ( variant ) |
959 | { | |
960 | case wxWINDOW_VARIANT_NORMAL : | |
8b573fb8 VZ |
961 | size = kControlSizeNormal; |
962 | themeFont = kThemeSystemFont ; | |
facd6764 SC |
963 | break ; |
964 | case wxWINDOW_VARIANT_SMALL : | |
8b573fb8 VZ |
965 | size = kControlSizeSmall; |
966 | themeFont = kThemeSmallSystemFont ; | |
facd6764 SC |
967 | break ; |
968 | case wxWINDOW_VARIANT_MINI : | |
969 | if (UMAGetSystemVersion() >= 0x1030 ) | |
970 | { | |
8b573fb8 VZ |
971 | // not always defined in the headers |
972 | size = 3 ; | |
973 | themeFont = 109 ; | |
facd6764 SC |
974 | } |
975 | else | |
976 | { | |
8b573fb8 VZ |
977 | size = kControlSizeSmall; |
978 | themeFont = kThemeSmallSystemFont ; | |
facd6764 SC |
979 | } |
980 | break ; | |
981 | case wxWINDOW_VARIANT_LARGE : | |
8b573fb8 VZ |
982 | size = kControlSizeLarge; |
983 | themeFont = kThemeSystemFont ; | |
facd6764 SC |
984 | break ; |
985 | default: | |
986 | wxFAIL_MSG(_T("unexpected window variant")); | |
987 | break ; | |
988 | } | |
5ca0d812 | 989 | m_peer->SetData<ControlSize>(kControlEntireControl, kControlSizeTag,&size ) ; |
facd6764 SC |
990 | |
991 | wxFont font ; | |
992 | font.MacCreateThemeFont( themeFont ) ; | |
993 | SetFont( font ) ; | |
994 | } | |
995 | ||
8b573fb8 | 996 | void wxWindowMac::MacUpdateControlFont() |
facd6764 | 997 | { |
ac99838a | 998 | m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ; |
8b573fb8 | 999 | Refresh() ; |
facd6764 SC |
1000 | } |
1001 | ||
1002 | bool wxWindowMac::SetFont(const wxFont& font) | |
1003 | { | |
d5ccba72 | 1004 | bool retval = wxWindowBase::SetFont( font ) ; |
8b573fb8 | 1005 | |
facd6764 | 1006 | MacUpdateControlFont() ; |
8b573fb8 | 1007 | |
facd6764 SC |
1008 | return retval; |
1009 | } | |
1010 | ||
1011 | bool wxWindowMac::SetForegroundColour(const wxColour& col ) | |
1012 | { | |
1013 | if ( !wxWindowBase::SetForegroundColour(col) ) | |
1014 | return false ; | |
8b573fb8 | 1015 | |
facd6764 | 1016 | MacUpdateControlFont() ; |
8b573fb8 | 1017 | |
facd6764 SC |
1018 | return true ; |
1019 | } | |
1020 | ||
1021 | bool wxWindowMac::SetBackgroundColour(const wxColour& col ) | |
1022 | { | |
1023 | if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol ) | |
1024 | return false ; | |
1025 | ||
1026 | wxBrush brush ; | |
b52acd03 RD |
1027 | wxColour newCol(GetBackgroundColour()); |
1028 | if ( newCol == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) | |
facd6764 SC |
1029 | { |
1030 | brush.MacSetTheme( kThemeBrushDocumentWindowBackground ) ; | |
1031 | } | |
b52acd03 | 1032 | else if ( newCol == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) ) |
facd6764 | 1033 | { |
8b573fb8 VZ |
1034 | brush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ; |
1035 | } | |
facd6764 SC |
1036 | else |
1037 | { | |
b52acd03 | 1038 | brush.SetColour( newCol ) ; |
facd6764 SC |
1039 | } |
1040 | MacSetBackgroundBrush( brush ) ; | |
8b573fb8 | 1041 | |
db7a550b | 1042 | MacUpdateControlFont() ; |
8b573fb8 | 1043 | |
facd6764 SC |
1044 | return true ; |
1045 | } | |
1046 | ||
7ea087b7 SC |
1047 | void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush ) |
1048 | { | |
1049 | m_macBackgroundBrush = brush ; | |
1050 | m_peer->SetBackground( brush ) ; | |
1051 | } | |
facd6764 SC |
1052 | |
1053 | bool wxWindowMac::MacCanFocus() const | |
1054 | { | |
f6e3849c SC |
1055 | // there is currently no way to determine whether the window is running in full keyboard |
1056 | // access mode, therefore we cannot rely on these features, yet the only other way would be | |
1057 | // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems | |
1058 | // in event handlers... | |
f1d527c1 | 1059 | UInt32 features = 0 ; |
5ca0d812 | 1060 | m_peer->GetFeatures( & features ) ; |
8b573fb8 | 1061 | return features & ( kControlSupportsFocus | kControlGetsFocusOnClick ) ; |
facd6764 SC |
1062 | } |
1063 | ||
1064 | ||
e766c8a9 | 1065 | void wxWindowMac::SetFocus() |
e9576ca5 | 1066 | { |
6264b550 RR |
1067 | if ( AcceptsFocus() ) |
1068 | { | |
7d0cfe71 | 1069 | |
f1d527c1 | 1070 | wxWindow* former = FindFocus() ; |
7d0cfe71 SC |
1071 | if ( former == this ) |
1072 | return ; | |
1073 | ||
5ca0d812 | 1074 | OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ; |
f1d527c1 SC |
1075 | // as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only |
1076 | // leave in case of an error | |
1077 | if ( err == errCouldntSetFocus ) | |
1078 | return ; | |
1079 | ||
1080 | #if !TARGET_API_MAC_OSX | |
1081 | // emulate carbon events when running under carbonlib where they are not natively available | |
1082 | if ( former ) | |
1083 | { | |
1084 | EventRef evRef = NULL ; | |
1085 | verify_noerr( MacCreateEvent( NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) , kEventAttributeUserEvent , | |
1086 | &evRef ) ); | |
1087 | ||
1088 | wxMacCarbonEvent cEvent( evRef ) ; | |
1089 | cEvent.SetParameter<ControlRef>( kEventParamDirectObject , (ControlRef) former->GetHandle() ) ; | |
1090 | cEvent.SetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode , kControlFocusNoPart ) ; | |
8b573fb8 | 1091 | |
f1d527c1 SC |
1092 | wxMacWindowEventHandler( NULL , evRef , former ) ; |
1093 | ReleaseEvent(evRef) ; | |
6264b550 | 1094 | } |
f1d527c1 | 1095 | // send new focus event |
6264b550 | 1096 | { |
f1d527c1 SC |
1097 | EventRef evRef = NULL ; |
1098 | verify_noerr( MacCreateEvent( NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) , kEventAttributeUserEvent , | |
1099 | &evRef ) ); | |
1100 | ||
1101 | wxMacCarbonEvent cEvent( evRef ) ; | |
1102 | cEvent.SetParameter<ControlRef>( kEventParamDirectObject , (ControlRef) GetHandle() ) ; | |
1103 | cEvent.SetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode , kControlFocusNextPart ) ; | |
8b573fb8 | 1104 | |
f1d527c1 SC |
1105 | wxMacWindowEventHandler( NULL , evRef , this ) ; |
1106 | ReleaseEvent(evRef) ; | |
6264b550 | 1107 | } |
f1d527c1 | 1108 | #endif |
6264b550 | 1109 | } |
e9576ca5 SC |
1110 | } |
1111 | ||
e9576ca5 | 1112 | |
4116c221 | 1113 | void wxWindowMac::DoCaptureMouse() |
e9576ca5 | 1114 | { |
519cb848 | 1115 | wxTheApp->s_captureWindow = this ; |
e9576ca5 SC |
1116 | } |
1117 | ||
90b959ae SC |
1118 | wxWindow* wxWindowBase::GetCapture() |
1119 | { | |
1120 | return wxTheApp->s_captureWindow ; | |
1121 | } | |
1122 | ||
4116c221 | 1123 | void wxWindowMac::DoReleaseMouse() |
e9576ca5 | 1124 | { |
519cb848 | 1125 | wxTheApp->s_captureWindow = NULL ; |
e9576ca5 SC |
1126 | } |
1127 | ||
e9576ca5 SC |
1128 | #if wxUSE_DRAG_AND_DROP |
1129 | ||
e766c8a9 | 1130 | void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget) |
e9576ca5 | 1131 | { |
e40298d5 JS |
1132 | if ( m_dropTarget != 0 ) { |
1133 | delete m_dropTarget; | |
1134 | } | |
6ed71b4f | 1135 | |
e40298d5 JS |
1136 | m_dropTarget = pDropTarget; |
1137 | if ( m_dropTarget != 0 ) | |
1138 | { | |
1139 | // TODO | |
1140 | } | |
e9576ca5 SC |
1141 | } |
1142 | ||
1143 | #endif | |
1144 | ||
1145 | // Old style file-manager drag&drop | |
e766c8a9 | 1146 | void wxWindowMac::DragAcceptFiles(bool accept) |
e9576ca5 SC |
1147 | { |
1148 | // TODO | |
1149 | } | |
1150 | ||
055a486b SC |
1151 | // Returns the size of the native control. In the case of the toplevel window |
1152 | // this is the content area root control | |
1153 | ||
facd6764 | 1154 | void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y, |
8b573fb8 | 1155 | int& w, int& h) const |
e9576ca5 | 1156 | { |
facd6764 | 1157 | Rect bounds ; |
8b573fb8 | 1158 | m_peer->GetRect( &bounds ) ; |
e9576ca5 | 1159 | |
14c9cbdb | 1160 | |
facd6764 SC |
1161 | x = bounds.left ; |
1162 | y = bounds.top ; | |
1163 | w = bounds.right - bounds.left ; | |
1164 | h = bounds.bottom - bounds.top ; | |
e9576ca5 SC |
1165 | } |
1166 | ||
055a486b | 1167 | // From a wx position / size calculate the appropriate size of the native control |
8b573fb8 | 1168 | |
facd6764 SC |
1169 | bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos, |
1170 | const wxSize& size, | |
1171 | int& x, int& y, | |
8b573fb8 | 1172 | int& w, int& h , bool adjustOrigin ) const |
51abe921 | 1173 | { |
5ca0d812 | 1174 | // the desired size, minus the border pixels gives the correct size of the control |
8b573fb8 | 1175 | |
facd6764 SC |
1176 | x = (int)pos.x; |
1177 | y = (int)pos.y; | |
1178 | // todo the default calls may be used as soon as PostCreateControl Is moved here | |
1179 | w = size.x ; // WidthDefault( size.x ); | |
1180 | h = size.y ; // HeightDefault( size.y ) ; | |
1181 | #if !TARGET_API_MAC_OSX | |
1182 | GetParent()->MacWindowToRootWindow( &x , &y ) ; | |
1183 | #endif | |
5ca0d812 SC |
1184 | |
1185 | x += MacGetLeftBorderSize() ; | |
1186 | y += MacGetTopBorderSize() ; | |
1187 | w -= MacGetLeftBorderSize() + MacGetRightBorderSize() ; | |
1188 | h -= MacGetTopBorderSize() + MacGetBottomBorderSize() ; | |
8b573fb8 | 1189 | |
79392158 SC |
1190 | if ( adjustOrigin ) |
1191 | AdjustForParentClientOrigin( x , y ) ; | |
7ebf5540 SC |
1192 | #if TARGET_API_MAC_OSX |
1193 | // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border | |
1194 | if ( ! GetParent()->IsTopLevel() ) | |
1195 | { | |
1196 | x -= GetParent()->MacGetLeftBorderSize() ; | |
1197 | y -= GetParent()->MacGetTopBorderSize() ; | |
1198 | } | |
1199 | #endif | |
facd6764 SC |
1200 | return true ; |
1201 | } | |
1202 | ||
42ef83fa | 1203 | // Get window size (not client size) |
facd6764 SC |
1204 | void wxWindowMac::DoGetSize(int *x, int *y) const |
1205 | { | |
5ca0d812 | 1206 | // take the size of the control and add the borders that have to be drawn outside |
42ef83fa SC |
1207 | int x1 , y1 , w1 , h1 ; |
1208 | ||
facd6764 | 1209 | MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ; |
42ef83fa | 1210 | |
5ca0d812 SC |
1211 | w1 += MacGetLeftBorderSize() + MacGetRightBorderSize() ; |
1212 | h1 += MacGetTopBorderSize() + MacGetBottomBorderSize() ; | |
8b573fb8 | 1213 | |
5ca0d812 SC |
1214 | if(x) *x = w1 ; |
1215 | if(y) *y = h1 ; | |
facd6764 SC |
1216 | } |
1217 | ||
42ef83fa | 1218 | // get the position of the bounds of this window in client coordinates of its parent |
facd6764 SC |
1219 | void wxWindowMac::DoGetPosition(int *x, int *y) const |
1220 | { | |
facd6764 SC |
1221 | int x1 , y1 , w1 ,h1 ; |
1222 | MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ; | |
5ca0d812 SC |
1223 | x1 -= MacGetLeftBorderSize() ; |
1224 | y1 -= MacGetTopBorderSize() ; | |
42ef83fa SC |
1225 | // to non-client |
1226 | #if !TARGET_API_MAC_OSX | |
1227 | if ( !GetParent()->IsTopLevel() ) | |
1228 | { | |
1229 | Rect bounds ; | |
1230 | GetControlBounds( (ControlRef) GetParent()->GetHandle() , &bounds ) ; | |
1231 | x1 -= bounds.left ; | |
1232 | y1 -= bounds.top ; | |
1233 | } | |
1234 | #endif | |
facd6764 | 1235 | if ( !IsTopLevel() ) |
2b5f62a0 | 1236 | { |
facd6764 SC |
1237 | wxWindow *parent = GetParent(); |
1238 | if ( parent ) | |
8950f7cc | 1239 | { |
1a02aff9 SC |
1240 | // we must first adjust it to be in window coordinates of the parent, as otherwise it gets lost by the clientareaorigin fix |
1241 | x1 += parent->MacGetLeftBorderSize() ; | |
1242 | y1 += parent->MacGetTopBorderSize() ; | |
1243 | // and now to client coordinates | |
facd6764 SC |
1244 | wxPoint pt(parent->GetClientAreaOrigin()); |
1245 | x1 -= pt.x ; | |
1246 | y1 -= pt.y ; | |
6ed71b4f | 1247 | } |
2b5f62a0 | 1248 | } |
facd6764 SC |
1249 | if(x) *x = x1 ; |
1250 | if(y) *y = y1 ; | |
facd6764 | 1251 | } |
51abe921 | 1252 | |
e766c8a9 | 1253 | void wxWindowMac::DoScreenToClient(int *x, int *y) const |
e9576ca5 | 1254 | { |
facd6764 | 1255 | WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; |
8b573fb8 | 1256 | |
facd6764 | 1257 | wxCHECK_RET( window , wxT("TopLevel Window Missing") ) ; |
8b573fb8 | 1258 | |
facd6764 SC |
1259 | { |
1260 | Point localwhere = {0,0} ; | |
519cb848 | 1261 | |
facd6764 SC |
1262 | if(x) localwhere.h = * x ; |
1263 | if(y) localwhere.v = * y ; | |
8b573fb8 | 1264 | |
a9de2608 | 1265 | QDGlobalToLocalPoint( GetWindowPort( window ) , &localwhere ) ; |
facd6764 SC |
1266 | if(x) *x = localwhere.h ; |
1267 | if(y) *y = localwhere.v ; | |
6ed71b4f | 1268 | |
facd6764 | 1269 | } |
2078220e | 1270 | MacRootWindowToWindow( x , y ) ; |
8b573fb8 | 1271 | |
facd6764 SC |
1272 | wxPoint origin = GetClientAreaOrigin() ; |
1273 | if(x) *x -= origin.x ; | |
1274 | if(y) *y -= origin.y ; | |
e9576ca5 SC |
1275 | } |
1276 | ||
e766c8a9 | 1277 | void wxWindowMac::DoClientToScreen(int *x, int *y) const |
e9576ca5 | 1278 | { |
facd6764 SC |
1279 | WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; |
1280 | wxCHECK_RET( window , wxT("TopLevel Window Missing") ) ; | |
14c9cbdb | 1281 | |
facd6764 SC |
1282 | wxPoint origin = GetClientAreaOrigin() ; |
1283 | if(x) *x += origin.x ; | |
1284 | if(y) *y += origin.y ; | |
14c9cbdb | 1285 | |
2078220e | 1286 | MacWindowToRootWindow( x , y ) ; |
14c9cbdb | 1287 | |
facd6764 SC |
1288 | { |
1289 | Point localwhere = { 0,0 }; | |
1290 | if(x) localwhere.h = * x ; | |
1291 | if(y) localwhere.v = * y ; | |
a9de2608 | 1292 | QDLocalToGlobalPoint( GetWindowPort( window ) , &localwhere ) ; |
facd6764 SC |
1293 | if(x) *x = localwhere.h ; |
1294 | if(y) *y = localwhere.v ; | |
1295 | } | |
519cb848 SC |
1296 | } |
1297 | ||
e766c8a9 | 1298 | void wxWindowMac::MacClientToRootWindow( int *x , int *y ) const |
519cb848 | 1299 | { |
1c310985 SC |
1300 | wxPoint origin = GetClientAreaOrigin() ; |
1301 | if(x) *x += origin.x ; | |
1302 | if(y) *y += origin.y ; | |
14c9cbdb | 1303 | |
1c310985 SC |
1304 | MacWindowToRootWindow( x , y ) ; |
1305 | } | |
1306 | ||
1307 | void wxWindowMac::MacRootWindowToClient( int *x , int *y ) const | |
1308 | { | |
1c310985 | 1309 | MacRootWindowToWindow( x , y ) ; |
facd6764 SC |
1310 | |
1311 | wxPoint origin = GetClientAreaOrigin() ; | |
1c310985 SC |
1312 | if(x) *x -= origin.x ; |
1313 | if(y) *y -= origin.y ; | |
1314 | } | |
1315 | ||
1316 | void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const | |
1317 | { | |
facd6764 | 1318 | #if TARGET_API_MAC_OSX |
5ca0d812 | 1319 | wxPoint pt ; |
facd6764 SC |
1320 | if ( x ) pt.x = *x ; |
1321 | if ( y ) pt.y = *y ; | |
1322 | ||
125c7984 | 1323 | if ( !IsTopLevel() ) |
5437ff47 RD |
1324 | { |
1325 | wxTopLevelWindowMac* top = MacGetTopLevelWindow(); | |
1326 | if (top) | |
5ca0d812 SC |
1327 | { |
1328 | pt.x -= MacGetLeftBorderSize() ; | |
1329 | pt.y -= MacGetTopBorderSize() ; | |
1330 | wxMacControl::Convert( &pt , m_peer , top->m_peer ) ; | |
1331 | } | |
5437ff47 | 1332 | } |
8b573fb8 | 1333 | |
facd6764 SC |
1334 | if ( x ) *x = (int) pt.x ; |
1335 | if ( y ) *y = (int) pt.y ; | |
1336 | #else | |
1c310985 | 1337 | if ( !IsTopLevel() ) |
6264b550 | 1338 | { |
facd6764 | 1339 | Rect bounds ; |
8b573fb8 | 1340 | m_peer->GetRect( &bounds ) ; |
055a486b SC |
1341 | if(x) *x += bounds.left - MacGetLeftBorderSize() ; |
1342 | if(y) *y += bounds.top - MacGetTopBorderSize() ; | |
6264b550 | 1343 | } |
facd6764 SC |
1344 | #endif |
1345 | } | |
1346 | ||
1347 | void wxWindowMac::MacWindowToRootWindow( short *x , short *y ) const | |
1348 | { | |
1349 | int x1 , y1 ; | |
1350 | if ( x ) x1 = *x ; | |
1351 | if ( y ) y1 = *y ; | |
1352 | MacWindowToRootWindow( &x1 , &y1 ) ; | |
1353 | if ( x ) *x = x1 ; | |
1354 | if ( y ) *y = y1 ; | |
519cb848 SC |
1355 | } |
1356 | ||
1c310985 | 1357 | void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const |
519cb848 | 1358 | { |
facd6764 | 1359 | #if TARGET_API_MAC_OSX |
5ca0d812 | 1360 | wxPoint pt ; |
facd6764 SC |
1361 | if ( x ) pt.x = *x ; |
1362 | if ( y ) pt.y = *y ; | |
1363 | ||
125c7984 | 1364 | if ( !IsTopLevel() ) |
5ca0d812 SC |
1365 | { |
1366 | wxMacControl::Convert( &pt , MacGetTopLevelWindow()->m_peer , m_peer ) ; | |
1367 | pt.x += MacGetLeftBorderSize() ; | |
1368 | pt.y += MacGetTopBorderSize() ; | |
1369 | } | |
8b573fb8 | 1370 | |
facd6764 SC |
1371 | if ( x ) *x = (int) pt.x ; |
1372 | if ( y ) *y = (int) pt.y ; | |
1373 | #else | |
1c310985 | 1374 | if ( !IsTopLevel() ) |
6264b550 | 1375 | { |
facd6764 | 1376 | Rect bounds ; |
8b573fb8 | 1377 | m_peer->GetRect( &bounds ) ; |
055a486b SC |
1378 | if(x) *x -= bounds.left + MacGetLeftBorderSize() ; |
1379 | if(y) *y -= bounds.top + MacGetTopBorderSize() ; | |
6264b550 | 1380 | } |
facd6764 | 1381 | #endif |
e9576ca5 SC |
1382 | } |
1383 | ||
facd6764 | 1384 | void wxWindowMac::MacRootWindowToWindow( short *x , short *y ) const |
e9576ca5 | 1385 | { |
facd6764 SC |
1386 | int x1 , y1 ; |
1387 | if ( x ) x1 = *x ; | |
1388 | if ( y ) y1 = *y ; | |
1389 | MacRootWindowToWindow( &x1 , &y1 ) ; | |
1390 | if ( x ) *x = x1 ; | |
1391 | if ( y ) *y = y1 ; | |
1392 | } | |
6ed71b4f | 1393 | |
29281095 SC |
1394 | void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) |
1395 | { | |
1396 | RgnHandle rgn = NewRgn() ; | |
1397 | Rect content ; | |
5ca0d812 | 1398 | if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr ) |
29281095 SC |
1399 | { |
1400 | GetRegionBounds( rgn , &content ) ; | |
29281095 SC |
1401 | } |
1402 | else | |
1403 | { | |
5ca0d812 | 1404 | m_peer->GetRect( &content ) ; |
29281095 | 1405 | } |
7596e51d | 1406 | DisposeRgn( rgn ) ; |
29281095 | 1407 | Rect structure ; |
5ca0d812 | 1408 | m_peer->GetRect( &structure ) ; |
8b573fb8 | 1409 | #if !TARGET_API_MAC_OSX |
29281095 SC |
1410 | OffsetRect( &content , -structure.left , -structure.top ) ; |
1411 | #endif | |
1412 | left = content.left - structure.left ; | |
1413 | top = content.top - structure.top ; | |
1414 | right = structure.right - content.right ; | |
1415 | bottom = structure.bottom - content.bottom ; | |
1416 | } | |
1417 | ||
facd6764 SC |
1418 | wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size ) const |
1419 | { | |
1420 | wxSize sizeTotal = size; | |
1421 | ||
1422 | RgnHandle rgn = NewRgn() ; | |
1423 | ||
1424 | Rect content ; | |
8b573fb8 | 1425 | |
5ca0d812 | 1426 | if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr ) |
6618870d | 1427 | { |
facd6764 | 1428 | GetRegionBounds( rgn , &content ) ; |
6618870d SC |
1429 | } |
1430 | else | |
1431 | { | |
5ca0d812 | 1432 | m_peer->GetRect( &content ) ; |
e40298d5 | 1433 | } |
7596e51d | 1434 | DisposeRgn( rgn ) ; |
facd6764 | 1435 | Rect structure ; |
5ca0d812 | 1436 | m_peer->GetRect( &structure ) ; |
8b573fb8 | 1437 | #if !TARGET_API_MAC_OSX |
facd6764 SC |
1438 | OffsetRect( &content , -structure.left , -structure.top ) ; |
1439 | #endif | |
6ed71b4f | 1440 | |
facd6764 | 1441 | sizeTotal.x += (structure.right - structure.left) - (content.right - content.left) ; |
8b573fb8 | 1442 | sizeTotal.y += (structure.bottom - structure.top) - (content.bottom - content.top ) ; |
6ed71b4f | 1443 | |
facd6764 SC |
1444 | sizeTotal.x += MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ; |
1445 | sizeTotal.y += MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ; | |
6ed71b4f | 1446 | |
facd6764 | 1447 | return sizeTotal; |
e9576ca5 SC |
1448 | } |
1449 | ||
1450 | ||
1451 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
e766c8a9 | 1452 | void wxWindowMac::DoGetClientSize(int *x, int *y) const |
e9576ca5 | 1453 | { |
9453cf2b | 1454 | int ww, hh; |
6ed71b4f | 1455 | |
facd6764 SC |
1456 | RgnHandle rgn = NewRgn() ; |
1457 | Rect content ; | |
5ca0d812 | 1458 | if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr ) |
facd6764 SC |
1459 | { |
1460 | GetRegionBounds( rgn , &content ) ; | |
facd6764 SC |
1461 | } |
1462 | else | |
1463 | { | |
5ca0d812 | 1464 | m_peer->GetRect( &content ) ; |
facd6764 | 1465 | } |
7596e51d | 1466 | DisposeRgn( rgn ) ; |
facd6764 SC |
1467 | #if !TARGET_API_MAC_OSX |
1468 | Rect structure ; | |
5ca0d812 | 1469 | m_peer->GetRect( &structure ) ; |
facd6764 | 1470 | OffsetRect( &content , -structure.left , -structure.top ) ; |
8b573fb8 | 1471 | #endif |
facd6764 SC |
1472 | ww = content.right - content.left ; |
1473 | hh = content.bottom - content.top ; | |
055a486b | 1474 | /* |
6264b550 RR |
1475 | ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ; |
1476 | hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ); | |
055a486b | 1477 | */ |
db7a550b | 1478 | /* |
e40298d5 JS |
1479 | if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) ) |
1480 | { | |
1481 | int x1 = 0 ; | |
1482 | int y1 = 0 ; | |
facd6764 SC |
1483 | int w ; |
1484 | int h ; | |
1485 | GetSize( &w , &h ) ; | |
8b573fb8 | 1486 | |
e40298d5 JS |
1487 | MacClientToRootWindow( &x1 , &y1 ) ; |
1488 | MacClientToRootWindow( &w , &h ) ; | |
6ed71b4f | 1489 | |
e40298d5 | 1490 | wxWindowMac *iter = (wxWindowMac*)this ; |
6ed71b4f | 1491 | |
e40298d5 JS |
1492 | int totW = 10000 , totH = 10000; |
1493 | while( iter ) | |
6264b550 | 1494 | { |
e40298d5 JS |
1495 | if ( iter->IsTopLevel() ) |
1496 | { | |
facd6764 | 1497 | iter->GetSize( &totW , &totH ) ; |
e40298d5 JS |
1498 | break ; |
1499 | } | |
6ed71b4f | 1500 | |
e40298d5 | 1501 | iter = iter->GetParent() ; |
6264b550 | 1502 | } |
6ed71b4f | 1503 | |
e40298d5 | 1504 | if (m_hScrollBar && m_hScrollBar->IsShown() ) |
6264b550 | 1505 | { |
db7a550b | 1506 | hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ; |
e40298d5 JS |
1507 | if ( h-y1 >= totH ) |
1508 | { | |
1509 | hh += 1 ; | |
1510 | } | |
6264b550 | 1511 | } |
e40298d5 | 1512 | if (m_vScrollBar && m_vScrollBar->IsShown() ) |
6264b550 | 1513 | { |
db7a550b | 1514 | ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE; |
e40298d5 JS |
1515 | if ( w-x1 >= totW ) |
1516 | { | |
1517 | ww += 1 ; | |
1518 | } | |
6264b550 RR |
1519 | } |
1520 | } | |
db7a550b SC |
1521 | */ |
1522 | if (m_hScrollBar && m_hScrollBar->IsShown() ) | |
1523 | { | |
1524 | hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ; | |
1525 | } | |
1526 | if (m_vScrollBar && m_vScrollBar->IsShown() ) | |
1527 | { | |
1528 | ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE; | |
1529 | } | |
e40298d5 JS |
1530 | if(x) *x = ww; |
1531 | if(y) *y = hh; | |
facd6764 SC |
1532 | |
1533 | } | |
1534 | ||
1535 | bool wxWindowMac::SetCursor(const wxCursor& cursor) | |
1536 | { | |
1537 | if (m_cursor == cursor) | |
1538 | return FALSE; | |
1539 | ||
1540 | if (wxNullCursor == cursor) | |
1541 | { | |
1542 | if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) ) | |
1543 | return FALSE ; | |
1544 | } | |
1545 | else | |
1546 | { | |
1547 | if ( ! wxWindowBase::SetCursor( cursor ) ) | |
1548 | return FALSE ; | |
1549 | } | |
1550 | ||
1551 | wxASSERT_MSG( m_cursor.Ok(), | |
1552 | wxT("cursor must be valid after call to the base version")); | |
8b573fb8 VZ |
1553 | |
1554 | ||
2d1760d3 | 1555 | wxWindowMac *mouseWin = 0 ; |
facd6764 | 1556 | { |
2d1760d3 SC |
1557 | WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; |
1558 | CGrafPtr savePort ; | |
1559 | Boolean swapped = QDSwapPort( GetWindowPort( window ) , &savePort ) ; | |
8b573fb8 | 1560 | |
2d1760d3 SC |
1561 | // TODO If we ever get a GetCurrentEvent.. replacement for the mouse |
1562 | // position, use it... | |
8b573fb8 | 1563 | |
2d1760d3 SC |
1564 | Point pt ; |
1565 | GetMouse( &pt ) ; | |
1566 | ControlPartCode part ; | |
1567 | ControlRef control ; | |
1568 | control = wxMacFindControlUnderMouse( pt , window , &part ) ; | |
1569 | if ( control ) | |
1570 | mouseWin = wxFindControlFromMacControl( control ) ; | |
8b573fb8 | 1571 | |
2d1760d3 SC |
1572 | if ( swapped ) |
1573 | QDSwapPort( savePort , NULL ) ; | |
facd6764 | 1574 | } |
2d1760d3 SC |
1575 | |
1576 | if ( mouseWin == this && !wxIsBusy() ) | |
facd6764 SC |
1577 | { |
1578 | m_cursor.MacInstall() ; | |
1579 | } | |
1580 | ||
1581 | return TRUE ; | |
519cb848 SC |
1582 | } |
1583 | ||
facd6764 SC |
1584 | #if wxUSE_MENUS |
1585 | bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) | |
1586 | { | |
1587 | menu->SetInvokingWindow(this); | |
1588 | menu->UpdateUI(); | |
8b573fb8 | 1589 | |
971562cb VS |
1590 | if ( x == -1 && y == -1 ) |
1591 | { | |
1592 | wxPoint mouse = wxGetMousePosition(); | |
1593 | x = mouse.x; y = mouse.y; | |
1594 | } | |
1595 | else | |
1596 | { | |
1597 | ClientToScreen( &x , &y ) ; | |
1598 | } | |
facd6764 SC |
1599 | |
1600 | menu->MacBeforeDisplay( true ) ; | |
1601 | long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ; | |
1602 | if ( HiWord(menuResult) != 0 ) | |
1603 | { | |
1604 | MenuCommand id ; | |
1605 | GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ; | |
1606 | wxMenuItem* item = NULL ; | |
1607 | wxMenu* realmenu ; | |
1608 | item = menu->FindItem(id, &realmenu) ; | |
1609 | if (item->IsCheckable()) | |
1610 | { | |
1611 | item->Check( !item->IsChecked() ) ; | |
1612 | } | |
1613 | menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; | |
1614 | } | |
1615 | menu->MacAfterDisplay( true ) ; | |
1616 | ||
1617 | menu->SetInvokingWindow(NULL); | |
1618 | ||
1619 | return TRUE; | |
1620 | } | |
1621 | #endif | |
51abe921 SC |
1622 | |
1623 | // ---------------------------------------------------------------------------- | |
1624 | // tooltips | |
1625 | // ---------------------------------------------------------------------------- | |
1626 | ||
1627 | #if wxUSE_TOOLTIPS | |
1628 | ||
e766c8a9 | 1629 | void wxWindowMac::DoSetToolTip(wxToolTip *tooltip) |
51abe921 SC |
1630 | { |
1631 | wxWindowBase::DoSetToolTip(tooltip); | |
6ed71b4f | 1632 | |
6264b550 RR |
1633 | if ( m_tooltip ) |
1634 | m_tooltip->SetWindow(this); | |
51abe921 SC |
1635 | } |
1636 | ||
1637 | #endif // wxUSE_TOOLTIPS | |
1638 | ||
e766c8a9 | 1639 | void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) |
51abe921 | 1640 | { |
db7a550b | 1641 | // this is never called for a toplevel window, so we know we have a parent |
facd6764 | 1642 | int former_x , former_y , former_w, former_h ; |
db7a550b SC |
1643 | |
1644 | // Get true coordinates of former position | |
facd6764 SC |
1645 | DoGetPosition( &former_x , &former_y ) ; |
1646 | DoGetSize( &former_w , &former_h ) ; | |
db7a550b SC |
1647 | |
1648 | wxWindow *parent = GetParent(); | |
1649 | if ( parent ) | |
1650 | { | |
1651 | wxPoint pt(parent->GetClientAreaOrigin()); | |
1652 | former_x += pt.x ; | |
1653 | former_y += pt.y ; | |
1654 | } | |
6ed71b4f | 1655 | |
e40298d5 JS |
1656 | int actualWidth = width; |
1657 | int actualHeight = height; | |
1658 | int actualX = x; | |
1659 | int actualY = y; | |
6ed71b4f | 1660 | |
14c9cbdb | 1661 | if ((m_minWidth != -1) && (actualWidth < m_minWidth)) |
6264b550 | 1662 | actualWidth = m_minWidth; |
14c9cbdb | 1663 | if ((m_minHeight != -1) && (actualHeight < m_minHeight)) |
6264b550 | 1664 | actualHeight = m_minHeight; |
14c9cbdb | 1665 | if ((m_maxWidth != -1) && (actualWidth > m_maxWidth)) |
6264b550 | 1666 | actualWidth = m_maxWidth; |
14c9cbdb | 1667 | if ((m_maxHeight != -1) && (actualHeight > m_maxHeight)) |
6264b550 | 1668 | actualHeight = m_maxHeight; |
6ed71b4f | 1669 | |
6264b550 RR |
1670 | bool doMove = false ; |
1671 | bool doResize = false ; | |
6ed71b4f | 1672 | |
6264b550 RR |
1673 | if ( actualX != former_x || actualY != former_y ) |
1674 | { | |
1675 | doMove = true ; | |
1676 | } | |
1677 | if ( actualWidth != former_w || actualHeight != former_h ) | |
1678 | { | |
1679 | doResize = true ; | |
1680 | } | |
6ed71b4f | 1681 | |
6264b550 RR |
1682 | if ( doMove || doResize ) |
1683 | { | |
79392158 SC |
1684 | // we don't adjust twice for the origin |
1685 | Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ; | |
5ca0d812 | 1686 | bool vis = m_peer->IsVisible(); |
8b573fb8 | 1687 | |
d390fdcf SC |
1688 | int outerBorder = MacGetLeftBorderSize() ; |
1689 | if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() ) | |
8b573fb8 | 1690 | outerBorder += 4 ; |
d390fdcf SC |
1691 | |
1692 | if ( vis && ( outerBorder > 0 ) ) | |
1693 | { | |
1694 | // as the borders are drawn on the parent we have to properly invalidate all these areas | |
1695 | RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ; | |
8b573fb8 | 1696 | |
d390fdcf SC |
1697 | Rect rect ; |
1698 | ||
1699 | m_peer->GetRect( &rect ) ; | |
1700 | RectRgn( updateInner , &rect ) ; | |
1701 | InsetRect( &rect , -outerBorder , -outerBorder ) ; | |
1702 | RectRgn( updateOuter , &rect ) ; | |
1703 | DiffRgn( updateOuter , updateInner ,updateOuter ) ; | |
8b573fb8 | 1704 | wxPoint parent(0,0); |
d390fdcf SC |
1705 | GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ; |
1706 | parent -= GetParent()->GetClientAreaOrigin() ; | |
1707 | OffsetRgn( updateOuter , -parent.x , -parent.y ) ; | |
8b573fb8 VZ |
1708 | CopyRgn( updateOuter , updateTotal ) ; |
1709 | ||
d390fdcf SC |
1710 | rect = r ; |
1711 | RectRgn( updateInner , &rect ) ; | |
1712 | InsetRect( &rect , -outerBorder , -outerBorder ) ; | |
1713 | RectRgn( updateOuter , &rect ) ; | |
1714 | DiffRgn( updateOuter , updateInner ,updateOuter ) ; | |
7ebf5540 SC |
1715 | |
1716 | OffsetRgn( updateOuter , -parent.x , -parent.y ) ; | |
8b573fb8 | 1717 | UnionRgn( updateOuter , updateTotal , updateTotal ) ; |
d390fdcf SC |
1718 | |
1719 | GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ; | |
1720 | DisposeRgn(updateOuter) ; | |
1721 | DisposeRgn(updateInner) ; | |
1722 | DisposeRgn(updateTotal) ; | |
1723 | } | |
5ca0d812 | 1724 | |
b05bf6ee SC |
1725 | // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not ! |
1726 | if ( vis ) | |
5ca0d812 | 1727 | m_peer->SetVisibility( false , true ) ; |
d390fdcf | 1728 | |
8b573fb8 | 1729 | m_peer->SetRect( &r ) ; |
b05bf6ee | 1730 | if ( vis ) |
5ca0d812 SC |
1731 | m_peer->SetVisibility( true , true ) ; |
1732 | ||
6264b550 RR |
1733 | MacRepositionScrollBars() ; |
1734 | if ( doMove ) | |
1735 | { | |
facd6764 | 1736 | wxPoint point(actualX,actualY); |
6264b550 RR |
1737 | wxMoveEvent event(point, m_windowId); |
1738 | event.SetEventObject(this); | |
1739 | GetEventHandler()->ProcessEvent(event) ; | |
1740 | } | |
1741 | if ( doResize ) | |
1742 | { | |
e40298d5 | 1743 | MacRepositionScrollBars() ; |
facd6764 | 1744 | wxSize size(actualWidth, actualHeight); |
e40298d5 JS |
1745 | wxSizeEvent event(size, m_windowId); |
1746 | event.SetEventObject(this); | |
1747 | GetEventHandler()->ProcessEvent(event); | |
6264b550 RR |
1748 | } |
1749 | } | |
6ed71b4f | 1750 | |
954fc50b SC |
1751 | } |
1752 | ||
facd6764 SC |
1753 | wxSize wxWindowMac::DoGetBestSize() const |
1754 | { | |
eb69d46e SC |
1755 | if ( m_macIsUserPane || IsTopLevel() ) |
1756 | return wxWindowBase::DoGetBestSize() ; | |
8b573fb8 | 1757 | |
facd6764 | 1758 | Rect bestsize = { 0 , 0 , 0 , 0 } ; |
facd6764 | 1759 | int bestWidth, bestHeight ; |
5ca0d812 | 1760 | m_peer->GetBestRect( &bestsize ) ; |
facd6764 SC |
1761 | |
1762 | if ( EmptyRect( &bestsize ) ) | |
1763 | { | |
facd6764 SC |
1764 | bestsize.left = bestsize.top = 0 ; |
1765 | bestsize.right = 16 ; | |
1766 | bestsize.bottom = 16 ; | |
1767 | if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) | |
1768 | { | |
1769 | bestsize.bottom = 16 ; | |
1770 | } | |
e3e817d4 | 1771 | #if wxUSE_SPINBTN |
facd6764 SC |
1772 | else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) |
1773 | { | |
8b573fb8 | 1774 | bestsize.bottom = 24 ; |
facd6764 | 1775 | } |
e3e817d4 | 1776 | #endif // wxUSE_SPINBTN |
facd6764 SC |
1777 | else |
1778 | { | |
8b573fb8 | 1779 | // return wxWindowBase::DoGetBestSize() ; |
facd6764 SC |
1780 | } |
1781 | } | |
1782 | ||
1783 | bestWidth = bestsize.right - bestsize.left ; | |
1784 | bestHeight = bestsize.bottom - bestsize.top ; | |
1785 | if ( bestHeight < 10 ) | |
1786 | bestHeight = 13 ; | |
8b573fb8 | 1787 | |
facd6764 SC |
1788 | return wxSize(bestWidth, bestHeight); |
1789 | } | |
1790 | ||
1791 | ||
954fc50b SC |
1792 | // set the size of the window: if the dimensions are positive, just use them, |
1793 | // but if any of them is equal to -1, it means that we must find the value for | |
1794 | // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in | |
1795 | // which case -1 is a valid value for x and y) | |
1796 | // | |
1797 | // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate | |
1798 | // the width/height to best suit our contents, otherwise we reuse the current | |
1799 | // width/height | |
1800 | void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) | |
1801 | { | |
1802 | // get the current size and position... | |
1803 | int currentX, currentY; | |
1804 | GetPosition(¤tX, ¤tY); | |
6ed71b4f | 1805 | |
954fc50b SC |
1806 | int currentW,currentH; |
1807 | GetSize(¤tW, ¤tH); | |
6ed71b4f | 1808 | |
954fc50b SC |
1809 | // ... and don't do anything (avoiding flicker) if it's already ok |
1810 | if ( x == currentX && y == currentY && | |
769ac869 | 1811 | width == currentW && height == currentH && ( height != -1 && width != -1 ) ) |
954fc50b | 1812 | { |
facd6764 | 1813 | // TODO REMOVE |
6264b550 | 1814 | MacRepositionScrollBars() ; // we might have a real position shift |
954fc50b SC |
1815 | return; |
1816 | } | |
6ed71b4f | 1817 | |
954fc50b SC |
1818 | if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) |
1819 | x = currentX; | |
1820 | if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) | |
1821 | y = currentY; | |
6ed71b4f | 1822 | |
954fc50b | 1823 | AdjustForParentClientOrigin(x, y, sizeFlags); |
6ed71b4f | 1824 | |
954fc50b SC |
1825 | wxSize size(-1, -1); |
1826 | if ( width == -1 ) | |
1827 | { | |
1828 | if ( sizeFlags & wxSIZE_AUTO_WIDTH ) | |
1829 | { | |
1830 | size = DoGetBestSize(); | |
1831 | width = size.x; | |
1832 | } | |
1833 | else | |
1834 | { | |
1835 | // just take the current one | |
1836 | width = currentW; | |
1837 | } | |
1838 | } | |
6ed71b4f | 1839 | |
954fc50b SC |
1840 | if ( height == -1 ) |
1841 | { | |
1842 | if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) | |
1843 | { | |
1844 | if ( size.x == -1 ) | |
1845 | { | |
1846 | size = DoGetBestSize(); | |
1847 | } | |
1848 | //else: already called DoGetBestSize() above | |
6ed71b4f | 1849 | |
954fc50b SC |
1850 | height = size.y; |
1851 | } | |
1852 | else | |
1853 | { | |
1854 | // just take the current one | |
1855 | height = currentH; | |
1856 | } | |
1857 | } | |
6ed71b4f | 1858 | |
954fc50b | 1859 | DoMoveWindow(x, y, width, height); |
6ed71b4f | 1860 | |
e9576ca5 | 1861 | } |
519cb848 | 1862 | |
e766c8a9 | 1863 | wxPoint wxWindowMac::GetClientAreaOrigin() const |
e9576ca5 | 1864 | { |
facd6764 SC |
1865 | RgnHandle rgn = NewRgn() ; |
1866 | Rect content ; | |
5ca0d812 | 1867 | m_peer->GetRegion( kControlContentMetaPart , rgn ) ; |
facd6764 SC |
1868 | GetRegionBounds( rgn , &content ) ; |
1869 | DisposeRgn( rgn ) ; | |
1870 | #if !TARGET_API_MAC_OSX | |
736fac3a SC |
1871 | // if the content rgn is empty / not supported |
1872 | // don't attempt to correct the coordinates to wxWindow relative ones | |
1873 | if (!::EmptyRect( &content ) ) | |
1874 | { | |
1875 | Rect structure ; | |
5ca0d812 | 1876 | m_peer->GetRect( &structure ) ; |
736fac3a SC |
1877 | OffsetRect( &content , -structure.left , -structure.top ) ; |
1878 | } | |
8b573fb8 | 1879 | #endif |
facd6764 SC |
1880 | |
1881 | return wxPoint( content.left + MacGetLeftBorderSize( ) , content.top + MacGetTopBorderSize( ) ); | |
1882 | } | |
1883 | ||
1884 | void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight) | |
1885 | { | |
1886 | if ( clientheight != -1 || clientheight != -1 ) | |
1887 | { | |
1888 | int currentclientwidth , currentclientheight ; | |
1889 | int currentwidth , currentheight ; | |
1890 | ||
1891 | GetClientSize( ¤tclientwidth , ¤tclientheight ) ; | |
1892 | GetSize( ¤twidth , ¤theight ) ; | |
1893 | ||
1894 | DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth , | |
1895 | currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ; | |
1896 | } | |
e9576ca5 SC |
1897 | } |
1898 | ||
d84afea9 | 1899 | void wxWindowMac::SetTitle(const wxString& title) |
e9576ca5 | 1900 | { |
facd6764 SC |
1901 | m_label = wxStripMenuCodes(title) ; |
1902 | ||
21fd5529 | 1903 | if ( m_peer && m_peer->Ok() ) |
facd6764 | 1904 | { |
5ca0d812 | 1905 | m_peer->SetTitle( m_label ) ; |
facd6764 SC |
1906 | } |
1907 | Refresh() ; | |
519cb848 SC |
1908 | } |
1909 | ||
d84afea9 | 1910 | wxString wxWindowMac::GetTitle() const |
519cb848 | 1911 | { |
ed60b502 | 1912 | return m_label ; |
519cb848 SC |
1913 | } |
1914 | ||
8ab50549 SC |
1915 | bool wxWindowMac::Show(bool show) |
1916 | { | |
1917 | if ( !wxWindowBase::Show(show) ) | |
1918 | return FALSE; | |
8b573fb8 | 1919 | |
8ab50549 | 1920 | // TODO use visibilityChanged Carbon Event for OSX |
2c899c20 SC |
1921 | if ( m_peer ) |
1922 | { | |
1923 | bool former = MacIsReallyShown() ; | |
8b573fb8 | 1924 | |
2c899c20 SC |
1925 | m_peer->SetVisibility( show , true ) ; |
1926 | if ( former != MacIsReallyShown() ) | |
1927 | MacPropagateVisibilityChanged() ; | |
1928 | } | |
8ab50549 SC |
1929 | return TRUE; |
1930 | } | |
1931 | ||
1932 | bool wxWindowMac::Enable(bool enable) | |
1933 | { | |
21fd5529 | 1934 | wxASSERT( m_peer->Ok() ) ; |
8ab50549 SC |
1935 | if ( !wxWindowBase::Enable(enable) ) |
1936 | return FALSE; | |
1937 | ||
1938 | bool former = MacIsReallyEnabled() ; | |
5ca0d812 | 1939 | m_peer->Enable( enable ) ; |
8ab50549 SC |
1940 | |
1941 | if ( former != MacIsReallyEnabled() ) | |
1942 | MacPropagateEnabledStateChanged() ; | |
1943 | return TRUE; | |
1944 | } | |
1945 | ||
8b573fb8 | 1946 | // |
8ab50549 SC |
1947 | // status change propagations (will be not necessary for OSX later ) |
1948 | // | |
1949 | ||
facd6764 SC |
1950 | void wxWindowMac::MacPropagateVisibilityChanged() |
1951 | { | |
73fe67bd | 1952 | #if !TARGET_API_MAC_OSX |
facd6764 | 1953 | MacVisibilityChanged() ; |
8b573fb8 | 1954 | |
71f2fb52 | 1955 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
facd6764 SC |
1956 | while ( node ) |
1957 | { | |
1958 | wxWindowMac *child = node->GetData(); | |
1959 | if ( child->IsShown() ) | |
1960 | child->MacPropagateVisibilityChanged( ) ; | |
1961 | node = node->GetNext(); | |
1962 | } | |
73fe67bd | 1963 | #endif |
facd6764 SC |
1964 | } |
1965 | ||
8ab50549 | 1966 | void wxWindowMac::MacPropagateEnabledStateChanged( ) |
e9576ca5 | 1967 | { |
73fe67bd | 1968 | #if !TARGET_API_MAC_OSX |
8ab50549 | 1969 | MacEnabledStateChanged() ; |
8b573fb8 | 1970 | |
71f2fb52 | 1971 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
8ab50549 SC |
1972 | while ( node ) |
1973 | { | |
1974 | wxWindowMac *child = node->GetData(); | |
1975 | if ( child->IsEnabled() ) | |
1976 | child->MacPropagateEnabledStateChanged() ; | |
1977 | node = node->GetNext(); | |
1978 | } | |
73fe67bd | 1979 | #endif |
8ab50549 SC |
1980 | } |
1981 | ||
1982 | void wxWindowMac::MacPropagateHiliteChanged( ) | |
1983 | { | |
73fe67bd | 1984 | #if !TARGET_API_MAC_OSX |
8ab50549 | 1985 | MacHiliteChanged() ; |
8b573fb8 | 1986 | |
71f2fb52 | 1987 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
8ab50549 SC |
1988 | while ( node ) |
1989 | { | |
1990 | wxWindowMac *child = node->GetData(); | |
1991 | // if ( child->IsEnabled() ) | |
1992 | child->MacPropagateHiliteChanged() ; | |
1993 | node = node->GetNext(); | |
1994 | } | |
73fe67bd | 1995 | #endif |
8ab50549 SC |
1996 | } |
1997 | ||
1998 | // | |
1999 | // status change notifications | |
8b573fb8 | 2000 | // |
8ab50549 | 2001 | |
8b573fb8 | 2002 | void wxWindowMac::MacVisibilityChanged() |
8ab50549 SC |
2003 | { |
2004 | } | |
2005 | ||
8b573fb8 | 2006 | void wxWindowMac::MacHiliteChanged() |
8ab50549 SC |
2007 | { |
2008 | } | |
2009 | ||
8b573fb8 | 2010 | void wxWindowMac::MacEnabledStateChanged() |
8ab50549 | 2011 | { |
facd6764 | 2012 | } |
e7549107 | 2013 | |
8ab50549 SC |
2014 | // |
2015 | // status queries on the inherited window's state | |
2016 | // | |
2017 | ||
8b573fb8 | 2018 | bool wxWindowMac::MacIsReallyShown() |
facd6764 SC |
2019 | { |
2020 | // only under OSX the visibility of the TLW is taken into account | |
2021 | #if TARGET_API_MAC_OSX | |
aa522e33 SC |
2022 | if ( m_peer && m_peer->Ok() ) |
2023 | return m_peer->IsVisible(); | |
2024 | #endif | |
facd6764 SC |
2025 | wxWindow* win = this ; |
2026 | while( win->IsShown() ) | |
2027 | { | |
2028 | if ( win->IsTopLevel() ) | |
2029 | return true ; | |
8b573fb8 | 2030 | |
facd6764 SC |
2031 | win = win->GetParent() ; |
2032 | if ( win == NULL ) | |
2033 | return true ; | |
8b573fb8 | 2034 | |
facd6764 SC |
2035 | } ; |
2036 | return false ; | |
facd6764 | 2037 | } |
4241baae | 2038 | |
8b573fb8 | 2039 | bool wxWindowMac::MacIsReallyEnabled() |
facd6764 | 2040 | { |
5ca0d812 | 2041 | return m_peer->IsEnabled() ; |
facd6764 SC |
2042 | } |
2043 | ||
8b573fb8 | 2044 | bool wxWindowMac::MacIsReallyHilited() |
c809f3be | 2045 | { |
5ca0d812 | 2046 | return m_peer->IsActive(); |
c809f3be SC |
2047 | } |
2048 | ||
8b573fb8 | 2049 | void wxWindowMac::MacFlashInvalidAreas() |
002c9672 SC |
2050 | { |
2051 | #if TARGET_API_MAC_OSX | |
2052 | HIViewFlashDirtyArea( (WindowRef) MacGetTopLevelWindowRef() ) ; | |
2053 | #endif | |
2054 | } | |
2055 | ||
8ab50549 SC |
2056 | // |
2057 | // | |
2058 | // | |
2059 | ||
e766c8a9 | 2060 | int wxWindowMac::GetCharHeight() const |
e9576ca5 | 2061 | { |
6264b550 RR |
2062 | wxClientDC dc ( (wxWindowMac*)this ) ; |
2063 | return dc.GetCharHeight() ; | |
e9576ca5 SC |
2064 | } |
2065 | ||
e766c8a9 | 2066 | int wxWindowMac::GetCharWidth() const |
e9576ca5 | 2067 | { |
6264b550 RR |
2068 | wxClientDC dc ( (wxWindowMac*)this ) ; |
2069 | return dc.GetCharWidth() ; | |
e9576ca5 SC |
2070 | } |
2071 | ||
e766c8a9 | 2072 | void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y, |
e7549107 | 2073 | int *descent, int *externalLeading, const wxFont *theFont ) const |
e9576ca5 | 2074 | { |
e7549107 SC |
2075 | const wxFont *fontToUse = theFont; |
2076 | if ( !fontToUse ) | |
2077 | fontToUse = &m_font; | |
14c9cbdb | 2078 | |
e766c8a9 | 2079 | wxClientDC dc( (wxWindowMac*) this ) ; |
7c74e7fe | 2080 | long lx,ly,ld,le ; |
5fde6fcc | 2081 | dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ; |
2f1ae414 | 2082 | if ( externalLeading ) |
6264b550 | 2083 | *externalLeading = le ; |
2f1ae414 | 2084 | if ( descent ) |
6264b550 | 2085 | *descent = ld ; |
2f1ae414 | 2086 | if ( x ) |
6264b550 | 2087 | *x = lx ; |
2f1ae414 | 2088 | if ( y ) |
6264b550 | 2089 | *y = ly ; |
e9576ca5 SC |
2090 | } |
2091 | ||
0a67a93b | 2092 | /* |
14c9cbdb | 2093 | * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect |
1c310985 SC |
2094 | * we always intersect with the entire window, not only with the client area |
2095 | */ | |
14c9cbdb | 2096 | |
e766c8a9 | 2097 | void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect) |
e9576ca5 | 2098 | { |
065ab451 SC |
2099 | if ( m_peer == NULL ) |
2100 | return ; | |
8b573fb8 | 2101 | |
facd6764 | 2102 | #if TARGET_API_MAC_OSX |
1e8cde71 | 2103 | if ( rect == NULL ) |
8b573fb8 | 2104 | m_peer->SetNeedsDisplay( true ) ; |
1e8cde71 SC |
2105 | else |
2106 | { | |
2107 | RgnHandle update = NewRgn() ; | |
2108 | SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ; | |
84f6927e SC |
2109 | SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ; |
2110 | wxPoint origin = GetClientAreaOrigin() ; | |
8b573fb8 | 2111 | OffsetRgn( update, origin.x , origin.y ) ; |
db7a550b SC |
2112 | // right now this is wx' window coordinates, as our native peer does not have borders, this is |
2113 | // inset | |
2114 | OffsetRgn( update , -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ; | |
8b573fb8 VZ |
2115 | m_peer->SetNeedsDisplay( true , update) ; |
2116 | DisposeRgn( update ) ; | |
1e8cde71 | 2117 | } |
facd6764 | 2118 | #else |
a9825a9b SC |
2119 | /* |
2120 | RgnHandle updateRgn = NewRgn() ; | |
2121 | if ( rect == NULL ) | |
2122 | { | |
2123 | CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ; | |
2124 | } | |
2125 | else | |
2126 | { | |
2127 | SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ; | |
8b573fb8 | 2128 | SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ; |
a9825a9b SC |
2129 | } |
2130 | InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ; | |
2131 | DisposeRgn(updateRgn) ; | |
2132 | */ | |
5ca0d812 | 2133 | if ( m_peer->IsVisible()) |
facd6764 | 2134 | { |
5ca0d812 SC |
2135 | m_peer->SetVisibility( false , false ) ; |
2136 | m_peer->SetVisibility( true , true ) ; | |
facd6764 SC |
2137 | } |
2138 | /* | |
94abc21f | 2139 | if ( MacGetTopLevelWindow() == NULL ) |
9a456218 | 2140 | return ; |
14c9cbdb | 2141 | |
5ca0d812 | 2142 | if ( !m_peer->IsVisible()) |
8b573fb8 VZ |
2143 | return ; |
2144 | ||
c3a05e8a | 2145 | wxPoint client = GetClientAreaOrigin(); |
9a456218 RR |
2146 | int x1 = -client.x; |
2147 | int y1 = -client.y; | |
2148 | int x2 = m_width - client.x; | |
2149 | int y2 = m_height - client.y; | |
2150 | ||
2151 | if (IsKindOf( CLASSINFO(wxButton))) | |
2152 | { | |
2153 | // buttons have an "aura" | |
2154 | y1 -= 5; | |
2155 | x1 -= 5; | |
2156 | y2 += 5; | |
2157 | x2 += 5; | |
2158 | } | |
2159 | ||
2160 | Rect clientrect = { y1, x1, y2, x2 }; | |
14c9cbdb | 2161 | |
1c310985 | 2162 | if ( rect ) |
6264b550 | 2163 | { |
1c310985 | 2164 | Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ; |
14c9cbdb | 2165 | SectRect( &clientrect , &r , &clientrect ) ; |
6264b550 | 2166 | } |
14c9cbdb | 2167 | |
1c310985 | 2168 | if ( !EmptyRect( &clientrect ) ) |
e9576ca5 | 2169 | { |
1c310985 | 2170 | int top = 0 , left = 0 ; |
14c9cbdb | 2171 | |
1c310985 SC |
2172 | MacClientToRootWindow( &left , &top ) ; |
2173 | OffsetRect( &clientrect , left , top ) ; | |
14c9cbdb | 2174 | |
1c310985 | 2175 | MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ; |
e9576ca5 | 2176 | } |
facd6764 SC |
2177 | */ |
2178 | #endif | |
2179 | } | |
2180 | ||
79392158 SC |
2181 | void wxWindowMac::Freeze() |
2182 | { | |
2183 | #if TARGET_API_MAC_OSX | |
2184 | if ( !m_frozenness++ ) | |
2185 | { | |
52ef5c3c RD |
2186 | if ( m_peer && m_peer->Ok() ) |
2187 | m_peer->SetDrawingEnabled( false ) ; | |
79392158 SC |
2188 | } |
2189 | #endif | |
2190 | } | |
2191 | ||
b175b96b | 2192 | |
79392158 SC |
2193 | void wxWindowMac::Thaw() |
2194 | { | |
2195 | #if TARGET_API_MAC_OSX | |
2196 | wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") ); | |
2197 | ||
2198 | if ( !--m_frozenness ) | |
2199 | { | |
52ef5c3c RD |
2200 | if ( m_peer && m_peer->Ok() ) |
2201 | { | |
2202 | m_peer->SetDrawingEnabled( true ) ; | |
2203 | m_peer->InvalidateWithChildren() ; | |
2204 | } | |
79392158 SC |
2205 | } |
2206 | #endif | |
2207 | } | |
2208 | ||
facd6764 SC |
2209 | void wxWindowMac::MacRedrawControl() |
2210 | { | |
2211 | /* | |
5ca0d812 | 2212 | if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible()) |
facd6764 SC |
2213 | { |
2214 | #if TARGET_API_MAC_CARBON | |
2215 | Update() ; | |
2216 | #else | |
2217 | wxClientDC dc(this) ; | |
2218 | wxMacPortSetter helper(&dc) ; | |
2219 | wxMacWindowClipper clipper(this) ; | |
2220 | wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; | |
21fd5529 | 2221 | UMADrawControl( *m_peer ) ; |
facd6764 SC |
2222 | #endif |
2223 | } | |
2224 | */ | |
2225 | } | |
8b573fb8 | 2226 | |
facd6764 SC |
2227 | /* TODO |
2228 | void wxWindowMac::OnPaint(wxPaintEvent& event) | |
2229 | { | |
2230 | // why don't we skip that here ? | |
e9576ca5 | 2231 | } |
facd6764 | 2232 | */ |
e9576ca5 | 2233 | |
e766c8a9 | 2234 | wxWindowMac *wxGetActiveWindow() |
e9576ca5 | 2235 | { |
519cb848 | 2236 | // actually this is a windows-only concept |
e9576ca5 SC |
2237 | return NULL; |
2238 | } | |
2239 | ||
e9576ca5 | 2240 | // Coordinates relative to the window |
e766c8a9 | 2241 | void wxWindowMac::WarpPointer (int x_pos, int y_pos) |
e9576ca5 | 2242 | { |
e40298d5 | 2243 | // We really don't move the mouse programmatically under Mac. |
e9576ca5 SC |
2244 | } |
2245 | ||
facd6764 | 2246 | void wxWindowMac::OnEraseBackground(wxEraseEvent& event) |
e9576ca5 | 2247 | { |
be346c26 | 2248 | #if TARGET_API_MAC_OSX |
facd6764 | 2249 | if ( m_macBackgroundBrush.Ok() == false || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT ) |
94abc21f | 2250 | { |
facd6764 | 2251 | event.Skip() ; |
94abc21f SC |
2252 | } |
2253 | else | |
be346c26 | 2254 | #endif |
7ebf5540 | 2255 | { |
8b573fb8 | 2256 | event.GetDC()->Clear() ; |
7ebf5540 | 2257 | } |
1c310985 SC |
2258 | } |
2259 | ||
2260 | void wxWindowMac::OnNcPaint( wxNcPaintEvent& event ) | |
2261 | { | |
af6b7b80 | 2262 | event.Skip() ; |
e9576ca5 SC |
2263 | } |
2264 | ||
e766c8a9 | 2265 | int wxWindowMac::GetScrollPos(int orient) const |
e9576ca5 | 2266 | { |
1c310985 SC |
2267 | if ( orient == wxHORIZONTAL ) |
2268 | { | |
2269 | if ( m_hScrollBar ) | |
2270 | return m_hScrollBar->GetThumbPosition() ; | |
2271 | } | |
2272 | else | |
2273 | { | |
2274 | if ( m_vScrollBar ) | |
2275 | return m_vScrollBar->GetThumbPosition() ; | |
2276 | } | |
e9576ca5 SC |
2277 | return 0; |
2278 | } | |
2279 | ||
2280 | // This now returns the whole range, not just the number | |
2281 | // of positions that we can scroll. | |
e766c8a9 | 2282 | int wxWindowMac::GetScrollRange(int orient) const |
e9576ca5 | 2283 | { |
1c310985 SC |
2284 | if ( orient == wxHORIZONTAL ) |
2285 | { | |
2286 | if ( m_hScrollBar ) | |
2287 | return m_hScrollBar->GetRange() ; | |
2288 | } | |
2289 | else | |
2290 | { | |
2291 | if ( m_vScrollBar ) | |
2292 | return m_vScrollBar->GetRange() ; | |
2293 | } | |
e9576ca5 SC |
2294 | return 0; |
2295 | } | |
2296 | ||
e766c8a9 | 2297 | int wxWindowMac::GetScrollThumb(int orient) const |
e9576ca5 | 2298 | { |
1c310985 SC |
2299 | if ( orient == wxHORIZONTAL ) |
2300 | { | |
2301 | if ( m_hScrollBar ) | |
2302 | return m_hScrollBar->GetThumbSize() ; | |
2303 | } | |
2304 | else | |
2305 | { | |
2306 | if ( m_vScrollBar ) | |
2307 | return m_vScrollBar->GetThumbSize() ; | |
2308 | } | |
e9576ca5 SC |
2309 | return 0; |
2310 | } | |
2311 | ||
e766c8a9 | 2312 | void wxWindowMac::SetScrollPos(int orient, int pos, bool refresh) |
e9576ca5 | 2313 | { |
1c310985 | 2314 | if ( orient == wxHORIZONTAL ) |
6264b550 | 2315 | { |
1c310985 SC |
2316 | if ( m_hScrollBar ) |
2317 | m_hScrollBar->SetThumbPosition( pos ) ; | |
6264b550 RR |
2318 | } |
2319 | else | |
2320 | { | |
1c310985 SC |
2321 | if ( m_vScrollBar ) |
2322 | m_vScrollBar->SetThumbPosition( pos ) ; | |
6264b550 | 2323 | } |
2f1ae414 SC |
2324 | } |
2325 | ||
14c9cbdb | 2326 | void wxWindowMac::MacPaintBorders( int left , int top ) |
2f1ae414 | 2327 | { |
1c310985 | 2328 | if( IsTopLevel() ) |
6264b550 | 2329 | return ; |
8b573fb8 | 2330 | |
fd926bcc | 2331 | Rect rect ; |
8b573fb8 | 2332 | m_peer->GetRect( &rect ) ; |
fd926bcc SC |
2333 | InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ; |
2334 | ||
2335 | if ( !IsTopLevel() ) | |
2336 | { | |
2337 | wxTopLevelWindowMac* top = MacGetTopLevelWindow(); | |
2338 | if (top) | |
2339 | { | |
2340 | wxPoint pt(0,0) ; | |
2341 | wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ; | |
2342 | rect.left += pt.x ; | |
2343 | rect.right += pt.x ; | |
2344 | rect.top += pt.y ; | |
2345 | rect.bottom += pt.y ; | |
2346 | } | |
2347 | } | |
8b573fb8 | 2348 | |
2f1ae414 SC |
2349 | if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) ) |
2350 | { | |
af6b7b80 | 2351 | Rect srect = rect ; |
11d1adbf | 2352 | SInt32 border = 0 ; |
5ca0d812 | 2353 | GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ; |
af6b7b80 SC |
2354 | InsetRect( &srect , border , border ); |
2355 | DrawThemeEditTextFrame(&srect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; | |
8208e181 SC |
2356 | } |
2357 | else if (HasFlag(wxSIMPLE_BORDER)) | |
2358 | { | |
af6b7b80 | 2359 | Rect srect = rect ; |
1a02aff9 SC |
2360 | SInt32 border = 0 ; |
2361 | GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ; | |
af6b7b80 | 2362 | InsetRect( &srect , border , border ); |
8b573fb8 | 2363 | DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; |
eec462f8 | 2364 | } |
8208e181 SC |
2365 | } |
2366 | ||
abda5788 SC |
2367 | void wxWindowMac::RemoveChild( wxWindowBase *child ) |
2368 | { | |
2369 | if ( child == m_hScrollBar ) | |
2370 | m_hScrollBar = NULL ; | |
2371 | if ( child == m_vScrollBar ) | |
2372 | m_vScrollBar = NULL ; | |
14c9cbdb | 2373 | |
abda5788 SC |
2374 | wxWindowBase::RemoveChild( child ) ; |
2375 | } | |
2376 | ||
e9576ca5 | 2377 | // New function that will replace some of the above. |
e766c8a9 | 2378 | void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible, |
e9576ca5 SC |
2379 | int range, bool refresh) |
2380 | { | |
e40298d5 JS |
2381 | if ( orient == wxHORIZONTAL ) |
2382 | { | |
2383 | if ( m_hScrollBar ) | |
6264b550 | 2384 | { |
e40298d5 | 2385 | if ( range == 0 || thumbVisible >= range ) |
6264b550 | 2386 | { |
e40298d5 JS |
2387 | if ( m_hScrollBar->IsShown() ) |
2388 | m_hScrollBar->Show(false) ; | |
2389 | } | |
2390 | else | |
2391 | { | |
2392 | if ( !m_hScrollBar->IsShown() ) | |
2393 | m_hScrollBar->Show(true) ; | |
2394 | m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; | |
6264b550 RR |
2395 | } |
2396 | } | |
e40298d5 JS |
2397 | } |
2398 | else | |
2399 | { | |
2400 | if ( m_vScrollBar ) | |
6264b550 | 2401 | { |
e40298d5 | 2402 | if ( range == 0 || thumbVisible >= range ) |
6264b550 | 2403 | { |
e40298d5 JS |
2404 | if ( m_vScrollBar->IsShown() ) |
2405 | m_vScrollBar->Show(false) ; | |
2406 | } | |
2407 | else | |
2408 | { | |
2409 | if ( !m_vScrollBar->IsShown() ) | |
2410 | m_vScrollBar->Show(true) ; | |
2411 | m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; | |
6264b550 RR |
2412 | } |
2413 | } | |
e40298d5 JS |
2414 | } |
2415 | MacRepositionScrollBars() ; | |
e9576ca5 SC |
2416 | } |
2417 | ||
2418 | // Does a physical scroll | |
e766c8a9 | 2419 | void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) |
e9576ca5 | 2420 | { |
ba87f54c SC |
2421 | if( dx == 0 && dy ==0 ) |
2422 | return ; | |
8b573fb8 | 2423 | |
6ed71b4f | 2424 | |
6264b550 | 2425 | { |
adb8a71b | 2426 | |
6264b550 RR |
2427 | int width , height ; |
2428 | GetClientSize( &width , &height ) ; | |
adb8a71b | 2429 | #if TARGET_API_MAC_OSX |
002c9672 | 2430 | // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control |
8b573fb8 | 2431 | // area is scrolled, this does not occur if width and height are 2 pixels less, |
002c9672 | 2432 | // TODO write optimal workaround |
42ef83fa | 2433 | wxRect scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width , height ) ; |
8b573fb8 | 2434 | if ( rect ) |
adb8a71b | 2435 | { |
5ca0d812 | 2436 | scrollrect.Intersect( *rect ) ; |
adb8a71b | 2437 | } |
5ca0d812 | 2438 | if ( m_peer->GetNeedsDisplay() ) |
002c9672 SC |
2439 | { |
2440 | // becuase HIViewScrollRect does not scroll the already invalidated area we have two options | |
2441 | // either immediate redraw or full invalidate | |
2442 | #if 1 | |
2443 | // is the better overall solution, as it does not slow down scrolling | |
5ca0d812 | 2444 | m_peer->SetNeedsDisplay( true ) ; |
002c9672 | 2445 | #else |
8b573fb8 | 2446 | // this would be the preferred version for fast drawing controls |
002c9672 SC |
2447 | if( UMAGetSystemVersion() < 0x1030 ) |
2448 | Update() ; | |
2449 | else | |
42ef83fa | 2450 | HIViewRender(m_peer->GetControlRef()) ; |
002c9672 SC |
2451 | #endif |
2452 | } | |
84e5d27d SC |
2453 | // as the native control might be not a 0/0 wx window coordinates, we have to offset |
2454 | scrollrect.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ; | |
5ca0d812 | 2455 | m_peer->ScrollRect( scrollrect , dx , dy ) ; |
adb8a71b | 2456 | #else |
6ed71b4f | 2457 | |
facd6764 | 2458 | wxPoint pos; |
8b573fb8 | 2459 | pos.x = pos.y = 0; |
430e1eed | 2460 | |
facd6764 | 2461 | Rect scrollrect; |
6264b550 | 2462 | RgnHandle updateRgn = NewRgn() ; |
430e1eed | 2463 | |
adb8a71b | 2464 | { |
430e1eed SC |
2465 | wxClientDC dc(this) ; |
2466 | wxMacPortSetter helper(&dc) ; | |
8b573fb8 | 2467 | |
5ca0d812 | 2468 | m_peer->GetRect( &scrollrect ) ; |
430e1eed SC |
2469 | scrollrect.top += MacGetTopBorderSize() ; |
2470 | scrollrect.left += MacGetLeftBorderSize() ; | |
2471 | scrollrect.bottom = scrollrect.top + height ; | |
2472 | scrollrect.right = scrollrect.left + width ; | |
8b573fb8 | 2473 | |
430e1eed SC |
2474 | if ( rect ) |
2475 | { | |
2476 | Rect r = { dc.YLOG2DEVMAC(rect->y) , dc.XLOG2DEVMAC(rect->x) , dc.YLOG2DEVMAC(rect->y + rect->height) , | |
2477 | dc.XLOG2DEVMAC(rect->x + rect->width) } ; | |
2478 | SectRect( &scrollrect , &r , &scrollrect ) ; | |
2479 | } | |
2480 | ScrollRect( &scrollrect , dx , dy , updateRgn ) ; | |
ba87f54c | 2481 | } |
430e1eed | 2482 | // ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ; |
facd6764 | 2483 | #endif |
6264b550 | 2484 | } |
6ed71b4f | 2485 | |
71f2fb52 | 2486 | for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext()) |
6264b550 | 2487 | { |
9bd1404d | 2488 | wxWindowMac *child = node->GetData(); |
6264b550 RR |
2489 | if (child == m_vScrollBar) continue; |
2490 | if (child == m_hScrollBar) continue; | |
2491 | if (child->IsTopLevel()) continue; | |
6ed71b4f | 2492 | |
6264b550 RR |
2493 | int x,y; |
2494 | child->GetPosition( &x, &y ); | |
2495 | int w,h; | |
2496 | child->GetSize( &w, &h ); | |
00f55394 SC |
2497 | if (rect) |
2498 | { | |
2499 | wxRect rc(x,y,w,h); | |
2500 | if (rect->Intersects(rc)) | |
2501 | child->SetSize( x+dx, y+dy, w, h ); | |
2502 | } | |
2503 | else | |
2504 | { | |
8b573fb8 VZ |
2505 | child->SetSize( x+dx, y+dy, w, h ); |
2506 | } | |
6264b550 | 2507 | } |
e9576ca5 SC |
2508 | } |
2509 | ||
e766c8a9 | 2510 | void wxWindowMac::MacOnScroll(wxScrollEvent &event ) |
7c74e7fe | 2511 | { |
6264b550 RR |
2512 | if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar ) |
2513 | { | |
2514 | wxScrollWinEvent wevent; | |
2515 | wevent.SetPosition(event.GetPosition()); | |
2516 | wevent.SetOrientation(event.GetOrientation()); | |
2517 | wevent.m_eventObject = this; | |
6ed71b4f VZ |
2518 | |
2519 | if (event.m_eventType == wxEVT_SCROLL_TOP) | |
6264b550 | 2520 | wevent.m_eventType = wxEVT_SCROLLWIN_TOP; |
6ed71b4f VZ |
2521 | else if (event.m_eventType == wxEVT_SCROLL_BOTTOM) |
2522 | wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM; | |
2523 | else if (event.m_eventType == wxEVT_SCROLL_LINEUP) | |
2524 | wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP; | |
2525 | else if (event.m_eventType == wxEVT_SCROLL_LINEDOWN) | |
2526 | wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; | |
2527 | else if (event.m_eventType == wxEVT_SCROLL_PAGEUP) | |
2528 | wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; | |
2529 | else if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN) | |
2530 | wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; | |
2531 | else if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK) | |
2532 | wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; | |
2533 | else if (event.m_eventType == wxEVT_SCROLL_THUMBRELEASE) | |
2534 | wevent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE; | |
2535 | ||
2536 | GetEventHandler()->ProcessEvent(wevent); | |
7c74e7fe SC |
2537 | } |
2538 | } | |
2539 | ||
e9576ca5 | 2540 | // Get the window with the focus |
0fe02759 | 2541 | wxWindowMac *wxWindowBase::DoFindFocus() |
e9576ca5 | 2542 | { |
f1d527c1 SC |
2543 | ControlRef control ; |
2544 | GetKeyboardFocus( GetUserFocusWindow() , &control ) ; | |
2545 | return wxFindControlFromMacControl( control ) ; | |
519cb848 SC |
2546 | } |
2547 | ||
e766c8a9 | 2548 | void wxWindowMac::OnSetFocus(wxFocusEvent& event) |
7810c95b SC |
2549 | { |
2550 | // panel wants to track the window which was the last to have focus in it, | |
2551 | // so we want to set ourselves as the window which last had focus | |
2552 | // | |
2553 | // notice that it's also important to do it upwards the tree becaus | |
2554 | // otherwise when the top level panel gets focus, it won't set it back to | |
2555 | // us, but to some other sibling | |
6ed71b4f | 2556 | |
c1fb8167 SC |
2557 | // CS:don't know if this is still needed: |
2558 | //wxChildFocusEvent eventFocus(this); | |
2559 | //(void)GetEventHandler()->ProcessEvent(eventFocus); | |
7810c95b | 2560 | |
5ca0d812 SC |
2561 | if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() ) |
2562 | { | |
788e118f | 2563 | wxMacWindowStateSaver sv( this ) ; |
5ca0d812 SC |
2564 | |
2565 | int w , h ; | |
788e118f SC |
2566 | int x , y ; |
2567 | x = y = 0 ; | |
2568 | MacWindowToRootWindow( &x , &y ) ; | |
5ca0d812 | 2569 | GetSize( &w , &h ) ; |
788e118f | 2570 | Rect rect = {y , x , h + y , w + x } ; |
5ca0d812 SC |
2571 | |
2572 | if ( event.GetEventType() == wxEVT_SET_FOCUS ) | |
2573 | DrawThemeFocusRect( &rect , true ) ; | |
2574 | else | |
af6b7b80 | 2575 | { |
5ca0d812 | 2576 | DrawThemeFocusRect( &rect , false ) ; |
8b573fb8 | 2577 | |
af6b7b80 | 2578 | // as this erases part of the frame we have to redraw borders |
101634b2 SC |
2579 | // and because our z-ordering is not always correct (staticboxes) |
2580 | // we have to invalidate things, we cannot simple redraw | |
2581 | RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() ; | |
2582 | RectRgn( updateInner , &rect ) ; | |
2583 | InsetRect( &rect , -4 , -4 ) ; | |
2584 | RectRgn( updateOuter , &rect ) ; | |
2585 | DiffRgn( updateOuter , updateInner ,updateOuter ) ; | |
8b573fb8 | 2586 | wxPoint parent(0,0); |
101634b2 SC |
2587 | GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ; |
2588 | parent -= GetParent()->GetClientAreaOrigin() ; | |
2589 | OffsetRgn( updateOuter , -parent.x , -parent.y ) ; | |
2590 | GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ; | |
2591 | DisposeRgn(updateOuter) ; | |
2592 | DisposeRgn(updateInner) ; | |
af6b7b80 | 2593 | } |
5ca0d812 SC |
2594 | } |
2595 | ||
7810c95b SC |
2596 | event.Skip(); |
2597 | } | |
2598 | ||
e39af974 | 2599 | void wxWindowMac::OnInternalIdle() |
e9576ca5 | 2600 | { |
e9576ca5 SC |
2601 | // This calls the UI-update mechanism (querying windows for |
2602 | // menu/toolbar/control state information) | |
e39af974 JS |
2603 | if (wxUpdateUIEvent::CanUpdate(this)) |
2604 | UpdateWindowUI(wxUPDATE_UI_FROMIDLE); | |
e9576ca5 SC |
2605 | } |
2606 | ||
2607 | // Raise the window to the top of the Z order | |
e766c8a9 | 2608 | void wxWindowMac::Raise() |
e9576ca5 | 2609 | { |
5ca0d812 | 2610 | m_peer->SetZOrder( true , NULL ) ; |
e9576ca5 SC |
2611 | } |
2612 | ||
2613 | // Lower the window to the bottom of the Z order | |
e766c8a9 | 2614 | void wxWindowMac::Lower() |
e9576ca5 | 2615 | { |
5ca0d812 | 2616 | m_peer->SetZOrder( false , NULL ) ; |
e9576ca5 SC |
2617 | } |
2618 | ||
6ed71b4f | 2619 | |
facd6764 | 2620 | // static wxWindow *gs_lastWhich = NULL; |
519cb848 | 2621 | |
7de59551 | 2622 | bool wxWindowMac::MacSetupCursor( const wxPoint& pt) |
467e3168 SC |
2623 | { |
2624 | // first trigger a set cursor event | |
6ed71b4f | 2625 | |
467e3168 SC |
2626 | wxPoint clientorigin = GetClientAreaOrigin() ; |
2627 | wxSize clientsize = GetClientSize() ; | |
2628 | wxCursor cursor ; | |
2629 | if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) | |
7de59551 | 2630 | { |
467e3168 | 2631 | wxSetCursorEvent event( pt.x , pt.y ); |
6ed71b4f | 2632 | |
467e3168 SC |
2633 | bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); |
2634 | if ( processedEvtSetCursor && event.HasCursor() ) | |
2635 | { | |
e40298d5 | 2636 | cursor = event.GetCursor() ; |
467e3168 SC |
2637 | } |
2638 | else | |
2639 | { | |
6ed71b4f | 2640 | |
467e3168 SC |
2641 | // the test for processedEvtSetCursor is here to prevent using m_cursor |
2642 | // if the user code caught EVT_SET_CURSOR() and returned nothing from | |
2643 | // it - this is a way to say that our cursor shouldn't be used for this | |
2644 | // point | |
2645 | if ( !processedEvtSetCursor && m_cursor.Ok() ) | |
2646 | { | |
2647 | cursor = m_cursor ; | |
2648 | } | |
2649 | if ( wxIsBusy() ) | |
2650 | { | |
2651 | } | |
2652 | else | |
2653 | { | |
2654 | if ( !GetParent() ) | |
2655 | cursor = *wxSTANDARD_CURSOR ; | |
2656 | } | |
2657 | } | |
2658 | if ( cursor.Ok() ) | |
2659 | cursor.MacInstall() ; | |
2660 | } | |
2661 | return cursor.Ok() ; | |
2662 | } | |
2663 | ||
e766c8a9 | 2664 | wxString wxWindowMac::MacGetToolTipString( wxPoint &pt ) |
2f1ae414 | 2665 | { |
6264b550 RR |
2666 | if ( m_tooltip ) |
2667 | { | |
2668 | return m_tooltip->GetTip() ; | |
2669 | } | |
427ff662 | 2670 | return wxEmptyString ; |
2f1ae414 | 2671 | } |
6264b550 | 2672 | |
1c310985 | 2673 | void wxWindowMac::Update() |
519cb848 | 2674 | { |
facd6764 | 2675 | #if TARGET_API_MAC_OSX |
957f865c | 2676 | |
430e1eed | 2677 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 |
957f865c RN |
2678 | WindowRef window = (WindowRef)MacGetTopLevelWindowRef() ; |
2679 | ||
430e1eed SC |
2680 | // for composited windows this also triggers a redraw of all |
2681 | // invalid views in the window | |
2682 | if( UMAGetSystemVersion() >= 0x1030 ) | |
8b573fb8 VZ |
2683 | HIWindowFlush(window) ; |
2684 | else | |
430e1eed SC |
2685 | #endif |
2686 | { | |
2687 | // the only way to trigger the redrawing on earlier systems is to call | |
2688 | // ReceiveNextEvent | |
2689 | ||
2690 | EventRef currentEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ; | |
2691 | UInt32 currentEventClass = 0 ; | |
2692 | UInt32 currentEventKind = 0 ; | |
2693 | if ( currentEvent != NULL ) | |
2694 | { | |
2695 | currentEventClass = ::GetEventClass( currentEvent ) ; | |
2696 | currentEventKind = ::GetEventKind( currentEvent ) ; | |
8b573fb8 | 2697 | } |
430e1eed SC |
2698 | if ( currentEventClass != kEventClassMenu ) |
2699 | { | |
2700 | // when tracking a menu, strange redraw errors occur if we flush now, so leave.. | |
2701 | ||
2702 | EventRef theEvent; | |
2703 | OSStatus status = noErr ; | |
2704 | status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ; | |
2705 | } | |
3e444781 | 2706 | else |
5ca0d812 | 2707 | m_peer->SetNeedsDisplay( true ) ; |
430e1eed | 2708 | } |
facd6764 | 2709 | #else |
5ca0d812 | 2710 | ::Draw1Control( m_peer->GetControlRef() ) ; |
bec721ec | 2711 | #endif |
519cb848 SC |
2712 | } |
2713 | ||
14c9cbdb | 2714 | wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const |
519cb848 | 2715 | { |
1c310985 | 2716 | wxTopLevelWindowMac* win = NULL ; |
facd6764 | 2717 | WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; |
1c310985 | 2718 | if ( window ) |
6264b550 | 2719 | { |
1c310985 | 2720 | win = wxFindWinFromMacWindow( window ) ; |
14c9cbdb | 2721 | } |
1c310985 | 2722 | return win ; |
519cb848 | 2723 | } |
facd6764 | 2724 | wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) |
94abc21f | 2725 | { |
0fa8508d SC |
2726 | // includeOuterStructures is true if we try to draw somthing like a focus ring etc. |
2727 | // also a window dc uses this, in this case we only clip in the hierarchy for hard | |
2728 | // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having | |
2729 | // to add focus borders everywhere | |
8b573fb8 | 2730 | |
facd6764 | 2731 | Rect r ; |
e40298d5 JS |
2732 | RgnHandle visRgn = NewRgn() ; |
2733 | RgnHandle tempRgn = NewRgn() ; | |
5ca0d812 | 2734 | if ( m_peer->IsVisible()) |
e40298d5 | 2735 | { |
5ca0d812 SC |
2736 | m_peer->GetRect( &r ) ; |
2737 | r.left -= MacGetLeftBorderSize() ; | |
2738 | r.top -= MacGetTopBorderSize() ; | |
2739 | r.bottom += MacGetBottomBorderSize() ; | |
2740 | r.right += MacGetRightBorderSize() ; | |
8b573fb8 | 2741 | |
facd6764 | 2742 | if (! MacGetTopLevelWindow()->MacUsesCompositing() ) |
21f9e953 | 2743 | { |
facd6764 SC |
2744 | MacRootWindowToWindow( &r.left , & r.top ) ; |
2745 | MacRootWindowToWindow( &r.right , & r.bottom ) ; | |
21f9e953 | 2746 | } |
facd6764 SC |
2747 | else |
2748 | { | |
2749 | r.right -= r.left ; | |
2750 | r.bottom -= r.top ; | |
2751 | r.left = 0 ; | |
2752 | r.top = 0 ; | |
2753 | } | |
2754 | if ( includeOuterStructures ) | |
af6b7b80 | 2755 | InsetRect( &r , -4 , -4 ) ; |
facd6764 | 2756 | RectRgn( visRgn , &r ) ; |
db7a550b | 2757 | |
21f9e953 | 2758 | if ( !IsTopLevel() ) |
94abc21f | 2759 | { |
facd6764 SC |
2760 | wxWindow* child = this ; |
2761 | wxWindow* parent = child->GetParent() ; | |
21f9e953 SC |
2762 | while( parent ) |
2763 | { | |
21f9e953 | 2764 | int x , y ; |
facd6764 | 2765 | wxSize size ; |
d3e780ec SC |
2766 | // we have to find a better clipping algorithm here, in order not to clip things |
2767 | // positioned like status and toolbar | |
2768 | if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ ) | |
facd6764 SC |
2769 | { |
2770 | size = parent->GetSize() ; | |
2771 | x = y = 0 ; | |
2772 | } | |
2773 | else | |
2774 | { | |
2775 | size = parent->GetClientSize() ; | |
2776 | wxPoint origin = parent->GetClientAreaOrigin() ; | |
2777 | x = origin.x ; | |
2778 | y = origin.y ; | |
2779 | } | |
21f9e953 SC |
2780 | parent->MacWindowToRootWindow( &x, &y ) ; |
2781 | MacRootWindowToWindow( &x , &y ) ; | |
2782 | ||
0fa8508d | 2783 | if ( !includeOuterStructures || ( |
7f17ac74 SC |
2784 | parent->MacClipChildren() || |
2785 | ( parent->GetParent() && parent->GetParent()->MacClipGrandChildren() ) | |
0fa8508d SC |
2786 | ) ) |
2787 | { | |
2788 | SetRectRgn( tempRgn , | |
2789 | x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , | |
2790 | x + size.x - parent->MacGetRightBorderSize(), | |
2791 | y + size.y - parent->MacGetBottomBorderSize()) ; | |
21f9e953 | 2792 | |
0fa8508d SC |
2793 | SectRgn( visRgn , tempRgn , visRgn ) ; |
2794 | } | |
21f9e953 SC |
2795 | if ( parent->IsTopLevel() ) |
2796 | break ; | |
facd6764 SC |
2797 | child = parent ; |
2798 | parent = child->GetParent() ; | |
7372fd0a | 2799 | } |
94abc21f | 2800 | } |
e40298d5 | 2801 | } |
facd6764 SC |
2802 | |
2803 | wxRegion vis = visRgn ; | |
e40298d5 JS |
2804 | DisposeRgn( visRgn ) ; |
2805 | DisposeRgn( tempRgn ) ; | |
facd6764 | 2806 | return vis ; |
94abc21f SC |
2807 | } |
2808 | ||
facd6764 SC |
2809 | /* |
2810 | This function must not change the updatergn ! | |
2811 | */ | |
8b573fb8 | 2812 | bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) |
519cb848 | 2813 | { |
76a5e5d2 | 2814 | RgnHandle updatergn = (RgnHandle) updatergnr ; |
facd6764 | 2815 | bool handled = false ; |
42ef83fa SC |
2816 | Rect updatebounds ; |
2817 | GetRegionBounds( updatergn , &updatebounds ) ; | |
eec462f8 | 2818 | // wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ; |
42ef83fa | 2819 | if ( !EmptyRgn(updatergn) ) |
6264b550 | 2820 | { |
1c310985 SC |
2821 | RgnHandle newupdate = NewRgn() ; |
2822 | wxSize point = GetClientSize() ; | |
2823 | wxPoint origin = GetClientAreaOrigin() ; | |
1c310985 | 2824 | SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y+point.y ) ; |
facd6764 | 2825 | SectRgn( newupdate , updatergn , newupdate ) ; |
8b573fb8 | 2826 | |
eec462f8 SC |
2827 | // first send an erase event to the entire update area |
2828 | { | |
42ef83fa | 2829 | wxWindowDC dc(this); |
1a02aff9 | 2830 | dc.SetClippingRegion(wxRegion(updatergn)); |
42ef83fa SC |
2831 | wxEraseEvent eevent( GetId(), &dc ); |
2832 | eevent.SetEventObject( this ); | |
2833 | GetEventHandler()->ProcessEvent( eevent ); | |
eec462f8 | 2834 | } |
8b573fb8 | 2835 | |
42ef83fa | 2836 | // calculate a client-origin version of the update rgn and set m_updateRegion to that |
1c310985 SC |
2837 | OffsetRgn( newupdate , -origin.x , -origin.y ) ; |
2838 | m_updateRegion = newupdate ; | |
8b573fb8 | 2839 | DisposeRgn( newupdate ) ; |
6ed71b4f | 2840 | |
1c310985 | 2841 | if ( !m_updateRegion.Empty() ) |
6264b550 | 2842 | { |
facd6764 | 2843 | // paint the window itself |
e40298d5 JS |
2844 | wxPaintEvent event; |
2845 | event.m_timeStamp = time ; | |
2846 | event.SetEventObject(this); | |
8b573fb8 | 2847 | handled = GetEventHandler()->ProcessEvent(event); |
af6b7b80 SC |
2848 | |
2849 | // we have to call the default built-in handler, as otherwise our frames will be drawn and immediately erased afterwards | |
2850 | if ( !handled ) | |
2851 | { | |
2852 | if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL ) | |
2853 | { | |
2854 | CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ; | |
2855 | handled = true ; | |
2856 | } | |
2857 | } | |
2858 | ||
eec462f8 | 2859 | } |
8b573fb8 | 2860 | |
eec462f8 SC |
2861 | // now we cannot rely on having its borders drawn by a window itself, as it does not |
2862 | // get the updateRgn wide enough to always do so, so we do it from the parent | |
2863 | // this would also be the place to draw any custom backgrounds for native controls | |
2864 | // in Composited windowing | |
36d7f54e | 2865 | wxPoint clientOrigin = GetClientAreaOrigin() ; |
8b573fb8 | 2866 | |
71f2fb52 | 2867 | for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext()) |
eec462f8 SC |
2868 | { |
2869 | wxWindowMac *child = node->GetData(); | |
2870 | if (child == m_vScrollBar) continue; | |
2871 | if (child == m_hScrollBar) continue; | |
2872 | if (child->IsTopLevel()) continue; | |
2873 | if (!child->IsShown()) continue; | |
fe779e40 | 2874 | |
af6b7b80 SC |
2875 | int x,y; |
2876 | child->GetPosition( &x, &y ); | |
2877 | int w,h; | |
2878 | child->GetSize( &w, &h ); | |
2879 | Rect childRect = { y , x , y + h , x + w } ; | |
36d7f54e | 2880 | OffsetRect( &childRect , clientOrigin.x , clientOrigin.y ) ; |
eec462f8 SC |
2881 | if ( child->MacGetTopBorderSize() ) |
2882 | { | |
eec462f8 SC |
2883 | if ( RectInRgn( &childRect , updatergn ) ) |
2884 | { | |
2885 | // paint custom borders | |
2886 | wxNcPaintEvent eventNc( child->GetId() ); | |
2887 | eventNc.SetEventObject( child ); | |
af6b7b80 SC |
2888 | if ( !child->GetEventHandler()->ProcessEvent( eventNc ) ) |
2889 | { | |
2890 | wxWindowDC dc(this) ; | |
2891 | dc.SetClippingRegion(wxRegion(updatergn)); | |
2892 | wxMacPortSetter helper(&dc) ; | |
36d7f54e | 2893 | child->MacPaintBorders( dc.m_macLocalOrigin.x + childRect.left , dc.m_macLocalOrigin.y + childRect.top) ; |
af6b7b80 | 2894 | } |
eec462f8 | 2895 | } |
8b573fb8 | 2896 | } |
af6b7b80 SC |
2897 | if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() ) |
2898 | { | |
2899 | wxWindowDC dc(this) ; | |
2900 | dc.SetClippingRegion(wxRegion(updatergn)); | |
2901 | wxMacPortSetter helper(&dc) ; | |
7ebf5540 SC |
2902 | Rect r = childRect ; |
2903 | OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ; | |
2904 | DrawThemeFocusRect( &r , true ) ; | |
af6b7b80 | 2905 | } |
14c9cbdb | 2906 | } |
6264b550 | 2907 | } |
facd6764 SC |
2908 | return handled ; |
2909 | } | |
6ed71b4f | 2910 | |
facd6764 SC |
2911 | void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) |
2912 | { | |
2913 | RgnHandle updatergn = (RgnHandle) updatergnr ; | |
2914 | // updatergn is always already clipped to our boundaries | |
2915 | // if we are in compositing mode then it is in relative to the upper left of the control | |
2916 | // if we are in non-compositing, then it is relatvie to the uppder left of the content area | |
2917 | // of the toplevel window | |
2918 | // it is in window coordinates, not in client coordinates | |
6ed71b4f | 2919 | |
facd6764 SC |
2920 | // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates |
2921 | RgnHandle ownUpdateRgn = NewRgn() ; | |
2922 | CopyRgn( updatergn , ownUpdateRgn ) ; | |
2923 | ||
2924 | if ( MacGetTopLevelWindow()->MacUsesCompositing() == false ) | |
8b573fb8 | 2925 | { |
facd6764 | 2926 | Rect bounds; |
5ca0d812 | 2927 | m_peer->GetRectInWindowCoords( &bounds ); |
facd6764 SC |
2928 | RgnHandle controlRgn = NewRgn(); |
2929 | RectRgn( controlRgn, &bounds ); | |
2930 | //KO: This sets the ownUpdateRgn to the area of this control that is inside | |
2931 | // the window update region | |
8b573fb8 | 2932 | SectRgn( ownUpdateRgn, controlRgn, ownUpdateRgn ); |
facd6764 | 2933 | DisposeRgn( controlRgn ); |
8b573fb8 | 2934 | |
facd6764 | 2935 | //KO: convert ownUpdateRgn to local coordinates |
8b573fb8 | 2936 | OffsetRgn( ownUpdateRgn, -bounds.left, -bounds.top ); |
6264b550 | 2937 | } |
8b573fb8 | 2938 | |
facd6764 SC |
2939 | MacDoRedraw( ownUpdateRgn , time ) ; |
2940 | DisposeRgn( ownUpdateRgn ) ; | |
6ed71b4f | 2941 | |
519cb848 SC |
2942 | } |
2943 | ||
facd6764 | 2944 | WXWindow wxWindowMac::MacGetTopLevelWindowRef() const |
519cb848 | 2945 | { |
6264b550 | 2946 | wxWindowMac *iter = (wxWindowMac*)this ; |
14c9cbdb | 2947 | |
6264b550 RR |
2948 | while( iter ) |
2949 | { | |
1c310985 SC |
2950 | if ( iter->IsTopLevel() ) |
2951 | return ((wxTopLevelWindow*)iter)->MacGetWindowRef() ; | |
519cb848 | 2952 | |
6264b550 | 2953 | iter = iter->GetParent() ; |
14c9cbdb | 2954 | } |
427ff662 | 2955 | wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ; |
6264b550 | 2956 | return NULL ; |
519cb848 SC |
2957 | } |
2958 | ||
14c9cbdb | 2959 | void wxWindowMac::MacCreateScrollBars( long style ) |
519cb848 | 2960 | { |
427ff662 | 2961 | wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ; |
14c9cbdb | 2962 | |
aa99e0cd SC |
2963 | if ( style & ( wxVSCROLL | wxHSCROLL ) ) |
2964 | { | |
2965 | bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ; | |
db7a550b | 2966 | int scrlsize = MAC_SCROLLBAR_SIZE ; |
8b573fb8 VZ |
2967 | wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL ; |
2968 | if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL || GetWindowVariant() == wxWINDOW_VARIANT_MINI ) | |
2969 | { | |
2970 | scrlsize = MAC_SMALL_SCROLLBAR_SIZE ; | |
2971 | variant = wxWINDOW_VARIANT_SMALL ; | |
2972 | } | |
db7a550b SC |
2973 | |
2974 | int adjust = hasBoth ? scrlsize - 1: 0 ; | |
aa99e0cd SC |
2975 | int width, height ; |
2976 | GetClientSize( &width , &height ) ; | |
2977 | ||
db7a550b SC |
2978 | wxPoint vPoint(width-scrlsize, 0) ; |
2979 | wxSize vSize(scrlsize, height - adjust) ; | |
2980 | wxPoint hPoint(0 , height-scrlsize ) ; | |
2981 | wxSize hSize( width - adjust, scrlsize) ; | |
aa99e0cd SC |
2982 | |
2983 | ||
2984 | if ( style & wxVSCROLL ) | |
2985 | { | |
375bb200 | 2986 | m_vScrollBar = new wxScrollBar(this, wxID_ANY, vPoint, |
aa99e0cd SC |
2987 | vSize , wxVERTICAL); |
2988 | } | |
2989 | ||
2990 | if ( style & wxHSCROLL ) | |
2991 | { | |
375bb200 | 2992 | m_hScrollBar = new wxScrollBar(this, wxID_ANY, hPoint, |
aa99e0cd SC |
2993 | hSize , wxHORIZONTAL); |
2994 | } | |
2995 | } | |
aa99e0cd | 2996 | |
14c9cbdb | 2997 | |
6264b550 RR |
2998 | // because the create does not take into account the client area origin |
2999 | MacRepositionScrollBars() ; // we might have a real position shift | |
519cb848 SC |
3000 | } |
3001 | ||
e766c8a9 | 3002 | void wxWindowMac::MacRepositionScrollBars() |
519cb848 | 3003 | { |
aa99e0cd SC |
3004 | if ( !m_hScrollBar && !m_vScrollBar ) |
3005 | return ; | |
8b573fb8 | 3006 | |
6264b550 | 3007 | bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ; |
db7a550b SC |
3008 | int scrlsize = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ; |
3009 | int adjust = hasBoth ? scrlsize - 1 : 0 ; | |
14c9cbdb | 3010 | |
6264b550 | 3011 | // get real client area |
14c9cbdb | 3012 | |
facd6764 SC |
3013 | int width ; |
3014 | int height ; | |
3015 | GetSize( &width , &height ) ; | |
6264b550 RR |
3016 | |
3017 | width -= MacGetLeftBorderSize() + MacGetRightBorderSize(); | |
3018 | height -= MacGetTopBorderSize() + MacGetBottomBorderSize(); | |
14c9cbdb | 3019 | |
6264b550 RR |
3020 | wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ; |
3021 | wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ; | |
3022 | wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ; | |
3023 | wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ; | |
db7a550b | 3024 | /* |
14c9cbdb | 3025 | int x = 0 ; |
6264b550 | 3026 | int y = 0 ; |
facd6764 SC |
3027 | int w ; |
3028 | int h ; | |
3029 | GetSize( &w , &h ) ; | |
14c9cbdb | 3030 | |
6264b550 RR |
3031 | MacClientToRootWindow( &x , &y ) ; |
3032 | MacClientToRootWindow( &w , &h ) ; | |
14c9cbdb | 3033 | |
6264b550 | 3034 | wxWindowMac *iter = (wxWindowMac*)this ; |
14c9cbdb | 3035 | |
6264b550 RR |
3036 | int totW = 10000 , totH = 10000; |
3037 | while( iter ) | |
3038 | { | |
1c310985 | 3039 | if ( iter->IsTopLevel() ) |
6264b550 | 3040 | { |
facd6764 | 3041 | iter->GetSize( &totW , &totH ) ; |
6264b550 RR |
3042 | break ; |
3043 | } | |
3044 | ||
3045 | iter = iter->GetParent() ; | |
14c9cbdb RD |
3046 | } |
3047 | ||
6264b550 RR |
3048 | if ( x == 0 ) |
3049 | { | |
3050 | hPoint.x = -1 ; | |
3051 | hSize.x += 1 ; | |
3052 | } | |
3053 | if ( y == 0 ) | |
3054 | { | |
3055 | vPoint.y = -1 ; | |
3056 | vSize.y += 1 ; | |
3057 | } | |
14c9cbdb | 3058 | |
6264b550 RR |
3059 | if ( w-x >= totW ) |
3060 | { | |
3061 | hSize.x += 1 ; | |
3062 | vPoint.x += 1 ; | |
3063 | } | |
14c9cbdb | 3064 | |
6264b550 RR |
3065 | if ( h-y >= totH ) |
3066 | { | |
3067 | vSize.y += 1 ; | |
3068 | hPoint.y += 1 ; | |
3069 | } | |
db7a550b | 3070 | */ |
6264b550 RR |
3071 | if ( m_vScrollBar ) |
3072 | { | |
3073 | m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE); | |
3074 | } | |
3075 | if ( m_hScrollBar ) | |
3076 | { | |
3077 | m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE); | |
3078 | } | |
519cb848 SC |
3079 | } |
3080 | ||
e766c8a9 | 3081 | bool wxWindowMac::AcceptsFocus() const |
7c551d95 SC |
3082 | { |
3083 | return MacCanFocus() && wxWindowBase::AcceptsFocus(); | |
3084 | } | |
519cb848 | 3085 | |
14c9cbdb | 3086 | void wxWindowMac::MacSuperChangedPosition() |
519cb848 | 3087 | { |
6264b550 | 3088 | // only window-absolute structures have to be moved i.e. controls |
519cb848 | 3089 | |
71f2fb52 | 3090 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
6264b550 RR |
3091 | while ( node ) |
3092 | { | |
9bd1404d | 3093 | wxWindowMac *child = node->GetData(); |
6264b550 | 3094 | child->MacSuperChangedPosition() ; |
eb22f2a6 | 3095 | node = node->GetNext(); |
6264b550 | 3096 | } |
519cb848 | 3097 | } |
519cb848 | 3098 | |
14c9cbdb | 3099 | void wxWindowMac::MacTopLevelWindowChangedPosition() |
a3bf4a62 | 3100 | { |
6264b550 | 3101 | // only screen-absolute structures have to be moved i.e. glcanvas |
a3bf4a62 | 3102 | |
71f2fb52 | 3103 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
6264b550 RR |
3104 | while ( node ) |
3105 | { | |
9bd1404d | 3106 | wxWindowMac *child = node->GetData(); |
6264b550 | 3107 | child->MacTopLevelWindowChangedPosition() ; |
eb22f2a6 | 3108 | node = node->GetNext(); |
6264b550 | 3109 | } |
a3bf4a62 | 3110 | } |
facd6764 | 3111 | |
e766c8a9 | 3112 | long wxWindowMac::MacGetLeftBorderSize( ) const |
2f1ae414 | 3113 | { |
1c310985 | 3114 | if( IsTopLevel() ) |
6264b550 | 3115 | return 0 ; |
2f1ae414 SC |
3116 | |
3117 | if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER ) | |
3118 | { | |
ed60b502 | 3119 | SInt32 border = 3 ; |
ed60b502 | 3120 | return border ; |
2f1ae414 SC |
3121 | } |
3122 | else if ( m_windowStyle &wxDOUBLE_BORDER) | |
3123 | { | |
ed60b502 | 3124 | SInt32 border = 3 ; |
ed60b502 | 3125 | return border ; |
2f1ae414 SC |
3126 | } |
3127 | else if (m_windowStyle &wxSIMPLE_BORDER) | |
3128 | { | |
6264b550 | 3129 | return 1 ; |
2f1ae414 | 3130 | } |
6264b550 | 3131 | return 0 ; |
2f1ae414 SC |
3132 | } |
3133 | ||
e766c8a9 | 3134 | long wxWindowMac::MacGetRightBorderSize( ) const |
5b781a67 | 3135 | { |
1c310985 SC |
3136 | // they are all symmetric in mac themes |
3137 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
3138 | } |
3139 | ||
e766c8a9 | 3140 | long wxWindowMac::MacGetTopBorderSize( ) const |
5b781a67 | 3141 | { |
1c310985 SC |
3142 | // they are all symmetric in mac themes |
3143 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
3144 | } |
3145 | ||
e766c8a9 | 3146 | long wxWindowMac::MacGetBottomBorderSize( ) const |
5b781a67 | 3147 | { |
1c310985 SC |
3148 | // they are all symmetric in mac themes |
3149 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
3150 | } |
3151 | ||
14c9cbdb | 3152 | long wxWindowMac::MacRemoveBordersFromStyle( long style ) |
2f1ae414 | 3153 | { |
055a486b | 3154 | return style & ~wxBORDER_MASK ; |
2f1ae414 | 3155 | } |
0a67a93b | 3156 | |
e766c8a9 | 3157 | // Find the wxWindowMac at the current mouse position, returning the mouse |
3723b7b1 | 3158 | // position. |
e766c8a9 | 3159 | wxWindowMac* wxFindWindowAtPointer(wxPoint& pt) |
3723b7b1 | 3160 | { |
59a12e90 | 3161 | pt = wxGetMousePosition(); |
e766c8a9 | 3162 | wxWindowMac* found = wxFindWindowAtPoint(pt); |
59a12e90 | 3163 | return found; |
3723b7b1 JS |
3164 | } |
3165 | ||
3166 | // Get the current mouse position. | |
3167 | wxPoint wxGetMousePosition() | |
3168 | { | |
57591e0e JS |
3169 | int x, y; |
3170 | wxGetMousePosition(& x, & y); | |
3171 | return wxPoint(x, y); | |
3723b7b1 JS |
3172 | } |
3173 | ||
6ed71b4f | 3174 | void wxWindowMac::OnMouseEvent( wxMouseEvent &event ) |
8950f7cc | 3175 | { |
8b573fb8 VZ |
3176 | if ( event.GetEventType() == wxEVT_RIGHT_DOWN ) |
3177 | { | |
3178 | // copied from wxGTK : CS | |
249aad30 | 3179 | // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN |
8950f7cc SC |
3180 | // except that: |
3181 | // | |
3182 | // (a) it's a command event and so is propagated to the parent | |
3183 | // (b) under MSW it can be generated from kbd too | |
3184 | // (c) it uses screen coords (because of (a)) | |
3185 | wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, | |
3186 | this->GetId(), | |
3187 | this->ClientToScreen(event.GetPosition())); | |
249aad30 SC |
3188 | if ( ! GetEventHandler()->ProcessEvent(evtCtx) ) |
3189 | event.Skip() ; | |
8b573fb8 | 3190 | } |
facd6764 SC |
3191 | else |
3192 | { | |
8b573fb8 | 3193 | event.Skip() ; |
facd6764 | 3194 | } |
8950f7cc SC |
3195 | } |
3196 | ||
8b573fb8 | 3197 | void wxWindowMac::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) |
facd6764 | 3198 | { |
facd6764 SC |
3199 | } |
3200 | ||
8b573fb8 | 3201 | Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin ) |
3083eb85 SC |
3202 | { |
3203 | int x ,y , w ,h ; | |
8b573fb8 | 3204 | |
79392158 | 3205 | window->MacGetBoundsForControl( pos , size , x , y, w, h , adjustForOrigin) ; |
3083eb85 SC |
3206 | Rect bounds = { y , x , y+h , x+w }; |
3207 | return bounds ; | |
3208 | } | |
3209 | ||
8b573fb8 | 3210 | wxInt32 wxWindowMac::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) |
f1d527c1 SC |
3211 | { |
3212 | return eventNotHandledErr ; | |
3213 | } | |
3214 | ||
facd6764 | 3215 |