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"
51 #include <ToolUtils.h>
54 #if wxUSE_DRAG_AND_DROP
60 extern wxList wxPendingDelete
;
61 wxWindowMac
* gFocusWindow
= NULL
;
63 #ifdef __WXUNIVERSAL__
64 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
66 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
67 #endif // __WXUNIVERSAL__/__WXMAC__
69 #if !USE_SHARED_LIBRARY
71 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
72 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
73 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
74 EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged
)
75 EVT_INIT_DIALOG(wxWindowMac::OnInitDialog
)
76 EVT_IDLE(wxWindowMac::OnIdle
)
77 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
82 #define wxMAC_DEBUG_REDRAW 0
83 #ifndef wxMAC_DEBUG_REDRAW
84 #define wxMAC_DEBUG_REDRAW 0
87 #define wxMAC_USE_THEME_BORDER 0
90 // ===========================================================================
92 // ===========================================================================
95 // ----------------------------------------------------------------------------
96 // constructors and such
97 // ----------------------------------------------------------------------------
99 void wxWindowMac::Init()
105 m_doubleClickAllowed
= 0;
106 m_winCaptured
= FALSE
;
108 m_isBeingDeleted
= FALSE
;
111 m_mouseInWindow
= FALSE
;
115 m_backgroundTransparent
= FALSE
;
117 // as all windows are created with WS_VISIBLE style...
125 m_hScrollBar
= NULL
;
126 m_vScrollBar
= NULL
;
130 wxWindowMac::~wxWindowMac()
132 // deleting a window while it is shown invalidates the region
134 wxWindowMac
* iter
= this ;
136 if ( iter
->IsTopLevel() )
141 iter
= iter
->GetParent() ;
146 m_isBeingDeleted
= TRUE
;
148 if ( s_lastMouseWindow
== this )
150 s_lastMouseWindow
= NULL
;
153 if ( gFocusWindow
== this )
155 gFocusWindow
= NULL
;
159 m_parent
->RemoveChild(this);
165 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
169 const wxString
& name
)
171 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
173 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
176 parent
->AddChild(this);
180 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
181 m_width
= WidthDefault( size
.x
);
182 m_height
= HeightDefault( size
.y
) ;
183 #ifndef __WXUNIVERSAL__
184 if ( ! IsKindOf( CLASSINFO ( wxControl
) ) && ! IsKindOf( CLASSINFO( wxStatusBar
) ) )
186 MacCreateScrollBars( style
) ;
192 void wxWindowMac::SetFocus()
194 if ( gFocusWindow
== this )
197 if ( AcceptsFocus() )
203 if ( gFocusWindow
->m_caret
)
205 gFocusWindow
->m_caret
->OnKillFocus();
207 #endif // wxUSE_CARET
208 #ifndef __WXUNIVERSAL__
209 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
210 if ( control
&& control
->GetMacControl() )
212 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNoPart
) ;
213 control
->MacRedrawControl() ;
216 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
217 event
.SetEventObject(gFocusWindow
);
218 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
220 gFocusWindow
= this ;
226 m_caret
->OnSetFocus();
228 #endif // wxUSE_CARET
229 // panel wants to track the window which was the last to have focus in it
230 wxChildFocusEvent
eventFocus(this);
231 GetEventHandler()->ProcessEvent(eventFocus
);
233 #ifndef __WXUNIVERSAL__
234 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
235 if ( control
&& control
->GetMacControl() )
237 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlEditTextPart
) ;
240 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
241 event
.SetEventObject(this);
242 GetEventHandler()->ProcessEvent(event
) ;
247 bool wxWindowMac::Enable(bool enable
)
249 if ( !wxWindowBase::Enable(enable
) )
252 MacSuperEnabled( enable
) ;
257 void wxWindowMac::CaptureMouse()
259 wxTheApp
->s_captureWindow
= this ;
262 wxWindow
* wxWindowBase::GetCapture()
264 return wxTheApp
->s_captureWindow
;
267 void wxWindowMac::ReleaseMouse()
269 wxTheApp
->s_captureWindow
= NULL
;
272 #if wxUSE_DRAG_AND_DROP
274 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
276 if ( m_dropTarget
!= 0 ) {
280 m_dropTarget
= pDropTarget
;
281 if ( m_dropTarget
!= 0 )
289 // Old style file-manager drag&drop
290 void wxWindowMac::DragAcceptFiles(bool accept
)
296 void wxWindowMac::DoGetSize(int *x
, int *y
) const
299 if(y
) *y
= m_height
;
302 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
308 if ( !IsTopLevel() && GetParent())
310 wxPoint
pt(GetParent()->GetClientAreaOrigin());
319 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
321 menu
->SetInvokingWindow(this);
323 ClientToScreen( &x
, &y
) ;
325 ::InsertMenu( (MenuHandle
) menu
->GetHMenu() , -1 ) ;
326 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
327 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
328 ::DeleteMenu( menu
->MacGetMenuId() ) ;
329 menu
->SetInvokingWindow(NULL
);
335 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
337 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
339 Point localwhere
= {0,0} ;
341 if(x
) localwhere
.h
= * x
;
342 if(y
) localwhere
.v
= * y
;
346 ::SetPort( UMAGetWindowPort( window
) ) ;
347 ::GlobalToLocal( &localwhere
) ;
350 if(x
) *x
= localwhere
.h
;
351 if(y
) *y
= localwhere
.v
;
353 MacRootWindowToClient( x
, y
) ;
356 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
358 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
360 MacClientToRootWindow( x
, y
) ;
362 Point localwhere
= { 0,0 };
363 if(x
) localwhere
.h
= * x
;
364 if(y
) localwhere
.v
= * y
;
368 ::SetPort( UMAGetWindowPort( window
) ) ;
370 ::LocalToGlobal( &localwhere
) ;
372 if(x
) *x
= localwhere
.h
;
373 if(y
) *y
= localwhere
.v
;
376 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
378 wxPoint origin
= GetClientAreaOrigin() ;
379 if(x
) *x
+= origin
.x
;
380 if(y
) *y
+= origin
.y
;
382 MacWindowToRootWindow( x
, y
) ;
385 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
387 wxPoint origin
= GetClientAreaOrigin() ;
388 MacRootWindowToWindow( x
, y
) ;
389 if(x
) *x
-= origin
.x
;
390 if(y
) *y
-= origin
.y
;
393 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
399 GetParent()->MacWindowToRootWindow( x
, y
) ;
403 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
409 GetParent()->MacRootWindowToWindow( x
, y
) ;
413 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
415 if (m_cursor
== cursor
)
418 if (wxNullCursor
== cursor
)
420 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
425 if ( ! wxWindowBase::SetCursor( cursor
) )
429 wxASSERT_MSG( m_cursor
.Ok(),
430 wxT("cursor must be valid after call to the base version"));
433 wxWindowMac
*mouseWin
;
436 // Change the cursor NOW if we're within the correct window
438 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
440 if ( mouseWin
== this && !wxIsBusy() )
442 m_cursor
.MacInstall() ;
450 // Get size *available for subwindows* i.e. excluding menu bar etc.
451 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
457 ww
-= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
458 hh
-= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
460 if ( (m_vScrollBar
&& m_vScrollBar
->IsShown()) || (m_hScrollBar
&& m_hScrollBar
->IsShown()) )
467 MacClientToRootWindow( &x1
, &y1
) ;
468 MacClientToRootWindow( &w
, &h
) ;
470 wxWindowMac
*iter
= (wxWindowMac
*)this ;
472 int totW
= 10000 , totH
= 10000;
475 if ( iter
->IsTopLevel() )
477 totW
= iter
->m_width
;
478 totH
= iter
->m_height
;
482 iter
= iter
->GetParent() ;
485 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
487 hh
-= MAC_SCROLLBAR_SIZE
;
493 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
495 ww
-= MAC_SCROLLBAR_SIZE
;
507 // ----------------------------------------------------------------------------
509 // ----------------------------------------------------------------------------
513 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
515 wxWindowBase::DoSetToolTip(tooltip
);
518 m_tooltip
->SetWindow(this);
521 #endif // wxUSE_TOOLTIPS
523 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
527 int former_w
= m_width
;
528 int former_h
= m_height
;
530 int actualWidth
= width
;
531 int actualHeight
= height
;
535 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
536 actualWidth
= m_minWidth
;
537 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
538 actualHeight
= m_minHeight
;
539 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
540 actualWidth
= m_maxWidth
;
541 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
542 actualHeight
= m_maxHeight
;
544 bool doMove
= false ;
545 bool doResize
= false ;
547 if ( actualX
!= former_x
|| actualY
!= former_y
)
551 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
556 if ( doMove
|| doResize
)
558 // erase former position
564 m_width
= actualWidth
;
565 m_height
= actualHeight
;
567 // erase new position
571 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
573 MacRepositionScrollBars() ;
576 wxPoint
point(m_x
, m_y
);
577 wxMoveEvent
event(point
, m_windowId
);
578 event
.SetEventObject(this);
579 GetEventHandler()->ProcessEvent(event
) ;
583 MacRepositionScrollBars() ;
584 wxSize
size(m_width
, m_height
);
585 wxSizeEvent
event(size
, m_windowId
);
586 event
.SetEventObject(this);
587 GetEventHandler()->ProcessEvent(event
);
593 // set the size of the window: if the dimensions are positive, just use them,
594 // but if any of them is equal to -1, it means that we must find the value for
595 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
596 // which case -1 is a valid value for x and y)
598 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
599 // the width/height to best suit our contents, otherwise we reuse the current
601 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
603 // get the current size and position...
604 int currentX
, currentY
;
605 GetPosition(¤tX
, ¤tY
);
607 int currentW
,currentH
;
608 GetSize(¤tW
, ¤tH
);
610 // ... and don't do anything (avoiding flicker) if it's already ok
611 if ( x
== currentX
&& y
== currentY
&&
612 width
== currentW
&& height
== currentH
)
614 MacRepositionScrollBars() ; // we might have a real position shift
618 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
620 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
623 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
628 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
630 size
= DoGetBestSize();
635 // just take the current one
642 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
646 size
= DoGetBestSize();
648 //else: already called DoGetBestSize() above
654 // just take the current one
659 DoMoveWindow(x
, y
, width
, height
);
662 // For implementation purposes - sometimes decorations make the client area
665 wxPoint
wxWindowMac::GetClientAreaOrigin() const
667 return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
670 void wxWindow::SetTitle(const wxString
& title
)
675 wxString
wxWindow::GetTitle() const
680 bool wxWindowMac::Show(bool show
)
682 if ( !wxWindowBase::Show(show
) )
685 MacSuperShown( show
) ;
688 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
689 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
690 if ( win
&& !win
->m_isBeingDeleted
)
701 void wxWindowMac::MacSuperShown( bool show
)
703 wxNode
*node
= GetChildren().First();
706 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
707 if ( child
->m_isShown
)
708 child
->MacSuperShown( show
) ;
713 void wxWindowMac::MacSuperEnabled( bool enabled
)
717 // to be absolutely correct we'd have to invalidate (with eraseBkground
718 // because unter MacOSX the frames are drawn with an addXXX mode)
721 wxNode
*node
= GetChildren().First();
724 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
725 if ( child
->m_isShown
)
726 child
->MacSuperEnabled( enabled
) ;
731 bool wxWindowMac::MacIsReallyShown() const
733 if ( m_isShown
&& (m_parent
!= NULL
) ) {
734 return m_parent
->MacIsReallyShown();
738 bool status = m_isShown ;
739 wxWindowMac * win = this ;
740 while ( status && win->m_parent != NULL )
742 win = win->m_parent ;
743 status = win->m_isShown ;
749 int wxWindowMac::GetCharHeight() const
751 wxClientDC
dc ( (wxWindowMac
*)this ) ;
752 return dc
.GetCharHeight() ;
755 int wxWindowMac::GetCharWidth() const
757 wxClientDC
dc ( (wxWindowMac
*)this ) ;
758 return dc
.GetCharWidth() ;
761 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
762 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
764 const wxFont
*fontToUse
= theFont
;
768 wxClientDC
dc( (wxWindowMac
*) this ) ;
770 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
771 if ( externalLeading
)
772 *externalLeading
= le
;
782 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
783 * we always intersect with the entire window, not only with the client area
786 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
788 if ( MacGetTopLevelWindow() == NULL
)
792 client
= GetClientAreaOrigin( ) ;
793 Rect clientrect
= { -client
.y
, -client
.x
, m_height
- client
.y
, m_width
- client
.x
} ;
796 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
797 SectRect( &clientrect
, &r
, &clientrect
) ;
799 if ( !EmptyRect( &clientrect
) )
801 int top
= 0 , left
= 0 ;
803 MacClientToRootWindow( &left
, &top
) ;
804 OffsetRect( &clientrect
, left
, top
) ;
806 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
810 #if wxUSE_CARET && WXWIN_COMPATIBILITY
811 // ---------------------------------------------------------------------------
812 // Caret manipulation
813 // ---------------------------------------------------------------------------
815 void wxWindowMac::CreateCaret(int w
, int h
)
817 SetCaret(new wxCaret(this, w
, h
));
820 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
822 wxFAIL_MSG("not implemented");
825 void wxWindowMac::ShowCaret(bool show
)
827 wxCHECK_RET( m_caret
, "no caret to show" );
832 void wxWindowMac::DestroyCaret()
837 void wxWindowMac::SetCaretPos(int x
, int y
)
839 wxCHECK_RET( m_caret
, "no caret to move" );
844 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
846 wxCHECK_RET( m_caret
, "no caret to get position of" );
848 m_caret
->GetPosition(x
, y
);
850 #endif // wxUSE_CARET
852 wxWindowMac
*wxGetActiveWindow()
854 // actually this is a windows-only concept
858 // Coordinates relative to the window
859 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
861 // We really dont move the mouse programmatically under mac
864 const wxBrush
& wxWindowMac::MacGetBackgroundBrush()
866 if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
868 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDocumentWindowBackground
) ;
870 else if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) )
872 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
873 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
874 // either a non gray background color or a non control window
876 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
878 wxWindowMac
* parent
= GetParent() ;
881 if ( parent
->MacGetRootWindow() != window
)
883 // we are in a different window on the mac system
889 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
)
890 && parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
892 // if we have any other colours in the hierarchy
893 m_macBackgroundBrush
.SetColour( parent
->m_backgroundColour
) ;
896 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
897 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
899 Rect extent
= { 0 , 0 , 0 , 0 } ;
902 wxSize size
= GetSize() ;
903 parent
->MacClientToRootWindow( &x
, &y
) ;
907 extent
.right
= x
+ size
.x
;
908 extent
.bottom
= y
+ size
.y
;
909 m_macBackgroundBrush
.SetMacThemeBackground( kThemeBackgroundTabPane
, (WXRECTPTR
) &extent
) ; // todo eventually change for inactive
913 parent
= parent
->GetParent() ;
917 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDialogBackgroundActive
) ; // todo eventually change for inactive
922 m_macBackgroundBrush
.SetColour( m_backgroundColour
) ;
925 return m_macBackgroundBrush
;
929 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
931 event
.GetDC()->Clear() ;
934 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
936 wxWindowDC
dc(this) ;
937 wxMacPortSetter
helper(&dc
) ;
939 MacPaintBorders( dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
942 int wxWindowMac::GetScrollPos(int orient
) const
944 if ( orient
== wxHORIZONTAL
)
947 return m_hScrollBar
->GetThumbPosition() ;
952 return m_vScrollBar
->GetThumbPosition() ;
957 // This now returns the whole range, not just the number
958 // of positions that we can scroll.
959 int wxWindowMac::GetScrollRange(int orient
) const
961 if ( orient
== wxHORIZONTAL
)
964 return m_hScrollBar
->GetRange() ;
969 return m_vScrollBar
->GetRange() ;
974 int wxWindowMac::GetScrollThumb(int orient
) const
976 if ( orient
== wxHORIZONTAL
)
979 return m_hScrollBar
->GetThumbSize() ;
984 return m_vScrollBar
->GetThumbSize() ;
989 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
991 if ( orient
== wxHORIZONTAL
)
994 m_hScrollBar
->SetThumbPosition( pos
) ;
999 m_vScrollBar
->SetThumbPosition( pos
) ;
1003 void wxWindowMac::MacPaintBorders( int left
, int top
)
1008 RGBColor white
= { 0xFFFF, 0xFFFF , 0xFFFF } ;
1009 RGBColor black
= { 0x0000, 0x0000 , 0x0000 } ;
1010 RGBColor face
= { 0xDDDD, 0xDDDD , 0xDDDD } ;
1011 RGBColor shadow
= { 0x4444, 0x4444 , 0x4444 } ;
1014 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
1016 #if wxMAC_USE_THEME_BORDER
1017 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1020 GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
1021 InsetRect( &rect , border , border );
1022 DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
1025 DrawThemePrimaryGroup(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
1027 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
1028 RGBForeColor( &face
);
1029 MoveTo( left
+ 0 , top
+ m_height
- 2 );
1030 LineTo( left
+ 0 , top
+ 0 );
1031 LineTo( left
+ m_width
- 2 , top
+ 0 );
1033 MoveTo( left
+ 2 , top
+ m_height
- 3 );
1034 LineTo( left
+ m_width
- 3 , top
+ m_height
- 3 );
1035 LineTo( left
+ m_width
- 3 , top
+ 2 );
1037 RGBForeColor( sunken
? &face
: &black
);
1038 MoveTo( left
+ 0 , top
+ m_height
- 1 );
1039 LineTo( left
+ m_width
- 1 , top
+ m_height
- 1 );
1040 LineTo( left
+ m_width
- 1 , top
+ 0 );
1042 RGBForeColor( sunken
? &shadow
: &white
);
1043 MoveTo( left
+ 1 , top
+ m_height
- 3 );
1044 LineTo( left
+ 1, top
+ 1 );
1045 LineTo( left
+ m_width
- 3 , top
+ 1 );
1047 RGBForeColor( sunken
? &white
: &shadow
);
1048 MoveTo( left
+ 1 , top
+ m_height
- 2 );
1049 LineTo( left
+ m_width
- 2 , top
+ m_height
- 2 );
1050 LineTo( left
+ m_width
- 2 , top
+ 1 );
1052 RGBForeColor( sunken
? &black
: &face
);
1053 MoveTo( left
+ 2 , top
+ m_height
- 4 );
1054 LineTo( left
+ 2 , top
+ 2 );
1055 LineTo( left
+ m_width
- 4 , top
+ 2 );
1058 else if (HasFlag(wxSIMPLE_BORDER
))
1060 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1061 RGBForeColor( &black
) ;
1062 FrameRect( &rect
) ;
1066 // New function that will replace some of the above.
1067 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
1068 int range
, bool refresh
)
1070 if ( orient
== wxHORIZONTAL
)
1074 if ( range
== 0 || thumbVisible
>= range
)
1076 if ( m_hScrollBar
->IsShown() )
1077 m_hScrollBar
->Show(false) ;
1081 if ( !m_hScrollBar
->IsShown() )
1082 m_hScrollBar
->Show(true) ;
1083 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1091 if ( range
== 0 || thumbVisible
>= range
)
1093 if ( m_vScrollBar
->IsShown() )
1094 m_vScrollBar
->Show(false) ;
1098 if ( !m_vScrollBar
->IsShown() )
1099 m_vScrollBar
->Show(true) ;
1100 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1104 MacRepositionScrollBars() ;
1107 // Does a physical scroll
1108 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1110 wxClientDC
dc(this) ;
1111 wxMacPortSetter
helper(&dc
) ;
1114 int width
, height
;
1115 GetClientSize( &width
, &height
) ;
1117 Rect scrollrect
= { dc
.YLOG2DEVMAC(0) , dc
.XLOG2DEVMAC(0) , dc
.YLOG2DEVMAC(height
) , dc
.XLOG2DEVMAC(width
) } ;
1118 RgnHandle updateRgn
= NewRgn() ;
1119 ClipRect( &scrollrect
) ;
1122 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
1123 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
1124 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1126 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1127 InvalWindowRgn( (WindowRef
) MacGetRootWindow() , updateRgn
) ;
1128 DisposeRgn( updateRgn
) ;
1131 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1133 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1134 if (child
== m_vScrollBar
) continue;
1135 if (child
== m_hScrollBar
) continue;
1136 if (child
->IsTopLevel()) continue;
1138 child
->GetPosition( &x
, &y
);
1140 child
->GetSize( &w
, &h
);
1141 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1146 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1148 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1150 wxScrollWinEvent wevent
;
1151 wevent
.SetPosition(event
.GetPosition());
1152 wevent
.SetOrientation(event
.GetOrientation());
1153 wevent
.m_eventObject
= this;
1155 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1156 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1158 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1159 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1161 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1162 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1164 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1165 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1167 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1168 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1170 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1171 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1173 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1174 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1177 GetEventHandler()->ProcessEvent(wevent
);
1181 // Get the window with the focus
1182 wxWindowMac
*wxWindowBase::FindFocus()
1184 return gFocusWindow
;
1187 #if WXWIN_COMPATIBILITY
1188 // If nothing defined for this, try the parent.
1189 // E.g. we may be a button loaded from a resource, with no callback function
1191 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1193 if ( GetEventHandler()->ProcessEvent(event
) )
1196 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1198 #endif // WXWIN_COMPATIBILITY_2
1200 #if WXWIN_COMPATIBILITY
1201 wxObject
* wxWindowMac::GetChild(int number
) const
1203 // Return a pointer to the Nth object in the Panel
1204 wxNode
*node
= GetChildren().First();
1207 node
= node
->Next();
1210 wxObject
*obj
= (wxObject
*)node
->Data();
1216 #endif // WXWIN_COMPATIBILITY
1218 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1220 // panel wants to track the window which was the last to have focus in it,
1221 // so we want to set ourselves as the window which last had focus
1223 // notice that it's also important to do it upwards the tree becaus
1224 // otherwise when the top level panel gets focus, it won't set it back to
1225 // us, but to some other sibling
1227 // CS:don't know if this is still needed:
1228 //wxChildFocusEvent eventFocus(this);
1229 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1234 void wxWindowMac::Clear()
1236 wxClientDC
dc(this);
1237 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1238 dc
.SetBackground(brush
);
1242 // Setup background and foreground colours correctly
1243 void wxWindowMac::SetupColours()
1246 SetBackgroundColour(GetParent()->GetBackgroundColour());
1249 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1252 // Check if we need to send a LEAVE event
1253 if (m_mouseInWindow)
1256 ::GetCursorPos(&pt);
1257 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1259 // Generate a LEAVE event
1260 m_mouseInWindow = FALSE;
1261 MSWOnMouseLeave(pt.x, pt.y, 0);
1266 // This calls the UI-update mechanism (querying windows for
1267 // menu/toolbar/control state information)
1271 // Raise the window to the top of the Z order
1272 void wxWindowMac::Raise()
1276 // Lower the window to the bottom of the Z order
1277 void wxWindowMac::Lower()
1281 void wxWindowMac::DoSetClientSize(int width
, int height
)
1283 if ( width
!= -1 || height
!= -1 )
1286 if ( width
!= -1 && m_vScrollBar
)
1287 width
+= MAC_SCROLLBAR_SIZE
;
1288 if ( height
!= -1 && m_vScrollBar
)
1289 height
+= MAC_SCROLLBAR_SIZE
;
1291 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1292 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1294 DoSetSize( -1 , -1 , width
, height
) ;
1299 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1301 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1305 if ((point
.x
< 0) || (point
.y
< 0) ||
1306 (point
.x
> (m_width
)) || (point
.y
> (m_height
)))
1311 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1312 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1316 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1318 wxPoint
newPoint( point
) ;
1320 if ( !IsTopLevel() )
1326 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1328 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1329 // added the m_isShown test --dmazzoni
1330 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1332 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1341 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1344 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1345 if ( ::FindWindow( pt
, &window
) == 3 )
1347 wxPoint
point( screenpoint
) ;
1348 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1351 point
= win
->ScreenToClient( point
) ;
1352 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1358 extern int wxBusyCursorCount
;
1360 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1362 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1363 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1367 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) )
1370 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1378 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1380 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1381 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1383 if (child
->MacDispatchMouseEvent(event
))
1391 if ( wxBusyCursorCount
== 0 )
1393 m_cursor
.MacInstall() ;
1396 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1398 // set focus to this window
1399 if (AcceptsFocus() && FindFocus()!=this)
1404 if ( event
.GetEventType() == wxEVT_MOTION
1405 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1406 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1407 wxToolTip::RelayEvent( this , event
);
1408 #endif // wxUSE_TOOLTIPS
1409 GetEventHandler()->ProcessEvent( event
) ;
1413 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1417 return m_tooltip
->GetTip() ;
1422 void wxWindowMac::Update()
1424 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1426 win
->MacUpdate( 0 ) ;
1429 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1431 wxTopLevelWindowMac
* win
= NULL
;
1432 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1435 win
= wxFindWinFromMacWindow( window
) ;
1440 const wxRegion
& wxWindowMac::MacGetVisibleRegion()
1442 RgnHandle visRgn
= NewRgn() ;
1443 RgnHandle tempRgn
= NewRgn() ;
1445 SetRectRgn( visRgn
, 0 , 0 , m_width
, m_height
) ;
1447 //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
1448 if ( IsKindOf( CLASSINFO( wxStaticBox
) ) )
1450 int borderTop
= 14 ;
1451 int borderOther
= 4 ;
1453 SetRectRgn( tempRgn
, borderOther
, borderTop
, m_width
- borderOther
, m_height
- borderOther
) ;
1454 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1457 if ( !IsTopLevel() )
1459 wxWindow
* parent
= GetParent() ;
1462 wxSize size
= parent
->GetSize() ;
1465 parent
->MacWindowToRootWindow( &x
, &y
) ;
1466 MacRootWindowToWindow( &x
, &y
) ;
1467 SetRectRgn( tempRgn
, x
, y
, x
+ size
.x
, y
+ size
.y
) ;
1468 SectRgn( visRgn
, tempRgn
, visRgn
) ;
1469 if ( parent
->IsTopLevel() )
1471 parent
= parent
->GetParent() ;
1474 if ( GetWindowStyle() & wxCLIP_CHILDREN
)
1476 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1478 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1480 if ( !child
->IsTopLevel() && child
->IsShown() )
1482 SetRectRgn( tempRgn
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1483 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1488 if ( (GetWindowStyle() & wxCLIP_SIBLINGS
) && GetParent() )
1490 bool thisWindowThrough
= false ;
1491 for (wxNode
*node
= GetParent()->GetChildren().First(); node
; node
= node
->Next())
1493 wxWindowMac
*sibling
= (wxWindowMac
*)node
->Data();
1494 if ( sibling
== this )
1496 thisWindowThrough
= true ;
1499 if( !thisWindowThrough
)
1504 if ( !sibling
->IsTopLevel() && sibling
->IsShown() )
1506 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
) ;
1507 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1511 m_macVisibleRegion
= visRgn
;
1512 DisposeRgn( visRgn
) ;
1513 DisposeRgn( tempRgn
) ;
1514 return m_macVisibleRegion
;
1517 void wxWindowMac::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
1519 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
1520 // updatergn is always already clipped to our boundaries
1521 // it is in window coordinates, not in client coordinates
1523 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1526 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
1527 RgnHandle ownUpdateRgn
= NewRgn() ;
1528 CopyRgn( updatergn
, ownUpdateRgn
) ;
1530 SectRgn( ownUpdateRgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn
) ;
1532 // newupdate is the update region in client coordinates
1533 RgnHandle newupdate
= NewRgn() ;
1534 wxSize point
= GetClientSize() ;
1535 wxPoint origin
= GetClientAreaOrigin() ;
1536 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1537 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1538 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1539 m_updateRegion
= newupdate
;
1540 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1542 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1544 wxWindowDC
dc(this);
1545 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1546 wxEraseEvent
eevent( GetId(), &dc
);
1547 eevent
.SetEventObject( this );
1548 GetEventHandler()->ProcessEvent( eevent
);
1550 wxNcPaintEvent
eventNc( GetId() );
1551 eventNc
.SetEventObject( this );
1552 GetEventHandler()->ProcessEvent( eventNc
);
1554 DisposeRgn( ownUpdateRgn
) ;
1555 if ( !m_updateRegion
.Empty() )
1558 event
.m_timeStamp
= time
;
1559 event
.SetEventObject(this);
1560 GetEventHandler()->ProcessEvent(event
);
1564 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1566 RgnHandle childupdate
= NewRgn() ;
1567 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1569 // calculate the update region for the child windows by intersecting the window rectangle with our own
1570 // passed in update region and then offset it to be client-wise window coordinates again
1571 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1572 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1573 SectRgn( childupdate
, updatergn
, childupdate
) ;
1574 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1575 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1577 // because dialogs may also be children
1578 child
->MacRedraw( childupdate
, time
, erase
) ;
1581 DisposeRgn( childupdate
) ;
1582 // eventually a draw grow box here
1586 WXHWND
wxWindowMac::MacGetRootWindow() const
1588 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1592 if ( iter
->IsTopLevel() )
1593 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1595 iter
= iter
->GetParent() ;
1597 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1601 void wxWindowMac::MacCreateScrollBars( long style
)
1603 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1605 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1606 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1608 GetClientSize( &width
, &height
) ;
1610 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1611 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1612 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1613 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1615 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1616 vSize
, wxVERTICAL
);
1618 if ( style
& wxVSCROLL
)
1624 m_vScrollBar
->Show(false) ;
1626 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1627 hSize
, wxHORIZONTAL
);
1628 if ( style
& wxHSCROLL
)
1633 m_hScrollBar
->Show(false) ;
1636 // because the create does not take into account the client area origin
1637 MacRepositionScrollBars() ; // we might have a real position shift
1640 void wxWindowMac::MacRepositionScrollBars()
1642 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1643 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1645 // get real client area
1647 int width
= m_width
;
1648 int height
= m_height
;
1650 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1651 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1653 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1654 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1655 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1656 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1663 MacClientToRootWindow( &x
, &y
) ;
1664 MacClientToRootWindow( &w
, &h
) ;
1666 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1668 int totW
= 10000 , totH
= 10000;
1671 if ( iter
->IsTopLevel() )
1673 totW
= iter
->m_width
;
1674 totH
= iter
->m_height
;
1678 iter
= iter
->GetParent() ;
1706 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1710 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1714 bool wxWindowMac::AcceptsFocus() const
1716 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1719 WXWidget
wxWindowMac::MacGetContainerForEmbedding()
1721 return GetParent()->MacGetContainerForEmbedding() ;
1724 void wxWindowMac::MacSuperChangedPosition()
1726 // only window-absolute structures have to be moved i.e. controls
1728 wxNode
*node
= GetChildren().First();
1731 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1732 child
->MacSuperChangedPosition() ;
1733 node
= node
->Next();
1737 void wxWindowMac::MacTopLevelWindowChangedPosition()
1739 // only screen-absolute structures have to be moved i.e. glcanvas
1741 wxNode
*node
= GetChildren().First();
1744 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1745 child
->MacTopLevelWindowChangedPosition() ;
1746 node
= node
->Next();
1749 long wxWindowMac::MacGetLeftBorderSize( ) const
1754 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1757 #if wxMAC_USE_THEME_BORDER
1759 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1764 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1767 #if wxMAC_USE_THEME_BORDER
1769 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1774 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1781 long wxWindowMac::MacGetRightBorderSize( ) const
1783 // they are all symmetric in mac themes
1784 return MacGetLeftBorderSize() ;
1787 long wxWindowMac::MacGetTopBorderSize( ) const
1789 // they are all symmetric in mac themes
1790 return MacGetLeftBorderSize() ;
1793 long wxWindowMac::MacGetBottomBorderSize( ) const
1795 // they are all symmetric in mac themes
1796 return MacGetLeftBorderSize() ;
1799 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1801 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1804 // Find the wxWindowMac at the current mouse position, returning the mouse
1806 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1808 pt
= wxGetMousePosition();
1809 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1813 // Get the current mouse position.
1814 wxPoint
wxGetMousePosition()
1817 wxGetMousePosition(& x
, & y
);
1818 return wxPoint(x
, y
);