1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/window.cpp
3 // Purpose: wxWindowMac
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/window.h"
23 #include "wx/dcclient.h"
24 #include "wx/button.h"
26 #include "wx/dialog.h"
27 #include "wx/settings.h"
28 #include "wx/msgdlg.h"
29 #include "wx/scrolbar.h"
30 #include "wx/statbox.h"
31 #include "wx/textctrl.h"
32 #include "wx/toolbar.h"
33 #include "wx/layout.h"
34 #include "wx/statusbr.h"
35 #include "wx/menuitem.h"
36 #include "wx/treectrl.h"
37 #include "wx/listctrl.h"
40 #include "wx/tooltip.h"
41 #include "wx/spinctrl.h"
42 #include "wx/geometry.h"
45 #include "wx/listctrl.h"
49 #include "wx/treectrl.h"
57 #include "wx/popupwin.h"
60 #if wxUSE_DRAG_AND_DROP
65 #include "wx/osx/uma.h"
67 #include "wx/osx/private.h"
69 #include <Carbon/Carbon.h>
72 #define MAC_SCROLLBAR_SIZE 15
73 #define MAC_SMALL_SCROLLBAR_SIZE 11
77 #define wxMAC_DEBUG_REDRAW 0
78 #ifndef wxMAC_DEBUG_REDRAW
79 #define wxMAC_DEBUG_REDRAW 0
82 // Get the window with the focus
83 WXWidget
wxWidgetImpl::FindFocus()
85 ControlRef control
= NULL
;
86 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
90 // ---------------------------------------------------------------------------
92 // ---------------------------------------------------------------------------
94 static const EventTypeSpec eventList
[] =
96 { kEventClassCommand
, kEventProcessCommand
} ,
97 { kEventClassCommand
, kEventCommandUpdateStatus
} ,
99 { kEventClassControl
, kEventControlGetClickActivation
} ,
100 { kEventClassControl
, kEventControlHit
} ,
102 { kEventClassTextInput
, kEventTextInputUnicodeForKeyEvent
} ,
103 { kEventClassTextInput
, kEventTextInputUpdateActiveInputArea
} ,
105 { kEventClassControl
, kEventControlDraw
} ,
107 { kEventClassControl
, kEventControlVisibilityChanged
} ,
108 { kEventClassControl
, kEventControlEnabledStateChanged
} ,
109 { kEventClassControl
, kEventControlHiliteChanged
} ,
111 { kEventClassControl
, kEventControlActivate
} ,
112 { kEventClassControl
, kEventControlDeactivate
} ,
114 { kEventClassControl
, kEventControlSetFocusPart
} ,
115 { kEventClassControl
, kEventControlFocusPartChanged
} ,
117 { kEventClassService
, kEventServiceGetTypes
},
118 { kEventClassService
, kEventServiceCopy
},
119 { kEventClassService
, kEventServicePaste
},
121 // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
122 // { kEventClassControl , kEventControlBoundsChanged } ,
125 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
127 OSStatus result
= eventNotHandledErr
;
128 static wxWindowMac
* targetFocusWindow
= NULL
;
129 static wxWindowMac
* formerFocusWindow
= NULL
;
131 wxMacCarbonEvent
cEvent( event
) ;
133 ControlRef controlRef
;
134 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
136 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
138 switch ( GetEventKind( event
) )
140 case kEventControlDraw
:
142 HIShapeRef updateRgn
= NULL
;
143 HIMutableShapeRef allocatedRgn
= NULL
;
144 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
146 // according to the docs: redraw entire control if param not present
147 if ( cEvent
.GetParameter
<HIShapeRef
>(kEventParamShape
, &updateRgn
) != noErr
)
149 updateRgn
= visRegion
.GetWXHRGN();
153 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
155 // as this update region is in native window locals we must adapt it to wx window local
156 allocatedRgn
= HIShapeCreateMutableCopy(updateRgn
);
157 HIShapeOffset(allocatedRgn
, thisWindow
->MacGetLeftBorderSize() , thisWindow
->MacGetTopBorderSize());
158 // hide the given region by the new region that must be shifted
159 updateRgn
= allocatedRgn
;
163 #if wxMAC_DEBUG_REDRAW
164 if ( thisWindow
->MacIsUserPane() )
166 static float color
= 0.5 ;
167 static int channel
= 0 ;
169 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
171 HIViewGetBounds( controlRef
, &bounds
);
172 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
173 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
174 CGContextFillRect( cgContext
, bounds
);
187 bool created
= false ;
188 CGContextRef cgContext
= NULL
;
189 OSStatus err
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, &cgContext
) ;
192 wxFAIL_MSG("Unable to retrieve CGContextRef");
195 thisWindow
->MacSetCGContextRef( cgContext
) ;
198 wxMacCGContextStateSaver
sg( cgContext
) ;
199 CGFloat alpha
= (CGFloat
)1.0 ;
201 wxWindow
* iter
= thisWindow
;
204 alpha
*= (CGFloat
)( iter
->GetTransparent()/255.0 ) ;
205 if ( iter
->IsTopLevel() )
208 iter
= iter
->GetParent() ;
211 CGContextSetAlpha( cgContext
, alpha
) ;
213 if ( thisWindow
->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT
)
216 HIViewGetBounds( controlRef
, &bounds
);
217 CGContextClearRect( cgContext
, bounds
);
220 if ( !HIShapeIsEmpty(updateRgn
) )
222 // refcount increase because wxRegion constructor takes ownership of the native region
224 thisWindow
->GetUpdateRegion() = wxRegion(updateRgn
);
225 if ( !thisWindow
->MacDoRedraw( cEvent
.GetTicks() ) )
227 // for native controls: call their native paint method
228 if ( !thisWindow
->MacIsUserPane() ||
229 ( thisWindow
->IsTopLevel() && thisWindow
->GetBackgroundStyle() == wxBG_STYLE_SYSTEM
) )
231 if ( thisWindow
->GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT
)
232 CallNextEventHandler( handler
,event
) ;
235 thisWindow
->MacPaintChildrenBorders();
237 thisWindow
->MacSetCGContextRef( NULL
) ;
241 CGContextRelease( cgContext
) ;
245 CFRelease( allocatedRgn
) ;
249 case kEventControlVisibilityChanged
:
250 // we might have two native controls attributed to the same wxWindow instance
251 // eg a scrollview and an embedded textview, make sure we only fire for the 'outer'
252 // control, as otherwise native and wx visibility are different
253 if ( thisWindow
->GetPeer() != NULL
&& thisWindow
->GetPeer()->GetControlRef() == controlRef
)
255 thisWindow
->MacVisibilityChanged() ;
259 case kEventControlEnabledStateChanged
:
260 thisWindow
->MacEnabledStateChanged();
263 case kEventControlHiliteChanged
:
264 thisWindow
->MacHiliteChanged() ;
267 case kEventControlActivate
:
268 case kEventControlDeactivate
:
269 // FIXME: we should have a virtual function for this!
271 if ( thisWindow
->IsKindOf( CLASSINFO( wxTreeCtrl
) ) )
272 thisWindow
->Refresh();
275 if ( thisWindow
->IsKindOf( CLASSINFO( wxListCtrl
) ) )
276 thisWindow
->Refresh();
282 // different handling on OS X
285 case kEventControlFocusPartChanged
:
286 // the event is emulated by wxmac for systems lower than 10.5
288 if ( UMAGetSystemVersion() < 0x1050 )
290 // as it is synthesized here, we have to manually avoid propagation
293 ControlPartCode previousControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPreviousPart
, typeControlPartCode
);
294 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlCurrentPart
, typeControlPartCode
);
296 if ( thisWindow
->MacGetTopLevelWindow() && thisWindow
->GetPeer()->NeedsFocusRect() )
298 thisWindow
->MacInvalidateBorders();
301 if ( currentControlPart
== 0 )
305 if ( thisWindow
->GetCaret() )
306 thisWindow
->GetCaret()->OnKillFocus();
309 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast<void*>(thisWindow
));
311 // remove this as soon as posting the synthesized event works properly
312 static bool inKillFocusEvent
= false ;
314 if ( !inKillFocusEvent
)
316 inKillFocusEvent
= true ;
317 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
318 event
.SetEventObject(thisWindow
);
319 event
.SetWindow(targetFocusWindow
);
320 thisWindow
->HandleWindowEvent(event
) ;
321 inKillFocusEvent
= false ;
322 targetFocusWindow
= NULL
;
325 else if ( previousControlPart
== 0 )
328 // panel wants to track the window which was the last to have focus in it
329 wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast<void*>(thisWindow
));
330 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
331 thisWindow
->HandleWindowEvent(eventFocus
);
334 if ( thisWindow
->GetCaret() )
335 thisWindow
->GetCaret()->OnSetFocus();
338 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
339 event
.SetEventObject(thisWindow
);
340 event
.SetWindow(formerFocusWindow
);
341 thisWindow
->HandleWindowEvent(event
) ;
342 formerFocusWindow
= NULL
;
346 case kEventControlSetFocusPart
:
348 Boolean focusEverything
= false ;
349 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
351 // put a breakpoint here to catch focus everything events
353 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
354 if ( controlPart
!= kControlFocusNoPart
)
356 targetFocusWindow
= thisWindow
;
357 wxLogTrace(_T("Focus"), _T("focus to be set(%p)"), static_cast<void*>(thisWindow
));
361 formerFocusWindow
= thisWindow
;
362 wxLogTrace(_T("Focus"), _T("focus to be lost(%p)"), static_cast<void*>(thisWindow
));
365 ControlPartCode previousControlPart
= 0;
366 verify_noerr( HIViewGetFocusPart(controlRef
, &previousControlPart
));
368 if ( thisWindow
->MacIsUserPane() )
370 if ( controlPart
!= kControlFocusNoPart
)
371 cEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPart
, typeControlPartCode
, 1 ) ;
375 result
= CallNextEventHandler(handler
, event
);
377 if ( UMAGetSystemVersion() < 0x1050 )
379 // set back to 0 if problems arise
381 if ( result
== noErr
)
383 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
384 // synthesize the event focus changed event
385 EventRef evRef
= NULL
;
387 OSStatus err
= MacCreateEvent(
388 NULL
, kEventClassControl
, kEventControlFocusPartChanged
, TicksToEventTime( TickCount() ) ,
389 kEventAttributeUserEvent
, &evRef
);
392 wxMacCarbonEvent
iEvent( evRef
) ;
393 iEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, controlRef
);
394 iEvent
.SetParameter
<EventTargetRef
>( kEventParamPostTarget
, typeEventTargetRef
, GetControlEventTarget( controlRef
) );
395 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPreviousPart
, typeControlPartCode
, previousControlPart
);
396 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlCurrentPart
, typeControlPartCode
, currentControlPart
);
399 // TODO test this first, avoid double posts etc...
400 PostEventToQueue( GetMainEventQueue(), evRef
, kEventPriorityHigh
);
402 wxMacWindowControlEventHandler( NULL
, evRef
, data
) ;
404 ReleaseEvent( evRef
) ;
407 // old implementation, to be removed if the new one works
408 if ( controlPart
== kControlFocusNoPart
)
411 if ( thisWindow
->GetCaret() )
412 thisWindow
->GetCaret()->OnKillFocus();
415 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast<void*>(thisWindow
));
417 static bool inKillFocusEvent
= false ;
419 if ( !inKillFocusEvent
)
421 inKillFocusEvent
= true ;
422 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
423 event
.SetEventObject(thisWindow
);
424 thisWindow
->HandleWindowEvent(event
) ;
425 inKillFocusEvent
= false ;
430 // panel wants to track the window which was the last to have focus in it
431 wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast<void*>(thisWindow
));
432 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
433 thisWindow
->HandleWindowEvent(eventFocus
);
436 if ( thisWindow
->GetCaret() )
437 thisWindow
->GetCaret()->OnSetFocus();
440 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
441 event
.SetEventObject(thisWindow
);
442 thisWindow
->HandleWindowEvent(event
) ;
449 case kEventControlHit
:
450 result
= thisWindow
->MacControlHit( handler
, event
) ;
453 case kEventControlGetClickActivation
:
455 // fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise)
456 WindowRef owner
= cEvent
.GetParameter
<WindowRef
>(kEventParamWindowRef
);
457 if ( !IsWindowActive(owner
) )
459 cEvent
.SetParameter(kEventParamClickActivation
,typeClickActivationResult
, (UInt32
) kActivateAndIgnoreClick
) ;
472 static pascal OSStatus
473 wxMacWindowServiceEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
477 OSStatus result
= eventNotHandledErr
;
479 wxMacCarbonEvent
cEvent( event
) ;
481 ControlRef controlRef
;
482 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
483 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
484 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
486 switch ( GetEventKind( event
) )
488 case kEventServiceGetTypes
:
492 textCtrl
->GetSelection( &from
, &to
) ;
494 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
496 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
497 if ( textCtrl
->IsEditable() )
498 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
500 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt', 'PICT', 'MooV', 'AIFF' */ };
501 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
503 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
507 CFArrayAppendValue(copyTypes
, typestring
) ;
509 CFArrayAppendValue(pasteTypes
, typestring
) ;
511 CFRelease( typestring
) ;
519 case kEventServiceCopy
:
524 textCtrl
->GetSelection( &from
, &to
) ;
525 wxString val
= textCtrl
->GetValue() ;
526 val
= val
.Mid( from
, to
- from
) ;
527 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
528 verify_noerr( PasteboardClear( pasteboard
) ) ;
529 PasteboardSynchronize( pasteboard
);
530 // TODO add proper conversion
531 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (const UInt8
*)val
.c_str(), val
.length() );
532 PasteboardPutItemFlavor( pasteboard
, (PasteboardItemID
) 1, CFSTR("com.apple.traditional-mac-plain-text"), data
, 0);
538 case kEventServicePaste
:
541 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
542 PasteboardSynchronize( pasteboard
);
544 verify_noerr( PasteboardGetItemCount( pasteboard
, &itemCount
) );
545 for( UInt32 itemIndex
= 1; itemIndex
<= itemCount
; itemIndex
++ )
547 PasteboardItemID itemID
;
548 if ( PasteboardGetItemIdentifier( pasteboard
, itemIndex
, &itemID
) == noErr
)
550 CFDataRef flavorData
= NULL
;
551 if ( PasteboardCopyItemFlavorData( pasteboard
, itemID
, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData
) == noErr
)
553 CFIndex flavorDataSize
= CFDataGetLength( flavorData
);
554 char *content
= new char[flavorDataSize
+1] ;
555 memcpy( content
, CFDataGetBytePtr( flavorData
), flavorDataSize
);
556 content
[flavorDataSize
]=0;
557 CFRelease( flavorData
);
559 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
561 textCtrl
->WriteText( wxString( content
) ) ;
579 pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
581 OSStatus result
= eventNotHandledErr
;
582 wxWindowMac
* focus
= (wxWindowMac
*) data
;
584 wchar_t* uniChars
= NULL
;
585 UInt32 when
= EventTimeToTicks( GetEventTime( event
) ) ;
587 UniChar
* charBuf
= NULL
;
588 ByteCount dataSize
= 0 ;
591 if ( GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, 0 , &dataSize
, NULL
) == noErr
)
593 numChars
= dataSize
/ sizeof( UniChar
) + 1;
596 if ( (size_t) numChars
* 2 > sizeof(buf
) )
597 charBuf
= new UniChar
[ numChars
] ;
601 uniChars
= new wchar_t[ numChars
] ;
602 GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, dataSize
, NULL
, charBuf
) ;
603 charBuf
[ numChars
- 1 ] = 0;
604 #if SIZEOF_WCHAR_T == 2
605 uniChars
= (wchar_t*) charBuf
;
606 /* memcpy( uniChars , charBuf , numChars * 2 ) ;*/ // is there any point in copying charBuf over itself? (in fact, memcpy isn't even guaranteed to work correctly if the source and destination ranges overlap...)
608 // the resulting string will never have more chars than the utf16 version, so this is safe
609 wxMBConvUTF16 converter
;
610 numChars
= converter
.MB2WC( uniChars
, (const char*)charBuf
, numChars
) ;
614 switch ( GetEventKind( event
) )
616 case kEventTextInputUpdateActiveInputArea
:
618 // An IME input event may return several characters, but we need to send one char at a time to
620 for (int pos
=0 ; pos
< numChars
; pos
++)
622 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
623 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
624 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
626 UInt32 message
= uniChars
[pos
] < 128 ? (char)uniChars
[pos
] : '?';
628 NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent
629 multiple times to update the active range during inline input, so this handler will often receive
630 uncommited text, which should usually not trigger side effects. It might be a good idea to check the
631 kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h).
632 On the other hand, it can be useful for some applications to react to uncommitted text (for example,
633 to update a status display), as long as it does not disrupt the inline input session. Ideally, wx
634 should add new event types to support advanced text input. For now, I would keep things as they are.
636 However, the code that was being used caused additional problems:
637 UInt32 message = (0 << 8) + ((char)uniChars[pos] );
638 Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline
639 input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji
640 for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB
641 (still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D
642 (the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress.
643 Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only
644 overlap with Unicode within the (7-bit) ASCII range.
645 But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks
646 for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII
647 characters as they are and replaces the rest with '?', ensuring that update events are triggered.
648 It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but
649 I don't have time to look into that right now.
652 if ( wxTheApp
->MacSendCharEvent(
653 focus
, message
, 0 , when
, 0 , 0 , uniChars
[pos
] ) )
658 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
662 case kEventTextInputUnicodeForKeyEvent
:
664 UInt32 keyCode
, modifiers
;
667 unsigned char charCode
;
669 GetEventParameter( event
, kEventParamTextInputSendKeyboardEvent
, typeEventRef
, NULL
, sizeof(rawEvent
), NULL
, &rawEvent
) ;
670 GetEventParameter( rawEvent
, kEventParamKeyMacCharCodes
, typeChar
, NULL
, sizeof(char), NULL
, &charCode
);
671 GetEventParameter( rawEvent
, kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
672 GetEventParameter( rawEvent
, kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
673 GetEventParameter( rawEvent
, kEventParamMouseLocation
, typeQDPoint
, NULL
, sizeof(Point
), NULL
, &point
);
675 UInt32 message
= (keyCode
<< 8) + charCode
;
677 // An IME input event may return several characters, but we need to send one char at a time to
679 for (int pos
=0 ; pos
< numChars
; pos
++)
681 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
682 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
683 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
685 if ( wxTheApp
->MacSendCharEvent(
686 focus
, message
, modifiers
, when
, point
.h
, point
.v
, uniChars
[pos
] ) )
691 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
700 if ( charBuf
!= buf
)
706 static pascal OSStatus
707 wxMacWindowCommandEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
711 OSStatus result
= eventNotHandledErr
;
712 wxWindowMac
* focus
= (wxWindowMac
*) data
;
716 wxMacCarbonEvent
cEvent( event
) ;
717 cEvent
.GetParameter
<HICommand
>(kEventParamDirectObject
,typeHICommand
,&command
) ;
719 wxMenuItem
* item
= NULL
;
720 wxMenu
* itemMenu
= wxFindMenuFromMacCommand( command
, item
) ;
724 wxASSERT( itemMenu
!= NULL
) ;
726 switch ( cEvent
.GetKind() )
728 case kEventProcessCommand
:
729 if ( itemMenu
->HandleCommandProcess( item
, focus
) )
733 case kEventCommandUpdateStatus
:
734 if ( itemMenu
->HandleCommandUpdateStatus( item
, focus
) )
745 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
747 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
748 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
749 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
750 OSStatus result
= eventNotHandledErr
;
752 switch ( GetEventClass( event
) )
754 case kEventClassCommand
:
755 result
= wxMacWindowCommandEventHandler( handler
, event
, data
) ;
758 case kEventClassControl
:
759 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
762 case kEventClassService
:
763 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
766 case kEventClassTextInput
:
767 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
774 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
779 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
781 // ---------------------------------------------------------------------------
782 // Scrollbar Tracking for all
783 // ---------------------------------------------------------------------------
785 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
786 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
790 wxWindow
* wx
= wxFindWindowFromWXWidget( (WXWidget
) control
) ;
793 wxEventType scrollEvent
= wxEVT_NULL
;
796 case kControlUpButtonPart
:
797 scrollEvent
= wxEVT_SCROLL_LINEUP
;
800 case kControlDownButtonPart
:
801 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
804 case kControlPageUpPart
:
805 scrollEvent
= wxEVT_SCROLL_PAGEUP
;
808 case kControlPageDownPart
:
809 scrollEvent
= wxEVT_SCROLL_PAGEDOWN
;
812 case kControlIndicatorPart
:
813 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
814 // when this is called as a live proc, mouse is always still down
815 // so no need for thumbrelease
816 // scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
819 wx
->TriggerScrollEvent(scrollEvent
) ;
823 wxMAC_DEFINE_PROC_GETTER( ControlActionUPP
, wxMacLiveScrollbarActionProc
) ;
825 wxWidgetImplType
* wxWidgetImpl::CreateUserPane( wxWindowMac
* wxpeer
, wxWindowMac
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
826 long style
, long extraStyle
)
828 OSStatus err
= noErr
;
829 Rect bounds
= wxMacGetBoundsForControl( wxpeer
, pos
, size
) ;
830 wxMacControl
* c
= new wxMacControl(wxpeer
) ;
832 | kControlSupportsEmbedding
833 | kControlSupportsLiveFeedback
834 | kControlGetsFocusOnClick
835 // | kControlHasSpecialBackground
836 // | kControlSupportsCalcBestRect
837 | kControlHandlesTracking
838 | kControlSupportsFocus
839 | kControlWantsActivate
840 | kControlWantsIdle
;
842 err
=::CreateUserPaneControl( MAC_WXHWND(wxpeer
->GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, c
->GetControlRefAddr() );
848 void wxMacControl::InstallEventHandler( WXWidget control
)
850 wxWidgetImpl::Associate( control
? control
: (WXWidget
) m_controlRef
, this ) ;
851 ::InstallControlEventHandler( control
? (ControlRef
) control
: m_controlRef
, GetwxMacWindowEventHandlerUPP(),
852 GetEventTypeCount(eventList
), eventList
, GetWXPeer(), NULL
);
855 IMPLEMENT_DYNAMIC_CLASS( wxMacControl
, wxWidgetImpl
)
857 wxMacControl::wxMacControl()
862 wxMacControl::wxMacControl(wxWindowMac
* peer
, bool isRootControl
) :
863 wxWidgetImpl( peer
, isRootControl
)
868 wxMacControl::~wxMacControl()
870 if ( m_controlRef
&& !IsRootControl() )
872 wxASSERT_MSG( m_controlRef
!= NULL
, wxT("Control Handle already NULL, Dispose called twice ?") );
873 wxASSERT_MSG( IsValidControlHandle(m_controlRef
) , wxT("Invalid Control Handle (maybe already released) in Dispose") );
875 wxWidgetImpl::RemoveAssociations( this ) ;
876 // we cannot check the ref count here anymore, as autorelease objects might delete their refs later
877 // we can have situations when being embedded, where the control gets deleted behind our back, so only
878 // CFRelease if we are safe
879 if ( IsValidControlHandle(m_controlRef
) )
880 CFRelease(m_controlRef
);
885 void wxMacControl::Init()
888 m_macControlEventHandler
= NULL
;
891 void wxMacControl::RemoveFromParent()
893 // nothing to do here for carbon
894 HIViewRemoveFromSuperview(m_controlRef
);
897 void wxMacControl::Embed( wxWidgetImpl
*parent
)
899 HIViewAddSubview((ControlRef
)parent
->GetWXWidget(), m_controlRef
);
902 void wxMacControl::SetNeedsDisplay( const wxRect
* rect
)
909 HIRect updatearea
= CGRectMake( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
910 HIViewSetNeedsDisplayInRect( m_controlRef
, &updatearea
, true );
913 HIViewSetNeedsDisplay( m_controlRef
, true );
916 void wxMacControl::Raise()
918 verify_noerr( HIViewSetZOrder( m_controlRef
, kHIViewZOrderAbove
, NULL
) );
921 void wxMacControl::Lower()
923 verify_noerr( HIViewSetZOrder( m_controlRef
, kHIViewZOrderBelow
, NULL
) );
926 void wxMacControl::GetContentArea(int &left
, int &top
, int &width
, int &height
) const
928 HIShapeRef rgn
= NULL
;
931 if ( HIViewCopyShape(m_controlRef
, kHIViewContentMetaPart
, &rgn
) == noErr
)
934 HIShapeGetBounds(rgn
, &cgrect
);
935 content
= (Rect
){ cgrect
.origin
.y
, cgrect
.origin
.x
, cgrect
.origin
.y
+cgrect
.size
.height
, cgrect
.origin
.x
+cgrect
.size
.width
};
940 GetControlBounds(m_controlRef
, &content
);
941 content
.right
-= content
.left
;
943 content
.bottom
-= content
.top
;
950 width
= content
.right
- content
.left
;
951 height
= content
.bottom
- content
.top
;
954 void wxMacControl::Move(int x
, int y
, int width
, int height
)
956 HIRect hir
= CGRectMake(x
,y
,width
,height
);
957 HIViewSetFrame ( m_controlRef
, &hir
);
960 void wxMacControl::GetPosition( int &x
, int &y
) const
963 GetControlBounds( m_controlRef
, &r
);
968 void wxMacControl::GetSize( int &width
, int &height
) const
971 GetControlBounds( m_controlRef
, &r
);
972 width
= r
.right
- r
.left
;
973 height
= r
.bottom
- r
.top
;
976 void wxMacControl::SetControlSize( wxWindowVariant variant
)
981 case wxWINDOW_VARIANT_NORMAL
:
982 size
= kControlSizeNormal
;
985 case wxWINDOW_VARIANT_SMALL
:
986 size
= kControlSizeSmall
;
989 case wxWINDOW_VARIANT_MINI
:
990 // not always defined in the headers
994 case wxWINDOW_VARIANT_LARGE
:
995 size
= kControlSizeLarge
;
999 wxFAIL_MSG(_T("unexpected window variant"));
1003 SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
, &size
) ;
1006 void wxMacControl::ScrollRect( const wxRect
*rect
, int dx
, int dy
)
1008 if (GetNeedsDisplay() )
1010 // because HIViewScrollRect does not scroll the already invalidated area we have two options:
1011 // in case there is already a pending redraw on that area
1012 // either immediate redraw or full invalidate
1014 // is the better overall solution, as it does not slow down scrolling
1017 // this would be the preferred version for fast drawing controls
1018 HIViewRender(GetControlRef()) ;
1022 // note there currently is a bug in OSX (10.3 +?) which makes inefficient refreshes in case an entire control
1023 // area is scrolled, this does not occur if width and height are 2 pixels less,
1024 // TODO: write optimal workaround
1026 HIRect scrollarea
= CGRectMake( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1027 HIViewScrollRect ( m_controlRef
, &scrollarea
, dx
,dy
);
1030 // this would be the preferred version for fast drawing controls
1031 HIViewRender(GetControlRef()) ;
1035 bool wxMacControl::CanFocus() const
1037 // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
1038 // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning,
1039 // but the value range is nowhere documented
1040 Boolean keyExistsAndHasValidFormat
;
1041 CFIndex fullKeyboardAccess
= CFPreferencesGetAppIntegerValue( CFSTR("AppleKeyboardUIMode" ) ,
1042 kCFPreferencesCurrentApplication
, &keyExistsAndHasValidFormat
);
1044 if ( keyExistsAndHasValidFormat
&& fullKeyboardAccess
> 0 )
1050 UInt32 features
= 0 ;
1051 GetControlFeatures( m_controlRef
, &features
) ;
1053 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
1057 bool wxMacControl::GetNeedsDisplay() const
1059 return HIViewGetNeedsDisplay( m_controlRef
);
1062 void wxWidgetImpl::Convert( wxPoint
*pt
, wxWidgetImpl
*from
, wxWidgetImpl
*to
)
1068 HIViewConvertPoint( &hiPoint
, (ControlRef
) from
->GetWXWidget() , (ControlRef
) to
->GetWXWidget() );
1069 pt
->x
= (int)hiPoint
.x
;
1070 pt
->y
= (int)hiPoint
.y
;
1073 bool wxMacControl::SetFocus()
1075 // as we cannot rely on the control features to find out whether we are in full keyboard mode,
1076 // we can only leave in case of an error
1078 OSStatus err
= SetKeyboardFocus( GetControlOwner( m_controlRef
), m_controlRef
, kControlFocusNextPart
);
1079 if ( err
== errCouldntSetFocus
)
1081 SetUserFocusWindow(GetControlOwner( m_controlRef
) );
1086 bool wxMacControl::HasFocus() const
1089 GetKeyboardFocus( GetUserFocusWindow() , &control
);
1090 return control
== m_controlRef
;
1093 void wxMacControl::SetCursor(const wxCursor
& cursor
)
1095 wxWindowMac
*mouseWin
= 0 ;
1096 WindowRef window
= GetControlOwner( m_controlRef
) ;
1098 wxNonOwnedWindow
* tlwwx
= wxNonOwnedWindow::GetFromWXWindow( (WXWindow
) window
) ;
1099 if ( tlwwx
!= NULL
)
1101 ControlPartCode part
;
1102 ControlRef control
;
1104 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
1106 HIGetMousePosition(kHICoordSpaceWindow
, window
, &hiPoint
);
1110 GetGlobalMouse( &pt
);
1113 tlwwx
->ScreenToClient(&x
, &y
);
1117 control
= FindControlUnderMouse( pt
, window
, &part
) ;
1119 mouseWin
= wxFindWindowFromWXWidget( (WXWidget
) control
) ;
1122 if ( mouseWin
== tlwwx
&& !wxIsBusy() )
1123 cursor
.MacInstall() ;
1126 void wxMacControl::CaptureMouse()
1130 void wxMacControl::ReleaseMouse()
1135 // subclass specifics
1138 OSStatus
wxMacControl::GetData(ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const
1140 return ::GetControlData( m_controlRef
, inPartCode
, inTag
, inBufferSize
, inOutBuffer
, outActualSize
);
1143 OSStatus
wxMacControl::GetDataSize(ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const
1145 return ::GetControlDataSize( m_controlRef
, inPartCode
, inTag
, outActualSize
);
1148 OSStatus
wxMacControl::SetData(ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
)
1150 return ::SetControlData( m_controlRef
, inPartCode
, inTag
, inSize
, inData
);
1153 OSStatus
wxMacControl::SendEvent( EventRef event
, OptionBits inOptions
)
1155 return SendEventToEventTargetWithOptions( event
,
1156 HIObjectGetEventTarget( (HIObjectRef
) m_controlRef
), inOptions
);
1159 OSStatus
wxMacControl::SendHICommand( HICommand
&command
, OptionBits inOptions
)
1161 wxMacCarbonEvent
event( kEventClassCommand
, kEventCommandProcess
);
1163 event
.SetParameter
<HICommand
>(kEventParamDirectObject
,command
);
1165 return SendEvent( event
, inOptions
);
1168 OSStatus
wxMacControl::SendHICommand( UInt32 commandID
, OptionBits inOptions
)
1172 memset( &command
, 0 , sizeof(command
) );
1173 command
.commandID
= commandID
;
1174 return SendHICommand( command
, inOptions
);
1177 void wxMacControl::PerformClick()
1179 HIViewSimulateClick (m_controlRef
, kControlButtonPart
, 0, NULL
);
1182 wxInt32
wxMacControl::GetValue() const
1184 return ::GetControl32BitValue( m_controlRef
);
1187 wxInt32
wxMacControl::GetMaximum() const
1189 return ::GetControl32BitMaximum( m_controlRef
);
1192 wxInt32
wxMacControl::GetMinimum() const
1194 return ::GetControl32BitMinimum( m_controlRef
);
1197 void wxMacControl::SetValue( wxInt32 v
)
1199 ::SetControl32BitValue( m_controlRef
, v
);
1202 void wxMacControl::SetMinimum( wxInt32 v
)
1204 ::SetControl32BitMinimum( m_controlRef
, v
);
1207 void wxMacControl::SetMaximum( wxInt32 v
)
1209 ::SetControl32BitMaximum( m_controlRef
, v
);
1212 void wxMacControl::SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
)
1214 ::SetControl32BitMinimum( m_controlRef
, minimum
);
1215 ::SetControl32BitMaximum( m_controlRef
, maximum
);
1216 ::SetControl32BitValue( m_controlRef
, value
);
1219 void wxMacControl::VisibilityChanged(bool WXUNUSED(shown
))
1223 void wxMacControl::SuperChangedPosition()
1227 void wxMacControl::SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
)
1230 #if wxOSX_USE_CORE_TEXT
1231 if ( UMAGetSystemVersion() >= 0x1050 )
1233 HIViewPartCode part
= 0;
1234 HIThemeTextHorizontalFlush flush
= kHIThemeTextHorizontalFlushDefault
;
1235 if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_CENTER_HORIZONTAL
)
1236 flush
= kHIThemeTextHorizontalFlushCenter
;
1237 else if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_RIGHT
)
1238 flush
= kHIThemeTextHorizontalFlushRight
;
1239 HIViewSetTextFont( m_controlRef
, part
, (CTFontRef
) font
.OSXGetCTFont() );
1240 HIViewSetTextHorizontalFlush( m_controlRef
, part
, flush
);
1242 if ( foreground
!= *wxBLACK
|| ignoreBlack
== false )
1244 ControlFontStyleRec fontStyle
;
1245 foreground
.GetRGBColor( &fontStyle
.foreColor
);
1246 fontStyle
.flags
= kControlUseForeColorMask
;
1247 ::SetControlFontStyle( m_controlRef
, &fontStyle
);
1251 #if wxOSX_USE_ATSU_TEXT
1252 ControlFontStyleRec fontStyle
;
1253 if ( font
.MacGetThemeFontID() != kThemeCurrentPortFont
)
1255 switch ( font
.MacGetThemeFontID() )
1257 case kThemeSmallSystemFont
:
1258 fontStyle
.font
= kControlFontSmallSystemFont
;
1261 case 109 : // mini font
1262 fontStyle
.font
= -5;
1265 case kThemeSystemFont
:
1266 fontStyle
.font
= kControlFontBigSystemFont
;
1270 fontStyle
.font
= kControlFontBigSystemFont
;
1274 fontStyle
.flags
= kControlUseFontMask
;
1278 fontStyle
.font
= font
.MacGetFontNum();
1279 fontStyle
.style
= font
.MacGetFontStyle();
1280 fontStyle
.size
= font
.GetPointSize();
1281 fontStyle
.flags
= kControlUseFontMask
| kControlUseFaceMask
| kControlUseSizeMask
;
1284 fontStyle
.just
= teJustLeft
;
1285 fontStyle
.flags
|= kControlUseJustMask
;
1286 if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_CENTER_HORIZONTAL
)
1287 fontStyle
.just
= teJustCenter
;
1288 else if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_RIGHT
)
1289 fontStyle
.just
= teJustRight
;
1292 // we only should do this in case of a non-standard color, as otherwise 'disabled' controls
1293 // won't get grayed out by the system anymore
1295 if ( foreground
!= *wxBLACK
|| ignoreBlack
== false )
1297 foreground
.GetRGBColor( &fontStyle
.foreColor
);
1298 fontStyle
.flags
|= kControlUseForeColorMask
;
1301 ::SetControlFontStyle( m_controlRef
, &fontStyle
);
1305 void wxMacControl::SetBackgroundColour( const wxColour
&WXUNUSED(col
) )
1307 // HITextViewSetBackgroundColor( m_textView , color );
1310 void wxMacControl::SetRange( SInt32 minimum
, SInt32 maximum
)
1312 ::SetControl32BitMinimum( m_controlRef
, minimum
);
1313 ::SetControl32BitMaximum( m_controlRef
, maximum
);
1316 short wxMacControl::HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
)
1318 return HandleControlKey( m_controlRef
, keyCode
, charCode
, modifiers
);
1321 void wxMacControl::SetActionProc( ControlActionUPP actionProc
)
1323 SetControlAction( m_controlRef
, actionProc
);
1326 SInt32
wxMacControl::GetViewSize() const
1328 return GetControlViewSize( m_controlRef
);
1331 bool wxMacControl::IsVisible() const
1333 return IsControlVisible( m_controlRef
);
1336 void wxMacControl::SetVisibility( bool visible
)
1338 SetControlVisibility( m_controlRef
, visible
, true );
1341 bool wxMacControl::IsEnabled() const
1343 return IsControlEnabled( m_controlRef
);
1346 bool wxMacControl::IsActive() const
1348 return IsControlActive( m_controlRef
);
1351 void wxMacControl::Enable( bool enable
)
1354 EnableControl( m_controlRef
);
1356 DisableControl( m_controlRef
);
1359 void wxMacControl::SetDrawingEnabled( bool enable
)
1361 HIViewSetDrawingEnabled( m_controlRef
, enable
);
1364 void wxMacControl::GetRectInWindowCoords( Rect
*r
)
1366 GetControlBounds( m_controlRef
, r
) ;
1368 WindowRef tlwref
= GetControlOwner( m_controlRef
) ;
1370 wxNonOwnedWindow
* tlwwx
= wxNonOwnedWindow::GetFromWXWindow( (WXWindow
) tlwref
) ;
1371 if ( tlwwx
!= NULL
)
1373 ControlRef rootControl
= tlwwx
->GetPeer()->GetControlRef() ;
1374 HIPoint hiPoint
= CGPointMake( 0 , 0 ) ;
1375 HIViewConvertPoint( &hiPoint
, HIViewGetSuperview(m_controlRef
) , rootControl
) ;
1376 OffsetRect( r
, (short) hiPoint
.x
, (short) hiPoint
.y
) ;
1380 void wxMacControl::GetBestRect( wxRect
*rect
) const
1382 short baselineoffset
;
1385 GetBestControlRect( m_controlRef
, &r
, &baselineoffset
);
1386 *rect
= wxRect( r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
-r
.top
);
1389 void wxMacControl::GetBestRect( Rect
*r
) const
1391 short baselineoffset
;
1392 GetBestControlRect( m_controlRef
, r
, &baselineoffset
);
1395 void wxMacControl::SetLabel( const wxString
&title
, wxFontEncoding encoding
)
1397 SetControlTitleWithCFString( m_controlRef
, wxCFStringRef( title
, encoding
) );
1400 void wxMacControl::GetFeatures( UInt32
* features
)
1402 GetControlFeatures( m_controlRef
, features
);
1405 void wxMacControl::PulseGauge()
1409 // SetNeedsDisplay would not invalidate the children
1410 static void InvalidateControlAndChildren( HIViewRef control
)
1412 HIViewSetNeedsDisplay( control
, true );
1413 UInt16 childrenCount
= 0;
1414 OSStatus err
= CountSubControls( control
, &childrenCount
);
1415 if ( err
== errControlIsNotEmbedder
)
1418 wxASSERT_MSG( err
== noErr
, wxT("Unexpected error when accessing subcontrols") );
1420 for ( UInt16 i
= childrenCount
; i
>=1; --i
)
1424 err
= GetIndexedSubControl( control
, i
, & child
);
1425 if ( err
== errControlIsNotEmbedder
)
1428 InvalidateControlAndChildren( child
);
1432 void wxMacControl::InvalidateWithChildren()
1434 InvalidateControlAndChildren( m_controlRef
);
1437 OSType wxMacCreator
= 'WXMC';
1438 OSType wxMacControlProperty
= 'MCCT';
1440 void wxMacControl::SetReferenceInNativeControl()
1443 verify_noerr( SetControlProperty ( m_controlRef
,
1444 wxMacCreator
,wxMacControlProperty
, sizeof(data
), &data
) );
1447 wxMacControl
* wxMacControl::GetReferenceFromNativeControl(ControlRef control
)
1449 wxMacControl
* ctl
= NULL
;
1450 ByteCount actualSize
;
1451 if ( GetControlProperty( control
,wxMacCreator
,wxMacControlProperty
, sizeof(ctl
) ,
1452 &actualSize
, &ctl
) == noErr
)
1459 void wxMacControl::SetBitmap( const wxBitmap
& WXUNUSED(bmp
) )
1461 // implemented in the respective subclasses
1464 void wxMacControl::SetScrollThumb( wxInt32
WXUNUSED(pos
), wxInt32
WXUNUSED(viewsize
) )
1466 // implemented in respective subclass
1473 OSStatus
wxMacControl::SetTabEnabled( SInt16 tabNo
, bool enable
)
1475 return ::SetTabEnabled( m_controlRef
, tabNo
, enable
);
1482 wxWidgetImplType
* wxWidgetImpl::CreateContentView( wxNonOwnedWindow
* now
)
1484 // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
1485 // the content view, so we have to retrieve it explicitly
1487 wxMacControl
* contentview
= new wxMacControl(now
, true /*isRootControl*/);
1488 HIViewFindByID( HIViewGetRoot( (WindowRef
) now
->GetWXWindow() ) , kHIViewWindowContentID
,
1489 contentview
->GetControlRefAddr() ) ;
1490 if ( !contentview
->IsOk() )
1492 // compatibility mode fallback
1493 GetRootControl( (WindowRef
) now
->GetWXWindow() , contentview
->GetControlRefAddr() ) ;
1496 // the root control level handler
1497 contentview
->InstallEventHandler() ;