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 wxWindowMac
* targetWindow
= NULL
;
173 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
175 OSStatus result
= eventNotHandledErr
;
177 wxMacCarbonEvent
cEvent( event
) ;
179 ControlRef controlRef
;
180 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
182 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
184 switch ( GetEventKind( event
) )
186 case kEventControlDraw
:
188 RgnHandle updateRgn
= NULL
;
189 RgnHandle allocatedRgn
= NULL
;
190 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
192 if ( cEvent
.GetParameter
<RgnHandle
>(kEventParamRgnHandle
, &updateRgn
) != noErr
)
194 HIShapeGetAsQDRgn( visRegion
.GetWXHRGN(), updateRgn
);
198 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
200 // as this update region is in native window locals we must adapt it to wx window local
201 allocatedRgn
= NewRgn() ;
202 CopyRgn( updateRgn
, allocatedRgn
) ;
204 // hide the given region by the new region that must be shifted
205 wxMacNativeToWindow( thisWindow
, allocatedRgn
) ;
206 updateRgn
= allocatedRgn
;
210 #if wxMAC_DEBUG_REDRAW
211 if ( thisWindow
->MacIsUserPane() )
213 static float color
= 0.5 ;
216 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
218 HIViewGetBounds( controlRef
, &bounds
);
219 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
220 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
221 CGContextFillRect( cgContext
, bounds
);
234 bool created
= false ;
235 CGContextRef cgContext
= NULL
;
236 OSStatus err
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, &cgContext
) ;
239 wxFAIL_MSG("Unable to retrieve CGContextRef");
242 thisWindow
->MacSetCGContextRef( cgContext
) ;
245 wxMacCGContextStateSaver
sg( cgContext
) ;
246 CGFloat alpha
= (CGFloat
)1.0 ;
248 wxWindow
* iter
= thisWindow
;
251 alpha
*= (CGFloat
)( iter
->GetTransparent()/255.0 ) ;
252 if ( iter
->IsTopLevel() )
255 iter
= iter
->GetParent() ;
258 CGContextSetAlpha( cgContext
, alpha
) ;
260 if ( thisWindow
->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT
)
263 HIViewGetBounds( controlRef
, &bounds
);
264 CGContextClearRect( cgContext
, bounds
);
269 if ( thisWindow
->MacDoRedraw( updateRgn
, cEvent
.GetTicks() ) )
272 thisWindow
->MacSetCGContextRef( NULL
) ;
276 CGContextRelease( cgContext
) ;
280 DisposeRgn( allocatedRgn
) ;
284 case kEventControlVisibilityChanged
:
285 // we might have two native controls attributed to the same wxWindow instance
286 // eg a scrollview and an embedded textview, make sure we only fire for the 'outer'
287 // control, as otherwise native and wx visibility are different
288 if ( thisWindow
->GetPeer() != NULL
&& thisWindow
->GetPeer()->GetControlRef() == controlRef
)
290 thisWindow
->MacVisibilityChanged() ;
294 case kEventControlEnabledStateChanged
:
295 thisWindow
->MacEnabledStateChanged();
298 case kEventControlHiliteChanged
:
299 thisWindow
->MacHiliteChanged() ;
302 case kEventControlActivate
:
303 case kEventControlDeactivate
:
304 // FIXME: we should have a virtual function for this!
306 if ( thisWindow
->IsKindOf( CLASSINFO( wxTreeCtrl
) ) )
307 thisWindow
->Refresh();
310 if ( thisWindow
->IsKindOf( CLASSINFO( wxListCtrl
) ) )
311 thisWindow
->Refresh();
317 // different handling on OS X
320 case kEventControlFocusPartChanged
:
321 // the event is emulated by wxmac for systems lower than 10.5
323 ControlPartCode previousControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPreviousPart
, typeControlPartCode
);
324 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlCurrentPart
, typeControlPartCode
);
326 if ( thisWindow
->MacGetTopLevelWindow() && thisWindow
->GetPeer()->NeedsFocusRect() )
328 thisWindow
->MacInvalidateBorders();
331 if ( currentControlPart
== 0 )
335 if ( thisWindow
->GetCaret() )
336 thisWindow
->GetCaret()->OnKillFocus();
339 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow
));
341 // remove this as soon as posting the synthesized event works properly
342 static bool inKillFocusEvent
= false ;
344 if ( !inKillFocusEvent
)
346 inKillFocusEvent
= true ;
347 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
348 event
.SetEventObject(thisWindow
);
349 event
.SetWindow(targetWindow
);
350 thisWindow
->HandleWindowEvent(event
) ;
351 inKillFocusEvent
= false ;
354 else if ( previousControlPart
== 0 )
357 // panel wants to track the window which was the last to have focus in it
358 wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow
));
359 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
360 thisWindow
->HandleWindowEvent(eventFocus
);
363 if ( thisWindow
->GetCaret() )
364 thisWindow
->GetCaret()->OnSetFocus();
367 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
368 event
.SetEventObject(thisWindow
);
369 thisWindow
->HandleWindowEvent(event
) ;
373 case kEventControlSetFocusPart
:
376 Boolean focusEverything
= false ;
377 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
379 // put a breakpoint here to catch focus everything events
382 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
383 if ( controlPart
!= kControlFocusNoPart
)
384 targetWindow
= thisWindow
;
386 ControlPartCode previousControlPart
= 0;
387 verify_noerr( HIViewGetFocusPart(controlRef
, &previousControlPart
));
389 if ( thisWindow
->MacIsUserPane() )
391 if ( controlPart
!= kControlFocusNoPart
)
392 cEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPart
, typeControlPartCode
, 1 ) ;
396 result
= CallNextEventHandler(handler
, event
);
398 if ( UMAGetSystemVersion() < 0x1050 )
400 // set back to 0 if problems arise
402 ControlPartCode currentControlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
403 // synthesize the event focus changed event
404 EventRef evRef
= NULL
;
406 OSStatus err
= MacCreateEvent(
407 NULL
, kEventClassControl
, kEventControlFocusPartChanged
, TicksToEventTime( TickCount() ) ,
408 kEventAttributeUserEvent
, &evRef
);
411 wxMacCarbonEvent
iEvent( evRef
) ;
412 iEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, controlRef
) ;
413 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlPreviousPart
, typeControlPartCode
, previousControlPart
) ;
414 iEvent
.SetParameter
<ControlPartCode
>( kEventParamControlCurrentPart
, typeControlPartCode
, currentControlPart
) ;
417 // TODO test this first, avoid double posts etc...
418 PostEventToQueue( GetMainEventQueue(), evRef
, kEventPriorityHigh
);
420 wxMacWindowControlEventHandler( NULL
, evRef
, data
) ;
422 ReleaseEvent( evRef
) ;
424 // old implementation, to be removed if the new one works
425 if ( controlPart
== kControlFocusNoPart
)
428 if ( thisWindow
->GetCaret() )
429 thisWindow
->GetCaret()->OnKillFocus();
432 wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow
));
434 static bool inKillFocusEvent
= false ;
436 if ( !inKillFocusEvent
)
438 inKillFocusEvent
= true ;
439 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
440 event
.SetEventObject(thisWindow
);
441 thisWindow
->HandleWindowEvent(event
) ;
442 inKillFocusEvent
= false ;
447 // panel wants to track the window which was the last to have focus in it
448 wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow
));
449 wxChildFocusEvent
eventFocus((wxWindow
*)thisWindow
);
450 thisWindow
->HandleWindowEvent(eventFocus
);
453 if ( thisWindow
->GetCaret() )
454 thisWindow
->GetCaret()->OnSetFocus();
457 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
458 event
.SetEventObject(thisWindow
);
459 thisWindow
->HandleWindowEvent(event
) ;
466 case kEventControlHit
:
467 result
= thisWindow
->MacControlHit( handler
, event
) ;
470 case kEventControlGetClickActivation
:
472 // fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise)
473 WindowRef owner
= cEvent
.GetParameter
<WindowRef
>(kEventParamWindowRef
);
474 if ( !IsWindowActive(owner
) )
476 cEvent
.SetParameter(kEventParamClickActivation
,(UInt32
) kActivateAndIgnoreClick
) ;
489 static pascal OSStatus
490 wxMacWindowServiceEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
494 OSStatus result
= eventNotHandledErr
;
496 wxMacCarbonEvent
cEvent( event
) ;
498 ControlRef controlRef
;
499 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
500 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
501 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
503 switch ( GetEventKind( event
) )
505 case kEventServiceGetTypes
:
509 textCtrl
->GetSelection( &from
, &to
) ;
511 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
513 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
514 if ( textCtrl
->IsEditable() )
515 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
517 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt', 'PICT', 'MooV', 'AIFF' */ };
518 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
520 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
524 CFArrayAppendValue(copyTypes
, typestring
) ;
526 CFArrayAppendValue(pasteTypes
, typestring
) ;
528 CFRelease( typestring
) ;
536 case kEventServiceCopy
:
541 textCtrl
->GetSelection( &from
, &to
) ;
542 wxString val
= textCtrl
->GetValue() ;
543 val
= val
.Mid( from
, to
- from
) ;
544 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
545 verify_noerr( PasteboardClear( pasteboard
) ) ;
546 PasteboardSynchronize( pasteboard
);
547 // TODO add proper conversion
548 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (const UInt8
*)val
.c_str(), val
.length() );
549 PasteboardPutItemFlavor( pasteboard
, (PasteboardItemID
) 1, CFSTR("com.apple.traditional-mac-plain-text"), data
, 0);
555 case kEventServicePaste
:
558 PasteboardRef pasteboard
= cEvent
.GetParameter
<PasteboardRef
>( kEventParamPasteboardRef
, typePasteboardRef
);
559 PasteboardSynchronize( pasteboard
);
561 verify_noerr( PasteboardGetItemCount( pasteboard
, &itemCount
) );
562 for( UInt32 itemIndex
= 1; itemIndex
<= itemCount
; itemIndex
++ )
564 PasteboardItemID itemID
;
565 if ( PasteboardGetItemIdentifier( pasteboard
, itemIndex
, &itemID
) == noErr
)
567 CFDataRef flavorData
= NULL
;
568 if ( PasteboardCopyItemFlavorData( pasteboard
, itemID
, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData
) == noErr
)
570 CFIndex flavorDataSize
= CFDataGetLength( flavorData
);
571 char *content
= new char[flavorDataSize
+1] ;
572 memcpy( content
, CFDataGetBytePtr( flavorData
), flavorDataSize
);
573 content
[flavorDataSize
]=0;
574 CFRelease( flavorData
);
576 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
578 textCtrl
->WriteText( wxString( content
) ) ;
596 pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
598 OSStatus result
= eventNotHandledErr
;
599 wxWindowMac
* focus
= (wxWindowMac
*) data
;
601 wchar_t* uniChars
= NULL
;
602 UInt32 when
= EventTimeToTicks( GetEventTime( event
) ) ;
604 UniChar
* charBuf
= NULL
;
605 ByteCount dataSize
= 0 ;
608 if ( GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, 0 , &dataSize
, NULL
) == noErr
)
610 numChars
= dataSize
/ sizeof( UniChar
) + 1;
613 if ( (size_t) numChars
* 2 > sizeof(buf
) )
614 charBuf
= new UniChar
[ numChars
] ;
618 uniChars
= new wchar_t[ numChars
] ;
619 GetEventParameter( event
, kEventParamTextInputSendText
, typeUnicodeText
, NULL
, dataSize
, NULL
, charBuf
) ;
620 charBuf
[ numChars
- 1 ] = 0;
621 #if SIZEOF_WCHAR_T == 2
622 uniChars
= (wchar_t*) charBuf
;
623 /* 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...)
625 // the resulting string will never have more chars than the utf16 version, so this is safe
626 wxMBConvUTF16 converter
;
627 numChars
= converter
.MB2WC( uniChars
, (const char*)charBuf
, numChars
) ;
631 switch ( GetEventKind( event
) )
633 case kEventTextInputUpdateActiveInputArea
:
635 // An IME input event may return several characters, but we need to send one char at a time to
637 for (int pos
=0 ; pos
< numChars
; pos
++)
639 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
640 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
641 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
643 UInt32 message
= uniChars
[pos
] < 128 ? (char)uniChars
[pos
] : '?';
645 NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent
646 multiple times to update the active range during inline input, so this handler will often receive
647 uncommited text, which should usually not trigger side effects. It might be a good idea to check the
648 kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h).
649 On the other hand, it can be useful for some applications to react to uncommitted text (for example,
650 to update a status display), as long as it does not disrupt the inline input session. Ideally, wx
651 should add new event types to support advanced text input. For now, I would keep things as they are.
653 However, the code that was being used caused additional problems:
654 UInt32 message = (0 << 8) + ((char)uniChars[pos] );
655 Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline
656 input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji
657 for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB
658 (still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D
659 (the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress.
660 Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only
661 overlap with Unicode within the (7-bit) ASCII range.
662 But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks
663 for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII
664 characters as they are and replaces the rest with '?', ensuring that update events are triggered.
665 It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but
666 I don't have time to look into that right now.
669 if ( wxTheApp
->MacSendCharEvent(
670 focus
, message
, 0 , when
, 0 , 0 , uniChars
[pos
] ) )
675 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
679 case kEventTextInputUnicodeForKeyEvent
:
681 UInt32 keyCode
, modifiers
;
684 unsigned char charCode
;
686 GetEventParameter( event
, kEventParamTextInputSendKeyboardEvent
, typeEventRef
, NULL
, sizeof(rawEvent
), NULL
, &rawEvent
) ;
687 GetEventParameter( rawEvent
, kEventParamKeyMacCharCodes
, typeChar
, NULL
, sizeof(char), NULL
, &charCode
);
688 GetEventParameter( rawEvent
, kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
689 GetEventParameter( rawEvent
, kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
690 GetEventParameter( rawEvent
, kEventParamMouseLocation
, typeQDPoint
, NULL
, sizeof(Point
), NULL
, &point
);
692 UInt32 message
= (keyCode
<< 8) + charCode
;
694 // An IME input event may return several characters, but we need to send one char at a time to
696 for (int pos
=0 ; pos
< numChars
; pos
++)
698 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
699 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
700 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
702 if ( wxTheApp
->MacSendCharEvent(
703 focus
, message
, modifiers
, when
, point
.h
, point
.v
, uniChars
[pos
] ) )
708 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
717 if ( charBuf
!= buf
)
723 static pascal OSStatus
724 wxMacWindowCommandEventHandler(EventHandlerCallRef
WXUNUSED(handler
),
728 OSStatus result
= eventNotHandledErr
;
729 wxWindowMac
* focus
= (wxWindowMac
*) data
;
733 wxMacCarbonEvent
cEvent( event
) ;
734 cEvent
.GetParameter
<HICommand
>(kEventParamDirectObject
,typeHICommand
,&command
) ;
736 wxMenuItem
* item
= NULL
;
737 wxMenu
* itemMenu
= wxFindMenuFromMacCommand( command
, item
) ;
738 int id
= wxMacCommandToId( command
.commandID
) ;
742 wxASSERT( itemMenu
!= NULL
) ;
744 switch ( cEvent
.GetKind() )
746 case kEventProcessCommand
:
747 result
= itemMenu
->MacHandleCommandProcess( item
, id
, focus
);
750 case kEventCommandUpdateStatus
:
751 result
= itemMenu
->MacHandleCommandUpdateStatus( item
, id
, focus
);
761 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
763 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
764 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
765 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
766 OSStatus result
= eventNotHandledErr
;
768 switch ( GetEventClass( event
) )
770 case kEventClassCommand
:
771 result
= wxMacWindowCommandEventHandler( handler
, event
, data
) ;
774 case kEventClassControl
:
775 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
778 case kEventClassService
:
779 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
782 case kEventClassTextInput
:
783 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
790 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
795 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
797 // ---------------------------------------------------------------------------
798 // Scrollbar Tracking for all
799 // ---------------------------------------------------------------------------
801 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
802 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
806 wxWindow
* wx
= wxFindControlFromMacControl( control
) ;
808 wx
->MacHandleControlClick( (WXWidget
) control
, partCode
, true /* stillDown */ ) ;
811 wxMAC_DEFINE_PROC_GETTER( ControlActionUPP
, wxMacLiveScrollbarActionProc
) ;
813 // ===========================================================================
815 // ===========================================================================
817 WX_DECLARE_HASH_MAP(ControlRef
, wxWindow
*, wxPointerHash
, wxPointerEqual
, MacControlMap
);
819 static MacControlMap wxWinMacControlList
;
821 wxWindow
*wxFindControlFromMacControl(ControlRef inControl
)
823 MacControlMap::iterator node
= wxWinMacControlList
.find(inControl
);
825 return (node
== wxWinMacControlList
.end()) ? NULL
: node
->second
;
828 void wxAssociateControlWithMacControl(ControlRef inControl
, wxWindow
*control
)
830 // adding NULL ControlRef is (first) surely a result of an error and
831 // (secondly) breaks native event processing
832 wxCHECK_RET( inControl
!= (ControlRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
834 wxWinMacControlList
[inControl
] = control
;
837 void wxRemoveMacControlAssociation(wxWindow
*control
)
839 // iterate over all the elements in the class
840 // is the iterator stable ? as we might have two associations pointing to the same wxWindow
841 // we should go on...
847 MacControlMap::iterator it
;
848 for ( it
= wxWinMacControlList
.begin(); it
!= wxWinMacControlList
.end(); ++it
)
850 if ( it
->second
== control
)
852 wxWinMacControlList
.erase(it
);
860 // ----------------------------------------------------------------------------
861 // constructors and such
862 // ----------------------------------------------------------------------------
864 wxWindowMac::wxWindowMac()
869 wxWindowMac::wxWindowMac(wxWindowMac
*parent
,
874 const wxString
& name
)
877 Create(parent
, id
, pos
, size
, style
, name
);
880 void wxWindowMac::Init()
884 m_cgContextRef
= NULL
;
886 // as all windows are created with WS_VISIBLE style...
889 m_hScrollBar
= NULL
;
890 m_vScrollBar
= NULL
;
891 m_hScrollBarAlwaysShown
= false;
892 m_vScrollBarAlwaysShown
= false;
894 m_macIsUserPane
= true;
895 m_clipChildren
= false ;
896 m_cachedClippedRectValid
= false ;
899 wxWindowMac::~wxWindowMac()
903 m_isBeingDeleted
= true;
905 MacInvalidateBorders() ;
907 #ifndef __WXUNIVERSAL__
908 // VS: make sure there's no wxFrame with last focus set to us:
909 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
911 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
914 if ( frame
->GetLastFocus() == this )
915 frame
->SetLastFocus((wxWindow
*)NULL
);
921 // destroy children before destroying this window itself
924 // wxRemoveMacControlAssociation( this ) ;
925 // If we delete an item, we should initialize the parent panel,
926 // because it could now be invalid.
927 wxTopLevelWindow
*tlw
= wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow
);
930 if ( tlw
->GetDefaultItem() == (wxButton
*) this)
931 tlw
->SetDefaultItem(NULL
);
934 if ( m_peer
&& m_peer
->Ok() )
936 // in case the callback might be called during destruction
937 wxRemoveMacControlAssociation( this) ;
938 ::RemoveEventHandler( (EventHandlerRef
) m_macControlEventHandler
) ;
939 // we currently are not using this hook
940 // ::SetControlColorProc( *m_peer , NULL ) ;
944 if ( g_MacLastWindow
== this )
945 g_MacLastWindow
= NULL
;
947 #ifndef __WXUNIVERSAL__
948 wxFrame
* frame
= wxDynamicCast( wxGetTopLevelParent( (wxWindow
*)this ) , wxFrame
) ;
951 if ( frame
->GetLastFocus() == this )
952 frame
->SetLastFocus( NULL
) ;
956 // delete our drop target if we've got one
957 #if wxUSE_DRAG_AND_DROP
958 if ( m_dropTarget
!= NULL
)
968 WXWidget
wxWindowMac::GetHandle() const
970 return (WXWidget
) m_peer
->GetControlRef() ;
973 void wxWindowMac::MacInstallEventHandler( WXWidget control
)
975 wxAssociateControlWithMacControl( (ControlRef
) control
, this ) ;
976 InstallControlEventHandler( (ControlRef
)control
, GetwxMacWindowEventHandlerUPP(),
977 GetEventTypeCount(eventList
), eventList
, this,
978 (EventHandlerRef
*)&m_macControlEventHandler
);
982 bool wxWindowMac::Create(wxWindowMac
*parent
,
987 const wxString
& name
)
989 wxCHECK_MSG( parent
, false, wxT("can't create wxWindowMac without parent") );
991 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
994 m_windowVariant
= parent
->GetWindowVariant() ;
996 if ( m_macIsUserPane
)
998 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
1001 | kControlSupportsEmbedding
1002 | kControlSupportsLiveFeedback
1003 | kControlGetsFocusOnClick
1004 // | kControlHasSpecialBackground
1005 // | kControlSupportsCalcBestRect
1006 | kControlHandlesTracking
1007 | kControlSupportsFocus
1008 | kControlWantsActivate
1009 | kControlWantsIdle
;
1011 m_peer
= new wxMacControl(this) ;
1012 OSStatus err
=::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, m_peer
->GetControlRefAddr() );
1013 verify_noerr( err
);
1015 MacPostControlCreate(pos
, size
) ;
1018 #ifndef __WXUNIVERSAL__
1019 // Don't give scrollbars to wxControls unless they ask for them
1020 if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
)))
1021 || (IsKindOf(CLASSINFO(wxControl
)) && ((style
& wxHSCROLL
) || (style
& wxVSCROLL
))))
1023 MacCreateScrollBars( style
) ;
1027 wxWindowCreateEvent
event(this);
1028 GetEventHandler()->AddPendingEvent(event
);
1033 void wxWindowMac::MacChildAdded()
1036 m_vScrollBar
->Raise() ;
1038 m_hScrollBar
->Raise() ;
1041 void wxWindowMac::MacPostControlCreate(const wxPoint
& WXUNUSED(pos
), const wxSize
& size
)
1043 wxASSERT_MSG( m_peer
!= NULL
&& m_peer
->Ok() , wxT("No valid mac control") ) ;
1045 m_peer
->SetReference( (URefCon
) this ) ;
1046 GetParent()->AddChild( this );
1048 MacInstallEventHandler( (WXWidget
) m_peer
->GetControlRef() );
1050 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
1051 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
1052 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
1053 GetParent()->MacChildAdded() ;
1055 // adjust font, controlsize etc
1056 DoSetWindowVariant( m_windowVariant
) ;
1058 m_peer
->SetLabel( wxStripMenuCodes(m_label
, wxStrip_Mnemonics
) ) ;
1060 if (!m_macIsUserPane
)
1061 SetInitialSize(size
);
1063 SetCursor( *wxSTANDARD_CURSOR
) ;
1066 void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant
)
1068 // Don't assert, in case we set the window variant before
1069 // the window is created
1070 // wxASSERT( m_peer->Ok() ) ;
1072 m_windowVariant
= variant
;
1074 if (m_peer
== NULL
|| !m_peer
->Ok())
1078 ThemeFontID themeFont
= kThemeSystemFont
;
1080 // we will get that from the settings later
1081 // and make this NORMAL later, but first
1082 // we have a few calculations that we must fix
1086 case wxWINDOW_VARIANT_NORMAL
:
1087 size
= kControlSizeNormal
;
1088 themeFont
= kThemeSystemFont
;
1091 case wxWINDOW_VARIANT_SMALL
:
1092 size
= kControlSizeSmall
;
1093 themeFont
= kThemeSmallSystemFont
;
1096 case wxWINDOW_VARIANT_MINI
:
1097 // not always defined in the headers
1102 case wxWINDOW_VARIANT_LARGE
:
1103 size
= kControlSizeLarge
;
1104 themeFont
= kThemeSystemFont
;
1108 wxFAIL_MSG(_T("unexpected window variant"));
1112 m_peer
->SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
, &size
) ;
1115 font
.MacCreateFromThemeFont( themeFont
) ;
1119 void wxWindowMac::MacUpdateControlFont()
1121 m_peer
->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
1122 // do not trigger refreshes upon invisible and possible partly created objects
1123 if ( IsShownOnScreen() )
1127 bool wxWindowMac::SetFont(const wxFont
& font
)
1129 bool retval
= wxWindowBase::SetFont( font
);
1131 MacUpdateControlFont() ;
1136 bool wxWindowMac::SetForegroundColour(const wxColour
& col
)
1138 bool retval
= wxWindowBase::SetForegroundColour( col
);
1141 MacUpdateControlFont();
1146 bool wxWindowMac::SetBackgroundColour(const wxColour
& col
)
1148 if ( !wxWindowBase::SetBackgroundColour(col
) && m_hasBgCol
)
1151 m_peer
->SetBackgroundColour( col
) ;
1156 bool wxWindowMac::MacCanFocus() const
1158 // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
1159 // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning,
1160 // but the value range is nowhere documented
1161 Boolean keyExistsAndHasValidFormat
;
1162 CFIndex fullKeyboardAccess
= CFPreferencesGetAppIntegerValue( CFSTR("AppleKeyboardUIMode" ) ,
1163 kCFPreferencesCurrentApplication
, &keyExistsAndHasValidFormat
);
1165 if ( keyExistsAndHasValidFormat
&& fullKeyboardAccess
> 0 )
1171 UInt32 features
= 0 ;
1172 m_peer
->GetFeatures( &features
) ;
1174 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
1178 void wxWindowMac::SetFocus()
1180 if ( !AcceptsFocus() )
1183 wxWindow
* former
= FindFocus() ;
1184 if ( former
== this )
1187 // as we cannot rely on the control features to find out whether we are in full keyboard mode,
1188 // we can only leave in case of an error
1189 OSStatus err
= m_peer
->SetFocus( kControlFocusNextPart
) ;
1190 if ( err
== errCouldntSetFocus
)
1193 SetUserFocusWindow( (WindowRef
)MacGetTopLevelWindowRef() );
1196 void wxWindowMac::DoCaptureMouse()
1198 wxApp::s_captureWindow
= this ;
1201 wxWindow
* wxWindowBase::GetCapture()
1203 return wxApp::s_captureWindow
;
1206 void wxWindowMac::DoReleaseMouse()
1208 wxApp::s_captureWindow
= NULL
;
1211 #if wxUSE_DRAG_AND_DROP
1213 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
1215 if ( m_dropTarget
!= NULL
)
1216 delete m_dropTarget
;
1218 m_dropTarget
= pDropTarget
;
1219 if ( m_dropTarget
!= NULL
)
1227 // Old-style File Manager Drag & Drop
1228 void wxWindowMac::DragAcceptFiles(bool WXUNUSED(accept
))
1233 // Returns the size of the native control. In the case of the toplevel window
1234 // this is the content area root control
1236 void wxWindowMac::MacGetPositionAndSizeFromControl(int& WXUNUSED(x
),
1239 int& WXUNUSED(h
)) const
1241 wxFAIL_MSG( wxT("Not currently supported") ) ;
1244 // From a wx position / size calculate the appropriate size of the native control
1246 bool wxWindowMac::MacGetBoundsForControl(
1250 int& w
, int& h
, bool adjustOrigin
) const
1252 // the desired size, minus the border pixels gives the correct size of the control
1256 // TODO: the default calls may be used as soon as PostCreateControl Is moved here
1257 w
= wxMax(size
.x
, 0) ; // WidthDefault( size.x );
1258 h
= wxMax(size
.y
, 0) ; // HeightDefault( size.y ) ;
1260 x
+= MacGetLeftBorderSize() ;
1261 y
+= MacGetTopBorderSize() ;
1262 w
-= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1263 h
-= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1266 AdjustForParentClientOrigin( x
, y
) ;
1268 // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
1269 if ( !GetParent()->IsTopLevel() )
1271 x
-= GetParent()->MacGetLeftBorderSize() ;
1272 y
-= GetParent()->MacGetTopBorderSize() ;
1278 // Get window size (not client size)
1279 void wxWindowMac::DoGetSize(int *x
, int *y
) const
1282 m_peer
->GetRect( &bounds
) ;
1285 *x
= bounds
.right
- bounds
.left
+ MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1287 *y
= bounds
.bottom
- bounds
.top
+ MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1290 // get the position of the bounds of this window in client coordinates of its parent
1291 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
1294 m_peer
->GetRect( &bounds
) ;
1296 int x1
= bounds
.left
;
1297 int y1
= bounds
.top
;
1299 // get the wx window position from the native one
1300 x1
-= MacGetLeftBorderSize() ;
1301 y1
-= MacGetTopBorderSize() ;
1303 if ( !IsTopLevel() )
1305 wxWindow
*parent
= GetParent();
1308 // we must first adjust it to be in window coordinates of the parent,
1309 // as otherwise it gets lost by the ClientAreaOrigin fix
1310 x1
+= parent
->MacGetLeftBorderSize() ;
1311 y1
+= parent
->MacGetTopBorderSize() ;
1313 // and now to client coordinates
1314 wxPoint
pt(parent
->GetClientAreaOrigin());
1326 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
1328 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1329 wxCHECK_RET( window
, wxT("TopLevel Window missing") ) ;
1331 Point localwhere
= { 0, 0 } ;
1338 wxMacGlobalToLocal( window
, &localwhere
) ;
1345 MacRootWindowToWindow( x
, y
) ;
1347 wxPoint origin
= GetClientAreaOrigin() ;
1354 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
1356 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1357 wxCHECK_RET( window
, wxT("TopLevel window missing") ) ;
1359 wxPoint origin
= GetClientAreaOrigin() ;
1365 MacWindowToRootWindow( x
, y
) ;
1367 Point localwhere
= { 0, 0 };
1373 wxMacLocalToGlobal( window
, &localwhere
) ;
1381 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
1383 wxPoint origin
= GetClientAreaOrigin() ;
1389 MacWindowToRootWindow( x
, y
) ;
1392 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
1394 MacRootWindowToWindow( x
, y
) ;
1396 wxPoint origin
= GetClientAreaOrigin() ;
1403 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
1412 if ( !IsTopLevel() )
1414 wxNonOwnedWindow
* top
= MacGetTopLevelWindow();
1417 pt
.x
-= MacGetLeftBorderSize() ;
1418 pt
.y
-= MacGetTopBorderSize() ;
1419 wxMacControl::Convert( &pt
, m_peer
, top
->m_peer
) ;
1429 void wxWindowMac::MacWindowToRootWindow( short *x
, short *y
) const
1438 MacWindowToRootWindow( &x1
, &y1
) ;
1446 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
1455 if ( !IsTopLevel() )
1457 wxNonOwnedWindow
* top
= MacGetTopLevelWindow();
1460 wxMacControl::Convert( &pt
, top
->m_peer
, m_peer
) ;
1461 pt
.x
+= MacGetLeftBorderSize() ;
1462 pt
.y
+= MacGetTopBorderSize() ;
1472 void wxWindowMac::MacRootWindowToWindow( short *x
, short *y
) const
1481 MacRootWindowToWindow( &x1
, &y1
) ;
1489 void wxWindowMac::MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
)
1491 RgnHandle rgn
= NewRgn() ;
1493 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1495 Rect structure
, content
;
1497 GetRegionBounds( rgn
, &content
) ;
1498 m_peer
->GetRect( &structure
) ;
1499 OffsetRect( &structure
, -structure
.left
, -structure
.top
) ;
1501 left
= content
.left
- structure
.left
;
1502 top
= content
.top
- structure
.top
;
1503 right
= structure
.right
- content
.right
;
1504 bottom
= structure
.bottom
- content
.bottom
;
1508 left
= top
= right
= bottom
= 0 ;
1514 wxSize
wxWindowMac::DoGetSizeFromClientSize( const wxSize
& size
) const
1516 wxSize sizeTotal
= size
;
1518 RgnHandle rgn
= NewRgn() ;
1519 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1521 Rect content
, structure
;
1522 GetRegionBounds( rgn
, &content
) ;
1523 m_peer
->GetRect( &structure
) ;
1525 // structure is in parent coordinates, but we only need width and height, so it's ok
1527 sizeTotal
.x
+= (structure
.right
- structure
.left
) - (content
.right
- content
.left
) ;
1528 sizeTotal
.y
+= (structure
.bottom
- structure
.top
) - (content
.bottom
- content
.top
) ;
1533 sizeTotal
.x
+= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1534 sizeTotal
.y
+= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1539 // Get size *available for subwindows* i.e. excluding menu bar etc.
1540 void wxWindowMac::DoGetClientSize( int *x
, int *y
) const
1544 RgnHandle rgn
= NewRgn() ;
1546 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1547 GetRegionBounds( rgn
, &content
) ;
1549 m_peer
->GetRect( &content
) ;
1552 ww
= content
.right
- content
.left
;
1553 hh
= content
.bottom
- content
.top
;
1555 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
1556 hh
-= m_hScrollBar
->GetSize().y
;
1558 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
1559 ww
-= m_vScrollBar
->GetSize().x
;
1567 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
1569 if (m_cursor
.IsSameAs(cursor
))
1574 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
1579 if ( ! wxWindowBase::SetCursor( cursor
) )
1583 wxASSERT_MSG( m_cursor
.Ok(),
1584 wxT("cursor must be valid after call to the base version"));
1586 wxWindowMac
*mouseWin
= 0 ;
1588 wxNonOwnedWindow
*tlw
= MacGetTopLevelWindow() ;
1589 WindowRef window
= (WindowRef
) ( tlw
? tlw
->MacGetWindowRef() : 0 ) ;
1591 ControlPartCode part
;
1592 ControlRef control
;
1594 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
1596 HIGetMousePosition(kHICoordSpaceWindow
, window
, &hiPoint
);
1600 GetGlobalMouse( &pt
);
1603 ScreenToClient(&x
, &y
);
1607 control
= FindControlUnderMouse( pt
, window
, &part
) ;
1609 mouseWin
= wxFindControlFromMacControl( control
) ;
1613 if ( mouseWin
== this && !wxIsBusy() )
1614 m_cursor
.MacInstall() ;
1620 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
1622 #ifndef __WXUNIVERSAL__
1623 menu
->SetInvokingWindow((wxWindow
*)this);
1626 if ( x
== wxDefaultCoord
&& y
== wxDefaultCoord
)
1628 wxPoint mouse
= wxGetMousePosition();
1634 ClientToScreen( &x
, &y
) ;
1637 menu
->MacBeforeDisplay( true ) ;
1638 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() , y
, x
, 0) ;
1639 if ( HiWord(menuResult
) != 0 )
1642 GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult
)) , LoWord(menuResult
) , &macid
);
1643 int id
= wxMacCommandToId( macid
);
1644 wxMenuItem
* item
= NULL
;
1646 item
= menu
->FindItem( id
, &realmenu
) ;
1649 if (item
->IsCheckable())
1650 item
->Check( !item
->IsChecked() ) ;
1652 menu
->SendEvent( id
, item
->IsCheckable() ? item
->IsChecked() : -1 ) ;
1656 menu
->MacAfterDisplay( true ) ;
1657 menu
->SetInvokingWindow( NULL
);
1661 // actually this shouldn't be called, because universal is having its own implementation
1667 // ----------------------------------------------------------------------------
1669 // ----------------------------------------------------------------------------
1673 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
1675 wxWindowBase::DoSetToolTip(tooltip
);
1678 m_tooltip
->SetWindow(this);
1683 void wxWindowMac::MacInvalidateBorders()
1685 if ( m_peer
== NULL
)
1688 bool vis
= IsShownOnScreen() ;
1692 int outerBorder
= MacGetLeftBorderSize() ;
1693 if ( m_peer
->NeedsFocusRect() /* && m_peer->HasFocus() */ )
1696 if ( outerBorder
== 0 )
1699 // now we know that we have something to do at all
1701 // as the borders are drawn on the parent we have to properly invalidate all these areas
1702 RgnHandle updateInner
, updateOuter
;
1705 // this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon
1706 updateInner
= NewRgn() ;
1707 updateOuter
= NewRgn() ;
1709 m_peer
->GetRect( &rect
) ;
1710 RectRgn( updateInner
, &rect
) ;
1711 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
1712 RectRgn( updateOuter
, &rect
) ;
1713 DiffRgn( updateOuter
, updateInner
, updateOuter
) ;
1715 GetParent()->m_peer
->SetNeedsDisplay( updateOuter
) ;
1717 DisposeRgn( updateOuter
) ;
1718 DisposeRgn( updateInner
) ;
1721 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
1723 // this is never called for a toplevel window, so we know we have a parent
1724 int former_x
, former_y
, former_w
, former_h
;
1726 // Get true coordinates of former position
1727 DoGetPosition( &former_x
, &former_y
) ;
1728 DoGetSize( &former_w
, &former_h
) ;
1730 wxWindow
*parent
= GetParent();
1733 wxPoint
pt(parent
->GetClientAreaOrigin());
1738 int actualWidth
= width
;
1739 int actualHeight
= height
;
1743 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
1744 actualWidth
= m_minWidth
;
1745 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
1746 actualHeight
= m_minHeight
;
1747 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
1748 actualWidth
= m_maxWidth
;
1749 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
1750 actualHeight
= m_maxHeight
;
1752 bool doMove
= false, doResize
= false ;
1754 if ( actualX
!= former_x
|| actualY
!= former_y
)
1757 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
1760 if ( doMove
|| doResize
)
1762 // as the borders are drawn outside the native control, we adjust now
1764 wxRect
bounds( wxPoint( actualX
+ MacGetLeftBorderSize() ,actualY
+ MacGetTopBorderSize() ),
1765 wxSize( actualWidth
- (MacGetLeftBorderSize() + MacGetRightBorderSize()) ,
1766 actualHeight
- (MacGetTopBorderSize() + MacGetBottomBorderSize()) ) ) ;
1769 wxMacRectToNative( &bounds
, &r
) ;
1771 if ( !GetParent()->IsTopLevel() )
1772 wxMacWindowToNative( GetParent() , &r
) ;
1774 MacInvalidateBorders() ;
1776 m_cachedClippedRectValid
= false ;
1777 m_peer
->SetRect( &r
) ;
1779 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
1781 MacInvalidateBorders() ;
1783 MacRepositionScrollBars() ;
1786 wxPoint
point(actualX
, actualY
);
1787 wxMoveEvent
event(point
, m_windowId
);
1788 event
.SetEventObject(this);
1789 HandleWindowEvent(event
) ;
1794 MacRepositionScrollBars() ;
1795 wxSize
size(actualWidth
, actualHeight
);
1796 wxSizeEvent
event(size
, m_windowId
);
1797 event
.SetEventObject(this);
1798 HandleWindowEvent(event
);
1803 wxSize
wxWindowMac::DoGetBestSize() const
1805 if ( m_macIsUserPane
|| IsTopLevel() )
1806 return wxWindowBase::DoGetBestSize() ;
1808 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
1809 int bestWidth
, bestHeight
;
1811 m_peer
->GetBestRect( &bestsize
) ;
1812 if ( EmptyRect( &bestsize
) )
1817 bestsize
.bottom
= 16 ;
1819 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
1821 bestsize
.bottom
= 16 ;
1824 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
1826 bestsize
.bottom
= 24 ;
1831 // return wxWindowBase::DoGetBestSize() ;
1835 bestWidth
= bestsize
.right
- bestsize
.left
;
1836 bestHeight
= bestsize
.bottom
- bestsize
.top
;
1837 if ( bestHeight
< 10 )
1840 return wxSize(bestWidth
, bestHeight
);
1843 // set the size of the window: if the dimensions are positive, just use them,
1844 // but if any of them is equal to -1, it means that we must find the value for
1845 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1846 // which case -1 is a valid value for x and y)
1848 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1849 // the width/height to best suit our contents, otherwise we reuse the current
1851 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1853 // get the current size and position...
1854 int currentX
, currentY
;
1855 int currentW
, currentH
;
1857 GetPosition(¤tX
, ¤tY
);
1858 GetSize(¤tW
, ¤tH
);
1860 // ... and don't do anything (avoiding flicker) if it's already ok
1861 if ( x
== currentX
&& y
== currentY
&&
1862 width
== currentW
&& height
== currentH
&& ( height
!= -1 && width
!= -1 ) )
1865 MacRepositionScrollBars() ; // we might have a real position shift
1870 if ( !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1872 if ( x
== wxDefaultCoord
)
1874 if ( y
== wxDefaultCoord
)
1878 AdjustForParentClientOrigin( x
, y
, sizeFlags
);
1880 wxSize size
= wxDefaultSize
;
1881 if ( width
== wxDefaultCoord
)
1883 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
1885 size
= DoGetBestSize();
1890 // just take the current one
1895 if ( height
== wxDefaultCoord
)
1897 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
1899 if ( size
.x
== wxDefaultCoord
)
1900 size
= DoGetBestSize();
1901 // else: already called DoGetBestSize() above
1907 // just take the current one
1912 DoMoveWindow( x
, y
, width
, height
);
1915 wxPoint
wxWindowMac::GetClientAreaOrigin() const
1917 RgnHandle rgn
= NewRgn() ;
1919 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1921 GetRegionBounds( rgn
, &content
) ;
1931 return wxPoint( content
.left
+ MacGetLeftBorderSize() , content
.top
+ MacGetTopBorderSize() );
1934 void wxWindowMac::DoSetClientSize(int clientwidth
, int clientheight
)
1936 if ( clientwidth
!= wxDefaultCoord
|| clientheight
!= wxDefaultCoord
)
1938 int currentclientwidth
, currentclientheight
;
1939 int currentwidth
, currentheight
;
1941 GetClientSize( ¤tclientwidth
, ¤tclientheight
) ;
1942 GetSize( ¤twidth
, ¤theight
) ;
1944 DoSetSize( wxDefaultCoord
, wxDefaultCoord
, currentwidth
+ clientwidth
- currentclientwidth
,
1945 currentheight
+ clientheight
- currentclientheight
, wxSIZE_USE_EXISTING
) ;
1949 void wxWindowMac::SetLabel(const wxString
& title
)
1953 if ( m_peer
&& m_peer
->Ok() )
1954 m_peer
->SetLabel( wxStripMenuCodes(m_label
, wxStrip_Mnemonics
) ) ;
1956 // do not trigger refreshes upon invisible and possible partly created objects
1957 if ( IsShownOnScreen() )
1961 wxString
wxWindowMac::GetLabel() const
1966 bool wxWindowMac::Show(bool show
)
1968 if ( !wxWindowBase::Show(show
) )
1972 m_peer
->SetVisibility( show
, true ) ;
1977 void wxWindowMac::DoEnable(bool enable
)
1979 m_peer
->Enable( enable
) ;
1983 // status change notifications
1986 void wxWindowMac::MacVisibilityChanged()
1990 void wxWindowMac::MacHiliteChanged()
1994 void wxWindowMac::MacEnabledStateChanged()
1996 OnEnabled( m_peer
->IsEnabled() );
2000 // status queries on the inherited window's state
2003 bool wxWindowMac::MacIsReallyEnabled()
2005 return m_peer
->IsEnabled() ;
2008 bool wxWindowMac::MacIsReallyHilited()
2010 return m_peer
->IsActive();
2013 void wxWindowMac::MacFlashInvalidAreas()
2015 #if TARGET_API_MAC_OSX
2016 HIViewFlashDirtyArea( (WindowRef
) MacGetTopLevelWindowRef() ) ;
2020 int wxWindowMac::GetCharHeight() const
2022 wxClientDC
dc( (wxWindowMac
*)this ) ;
2024 return dc
.GetCharHeight() ;
2027 int wxWindowMac::GetCharWidth() const
2029 wxClientDC
dc( (wxWindowMac
*)this ) ;
2031 return dc
.GetCharWidth() ;
2034 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
2035 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
2037 const wxFont
*fontToUse
= theFont
;
2039 fontToUse
= &m_font
;
2041 wxClientDC
dc( (wxWindowMac
*) this ) ;
2042 wxCoord lx
,ly
,ld
,le
;
2043 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
2044 if ( externalLeading
)
2045 *externalLeading
= le
;
2055 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
2056 * we always intersect with the entire window, not only with the client area
2059 void wxWindowMac::Refresh(bool WXUNUSED(eraseBack
), const wxRect
*rect
)
2061 if ( m_peer
== NULL
)
2064 if ( !IsShownOnScreen() )
2071 wxMacRectToNative( rect
, &r
) ;
2072 m_peer
->SetNeedsDisplay( &r
) ;
2076 m_peer
->SetNeedsDisplay() ;
2080 void wxWindowMac::DoFreeze()
2082 #if TARGET_API_MAC_OSX
2083 if ( m_peer
&& m_peer
->Ok() )
2084 m_peer
->SetDrawingEnabled( false ) ;
2088 void wxWindowMac::DoThaw()
2090 #if TARGET_API_MAC_OSX
2091 if ( m_peer
&& m_peer
->Ok() )
2093 m_peer
->SetDrawingEnabled( true ) ;
2094 m_peer
->InvalidateWithChildren() ;
2099 wxWindowMac
*wxGetActiveWindow()
2101 // actually this is a windows-only concept
2105 // Coordinates relative to the window
2106 void wxWindowMac::WarpPointer(int WXUNUSED(x_pos
), int WXUNUSED(y_pos
))
2108 // We really don't move the mouse programmatically under Mac.
2111 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
2113 if ( MacGetTopLevelWindow() == NULL
)
2116 #if TARGET_API_MAC_OSX
2117 if ( !m_backgroundColour.Ok() || GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
2123 if ( GetBackgroundStyle() == wxBG_STYLE_COLOUR
)
2125 event
.GetDC()->Clear() ;
2127 else if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM
)
2129 // don't skip the event here, custom background means that the app
2130 // is drawing it itself in its OnPaint(), so don't draw it at all
2131 // now to avoid flicker
2139 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
2144 int wxWindowMac::GetScrollPos(int orient
) const
2146 if ( orient
== wxHORIZONTAL
)
2149 return m_hScrollBar
->GetThumbPosition() ;
2154 return m_vScrollBar
->GetThumbPosition() ;
2160 // This now returns the whole range, not just the number
2161 // of positions that we can scroll.
2162 int wxWindowMac::GetScrollRange(int orient
) const
2164 if ( orient
== wxHORIZONTAL
)
2167 return m_hScrollBar
->GetRange() ;
2172 return m_vScrollBar
->GetRange() ;
2178 int wxWindowMac::GetScrollThumb(int orient
) const
2180 if ( orient
== wxHORIZONTAL
)
2183 return m_hScrollBar
->GetThumbSize() ;
2188 return m_vScrollBar
->GetThumbSize() ;
2194 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool WXUNUSED(refresh
))
2196 if ( orient
== wxHORIZONTAL
)
2199 m_hScrollBar
->SetThumbPosition( pos
) ;
2204 m_vScrollBar
->SetThumbPosition( pos
) ;
2209 wxWindowMac::AlwaysShowScrollbars(bool hflag
, bool vflag
)
2211 bool needVisibilityUpdate
= false;
2213 if ( m_hScrollBarAlwaysShown
!= hflag
)
2215 m_hScrollBarAlwaysShown
= hflag
;
2216 needVisibilityUpdate
= true;
2219 if ( m_vScrollBarAlwaysShown
!= vflag
)
2221 m_vScrollBarAlwaysShown
= vflag
;
2222 needVisibilityUpdate
= true;
2225 if ( needVisibilityUpdate
)
2226 DoUpdateScrollbarVisibility();
2230 // we draw borders and grow boxes, are already set up and clipped in the current port / cgContextRef
2231 // our own window origin is at leftOrigin/rightOrigin
2234 void wxWindowMac::MacPaintGrowBox()
2239 if ( MacHasScrollBarCorner() )
2243 CGContextRef cgContext
= (CGContextRef
) MacGetCGContextRef() ;
2244 wxASSERT( cgContext
) ;
2246 m_peer
->GetRect( &rect
) ;
2248 int size
= m_hScrollBar
? m_hScrollBar
->GetSize().y
: ( m_vScrollBar
? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2249 CGRect cgrect
= CGRectMake( rect
.right
- size
, rect
.bottom
- size
, size
, size
) ;
2250 CGPoint cgpoint
= CGPointMake( rect
.right
- size
, rect
.bottom
- size
) ;
2251 CGContextSaveGState( cgContext
);
2253 if ( m_backgroundColour
.Ok() )
2255 CGContextSetFillColorWithColor( cgContext
, m_backgroundColour
.GetCGColor() );
2259 CGContextSetRGBFillColor( cgContext
, (CGFloat
) 1.0, (CGFloat
)1.0 ,(CGFloat
) 1.0 , (CGFloat
)1.0 );
2261 CGContextFillRect( cgContext
, cgrect
);
2262 CGContextRestoreGState( cgContext
);
2266 void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin
) , int WXUNUSED(rightOrigin
) )
2272 bool hasFocus
= m_peer
->NeedsFocusRect() && m_peer
->HasFocus() ;
2274 // back to the surrounding frame rectangle
2275 m_peer
->GetRect( &rect
) ;
2276 InsetRect( &rect
, -1 , -1 ) ;
2279 CGRect cgrect
= CGRectMake( rect
.left
, rect
.top
, rect
.right
- rect
.left
,
2280 rect
.bottom
- rect
.top
) ;
2282 HIThemeFrameDrawInfo info
;
2283 memset( &info
, 0 , sizeof(info
) ) ;
2287 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
2288 info
.isFocused
= hasFocus
;
2290 CGContextRef cgContext
= (CGContextRef
) GetParent()->MacGetCGContextRef() ;
2291 wxASSERT( cgContext
) ;
2293 if ( HasFlag(wxRAISED_BORDER
) || HasFlag(wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
2295 info
.kind
= kHIThemeFrameTextFieldSquare
;
2296 HIThemeDrawFrame( &cgrect
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2298 else if ( HasFlag(wxSIMPLE_BORDER
) )
2300 info
.kind
= kHIThemeFrameListBox
;
2301 HIThemeDrawFrame( &cgrect
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2303 else if ( hasFocus
)
2305 HIThemeDrawFocusRect( &cgrect
, true , cgContext
, kHIThemeOrientationNormal
) ;
2307 #if 0 // TODO REMOVE now done in a separate call earlier in drawing the window itself
2308 m_peer
->GetRect( &rect
) ;
2309 if ( MacHasScrollBarCorner() )
2311 int variant
= (m_hScrollBar
== NULL
? m_vScrollBar
: m_hScrollBar
) ->GetWindowVariant();
2312 int size
= m_hScrollBar
? m_hScrollBar
->GetSize().y
: ( m_vScrollBar
? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2313 CGRect cgrect
= CGRectMake( rect
.right
- size
, rect
.bottom
- size
, size
, size
) ;
2314 CGPoint cgpoint
= CGPointMake( rect
.right
- size
, rect
.bottom
- size
) ;
2315 HIThemeGrowBoxDrawInfo info
;
2316 memset( &info
, 0, sizeof(info
) ) ;
2318 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
2319 info
.kind
= kHIThemeGrowBoxKindNone
;
2320 // contrary to the docs ...SizeSmall does not work
2321 info
.size
= kHIThemeGrowBoxSizeNormal
;
2322 info
.direction
= 0 ;
2323 HIThemeDrawGrowBox( &cgpoint
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2329 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
2331 if ( child
== m_hScrollBar
)
2332 m_hScrollBar
= NULL
;
2333 if ( child
== m_vScrollBar
)
2334 m_vScrollBar
= NULL
;
2336 wxWindowBase::RemoveChild( child
) ;
2339 void wxWindowMac::DoUpdateScrollbarVisibility()
2341 bool triggerSizeEvent
= false;
2345 bool showHScrollBar
= m_hScrollBarAlwaysShown
|| m_hScrollBar
->IsNeeded();
2347 if ( m_hScrollBar
->IsShown() != showHScrollBar
)
2349 m_hScrollBar
->Show( showHScrollBar
);
2350 triggerSizeEvent
= true;
2356 bool showVScrollBar
= m_vScrollBarAlwaysShown
|| m_vScrollBar
->IsNeeded();
2358 if ( m_vScrollBar
->IsShown() != showVScrollBar
)
2360 m_vScrollBar
->Show( showVScrollBar
) ;
2361 triggerSizeEvent
= true;
2365 MacRepositionScrollBars() ;
2366 if ( triggerSizeEvent
)
2368 wxSizeEvent
event(GetSize(), m_windowId
);
2369 event
.SetEventObject(this);
2370 HandleWindowEvent(event
);
2374 // New function that will replace some of the above.
2375 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumb
,
2376 int range
, bool refresh
)
2378 if ( orient
== wxHORIZONTAL
&& m_hScrollBar
)
2379 m_hScrollBar
->SetScrollbar(pos
, thumb
, range
, thumb
, refresh
);
2380 else if ( orient
== wxVERTICAL
&& m_vScrollBar
)
2381 m_vScrollBar
->SetScrollbar(pos
, thumb
, range
, thumb
, refresh
);
2383 DoUpdateScrollbarVisibility();
2386 // Does a physical scroll
2387 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
2389 if ( dx
== 0 && dy
== 0 )
2392 int width
, height
;
2393 GetClientSize( &width
, &height
) ;
2396 // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
2397 // area is scrolled, this does not occur if width and height are 2 pixels less,
2398 // TODO: write optimal workaround
2399 wxRect
scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width
, height
) ;
2401 scrollrect
.Intersect( *rect
) ;
2403 if ( m_peer
->GetNeedsDisplay() )
2405 // because HIViewScrollRect does not scroll the already invalidated area we have two options:
2406 // in case there is already a pending redraw on that area
2407 // either immediate redraw or full invalidate
2409 // is the better overall solution, as it does not slow down scrolling
2410 m_peer
->SetNeedsDisplay() ;
2412 // this would be the preferred version for fast drawing controls
2413 HIViewRender(m_peer
->GetControlRef()) ;
2417 // as the native control might be not a 0/0 wx window coordinates, we have to offset
2418 scrollrect
.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2419 m_peer
->ScrollRect( &scrollrect
, dx
, dy
) ;
2422 // this would be the preferred version for fast drawing controls
2423 HIViewRender(m_peer
->GetControlRef()) ;
2429 for (wxWindowList::compatibility_iterator node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2431 child
= node
->GetData();
2434 if (child
== m_vScrollBar
)
2436 if (child
== m_hScrollBar
)
2438 if (child
->IsTopLevel())
2441 child
->GetPosition( &x
, &y
);
2442 child
->GetSize( &w
, &h
);
2445 wxRect
rc( x
, y
, w
, h
);
2446 if (rect
->Intersects( rc
))
2447 child
->SetSize( x
+ dx
, y
+ dy
, w
, h
, wxSIZE_AUTO
|wxSIZE_ALLOW_MINUS_ONE
);
2451 child
->SetSize( x
+ dx
, y
+ dy
, w
, h
, wxSIZE_AUTO
|wxSIZE_ALLOW_MINUS_ONE
);
2456 void wxWindowMac::MacOnScroll( wxScrollEvent
&event
)
2458 if ( event
.GetEventObject() == m_vScrollBar
|| event
.GetEventObject() == m_hScrollBar
)
2460 wxScrollWinEvent wevent
;
2461 wevent
.SetPosition(event
.GetPosition());
2462 wevent
.SetOrientation(event
.GetOrientation());
2463 wevent
.SetEventObject(this);
2465 if (event
.GetEventType() == wxEVT_SCROLL_TOP
)
2466 wevent
.SetEventType( wxEVT_SCROLLWIN_TOP
);
2467 else if (event
.GetEventType() == wxEVT_SCROLL_BOTTOM
)
2468 wevent
.SetEventType( wxEVT_SCROLLWIN_BOTTOM
);
2469 else if (event
.GetEventType() == wxEVT_SCROLL_LINEUP
)
2470 wevent
.SetEventType( wxEVT_SCROLLWIN_LINEUP
);
2471 else if (event
.GetEventType() == wxEVT_SCROLL_LINEDOWN
)
2472 wevent
.SetEventType( wxEVT_SCROLLWIN_LINEDOWN
);
2473 else if (event
.GetEventType() == wxEVT_SCROLL_PAGEUP
)
2474 wevent
.SetEventType( wxEVT_SCROLLWIN_PAGEUP
);
2475 else if (event
.GetEventType() == wxEVT_SCROLL_PAGEDOWN
)
2476 wevent
.SetEventType( wxEVT_SCROLLWIN_PAGEDOWN
);
2477 else if (event
.GetEventType() == wxEVT_SCROLL_THUMBTRACK
)
2478 wevent
.SetEventType( wxEVT_SCROLLWIN_THUMBTRACK
);
2479 else if (event
.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
)
2480 wevent
.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE
);
2482 HandleWindowEvent(wevent
);
2486 // Get the window with the focus
2487 wxWindowMac
*wxWindowBase::DoFindFocus()
2489 ControlRef control
;
2490 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
2491 return wxFindControlFromMacControl( control
) ;
2494 void wxWindowMac::OnInternalIdle()
2496 // This calls the UI-update mechanism (querying windows for
2497 // menu/toolbar/control state information)
2498 if (wxUpdateUIEvent::CanUpdate(this) && IsShownOnScreen())
2499 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
2502 // Raise the window to the top of the Z order
2503 void wxWindowMac::Raise()
2505 m_peer
->SetZOrder( true , NULL
) ;
2508 // Lower the window to the bottom of the Z order
2509 void wxWindowMac::Lower()
2511 m_peer
->SetZOrder( false , NULL
) ;
2514 // static wxWindow *gs_lastWhich = NULL;
2516 bool wxWindowMac::MacSetupCursor( const wxPoint
& pt
)
2518 // first trigger a set cursor event
2520 wxPoint clientorigin
= GetClientAreaOrigin() ;
2521 wxSize clientsize
= GetClientSize() ;
2523 if ( wxRect2DInt( clientorigin
.x
, clientorigin
.y
, clientsize
.x
, clientsize
.y
).Contains( wxPoint2DInt( pt
) ) )
2525 wxSetCursorEvent
event( pt
.x
, pt
.y
);
2527 bool processedEvtSetCursor
= HandleWindowEvent(event
);
2528 if ( processedEvtSetCursor
&& event
.HasCursor() )
2530 cursor
= event
.GetCursor() ;
2534 // the test for processedEvtSetCursor is here to prevent using m_cursor
2535 // if the user code caught EVT_SET_CURSOR() and returned nothing from
2536 // it - this is a way to say that our cursor shouldn't be used for this
2538 if ( !processedEvtSetCursor
&& m_cursor
.Ok() )
2541 if ( !wxIsBusy() && !GetParent() )
2542 cursor
= *wxSTANDARD_CURSOR
;
2546 cursor
.MacInstall() ;
2549 return cursor
.Ok() ;
2552 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&WXUNUSED(pt
) )
2556 return m_tooltip
->GetTip() ;
2559 return wxEmptyString
;
2562 void wxWindowMac::ClearBackground()
2568 void wxWindowMac::Update()
2570 wxNonOwnedWindow
* top
= MacGetTopLevelWindow();
2572 top
->MacPerformUpdates() ;
2575 wxNonOwnedWindow
* wxWindowMac::MacGetTopLevelWindow() const
2577 wxNonOwnedWindow
* win
= NULL
;
2578 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
2580 win
= wxFindWinFromMacWindow( window
) ;
2585 const wxRect
& wxWindowMac::MacGetClippedClientRect() const
2587 MacUpdateClippedRects() ;
2589 return m_cachedClippedClientRect
;
2592 const wxRect
& wxWindowMac::MacGetClippedRect() const
2594 MacUpdateClippedRects() ;
2596 return m_cachedClippedRect
;
2599 const wxRect
&wxWindowMac:: MacGetClippedRectWithOuterStructure() const
2601 MacUpdateClippedRects() ;
2603 return m_cachedClippedRectWithOuterStructure
;
2606 const wxRegion
& wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures
)
2608 static wxRegion emptyrgn
;
2610 if ( !m_isBeingDeleted
&& IsShownOnScreen() )
2612 MacUpdateClippedRects() ;
2613 if ( includeOuterStructures
)
2614 return m_cachedClippedRegionWithOuterStructure
;
2616 return m_cachedClippedRegion
;
2624 void wxWindowMac::MacUpdateClippedRects() const
2626 if ( m_cachedClippedRectValid
)
2629 // includeOuterStructures is true if we try to draw somthing like a focus ring etc.
2630 // also a window dc uses this, in this case we only clip in the hierarchy for hard
2631 // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
2632 // to add focus borders everywhere
2634 Rect r
, rIncludingOuterStructures
;
2636 m_peer
->GetRect( &r
) ;
2637 r
.left
-= MacGetLeftBorderSize() ;
2638 r
.top
-= MacGetTopBorderSize() ;
2639 r
.bottom
+= MacGetBottomBorderSize() ;
2640 r
.right
+= MacGetRightBorderSize() ;
2647 rIncludingOuterStructures
= r
;
2648 InsetRect( &rIncludingOuterStructures
, -4 , -4 ) ;
2650 wxRect cl
= GetClientRect() ;
2651 Rect rClient
= { cl
.y
, cl
.x
, cl
.y
+ cl
.height
, cl
.x
+ cl
.width
} ;
2655 const wxWindow
* child
= this ;
2656 const wxWindow
* parent
= NULL
;
2658 while ( !child
->IsTopLevel() && ( parent
= child
->GetParent() ) != NULL
)
2660 if ( parent
->MacIsChildOfClientArea(child
) )
2662 size
= parent
->GetClientSize() ;
2663 wxPoint origin
= parent
->GetClientAreaOrigin() ;
2669 // this will be true for scrollbars, toolbars etc.
2670 size
= parent
->GetSize() ;
2671 y
= parent
->MacGetTopBorderSize() ;
2672 x
= parent
->MacGetLeftBorderSize() ;
2673 size
.x
-= parent
->MacGetLeftBorderSize() + parent
->MacGetRightBorderSize() ;
2674 size
.y
-= parent
->MacGetTopBorderSize() + parent
->MacGetBottomBorderSize() ;
2677 parent
->MacWindowToRootWindow( &x
, &y
) ;
2678 MacRootWindowToWindow( &x
, &y
) ;
2680 Rect rparent
= { y
, x
, y
+ size
.y
, x
+ size
.x
} ;
2682 // the wxwindow and client rects will always be clipped
2683 SectRect( &r
, &rparent
, &r
) ;
2684 SectRect( &rClient
, &rparent
, &rClient
) ;
2686 // the structure only at 'hard' borders
2687 if ( parent
->MacClipChildren() ||
2688 ( parent
->GetParent() && parent
->GetParent()->MacClipGrandChildren() ) )
2690 SectRect( &rIncludingOuterStructures
, &rparent
, &rIncludingOuterStructures
) ;
2696 m_cachedClippedRect
= wxRect( r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
- r
.top
) ;
2697 m_cachedClippedClientRect
= wxRect( rClient
.left
, rClient
.top
,
2698 rClient
.right
- rClient
.left
, rClient
.bottom
- rClient
.top
) ;
2699 m_cachedClippedRectWithOuterStructure
= wxRect(
2700 rIncludingOuterStructures
.left
, rIncludingOuterStructures
.top
,
2701 rIncludingOuterStructures
.right
- rIncludingOuterStructures
.left
,
2702 rIncludingOuterStructures
.bottom
- rIncludingOuterStructures
.top
) ;
2704 m_cachedClippedRegionWithOuterStructure
= wxRegion( m_cachedClippedRectWithOuterStructure
) ;
2705 m_cachedClippedRegion
= wxRegion( m_cachedClippedRect
) ;
2706 m_cachedClippedClientRegion
= wxRegion( m_cachedClippedClientRect
) ;
2708 m_cachedClippedRectValid
= true ;
2712 This function must not change the updatergn !
2714 bool wxWindowMac::MacDoRedraw( void* updatergnr
, long time
)
2716 bool handled
= false ;
2718 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2719 GetRegionBounds( updatergn
, &updatebounds
) ;
2721 // wxLogDebug(wxT("update for %s bounds %d, %d, %d, %d"), wxString(GetClassInfo()->GetClassName()).c_str(), updatebounds.left, updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
2723 if ( !EmptyRgn(updatergn
) )
2725 RgnHandle newupdate
= NewRgn() ;
2726 wxSize point
= GetClientSize() ;
2727 wxPoint origin
= GetClientAreaOrigin() ;
2728 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+ point
.y
) ;
2729 SectRgn( newupdate
, updatergn
, newupdate
) ;
2731 // first send an erase event to the entire update area
2733 // for the toplevel window this really is the entire area
2734 // for all the others only their client area, otherwise they
2735 // might be drawing with full alpha and eg put blue into
2736 // the grow-box area of a scrolled window (scroll sample)
2737 wxDC
* dc
= new wxWindowDC(this);
2739 dc
->SetClippingRegion(wxRegion(HIShapeCreateWithQDRgn(updatergn
)));
2741 dc
->SetClippingRegion(wxRegion(HIShapeCreateWithQDRgn(newupdate
)));
2743 wxEraseEvent
eevent( GetId(), dc
);
2744 eevent
.SetEventObject( this );
2745 HandleWindowEvent( eevent
);
2751 // calculate a client-origin version of the update rgn and set m_updateRegion to that
2752 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
2753 m_updateRegion
= wxRegion(HIShapeCreateWithQDRgn(newupdate
)) ;
2754 DisposeRgn( newupdate
) ;
2756 if ( !m_updateRegion
.Empty() )
2758 // paint the window itself
2761 event
.SetTimestamp(time
);
2762 event
.SetEventObject(this);
2763 HandleWindowEvent(event
);
2767 // now we cannot rely on having its borders drawn by a window itself, as it does not
2768 // get the updateRgn wide enough to always do so, so we do it from the parent
2769 // this would also be the place to draw any custom backgrounds for native controls
2770 // in Composited windowing
2771 wxPoint clientOrigin
= GetClientAreaOrigin() ;
2775 for (wxWindowList::compatibility_iterator node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2777 child
= node
->GetData();
2780 if (child
== m_vScrollBar
)
2782 if (child
== m_hScrollBar
)
2784 if (child
->IsTopLevel())
2786 if (!child
->IsShown())
2789 // only draw those in the update region (add a safety margin of 10 pixels for shadow effects
2791 child
->GetPosition( &x
, &y
);
2792 child
->GetSize( &w
, &h
);
2793 Rect childRect
= { y
, x
, y
+ h
, x
+ w
} ;
2794 OffsetRect( &childRect
, clientOrigin
.x
, clientOrigin
.y
) ;
2795 InsetRect( &childRect
, -10 , -10) ;
2797 if ( RectInRgn( &childRect
, updatergn
) )
2799 // paint custom borders
2800 wxNcPaintEvent
eventNc( child
->GetId() );
2801 eventNc
.SetEventObject( child
);
2802 if ( !child
->HandleWindowEvent( eventNc
) )
2804 child
->MacPaintBorders(0, 0) ;
2814 WXWindow
wxWindowMac::MacGetTopLevelWindowRef() const
2816 wxWindowMac
*iter
= (wxWindowMac
*)this ;
2820 if ( iter
->IsTopLevel() )
2822 wxTopLevelWindow
* toplevel
= wxDynamicCast(iter
,wxTopLevelWindow
);
2824 return toplevel
->MacGetWindowRef();
2826 wxPopupWindow
* popupwin
= wxDynamicCast(iter
,wxPopupWindow
);
2828 return popupwin
->MacGetWindowRef();
2831 iter
= iter
->GetParent() ;
2837 bool wxWindowMac::MacHasScrollBarCorner() const
2839 /* Returns whether the scroll bars in a wxScrolledWindow should be
2840 * shortened. Scroll bars should be shortened if either:
2842 * - both scroll bars are visible, or
2844 * - there is a resize box in the parent frame's corner and this
2845 * window shares the bottom and right edge with the parent
2849 if ( m_hScrollBar
== NULL
&& m_vScrollBar
== NULL
)
2852 if ( ( m_hScrollBar
&& m_hScrollBar
->IsShown() )
2853 && ( m_vScrollBar
&& m_vScrollBar
->IsShown() ) )
2855 // Both scroll bars visible
2860 wxPoint thisWindowBottomRight
= GetScreenRect().GetBottomRight();
2862 for ( const wxWindow
*win
= this; win
; win
= win
->GetParent() )
2864 const wxFrame
*frame
= wxDynamicCast( win
, wxFrame
) ;
2867 if ( frame
->GetWindowStyleFlag() & wxRESIZE_BORDER
)
2869 // Parent frame has resize handle
2870 wxPoint frameBottomRight
= frame
->GetScreenRect().GetBottomRight();
2872 // Note: allow for some wiggle room here as wxMac's
2873 // window rect calculations seem to be imprecise
2874 if ( abs( thisWindowBottomRight
.x
- frameBottomRight
.x
) <= 2
2875 && abs( thisWindowBottomRight
.y
- frameBottomRight
.y
) <= 2 )
2877 // Parent frame has resize handle and shares
2878 // right bottom corner
2883 // Parent frame has resize handle but doesn't
2884 // share right bottom corner
2890 // Parent frame doesn't have resize handle
2896 // No parent frame found
2901 void wxWindowMac::MacCreateScrollBars( long style
)
2903 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, wxT("attempt to create window twice") ) ;
2905 if ( style
& ( wxVSCROLL
| wxHSCROLL
) )
2907 int scrlsize
= MAC_SCROLLBAR_SIZE
;
2908 if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL
|| GetWindowVariant() == wxWINDOW_VARIANT_MINI
)
2910 scrlsize
= MAC_SMALL_SCROLLBAR_SIZE
;
2913 int adjust
= MacHasScrollBarCorner() ? scrlsize
- 1: 0 ;
2915 GetClientSize( &width
, &height
) ;
2917 wxPoint
vPoint(width
- scrlsize
, 0) ;
2918 wxSize
vSize(scrlsize
, height
- adjust
) ;
2919 wxPoint
hPoint(0, height
- scrlsize
) ;
2920 wxSize
hSize(width
- adjust
, scrlsize
) ;
2922 // we have to set the min size to a smaller value, otherwise they cannot get smaller (InitialSize sets MinSize)
2923 if ( style
& wxVSCROLL
)
2925 m_vScrollBar
= new wxScrollBar((wxWindow
*)this, wxID_ANY
, vPoint
, vSize
, wxVERTICAL
);
2926 m_vScrollBar
->SetMinSize( wxDefaultSize
);
2929 if ( style
& wxHSCROLL
)
2931 m_hScrollBar
= new wxScrollBar((wxWindow
*)this, wxID_ANY
, hPoint
, hSize
, wxHORIZONTAL
);
2932 m_hScrollBar
->SetMinSize( wxDefaultSize
);
2936 // because the create does not take into account the client area origin
2937 // we might have a real position shift
2938 MacRepositionScrollBars() ;
2941 bool wxWindowMac::MacIsChildOfClientArea( const wxWindow
* child
) const
2943 bool result
= ((child
== NULL
) || ((child
!= m_hScrollBar
) && (child
!= m_vScrollBar
)));
2948 void wxWindowMac::MacRepositionScrollBars()
2950 if ( !m_hScrollBar
&& !m_vScrollBar
)
2953 int scrlsize
= m_hScrollBar
? m_hScrollBar
->GetSize().y
: ( m_vScrollBar
? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2954 int adjust
= MacHasScrollBarCorner() ? scrlsize
- 1 : 0 ;
2956 // get real client area
2958 GetSize( &width
, &height
);
2960 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
2961 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
2963 wxPoint
vPoint( width
- scrlsize
, 0 ) ;
2964 wxSize
vSize( scrlsize
, height
- adjust
) ;
2965 wxPoint
hPoint( 0 , height
- scrlsize
) ;
2966 wxSize
hSize( width
- adjust
, scrlsize
) ;
2969 int x
= 0, y
= 0, w
, h
;
2970 GetSize( &w
, &h
) ;
2972 MacClientToRootWindow( &x
, &y
) ;
2973 MacClientToRootWindow( &w
, &h
) ;
2975 wxWindowMac
*iter
= (wxWindowMac
*)this ;
2977 int totW
= 10000 , totH
= 10000;
2980 if ( iter
->IsTopLevel() )
2982 iter
->GetSize( &totW
, &totH
) ;
2986 iter
= iter
->GetParent() ;
3000 if ( w
- x
>= totW
)
3005 if ( h
- y
>= totH
)
3013 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
3015 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
3018 bool wxWindowMac::AcceptsFocus() const
3020 return MacCanFocus() && wxWindowBase::AcceptsFocus();
3023 void wxWindowMac::MacSuperChangedPosition()
3025 // only window-absolute structures have to be moved i.e. controls
3027 m_cachedClippedRectValid
= false ;
3030 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
3033 child
= node
->GetData();
3034 child
->MacSuperChangedPosition() ;
3036 node
= node
->GetNext();
3040 void wxWindowMac::MacTopLevelWindowChangedPosition()
3042 // only screen-absolute structures have to be moved i.e. glcanvas
3045 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
3048 child
= node
->GetData();
3049 child
->MacTopLevelWindowChangedPosition() ;
3051 node
= node
->GetNext();
3055 long wxWindowMac::MacGetLeftBorderSize() const
3062 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
))
3064 // this metric is only the 'outset' outside the simple frame rect
3065 GetThemeMetric( kThemeMetricEditTextFrameOutset
, &border
) ;
3068 else if (HasFlag(wxSIMPLE_BORDER
))
3070 // this metric is only the 'outset' outside the simple frame rect
3071 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
3078 long wxWindowMac::MacGetRightBorderSize() const
3080 // they are all symmetric in mac themes
3081 return MacGetLeftBorderSize() ;
3084 long wxWindowMac::MacGetTopBorderSize() const
3086 // they are all symmetric in mac themes
3087 return MacGetLeftBorderSize() ;
3090 long wxWindowMac::MacGetBottomBorderSize() const
3092 // they are all symmetric in mac themes
3093 return MacGetLeftBorderSize() ;
3096 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
3098 return style
& ~wxBORDER_MASK
;
3101 // Find the wxWindowMac at the current mouse position, returning the mouse
3103 wxWindowMac
* wxFindWindowAtPointer( wxPoint
& pt
)
3105 pt
= wxGetMousePosition();
3106 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
3111 // Get the current mouse position.
3112 wxPoint
wxGetMousePosition()
3116 wxGetMousePosition( &x
, &y
);
3118 return wxPoint(x
, y
);
3121 void wxWindowMac::OnMouseEvent( wxMouseEvent
&event
)
3123 if ( event
.GetEventType() == wxEVT_RIGHT_DOWN
)
3125 // copied from wxGTK : CS
3126 // VZ: shouldn't we move this to base class then?
3128 // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
3131 // (a) it's a command event and so is propagated to the parent
3132 // (b) under MSW it can be generated from kbd too
3133 // (c) it uses screen coords (because of (a))
3134 wxContextMenuEvent
evtCtx(wxEVT_CONTEXT_MENU
,
3136 this->ClientToScreen(event
.GetPosition()));
3137 evtCtx
.SetEventObject(this);
3138 if ( ! HandleWindowEvent(evtCtx
) )
3147 void wxWindowMac::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
3149 if ( wxTheApp
->MacGetCurrentEvent() != NULL
&& wxTheApp
->MacGetCurrentEventHandlerCallRef() != NULL
3150 && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT
)
3151 CallNextEventHandler(
3152 (EventHandlerCallRef
)wxTheApp
->MacGetCurrentEventHandlerCallRef() ,
3153 (EventRef
) wxTheApp
->MacGetCurrentEvent() ) ;
3156 void wxWindowMac::MacHandleControlClick(WXWidget
WXUNUSED(control
),
3157 wxInt16
WXUNUSED(controlpart
),
3158 bool WXUNUSED(mouseStillDown
))
3162 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
)
3166 window
->MacGetBoundsForControl( pos
, size
, x
, y
, w
, h
, adjustForOrigin
) ;
3167 Rect bounds
= { y
, x
, y
+ h
, x
+ w
};
3172 wxInt32
wxWindowMac::MacControlHit(WXEVENTHANDLERREF
WXUNUSED(handler
) , WXEVENTREF
WXUNUSED(event
) )
3174 return eventNotHandledErr
;
3177 bool wxWindowMac::Reparent(wxWindowBase
*newParentBase
)
3179 wxWindowMac
*newParent
= (wxWindowMac
*)newParentBase
;
3180 if ( !wxWindowBase::Reparent(newParent
) )
3183 // copied from MacPostControlCreate
3184 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
3186 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
3188 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
3193 bool wxWindowMac::SetTransparent(wxByte alpha
)
3195 SetBackgroundStyle(wxBG_STYLE_TRANSPARENT
);
3197 if ( alpha
!= m_macAlpha
)
3199 m_macAlpha
= alpha
;
3206 bool wxWindowMac::CanSetTransparent()
3211 wxByte
wxWindowMac::GetTransparent() const
3216 bool wxWindowMac::IsShownOnScreen() const
3218 #if TARGET_API_MAC_OSX
3219 if ( m_peer
&& m_peer
->Ok() )
3221 bool peerVis
= m_peer
->IsVisible();
3222 bool wxVis
= wxWindowBase::IsShownOnScreen();
3223 if( peerVis
!= wxVis
)
3225 // CS : put a breakpoint here to investigate differences
3226 // between native an wx visibilities
3227 // the only place where I've encountered them until now
3228 // are the hiding/showing sequences where the vis-changed event is
3229 // first sent to the innermost control, while wx does things
3230 // from the outmost control
3231 wxVis
= wxWindowBase::IsShownOnScreen();
3235 return m_peer
->IsVisible();
3239 return wxWindowBase::IsShownOnScreen();