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 // ---------------------------------------------------------------------------
84 // ---------------------------------------------------------------------------
86 static const EventTypeSpec eventList
[] =
88 { kEventClassCommand
, kEventProcessCommand
} ,
89 { kEventClassCommand
, kEventCommandUpdateStatus
} ,
91 { kEventClassControl
, kEventControlGetClickActivation
} ,
92 { kEventClassControl
, kEventControlHit
} ,
94 { kEventClassTextInput
, kEventTextInputUnicodeForKeyEvent
} ,
95 { kEventClassTextInput
, kEventTextInputUpdateActiveInputArea
} ,
97 { kEventClassControl
, kEventControlDraw
} ,
99 { kEventClassControl
, kEventControlVisibilityChanged
} ,
100 { kEventClassControl
, kEventControlEnabledStateChanged
} ,
101 { kEventClassControl
, kEventControlHiliteChanged
} ,
103 { kEventClassControl
, kEventControlActivate
} ,
104 { kEventClassControl
, kEventControlDeactivate
} ,
106 { kEventClassControl
, kEventControlSetFocusPart
} ,
107 { kEventClassControl
, kEventControlFocusPartChanged
} ,
109 { kEventClassService
, kEventServiceGetTypes
},
110 { kEventClassService
, kEventServiceCopy
},
111 { kEventClassService
, kEventServicePaste
},
113 // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
114 // { kEventClassControl , kEventControlBoundsChanged } ,
117 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
119 OSStatus result
= eventNotHandledErr
;
120 static wxWindowMac
* targetFocusWindow
= NULL
;
121 static wxWindowMac
* formerFocusWindow
= NULL
;
123 wxMacCarbonEvent
cEvent( event
) ;
125 ControlRef controlRef
;
126 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
128 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
130 switch ( GetEventKind( event
) )
132 case kEventControlDraw
:
134 HIShapeRef updateRgn
= NULL
;
135 HIMutableShapeRef allocatedRgn
= NULL
;
136 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
138 // according to the docs: redraw entire control if param not present
139 if ( cEvent
.GetParameter
<HIShapeRef
>(kEventParamShape
, &updateRgn
) != noErr
)
141 updateRgn
= visRegion
.GetWXHRGN();
145 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
147 // as this update region is in native window locals we must adapt it to wx window local
148 allocatedRgn
= HIShapeCreateMutableCopy(updateRgn
);
149 HIShapeOffset(allocatedRgn
, thisWindow
->MacGetLeftBorderSize() , thisWindow
->MacGetTopBorderSize());
150 // hide the given region by the new region that must be shifted
151 updateRgn
= allocatedRgn
;
155 #if wxMAC_DEBUG_REDRAW
156 if ( thisWindow
->MacIsUserPane() )
158 static float color
= 0.5 ;
159 static int channel
= 0 ;
161 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
163 HIViewGetBounds( controlRef
, &bounds
);
164 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
165 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
166 CGContextFillRect( cgContext
, bounds
);
179 bool created
= false ;
180 CGContextRef cgContext
= NULL
;
181 OSStatus err
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, &cgContext
) ;
184 wxFAIL_MSG("Unable to retrieve CGContextRef");
187 thisWindow
->MacSetCGContextRef( cgContext
) ;
190 wxMacCGContextStateSaver
sg( cgContext
) ;
191 CGFloat alpha
= (CGFloat
)1.0 ;
193 wxWindow
* iter
= thisWindow
;
196 alpha
*= (CGFloat
)( iter
->GetTransparent()/255.0 ) ;
197 if ( iter
->IsTopLevel() )
200 iter
= iter
->GetParent() ;
203 CGContextSetAlpha( cgContext
, alpha
) ;
205 if ( thisWindow
->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT
)
208 HIViewGetBounds( controlRef
, &bounds
);
209 CGContextClearRect( cgContext
, bounds
);
212 if ( !HIShapeIsEmpty(updateRgn
) )
214 // refcount increase because wxRegion constructor takes ownership of the native region
216 thisWindow
->GetUpdateRegion() = wxRegion(updateRgn
);
217 if ( !thisWindow
->MacDoRedraw( cEvent
.GetTicks() ) )
219 // for native controls: call their native paint method
220 if ( !thisWindow
->MacIsUserPane() ||
221 ( thisWindow
->IsTopLevel() && thisWindow
->GetBackgroundStyle() == wxBG_STYLE_SYSTEM
) )
223 if ( thisWindow
->GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT
)
224 CallNextEventHandler( handler
,event
) ;
227 thisWindow
->MacPaintChildrenBorders();
229 thisWindow
->MacSetCGContextRef( NULL
) ;
233 CGContextRelease( cgContext
) ;
237 CFRelease( allocatedRgn
) ;
241 case kEventControlVisibilityChanged
:
242 // we might have two native controls attributed to the same wxWindow instance
243 // eg a scrollview and an embedded textview, make sure we only fire for the 'outer'
244 // control, as otherwise native and wx visibility are different
245 if ( thisWindow
->GetPeer() != NULL
&& thisWindow
->GetPeer()->GetControlRef() == controlRef
)
247 thisWindow
->MacVisibilityChanged() ;
251 case kEventControlEnabledStateChanged
:
252 thisWindow
->MacEnabledStateChanged();
255 case kEventControlHiliteChanged
:
256 thisWindow
->MacHiliteChanged() ;
259 case kEventControlActivate
:
260 case kEventControlDeactivate
:
261 // FIXME: we should have a virtual function for this!
263 if ( thisWindow
->IsKindOf( CLASSINFO( wxTreeCtrl
) ) )
264 thisWindow
->Refresh();
267 if ( thisWindow
->IsKindOf( CLASSINFO( wxListCtrl
) ) )
268 thisWindow
->Refresh();
274 // different handling on OS X
277 case kEventControlFocusPartChanged
:
278 // the event is emulated by wxmac for systems lower than 10.5
280 if ( UMAGetSystemVersion() < 0x1050 )
282 // as it is synthesized here, we have to manually avoid propagation
285 ControlPartCode previousControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPreviousPart
, typeControlPartCode
);
286 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlCurrentPart
, typeControlPartCode
);
288 if ( thisWindow
->MacGetTopLevelWindow() && thisWindow
->GetPeer()->NeedsFocusRect() )
290 thisWindow
->MacInvalidateBorders();
293 if ( currentControlPart
== 0 )
297 if ( thisWindow
->GetCaret() )
298 thisWindow
->GetCaret()->OnKillFocus();
301 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast<void*>(thisWindow
));
303 // remove this as soon as posting the synthesized event works properly
304 static bool inKillFocusEvent
= false ;
306 if ( !inKillFocusEvent
)
308 inKillFocusEvent
= true ;
309 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
310 event
.SetEventObject(thisWindow
);
311 event
.SetWindow(targetFocusWindow
);
312 thisWindow
->HandleWindowEvent(event
) ;
313 inKillFocusEvent
= false ;
314 targetFocusWindow
= NULL
;
317 else if ( previousControlPart
== 0 )
320 // panel wants to track the window which was the last to have focus in it
321 wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast<void*>(thisWindow
));
322 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
323 thisWindow
->HandleWindowEvent(eventFocus
);
326 if ( thisWindow
->GetCaret() )
327 thisWindow
->GetCaret()->OnSetFocus();
330 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
331 event
.SetEventObject(thisWindow
);
332 event
.SetWindow(formerFocusWindow
);
333 thisWindow
->HandleWindowEvent(event
) ;
334 formerFocusWindow
= NULL
;
338 case kEventControlSetFocusPart
:
340 Boolean focusEverything
= false ;
341 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
343 // put a breakpoint here to catch focus everything events
345 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
346 if ( controlPart
!= kControlFocusNoPart
)
348 targetFocusWindow
= thisWindow
;
349 wxLogTrace(_T("Focus"), _T("focus to be set(%p)"), static_cast<void*>(thisWindow
));
353 formerFocusWindow
= thisWindow
;
354 wxLogTrace(_T("Focus"), _T("focus to be lost(%p)"), static_cast<void*>(thisWindow
));
357 ControlPartCode previousControlPart
= 0;
358 verify_noerr( HIViewGetFocusPart(controlRef
, &previousControlPart
));
360 if ( thisWindow
->MacIsUserPane() )
362 if ( controlPart
!= kControlFocusNoPart
)
363 cEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPart
, typeControlPartCode
, 1 ) ;
367 result
= CallNextEventHandler(handler
, event
);
369 if ( UMAGetSystemVersion() < 0x1050 )
371 // set back to 0 if problems arise
373 if ( result
== noErr
)
375 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
376 // synthesize the event focus changed event
377 EventRef evRef
= NULL
;
379 OSStatus err
= MacCreateEvent(
380 NULL
, kEventClassControl
, kEventControlFocusPartChanged
, TicksToEventTime( TickCount() ) ,
381 kEventAttributeUserEvent
, &evRef
);
384 wxMacCarbonEvent
iEvent( evRef
) ;
385 iEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, controlRef
);
386 iEvent
.SetParameter
<EventTargetRef
>( kEventParamPostTarget
, typeEventTargetRef
, GetControlEventTarget( controlRef
) );
387 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPreviousPart
, typeControlPartCode
, previousControlPart
);
388 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlCurrentPart
, typeControlPartCode
, currentControlPart
);
391 // TODO test this first, avoid double posts etc...
392 PostEventToQueue( GetMainEventQueue(), evRef
, kEventPriorityHigh
);
394 wxMacWindowControlEventHandler( NULL
, evRef
, data
) ;
396 ReleaseEvent( evRef
) ;
399 // old implementation, to be removed if the new one works
400 if ( controlPart
== kControlFocusNoPart
)
403 if ( thisWindow
->GetCaret() )
404 thisWindow
->GetCaret()->OnKillFocus();
407 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast<void*>(thisWindow
));
409 static bool inKillFocusEvent
= false ;
411 if ( !inKillFocusEvent
)
413 inKillFocusEvent
= true ;
414 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
415 event
.SetEventObject(thisWindow
);
416 thisWindow
->HandleWindowEvent(event
) ;
417 inKillFocusEvent
= false ;
422 // panel wants to track the window which was the last to have focus in it
423 wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast<void*>(thisWindow
));
424 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
425 thisWindow
->HandleWindowEvent(eventFocus
);
428 if ( thisWindow
->GetCaret() )
429 thisWindow
->GetCaret()->OnSetFocus();
432 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
433 event
.SetEventObject(thisWindow
);
434 thisWindow
->HandleWindowEvent(event
) ;
441 case kEventControlHit
:
442 result
= thisWindow
->MacControlHit( handler
, event
) ;
445 case kEventControlGetClickActivation
:
447 // fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise)
448 WindowRef owner
= cEvent
.GetParameter
<WindowRef
>(kEventParamWindowRef
);
449 if ( !IsWindowActive(owner
) )
451 cEvent
.SetParameter(kEventParamClickActivation
,typeClickActivationResult
, (UInt32
) kActivateAndIgnoreClick
) ;
464 static pascal OSStatus
465 wxMacWindowServiceEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
469 OSStatus result
= eventNotHandledErr
;
471 wxMacCarbonEvent
cEvent( event
) ;
473 ControlRef controlRef
;
474 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
475 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
476 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
478 switch ( GetEventKind( event
) )
480 case kEventServiceGetTypes
:
484 textCtrl
->GetSelection( &from
, &to
) ;
486 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
488 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
489 if ( textCtrl
->IsEditable() )
490 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
492 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt', 'PICT', 'MooV', 'AIFF' */ };
493 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
495 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
499 CFArrayAppendValue(copyTypes
, typestring
) ;
501 CFArrayAppendValue(pasteTypes
, typestring
) ;
503 CFRelease( typestring
) ;
511 case kEventServiceCopy
:
516 textCtrl
->GetSelection( &from
, &to
) ;
517 wxString val
= textCtrl
->GetValue() ;
518 val
= val
.Mid( from
, to
- from
) ;
519 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
520 verify_noerr( PasteboardClear( pasteboard
) ) ;
521 PasteboardSynchronize( pasteboard
);
522 // TODO add proper conversion
523 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (const UInt8
*)val
.c_str(), val
.length() );
524 PasteboardPutItemFlavor( pasteboard
, (PasteboardItemID
) 1, CFSTR("com.apple.traditional-mac-plain-text"), data
, 0);
530 case kEventServicePaste
:
533 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
534 PasteboardSynchronize( pasteboard
);
536 verify_noerr( PasteboardGetItemCount( pasteboard
, &itemCount
) );
537 for( UInt32 itemIndex
= 1; itemIndex
<= itemCount
; itemIndex
++ )
539 PasteboardItemID itemID
;
540 if ( PasteboardGetItemIdentifier( pasteboard
, itemIndex
, &itemID
) == noErr
)
542 CFDataRef flavorData
= NULL
;
543 if ( PasteboardCopyItemFlavorData( pasteboard
, itemID
, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData
) == noErr
)
545 CFIndex flavorDataSize
= CFDataGetLength( flavorData
);
546 char *content
= new char[flavorDataSize
+1] ;
547 memcpy( content
, CFDataGetBytePtr( flavorData
), flavorDataSize
);
548 content
[flavorDataSize
]=0;
549 CFRelease( flavorData
);
551 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
553 textCtrl
->WriteText( wxString( content
) ) ;
571 pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
573 OSStatus result
= eventNotHandledErr
;
574 wxWindowMac
* focus
= (wxWindowMac
*) data
;
576 wchar_t* uniChars
= NULL
;
577 UInt32 when
= EventTimeToTicks( GetEventTime( event
) ) ;
579 UniChar
* charBuf
= NULL
;
580 ByteCount dataSize
= 0 ;
583 if ( GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, 0 , &dataSize
, NULL
) == noErr
)
585 numChars
= dataSize
/ sizeof( UniChar
) + 1;
588 if ( (size_t) numChars
* 2 > sizeof(buf
) )
589 charBuf
= new UniChar
[ numChars
] ;
593 uniChars
= new wchar_t[ numChars
] ;
594 GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, dataSize
, NULL
, charBuf
) ;
595 charBuf
[ numChars
- 1 ] = 0;
596 #if SIZEOF_WCHAR_T == 2
597 uniChars
= (wchar_t*) charBuf
;
598 /* 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...)
600 // the resulting string will never have more chars than the utf16 version, so this is safe
601 wxMBConvUTF16 converter
;
602 numChars
= converter
.MB2WC( uniChars
, (const char*)charBuf
, numChars
) ;
606 switch ( GetEventKind( event
) )
608 case kEventTextInputUpdateActiveInputArea
:
610 // An IME input event may return several characters, but we need to send one char at a time to
612 for (int pos
=0 ; pos
< numChars
; pos
++)
614 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
615 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
616 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
618 UInt32 message
= uniChars
[pos
] < 128 ? (char)uniChars
[pos
] : '?';
620 NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent
621 multiple times to update the active range during inline input, so this handler will often receive
622 uncommited text, which should usually not trigger side effects. It might be a good idea to check the
623 kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h).
624 On the other hand, it can be useful for some applications to react to uncommitted text (for example,
625 to update a status display), as long as it does not disrupt the inline input session. Ideally, wx
626 should add new event types to support advanced text input. For now, I would keep things as they are.
628 However, the code that was being used caused additional problems:
629 UInt32 message = (0 << 8) + ((char)uniChars[pos] );
630 Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline
631 input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji
632 for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB
633 (still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D
634 (the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress.
635 Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only
636 overlap with Unicode within the (7-bit) ASCII range.
637 But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks
638 for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII
639 characters as they are and replaces the rest with '?', ensuring that update events are triggered.
640 It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but
641 I don't have time to look into that right now.
644 if ( wxTheApp
->MacSendCharEvent(
645 focus
, message
, 0 , when
, 0 , 0 , uniChars
[pos
] ) )
650 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
654 case kEventTextInputUnicodeForKeyEvent
:
656 UInt32 keyCode
, modifiers
;
659 unsigned char charCode
;
661 GetEventParameter( event
, kEventParamTextInputSendKeyboardEvent
, typeEventRef
, NULL
, sizeof(rawEvent
), NULL
, &rawEvent
) ;
662 GetEventParameter( rawEvent
, kEventParamKeyMacCharCodes
, typeChar
, NULL
, sizeof(char), NULL
, &charCode
);
663 GetEventParameter( rawEvent
, kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
664 GetEventParameter( rawEvent
, kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
665 GetEventParameter( rawEvent
, kEventParamMouseLocation
, typeQDPoint
, NULL
, sizeof(Point
), NULL
, &point
);
667 UInt32 message
= (keyCode
<< 8) + charCode
;
669 // An IME input event may return several characters, but we need to send one char at a time to
671 for (int pos
=0 ; pos
< numChars
; pos
++)
673 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
674 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
675 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
677 if ( wxTheApp
->MacSendCharEvent(
678 focus
, message
, modifiers
, when
, point
.h
, point
.v
, uniChars
[pos
] ) )
683 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
692 if ( charBuf
!= buf
)
698 static pascal OSStatus
699 wxMacWindowCommandEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
703 OSStatus result
= eventNotHandledErr
;
704 wxWindowMac
* focus
= (wxWindowMac
*) data
;
708 wxMacCarbonEvent
cEvent( event
) ;
709 cEvent
.GetParameter
<HICommand
>(kEventParamDirectObject
,typeHICommand
,&command
) ;
711 wxMenuItem
* item
= NULL
;
712 wxMenu
* itemMenu
= wxFindMenuFromMacCommand( command
, item
) ;
716 wxASSERT( itemMenu
!= NULL
) ;
718 switch ( cEvent
.GetKind() )
720 case kEventProcessCommand
:
721 if ( itemMenu
->HandleCommandProcess( item
, focus
) )
725 case kEventCommandUpdateStatus
:
726 if ( itemMenu
->HandleCommandUpdateStatus( item
, focus
) )
737 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
739 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
740 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
741 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
742 OSStatus result
= eventNotHandledErr
;
744 switch ( GetEventClass( event
) )
746 case kEventClassCommand
:
747 result
= wxMacWindowCommandEventHandler( handler
, event
, data
) ;
750 case kEventClassControl
:
751 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
754 case kEventClassService
:
755 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
758 case kEventClassTextInput
:
759 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
766 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
771 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
773 // ---------------------------------------------------------------------------
774 // Scrollbar Tracking for all
775 // ---------------------------------------------------------------------------
777 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
778 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
782 wxWindow
* wx
= wxFindWindowFromWXWidget( (WXWidget
) control
) ;
785 wxEventType scrollEvent
= wxEVT_NULL
;
788 case kControlUpButtonPart
:
789 scrollEvent
= wxEVT_SCROLL_LINEUP
;
792 case kControlDownButtonPart
:
793 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
796 case kControlPageUpPart
:
797 scrollEvent
= wxEVT_SCROLL_PAGEUP
;
800 case kControlPageDownPart
:
801 scrollEvent
= wxEVT_SCROLL_PAGEDOWN
;
804 case kControlIndicatorPart
:
805 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
806 // when this is called as a live proc, mouse is always still down
807 // so no need for thumbrelease
808 // scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
811 wx
->TriggerScrollEvent(scrollEvent
) ;
815 wxMAC_DEFINE_PROC_GETTER( ControlActionUPP
, wxMacLiveScrollbarActionProc
) ;
817 wxWidgetImplType
* wxWidgetImpl::CreateUserPane( wxWindowMac
* wxpeer
, wxWindowMac
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
818 long style
, long extraStyle
)
820 OSStatus err
= noErr
;
821 Rect bounds
= wxMacGetBoundsForControl( wxpeer
, pos
, size
) ;
822 wxMacControl
* c
= new wxMacControl(wxpeer
) ;
824 | kControlSupportsEmbedding
825 | kControlSupportsLiveFeedback
826 | kControlGetsFocusOnClick
827 // | kControlHasSpecialBackground
828 // | kControlSupportsCalcBestRect
829 | kControlHandlesTracking
830 | kControlSupportsFocus
831 | kControlWantsActivate
832 | kControlWantsIdle
;
834 err
=::CreateUserPaneControl( MAC_WXHWND(wxpeer
->GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, c
->GetControlRefAddr() );
840 void wxMacControl::InstallEventHandler( WXWidget control
)
842 wxWidgetImpl::Associate( control
? control
: (WXWidget
) m_controlRef
, this ) ;
843 ::InstallControlEventHandler( control
? (ControlRef
) control
: m_controlRef
, GetwxMacWindowEventHandlerUPP(),
844 GetEventTypeCount(eventList
), eventList
, GetWXPeer(), NULL
);
847 IMPLEMENT_DYNAMIC_CLASS( wxMacControl
, wxWidgetImpl
)
849 wxMacControl::wxMacControl()
854 wxMacControl::wxMacControl(wxWindowMac
* peer
, bool isRootControl
) :
855 wxWidgetImpl( peer
, isRootControl
)
860 wxMacControl::~wxMacControl()
862 if ( m_controlRef
&& !IsRootControl() )
864 wxASSERT_MSG( m_controlRef
!= NULL
, wxT("Control Handle already NULL, Dispose called twice ?") );
865 wxASSERT_MSG( IsValidControlHandle(m_controlRef
) , wxT("Invalid Control Handle (maybe already released) in Dispose") );
867 wxWidgetImpl::RemoveAssociations( this ) ;
868 // we cannot check the ref count here anymore, as autorelease objects might delete their refs later
869 // we can have situations when being embedded, where the control gets deleted behind our back, so only
870 // CFRelease if we are safe
871 if ( IsValidControlHandle(m_controlRef
) )
872 CFRelease(m_controlRef
);
877 void wxMacControl::Init()
880 m_macControlEventHandler
= NULL
;
883 void wxMacControl::RemoveFromParent()
885 // nothing to do here for carbon
886 HIViewRemoveFromSuperview(m_controlRef
);
889 void wxMacControl::Embed( wxWidgetImpl
*parent
)
891 HIViewAddSubview((ControlRef
)parent
->GetWXWidget(), m_controlRef
);
894 void wxMacControl::SetNeedsDisplay( const wxRect
* rect
)
901 HIRect updatearea
= CGRectMake( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
902 HIViewSetNeedsDisplayInRect( m_controlRef
, &updatearea
, true );
905 HIViewSetNeedsDisplay( m_controlRef
, true );
908 void wxMacControl::Raise()
910 verify_noerr( HIViewSetZOrder( m_controlRef
, kHIViewZOrderAbove
, NULL
) );
913 void wxMacControl::Lower()
915 verify_noerr( HIViewSetZOrder( m_controlRef
, kHIViewZOrderBelow
, NULL
) );
918 void wxMacControl::GetContentArea(int &left
, int &top
, int &width
, int &height
) const
920 HIShapeRef rgn
= NULL
;
923 if ( HIViewCopyShape(m_controlRef
, kHIViewContentMetaPart
, &rgn
) == noErr
)
926 HIShapeGetBounds(rgn
, &cgrect
);
927 content
= (Rect
){ cgrect
.origin
.y
, cgrect
.origin
.x
, cgrect
.origin
.y
+cgrect
.size
.height
, cgrect
.origin
.x
+cgrect
.size
.width
};
932 GetControlBounds(m_controlRef
, &content
);
933 content
.right
-= content
.left
;
935 content
.bottom
-= content
.top
;
942 width
= content
.right
- content
.left
;
943 height
= content
.bottom
- content
.top
;
946 void wxMacControl::Move(int x
, int y
, int width
, int height
)
948 HIRect hir
= CGRectMake(x
,y
,width
,height
);
949 HIViewSetFrame ( m_controlRef
, &hir
);
952 void wxMacControl::GetPosition( int &x
, int &y
) const
955 GetControlBounds( m_controlRef
, &r
);
960 void wxMacControl::GetSize( int &width
, int &height
) const
963 GetControlBounds( m_controlRef
, &r
);
964 width
= r
.right
- r
.left
;
965 height
= r
.bottom
- r
.top
;
968 void wxMacControl::SetControlSize( wxWindowVariant variant
)
973 case wxWINDOW_VARIANT_NORMAL
:
974 size
= kControlSizeNormal
;
977 case wxWINDOW_VARIANT_SMALL
:
978 size
= kControlSizeSmall
;
981 case wxWINDOW_VARIANT_MINI
:
982 // not always defined in the headers
986 case wxWINDOW_VARIANT_LARGE
:
987 size
= kControlSizeLarge
;
991 wxFAIL_MSG(_T("unexpected window variant"));
995 SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
, &size
) ;
998 void wxMacControl::ScrollRect( const wxRect
*rect
, int dx
, int dy
)
1000 if (GetNeedsDisplay() )
1002 // because HIViewScrollRect does not scroll the already invalidated area we have two options:
1003 // in case there is already a pending redraw on that area
1004 // either immediate redraw or full invalidate
1006 // is the better overall solution, as it does not slow down scrolling
1009 // this would be the preferred version for fast drawing controls
1010 HIViewRender(GetControlRef()) ;
1014 // note there currently is a bug in OSX (10.3 +?) which makes inefficient refreshes in case an entire control
1015 // area is scrolled, this does not occur if width and height are 2 pixels less,
1016 // TODO: write optimal workaround
1018 HIRect scrollarea
= CGRectMake( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1019 HIViewScrollRect ( m_controlRef
, &scrollarea
, dx
,dy
);
1022 // this would be the preferred version for fast drawing controls
1023 HIViewRender(GetControlRef()) ;
1027 bool wxMacControl::CanFocus() const
1029 // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
1030 // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning,
1031 // but the value range is nowhere documented
1032 Boolean keyExistsAndHasValidFormat
;
1033 CFIndex fullKeyboardAccess
= CFPreferencesGetAppIntegerValue( CFSTR("AppleKeyboardUIMode" ) ,
1034 kCFPreferencesCurrentApplication
, &keyExistsAndHasValidFormat
);
1036 if ( keyExistsAndHasValidFormat
&& fullKeyboardAccess
> 0 )
1042 UInt32 features
= 0 ;
1043 GetControlFeatures( m_controlRef
, &features
) ;
1045 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
1049 bool wxMacControl::GetNeedsDisplay() const
1051 return HIViewGetNeedsDisplay( m_controlRef
);
1054 void wxWidgetImpl::Convert( wxPoint
*pt
, wxWidgetImpl
*from
, wxWidgetImpl
*to
)
1060 HIViewConvertPoint( &hiPoint
, (ControlRef
) from
->GetWXWidget() , (ControlRef
) to
->GetWXWidget() );
1061 pt
->x
= (int)hiPoint
.x
;
1062 pt
->y
= (int)hiPoint
.y
;
1065 bool wxMacControl::SetFocus()
1067 // as we cannot rely on the control features to find out whether we are in full keyboard mode,
1068 // we can only leave in case of an error
1070 OSStatus err
= SetKeyboardFocus( GetControlOwner( m_controlRef
), m_controlRef
, kControlFocusNextPart
);
1071 if ( err
== errCouldntSetFocus
)
1073 SetUserFocusWindow(GetControlOwner( m_controlRef
) );
1078 bool wxMacControl::HasFocus() const
1081 GetKeyboardFocus( GetUserFocusWindow() , &control
);
1082 return control
== m_controlRef
;
1085 void wxMacControl::SetCursor(const wxCursor
& cursor
)
1087 wxWindowMac
*mouseWin
= 0 ;
1088 WindowRef window
= GetControlOwner( m_controlRef
) ;
1090 wxNonOwnedWindow
* tlwwx
= wxNonOwnedWindow::GetFromWXWindow( (WXWindow
) window
) ;
1091 if ( tlwwx
!= NULL
)
1093 ControlPartCode part
;
1094 ControlRef control
;
1096 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
1098 HIGetMousePosition(kHICoordSpaceWindow
, window
, &hiPoint
);
1102 GetGlobalMouse( &pt
);
1105 tlwwx
->ScreenToClient(&x
, &y
);
1109 control
= FindControlUnderMouse( pt
, window
, &part
) ;
1111 mouseWin
= wxFindWindowFromWXWidget( (WXWidget
) control
) ;
1114 if ( mouseWin
== tlwwx
&& !wxIsBusy() )
1115 cursor
.MacInstall() ;
1118 void wxMacControl::CaptureMouse()
1122 void wxMacControl::ReleaseMouse()
1127 // subclass specifics
1130 OSStatus
wxMacControl::GetData(ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const
1132 return ::GetControlData( m_controlRef
, inPartCode
, inTag
, inBufferSize
, inOutBuffer
, outActualSize
);
1135 OSStatus
wxMacControl::GetDataSize(ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const
1137 return ::GetControlDataSize( m_controlRef
, inPartCode
, inTag
, outActualSize
);
1140 OSStatus
wxMacControl::SetData(ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
)
1142 return ::SetControlData( m_controlRef
, inPartCode
, inTag
, inSize
, inData
);
1145 OSStatus
wxMacControl::SendEvent( EventRef event
, OptionBits inOptions
)
1147 return SendEventToEventTargetWithOptions( event
,
1148 HIObjectGetEventTarget( (HIObjectRef
) m_controlRef
), inOptions
);
1151 OSStatus
wxMacControl::SendHICommand( HICommand
&command
, OptionBits inOptions
)
1153 wxMacCarbonEvent
event( kEventClassCommand
, kEventCommandProcess
);
1155 event
.SetParameter
<HICommand
>(kEventParamDirectObject
,command
);
1157 return SendEvent( event
, inOptions
);
1160 OSStatus
wxMacControl::SendHICommand( UInt32 commandID
, OptionBits inOptions
)
1164 memset( &command
, 0 , sizeof(command
) );
1165 command
.commandID
= commandID
;
1166 return SendHICommand( command
, inOptions
);
1169 void wxMacControl::PerformClick()
1171 HIViewSimulateClick (m_controlRef
, kControlButtonPart
, 0, NULL
);
1174 wxInt32
wxMacControl::GetValue() const
1176 return ::GetControl32BitValue( m_controlRef
);
1179 wxInt32
wxMacControl::GetMaximum() const
1181 return ::GetControl32BitMaximum( m_controlRef
);
1184 wxInt32
wxMacControl::GetMinimum() const
1186 return ::GetControl32BitMinimum( m_controlRef
);
1189 void wxMacControl::SetValue( wxInt32 v
)
1191 ::SetControl32BitValue( m_controlRef
, v
);
1194 void wxMacControl::SetMinimum( wxInt32 v
)
1196 ::SetControl32BitMinimum( m_controlRef
, v
);
1199 void wxMacControl::SetMaximum( wxInt32 v
)
1201 ::SetControl32BitMaximum( m_controlRef
, v
);
1204 void wxMacControl::SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
)
1206 ::SetControl32BitMinimum( m_controlRef
, minimum
);
1207 ::SetControl32BitMaximum( m_controlRef
, maximum
);
1208 ::SetControl32BitValue( m_controlRef
, value
);
1211 void wxMacControl::VisibilityChanged(bool WXUNUSED(shown
))
1215 void wxMacControl::SuperChangedPosition()
1219 void wxMacControl::SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
)
1222 #if wxOSX_USE_CORE_TEXT
1223 if ( UMAGetSystemVersion() >= 0x1050 )
1225 HIViewPartCode part
= 0;
1226 HIThemeTextHorizontalFlush flush
= kHIThemeTextHorizontalFlushDefault
;
1227 if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_CENTER_HORIZONTAL
)
1228 flush
= kHIThemeTextHorizontalFlushCenter
;
1229 else if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_RIGHT
)
1230 flush
= kHIThemeTextHorizontalFlushRight
;
1231 HIViewSetTextFont( m_controlRef
, part
, (CTFontRef
) font
.MacGetCTFont() );
1232 HIViewSetTextHorizontalFlush( m_controlRef
, part
, flush
);
1234 if ( foreground
!= *wxBLACK
|| ignoreBlack
== false )
1236 ControlFontStyleRec fontStyle
;
1237 foreground
.GetRGBColor( &fontStyle
.foreColor
);
1238 fontStyle
.flags
= kControlUseForeColorMask
;
1239 ::SetControlFontStyle( m_controlRef
, &fontStyle
);
1243 #if wxOSX_USE_ATSU_TEXT
1244 ControlFontStyleRec fontStyle
;
1245 if ( font
.MacGetThemeFontID() != kThemeCurrentPortFont
)
1247 switch ( font
.MacGetThemeFontID() )
1249 case kThemeSmallSystemFont
:
1250 fontStyle
.font
= kControlFontSmallSystemFont
;
1253 case 109 : // mini font
1254 fontStyle
.font
= -5;
1257 case kThemeSystemFont
:
1258 fontStyle
.font
= kControlFontBigSystemFont
;
1262 fontStyle
.font
= kControlFontBigSystemFont
;
1266 fontStyle
.flags
= kControlUseFontMask
;
1270 fontStyle
.font
= font
.MacGetFontNum();
1271 fontStyle
.style
= font
.MacGetFontStyle();
1272 fontStyle
.size
= font
.MacGetFontSize();
1273 fontStyle
.flags
= kControlUseFontMask
| kControlUseFaceMask
| kControlUseSizeMask
;
1276 fontStyle
.just
= teJustLeft
;
1277 fontStyle
.flags
|= kControlUseJustMask
;
1278 if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_CENTER_HORIZONTAL
)
1279 fontStyle
.just
= teJustCenter
;
1280 else if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_RIGHT
)
1281 fontStyle
.just
= teJustRight
;
1284 // we only should do this in case of a non-standard color, as otherwise 'disabled' controls
1285 // won't get grayed out by the system anymore
1287 if ( foreground
!= *wxBLACK
|| ignoreBlack
== false )
1289 foreground
.GetRGBColor( &fontStyle
.foreColor
);
1290 fontStyle
.flags
|= kControlUseForeColorMask
;
1293 ::SetControlFontStyle( m_controlRef
, &fontStyle
);
1297 void wxMacControl::SetBackgroundColour( const wxColour
&WXUNUSED(col
) )
1299 // HITextViewSetBackgroundColor( m_textView , color );
1302 void wxMacControl::SetRange( SInt32 minimum
, SInt32 maximum
)
1304 ::SetControl32BitMinimum( m_controlRef
, minimum
);
1305 ::SetControl32BitMaximum( m_controlRef
, maximum
);
1308 short wxMacControl::HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
)
1310 return HandleControlKey( m_controlRef
, keyCode
, charCode
, modifiers
);
1313 void wxMacControl::SetActionProc( ControlActionUPP actionProc
)
1315 SetControlAction( m_controlRef
, actionProc
);
1318 SInt32
wxMacControl::GetViewSize() const
1320 return GetControlViewSize( m_controlRef
);
1323 bool wxMacControl::IsVisible() const
1325 return IsControlVisible( m_controlRef
);
1328 void wxMacControl::SetVisibility( bool visible
)
1330 SetControlVisibility( m_controlRef
, visible
, true );
1333 bool wxMacControl::IsEnabled() const
1335 return IsControlEnabled( m_controlRef
);
1338 bool wxMacControl::IsActive() const
1340 return IsControlActive( m_controlRef
);
1343 void wxMacControl::Enable( bool enable
)
1346 EnableControl( m_controlRef
);
1348 DisableControl( m_controlRef
);
1351 void wxMacControl::SetDrawingEnabled( bool enable
)
1353 HIViewSetDrawingEnabled( m_controlRef
, enable
);
1356 void wxMacControl::GetRectInWindowCoords( Rect
*r
)
1358 GetControlBounds( m_controlRef
, r
) ;
1360 WindowRef tlwref
= GetControlOwner( m_controlRef
) ;
1362 wxNonOwnedWindow
* tlwwx
= wxNonOwnedWindow::GetFromWXWindow( (WXWindow
) tlwref
) ;
1363 if ( tlwwx
!= NULL
)
1365 ControlRef rootControl
= tlwwx
->GetPeer()->GetControlRef() ;
1366 HIPoint hiPoint
= CGPointMake( 0 , 0 ) ;
1367 HIViewConvertPoint( &hiPoint
, HIViewGetSuperview(m_controlRef
) , rootControl
) ;
1368 OffsetRect( r
, (short) hiPoint
.x
, (short) hiPoint
.y
) ;
1372 void wxMacControl::GetBestRect( wxRect
*rect
) const
1374 short baselineoffset
;
1377 GetBestControlRect( m_controlRef
, &r
, &baselineoffset
);
1378 *rect
= wxRect( r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
-r
.top
);
1381 void wxMacControl::GetBestRect( Rect
*r
) const
1383 short baselineoffset
;
1384 GetBestControlRect( m_controlRef
, r
, &baselineoffset
);
1387 void wxMacControl::SetLabel( const wxString
&title
, wxFontEncoding encoding
)
1389 SetControlTitleWithCFString( m_controlRef
, wxCFStringRef( title
, encoding
) );
1392 void wxMacControl::GetFeatures( UInt32
* features
)
1394 GetControlFeatures( m_controlRef
, features
);
1397 void wxMacControl::PulseGauge()
1401 // SetNeedsDisplay would not invalidate the children
1402 static void InvalidateControlAndChildren( HIViewRef control
)
1404 HIViewSetNeedsDisplay( control
, true );
1405 UInt16 childrenCount
= 0;
1406 OSStatus err
= CountSubControls( control
, &childrenCount
);
1407 if ( err
== errControlIsNotEmbedder
)
1410 wxASSERT_MSG( err
== noErr
, wxT("Unexpected error when accessing subcontrols") );
1412 for ( UInt16 i
= childrenCount
; i
>=1; --i
)
1416 err
= GetIndexedSubControl( control
, i
, & child
);
1417 if ( err
== errControlIsNotEmbedder
)
1420 InvalidateControlAndChildren( child
);
1424 void wxMacControl::InvalidateWithChildren()
1426 InvalidateControlAndChildren( m_controlRef
);
1429 OSType wxMacCreator
= 'WXMC';
1430 OSType wxMacControlProperty
= 'MCCT';
1432 void wxMacControl::SetReferenceInNativeControl()
1435 verify_noerr( SetControlProperty ( m_controlRef
,
1436 wxMacCreator
,wxMacControlProperty
, sizeof(data
), &data
) );
1439 wxMacControl
* wxMacControl::GetReferenceFromNativeControl(ControlRef control
)
1441 wxMacControl
* ctl
= NULL
;
1442 ByteCount actualSize
;
1443 if ( GetControlProperty( control
,wxMacCreator
,wxMacControlProperty
, sizeof(ctl
) ,
1444 &actualSize
, &ctl
) == noErr
)
1451 void wxMacControl::SetBitmap( const wxBitmap
& WXUNUSED(bmp
) )
1453 // implemented in the respective subclasses
1456 void wxMacControl::SetScrollThumb( wxInt32
WXUNUSED(pos
), wxInt32
WXUNUSED(viewsize
) )
1458 // implemented in respective subclass
1465 OSStatus
wxMacControl::SetTabEnabled( SInt16 tabNo
, bool enable
)
1467 return ::SetTabEnabled( m_controlRef
, tabNo
, enable
);
1474 wxWidgetImplType
* wxWidgetImpl::CreateContentView( wxNonOwnedWindow
* now
)
1476 // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
1477 // the content view, so we have to retrieve it explicitly
1479 wxMacControl
* contentview
= new wxMacControl(now
, true /*isRootControl*/);
1480 HIViewFindByID( HIViewGetRoot( (WindowRef
) now
->GetWXWindow() ) , kHIViewWindowContentID
,
1481 contentview
->GetControlRefAddr() ) ;
1482 if ( !contentview
->IsOk() )
1484 // compatibility mode fallback
1485 GetRootControl( (WindowRef
) now
->GetWXWindow() , contentview
->GetControlRefAddr() ) ;
1488 // the root control level handler
1489 contentview
->InstallEventHandler() ;