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 CGContextRef cgContext
= NULL
;
188 OSStatus err
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, &cgContext
) ;
191 wxFAIL_MSG("Unable to retrieve CGContextRef");
194 thisWindow
->MacSetCGContextRef( cgContext
) ;
197 wxMacCGContextStateSaver
sg( cgContext
) ;
198 CGFloat alpha
= (CGFloat
)1.0 ;
200 wxWindow
* iter
= thisWindow
;
203 alpha
*= (CGFloat
)( iter
->GetTransparent()/255.0 ) ;
204 if ( iter
->IsTopLevel() )
207 iter
= iter
->GetParent() ;
210 CGContextSetAlpha( cgContext
, alpha
) ;
212 if ( thisWindow
->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT
)
215 HIViewGetBounds( controlRef
, &bounds
);
216 CGContextClearRect( cgContext
, bounds
);
219 if ( !HIShapeIsEmpty(updateRgn
) )
221 // refcount increase because wxRegion constructor takes ownership of the native region
223 thisWindow
->GetUpdateRegion() = wxRegion(updateRgn
);
224 if ( !thisWindow
->MacDoRedraw( cEvent
.GetTicks() ) )
226 // for native controls: call their native paint method
227 if ( !thisWindow
->MacIsUserPane() ||
228 ( thisWindow
->IsTopLevel() && thisWindow
->GetBackgroundStyle() == wxBG_STYLE_SYSTEM
) )
230 if ( thisWindow
->GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT
)
232 CallNextEventHandler( handler
,event
) ;
241 thisWindow
->MacPaintChildrenBorders();
243 thisWindow
->MacSetCGContextRef( NULL
) ;
248 CFRelease( allocatedRgn
) ;
252 case kEventControlVisibilityChanged
:
253 // we might have two native controls attributed to the same wxWindow instance
254 // eg a scrollview and an embedded textview, make sure we only fire for the 'outer'
255 // control, as otherwise native and wx visibility are different
256 if ( thisWindow
->GetPeer() != NULL
&& thisWindow
->GetPeer()->GetControlRef() == controlRef
)
258 thisWindow
->MacVisibilityChanged() ;
262 case kEventControlEnabledStateChanged
:
263 thisWindow
->MacEnabledStateChanged();
266 case kEventControlHiliteChanged
:
267 thisWindow
->MacHiliteChanged() ;
270 case kEventControlActivate
:
271 case kEventControlDeactivate
:
272 // FIXME: we should have a virtual function for this!
274 if ( thisWindow
->IsKindOf( CLASSINFO( wxTreeCtrl
) ) )
275 thisWindow
->Refresh();
278 if ( thisWindow
->IsKindOf( CLASSINFO( wxListCtrl
) ) )
279 thisWindow
->Refresh();
285 // different handling on OS X
288 case kEventControlFocusPartChanged
:
289 // the event is emulated by wxmac for systems lower than 10.5
291 if ( UMAGetSystemVersion() < 0x1050 )
293 // as it is synthesized here, we have to manually avoid propagation
296 ControlPartCode previousControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPreviousPart
, typeControlPartCode
);
297 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlCurrentPart
, typeControlPartCode
);
299 if ( thisWindow
->MacGetTopLevelWindow() && thisWindow
->GetPeer()->NeedsFocusRect() )
301 thisWindow
->MacInvalidateBorders();
304 if ( currentControlPart
== 0 )
308 if ( thisWindow
->GetCaret() )
309 thisWindow
->GetCaret()->OnKillFocus();
312 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast<void*>(thisWindow
));
314 // remove this as soon as posting the synthesized event works properly
315 static bool inKillFocusEvent
= false ;
317 if ( !inKillFocusEvent
)
319 inKillFocusEvent
= true ;
320 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
321 event
.SetEventObject(thisWindow
);
322 event
.SetWindow(targetFocusWindow
);
323 thisWindow
->HandleWindowEvent(event
) ;
324 inKillFocusEvent
= false ;
325 targetFocusWindow
= NULL
;
328 else if ( previousControlPart
== 0 )
331 // panel wants to track the window which was the last to have focus in it
332 wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast<void*>(thisWindow
));
333 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
334 thisWindow
->HandleWindowEvent(eventFocus
);
337 if ( thisWindow
->GetCaret() )
338 thisWindow
->GetCaret()->OnSetFocus();
341 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
342 event
.SetEventObject(thisWindow
);
343 event
.SetWindow(formerFocusWindow
);
344 thisWindow
->HandleWindowEvent(event
) ;
345 formerFocusWindow
= NULL
;
349 case kEventControlSetFocusPart
:
351 Boolean focusEverything
= false ;
352 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
354 // put a breakpoint here to catch focus everything events
356 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
357 if ( controlPart
!= kControlFocusNoPart
)
359 targetFocusWindow
= thisWindow
;
360 wxLogTrace(_T("Focus"), _T("focus to be set(%p)"), static_cast<void*>(thisWindow
));
364 formerFocusWindow
= thisWindow
;
365 wxLogTrace(_T("Focus"), _T("focus to be lost(%p)"), static_cast<void*>(thisWindow
));
368 ControlPartCode previousControlPart
= 0;
369 verify_noerr( HIViewGetFocusPart(controlRef
, &previousControlPart
));
371 if ( thisWindow
->MacIsUserPane() )
373 if ( controlPart
!= kControlFocusNoPart
)
374 cEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPart
, typeControlPartCode
, 1 ) ;
378 result
= CallNextEventHandler(handler
, event
);
380 if ( UMAGetSystemVersion() < 0x1050 )
382 // set back to 0 if problems arise
384 if ( result
== noErr
)
386 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
387 // synthesize the event focus changed event
388 EventRef evRef
= NULL
;
390 OSStatus err
= MacCreateEvent(
391 NULL
, kEventClassControl
, kEventControlFocusPartChanged
, TicksToEventTime( TickCount() ) ,
392 kEventAttributeUserEvent
, &evRef
);
395 wxMacCarbonEvent
iEvent( evRef
) ;
396 iEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, controlRef
);
397 iEvent
.SetParameter
<EventTargetRef
>( kEventParamPostTarget
, typeEventTargetRef
, GetControlEventTarget( controlRef
) );
398 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPreviousPart
, typeControlPartCode
, previousControlPart
);
399 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlCurrentPart
, typeControlPartCode
, currentControlPart
);
402 // TODO test this first, avoid double posts etc...
403 PostEventToQueue( GetMainEventQueue(), evRef
, kEventPriorityHigh
);
405 wxMacWindowControlEventHandler( NULL
, evRef
, data
) ;
407 ReleaseEvent( evRef
) ;
410 // old implementation, to be removed if the new one works
411 if ( controlPart
== kControlFocusNoPart
)
414 if ( thisWindow
->GetCaret() )
415 thisWindow
->GetCaret()->OnKillFocus();
418 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast<void*>(thisWindow
));
420 static bool inKillFocusEvent
= false ;
422 if ( !inKillFocusEvent
)
424 inKillFocusEvent
= true ;
425 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
426 event
.SetEventObject(thisWindow
);
427 thisWindow
->HandleWindowEvent(event
) ;
428 inKillFocusEvent
= false ;
433 // panel wants to track the window which was the last to have focus in it
434 wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast<void*>(thisWindow
));
435 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
436 thisWindow
->HandleWindowEvent(eventFocus
);
439 if ( thisWindow
->GetCaret() )
440 thisWindow
->GetCaret()->OnSetFocus();
443 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
444 event
.SetEventObject(thisWindow
);
445 thisWindow
->HandleWindowEvent(event
) ;
452 case kEventControlHit
:
453 result
= thisWindow
->MacControlHit( handler
, event
) ;
456 case kEventControlGetClickActivation
:
458 // fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise)
459 WindowRef owner
= cEvent
.GetParameter
<WindowRef
>(kEventParamWindowRef
);
460 if ( !IsWindowActive(owner
) )
462 cEvent
.SetParameter(kEventParamClickActivation
,typeClickActivationResult
, (UInt32
) kActivateAndIgnoreClick
) ;
475 static pascal OSStatus
476 wxMacWindowServiceEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
480 OSStatus result
= eventNotHandledErr
;
482 wxMacCarbonEvent
cEvent( event
) ;
484 ControlRef controlRef
;
485 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
486 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
487 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
489 switch ( GetEventKind( event
) )
491 case kEventServiceGetTypes
:
495 textCtrl
->GetSelection( &from
, &to
) ;
497 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
499 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
500 if ( textCtrl
->IsEditable() )
501 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
503 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt', 'PICT', 'MooV', 'AIFF' */ };
504 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
506 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
510 CFArrayAppendValue(copyTypes
, typestring
) ;
512 CFArrayAppendValue(pasteTypes
, typestring
) ;
514 CFRelease( typestring
) ;
522 case kEventServiceCopy
:
527 textCtrl
->GetSelection( &from
, &to
) ;
528 wxString val
= textCtrl
->GetValue() ;
529 val
= val
.Mid( from
, to
- from
) ;
530 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
531 verify_noerr( PasteboardClear( pasteboard
) ) ;
532 PasteboardSynchronize( pasteboard
);
533 // TODO add proper conversion
534 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (const UInt8
*)val
.c_str(), val
.length() );
535 PasteboardPutItemFlavor( pasteboard
, (PasteboardItemID
) 1, CFSTR("com.apple.traditional-mac-plain-text"), data
, 0);
541 case kEventServicePaste
:
544 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
545 PasteboardSynchronize( pasteboard
);
547 verify_noerr( PasteboardGetItemCount( pasteboard
, &itemCount
) );
548 for( UInt32 itemIndex
= 1; itemIndex
<= itemCount
; itemIndex
++ )
550 PasteboardItemID itemID
;
551 if ( PasteboardGetItemIdentifier( pasteboard
, itemIndex
, &itemID
) == noErr
)
553 CFDataRef flavorData
= NULL
;
554 if ( PasteboardCopyItemFlavorData( pasteboard
, itemID
, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData
) == noErr
)
556 CFIndex flavorDataSize
= CFDataGetLength( flavorData
);
557 char *content
= new char[flavorDataSize
+1] ;
558 memcpy( content
, CFDataGetBytePtr( flavorData
), flavorDataSize
);
559 content
[flavorDataSize
]=0;
560 CFRelease( flavorData
);
562 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
564 textCtrl
->WriteText( wxString( content
) ) ;
582 pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
584 OSStatus result
= eventNotHandledErr
;
585 wxWindowMac
* focus
= (wxWindowMac
*) data
;
587 wchar_t* uniChars
= NULL
;
588 UInt32 when
= EventTimeToTicks( GetEventTime( event
) ) ;
590 UniChar
* charBuf
= NULL
;
591 ByteCount dataSize
= 0 ;
594 if ( GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, 0 , &dataSize
, NULL
) == noErr
)
596 numChars
= dataSize
/ sizeof( UniChar
) + 1;
599 if ( (size_t) numChars
* 2 > sizeof(buf
) )
600 charBuf
= new UniChar
[ numChars
] ;
604 uniChars
= new wchar_t[ numChars
] ;
605 GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, dataSize
, NULL
, charBuf
) ;
606 charBuf
[ numChars
- 1 ] = 0;
607 #if SIZEOF_WCHAR_T == 2
608 uniChars
= (wchar_t*) charBuf
;
609 /* 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...)
611 // the resulting string will never have more chars than the utf16 version, so this is safe
612 wxMBConvUTF16 converter
;
613 numChars
= converter
.MB2WC( uniChars
, (const char*)charBuf
, numChars
) ;
617 switch ( GetEventKind( event
) )
619 case kEventTextInputUpdateActiveInputArea
:
621 // An IME input event may return several characters, but we need to send one char at a time to
623 for (int pos
=0 ; pos
< numChars
; pos
++)
625 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
626 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
627 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
629 UInt32 message
= uniChars
[pos
] < 128 ? (char)uniChars
[pos
] : '?';
631 NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent
632 multiple times to update the active range during inline input, so this handler will often receive
633 uncommited text, which should usually not trigger side effects. It might be a good idea to check the
634 kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h).
635 On the other hand, it can be useful for some applications to react to uncommitted text (for example,
636 to update a status display), as long as it does not disrupt the inline input session. Ideally, wx
637 should add new event types to support advanced text input. For now, I would keep things as they are.
639 However, the code that was being used caused additional problems:
640 UInt32 message = (0 << 8) + ((char)uniChars[pos] );
641 Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline
642 input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji
643 for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB
644 (still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D
645 (the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress.
646 Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only
647 overlap with Unicode within the (7-bit) ASCII range.
648 But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks
649 for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII
650 characters as they are and replaces the rest with '?', ensuring that update events are triggered.
651 It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but
652 I don't have time to look into that right now.
655 if ( wxTheApp
->MacSendCharEvent(
656 focus
, message
, 0 , when
, 0 , 0 , uniChars
[pos
] ) )
661 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
665 case kEventTextInputUnicodeForKeyEvent
:
667 UInt32 keyCode
, modifiers
;
670 unsigned char charCode
;
672 GetEventParameter( event
, kEventParamTextInputSendKeyboardEvent
, typeEventRef
, NULL
, sizeof(rawEvent
), NULL
, &rawEvent
) ;
673 GetEventParameter( rawEvent
, kEventParamKeyMacCharCodes
, typeChar
, NULL
, sizeof(char), NULL
, &charCode
);
674 GetEventParameter( rawEvent
, kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
675 GetEventParameter( rawEvent
, kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
676 GetEventParameter( rawEvent
, kEventParamMouseLocation
, typeQDPoint
, NULL
, sizeof(Point
), NULL
, &point
);
678 UInt32 message
= (keyCode
<< 8) + charCode
;
680 // An IME input event may return several characters, but we need to send one char at a time to
682 for (int pos
=0 ; pos
< numChars
; pos
++)
684 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
685 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
686 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
688 if ( wxTheApp
->MacSendCharEvent(
689 focus
, message
, modifiers
, when
, point
.h
, point
.v
, uniChars
[pos
] ) )
694 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
703 if ( charBuf
!= buf
)
709 static pascal OSStatus
710 wxMacWindowCommandEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
714 OSStatus result
= eventNotHandledErr
;
715 wxWindowMac
* focus
= (wxWindowMac
*) data
;
719 wxMacCarbonEvent
cEvent( event
) ;
720 cEvent
.GetParameter
<HICommand
>(kEventParamDirectObject
,typeHICommand
,&command
) ;
722 wxMenuItem
* item
= NULL
;
723 wxMenu
* itemMenu
= wxFindMenuFromMacCommand( command
, item
) ;
727 wxASSERT( itemMenu
!= NULL
) ;
729 switch ( cEvent
.GetKind() )
731 case kEventProcessCommand
:
732 if ( itemMenu
->HandleCommandProcess( item
, focus
) )
736 case kEventCommandUpdateStatus
:
737 if ( itemMenu
->HandleCommandUpdateStatus( item
, focus
) )
748 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
750 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
751 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
752 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
753 OSStatus result
= eventNotHandledErr
;
755 switch ( GetEventClass( event
) )
757 case kEventClassCommand
:
758 result
= wxMacWindowCommandEventHandler( handler
, event
, data
) ;
761 case kEventClassControl
:
762 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
765 case kEventClassService
:
766 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
769 case kEventClassTextInput
:
770 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
777 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
782 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
784 // ---------------------------------------------------------------------------
785 // Scrollbar Tracking for all
786 // ---------------------------------------------------------------------------
788 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
789 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
793 wxWindow
* wx
= wxFindWindowFromWXWidget( (WXWidget
) control
) ;
796 wxEventType scrollEvent
= wxEVT_NULL
;
799 case kControlUpButtonPart
:
800 scrollEvent
= wxEVT_SCROLL_LINEUP
;
803 case kControlDownButtonPart
:
804 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
807 case kControlPageUpPart
:
808 scrollEvent
= wxEVT_SCROLL_PAGEUP
;
811 case kControlPageDownPart
:
812 scrollEvent
= wxEVT_SCROLL_PAGEDOWN
;
815 case kControlIndicatorPart
:
816 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
817 // when this is called as a live proc, mouse is always still down
818 // so no need for thumbrelease
819 // scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
822 wx
->TriggerScrollEvent(scrollEvent
) ;
826 wxMAC_DEFINE_PROC_GETTER( ControlActionUPP
, wxMacLiveScrollbarActionProc
) ;
828 wxWidgetImplType
* wxWidgetImpl::CreateUserPane( wxWindowMac
* wxpeer
,
829 wxWindowMac
* WXUNUSED(parent
),
830 wxWindowID
WXUNUSED(id
),
833 long WXUNUSED(style
),
834 long WXUNUSED(extraStyle
))
836 OSStatus err
= noErr
;
837 Rect bounds
= wxMacGetBoundsForControl( wxpeer
, pos
, size
) ;
838 wxMacControl
* c
= new wxMacControl(wxpeer
) ;
840 | kControlSupportsEmbedding
841 | kControlSupportsLiveFeedback
842 | kControlGetsFocusOnClick
843 // | kControlHasSpecialBackground
844 // | kControlSupportsCalcBestRect
845 | kControlHandlesTracking
846 | kControlSupportsFocus
847 | kControlWantsActivate
848 | kControlWantsIdle
;
850 err
=::CreateUserPaneControl( MAC_WXHWND(wxpeer
->GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, c
->GetControlRefAddr() );
856 void wxMacControl::InstallEventHandler( WXWidget control
)
858 wxWidgetImpl::Associate( control
? control
: (WXWidget
) m_controlRef
, this ) ;
859 ::InstallControlEventHandler( control
? (ControlRef
) control
: m_controlRef
, GetwxMacWindowEventHandlerUPP(),
860 GetEventTypeCount(eventList
), eventList
, GetWXPeer(), NULL
);
863 IMPLEMENT_DYNAMIC_CLASS( wxMacControl
, wxWidgetImpl
)
865 wxMacControl::wxMacControl()
870 wxMacControl::wxMacControl(wxWindowMac
* peer
, bool isRootControl
) :
871 wxWidgetImpl( peer
, isRootControl
)
876 wxMacControl::~wxMacControl()
878 if ( m_controlRef
&& !IsRootControl() )
880 wxASSERT_MSG( m_controlRef
!= NULL
, wxT("Control Handle already NULL, Dispose called twice ?") );
881 wxASSERT_MSG( IsValidControlHandle(m_controlRef
) , wxT("Invalid Control Handle (maybe already released) in Dispose") );
883 wxWidgetImpl::RemoveAssociations( this ) ;
884 // we cannot check the ref count here anymore, as autorelease objects might delete their refs later
885 // we can have situations when being embedded, where the control gets deleted behind our back, so only
886 // CFRelease if we are safe
887 if ( IsValidControlHandle(m_controlRef
) )
888 CFRelease(m_controlRef
);
893 void wxMacControl::Init()
896 m_macControlEventHandler
= NULL
;
899 void wxMacControl::RemoveFromParent()
901 // nothing to do here for carbon
902 HIViewRemoveFromSuperview(m_controlRef
);
905 void wxMacControl::Embed( wxWidgetImpl
*parent
)
907 HIViewAddSubview((ControlRef
)parent
->GetWXWidget(), m_controlRef
);
910 void wxMacControl::SetNeedsDisplay( const wxRect
* rect
)
917 HIRect updatearea
= CGRectMake( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
918 HIViewSetNeedsDisplayInRect( m_controlRef
, &updatearea
, true );
921 HIViewSetNeedsDisplay( m_controlRef
, true );
924 void wxMacControl::Raise()
926 verify_noerr( HIViewSetZOrder( m_controlRef
, kHIViewZOrderAbove
, NULL
) );
929 void wxMacControl::Lower()
931 verify_noerr( HIViewSetZOrder( m_controlRef
, kHIViewZOrderBelow
, NULL
) );
934 void wxMacControl::GetContentArea(int &left
, int &top
, int &width
, int &height
) const
936 HIShapeRef rgn
= NULL
;
939 if ( HIViewCopyShape(m_controlRef
, kHIViewContentMetaPart
, &rgn
) == noErr
)
942 HIShapeGetBounds(rgn
, &cgrect
);
943 content
= (Rect
){ cgrect
.origin
.y
, cgrect
.origin
.x
, cgrect
.origin
.y
+cgrect
.size
.height
, cgrect
.origin
.x
+cgrect
.size
.width
};
948 GetControlBounds(m_controlRef
, &content
);
949 content
.right
-= content
.left
;
951 content
.bottom
-= content
.top
;
958 width
= content
.right
- content
.left
;
959 height
= content
.bottom
- content
.top
;
962 void wxMacControl::Move(int x
, int y
, int width
, int height
)
964 HIRect hir
= CGRectMake(x
,y
,width
,height
);
965 HIViewSetFrame ( m_controlRef
, &hir
);
968 void wxMacControl::GetPosition( int &x
, int &y
) const
971 GetControlBounds( m_controlRef
, &r
);
976 void wxMacControl::GetSize( int &width
, int &height
) const
979 GetControlBounds( m_controlRef
, &r
);
980 width
= r
.right
- r
.left
;
981 height
= r
.bottom
- r
.top
;
984 void wxMacControl::SetControlSize( wxWindowVariant variant
)
989 case wxWINDOW_VARIANT_NORMAL
:
990 size
= kControlSizeNormal
;
993 case wxWINDOW_VARIANT_SMALL
:
994 size
= kControlSizeSmall
;
997 case wxWINDOW_VARIANT_MINI
:
998 // not always defined in the headers
1002 case wxWINDOW_VARIANT_LARGE
:
1003 size
= kControlSizeLarge
;
1007 wxFAIL_MSG(_T("unexpected window variant"));
1011 SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
, &size
) ;
1014 void wxMacControl::ScrollRect( const wxRect
*rect
, int dx
, int dy
)
1016 if (GetNeedsDisplay() )
1018 // because HIViewScrollRect does not scroll the already invalidated area we have two options:
1019 // in case there is already a pending redraw on that area
1020 // either immediate redraw or full invalidate
1022 // is the better overall solution, as it does not slow down scrolling
1025 // this would be the preferred version for fast drawing controls
1026 HIViewRender(GetControlRef()) ;
1030 // note there currently is a bug in OSX (10.3 +?) which makes inefficient refreshes in case an entire control
1031 // area is scrolled, this does not occur if width and height are 2 pixels less,
1032 // TODO: write optimal workaround
1034 HIRect scrollarea
= CGRectMake( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1035 HIViewScrollRect ( m_controlRef
, &scrollarea
, dx
,dy
);
1038 // this would be the preferred version for fast drawing controls
1039 HIViewRender(GetControlRef()) ;
1043 bool wxMacControl::CanFocus() const
1045 // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
1046 // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning,
1047 // but the value range is nowhere documented
1048 Boolean keyExistsAndHasValidFormat
;
1049 CFIndex fullKeyboardAccess
= CFPreferencesGetAppIntegerValue( CFSTR("AppleKeyboardUIMode" ) ,
1050 kCFPreferencesCurrentApplication
, &keyExistsAndHasValidFormat
);
1052 if ( keyExistsAndHasValidFormat
&& fullKeyboardAccess
> 0 )
1058 UInt32 features
= 0 ;
1059 GetControlFeatures( m_controlRef
, &features
) ;
1061 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
1065 bool wxMacControl::GetNeedsDisplay() const
1067 return HIViewGetNeedsDisplay( m_controlRef
);
1070 void wxWidgetImpl::Convert( wxPoint
*pt
, wxWidgetImpl
*from
, wxWidgetImpl
*to
)
1076 HIViewConvertPoint( &hiPoint
, (ControlRef
) from
->GetWXWidget() , (ControlRef
) to
->GetWXWidget() );
1077 pt
->x
= (int)hiPoint
.x
;
1078 pt
->y
= (int)hiPoint
.y
;
1081 bool wxMacControl::SetFocus()
1083 // as we cannot rely on the control features to find out whether we are in full keyboard mode,
1084 // we can only leave in case of an error
1086 OSStatus err
= SetKeyboardFocus( GetControlOwner( m_controlRef
), m_controlRef
, kControlFocusNextPart
);
1087 if ( err
== errCouldntSetFocus
)
1089 SetUserFocusWindow(GetControlOwner( m_controlRef
) );
1094 bool wxMacControl::HasFocus() const
1097 GetKeyboardFocus( GetUserFocusWindow() , &control
);
1098 return control
== m_controlRef
;
1101 void wxMacControl::SetCursor(const wxCursor
& cursor
)
1103 wxWindowMac
*mouseWin
= 0 ;
1104 WindowRef window
= GetControlOwner( m_controlRef
) ;
1106 wxNonOwnedWindow
* tlwwx
= wxNonOwnedWindow::GetFromWXWindow( (WXWindow
) window
) ;
1107 if ( tlwwx
!= NULL
)
1109 ControlPartCode part
;
1110 ControlRef control
;
1112 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
1114 HIGetMousePosition(kHICoordSpaceWindow
, window
, &hiPoint
);
1118 GetGlobalMouse( &pt
);
1121 tlwwx
->ScreenToClient(&x
, &y
);
1125 control
= FindControlUnderMouse( pt
, window
, &part
) ;
1127 mouseWin
= wxFindWindowFromWXWidget( (WXWidget
) control
) ;
1130 if ( mouseWin
== tlwwx
&& !wxIsBusy() )
1131 cursor
.MacInstall() ;
1134 void wxMacControl::CaptureMouse()
1138 void wxMacControl::ReleaseMouse()
1143 // subclass specifics
1146 OSStatus
wxMacControl::GetData(ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const
1148 return ::GetControlData( m_controlRef
, inPartCode
, inTag
, inBufferSize
, inOutBuffer
, outActualSize
);
1151 OSStatus
wxMacControl::GetDataSize(ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const
1153 return ::GetControlDataSize( m_controlRef
, inPartCode
, inTag
, outActualSize
);
1156 OSStatus
wxMacControl::SetData(ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
)
1158 return ::SetControlData( m_controlRef
, inPartCode
, inTag
, inSize
, inData
);
1161 OSStatus
wxMacControl::SendEvent( EventRef event
, OptionBits inOptions
)
1163 return SendEventToEventTargetWithOptions( event
,
1164 HIObjectGetEventTarget( (HIObjectRef
) m_controlRef
), inOptions
);
1167 OSStatus
wxMacControl::SendHICommand( HICommand
&command
, OptionBits inOptions
)
1169 wxMacCarbonEvent
event( kEventClassCommand
, kEventCommandProcess
);
1171 event
.SetParameter
<HICommand
>(kEventParamDirectObject
,command
);
1173 return SendEvent( event
, inOptions
);
1176 OSStatus
wxMacControl::SendHICommand( UInt32 commandID
, OptionBits inOptions
)
1180 memset( &command
, 0 , sizeof(command
) );
1181 command
.commandID
= commandID
;
1182 return SendHICommand( command
, inOptions
);
1185 void wxMacControl::PerformClick()
1187 HIViewSimulateClick (m_controlRef
, kControlButtonPart
, 0, NULL
);
1190 wxInt32
wxMacControl::GetValue() const
1192 return ::GetControl32BitValue( m_controlRef
);
1195 wxInt32
wxMacControl::GetMaximum() const
1197 return ::GetControl32BitMaximum( m_controlRef
);
1200 wxInt32
wxMacControl::GetMinimum() const
1202 return ::GetControl32BitMinimum( m_controlRef
);
1205 void wxMacControl::SetValue( wxInt32 v
)
1207 ::SetControl32BitValue( m_controlRef
, v
);
1210 void wxMacControl::SetMinimum( wxInt32 v
)
1212 ::SetControl32BitMinimum( m_controlRef
, v
);
1215 void wxMacControl::SetMaximum( wxInt32 v
)
1217 ::SetControl32BitMaximum( m_controlRef
, v
);
1220 void wxMacControl::SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
)
1222 ::SetControl32BitMinimum( m_controlRef
, minimum
);
1223 ::SetControl32BitMaximum( m_controlRef
, maximum
);
1224 ::SetControl32BitValue( m_controlRef
, value
);
1227 void wxMacControl::VisibilityChanged(bool WXUNUSED(shown
))
1231 void wxMacControl::SuperChangedPosition()
1235 void wxMacControl::SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
)
1238 #if wxOSX_USE_CORE_TEXT
1239 if ( UMAGetSystemVersion() >= 0x1050 )
1241 HIViewPartCode part
= 0;
1242 HIThemeTextHorizontalFlush flush
= kHIThemeTextHorizontalFlushDefault
;
1243 if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_CENTER_HORIZONTAL
)
1244 flush
= kHIThemeTextHorizontalFlushCenter
;
1245 else if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_RIGHT
)
1246 flush
= kHIThemeTextHorizontalFlushRight
;
1247 HIViewSetTextFont( m_controlRef
, part
, (CTFontRef
) font
.OSXGetCTFont() );
1248 HIViewSetTextHorizontalFlush( m_controlRef
, part
, flush
);
1250 if ( foreground
!= *wxBLACK
|| ignoreBlack
== false )
1252 ControlFontStyleRec fontStyle
;
1253 foreground
.GetRGBColor( &fontStyle
.foreColor
);
1254 fontStyle
.flags
= kControlUseForeColorMask
;
1255 ::SetControlFontStyle( m_controlRef
, &fontStyle
);
1259 #if wxOSX_USE_ATSU_TEXT
1260 ControlFontStyleRec fontStyle
;
1261 if ( font
.MacGetThemeFontID() != kThemeCurrentPortFont
)
1263 switch ( font
.MacGetThemeFontID() )
1265 case kThemeSmallSystemFont
:
1266 fontStyle
.font
= kControlFontSmallSystemFont
;
1269 case 109 : // mini font
1270 fontStyle
.font
= -5;
1273 case kThemeSystemFont
:
1274 fontStyle
.font
= kControlFontBigSystemFont
;
1278 fontStyle
.font
= kControlFontBigSystemFont
;
1282 fontStyle
.flags
= kControlUseFontMask
;
1286 fontStyle
.font
= font
.MacGetFontNum();
1287 fontStyle
.style
= font
.MacGetFontStyle();
1288 fontStyle
.size
= font
.GetPointSize();
1289 fontStyle
.flags
= kControlUseFontMask
| kControlUseFaceMask
| kControlUseSizeMask
;
1292 fontStyle
.just
= teJustLeft
;
1293 fontStyle
.flags
|= kControlUseJustMask
;
1294 if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_CENTER_HORIZONTAL
)
1295 fontStyle
.just
= teJustCenter
;
1296 else if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_RIGHT
)
1297 fontStyle
.just
= teJustRight
;
1300 // we only should do this in case of a non-standard color, as otherwise 'disabled' controls
1301 // won't get grayed out by the system anymore
1303 if ( foreground
!= *wxBLACK
|| ignoreBlack
== false )
1305 foreground
.GetRGBColor( &fontStyle
.foreColor
);
1306 fontStyle
.flags
|= kControlUseForeColorMask
;
1309 ::SetControlFontStyle( m_controlRef
, &fontStyle
);
1313 void wxMacControl::SetBackgroundColour( const wxColour
&WXUNUSED(col
) )
1315 // HITextViewSetBackgroundColor( m_textView , color );
1318 void wxMacControl::SetRange( SInt32 minimum
, SInt32 maximum
)
1320 ::SetControl32BitMinimum( m_controlRef
, minimum
);
1321 ::SetControl32BitMaximum( m_controlRef
, maximum
);
1324 short wxMacControl::HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
)
1326 return HandleControlKey( m_controlRef
, keyCode
, charCode
, modifiers
);
1329 void wxMacControl::SetActionProc( ControlActionUPP actionProc
)
1331 SetControlAction( m_controlRef
, actionProc
);
1334 SInt32
wxMacControl::GetViewSize() const
1336 return GetControlViewSize( m_controlRef
);
1339 bool wxMacControl::IsVisible() const
1341 return IsControlVisible( m_controlRef
);
1344 void wxMacControl::SetVisibility( bool visible
)
1346 SetControlVisibility( m_controlRef
, visible
, true );
1349 bool wxMacControl::IsEnabled() const
1351 return IsControlEnabled( m_controlRef
);
1354 bool wxMacControl::IsActive() const
1356 return IsControlActive( m_controlRef
);
1359 void wxMacControl::Enable( bool enable
)
1362 EnableControl( m_controlRef
);
1364 DisableControl( m_controlRef
);
1367 void wxMacControl::SetDrawingEnabled( bool enable
)
1369 HIViewSetDrawingEnabled( m_controlRef
, enable
);
1372 void wxMacControl::GetRectInWindowCoords( Rect
*r
)
1374 GetControlBounds( m_controlRef
, r
) ;
1376 WindowRef tlwref
= GetControlOwner( m_controlRef
) ;
1378 wxNonOwnedWindow
* tlwwx
= wxNonOwnedWindow::GetFromWXWindow( (WXWindow
) tlwref
) ;
1379 if ( tlwwx
!= NULL
)
1381 ControlRef rootControl
= tlwwx
->GetPeer()->GetControlRef() ;
1382 HIPoint hiPoint
= CGPointMake( 0 , 0 ) ;
1383 HIViewConvertPoint( &hiPoint
, HIViewGetSuperview(m_controlRef
) , rootControl
) ;
1384 OffsetRect( r
, (short) hiPoint
.x
, (short) hiPoint
.y
) ;
1388 void wxMacControl::GetBestRect( wxRect
*rect
) const
1390 short baselineoffset
;
1393 GetBestControlRect( m_controlRef
, &r
, &baselineoffset
);
1394 *rect
= wxRect( r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
-r
.top
);
1397 void wxMacControl::GetBestRect( Rect
*r
) const
1399 short baselineoffset
;
1400 GetBestControlRect( m_controlRef
, r
, &baselineoffset
);
1403 void wxMacControl::SetLabel( const wxString
&title
, wxFontEncoding encoding
)
1405 SetControlTitleWithCFString( m_controlRef
, wxCFStringRef( title
, encoding
) );
1408 void wxMacControl::GetFeatures( UInt32
* features
)
1410 GetControlFeatures( m_controlRef
, features
);
1413 void wxMacControl::PulseGauge()
1417 // SetNeedsDisplay would not invalidate the children
1418 static void InvalidateControlAndChildren( HIViewRef control
)
1420 HIViewSetNeedsDisplay( control
, true );
1421 UInt16 childrenCount
= 0;
1422 OSStatus err
= CountSubControls( control
, &childrenCount
);
1423 if ( err
== errControlIsNotEmbedder
)
1426 wxASSERT_MSG( err
== noErr
, wxT("Unexpected error when accessing subcontrols") );
1428 for ( UInt16 i
= childrenCount
; i
>=1; --i
)
1432 err
= GetIndexedSubControl( control
, i
, & child
);
1433 if ( err
== errControlIsNotEmbedder
)
1436 InvalidateControlAndChildren( child
);
1440 void wxMacControl::InvalidateWithChildren()
1442 InvalidateControlAndChildren( m_controlRef
);
1445 OSType wxMacCreator
= 'WXMC';
1446 OSType wxMacControlProperty
= 'MCCT';
1448 void wxMacControl::SetReferenceInNativeControl()
1451 verify_noerr( SetControlProperty ( m_controlRef
,
1452 wxMacCreator
,wxMacControlProperty
, sizeof(data
), &data
) );
1455 wxMacControl
* wxMacControl::GetReferenceFromNativeControl(ControlRef control
)
1457 wxMacControl
* ctl
= NULL
;
1458 ByteCount actualSize
;
1459 if ( GetControlProperty( control
,wxMacCreator
,wxMacControlProperty
, sizeof(ctl
) ,
1460 &actualSize
, &ctl
) == noErr
)
1467 void wxMacControl::SetBitmap( const wxBitmap
& WXUNUSED(bmp
) )
1469 // implemented in the respective subclasses
1472 void wxMacControl::SetScrollThumb( wxInt32
WXUNUSED(pos
), wxInt32
WXUNUSED(viewsize
) )
1474 // implemented in respective subclass
1481 OSStatus
wxMacControl::SetTabEnabled( SInt16 tabNo
, bool enable
)
1483 return ::SetTabEnabled( m_controlRef
, tabNo
, enable
);
1490 wxWidgetImplType
* wxWidgetImpl::CreateContentView( wxNonOwnedWindow
* now
)
1492 // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
1493 // the content view, so we have to retrieve it explicitly
1495 wxMacControl
* contentview
= new wxMacControl(now
, true /*isRootControl*/);
1496 HIViewFindByID( HIViewGetRoot( (WindowRef
) now
->GetWXWindow() ) , kHIViewWindowContentID
,
1497 contentview
->GetControlRefAddr() ) ;
1498 if ( !contentview
->IsOk() )
1500 // compatibility mode fallback
1501 GetRootControl( (WindowRef
) now
->GetWXWindow() , contentview
->GetControlRefAddr() ) ;
1504 // the root control level handler
1505 contentview
->InstallEventHandler() ;