1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/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
64 #include "wx/mac/uma.h"
66 #define MAC_SCROLLBAR_SIZE 15
67 #define MAC_SMALL_SCROLLBAR_SIZE 11
71 #ifdef __WXUNIVERSAL__
72 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
74 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
77 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
78 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
79 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
80 EVT_PAINT(wxWindowMac::OnPaint
)
81 EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent
)
84 #define wxMAC_DEBUG_REDRAW 0
85 #ifndef wxMAC_DEBUG_REDRAW
86 #define wxMAC_DEBUG_REDRAW 0
89 // ---------------------------------------------------------------------------
90 // Utility Routines to move between different coordinate systems
91 // ---------------------------------------------------------------------------
94 * Right now we have the following setup :
95 * a border that is not part of the native control is always outside the
96 * control's border (otherwise we loose all native intelligence, future ways
97 * may be to have a second embedding control responsible for drawing borders
98 * and backgrounds eventually)
99 * so all this border calculations have to be taken into account when calling
100 * native methods or getting native oriented data
101 * so we have three coordinate systems here
102 * wx client coordinates
103 * wx window coordinates (including window frames)
108 // originating from native control
112 void wxMacNativeToWindow( const wxWindow
* window
, RgnHandle handle
)
114 OffsetRgn( handle
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
117 void wxMacNativeToWindow( const wxWindow
* window
, Rect
*rect
)
119 OffsetRect( rect
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
123 // directed towards native control
126 void wxMacWindowToNative( const wxWindow
* window
, RgnHandle handle
)
128 OffsetRgn( handle
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() );
131 void wxMacWindowToNative( const wxWindow
* window
, Rect
*rect
)
133 OffsetRect( rect
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() ) ;
136 // ---------------------------------------------------------------------------
138 // ---------------------------------------------------------------------------
140 static const EventTypeSpec eventList
[] =
142 { kEventClassCommand
, kEventProcessCommand
} ,
143 { kEventClassCommand
, kEventCommandUpdateStatus
} ,
145 { kEventClassControl
, kEventControlGetClickActivation
} ,
146 { kEventClassControl
, kEventControlHit
} ,
148 { kEventClassTextInput
, kEventTextInputUnicodeForKeyEvent
} ,
149 { kEventClassTextInput
, kEventTextInputUpdateActiveInputArea
} ,
151 { kEventClassControl
, kEventControlDraw
} ,
153 { kEventClassControl
, kEventControlVisibilityChanged
} ,
154 { kEventClassControl
, kEventControlEnabledStateChanged
} ,
155 { kEventClassControl
, kEventControlHiliteChanged
} ,
157 { kEventClassControl
, kEventControlActivate
} ,
158 { kEventClassControl
, kEventControlDeactivate
} ,
160 { kEventClassControl
, kEventControlSetFocusPart
} ,
161 { kEventClassControl
, kEventControlFocusPartChanged
} ,
163 { kEventClassService
, kEventServiceGetTypes
},
164 { kEventClassService
, kEventServiceCopy
},
165 { kEventClassService
, kEventServicePaste
},
167 // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
168 // { kEventClassControl , kEventControlBoundsChanged } ,
171 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
173 OSStatus result
= eventNotHandledErr
;
175 wxMacCarbonEvent
cEvent( event
) ;
177 ControlRef controlRef
;
178 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
180 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
182 switch ( GetEventKind( event
) )
184 case kEventControlDraw
:
186 RgnHandle updateRgn
= NULL
;
187 RgnHandle allocatedRgn
= NULL
;
188 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
190 if ( cEvent
.GetParameter
<RgnHandle
>(kEventParamRgnHandle
, &updateRgn
) != noErr
)
192 HIShapeGetAsQDRgn( visRegion
.GetWXHRGN(), updateRgn
);
196 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
198 // as this update region is in native window locals we must adapt it to wx window local
199 allocatedRgn
= NewRgn() ;
200 CopyRgn( updateRgn
, allocatedRgn
) ;
202 // hide the given region by the new region that must be shifted
203 wxMacNativeToWindow( thisWindow
, allocatedRgn
) ;
204 updateRgn
= allocatedRgn
;
208 #if wxMAC_DEBUG_REDRAW
209 if ( thisWindow
->MacIsUserPane() )
211 static float color
= 0.5 ;
214 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
216 HIViewGetBounds( controlRef
, &bounds
);
217 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
218 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
219 CGContextFillRect( cgContext
, bounds
);
232 bool created
= false ;
233 CGContextRef cgContext
= NULL
;
234 OSStatus err
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, &cgContext
) ;
237 wxFAIL_MSG("Unable to retrieve CGContextRef");
240 thisWindow
->MacSetCGContextRef( cgContext
) ;
243 wxMacCGContextStateSaver
sg( cgContext
) ;
244 CGFloat alpha
= (CGFloat
)1.0 ;
246 wxWindow
* iter
= thisWindow
;
249 alpha
*= (CGFloat
)( iter
->GetTransparent()/255.0 ) ;
250 if ( iter
->IsTopLevel() )
253 iter
= iter
->GetParent() ;
256 CGContextSetAlpha( cgContext
, alpha
) ;
258 if ( thisWindow
->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT
)
261 HIViewGetBounds( controlRef
, &bounds
);
262 CGContextClearRect( cgContext
, bounds
);
267 if ( thisWindow
->MacDoRedraw( updateRgn
, cEvent
.GetTicks() ) )
270 thisWindow
->MacSetCGContextRef( NULL
) ;
274 CGContextRelease( cgContext
) ;
278 DisposeRgn( allocatedRgn
) ;
282 case kEventControlVisibilityChanged
:
283 // we might have two native controls attributed to the same wxWindow instance
284 // eg a scrollview and an embedded textview, make sure we only fire for the 'outer'
285 // control, as otherwise native and wx visibility are different
286 if ( thisWindow
->GetPeer() != NULL
&& thisWindow
->GetPeer()->GetControlRef() == controlRef
)
288 thisWindow
->MacVisibilityChanged() ;
292 case kEventControlEnabledStateChanged
:
293 thisWindow
->MacEnabledStateChanged();
296 case kEventControlHiliteChanged
:
297 thisWindow
->MacHiliteChanged() ;
300 case kEventControlActivate
:
301 case kEventControlDeactivate
:
302 // FIXME: we should have a virtual function for this!
304 if ( thisWindow
->IsKindOf( CLASSINFO( wxTreeCtrl
) ) )
305 thisWindow
->Refresh();
308 if ( thisWindow
->IsKindOf( CLASSINFO( wxListCtrl
) ) )
309 thisWindow
->Refresh();
315 // different handling on OS X
318 case kEventControlFocusPartChanged
:
319 // the event is emulated by wxmac for systems lower than 10.5
321 ControlPartCode previousControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPreviousPart
, typeControlPartCode
);
322 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlCurrentPart
, typeControlPartCode
);
324 if ( thisWindow
->MacGetTopLevelWindow() && thisWindow
->GetPeer()->NeedsFocusRect() )
326 thisWindow
->MacInvalidateBorders();
329 if ( currentControlPart
== 0 )
333 if ( thisWindow
->GetCaret() )
334 thisWindow
->GetCaret()->OnKillFocus();
337 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow
));
339 // remove this as soon as posting the synthesized event works properly
340 static bool inKillFocusEvent
= false ;
342 if ( !inKillFocusEvent
)
344 inKillFocusEvent
= true ;
345 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
346 event
.SetEventObject(thisWindow
);
347 thisWindow
->HandleWindowEvent(event
) ;
348 inKillFocusEvent
= false ;
351 else if ( previousControlPart
== 0 )
354 // panel wants to track the window which was the last to have focus in it
355 wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow
));
356 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
357 thisWindow
->HandleWindowEvent(eventFocus
);
360 if ( thisWindow
->GetCaret() )
361 thisWindow
->GetCaret()->OnSetFocus();
364 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
365 event
.SetEventObject(thisWindow
);
366 thisWindow
->HandleWindowEvent(event
) ;
370 case kEventControlSetFocusPart
:
373 Boolean focusEverything
= false ;
374 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
376 // put a breakpoint here to catch focus everything events
379 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
381 ControlPartCode previousControlPart
= 0;
382 verify_noerr( HIViewGetFocusPart(controlRef
, &previousControlPart
));
384 if ( thisWindow
->MacIsUserPane() )
386 if ( controlPart
!= kControlFocusNoPart
)
387 cEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPart
, typeControlPartCode
, 1 ) ;
391 result
= CallNextEventHandler(handler
, event
);
393 if ( UMAGetSystemVersion() < 0x1050 )
395 // set back to 0 if problems arise
397 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
398 // synthesize the event focus changed event
399 EventRef evRef
= NULL
;
401 OSStatus err
= MacCreateEvent(
402 NULL
, kEventClassControl
, kEventControlFocusPartChanged
, TicksToEventTime( TickCount() ) ,
403 kEventAttributeUserEvent
, &evRef
);
406 wxMacCarbonEvent
iEvent( evRef
) ;
407 iEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, controlRef
) ;
408 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPreviousPart
, typeControlPartCode
, previousControlPart
) ;
409 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlCurrentPart
, typeControlPartCode
, currentControlPart
) ;
412 // TODO test this first, avoid double posts etc...
413 PostEventToQueue( GetMainEventQueue(), evRef
, kEventPriorityHigh
);
415 wxMacWindowControlEventHandler( NULL
, evRef
, data
) ;
417 ReleaseEvent( evRef
) ;
419 // old implementation, to be removed if the new one works
420 if ( controlPart
== kControlFocusNoPart
)
423 if ( thisWindow
->GetCaret() )
424 thisWindow
->GetCaret()->OnKillFocus();
427 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow
));
429 static bool inKillFocusEvent
= false ;
431 if ( !inKillFocusEvent
)
433 inKillFocusEvent
= true ;
434 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
435 event
.SetEventObject(thisWindow
);
436 thisWindow
->HandleWindowEvent(event
) ;
437 inKillFocusEvent
= false ;
442 // panel wants to track the window which was the last to have focus in it
443 wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow
));
444 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
445 thisWindow
->HandleWindowEvent(eventFocus
);
448 if ( thisWindow
->GetCaret() )
449 thisWindow
->GetCaret()->OnSetFocus();
452 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
453 event
.SetEventObject(thisWindow
);
454 thisWindow
->HandleWindowEvent(event
) ;
461 case kEventControlHit
:
462 result
= thisWindow
->MacControlHit( handler
, event
) ;
465 case kEventControlGetClickActivation
:
467 // fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise)
468 WindowRef owner
= cEvent
.GetParameter
<WindowRef
>(kEventParamWindowRef
);
469 if ( !IsWindowActive(owner
) )
471 cEvent
.SetParameter(kEventParamClickActivation
,(UInt32
) kActivateAndIgnoreClick
) ;
484 static pascal OSStatus
485 wxMacWindowServiceEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
489 OSStatus result
= eventNotHandledErr
;
491 wxMacCarbonEvent
cEvent( event
) ;
493 ControlRef controlRef
;
494 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
495 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
496 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
498 switch ( GetEventKind( event
) )
500 case kEventServiceGetTypes
:
504 textCtrl
->GetSelection( &from
, &to
) ;
506 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
508 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
509 if ( textCtrl
->IsEditable() )
510 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
512 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt', 'PICT', 'MooV', 'AIFF' */ };
513 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
515 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
519 CFArrayAppendValue(copyTypes
, typestring
) ;
521 CFArrayAppendValue(pasteTypes
, typestring
) ;
523 CFRelease( typestring
) ;
531 case kEventServiceCopy
:
536 textCtrl
->GetSelection( &from
, &to
) ;
537 wxString val
= textCtrl
->GetValue() ;
538 val
= val
.Mid( from
, to
- from
) ;
539 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
540 verify_noerr( PasteboardClear( pasteboard
) ) ;
541 PasteboardSynchronize( pasteboard
);
542 // TODO add proper conversion
543 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (const UInt8
*)val
.c_str(), val
.length() );
544 PasteboardPutItemFlavor( pasteboard
, (PasteboardItemID
) 1, CFSTR("com.apple.traditional-mac-plain-text"), data
, 0);
550 case kEventServicePaste
:
553 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
554 PasteboardSynchronize( pasteboard
);
556 verify_noerr( PasteboardGetItemCount( pasteboard
, &itemCount
) );
557 for( UInt32 itemIndex
= 1; itemIndex
<= itemCount
; itemIndex
++ )
559 PasteboardItemID itemID
;
560 if ( PasteboardGetItemIdentifier( pasteboard
, itemIndex
, &itemID
) == noErr
)
562 CFDataRef flavorData
= NULL
;
563 if ( PasteboardCopyItemFlavorData( pasteboard
, itemID
, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData
) == noErr
)
565 CFIndex flavorDataSize
= CFDataGetLength( flavorData
);
566 char *content
= new char[flavorDataSize
+1] ;
567 memcpy( content
, CFDataGetBytePtr( flavorData
), flavorDataSize
);
568 content
[flavorDataSize
]=0;
569 CFRelease( flavorData
);
571 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
573 textCtrl
->WriteText( wxString( content
) ) ;
591 pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
593 OSStatus result
= eventNotHandledErr
;
594 wxWindowMac
* focus
= (wxWindowMac
*) data
;
596 wchar_t* uniChars
= NULL
;
597 UInt32 when
= EventTimeToTicks( GetEventTime( event
) ) ;
599 UniChar
* charBuf
= NULL
;
600 ByteCount dataSize
= 0 ;
603 if ( GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, 0 , &dataSize
, NULL
) == noErr
)
605 numChars
= dataSize
/ sizeof( UniChar
) + 1;
608 if ( (size_t) numChars
* 2 > sizeof(buf
) )
609 charBuf
= new UniChar
[ numChars
] ;
613 uniChars
= new wchar_t[ numChars
] ;
614 GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, dataSize
, NULL
, charBuf
) ;
615 charBuf
[ numChars
- 1 ] = 0;
616 #if SIZEOF_WCHAR_T == 2
617 uniChars
= (wchar_t*) charBuf
;
618 /* 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...)
620 // the resulting string will never have more chars than the utf16 version, so this is safe
621 wxMBConvUTF16 converter
;
622 numChars
= converter
.MB2WC( uniChars
, (const char*)charBuf
, numChars
) ;
626 switch ( GetEventKind( event
) )
628 case kEventTextInputUpdateActiveInputArea
:
630 // An IME input event may return several characters, but we need to send one char at a time to
632 for (int pos
=0 ; pos
< numChars
; pos
++)
634 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
635 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
636 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
638 UInt32 message
= uniChars
[pos
] < 128 ? (char)uniChars
[pos
] : '?';
640 NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent
641 multiple times to update the active range during inline input, so this handler will often receive
642 uncommited text, which should usually not trigger side effects. It might be a good idea to check the
643 kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h).
644 On the other hand, it can be useful for some applications to react to uncommitted text (for example,
645 to update a status display), as long as it does not disrupt the inline input session. Ideally, wx
646 should add new event types to support advanced text input. For now, I would keep things as they are.
648 However, the code that was being used caused additional problems:
649 UInt32 message = (0 << 8) + ((char)uniChars[pos] );
650 Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline
651 input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji
652 for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB
653 (still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D
654 (the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress.
655 Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only
656 overlap with Unicode within the (7-bit) ASCII range.
657 But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks
658 for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII
659 characters as they are and replaces the rest with '?', ensuring that update events are triggered.
660 It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but
661 I don't have time to look into that right now.
664 if ( wxTheApp
->MacSendCharEvent(
665 focus
, message
, 0 , when
, 0 , 0 , uniChars
[pos
] ) )
670 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
674 case kEventTextInputUnicodeForKeyEvent
:
676 UInt32 keyCode
, modifiers
;
679 unsigned char charCode
;
681 GetEventParameter( event
, kEventParamTextInputSendKeyboardEvent
, typeEventRef
, NULL
, sizeof(rawEvent
), NULL
, &rawEvent
) ;
682 GetEventParameter( rawEvent
, kEventParamKeyMacCharCodes
, typeChar
, NULL
, sizeof(char), NULL
, &charCode
);
683 GetEventParameter( rawEvent
, kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
684 GetEventParameter( rawEvent
, kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
685 GetEventParameter( rawEvent
, kEventParamMouseLocation
, typeQDPoint
, NULL
, sizeof(Point
), NULL
, &point
);
687 UInt32 message
= (keyCode
<< 8) + charCode
;
689 // An IME input event may return several characters, but we need to send one char at a time to
691 for (int pos
=0 ; pos
< numChars
; pos
++)
693 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
694 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
695 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
697 if ( wxTheApp
->MacSendCharEvent(
698 focus
, message
, modifiers
, when
, point
.h
, point
.v
, uniChars
[pos
] ) )
703 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
712 if ( charBuf
!= buf
)
718 static pascal OSStatus
719 wxMacWindowCommandEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
723 OSStatus result
= eventNotHandledErr
;
724 wxWindowMac
* focus
= (wxWindowMac
*) data
;
728 wxMacCarbonEvent
cEvent( event
) ;
729 cEvent
.GetParameter
<HICommand
>(kEventParamDirectObject
,typeHICommand
,&command
) ;
731 wxMenuItem
* item
= NULL
;
732 wxMenu
* itemMenu
= wxFindMenuFromMacCommand( command
, item
) ;
733 int id
= wxMacCommandToId( command
.commandID
) ;
737 wxASSERT( itemMenu
!= NULL
) ;
739 switch ( cEvent
.GetKind() )
741 case kEventProcessCommand
:
742 result
= itemMenu
->MacHandleCommandProcess( item
, id
, focus
);
745 case kEventCommandUpdateStatus
:
746 result
= itemMenu
->MacHandleCommandUpdateStatus( item
, id
, focus
);
756 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
758 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
759 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
760 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
761 OSStatus result
= eventNotHandledErr
;
763 switch ( GetEventClass( event
) )
765 case kEventClassCommand
:
766 result
= wxMacWindowCommandEventHandler( handler
, event
, data
) ;
769 case kEventClassControl
:
770 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
773 case kEventClassService
:
774 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
777 case kEventClassTextInput
:
778 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
785 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
790 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
792 // ---------------------------------------------------------------------------
793 // Scrollbar Tracking for all
794 // ---------------------------------------------------------------------------
796 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
797 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
801 wxWindow
* wx
= wxFindControlFromMacControl( control
) ;
803 wx
->MacHandleControlClick( (WXWidget
) control
, partCode
, true /* stillDown */ ) ;
806 wxMAC_DEFINE_PROC_GETTER( ControlActionUPP
, wxMacLiveScrollbarActionProc
) ;
808 // ===========================================================================
810 // ===========================================================================
812 WX_DECLARE_HASH_MAP(ControlRef
, wxWindow
*, wxPointerHash
, wxPointerEqual
, MacControlMap
);
814 static MacControlMap wxWinMacControlList
;
816 wxWindow
*wxFindControlFromMacControl(ControlRef inControl
)
818 MacControlMap::iterator node
= wxWinMacControlList
.find(inControl
);
820 return (node
== wxWinMacControlList
.end()) ? NULL
: node
->second
;
823 void wxAssociateControlWithMacControl(ControlRef inControl
, wxWindow
*control
)
825 // adding NULL ControlRef is (first) surely a result of an error and
826 // (secondly) breaks native event processing
827 wxCHECK_RET( inControl
!= (ControlRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
829 wxWinMacControlList
[inControl
] = control
;
832 void wxRemoveMacControlAssociation(wxWindow
*control
)
834 // iterate over all the elements in the class
835 // is the iterator stable ? as we might have two associations pointing to the same wxWindow
836 // we should go on...
842 MacControlMap::iterator it
;
843 for ( it
= wxWinMacControlList
.begin(); it
!= wxWinMacControlList
.end(); ++it
)
845 if ( it
->second
== control
)
847 wxWinMacControlList
.erase(it
);
855 // ----------------------------------------------------------------------------
856 // constructors and such
857 // ----------------------------------------------------------------------------
859 wxWindowMac::wxWindowMac()
864 wxWindowMac::wxWindowMac(wxWindowMac
*parent
,
869 const wxString
& name
)
872 Create(parent
, id
, pos
, size
, style
, name
);
875 void wxWindowMac::Init()
879 m_cgContextRef
= NULL
;
881 // as all windows are created with WS_VISIBLE style...
884 m_hScrollBar
= NULL
;
885 m_vScrollBar
= NULL
;
886 m_hScrollBarAlwaysShown
= false;
887 m_vScrollBarAlwaysShown
= false;
889 m_macIsUserPane
= true;
890 m_clipChildren
= false ;
891 m_cachedClippedRectValid
= false ;
894 wxWindowMac::~wxWindowMac()
898 m_isBeingDeleted
= true;
900 MacInvalidateBorders() ;
902 #ifndef __WXUNIVERSAL__
903 // VS: make sure there's no wxFrame with last focus set to us:
904 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
906 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
909 if ( frame
->GetLastFocus() == this )
910 frame
->SetLastFocus((wxWindow
*)NULL
);
916 // destroy children before destroying this window itself
919 // wxRemoveMacControlAssociation( this ) ;
920 // If we delete an item, we should initialize the parent panel,
921 // because it could now be invalid.
922 wxTopLevelWindow
*tlw
= wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow
);
925 if ( tlw
->GetDefaultItem() == (wxButton
*) this)
926 tlw
->SetDefaultItem(NULL
);
929 if ( m_peer
&& m_peer
->Ok() )
931 // in case the callback might be called during destruction
932 wxRemoveMacControlAssociation( this) ;
933 ::RemoveEventHandler( (EventHandlerRef
) m_macControlEventHandler
) ;
934 // we currently are not using this hook
935 // ::SetControlColorProc( *m_peer , NULL ) ;
939 if ( g_MacLastWindow
== this )
940 g_MacLastWindow
= NULL
;
942 #ifndef __WXUNIVERSAL__
943 wxFrame
* frame
= wxDynamicCast( wxGetTopLevelParent( (wxWindow
*)this ) , wxFrame
) ;
946 if ( frame
->GetLastFocus() == this )
947 frame
->SetLastFocus( NULL
) ;
951 // delete our drop target if we've got one
952 #if wxUSE_DRAG_AND_DROP
953 if ( m_dropTarget
!= NULL
)
963 WXWidget
wxWindowMac::GetHandle() const
965 return (WXWidget
) m_peer
->GetControlRef() ;
968 void wxWindowMac::MacInstallEventHandler( WXWidget control
)
970 wxAssociateControlWithMacControl( (ControlRef
) control
, this ) ;
971 InstallControlEventHandler( (ControlRef
)control
, GetwxMacWindowEventHandlerUPP(),
972 GetEventTypeCount(eventList
), eventList
, this,
973 (EventHandlerRef
*)&m_macControlEventHandler
);
977 bool wxWindowMac::Create(wxWindowMac
*parent
,
982 const wxString
& name
)
984 wxCHECK_MSG( parent
, false, wxT("can't create wxWindowMac without parent") );
986 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
989 m_windowVariant
= parent
->GetWindowVariant() ;
991 if ( m_macIsUserPane
)
993 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
996 | kControlSupportsEmbedding
997 | kControlSupportsLiveFeedback
998 | kControlGetsFocusOnClick
999 // | kControlHasSpecialBackground
1000 // | kControlSupportsCalcBestRect
1001 | kControlHandlesTracking
1002 | kControlSupportsFocus
1003 | kControlWantsActivate
1004 | kControlWantsIdle
;
1006 m_peer
= new wxMacControl(this) ;
1007 OSStatus err
=::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, m_peer
->GetControlRefAddr() );
1008 verify_noerr( err
);
1010 MacPostControlCreate(pos
, size
) ;
1013 #ifndef __WXUNIVERSAL__
1014 // Don't give scrollbars to wxControls unless they ask for them
1015 if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
)))
1016 || (IsKindOf(CLASSINFO(wxControl
)) && ((style
& wxHSCROLL
) || (style
& wxVSCROLL
))))
1018 MacCreateScrollBars( style
) ;
1022 wxWindowCreateEvent
event(this);
1023 GetEventHandler()->AddPendingEvent(event
);
1028 void wxWindowMac::MacChildAdded()
1031 m_vScrollBar
->Raise() ;
1033 m_hScrollBar
->Raise() ;
1036 void wxWindowMac::MacPostControlCreate(const wxPoint
& WXUNUSED(pos
), const wxSize
& size
)
1038 wxASSERT_MSG( m_peer
!= NULL
&& m_peer
->Ok() , wxT("No valid mac control") ) ;
1040 m_peer
->SetReference( (URefCon
) this ) ;
1041 GetParent()->AddChild( this );
1043 MacInstallEventHandler( (WXWidget
) m_peer
->GetControlRef() );
1045 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
1046 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
1047 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
1048 GetParent()->MacChildAdded() ;
1050 // adjust font, controlsize etc
1051 DoSetWindowVariant( m_windowVariant
) ;
1053 m_peer
->SetLabel( wxStripMenuCodes(m_label
, wxStrip_Mnemonics
) ) ;
1055 if (!m_macIsUserPane
)
1056 SetInitialSize(size
);
1058 SetCursor( *wxSTANDARD_CURSOR
) ;
1061 void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant
)
1063 // Don't assert, in case we set the window variant before
1064 // the window is created
1065 // wxASSERT( m_peer->Ok() ) ;
1067 m_windowVariant
= variant
;
1069 if (m_peer
== NULL
|| !m_peer
->Ok())
1073 ThemeFontID themeFont
= kThemeSystemFont
;
1075 // we will get that from the settings later
1076 // and make this NORMAL later, but first
1077 // we have a few calculations that we must fix
1081 case wxWINDOW_VARIANT_NORMAL
:
1082 size
= kControlSizeNormal
;
1083 themeFont
= kThemeSystemFont
;
1086 case wxWINDOW_VARIANT_SMALL
:
1087 size
= kControlSizeSmall
;
1088 themeFont
= kThemeSmallSystemFont
;
1091 case wxWINDOW_VARIANT_MINI
:
1092 // not always defined in the headers
1097 case wxWINDOW_VARIANT_LARGE
:
1098 size
= kControlSizeLarge
;
1099 themeFont
= kThemeSystemFont
;
1103 wxFAIL_MSG(_T("unexpected window variant"));
1107 m_peer
->SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
, &size
) ;
1110 font
.MacCreateFromThemeFont( themeFont
) ;
1114 void wxWindowMac::MacUpdateControlFont()
1116 m_peer
->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
1117 // do not trigger refreshes upon invisible and possible partly created objects
1118 if ( IsShownOnScreen() )
1122 bool wxWindowMac::SetFont(const wxFont
& font
)
1124 bool retval
= wxWindowBase::SetFont( font
);
1126 MacUpdateControlFont() ;
1131 bool wxWindowMac::SetForegroundColour(const wxColour
& col
)
1133 bool retval
= wxWindowBase::SetForegroundColour( col
);
1136 MacUpdateControlFont();
1141 bool wxWindowMac::SetBackgroundColour(const wxColour
& col
)
1143 if ( !wxWindowBase::SetBackgroundColour(col
) && m_hasBgCol
)
1146 m_peer
->SetBackgroundColour( col
) ;
1151 bool wxWindowMac::MacCanFocus() const
1153 // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
1154 // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning,
1155 // but the value range is nowhere documented
1156 Boolean keyExistsAndHasValidFormat
;
1157 CFIndex fullKeyboardAccess
= CFPreferencesGetAppIntegerValue( CFSTR("AppleKeyboardUIMode" ) ,
1158 kCFPreferencesCurrentApplication
, &keyExistsAndHasValidFormat
);
1160 if ( keyExistsAndHasValidFormat
&& fullKeyboardAccess
> 0 )
1166 UInt32 features
= 0 ;
1167 m_peer
->GetFeatures( &features
) ;
1169 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
1173 void wxWindowMac::SetFocus()
1175 if ( !AcceptsFocus() )
1178 wxWindow
* former
= FindFocus() ;
1179 if ( former
== this )
1182 // as we cannot rely on the control features to find out whether we are in full keyboard mode,
1183 // we can only leave in case of an error
1184 OSStatus err
= m_peer
->SetFocus( kControlFocusNextPart
) ;
1185 if ( err
== errCouldntSetFocus
)
1188 SetUserFocusWindow( (WindowRef
)MacGetTopLevelWindowRef() );
1191 void wxWindowMac::DoCaptureMouse()
1193 wxApp::s_captureWindow
= this ;
1196 wxWindow
* wxWindowBase::GetCapture()
1198 return wxApp::s_captureWindow
;
1201 void wxWindowMac::DoReleaseMouse()
1203 wxApp::s_captureWindow
= NULL
;
1206 #if wxUSE_DRAG_AND_DROP
1208 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
1210 if ( m_dropTarget
!= NULL
)
1211 delete m_dropTarget
;
1213 m_dropTarget
= pDropTarget
;
1214 if ( m_dropTarget
!= NULL
)
1222 // Old-style File Manager Drag & Drop
1223 void wxWindowMac::DragAcceptFiles(bool WXUNUSED(accept
))
1228 // Returns the size of the native control. In the case of the toplevel window
1229 // this is the content area root control
1231 void wxWindowMac::MacGetPositionAndSizeFromControl(int& WXUNUSED(x
),
1234 int& WXUNUSED(h
)) const
1236 wxFAIL_MSG( wxT("Not currently supported") ) ;
1239 // From a wx position / size calculate the appropriate size of the native control
1241 bool wxWindowMac::MacGetBoundsForControl(
1245 int& w
, int& h
, bool adjustOrigin
) const
1247 // the desired size, minus the border pixels gives the correct size of the control
1251 // TODO: the default calls may be used as soon as PostCreateControl Is moved here
1252 w
= wxMax(size
.x
, 0) ; // WidthDefault( size.x );
1253 h
= wxMax(size
.y
, 0) ; // HeightDefault( size.y ) ;
1255 x
+= MacGetLeftBorderSize() ;
1256 y
+= MacGetTopBorderSize() ;
1257 w
-= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1258 h
-= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1261 AdjustForParentClientOrigin( x
, y
) ;
1263 // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
1264 if ( !GetParent()->IsTopLevel() )
1266 x
-= GetParent()->MacGetLeftBorderSize() ;
1267 y
-= GetParent()->MacGetTopBorderSize() ;
1273 // Get window size (not client size)
1274 void wxWindowMac::DoGetSize(int *x
, int *y
) const
1277 m_peer
->GetRect( &bounds
) ;
1280 *x
= bounds
.right
- bounds
.left
+ MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1282 *y
= bounds
.bottom
- bounds
.top
+ MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1285 // get the position of the bounds of this window in client coordinates of its parent
1286 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
1289 m_peer
->GetRect( &bounds
) ;
1291 int x1
= bounds
.left
;
1292 int y1
= bounds
.top
;
1294 // get the wx window position from the native one
1295 x1
-= MacGetLeftBorderSize() ;
1296 y1
-= MacGetTopBorderSize() ;
1298 if ( !IsTopLevel() )
1300 wxWindow
*parent
= GetParent();
1303 // we must first adjust it to be in window coordinates of the parent,
1304 // as otherwise it gets lost by the ClientAreaOrigin fix
1305 x1
+= parent
->MacGetLeftBorderSize() ;
1306 y1
+= parent
->MacGetTopBorderSize() ;
1308 // and now to client coordinates
1309 wxPoint
pt(parent
->GetClientAreaOrigin());
1321 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
1323 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1324 wxCHECK_RET( window
, wxT("TopLevel Window missing") ) ;
1326 Point localwhere
= { 0, 0 } ;
1333 wxMacGlobalToLocal( window
, &localwhere
) ;
1340 MacRootWindowToWindow( x
, y
) ;
1342 wxPoint origin
= GetClientAreaOrigin() ;
1349 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
1351 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1352 wxCHECK_RET( window
, wxT("TopLevel window missing") ) ;
1354 wxPoint origin
= GetClientAreaOrigin() ;
1360 MacWindowToRootWindow( x
, y
) ;
1362 Point localwhere
= { 0, 0 };
1368 wxMacLocalToGlobal( window
, &localwhere
) ;
1376 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
1378 wxPoint origin
= GetClientAreaOrigin() ;
1384 MacWindowToRootWindow( x
, y
) ;
1387 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
1389 MacRootWindowToWindow( x
, y
) ;
1391 wxPoint origin
= GetClientAreaOrigin() ;
1398 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
1407 if ( !IsTopLevel() )
1409 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
1412 pt
.x
-= MacGetLeftBorderSize() ;
1413 pt
.y
-= MacGetTopBorderSize() ;
1414 wxMacControl::Convert( &pt
, m_peer
, top
->m_peer
) ;
1424 void wxWindowMac::MacWindowToRootWindow( short *x
, short *y
) const
1433 MacWindowToRootWindow( &x1
, &y1
) ;
1441 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
1450 if ( !IsTopLevel() )
1452 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
1455 wxMacControl::Convert( &pt
, top
->m_peer
, m_peer
) ;
1456 pt
.x
+= MacGetLeftBorderSize() ;
1457 pt
.y
+= MacGetTopBorderSize() ;
1467 void wxWindowMac::MacRootWindowToWindow( short *x
, short *y
) const
1476 MacRootWindowToWindow( &x1
, &y1
) ;
1484 void wxWindowMac::MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
)
1486 RgnHandle rgn
= NewRgn() ;
1488 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1490 Rect structure
, content
;
1492 GetRegionBounds( rgn
, &content
) ;
1493 m_peer
->GetRect( &structure
) ;
1494 OffsetRect( &structure
, -structure
.left
, -structure
.top
) ;
1496 left
= content
.left
- structure
.left
;
1497 top
= content
.top
- structure
.top
;
1498 right
= structure
.right
- content
.right
;
1499 bottom
= structure
.bottom
- content
.bottom
;
1503 left
= top
= right
= bottom
= 0 ;
1509 wxSize
wxWindowMac::DoGetSizeFromClientSize( const wxSize
& size
) const
1511 wxSize sizeTotal
= size
;
1513 RgnHandle rgn
= NewRgn() ;
1514 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1516 Rect content
, structure
;
1517 GetRegionBounds( rgn
, &content
) ;
1518 m_peer
->GetRect( &structure
) ;
1520 // structure is in parent coordinates, but we only need width and height, so it's ok
1522 sizeTotal
.x
+= (structure
.right
- structure
.left
) - (content
.right
- content
.left
) ;
1523 sizeTotal
.y
+= (structure
.bottom
- structure
.top
) - (content
.bottom
- content
.top
) ;
1528 sizeTotal
.x
+= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1529 sizeTotal
.y
+= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1534 // Get size *available for subwindows* i.e. excluding menu bar etc.
1535 void wxWindowMac::DoGetClientSize( int *x
, int *y
) const
1539 RgnHandle rgn
= NewRgn() ;
1541 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1542 GetRegionBounds( rgn
, &content
) ;
1544 m_peer
->GetRect( &content
) ;
1547 ww
= content
.right
- content
.left
;
1548 hh
= content
.bottom
- content
.top
;
1550 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
1551 hh
-= m_hScrollBar
->GetSize().y
;
1553 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
1554 ww
-= m_vScrollBar
->GetSize().x
;
1562 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
1564 if (m_cursor
.IsSameAs(cursor
))
1569 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
1574 if ( ! wxWindowBase::SetCursor( cursor
) )
1578 wxASSERT_MSG( m_cursor
.Ok(),
1579 wxT("cursor must be valid after call to the base version"));
1581 wxWindowMac
*mouseWin
= 0 ;
1583 wxTopLevelWindowMac
*tlw
= MacGetTopLevelWindow() ;
1584 WindowRef window
= (WindowRef
) ( tlw
? tlw
->MacGetWindowRef() : 0 ) ;
1586 ControlPartCode part
;
1587 ControlRef control
;
1589 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
1591 HIGetMousePosition(kHICoordSpaceWindow
, window
, &hiPoint
);
1595 GetGlobalMouse( &pt
);
1598 ScreenToClient(&x
, &y
);
1602 control
= FindControlUnderMouse( pt
, window
, &part
) ;
1604 mouseWin
= wxFindControlFromMacControl( control
) ;
1608 if ( mouseWin
== this && !wxIsBusy() )
1609 m_cursor
.MacInstall() ;
1615 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
1617 #ifndef __WXUNIVERSAL__
1618 menu
->SetInvokingWindow((wxWindow
*)this);
1621 if ( x
== wxDefaultCoord
&& y
== wxDefaultCoord
)
1623 wxPoint mouse
= wxGetMousePosition();
1629 ClientToScreen( &x
, &y
) ;
1632 menu
->MacBeforeDisplay( true ) ;
1633 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() , y
, x
, 0) ;
1634 if ( HiWord(menuResult
) != 0 )
1637 GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult
)) , LoWord(menuResult
) , &macid
);
1638 int id
= wxMacCommandToId( macid
);
1639 wxMenuItem
* item
= NULL
;
1641 item
= menu
->FindItem( id
, &realmenu
) ;
1644 if (item
->IsCheckable())
1645 item
->Check( !item
->IsChecked() ) ;
1647 menu
->SendEvent( id
, item
->IsCheckable() ? item
->IsChecked() : -1 ) ;
1651 menu
->MacAfterDisplay( true ) ;
1652 menu
->SetInvokingWindow( NULL
);
1656 // actually this shouldn't be called, because universal is having its own implementation
1662 // ----------------------------------------------------------------------------
1664 // ----------------------------------------------------------------------------
1668 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
1670 wxWindowBase::DoSetToolTip(tooltip
);
1673 m_tooltip
->SetWindow(this);
1678 void wxWindowMac::MacInvalidateBorders()
1680 if ( m_peer
== NULL
)
1683 bool vis
= IsShownOnScreen() ;
1687 int outerBorder
= MacGetLeftBorderSize() ;
1688 if ( m_peer
->NeedsFocusRect() /* && m_peer->HasFocus() */ )
1691 if ( outerBorder
== 0 )
1694 // now we know that we have something to do at all
1696 // as the borders are drawn on the parent we have to properly invalidate all these areas
1697 RgnHandle updateInner
, updateOuter
;
1700 // this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon
1701 updateInner
= NewRgn() ;
1702 updateOuter
= NewRgn() ;
1704 m_peer
->GetRect( &rect
) ;
1705 RectRgn( updateInner
, &rect
) ;
1706 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
1707 RectRgn( updateOuter
, &rect
) ;
1708 DiffRgn( updateOuter
, updateInner
, updateOuter
) ;
1710 GetParent()->m_peer
->SetNeedsDisplay( updateOuter
) ;
1712 DisposeRgn( updateOuter
) ;
1713 DisposeRgn( updateInner
) ;
1716 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
1718 // this is never called for a toplevel window, so we know we have a parent
1719 int former_x
, former_y
, former_w
, former_h
;
1721 // Get true coordinates of former position
1722 DoGetPosition( &former_x
, &former_y
) ;
1723 DoGetSize( &former_w
, &former_h
) ;
1725 wxWindow
*parent
= GetParent();
1728 wxPoint
pt(parent
->GetClientAreaOrigin());
1733 int actualWidth
= width
;
1734 int actualHeight
= height
;
1738 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
1739 actualWidth
= m_minWidth
;
1740 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
1741 actualHeight
= m_minHeight
;
1742 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
1743 actualWidth
= m_maxWidth
;
1744 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
1745 actualHeight
= m_maxHeight
;
1747 bool doMove
= false, doResize
= false ;
1749 if ( actualX
!= former_x
|| actualY
!= former_y
)
1752 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
1755 if ( doMove
|| doResize
)
1757 // as the borders are drawn outside the native control, we adjust now
1759 wxRect
bounds( wxPoint( actualX
+ MacGetLeftBorderSize() ,actualY
+ MacGetTopBorderSize() ),
1760 wxSize( actualWidth
- (MacGetLeftBorderSize() + MacGetRightBorderSize()) ,
1761 actualHeight
- (MacGetTopBorderSize() + MacGetBottomBorderSize()) ) ) ;
1764 wxMacRectToNative( &bounds
, &r
) ;
1766 if ( !GetParent()->IsTopLevel() )
1767 wxMacWindowToNative( GetParent() , &r
) ;
1769 MacInvalidateBorders() ;
1771 m_cachedClippedRectValid
= false ;
1772 m_peer
->SetRect( &r
) ;
1774 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
1776 MacInvalidateBorders() ;
1778 MacRepositionScrollBars() ;
1781 wxPoint
point(actualX
, actualY
);
1782 wxMoveEvent
event(point
, m_windowId
);
1783 event
.SetEventObject(this);
1784 HandleWindowEvent(event
) ;
1789 MacRepositionScrollBars() ;
1790 wxSize
size(actualWidth
, actualHeight
);
1791 wxSizeEvent
event(size
, m_windowId
);
1792 event
.SetEventObject(this);
1793 HandleWindowEvent(event
);
1798 wxSize
wxWindowMac::DoGetBestSize() const
1800 if ( m_macIsUserPane
|| IsTopLevel() )
1801 return wxWindowBase::DoGetBestSize() ;
1803 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
1804 int bestWidth
, bestHeight
;
1806 m_peer
->GetBestRect( &bestsize
) ;
1807 if ( EmptyRect( &bestsize
) )
1812 bestsize
.bottom
= 16 ;
1814 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
1816 bestsize
.bottom
= 16 ;
1819 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
1821 bestsize
.bottom
= 24 ;
1826 // return wxWindowBase::DoGetBestSize() ;
1830 bestWidth
= bestsize
.right
- bestsize
.left
;
1831 bestHeight
= bestsize
.bottom
- bestsize
.top
;
1832 if ( bestHeight
< 10 )
1835 return wxSize(bestWidth
, bestHeight
);
1838 // set the size of the window: if the dimensions are positive, just use them,
1839 // but if any of them is equal to -1, it means that we must find the value for
1840 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1841 // which case -1 is a valid value for x and y)
1843 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1844 // the width/height to best suit our contents, otherwise we reuse the current
1846 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1848 // get the current size and position...
1849 int currentX
, currentY
;
1850 int currentW
, currentH
;
1852 GetPosition(¤tX
, ¤tY
);
1853 GetSize(¤tW
, ¤tH
);
1855 // ... and don't do anything (avoiding flicker) if it's already ok
1856 if ( x
== currentX
&& y
== currentY
&&
1857 width
== currentW
&& height
== currentH
&& ( height
!= -1 && width
!= -1 ) )
1860 MacRepositionScrollBars() ; // we might have a real position shift
1865 if ( !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1867 if ( x
== wxDefaultCoord
)
1869 if ( y
== wxDefaultCoord
)
1873 AdjustForParentClientOrigin( x
, y
, sizeFlags
);
1875 wxSize size
= wxDefaultSize
;
1876 if ( width
== wxDefaultCoord
)
1878 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
1880 size
= DoGetBestSize();
1885 // just take the current one
1890 if ( height
== wxDefaultCoord
)
1892 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
1894 if ( size
.x
== wxDefaultCoord
)
1895 size
= DoGetBestSize();
1896 // else: already called DoGetBestSize() above
1902 // just take the current one
1907 DoMoveWindow( x
, y
, width
, height
);
1910 wxPoint
wxWindowMac::GetClientAreaOrigin() const
1912 RgnHandle rgn
= NewRgn() ;
1914 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1916 GetRegionBounds( rgn
, &content
) ;
1926 return wxPoint( content
.left
+ MacGetLeftBorderSize() , content
.top
+ MacGetTopBorderSize() );
1929 void wxWindowMac::DoSetClientSize(int clientwidth
, int clientheight
)
1931 if ( clientwidth
!= wxDefaultCoord
|| clientheight
!= wxDefaultCoord
)
1933 int currentclientwidth
, currentclientheight
;
1934 int currentwidth
, currentheight
;
1936 GetClientSize( ¤tclientwidth
, ¤tclientheight
) ;
1937 GetSize( ¤twidth
, ¤theight
) ;
1939 DoSetSize( wxDefaultCoord
, wxDefaultCoord
, currentwidth
+ clientwidth
- currentclientwidth
,
1940 currentheight
+ clientheight
- currentclientheight
, wxSIZE_USE_EXISTING
) ;
1944 void wxWindowMac::SetLabel(const wxString
& title
)
1948 if ( m_peer
&& m_peer
->Ok() )
1949 m_peer
->SetLabel( wxStripMenuCodes(m_label
, wxStrip_Mnemonics
) ) ;
1951 // do not trigger refreshes upon invisible and possible partly created objects
1952 if ( IsShownOnScreen() )
1956 wxString
wxWindowMac::GetLabel() const
1961 bool wxWindowMac::Show(bool show
)
1963 if ( !wxWindowBase::Show(show
) )
1967 m_peer
->SetVisibility( show
, true ) ;
1972 void wxWindowMac::DoEnable(bool enable
)
1974 m_peer
->Enable( enable
) ;
1978 // status change notifications
1981 void wxWindowMac::MacVisibilityChanged()
1985 void wxWindowMac::MacHiliteChanged()
1989 void wxWindowMac::MacEnabledStateChanged()
1991 OnEnabled( m_peer
->IsEnabled() );
1995 // status queries on the inherited window's state
1998 bool wxWindowMac::MacIsReallyEnabled()
2000 return m_peer
->IsEnabled() ;
2003 bool wxWindowMac::MacIsReallyHilited()
2005 return m_peer
->IsActive();
2008 void wxWindowMac::MacFlashInvalidAreas()
2010 #if TARGET_API_MAC_OSX
2011 HIViewFlashDirtyArea( (WindowRef
) MacGetTopLevelWindowRef() ) ;
2015 int wxWindowMac::GetCharHeight() const
2017 wxClientDC
dc( (wxWindowMac
*)this ) ;
2019 return dc
.GetCharHeight() ;
2022 int wxWindowMac::GetCharWidth() const
2024 wxClientDC
dc( (wxWindowMac
*)this ) ;
2026 return dc
.GetCharWidth() ;
2029 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
2030 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
2032 const wxFont
*fontToUse
= theFont
;
2034 fontToUse
= &m_font
;
2036 wxClientDC
dc( (wxWindowMac
*) this ) ;
2037 wxCoord lx
,ly
,ld
,le
;
2038 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
2039 if ( externalLeading
)
2040 *externalLeading
= le
;
2050 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
2051 * we always intersect with the entire window, not only with the client area
2054 void wxWindowMac::Refresh(bool WXUNUSED(eraseBack
), const wxRect
*rect
)
2056 if ( m_peer
== NULL
)
2059 if ( !IsShownOnScreen() )
2066 wxMacRectToNative( rect
, &r
) ;
2067 m_peer
->SetNeedsDisplay( &r
) ;
2071 m_peer
->SetNeedsDisplay() ;
2075 void wxWindowMac::DoFreeze()
2077 #if TARGET_API_MAC_OSX
2078 if ( m_peer
&& m_peer
->Ok() )
2079 m_peer
->SetDrawingEnabled( false ) ;
2083 void wxWindowMac::DoThaw()
2085 #if TARGET_API_MAC_OSX
2086 if ( m_peer
&& m_peer
->Ok() )
2088 m_peer
->SetDrawingEnabled( true ) ;
2089 m_peer
->InvalidateWithChildren() ;
2094 wxWindowMac
*wxGetActiveWindow()
2096 // actually this is a windows-only concept
2100 // Coordinates relative to the window
2101 void wxWindowMac::WarpPointer(int WXUNUSED(x_pos
), int WXUNUSED(y_pos
))
2103 // We really don't move the mouse programmatically under Mac.
2106 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
2108 if ( MacGetTopLevelWindow() == NULL
)
2111 #if TARGET_API_MAC_OSX
2112 if ( !m_backgroundColour.Ok() || GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
2118 if ( GetBackgroundStyle() == wxBG_STYLE_COLOUR
)
2120 event
.GetDC()->Clear() ;
2122 else if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM
)
2124 // don't skip the event here, custom background means that the app
2125 // is drawing it itself in its OnPaint(), so don't draw it at all
2126 // now to avoid flicker
2134 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
2139 int wxWindowMac::GetScrollPos(int orient
) const
2141 if ( orient
== wxHORIZONTAL
)
2144 return m_hScrollBar
->GetThumbPosition() ;
2149 return m_vScrollBar
->GetThumbPosition() ;
2155 // This now returns the whole range, not just the number
2156 // of positions that we can scroll.
2157 int wxWindowMac::GetScrollRange(int orient
) const
2159 if ( orient
== wxHORIZONTAL
)
2162 return m_hScrollBar
->GetRange() ;
2167 return m_vScrollBar
->GetRange() ;
2173 int wxWindowMac::GetScrollThumb(int orient
) const
2175 if ( orient
== wxHORIZONTAL
)
2178 return m_hScrollBar
->GetThumbSize() ;
2183 return m_vScrollBar
->GetThumbSize() ;
2189 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool WXUNUSED(refresh
))
2191 if ( orient
== wxHORIZONTAL
)
2194 m_hScrollBar
->SetThumbPosition( pos
) ;
2199 m_vScrollBar
->SetThumbPosition( pos
) ;
2204 wxWindowMac::AlwaysShowScrollbars(bool hflag
, bool vflag
)
2206 bool needVisibilityUpdate
= false;
2208 if ( m_hScrollBarAlwaysShown
!= hflag
)
2210 m_hScrollBarAlwaysShown
= hflag
;
2211 needVisibilityUpdate
= true;
2214 if ( m_vScrollBarAlwaysShown
!= vflag
)
2216 m_vScrollBarAlwaysShown
= vflag
;
2217 needVisibilityUpdate
= true;
2220 if ( needVisibilityUpdate
)
2221 DoUpdateScrollbarVisibility();
2225 // we draw borders and grow boxes, are already set up and clipped in the current port / cgContextRef
2226 // our own window origin is at leftOrigin/rightOrigin
2229 void wxWindowMac::MacPaintGrowBox()
2234 if ( MacHasScrollBarCorner() )
2238 CGContextRef cgContext
= (CGContextRef
) MacGetCGContextRef() ;
2239 wxASSERT( cgContext
) ;
2241 m_peer
->GetRect( &rect
) ;
2243 int size
= m_hScrollBar
? m_hScrollBar
->GetSize().y
: ( m_vScrollBar
? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2244 CGRect cgrect
= CGRectMake( rect
.right
- size
, rect
.bottom
- size
, size
, size
) ;
2245 CGPoint cgpoint
= CGPointMake( rect
.right
- size
, rect
.bottom
- size
) ;
2246 CGContextSaveGState( cgContext
);
2248 if ( m_backgroundColour
.Ok() )
2250 CGContextSetFillColorWithColor( cgContext
, m_backgroundColour
.GetCGColor() );
2254 CGContextSetRGBFillColor( cgContext
, (CGFloat
) 1.0, (CGFloat
)1.0 ,(CGFloat
) 1.0 , (CGFloat
)1.0 );
2256 CGContextFillRect( cgContext
, cgrect
);
2257 CGContextRestoreGState( cgContext
);
2261 void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin
) , int WXUNUSED(rightOrigin
) )
2267 bool hasFocus
= m_peer
->NeedsFocusRect() && m_peer
->HasFocus() ;
2269 // back to the surrounding frame rectangle
2270 m_peer
->GetRect( &rect
) ;
2271 InsetRect( &rect
, -1 , -1 ) ;
2274 CGRect cgrect
= CGRectMake( rect
.left
, rect
.top
, rect
.right
- rect
.left
,
2275 rect
.bottom
- rect
.top
) ;
2277 HIThemeFrameDrawInfo info
;
2278 memset( &info
, 0 , sizeof(info
) ) ;
2282 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
2283 info
.isFocused
= hasFocus
;
2285 CGContextRef cgContext
= (CGContextRef
) GetParent()->MacGetCGContextRef() ;
2286 wxASSERT( cgContext
) ;
2288 if ( HasFlag(wxRAISED_BORDER
) || HasFlag(wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
2290 info
.kind
= kHIThemeFrameTextFieldSquare
;
2291 HIThemeDrawFrame( &cgrect
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2293 else if ( HasFlag(wxSIMPLE_BORDER
) )
2295 info
.kind
= kHIThemeFrameListBox
;
2296 HIThemeDrawFrame( &cgrect
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2298 else if ( hasFocus
)
2300 HIThemeDrawFocusRect( &cgrect
, true , cgContext
, kHIThemeOrientationNormal
) ;
2302 #if 0 // TODO REMOVE now done in a separate call earlier in drawing the window itself
2303 m_peer
->GetRect( &rect
) ;
2304 if ( MacHasScrollBarCorner() )
2306 int variant
= (m_hScrollBar
== NULL
? m_vScrollBar
: m_hScrollBar
) ->GetWindowVariant();
2307 int size
= m_hScrollBar
? m_hScrollBar
->GetSize().y
: ( m_vScrollBar
? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2308 CGRect cgrect
= CGRectMake( rect
.right
- size
, rect
.bottom
- size
, size
, size
) ;
2309 CGPoint cgpoint
= CGPointMake( rect
.right
- size
, rect
.bottom
- size
) ;
2310 HIThemeGrowBoxDrawInfo info
;
2311 memset( &info
, 0, sizeof(info
) ) ;
2313 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
2314 info
.kind
= kHIThemeGrowBoxKindNone
;
2315 // contrary to the docs ...SizeSmall does not work
2316 info
.size
= kHIThemeGrowBoxSizeNormal
;
2317 info
.direction
= 0 ;
2318 HIThemeDrawGrowBox( &cgpoint
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2324 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
2326 if ( child
== m_hScrollBar
)
2327 m_hScrollBar
= NULL
;
2328 if ( child
== m_vScrollBar
)
2329 m_vScrollBar
= NULL
;
2331 wxWindowBase::RemoveChild( child
) ;
2334 void wxWindowMac::DoUpdateScrollbarVisibility()
2336 bool triggerSizeEvent
= false;
2340 bool showHScrollBar
= m_hScrollBarAlwaysShown
|| m_hScrollBar
->IsNeeded();
2342 if ( m_hScrollBar
->IsShown() != showHScrollBar
)
2344 m_hScrollBar
->Show( showHScrollBar
);
2345 triggerSizeEvent
= true;
2351 bool showVScrollBar
= m_vScrollBarAlwaysShown
|| m_vScrollBar
->IsNeeded();
2353 if ( m_vScrollBar
->IsShown() != showVScrollBar
)
2355 m_vScrollBar
->Show( showVScrollBar
) ;
2356 triggerSizeEvent
= true;
2360 MacRepositionScrollBars() ;
2361 if ( triggerSizeEvent
)
2363 wxSizeEvent
event(GetSize(), m_windowId
);
2364 event
.SetEventObject(this);
2365 HandleWindowEvent(event
);
2369 // New function that will replace some of the above.
2370 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumb
,
2371 int range
, bool refresh
)
2373 if ( orient
== wxHORIZONTAL
&& m_hScrollBar
)
2374 m_hScrollBar
->SetScrollbar(pos
, thumb
, range
, thumb
, refresh
);
2375 else if ( orient
== wxVERTICAL
&& m_vScrollBar
)
2376 m_vScrollBar
->SetScrollbar(pos
, thumb
, range
, thumb
, refresh
);
2378 DoUpdateScrollbarVisibility();
2381 // Does a physical scroll
2382 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
2384 if ( dx
== 0 && dy
== 0 )
2387 int width
, height
;
2388 GetClientSize( &width
, &height
) ;
2391 // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
2392 // area is scrolled, this does not occur if width and height are 2 pixels less,
2393 // TODO: write optimal workaround
2394 wxRect
scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width
, height
) ;
2396 scrollrect
.Intersect( *rect
) ;
2398 if ( m_peer
->GetNeedsDisplay() )
2400 // because HIViewScrollRect does not scroll the already invalidated area we have two options:
2401 // in case there is already a pending redraw on that area
2402 // either immediate redraw or full invalidate
2404 // is the better overall solution, as it does not slow down scrolling
2405 m_peer
->SetNeedsDisplay() ;
2407 // this would be the preferred version for fast drawing controls
2408 HIViewRender(m_peer
->GetControlRef()) ;
2412 // as the native control might be not a 0/0 wx window coordinates, we have to offset
2413 scrollrect
.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2414 m_peer
->ScrollRect( &scrollrect
, dx
, dy
) ;
2417 // this would be the preferred version for fast drawing controls
2418 HIViewRender(m_peer
->GetControlRef()) ;
2424 for (wxWindowList::compatibility_iterator node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2426 child
= node
->GetData();
2429 if (child
== m_vScrollBar
)
2431 if (child
== m_hScrollBar
)
2433 if (child
->IsTopLevel())
2436 child
->GetPosition( &x
, &y
);
2437 child
->GetSize( &w
, &h
);
2440 wxRect
rc( x
, y
, w
, h
);
2441 if (rect
->Intersects( rc
))
2442 child
->SetSize( x
+ dx
, y
+ dy
, w
, h
, wxSIZE_AUTO
|wxSIZE_ALLOW_MINUS_ONE
);
2446 child
->SetSize( x
+ dx
, y
+ dy
, w
, h
, wxSIZE_AUTO
|wxSIZE_ALLOW_MINUS_ONE
);
2451 void wxWindowMac::MacOnScroll( wxScrollEvent
&event
)
2453 if ( event
.GetEventObject() == m_vScrollBar
|| event
.GetEventObject() == m_hScrollBar
)
2455 wxScrollWinEvent wevent
;
2456 wevent
.SetPosition(event
.GetPosition());
2457 wevent
.SetOrientation(event
.GetOrientation());
2458 wevent
.SetEventObject(this);
2460 if (event
.GetEventType() == wxEVT_SCROLL_TOP
)
2461 wevent
.SetEventType( wxEVT_SCROLLWIN_TOP
);
2462 else if (event
.GetEventType() == wxEVT_SCROLL_BOTTOM
)
2463 wevent
.SetEventType( wxEVT_SCROLLWIN_BOTTOM
);
2464 else if (event
.GetEventType() == wxEVT_SCROLL_LINEUP
)
2465 wevent
.SetEventType( wxEVT_SCROLLWIN_LINEUP
);
2466 else if (event
.GetEventType() == wxEVT_SCROLL_LINEDOWN
)
2467 wevent
.SetEventType( wxEVT_SCROLLWIN_LINEDOWN
);
2468 else if (event
.GetEventType() == wxEVT_SCROLL_PAGEUP
)
2469 wevent
.SetEventType( wxEVT_SCROLLWIN_PAGEUP
);
2470 else if (event
.GetEventType() == wxEVT_SCROLL_PAGEDOWN
)
2471 wevent
.SetEventType( wxEVT_SCROLLWIN_PAGEDOWN
);
2472 else if (event
.GetEventType() == wxEVT_SCROLL_THUMBTRACK
)
2473 wevent
.SetEventType( wxEVT_SCROLLWIN_THUMBTRACK
);
2474 else if (event
.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
)
2475 wevent
.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE
);
2477 HandleWindowEvent(wevent
);
2481 // Get the window with the focus
2482 wxWindowMac
*wxWindowBase::DoFindFocus()
2484 ControlRef control
;
2485 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
2486 return wxFindControlFromMacControl( control
) ;
2489 void wxWindowMac::OnInternalIdle()
2491 // This calls the UI-update mechanism (querying windows for
2492 // menu/toolbar/control state information)
2493 if (wxUpdateUIEvent::CanUpdate(this) && IsShownOnScreen())
2494 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
2497 // Raise the window to the top of the Z order
2498 void wxWindowMac::Raise()
2500 m_peer
->SetZOrder( true , NULL
) ;
2503 // Lower the window to the bottom of the Z order
2504 void wxWindowMac::Lower()
2506 m_peer
->SetZOrder( false , NULL
) ;
2509 // static wxWindow *gs_lastWhich = NULL;
2511 bool wxWindowMac::MacSetupCursor( const wxPoint
& pt
)
2513 // first trigger a set cursor event
2515 wxPoint clientorigin
= GetClientAreaOrigin() ;
2516 wxSize clientsize
= GetClientSize() ;
2518 if ( wxRect2DInt( clientorigin
.x
, clientorigin
.y
, clientsize
.x
, clientsize
.y
).Contains( wxPoint2DInt( pt
) ) )
2520 wxSetCursorEvent
event( pt
.x
, pt
.y
);
2522 bool processedEvtSetCursor
= HandleWindowEvent(event
);
2523 if ( processedEvtSetCursor
&& event
.HasCursor() )
2525 cursor
= event
.GetCursor() ;
2529 // the test for processedEvtSetCursor is here to prevent using m_cursor
2530 // if the user code caught EVT_SET_CURSOR() and returned nothing from
2531 // it - this is a way to say that our cursor shouldn't be used for this
2533 if ( !processedEvtSetCursor
&& m_cursor
.Ok() )
2536 if ( !wxIsBusy() && !GetParent() )
2537 cursor
= *wxSTANDARD_CURSOR
;
2541 cursor
.MacInstall() ;
2544 return cursor
.Ok() ;
2547 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&WXUNUSED(pt
) )
2551 return m_tooltip
->GetTip() ;
2554 return wxEmptyString
;
2557 void wxWindowMac::ClearBackground()
2563 void wxWindowMac::Update()
2565 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
2567 top
->MacPerformUpdates() ;
2570 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
2572 wxTopLevelWindowMac
* win
= NULL
;
2573 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
2575 win
= wxFindWinFromMacWindow( window
) ;
2580 const wxRect
& wxWindowMac::MacGetClippedClientRect() const
2582 MacUpdateClippedRects() ;
2584 return m_cachedClippedClientRect
;
2587 const wxRect
& wxWindowMac::MacGetClippedRect() const
2589 MacUpdateClippedRects() ;
2591 return m_cachedClippedRect
;
2594 const wxRect
&wxWindowMac:: MacGetClippedRectWithOuterStructure() const
2596 MacUpdateClippedRects() ;
2598 return m_cachedClippedRectWithOuterStructure
;
2601 const wxRegion
& wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures
)
2603 static wxRegion emptyrgn
;
2605 if ( !m_isBeingDeleted
&& IsShownOnScreen() )
2607 MacUpdateClippedRects() ;
2608 if ( includeOuterStructures
)
2609 return m_cachedClippedRegionWithOuterStructure
;
2611 return m_cachedClippedRegion
;
2619 void wxWindowMac::MacUpdateClippedRects() const
2621 if ( m_cachedClippedRectValid
)
2624 // includeOuterStructures is true if we try to draw somthing like a focus ring etc.
2625 // also a window dc uses this, in this case we only clip in the hierarchy for hard
2626 // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
2627 // to add focus borders everywhere
2629 Rect r
, rIncludingOuterStructures
;
2631 m_peer
->GetRect( &r
) ;
2632 r
.left
-= MacGetLeftBorderSize() ;
2633 r
.top
-= MacGetTopBorderSize() ;
2634 r
.bottom
+= MacGetBottomBorderSize() ;
2635 r
.right
+= MacGetRightBorderSize() ;
2642 rIncludingOuterStructures
= r
;
2643 InsetRect( &rIncludingOuterStructures
, -4 , -4 ) ;
2645 wxRect cl
= GetClientRect() ;
2646 Rect rClient
= { cl
.y
, cl
.x
, cl
.y
+ cl
.height
, cl
.x
+ cl
.width
} ;
2650 const wxWindow
* child
= this ;
2651 const wxWindow
* parent
= NULL
;
2653 while ( !child
->IsTopLevel() && ( parent
= child
->GetParent() ) != NULL
)
2655 if ( parent
->MacIsChildOfClientArea(child
) )
2657 size
= parent
->GetClientSize() ;
2658 wxPoint origin
= parent
->GetClientAreaOrigin() ;
2664 // this will be true for scrollbars, toolbars etc.
2665 size
= parent
->GetSize() ;
2666 y
= parent
->MacGetTopBorderSize() ;
2667 x
= parent
->MacGetLeftBorderSize() ;
2668 size
.x
-= parent
->MacGetLeftBorderSize() + parent
->MacGetRightBorderSize() ;
2669 size
.y
-= parent
->MacGetTopBorderSize() + parent
->MacGetBottomBorderSize() ;
2672 parent
->MacWindowToRootWindow( &x
, &y
) ;
2673 MacRootWindowToWindow( &x
, &y
) ;
2675 Rect rparent
= { y
, x
, y
+ size
.y
, x
+ size
.x
} ;
2677 // the wxwindow and client rects will always be clipped
2678 SectRect( &r
, &rparent
, &r
) ;
2679 SectRect( &rClient
, &rparent
, &rClient
) ;
2681 // the structure only at 'hard' borders
2682 if ( parent
->MacClipChildren() ||
2683 ( parent
->GetParent() && parent
->GetParent()->MacClipGrandChildren() ) )
2685 SectRect( &rIncludingOuterStructures
, &rparent
, &rIncludingOuterStructures
) ;
2691 m_cachedClippedRect
= wxRect( r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
- r
.top
) ;
2692 m_cachedClippedClientRect
= wxRect( rClient
.left
, rClient
.top
,
2693 rClient
.right
- rClient
.left
, rClient
.bottom
- rClient
.top
) ;
2694 m_cachedClippedRectWithOuterStructure
= wxRect(
2695 rIncludingOuterStructures
.left
, rIncludingOuterStructures
.top
,
2696 rIncludingOuterStructures
.right
- rIncludingOuterStructures
.left
,
2697 rIncludingOuterStructures
.bottom
- rIncludingOuterStructures
.top
) ;
2699 m_cachedClippedRegionWithOuterStructure
= wxRegion( m_cachedClippedRectWithOuterStructure
) ;
2700 m_cachedClippedRegion
= wxRegion( m_cachedClippedRect
) ;
2701 m_cachedClippedClientRegion
= wxRegion( m_cachedClippedClientRect
) ;
2703 m_cachedClippedRectValid
= true ;
2707 This function must not change the updatergn !
2709 bool wxWindowMac::MacDoRedraw( void* updatergnr
, long time
)
2711 bool handled
= false ;
2713 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2714 GetRegionBounds( updatergn
, &updatebounds
) ;
2716 // wxLogDebug(wxT("update for %s bounds %d, %d, %d, %d"), wxString(GetClassInfo()->GetClassName()).c_str(), updatebounds.left, updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
2718 if ( !EmptyRgn(updatergn
) )
2720 RgnHandle newupdate
= NewRgn() ;
2721 wxSize point
= GetClientSize() ;
2722 wxPoint origin
= GetClientAreaOrigin() ;
2723 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+ point
.y
) ;
2724 SectRgn( newupdate
, updatergn
, newupdate
) ;
2726 // first send an erase event to the entire update area
2728 // for the toplevel window this really is the entire area
2729 // for all the others only their client area, otherwise they
2730 // might be drawing with full alpha and eg put blue into
2731 // the grow-box area of a scrolled window (scroll sample)
2732 wxDC
* dc
= new wxWindowDC(this);
2734 dc
->SetClippingRegion(wxRegion(HIShapeCreateWithQDRgn(updatergn
)));
2736 dc
->SetClippingRegion(wxRegion(HIShapeCreateWithQDRgn(newupdate
)));
2738 wxEraseEvent
eevent( GetId(), dc
);
2739 eevent
.SetEventObject( this );
2740 HandleWindowEvent( eevent
);
2746 // calculate a client-origin version of the update rgn and set m_updateRegion to that
2747 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
2748 m_updateRegion
= wxRegion(HIShapeCreateWithQDRgn(newupdate
)) ;
2749 DisposeRgn( newupdate
) ;
2751 if ( !m_updateRegion
.Empty() )
2753 // paint the window itself
2756 event
.SetTimestamp(time
);
2757 event
.SetEventObject(this);
2758 HandleWindowEvent(event
);
2762 // now we cannot rely on having its borders drawn by a window itself, as it does not
2763 // get the updateRgn wide enough to always do so, so we do it from the parent
2764 // this would also be the place to draw any custom backgrounds for native controls
2765 // in Composited windowing
2766 wxPoint clientOrigin
= GetClientAreaOrigin() ;
2770 for (wxWindowList::compatibility_iterator node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2772 child
= node
->GetData();
2775 if (child
== m_vScrollBar
)
2777 if (child
== m_hScrollBar
)
2779 if (child
->IsTopLevel())
2781 if (!child
->IsShown())
2784 // only draw those in the update region (add a safety margin of 10 pixels for shadow effects
2786 child
->GetPosition( &x
, &y
);
2787 child
->GetSize( &w
, &h
);
2788 Rect childRect
= { y
, x
, y
+ h
, x
+ w
} ;
2789 OffsetRect( &childRect
, clientOrigin
.x
, clientOrigin
.y
) ;
2790 InsetRect( &childRect
, -10 , -10) ;
2792 if ( RectInRgn( &childRect
, updatergn
) )
2794 // paint custom borders
2795 wxNcPaintEvent
eventNc( child
->GetId() );
2796 eventNc
.SetEventObject( child
);
2797 if ( !child
->HandleWindowEvent( eventNc
) )
2799 child
->MacPaintBorders(0, 0) ;
2809 WXWindow
wxWindowMac::MacGetTopLevelWindowRef() const
2811 wxWindowMac
*iter
= (wxWindowMac
*)this ;
2815 if ( iter
->IsTopLevel() )
2817 wxTopLevelWindow
* toplevel
= wxDynamicCast(iter
,wxTopLevelWindow
);
2819 return toplevel
->MacGetWindowRef();
2821 wxPopupWindow
* popupwin
= wxDynamicCast(iter
,wxPopupWindow
);
2823 return popupwin
->MacGetPopupWindowRef();
2826 iter
= iter
->GetParent() ;
2832 bool wxWindowMac::MacHasScrollBarCorner() const
2834 /* Returns whether the scroll bars in a wxScrolledWindow should be
2835 * shortened. Scroll bars should be shortened if either:
2837 * - both scroll bars are visible, or
2839 * - there is a resize box in the parent frame's corner and this
2840 * window shares the bottom and right edge with the parent
2844 if ( m_hScrollBar
== NULL
&& m_vScrollBar
== NULL
)
2847 if ( ( m_hScrollBar
&& m_hScrollBar
->IsShown() )
2848 && ( m_vScrollBar
&& m_vScrollBar
->IsShown() ) )
2850 // Both scroll bars visible
2855 wxPoint thisWindowBottomRight
= GetScreenRect().GetBottomRight();
2857 for ( const wxWindow
*win
= this; win
; win
= win
->GetParent() )
2859 const wxFrame
*frame
= wxDynamicCast( win
, wxFrame
) ;
2862 if ( frame
->GetWindowStyleFlag() & wxRESIZE_BORDER
)
2864 // Parent frame has resize handle
2865 wxPoint frameBottomRight
= frame
->GetScreenRect().GetBottomRight();
2867 // Note: allow for some wiggle room here as wxMac's
2868 // window rect calculations seem to be imprecise
2869 if ( abs( thisWindowBottomRight
.x
- frameBottomRight
.x
) <= 2
2870 && abs( thisWindowBottomRight
.y
- frameBottomRight
.y
) <= 2 )
2872 // Parent frame has resize handle and shares
2873 // right bottom corner
2878 // Parent frame has resize handle but doesn't
2879 // share right bottom corner
2885 // Parent frame doesn't have resize handle
2891 // No parent frame found
2896 void wxWindowMac::MacCreateScrollBars( long style
)
2898 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, wxT("attempt to create window twice") ) ;
2900 if ( style
& ( wxVSCROLL
| wxHSCROLL
) )
2902 int scrlsize
= MAC_SCROLLBAR_SIZE
;
2903 if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL
|| GetWindowVariant() == wxWINDOW_VARIANT_MINI
)
2905 scrlsize
= MAC_SMALL_SCROLLBAR_SIZE
;
2908 int adjust
= MacHasScrollBarCorner() ? scrlsize
- 1: 0 ;
2910 GetClientSize( &width
, &height
) ;
2912 wxPoint
vPoint(width
- scrlsize
, 0) ;
2913 wxSize
vSize(scrlsize
, height
- adjust
) ;
2914 wxPoint
hPoint(0, height
- scrlsize
) ;
2915 wxSize
hSize(width
- adjust
, scrlsize
) ;
2917 // we have to set the min size to a smaller value, otherwise they cannot get smaller (InitialSize sets MinSize)
2918 if ( style
& wxVSCROLL
)
2920 m_vScrollBar
= new wxScrollBar((wxWindow
*)this, wxID_ANY
, vPoint
, vSize
, wxVERTICAL
);
2921 m_vScrollBar
->SetMinSize( wxDefaultSize
);
2924 if ( style
& wxHSCROLL
)
2926 m_hScrollBar
= new wxScrollBar((wxWindow
*)this, wxID_ANY
, hPoint
, hSize
, wxHORIZONTAL
);
2927 m_hScrollBar
->SetMinSize( wxDefaultSize
);
2931 // because the create does not take into account the client area origin
2932 // we might have a real position shift
2933 MacRepositionScrollBars() ;
2936 bool wxWindowMac::MacIsChildOfClientArea( const wxWindow
* child
) const
2938 bool result
= ((child
== NULL
) || ((child
!= m_hScrollBar
) && (child
!= m_vScrollBar
)));
2943 void wxWindowMac::MacRepositionScrollBars()
2945 if ( !m_hScrollBar
&& !m_vScrollBar
)
2948 int scrlsize
= m_hScrollBar
? m_hScrollBar
->GetSize().y
: ( m_vScrollBar
? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2949 int adjust
= MacHasScrollBarCorner() ? scrlsize
- 1 : 0 ;
2951 // get real client area
2953 GetSize( &width
, &height
);
2955 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
2956 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
2958 wxPoint
vPoint( width
- scrlsize
, 0 ) ;
2959 wxSize
vSize( scrlsize
, height
- adjust
) ;
2960 wxPoint
hPoint( 0 , height
- scrlsize
) ;
2961 wxSize
hSize( width
- adjust
, scrlsize
) ;
2964 int x
= 0, y
= 0, w
, h
;
2965 GetSize( &w
, &h
) ;
2967 MacClientToRootWindow( &x
, &y
) ;
2968 MacClientToRootWindow( &w
, &h
) ;
2970 wxWindowMac
*iter
= (wxWindowMac
*)this ;
2972 int totW
= 10000 , totH
= 10000;
2975 if ( iter
->IsTopLevel() )
2977 iter
->GetSize( &totW
, &totH
) ;
2981 iter
= iter
->GetParent() ;
2995 if ( w
- x
>= totW
)
3000 if ( h
- y
>= totH
)
3008 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
3010 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
3013 bool wxWindowMac::AcceptsFocus() const
3015 return MacCanFocus() && wxWindowBase::AcceptsFocus();
3018 void wxWindowMac::MacSuperChangedPosition()
3020 // only window-absolute structures have to be moved i.e. controls
3022 m_cachedClippedRectValid
= false ;
3025 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
3028 child
= node
->GetData();
3029 child
->MacSuperChangedPosition() ;
3031 node
= node
->GetNext();
3035 void wxWindowMac::MacTopLevelWindowChangedPosition()
3037 // only screen-absolute structures have to be moved i.e. glcanvas
3040 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
3043 child
= node
->GetData();
3044 child
->MacTopLevelWindowChangedPosition() ;
3046 node
= node
->GetNext();
3050 long wxWindowMac::MacGetLeftBorderSize() const
3057 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
))
3059 // this metric is only the 'outset' outside the simple frame rect
3060 GetThemeMetric( kThemeMetricEditTextFrameOutset
, &border
) ;
3063 else if (HasFlag(wxSIMPLE_BORDER
))
3065 // this metric is only the 'outset' outside the simple frame rect
3066 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
3073 long wxWindowMac::MacGetRightBorderSize() const
3075 // they are all symmetric in mac themes
3076 return MacGetLeftBorderSize() ;
3079 long wxWindowMac::MacGetTopBorderSize() const
3081 // they are all symmetric in mac themes
3082 return MacGetLeftBorderSize() ;
3085 long wxWindowMac::MacGetBottomBorderSize() const
3087 // they are all symmetric in mac themes
3088 return MacGetLeftBorderSize() ;
3091 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
3093 return style
& ~wxBORDER_MASK
;
3096 // Find the wxWindowMac at the current mouse position, returning the mouse
3098 wxWindowMac
* wxFindWindowAtPointer( wxPoint
& pt
)
3100 pt
= wxGetMousePosition();
3101 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
3106 // Get the current mouse position.
3107 wxPoint
wxGetMousePosition()
3111 wxGetMousePosition( &x
, &y
);
3113 return wxPoint(x
, y
);
3116 void wxWindowMac::OnMouseEvent( wxMouseEvent
&event
)
3118 if ( event
.GetEventType() == wxEVT_RIGHT_DOWN
)
3120 // copied from wxGTK : CS
3121 // VZ: shouldn't we move this to base class then?
3123 // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
3126 // (a) it's a command event and so is propagated to the parent
3127 // (b) under MSW it can be generated from kbd too
3128 // (c) it uses screen coords (because of (a))
3129 wxContextMenuEvent
evtCtx(wxEVT_CONTEXT_MENU
,
3131 this->ClientToScreen(event
.GetPosition()));
3132 evtCtx
.SetEventObject(this);
3133 if ( ! HandleWindowEvent(evtCtx
) )
3142 void wxWindowMac::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
3144 if ( wxTheApp
->MacGetCurrentEvent() != NULL
&& wxTheApp
->MacGetCurrentEventHandlerCallRef() != NULL
3145 && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT
)
3146 CallNextEventHandler(
3147 (EventHandlerCallRef
)wxTheApp
->MacGetCurrentEventHandlerCallRef() ,
3148 (EventRef
) wxTheApp
->MacGetCurrentEvent() ) ;
3151 void wxWindowMac::MacHandleControlClick(WXWidget
WXUNUSED(control
),
3152 wxInt16
WXUNUSED(controlpart
),
3153 bool WXUNUSED(mouseStillDown
))
3157 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
)
3161 window
->MacGetBoundsForControl( pos
, size
, x
, y
, w
, h
, adjustForOrigin
) ;
3162 Rect bounds
= { y
, x
, y
+ h
, x
+ w
};
3167 wxInt32
wxWindowMac::MacControlHit(WXEVENTHANDLERREF
WXUNUSED(handler
) , WXEVENTREF
WXUNUSED(event
) )
3169 return eventNotHandledErr
;
3172 bool wxWindowMac::Reparent(wxWindowBase
*newParentBase
)
3174 wxWindowMac
*newParent
= (wxWindowMac
*)newParentBase
;
3175 if ( !wxWindowBase::Reparent(newParent
) )
3178 // copied from MacPostControlCreate
3179 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
3181 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
3183 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
3188 bool wxWindowMac::SetTransparent(wxByte alpha
)
3190 SetBackgroundStyle(wxBG_STYLE_TRANSPARENT
);
3192 if ( alpha
!= m_macAlpha
)
3194 m_macAlpha
= alpha
;
3201 bool wxWindowMac::CanSetTransparent()
3206 wxByte
wxWindowMac::GetTransparent() const
3211 bool wxWindowMac::IsShownOnScreen() const
3213 #if TARGET_API_MAC_OSX
3214 if ( m_peer
&& m_peer
->Ok() )
3216 bool peerVis
= m_peer
->IsVisible();
3217 bool wxVis
= wxWindowBase::IsShownOnScreen();
3218 if( peerVis
!= wxVis
)
3220 // CS : put a breakpoint here to investigate differences
3221 // between native an wx visibilities
3222 // the only place where I've encountered them until now
3223 // are the hiding/showing sequences where the vis-changed event is
3224 // first sent to the innermost control, while wx does things
3225 // from the outmost control
3226 wxVis
= wxWindowBase::IsShownOnScreen();
3230 return m_peer
->IsVisible();
3234 return wxWindowBase::IsShownOnScreen();