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"
38 #include "wx/spinctrl.h"
45 #define wxWINDOW_HSCROLL 5998
46 #define wxWINDOW_VSCROLL 5997
47 #define MAC_SCROLLBAR_SIZE 16
49 #include "wx/mac/uma.h"
52 #include <ToolUtils.h>
55 #if wxUSE_DRAG_AND_DROP
61 extern wxList wxPendingDelete
;
62 wxWindowMac
* gFocusWindow
= NULL
;
64 #ifdef __WXUNIVERSAL__
65 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
67 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
68 #endif // __WXUNIVERSAL__/__WXMAC__
70 #if !USE_SHARED_LIBRARY
72 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
73 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
74 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
75 EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged
)
76 EVT_INIT_DIALOG(wxWindowMac::OnInitDialog
)
77 EVT_IDLE(wxWindowMac::OnIdle
)
78 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
83 #define wxMAC_DEBUG_REDRAW 0
84 #ifndef wxMAC_DEBUG_REDRAW
85 #define wxMAC_DEBUG_REDRAW 0
88 #define wxMAC_USE_THEME_BORDER 0
91 // ===========================================================================
93 // ===========================================================================
96 // ----------------------------------------------------------------------------
97 // constructors and such
98 // ----------------------------------------------------------------------------
100 void wxWindowMac::Init()
106 m_doubleClickAllowed
= 0;
107 m_winCaptured
= FALSE
;
109 m_isBeingDeleted
= FALSE
;
112 m_mouseInWindow
= FALSE
;
116 m_backgroundTransparent
= FALSE
;
118 // as all windows are created with WS_VISIBLE style...
126 m_hScrollBar
= NULL
;
127 m_vScrollBar
= NULL
;
129 m_label
= wxEmptyString
;
133 wxWindowMac::~wxWindowMac()
135 // deleting a window while it is shown invalidates the region
137 wxWindowMac
* iter
= this ;
139 if ( iter
->IsTopLevel() )
144 iter
= iter
->GetParent() ;
149 m_isBeingDeleted
= TRUE
;
151 if ( s_lastMouseWindow
== this )
153 s_lastMouseWindow
= NULL
;
156 if ( gFocusWindow
== this )
158 gFocusWindow
= NULL
;
162 m_parent
->RemoveChild(this);
168 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
172 const wxString
& name
)
174 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
176 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
179 parent
->AddChild(this);
183 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
184 m_width
= WidthDefault( size
.x
);
185 m_height
= HeightDefault( size
.y
) ;
186 #ifndef __WXUNIVERSAL__
187 if ( ! IsKindOf( CLASSINFO ( wxControl
) ) && ! IsKindOf( CLASSINFO( wxStatusBar
) ) )
189 MacCreateScrollBars( style
) ;
195 void wxWindowMac::SetFocus()
197 if ( gFocusWindow
== this )
200 if ( AcceptsFocus() )
206 if ( gFocusWindow
->m_caret
)
208 gFocusWindow
->m_caret
->OnKillFocus();
210 #endif // wxUSE_CARET
211 #ifndef __WXUNIVERSAL__
212 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
213 if ( control
&& control
->GetMacControl() )
215 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNoPart
) ;
216 control
->MacRedrawControl() ;
219 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
220 event
.SetEventObject(gFocusWindow
);
221 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
223 gFocusWindow
= this ;
229 m_caret
->OnSetFocus();
231 #endif // wxUSE_CARET
232 // panel wants to track the window which was the last to have focus in it
233 wxChildFocusEvent
eventFocus(this);
234 GetEventHandler()->ProcessEvent(eventFocus
);
236 #ifndef __WXUNIVERSAL__
237 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
238 if ( control
&& control
->GetMacControl() )
240 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlEditTextPart
) ;
243 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
244 event
.SetEventObject(this);
245 GetEventHandler()->ProcessEvent(event
) ;
250 bool wxWindowMac::Enable(bool enable
)
252 if ( !wxWindowBase::Enable(enable
) )
255 MacSuperEnabled( enable
) ;
260 void wxWindowMac::DoCaptureMouse()
262 wxTheApp
->s_captureWindow
= this ;
265 wxWindow
* wxWindowBase::GetCapture()
267 return wxTheApp
->s_captureWindow
;
270 void wxWindowMac::DoReleaseMouse()
272 wxTheApp
->s_captureWindow
= NULL
;
275 #if wxUSE_DRAG_AND_DROP
277 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
279 if ( m_dropTarget
!= 0 ) {
283 m_dropTarget
= pDropTarget
;
284 if ( m_dropTarget
!= 0 )
292 // Old style file-manager drag&drop
293 void wxWindowMac::DragAcceptFiles(bool accept
)
299 void wxWindowMac::DoGetSize(int *x
, int *y
) const
302 if(y
) *y
= m_height
;
305 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
311 if ( !IsTopLevel() && GetParent())
313 wxPoint
pt(GetParent()->GetClientAreaOrigin());
322 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
324 menu
->SetInvokingWindow(this);
326 ClientToScreen( &x
, &y
) ;
328 ::InsertMenu( (MenuHandle
) menu
->GetHMenu() , -1 ) ;
329 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
330 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
331 ::DeleteMenu( menu
->MacGetMenuId() ) ;
332 menu
->SetInvokingWindow(NULL
);
338 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
340 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
342 Point localwhere
= {0,0} ;
344 if(x
) localwhere
.h
= * x
;
345 if(y
) localwhere
.v
= * y
;
349 ::SetPort( UMAGetWindowPort( window
) ) ;
350 ::GlobalToLocal( &localwhere
) ;
353 if(x
) *x
= localwhere
.h
;
354 if(y
) *y
= localwhere
.v
;
356 MacRootWindowToWindow( x
, y
) ;
358 x
-= MacGetLeftBorderSize() ;
360 y
-= MacGetTopBorderSize() ;
363 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
365 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
368 x
+= MacGetLeftBorderSize() ;
370 y
+= MacGetTopBorderSize() ;
372 MacWindowToRootWindow( x
, y
) ;
374 Point localwhere
= { 0,0 };
375 if(x
) localwhere
.h
= * x
;
376 if(y
) localwhere
.v
= * y
;
380 ::SetPort( UMAGetWindowPort( window
) ) ;
382 ::LocalToGlobal( &localwhere
) ;
384 if(x
) *x
= localwhere
.h
;
385 if(y
) *y
= localwhere
.v
;
388 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
390 wxPoint origin
= GetClientAreaOrigin() ;
391 if(x
) *x
+= origin
.x
;
392 if(y
) *y
+= origin
.y
;
394 MacWindowToRootWindow( x
, y
) ;
397 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
399 wxPoint origin
= GetClientAreaOrigin() ;
400 MacRootWindowToWindow( x
, y
) ;
401 if(x
) *x
-= origin
.x
;
402 if(y
) *y
-= origin
.y
;
405 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
411 GetParent()->MacWindowToRootWindow( x
, y
) ;
415 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
421 GetParent()->MacRootWindowToWindow( x
, y
) ;
425 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
427 if (m_cursor
== cursor
)
430 if (wxNullCursor
== cursor
)
432 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
437 if ( ! wxWindowBase::SetCursor( cursor
) )
441 wxASSERT_MSG( m_cursor
.Ok(),
442 wxT("cursor must be valid after call to the base version"));
445 wxWindowMac
*mouseWin
;
448 // Change the cursor NOW if we're within the correct window
450 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
452 if ( mouseWin
== this && !wxIsBusy() )
454 m_cursor
.MacInstall() ;
462 // Get size *available for subwindows* i.e. excluding menu bar etc.
463 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
469 ww
-= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
470 hh
-= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
472 if ( (m_vScrollBar
&& m_vScrollBar
->IsShown()) || (m_hScrollBar
&& m_hScrollBar
->IsShown()) )
479 MacClientToRootWindow( &x1
, &y1
) ;
480 MacClientToRootWindow( &w
, &h
) ;
482 wxWindowMac
*iter
= (wxWindowMac
*)this ;
484 int totW
= 10000 , totH
= 10000;
487 if ( iter
->IsTopLevel() )
489 totW
= iter
->m_width
;
490 totH
= iter
->m_height
;
494 iter
= iter
->GetParent() ;
497 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
499 hh
-= MAC_SCROLLBAR_SIZE
;
505 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
507 ww
-= MAC_SCROLLBAR_SIZE
;
519 // ----------------------------------------------------------------------------
521 // ----------------------------------------------------------------------------
525 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
527 wxWindowBase::DoSetToolTip(tooltip
);
530 m_tooltip
->SetWindow(this);
533 #endif // wxUSE_TOOLTIPS
535 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
539 int former_w
= m_width
;
540 int former_h
= m_height
;
542 int actualWidth
= width
;
543 int actualHeight
= height
;
547 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
548 actualWidth
= m_minWidth
;
549 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
550 actualHeight
= m_minHeight
;
551 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
552 actualWidth
= m_maxWidth
;
553 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
554 actualHeight
= m_maxHeight
;
556 bool doMove
= false ;
557 bool doResize
= false ;
559 if ( actualX
!= former_x
|| actualY
!= former_y
)
563 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
568 if ( doMove
|| doResize
)
570 // erase former position
576 m_width
= actualWidth
;
577 m_height
= actualHeight
;
579 // erase new position
583 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
585 MacRepositionScrollBars() ;
588 wxPoint
point(m_x
, m_y
);
589 wxMoveEvent
event(point
, m_windowId
);
590 event
.SetEventObject(this);
591 GetEventHandler()->ProcessEvent(event
) ;
595 MacRepositionScrollBars() ;
596 wxSize
size(m_width
, m_height
);
597 wxSizeEvent
event(size
, m_windowId
);
598 event
.SetEventObject(this);
599 GetEventHandler()->ProcessEvent(event
);
605 // set the size of the window: if the dimensions are positive, just use them,
606 // but if any of them is equal to -1, it means that we must find the value for
607 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
608 // which case -1 is a valid value for x and y)
610 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
611 // the width/height to best suit our contents, otherwise we reuse the current
613 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
615 // get the current size and position...
616 int currentX
, currentY
;
617 GetPosition(¤tX
, ¤tY
);
619 int currentW
,currentH
;
620 GetSize(¤tW
, ¤tH
);
622 // ... and don't do anything (avoiding flicker) if it's already ok
623 if ( x
== currentX
&& y
== currentY
&&
624 width
== currentW
&& height
== currentH
)
626 MacRepositionScrollBars() ; // we might have a real position shift
630 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
632 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
635 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
640 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
642 size
= DoGetBestSize();
647 // just take the current one
654 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
658 size
= DoGetBestSize();
660 //else: already called DoGetBestSize() above
666 // just take the current one
671 DoMoveWindow(x
, y
, width
, height
);
674 // For implementation purposes - sometimes decorations make the client area
677 wxPoint
wxWindowMac::GetClientAreaOrigin() const
679 return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
682 void wxWindowMac::SetTitle(const wxString
& title
)
687 wxString
wxWindowMac::GetTitle() const
692 bool wxWindowMac::Show(bool show
)
694 if ( !wxWindowBase::Show(show
) )
697 MacSuperShown( show
) ;
700 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
701 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
702 if ( win
&& !win
->m_isBeingDeleted
)
713 void wxWindowMac::MacSuperShown( bool show
)
715 wxNode
*node
= GetChildren().First();
718 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
719 if ( child
->m_isShown
)
720 child
->MacSuperShown( show
) ;
725 void wxWindowMac::MacSuperEnabled( bool enabled
)
729 // to be absolutely correct we'd have to invalidate (with eraseBkground
730 // because unter MacOSX the frames are drawn with an addXXX mode)
733 wxNode
*node
= GetChildren().First();
736 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
737 if ( child
->m_isShown
)
738 child
->MacSuperEnabled( enabled
) ;
743 bool wxWindowMac::MacIsReallyShown() const
745 if ( m_isShown
&& (m_parent
!= NULL
) ) {
746 return m_parent
->MacIsReallyShown();
750 bool status = m_isShown ;
751 wxWindowMac * win = this ;
752 while ( status && win->m_parent != NULL )
754 win = win->m_parent ;
755 status = win->m_isShown ;
761 int wxWindowMac::GetCharHeight() const
763 wxClientDC
dc ( (wxWindowMac
*)this ) ;
764 return dc
.GetCharHeight() ;
767 int wxWindowMac::GetCharWidth() const
769 wxClientDC
dc ( (wxWindowMac
*)this ) ;
770 return dc
.GetCharWidth() ;
773 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
774 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
776 const wxFont
*fontToUse
= theFont
;
780 wxClientDC
dc( (wxWindowMac
*) this ) ;
782 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
783 if ( externalLeading
)
784 *externalLeading
= le
;
794 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
795 * we always intersect with the entire window, not only with the client area
798 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
800 if ( MacGetTopLevelWindow() == NULL
)
804 client
= GetClientAreaOrigin( ) ;
805 Rect clientrect
= { -client
.y
, -client
.x
, m_height
- client
.y
, m_width
- client
.x
} ;
808 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
809 SectRect( &clientrect
, &r
, &clientrect
) ;
811 if ( !EmptyRect( &clientrect
) )
813 int top
= 0 , left
= 0 ;
815 MacClientToRootWindow( &left
, &top
) ;
816 OffsetRect( &clientrect
, left
, top
) ;
818 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
822 #if wxUSE_CARET && WXWIN_COMPATIBILITY
823 // ---------------------------------------------------------------------------
824 // Caret manipulation
825 // ---------------------------------------------------------------------------
827 void wxWindowMac::CreateCaret(int w
, int h
)
829 SetCaret(new wxCaret(this, w
, h
));
832 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
834 wxFAIL_MSG("not implemented");
837 void wxWindowMac::ShowCaret(bool show
)
839 wxCHECK_RET( m_caret
, "no caret to show" );
844 void wxWindowMac::DestroyCaret()
849 void wxWindowMac::SetCaretPos(int x
, int y
)
851 wxCHECK_RET( m_caret
, "no caret to move" );
856 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
858 wxCHECK_RET( m_caret
, "no caret to get position of" );
860 m_caret
->GetPosition(x
, y
);
862 #endif // wxUSE_CARET
864 wxWindowMac
*wxGetActiveWindow()
866 // actually this is a windows-only concept
870 // Coordinates relative to the window
871 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
873 // We really dont move the mouse programmatically under mac
876 const wxBrush
& wxWindowMac::MacGetBackgroundBrush()
878 if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
880 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDocumentWindowBackground
) ;
882 else if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) )
884 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
885 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
886 // either a non gray background color or a non control window
888 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
890 wxWindowMac
* parent
= GetParent() ;
893 if ( parent
->MacGetRootWindow() != window
)
895 // we are in a different window on the mac system
901 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
)
902 && parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
904 // if we have any other colours in the hierarchy
905 m_macBackgroundBrush
.SetColour( parent
->m_backgroundColour
) ;
908 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
909 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
911 Rect extent
= { 0 , 0 , 0 , 0 } ;
914 wxSize size
= GetSize() ;
915 parent
->MacClientToRootWindow( &x
, &y
) ;
919 extent
.right
= x
+ size
.x
;
920 extent
.bottom
= y
+ size
.y
;
921 m_macBackgroundBrush
.SetMacThemeBackground( kThemeBackgroundTabPane
, (WXRECTPTR
) &extent
) ; // todo eventually change for inactive
925 parent
= parent
->GetParent() ;
929 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDialogBackgroundActive
) ; // todo eventually change for inactive
934 m_macBackgroundBrush
.SetColour( m_backgroundColour
) ;
937 return m_macBackgroundBrush
;
941 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
943 event
.GetDC()->Clear() ;
946 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
948 wxWindowDC
dc(this) ;
949 wxMacPortSetter
helper(&dc
) ;
951 MacPaintBorders( dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
954 int wxWindowMac::GetScrollPos(int orient
) const
956 if ( orient
== wxHORIZONTAL
)
959 return m_hScrollBar
->GetThumbPosition() ;
964 return m_vScrollBar
->GetThumbPosition() ;
969 // This now returns the whole range, not just the number
970 // of positions that we can scroll.
971 int wxWindowMac::GetScrollRange(int orient
) const
973 if ( orient
== wxHORIZONTAL
)
976 return m_hScrollBar
->GetRange() ;
981 return m_vScrollBar
->GetRange() ;
986 int wxWindowMac::GetScrollThumb(int orient
) const
988 if ( orient
== wxHORIZONTAL
)
991 return m_hScrollBar
->GetThumbSize() ;
996 return m_vScrollBar
->GetThumbSize() ;
1001 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
1003 if ( orient
== wxHORIZONTAL
)
1006 m_hScrollBar
->SetThumbPosition( pos
) ;
1011 m_vScrollBar
->SetThumbPosition( pos
) ;
1015 void wxWindowMac::MacPaintBorders( int left
, int top
)
1020 RGBColor white
= { 0xFFFF, 0xFFFF , 0xFFFF } ;
1021 RGBColor black
= { 0x0000, 0x0000 , 0x0000 } ;
1022 RGBColor face
= { 0xDDDD, 0xDDDD , 0xDDDD } ;
1023 RGBColor shadow
= { 0x4444, 0x4444 , 0x4444 } ;
1026 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
1028 #if wxMAC_USE_THEME_BORDER
1029 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1032 GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
1033 InsetRect( &rect , border , border );
1034 DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
1037 DrawThemePrimaryGroup(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
1039 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
1040 RGBForeColor( &face
);
1041 MoveTo( left
+ 0 , top
+ m_height
- 2 );
1042 LineTo( left
+ 0 , top
+ 0 );
1043 LineTo( left
+ m_width
- 2 , top
+ 0 );
1045 MoveTo( left
+ 2 , top
+ m_height
- 3 );
1046 LineTo( left
+ m_width
- 3 , top
+ m_height
- 3 );
1047 LineTo( left
+ m_width
- 3 , top
+ 2 );
1049 RGBForeColor( sunken
? &face
: &black
);
1050 MoveTo( left
+ 0 , top
+ m_height
- 1 );
1051 LineTo( left
+ m_width
- 1 , top
+ m_height
- 1 );
1052 LineTo( left
+ m_width
- 1 , top
+ 0 );
1054 RGBForeColor( sunken
? &shadow
: &white
);
1055 MoveTo( left
+ 1 , top
+ m_height
- 3 );
1056 LineTo( left
+ 1, top
+ 1 );
1057 LineTo( left
+ m_width
- 3 , top
+ 1 );
1059 RGBForeColor( sunken
? &white
: &shadow
);
1060 MoveTo( left
+ 1 , top
+ m_height
- 2 );
1061 LineTo( left
+ m_width
- 2 , top
+ m_height
- 2 );
1062 LineTo( left
+ m_width
- 2 , top
+ 1 );
1064 RGBForeColor( sunken
? &black
: &face
);
1065 MoveTo( left
+ 2 , top
+ m_height
- 4 );
1066 LineTo( left
+ 2 , top
+ 2 );
1067 LineTo( left
+ m_width
- 4 , top
+ 2 );
1070 else if (HasFlag(wxSIMPLE_BORDER
))
1072 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1073 RGBForeColor( &black
) ;
1074 FrameRect( &rect
) ;
1078 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
1080 if ( child
== m_hScrollBar
)
1081 m_hScrollBar
= NULL
;
1082 if ( child
== m_vScrollBar
)
1083 m_vScrollBar
= NULL
;
1085 wxWindowBase::RemoveChild( child
) ;
1088 // New function that will replace some of the above.
1089 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
1090 int range
, bool refresh
)
1092 if ( orient
== wxHORIZONTAL
)
1096 if ( range
== 0 || thumbVisible
>= range
)
1098 if ( m_hScrollBar
->IsShown() )
1099 m_hScrollBar
->Show(false) ;
1103 if ( !m_hScrollBar
->IsShown() )
1104 m_hScrollBar
->Show(true) ;
1105 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1113 if ( range
== 0 || thumbVisible
>= range
)
1115 if ( m_vScrollBar
->IsShown() )
1116 m_vScrollBar
->Show(false) ;
1120 if ( !m_vScrollBar
->IsShown() )
1121 m_vScrollBar
->Show(true) ;
1122 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1126 MacRepositionScrollBars() ;
1129 // Does a physical scroll
1130 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1132 wxClientDC
dc(this) ;
1133 wxMacPortSetter
helper(&dc
) ;
1136 int width
, height
;
1137 GetClientSize( &width
, &height
) ;
1139 Rect scrollrect
= { dc
.YLOG2DEVMAC(0) , dc
.XLOG2DEVMAC(0) , dc
.YLOG2DEVMAC(height
) , dc
.XLOG2DEVMAC(width
) } ;
1140 RgnHandle updateRgn
= NewRgn() ;
1141 ClipRect( &scrollrect
) ;
1144 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
1145 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
1146 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1148 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1149 InvalWindowRgn( (WindowRef
) MacGetRootWindow() , updateRgn
) ;
1150 DisposeRgn( updateRgn
) ;
1153 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1155 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1156 if (child
== m_vScrollBar
) continue;
1157 if (child
== m_hScrollBar
) continue;
1158 if (child
->IsTopLevel()) continue;
1160 child
->GetPosition( &x
, &y
);
1162 child
->GetSize( &w
, &h
);
1163 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1168 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1170 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1172 wxScrollWinEvent wevent
;
1173 wevent
.SetPosition(event
.GetPosition());
1174 wevent
.SetOrientation(event
.GetOrientation());
1175 wevent
.m_eventObject
= this;
1177 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1178 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1180 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1181 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1183 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1184 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1186 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1187 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1189 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1190 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1192 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1193 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1195 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1196 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1199 GetEventHandler()->ProcessEvent(wevent
);
1203 // Get the window with the focus
1204 wxWindowMac
*wxWindowBase::FindFocus()
1206 return gFocusWindow
;
1209 #if WXWIN_COMPATIBILITY
1210 // If nothing defined for this, try the parent.
1211 // E.g. we may be a button loaded from a resource, with no callback function
1213 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1215 if ( GetEventHandler()->ProcessEvent(event
) )
1218 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1220 #endif // WXWIN_COMPATIBILITY_2
1222 #if WXWIN_COMPATIBILITY
1223 wxObject
* wxWindowMac::GetChild(int number
) const
1225 // Return a pointer to the Nth object in the Panel
1226 wxNode
*node
= GetChildren().First();
1229 node
= node
->Next();
1232 wxObject
*obj
= (wxObject
*)node
->Data();
1238 #endif // WXWIN_COMPATIBILITY
1240 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1242 // panel wants to track the window which was the last to have focus in it,
1243 // so we want to set ourselves as the window which last had focus
1245 // notice that it's also important to do it upwards the tree becaus
1246 // otherwise when the top level panel gets focus, it won't set it back to
1247 // us, but to some other sibling
1249 // CS:don't know if this is still needed:
1250 //wxChildFocusEvent eventFocus(this);
1251 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1256 void wxWindowMac::Clear()
1258 wxClientDC
dc(this);
1259 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1260 dc
.SetBackground(brush
);
1264 // Setup background and foreground colours correctly
1265 void wxWindowMac::SetupColours()
1268 SetBackgroundColour(GetParent()->GetBackgroundColour());
1271 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1274 // Check if we need to send a LEAVE event
1275 if (m_mouseInWindow)
1278 ::GetCursorPos(&pt);
1279 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1281 // Generate a LEAVE event
1282 m_mouseInWindow = FALSE;
1283 MSWOnMouseLeave(pt.x, pt.y, 0);
1288 // This calls the UI-update mechanism (querying windows for
1289 // menu/toolbar/control state information)
1293 // Raise the window to the top of the Z order
1294 void wxWindowMac::Raise()
1298 // Lower the window to the bottom of the Z order
1299 void wxWindowMac::Lower()
1303 void wxWindowMac::DoSetClientSize(int width
, int height
)
1305 if ( width
!= -1 || height
!= -1 )
1308 if ( width
!= -1 && m_vScrollBar
)
1309 width
+= MAC_SCROLLBAR_SIZE
;
1310 if ( height
!= -1 && m_vScrollBar
)
1311 height
+= MAC_SCROLLBAR_SIZE
;
1313 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1314 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1316 DoSetSize( -1 , -1 , width
, height
) ;
1321 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1323 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1327 if ((point
.x
< 0) || (point
.y
< 0) ||
1328 (point
.x
> (m_width
)) || (point
.y
> (m_height
)))
1333 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1334 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1338 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1340 wxPoint
newPoint( point
) ;
1342 if ( !IsTopLevel() )
1348 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1350 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1351 // added the m_isShown test --dmazzoni
1352 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1354 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1363 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1367 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1368 if ( ::FindWindow( pt
, &window
) == 3 )
1371 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1374 // No, this yields the CLIENT are, we need the whole frame. RR.
1375 // point = win->ScreenToClient( point ) ;
1378 ::GetPort( &port
) ;
1379 ::SetPort( UMAGetWindowPort( window
) ) ;
1380 ::GlobalToLocal( &pt
) ;
1383 wxPoint
point( pt
.h
, pt
.v
) ;
1385 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1391 extern int wxBusyCursorCount
;
1392 static wxWindow
*gs_lastWhich
= NULL
;
1394 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1396 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1397 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1401 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) || IsKindOf( CLASSINFO( wxSpinCtrl
) ))
1404 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1412 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1414 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1415 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1417 if (child
->MacDispatchMouseEvent(event
))
1424 event
.SetEventObject( this ) ;
1426 if ( wxBusyCursorCount
== 0 )
1428 m_cursor
.MacInstall() ;
1431 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1433 // set focus to this window
1434 if (AcceptsFocus() && FindFocus()!=this)
1439 if ( event
.GetEventType() == wxEVT_MOTION
1440 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1441 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1442 wxToolTip::RelayEvent( this , event
);
1443 #endif // wxUSE_TOOLTIPS
1445 if (gs_lastWhich
!= this)
1447 gs_lastWhich
= this;
1449 // Double clicks must always occur on the same window
1450 if (event
.GetEventType() == wxEVT_LEFT_DCLICK
)
1451 event
.SetEventType( wxEVT_LEFT_DOWN
);
1452 if (event
.GetEventType() == wxEVT_RIGHT_DCLICK
)
1453 event
.SetEventType( wxEVT_RIGHT_DOWN
);
1455 // Same for mouse up events
1456 if (event
.GetEventType() == wxEVT_LEFT_UP
)
1458 if (event
.GetEventType() == wxEVT_RIGHT_UP
)
1462 GetEventHandler()->ProcessEvent( event
) ;
1467 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1471 return m_tooltip
->GetTip() ;
1476 void wxWindowMac::Update()
1478 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1481 win
->MacUpdate( 0 ) ;
1482 #if TARGET_API_MAC_CARBON
1483 if ( QDIsPortBuffered( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) ) )
1485 QDFlushPortBuffer( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) , NULL
) ;
1491 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1493 wxTopLevelWindowMac
* win
= NULL
;
1494 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1497 win
= wxFindWinFromMacWindow( window
) ;
1502 const wxRegion
& wxWindowMac::MacGetVisibleRegion()
1504 RgnHandle visRgn
= NewRgn() ;
1505 RgnHandle tempRgn
= NewRgn() ;
1507 SetRectRgn( visRgn
, 0 , 0 , m_width
, m_height
) ;
1509 //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
1510 if ( IsKindOf( CLASSINFO( wxStaticBox
) ) )
1512 int borderTop
= 14 ;
1513 int borderOther
= 4 ;
1515 SetRectRgn( tempRgn
, borderOther
, borderTop
, m_width
- borderOther
, m_height
- borderOther
) ;
1516 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1519 if ( !IsTopLevel() )
1521 wxWindow
* parent
= GetParent() ;
1524 wxSize size
= parent
->GetSize() ;
1527 parent
->MacWindowToRootWindow( &x
, &y
) ;
1528 MacRootWindowToWindow( &x
, &y
) ;
1529 SetRectRgn( tempRgn
, x
, y
, x
+ size
.x
, y
+ size
.y
) ;
1530 SectRgn( visRgn
, tempRgn
, visRgn
) ;
1531 if ( parent
->IsTopLevel() )
1533 parent
= parent
->GetParent() ;
1536 if ( GetWindowStyle() & wxCLIP_CHILDREN
)
1538 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1540 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1542 if ( !child
->IsTopLevel() && child
->IsShown() )
1544 SetRectRgn( tempRgn
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1545 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1550 if ( (GetWindowStyle() & wxCLIP_SIBLINGS
) && GetParent() )
1552 bool thisWindowThrough
= false ;
1553 for (wxNode
*node
= GetParent()->GetChildren().First(); node
; node
= node
->Next())
1555 wxWindowMac
*sibling
= (wxWindowMac
*)node
->Data();
1556 if ( sibling
== this )
1558 thisWindowThrough
= true ;
1561 if( !thisWindowThrough
)
1566 if ( !sibling
->IsTopLevel() && sibling
->IsShown() )
1568 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
) ;
1569 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1573 m_macVisibleRegion
= visRgn
;
1574 DisposeRgn( visRgn
) ;
1575 DisposeRgn( tempRgn
) ;
1576 return m_macVisibleRegion
;
1579 void wxWindowMac::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
1581 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
1582 // updatergn is always already clipped to our boundaries
1583 // it is in window coordinates, not in client coordinates
1585 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1588 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
1589 RgnHandle ownUpdateRgn
= NewRgn() ;
1590 CopyRgn( updatergn
, ownUpdateRgn
) ;
1592 SectRgn( ownUpdateRgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn
) ;
1594 // newupdate is the update region in client coordinates
1595 RgnHandle newupdate
= NewRgn() ;
1596 wxSize point
= GetClientSize() ;
1597 wxPoint origin
= GetClientAreaOrigin() ;
1598 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1599 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1600 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1601 m_updateRegion
= newupdate
;
1602 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1604 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1606 wxWindowDC
dc(this);
1607 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1608 wxEraseEvent
eevent( GetId(), &dc
);
1609 eevent
.SetEventObject( this );
1610 GetEventHandler()->ProcessEvent( eevent
);
1612 wxNcPaintEvent
eventNc( GetId() );
1613 eventNc
.SetEventObject( this );
1614 GetEventHandler()->ProcessEvent( eventNc
);
1616 DisposeRgn( ownUpdateRgn
) ;
1617 if ( !m_updateRegion
.Empty() )
1620 event
.m_timeStamp
= time
;
1621 event
.SetEventObject(this);
1622 GetEventHandler()->ProcessEvent(event
);
1626 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1628 RgnHandle childupdate
= NewRgn() ;
1629 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1631 // calculate the update region for the child windows by intersecting the window rectangle with our own
1632 // passed in update region and then offset it to be client-wise window coordinates again
1633 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1634 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1635 SectRgn( childupdate
, updatergn
, childupdate
) ;
1636 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1637 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1639 // because dialogs may also be children
1640 child
->MacRedraw( childupdate
, time
, erase
) ;
1643 DisposeRgn( childupdate
) ;
1644 // eventually a draw grow box here
1648 WXHWND
wxWindowMac::MacGetRootWindow() const
1650 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1654 if ( iter
->IsTopLevel() )
1655 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1657 iter
= iter
->GetParent() ;
1659 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1663 void wxWindowMac::MacCreateScrollBars( long style
)
1665 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1667 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1668 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1670 GetClientSize( &width
, &height
) ;
1672 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1673 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1674 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1675 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1677 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1678 vSize
, wxVERTICAL
);
1680 if ( style
& wxVSCROLL
)
1686 m_vScrollBar
->Show(false) ;
1688 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1689 hSize
, wxHORIZONTAL
);
1690 if ( style
& wxHSCROLL
)
1695 m_hScrollBar
->Show(false) ;
1698 // because the create does not take into account the client area origin
1699 MacRepositionScrollBars() ; // we might have a real position shift
1702 void wxWindowMac::MacRepositionScrollBars()
1704 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1705 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1707 // get real client area
1709 int width
= m_width
;
1710 int height
= m_height
;
1712 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1713 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1715 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1716 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1717 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1718 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1725 MacClientToRootWindow( &x
, &y
) ;
1726 MacClientToRootWindow( &w
, &h
) ;
1728 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1730 int totW
= 10000 , totH
= 10000;
1733 if ( iter
->IsTopLevel() )
1735 totW
= iter
->m_width
;
1736 totH
= iter
->m_height
;
1740 iter
= iter
->GetParent() ;
1768 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1772 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1776 bool wxWindowMac::AcceptsFocus() const
1778 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1781 WXWidget
wxWindowMac::MacGetContainerForEmbedding()
1783 return GetParent()->MacGetContainerForEmbedding() ;
1786 void wxWindowMac::MacSuperChangedPosition()
1788 // only window-absolute structures have to be moved i.e. controls
1790 wxNode
*node
= GetChildren().First();
1793 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1794 child
->MacSuperChangedPosition() ;
1795 node
= node
->Next();
1799 void wxWindowMac::MacTopLevelWindowChangedPosition()
1801 // only screen-absolute structures have to be moved i.e. glcanvas
1803 wxNode
*node
= GetChildren().First();
1806 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1807 child
->MacTopLevelWindowChangedPosition() ;
1808 node
= node
->Next();
1811 long wxWindowMac::MacGetLeftBorderSize( ) const
1816 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1819 #if wxMAC_USE_THEME_BORDER
1821 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1826 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1829 #if wxMAC_USE_THEME_BORDER
1831 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1836 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1843 long wxWindowMac::MacGetRightBorderSize( ) const
1845 // they are all symmetric in mac themes
1846 return MacGetLeftBorderSize() ;
1849 long wxWindowMac::MacGetTopBorderSize( ) const
1851 // they are all symmetric in mac themes
1852 return MacGetLeftBorderSize() ;
1855 long wxWindowMac::MacGetBottomBorderSize( ) const
1857 // they are all symmetric in mac themes
1858 return MacGetLeftBorderSize() ;
1861 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1863 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1866 // Find the wxWindowMac at the current mouse position, returning the mouse
1868 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1870 pt
= wxGetMousePosition();
1871 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1875 // Get the current mouse position.
1876 wxPoint
wxGetMousePosition()
1879 wxGetMousePosition(& x
, & y
);
1880 return wxPoint(x
, y
);