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