1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowMac
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
18 #include "wx/window.h"
20 #include "wx/dcclient.h"
24 #include "wx/layout.h"
25 #include "wx/dialog.h"
26 #include "wx/listbox.h"
27 #include "wx/scrolbar.h"
28 #include "wx/statbox.h"
29 #include "wx/button.h"
30 #include "wx/settings.h"
31 #include "wx/msgdlg.h"
33 #include "wx/notebook.h"
34 #include "wx/tabctrl.h"
35 #include "wx/tooltip.h"
36 #include "wx/statusbr.h"
37 #include "wx/menuitem.h"
44 #define wxWINDOW_HSCROLL 5998
45 #define wxWINDOW_VSCROLL 5997
46 #define MAC_SCROLLBAR_SIZE 16
48 #include "wx/mac/uma.h"
50 #if wxUSE_DRAG_AND_DROP
56 extern wxList wxPendingDelete
;
57 wxWindowMac
* gFocusWindow
= NULL
;
59 #ifdef __WXUNIVERSAL__
60 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
62 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
63 #endif // __WXUNIVERSAL__/__WXMAC__
65 #if !USE_SHARED_LIBRARY
67 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
68 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
69 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
70 EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged
)
71 EVT_INIT_DIALOG(wxWindowMac::OnInitDialog
)
72 EVT_IDLE(wxWindowMac::OnIdle
)
73 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
78 #define wxMAC_DEBUG_REDRAW 0
79 #ifndef wxMAC_DEBUG_REDRAW
80 #define wxMAC_DEBUG_REDRAW 0
83 #define wxMAC_USE_THEME_BORDER 0
86 // ===========================================================================
88 // ===========================================================================
91 // ----------------------------------------------------------------------------
92 // constructors and such
93 // ----------------------------------------------------------------------------
95 void wxWindowMac::Init()
101 m_doubleClickAllowed
= 0;
102 m_winCaptured
= FALSE
;
104 m_isBeingDeleted
= FALSE
;
107 m_mouseInWindow
= FALSE
;
111 m_backgroundTransparent
= FALSE
;
113 // as all windows are created with WS_VISIBLE style...
121 m_hScrollBar
= NULL
;
122 m_vScrollBar
= NULL
;
126 wxWindowMac::~wxWindowMac()
128 // deleting a window while it is shown invalidates the region
130 wxWindowMac
* iter
= this ;
132 if ( iter
->IsTopLevel() )
137 iter
= iter
->GetParent() ;
142 m_isBeingDeleted
= TRUE
;
144 if ( s_lastMouseWindow
== this )
146 s_lastMouseWindow
= NULL
;
149 if ( gFocusWindow
== this )
151 gFocusWindow
= NULL
;
155 m_parent
->RemoveChild(this);
161 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
165 const wxString
& name
)
167 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
169 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
172 parent
->AddChild(this);
176 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
177 m_width
= WidthDefault( size
.x
);
178 m_height
= HeightDefault( size
.y
) ;
179 #ifndef __WXUNIVERSAL__
180 if ( ! IsKindOf( CLASSINFO ( wxControl
) ) && ! IsKindOf( CLASSINFO( wxStatusBar
) ) )
182 MacCreateScrollBars( style
) ;
188 void wxWindowMac::SetFocus()
190 if ( gFocusWindow
== this )
193 if ( AcceptsFocus() )
199 if ( gFocusWindow
->m_caret
)
201 gFocusWindow
->m_caret
->OnKillFocus();
203 #endif // wxUSE_CARET
204 #ifndef __WXUNIVERSAL__
205 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
206 if ( control
&& control
->GetMacControl() )
208 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNoPart
) ;
209 control
->MacRedrawControl() ;
212 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
213 event
.SetEventObject(gFocusWindow
);
214 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
216 gFocusWindow
= this ;
222 m_caret
->OnSetFocus();
224 #endif // wxUSE_CARET
225 // panel wants to track the window which was the last to have focus in it
226 wxChildFocusEvent
eventFocus(this);
227 GetEventHandler()->ProcessEvent(eventFocus
);
229 #ifndef __WXUNIVERSAL__
230 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
231 if ( control
&& control
->GetMacControl() )
233 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlEditTextPart
) ;
236 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
237 event
.SetEventObject(this);
238 GetEventHandler()->ProcessEvent(event
) ;
243 bool wxWindowMac::Enable(bool enable
)
245 if ( !wxWindowBase::Enable(enable
) )
248 MacSuperEnabled( enable
) ;
253 void wxWindowMac::CaptureMouse()
255 wxTheApp
->s_captureWindow
= this ;
258 wxWindow
* wxWindowBase::GetCapture()
260 return wxTheApp
->s_captureWindow
;
263 void wxWindowMac::ReleaseMouse()
265 wxTheApp
->s_captureWindow
= NULL
;
268 #if wxUSE_DRAG_AND_DROP
270 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
272 if ( m_dropTarget
!= 0 ) {
276 m_dropTarget
= pDropTarget
;
277 if ( m_dropTarget
!= 0 )
285 // Old style file-manager drag&drop
286 void wxWindowMac::DragAcceptFiles(bool accept
)
292 void wxWindowMac::DoGetSize(int *x
, int *y
) const
295 if(y
) *y
= m_height
;
298 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
304 if ( !IsTopLevel() && GetParent())
306 wxPoint
pt(GetParent()->GetClientAreaOrigin());
315 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
317 menu
->SetInvokingWindow(this);
319 ClientToScreen( &x
, &y
) ;
321 ::InsertMenu( (MenuHandle
) menu
->GetHMenu() , -1 ) ;
322 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
323 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
324 ::DeleteMenu( menu
->MacGetMenuId() ) ;
325 menu
->SetInvokingWindow(NULL
);
331 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
333 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
335 Point localwhere
= {0,0} ;
337 if(x
) localwhere
.h
= * x
;
338 if(y
) localwhere
.v
= * y
;
342 ::SetPort( UMAGetWindowPort( window
) ) ;
343 ::GlobalToLocal( &localwhere
) ;
346 if(x
) *x
= localwhere
.h
;
347 if(y
) *y
= localwhere
.v
;
349 MacRootWindowToClient( x
, y
) ;
352 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
354 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
356 MacClientToRootWindow( x
, y
) ;
358 Point localwhere
= { 0,0 };
359 if(x
) localwhere
.h
= * x
;
360 if(y
) localwhere
.v
= * y
;
364 ::SetPort( UMAGetWindowPort( window
) ) ;
366 ::LocalToGlobal( &localwhere
) ;
368 if(x
) *x
= localwhere
.h
;
369 if(y
) *y
= localwhere
.v
;
372 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
374 wxPoint origin
= GetClientAreaOrigin() ;
375 if(x
) *x
+= origin
.x
;
376 if(y
) *y
+= origin
.y
;
378 MacWindowToRootWindow( x
, y
) ;
381 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
383 wxPoint origin
= GetClientAreaOrigin() ;
384 MacRootWindowToWindow( x
, y
) ;
385 if(x
) *x
-= origin
.x
;
386 if(y
) *y
-= origin
.y
;
389 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
395 GetParent()->MacWindowToRootWindow( x
, y
) ;
399 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
405 GetParent()->MacRootWindowToWindow( x
, y
) ;
409 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
411 if (m_cursor
== cursor
)
414 if (wxNullCursor
== cursor
)
416 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
421 if ( ! wxWindowBase::SetCursor( cursor
) )
425 wxASSERT_MSG( m_cursor
.Ok(),
426 wxT("cursor must be valid after call to the base version"));
429 wxWindowMac
*mouseWin
;
432 // Change the cursor NOW if we're within the correct window
434 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
436 if ( mouseWin
== this && !wxIsBusy() )
438 m_cursor
.MacInstall() ;
446 // Get size *available for subwindows* i.e. excluding menu bar etc.
447 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
453 ww
-= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
454 hh
-= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
456 if ( (m_vScrollBar
&& m_vScrollBar
->IsShown()) || (m_hScrollBar
&& m_hScrollBar
->IsShown()) )
463 MacClientToRootWindow( &x1
, &y1
) ;
464 MacClientToRootWindow( &w
, &h
) ;
466 wxWindowMac
*iter
= (wxWindowMac
*)this ;
468 int totW
= 10000 , totH
= 10000;
471 if ( iter
->IsTopLevel() )
473 totW
= iter
->m_width
;
474 totH
= iter
->m_height
;
478 iter
= iter
->GetParent() ;
481 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
483 hh
-= MAC_SCROLLBAR_SIZE
;
489 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
491 ww
-= MAC_SCROLLBAR_SIZE
;
503 // ----------------------------------------------------------------------------
505 // ----------------------------------------------------------------------------
509 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
511 wxWindowBase::DoSetToolTip(tooltip
);
514 m_tooltip
->SetWindow(this);
517 #endif // wxUSE_TOOLTIPS
519 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
523 int former_w
= m_width
;
524 int former_h
= m_height
;
526 int actualWidth
= width
;
527 int actualHeight
= height
;
531 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
532 actualWidth
= m_minWidth
;
533 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
534 actualHeight
= m_minHeight
;
535 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
536 actualWidth
= m_maxWidth
;
537 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
538 actualHeight
= m_maxHeight
;
540 bool doMove
= false ;
541 bool doResize
= false ;
543 if ( actualX
!= former_x
|| actualY
!= former_y
)
547 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
552 if ( doMove
|| doResize
)
554 // erase former position
560 m_width
= actualWidth
;
561 m_height
= actualHeight
;
563 // erase new position
567 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
569 MacRepositionScrollBars() ;
572 wxPoint
point(m_x
, m_y
);
573 wxMoveEvent
event(point
, m_windowId
);
574 event
.SetEventObject(this);
575 GetEventHandler()->ProcessEvent(event
) ;
579 MacRepositionScrollBars() ;
580 wxSize
size(m_width
, m_height
);
581 wxSizeEvent
event(size
, m_windowId
);
582 event
.SetEventObject(this);
583 GetEventHandler()->ProcessEvent(event
);
589 // set the size of the window: if the dimensions are positive, just use them,
590 // but if any of them is equal to -1, it means that we must find the value for
591 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
592 // which case -1 is a valid value for x and y)
594 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
595 // the width/height to best suit our contents, otherwise we reuse the current
597 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
599 // get the current size and position...
600 int currentX
, currentY
;
601 GetPosition(¤tX
, ¤tY
);
603 int currentW
,currentH
;
604 GetSize(¤tW
, ¤tH
);
606 // ... and don't do anything (avoiding flicker) if it's already ok
607 if ( x
== currentX
&& y
== currentY
&&
608 width
== currentW
&& height
== currentH
)
610 MacRepositionScrollBars() ; // we might have a real position shift
614 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
616 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
619 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
624 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
626 size
= DoGetBestSize();
631 // just take the current one
638 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
642 size
= DoGetBestSize();
644 //else: already called DoGetBestSize() above
650 // just take the current one
655 DoMoveWindow(x
, y
, width
, height
);
658 // For implementation purposes - sometimes decorations make the client area
661 wxPoint
wxWindowMac::GetClientAreaOrigin() const
663 return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
666 void wxWindow::SetTitle(const wxString
& title
)
671 wxString
wxWindow::GetTitle() const
676 bool wxWindowMac::Show(bool show
)
678 if ( !wxWindowBase::Show(show
) )
681 MacSuperShown( show
) ;
684 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
685 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
686 if ( win
&& !win
->m_isBeingDeleted
)
697 void wxWindowMac::MacSuperShown( bool show
)
699 wxNode
*node
= GetChildren().First();
702 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
703 if ( child
->m_isShown
)
704 child
->MacSuperShown( show
) ;
709 void wxWindowMac::MacSuperEnabled( bool enabled
)
713 // to be absolutely correct we'd have to invalidate (with eraseBkground
714 // because unter MacOSX the frames are drawn with an addXXX mode)
717 wxNode
*node
= GetChildren().First();
720 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
721 if ( child
->m_isShown
)
722 child
->MacSuperEnabled( enabled
) ;
727 bool wxWindowMac::MacIsReallyShown() const
729 if ( m_isShown
&& (m_parent
!= NULL
) ) {
730 return m_parent
->MacIsReallyShown();
734 bool status = m_isShown ;
735 wxWindowMac * win = this ;
736 while ( status && win->m_parent != NULL )
738 win = win->m_parent ;
739 status = win->m_isShown ;
745 int wxWindowMac::GetCharHeight() const
747 wxClientDC
dc ( (wxWindowMac
*)this ) ;
748 return dc
.GetCharHeight() ;
751 int wxWindowMac::GetCharWidth() const
753 wxClientDC
dc ( (wxWindowMac
*)this ) ;
754 return dc
.GetCharWidth() ;
757 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
758 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
760 const wxFont
*fontToUse
= theFont
;
764 wxClientDC
dc( (wxWindowMac
*) this ) ;
766 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
767 if ( externalLeading
)
768 *externalLeading
= le
;
778 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
779 * we always intersect with the entire window, not only with the client area
782 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
784 if ( MacGetTopLevelWindow() == NULL
)
788 client
= GetClientAreaOrigin( ) ;
789 Rect clientrect
= { -client
.y
, -client
.x
, m_height
- client
.y
, m_width
- client
.x
} ;
792 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
793 SectRect( &clientrect
, &r
, &clientrect
) ;
795 if ( !EmptyRect( &clientrect
) )
797 int top
= 0 , left
= 0 ;
799 MacClientToRootWindow( &left
, &top
) ;
800 OffsetRect( &clientrect
, left
, top
) ;
802 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
806 #if wxUSE_CARET && WXWIN_COMPATIBILITY
807 // ---------------------------------------------------------------------------
808 // Caret manipulation
809 // ---------------------------------------------------------------------------
811 void wxWindowMac::CreateCaret(int w
, int h
)
813 SetCaret(new wxCaret(this, w
, h
));
816 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
818 wxFAIL_MSG("not implemented");
821 void wxWindowMac::ShowCaret(bool show
)
823 wxCHECK_RET( m_caret
, "no caret to show" );
828 void wxWindowMac::DestroyCaret()
833 void wxWindowMac::SetCaretPos(int x
, int y
)
835 wxCHECK_RET( m_caret
, "no caret to move" );
840 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
842 wxCHECK_RET( m_caret
, "no caret to get position of" );
844 m_caret
->GetPosition(x
, y
);
846 #endif // wxUSE_CARET
848 wxWindowMac
*wxGetActiveWindow()
850 // actually this is a windows-only concept
854 // Coordinates relative to the window
855 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
857 // We really dont move the mouse programmatically under mac
860 const wxBrush
& wxWindowMac::MacGetBackgroundBrush()
862 if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
864 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDocumentWindowBackground
) ;
866 else if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
868 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
869 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
870 // either a non gray background color or a non control window
872 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
874 wxWindowMac
* parent
= GetParent() ;
877 if ( parent
->MacGetRootWindow() != window
)
879 // we are in a different window on the mac system
885 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
)
886 && parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
888 // if we have any other colours in the hierarchy
889 m_macBackgroundBrush
.SetColour( parent
->m_backgroundColour
) ;
892 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
893 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
895 Rect extent
= { 0 , 0 , 0 , 0 } ;
898 wxSize size
= GetSize() ;
899 parent
->MacClientToRootWindow( &x
, &y
) ;
903 extent
.right
= x
+ size
.x
;
904 extent
.bottom
= y
+ size
.y
;
905 m_macBackgroundBrush
.SetMacThemeBackground( kThemeBackgroundTabPane
, (WXRECTPTR
) &extent
) ; // todo eventually change for inactive
909 parent
= parent
->GetParent() ;
913 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDialogBackgroundActive
) ; // todo eventually change for inactive
918 m_macBackgroundBrush
.SetColour( m_backgroundColour
) ;
921 return m_macBackgroundBrush
;
925 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
927 event
.GetDC()->Clear() ;
930 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
932 wxWindowDC
dc(this) ;
933 wxMacPortSetter
helper(&dc
) ;
935 MacPaintBorders( dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
938 int wxWindowMac::GetScrollPos(int orient
) const
940 if ( orient
== wxHORIZONTAL
)
943 return m_hScrollBar
->GetThumbPosition() ;
948 return m_vScrollBar
->GetThumbPosition() ;
953 // This now returns the whole range, not just the number
954 // of positions that we can scroll.
955 int wxWindowMac::GetScrollRange(int orient
) const
957 if ( orient
== wxHORIZONTAL
)
960 return m_hScrollBar
->GetRange() ;
965 return m_vScrollBar
->GetRange() ;
970 int wxWindowMac::GetScrollThumb(int orient
) const
972 if ( orient
== wxHORIZONTAL
)
975 return m_hScrollBar
->GetThumbSize() ;
980 return m_vScrollBar
->GetThumbSize() ;
985 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
987 if ( orient
== wxHORIZONTAL
)
990 m_hScrollBar
->SetThumbPosition( pos
) ;
995 m_vScrollBar
->SetThumbPosition( pos
) ;
999 void wxWindowMac::MacPaintBorders( int left
, int top
)
1004 RGBColor white
= { 0xFFFF, 0xFFFF , 0xFFFF } ;
1005 RGBColor black
= { 0x0000, 0x0000 , 0x0000 } ;
1006 RGBColor face
= { 0xDDDD, 0xDDDD , 0xDDDD } ;
1007 RGBColor shadow
= { 0x4444, 0x4444 , 0x4444 } ;
1010 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
1012 #if wxMAC_USE_THEME_BORDER
1013 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1016 GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
1017 InsetRect( &rect , border , border );
1018 DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
1021 DrawThemePrimaryGroup(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
1023 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
1024 RGBForeColor( &face
);
1025 MoveTo( left
+ 0 , top
+ m_height
- 2 );
1026 LineTo( left
+ 0 , top
+ 0 );
1027 LineTo( left
+ m_width
- 2 , top
+ 0 );
1029 MoveTo( left
+ 2 , top
+ m_height
- 3 );
1030 LineTo( left
+ m_width
- 3 , top
+ m_height
- 3 );
1031 LineTo( left
+ m_width
- 3 , top
+ 2 );
1033 RGBForeColor( sunken
? &face
: &black
);
1034 MoveTo( left
+ 0 , top
+ m_height
- 1 );
1035 LineTo( left
+ m_width
- 1 , top
+ m_height
- 1 );
1036 LineTo( left
+ m_width
- 1 , top
+ 0 );
1038 RGBForeColor( sunken
? &shadow
: &white
);
1039 MoveTo( left
+ 1 , top
+ m_height
- 3 );
1040 LineTo( left
+ 1, top
+ 1 );
1041 LineTo( left
+ m_width
- 3 , top
+ 1 );
1043 RGBForeColor( sunken
? &white
: &shadow
);
1044 MoveTo( left
+ 1 , top
+ m_height
- 2 );
1045 LineTo( left
+ m_width
- 2 , top
+ m_height
- 2 );
1046 LineTo( left
+ m_width
- 2 , top
+ 1 );
1048 RGBForeColor( sunken
? &black
: &face
);
1049 MoveTo( left
+ 2 , top
+ m_height
- 4 );
1050 LineTo( left
+ 2 , top
+ 2 );
1051 LineTo( left
+ m_width
- 4 , top
+ 2 );
1054 else if (HasFlag(wxSIMPLE_BORDER
))
1056 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1057 RGBForeColor( &black
) ;
1058 FrameRect( &rect
) ;
1062 // New function that will replace some of the above.
1063 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
1064 int range
, bool refresh
)
1066 if ( orient
== wxHORIZONTAL
)
1070 if ( range
== 0 || thumbVisible
>= range
)
1072 if ( m_hScrollBar
->IsShown() )
1073 m_hScrollBar
->Show(false) ;
1077 if ( !m_hScrollBar
->IsShown() )
1078 m_hScrollBar
->Show(true) ;
1079 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1087 if ( range
== 0 || thumbVisible
>= range
)
1089 if ( m_vScrollBar
->IsShown() )
1090 m_vScrollBar
->Show(false) ;
1094 if ( !m_vScrollBar
->IsShown() )
1095 m_vScrollBar
->Show(true) ;
1096 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1100 MacRepositionScrollBars() ;
1103 // Does a physical scroll
1104 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1106 wxClientDC
dc(this) ;
1107 wxMacPortSetter
helper(&dc
) ;
1110 int width
, height
;
1111 GetClientSize( &width
, &height
) ;
1113 Rect scrollrect
= { dc
.YLOG2DEVMAC(0) , dc
.XLOG2DEVMAC(0) , dc
.YLOG2DEVMAC(height
) , dc
.XLOG2DEVMAC(width
) } ;
1114 RgnHandle updateRgn
= NewRgn() ;
1115 ClipRect( &scrollrect
) ;
1118 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
1119 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
1120 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1122 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1123 InvalWindowRgn( (WindowRef
) MacGetRootWindow() , updateRgn
) ;
1124 DisposeRgn( updateRgn
) ;
1127 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1129 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1130 if (child
== m_vScrollBar
) continue;
1131 if (child
== m_hScrollBar
) continue;
1132 if (child
->IsTopLevel()) continue;
1134 child
->GetPosition( &x
, &y
);
1136 child
->GetSize( &w
, &h
);
1137 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1142 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1144 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1146 wxScrollWinEvent wevent
;
1147 wevent
.SetPosition(event
.GetPosition());
1148 wevent
.SetOrientation(event
.GetOrientation());
1149 wevent
.m_eventObject
= this;
1151 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1152 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1154 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1155 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1157 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1158 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1160 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1161 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1163 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1164 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1166 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1167 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1169 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1170 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1173 GetEventHandler()->ProcessEvent(wevent
);
1177 // Get the window with the focus
1178 wxWindowMac
*wxWindowBase::FindFocus()
1180 return gFocusWindow
;
1183 #if WXWIN_COMPATIBILITY
1184 // If nothing defined for this, try the parent.
1185 // E.g. we may be a button loaded from a resource, with no callback function
1187 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1189 if ( GetEventHandler()->ProcessEvent(event
) )
1192 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1194 #endif // WXWIN_COMPATIBILITY_2
1196 #if WXWIN_COMPATIBILITY
1197 wxObject
* wxWindowMac::GetChild(int number
) const
1199 // Return a pointer to the Nth object in the Panel
1200 wxNode
*node
= GetChildren().First();
1203 node
= node
->Next();
1206 wxObject
*obj
= (wxObject
*)node
->Data();
1212 #endif // WXWIN_COMPATIBILITY
1214 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1216 // panel wants to track the window which was the last to have focus in it,
1217 // so we want to set ourselves as the window which last had focus
1219 // notice that it's also important to do it upwards the tree becaus
1220 // otherwise when the top level panel gets focus, it won't set it back to
1221 // us, but to some other sibling
1223 // CS:don't know if this is still needed:
1224 //wxChildFocusEvent eventFocus(this);
1225 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1230 void wxWindowMac::Clear()
1232 wxClientDC
dc(this);
1233 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1234 dc
.SetBackground(brush
);
1238 // Setup background and foreground colours correctly
1239 void wxWindowMac::SetupColours()
1242 SetBackgroundColour(GetParent()->GetBackgroundColour());
1245 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1248 // Check if we need to send a LEAVE event
1249 if (m_mouseInWindow)
1252 ::GetCursorPos(&pt);
1253 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1255 // Generate a LEAVE event
1256 m_mouseInWindow = FALSE;
1257 MSWOnMouseLeave(pt.x, pt.y, 0);
1262 // This calls the UI-update mechanism (querying windows for
1263 // menu/toolbar/control state information)
1267 // Raise the window to the top of the Z order
1268 void wxWindowMac::Raise()
1272 // Lower the window to the bottom of the Z order
1273 void wxWindowMac::Lower()
1277 void wxWindowMac::DoSetClientSize(int width
, int height
)
1279 if ( width
!= -1 || height
!= -1 )
1282 if ( width
!= -1 && m_vScrollBar
)
1283 width
+= MAC_SCROLLBAR_SIZE
;
1284 if ( height
!= -1 && m_vScrollBar
)
1285 height
+= MAC_SCROLLBAR_SIZE
;
1287 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1288 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1290 DoSetSize( -1 , -1 , width
, height
) ;
1295 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1297 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1301 if ((point
.x
< 0) || (point
.y
< 0) ||
1302 (point
.x
> (m_width
)) || (point
.y
> (m_height
)))
1307 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1308 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1312 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1314 wxPoint
newPoint( point
) ;
1316 if ( !IsTopLevel() )
1322 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1324 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1325 // added the m_isShown test --dmazzoni
1326 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1328 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1337 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1340 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1341 if ( ::FindWindow( pt
, &window
) == 3 )
1343 wxPoint
point( screenpoint
) ;
1344 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1347 point
= win
->ScreenToClient( point
) ;
1348 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1354 extern int wxBusyCursorCount
;
1356 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1358 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1359 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1363 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) )
1366 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1374 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1376 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1377 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1379 if (child
->MacDispatchMouseEvent(event
))
1387 if ( wxBusyCursorCount
== 0 )
1389 m_cursor
.MacInstall() ;
1392 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1394 // set focus to this window
1395 if (AcceptsFocus() && FindFocus()!=this)
1400 if ( event
.GetEventType() == wxEVT_MOTION
1401 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1402 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1403 wxToolTip::RelayEvent( this , event
);
1404 #endif // wxUSE_TOOLTIPS
1405 GetEventHandler()->ProcessEvent( event
) ;
1409 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1413 return m_tooltip
->GetTip() ;
1418 void wxWindowMac::Update()
1420 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1422 win
->MacUpdate( 0 ) ;
1425 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1427 wxTopLevelWindowMac
* win
= NULL
;
1428 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1431 win
= wxFindWinFromMacWindow( window
) ;
1436 const wxRegion
& wxWindowMac::MacGetVisibleRegion()
1438 RgnHandle visRgn
= NewRgn() ;
1439 RgnHandle tempRgn
= NewRgn() ;
1441 SetRectRgn( visRgn
, 0 , 0 , m_width
, m_height
) ;
1443 //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
1444 if ( IsKindOf( CLASSINFO( wxStaticBox
) ) )
1446 int borderTop
= 14 ;
1447 int borderOther
= 4 ;
1449 SetRectRgn( tempRgn
, borderOther
, borderTop
, m_width
- borderOther
, m_height
- borderOther
) ;
1450 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1453 if ( !IsTopLevel() )
1455 wxWindow
* parent
= GetParent() ;
1458 wxSize size
= parent
->GetSize() ;
1461 parent
->MacWindowToRootWindow( &x
, &y
) ;
1462 MacRootWindowToWindow( &x
, &y
) ;
1463 SetRectRgn( tempRgn
, x
, y
, x
+ size
.x
, y
+ size
.y
) ;
1464 SectRgn( visRgn
, tempRgn
, visRgn
) ;
1465 if ( parent
->IsTopLevel() )
1467 parent
= parent
->GetParent() ;
1470 if ( GetWindowStyle() & wxCLIP_CHILDREN
)
1472 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1474 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1476 if ( !child
->IsTopLevel() && child
->IsShown() )
1478 SetRectRgn( tempRgn
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1479 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1484 if ( (GetWindowStyle() & wxCLIP_SIBLINGS
) && GetParent() )
1486 bool thisWindowThrough
= false ;
1487 for (wxNode
*node
= GetParent()->GetChildren().First(); node
; node
= node
->Next())
1489 wxWindowMac
*sibling
= (wxWindowMac
*)node
->Data();
1490 if ( sibling
== this )
1492 thisWindowThrough
= true ;
1495 if( !thisWindowThrough
)
1500 if ( !sibling
->IsTopLevel() && sibling
->IsShown() )
1502 SetRectRgn( tempRgn
, sibling
->m_x
- m_x
, sibling
->m_y
- m_y
, sibling
->m_x
+ sibling
->m_width
- m_x
, sibling
->m_y
+ sibling
->m_height
- m_y
) ;
1503 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1507 m_macVisibleRegion
= visRgn
;
1508 DisposeRgn( visRgn
) ;
1509 DisposeRgn( tempRgn
) ;
1510 return m_macVisibleRegion
;
1513 void wxWindowMac::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
1515 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
1516 // updatergn is always already clipped to our boundaries
1517 // it is in window coordinates, not in client coordinates
1519 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1522 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
1523 RgnHandle ownUpdateRgn
= NewRgn() ;
1524 CopyRgn( updatergn
, ownUpdateRgn
) ;
1526 SectRgn( ownUpdateRgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn
) ;
1528 // newupdate is the update region in client coordinates
1529 RgnHandle newupdate
= NewRgn() ;
1530 wxSize point
= GetClientSize() ;
1531 wxPoint origin
= GetClientAreaOrigin() ;
1532 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1533 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1534 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1535 m_updateRegion
= newupdate
;
1536 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1538 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1540 wxWindowDC
dc(this);
1541 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1542 wxEraseEvent
eevent( GetId(), &dc
);
1543 eevent
.SetEventObject( this );
1544 GetEventHandler()->ProcessEvent( eevent
);
1546 wxNcPaintEvent
eventNc( GetId() );
1547 eventNc
.SetEventObject( this );
1548 GetEventHandler()->ProcessEvent( eventNc
);
1550 DisposeRgn( ownUpdateRgn
) ;
1551 if ( !m_updateRegion
.Empty() )
1554 event
.m_timeStamp
= time
;
1555 event
.SetEventObject(this);
1556 GetEventHandler()->ProcessEvent(event
);
1560 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1562 RgnHandle childupdate
= NewRgn() ;
1563 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1565 // calculate the update region for the child windows by intersecting the window rectangle with our own
1566 // passed in update region and then offset it to be client-wise window coordinates again
1567 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1568 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1569 SectRgn( childupdate
, updatergn
, childupdate
) ;
1570 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1571 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1573 // because dialogs may also be children
1574 child
->MacRedraw( childupdate
, time
, erase
) ;
1577 DisposeRgn( childupdate
) ;
1578 // eventually a draw grow box here
1582 WXHWND
wxWindowMac::MacGetRootWindow() const
1584 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1588 if ( iter
->IsTopLevel() )
1589 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1591 iter
= iter
->GetParent() ;
1593 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1597 void wxWindowMac::MacCreateScrollBars( long style
)
1599 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1601 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1602 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1604 GetClientSize( &width
, &height
) ;
1606 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1607 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1608 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1609 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1611 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1612 vSize
, wxVERTICAL
);
1614 if ( style
& wxVSCROLL
)
1620 m_vScrollBar
->Show(false) ;
1622 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1623 hSize
, wxHORIZONTAL
);
1624 if ( style
& wxHSCROLL
)
1629 m_hScrollBar
->Show(false) ;
1632 // because the create does not take into account the client area origin
1633 MacRepositionScrollBars() ; // we might have a real position shift
1636 void wxWindowMac::MacRepositionScrollBars()
1638 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1639 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1641 // get real client area
1643 int width
= m_width
;
1644 int height
= m_height
;
1646 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1647 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1649 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1650 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1651 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1652 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1659 MacClientToRootWindow( &x
, &y
) ;
1660 MacClientToRootWindow( &w
, &h
) ;
1662 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1664 int totW
= 10000 , totH
= 10000;
1667 if ( iter
->IsTopLevel() )
1669 totW
= iter
->m_width
;
1670 totH
= iter
->m_height
;
1674 iter
= iter
->GetParent() ;
1702 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1706 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1710 bool wxWindowMac::AcceptsFocus() const
1712 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1715 WXWidget
wxWindowMac::MacGetContainerForEmbedding()
1717 return GetParent()->MacGetContainerForEmbedding() ;
1720 void wxWindowMac::MacSuperChangedPosition()
1722 // only window-absolute structures have to be moved i.e. controls
1724 wxNode
*node
= GetChildren().First();
1727 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1728 child
->MacSuperChangedPosition() ;
1729 node
= node
->Next();
1733 void wxWindowMac::MacTopLevelWindowChangedPosition()
1735 // only screen-absolute structures have to be moved i.e. glcanvas
1737 wxNode
*node
= GetChildren().First();
1740 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1741 child
->MacTopLevelWindowChangedPosition() ;
1742 node
= node
->Next();
1745 long wxWindowMac::MacGetLeftBorderSize( ) const
1750 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1753 #if wxMAC_USE_THEME_BORDER
1755 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1760 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1763 #if wxMAC_USE_THEME_BORDER
1765 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1770 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1777 long wxWindowMac::MacGetRightBorderSize( ) const
1779 // they are all symmetric in mac themes
1780 return MacGetLeftBorderSize() ;
1783 long wxWindowMac::MacGetTopBorderSize( ) const
1785 // they are all symmetric in mac themes
1786 return MacGetLeftBorderSize() ;
1789 long wxWindowMac::MacGetBottomBorderSize( ) const
1791 // they are all symmetric in mac themes
1792 return MacGetLeftBorderSize() ;
1795 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1797 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1800 // Find the wxWindowMac at the current mouse position, returning the mouse
1802 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1804 pt
= wxGetMousePosition();
1805 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1809 // Get the current mouse position.
1810 wxPoint
wxGetMousePosition()
1813 wxGetMousePosition(& x
, & y
);
1814 return wxPoint(x
, y
);