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
;
128 m_label
= wxEmptyString
;
132 wxWindowMac::~wxWindowMac()
134 // deleting a window while it is shown invalidates the region
136 wxWindowMac
* iter
= this ;
138 if ( iter
->IsTopLevel() )
143 iter
= iter
->GetParent() ;
148 m_isBeingDeleted
= TRUE
;
150 if ( s_lastMouseWindow
== this )
152 s_lastMouseWindow
= NULL
;
155 if ( gFocusWindow
== this )
157 gFocusWindow
= NULL
;
161 m_parent
->RemoveChild(this);
167 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
171 const wxString
& name
)
173 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
175 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
178 parent
->AddChild(this);
182 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
183 m_width
= WidthDefault( size
.x
);
184 m_height
= HeightDefault( size
.y
) ;
185 #ifndef __WXUNIVERSAL__
186 if ( ! IsKindOf( CLASSINFO ( wxControl
) ) && ! IsKindOf( CLASSINFO( wxStatusBar
) ) )
188 MacCreateScrollBars( style
) ;
194 void wxWindowMac::SetFocus()
196 if ( gFocusWindow
== this )
199 if ( AcceptsFocus() )
205 if ( gFocusWindow
->m_caret
)
207 gFocusWindow
->m_caret
->OnKillFocus();
209 #endif // wxUSE_CARET
210 #ifndef __WXUNIVERSAL__
211 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
212 if ( control
&& control
->GetMacControl() )
214 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNoPart
) ;
215 control
->MacRedrawControl() ;
218 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
219 event
.SetEventObject(gFocusWindow
);
220 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
222 gFocusWindow
= this ;
228 m_caret
->OnSetFocus();
230 #endif // wxUSE_CARET
231 // panel wants to track the window which was the last to have focus in it
232 wxChildFocusEvent
eventFocus(this);
233 GetEventHandler()->ProcessEvent(eventFocus
);
235 #ifndef __WXUNIVERSAL__
236 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
237 if ( control
&& control
->GetMacControl() )
239 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlEditTextPart
) ;
242 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
243 event
.SetEventObject(this);
244 GetEventHandler()->ProcessEvent(event
) ;
249 bool wxWindowMac::Enable(bool enable
)
251 if ( !wxWindowBase::Enable(enable
) )
254 MacSuperEnabled( enable
) ;
259 void wxWindowMac::DoCaptureMouse()
261 wxTheApp
->s_captureWindow
= this ;
264 wxWindow
* wxWindowBase::GetCapture()
266 return wxTheApp
->s_captureWindow
;
269 void wxWindowMac::DoReleaseMouse()
271 wxTheApp
->s_captureWindow
= NULL
;
274 #if wxUSE_DRAG_AND_DROP
276 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
278 if ( m_dropTarget
!= 0 ) {
282 m_dropTarget
= pDropTarget
;
283 if ( m_dropTarget
!= 0 )
291 // Old style file-manager drag&drop
292 void wxWindowMac::DragAcceptFiles(bool accept
)
298 void wxWindowMac::DoGetSize(int *x
, int *y
) const
301 if(y
) *y
= m_height
;
304 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
310 if ( !IsTopLevel() && GetParent())
312 wxPoint
pt(GetParent()->GetClientAreaOrigin());
321 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
323 menu
->SetInvokingWindow(this);
325 ClientToScreen( &x
, &y
) ;
327 ::InsertMenu( (MenuHandle
) menu
->GetHMenu() , -1 ) ;
328 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
329 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
330 ::DeleteMenu( menu
->MacGetMenuId() ) ;
331 menu
->SetInvokingWindow(NULL
);
337 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
339 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
341 Point localwhere
= {0,0} ;
343 if(x
) localwhere
.h
= * x
;
344 if(y
) localwhere
.v
= * y
;
348 ::SetPort( UMAGetWindowPort( window
) ) ;
349 ::GlobalToLocal( &localwhere
) ;
352 if(x
) *x
= localwhere
.h
;
353 if(y
) *y
= localwhere
.v
;
355 MacRootWindowToWindow( x
, y
) ;
357 x
-= MacGetLeftBorderSize() ;
359 y
-= MacGetTopBorderSize() ;
362 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
364 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
367 x
+= MacGetLeftBorderSize() ;
369 y
+= MacGetTopBorderSize() ;
371 MacWindowToRootWindow( x
, y
) ;
373 Point localwhere
= { 0,0 };
374 if(x
) localwhere
.h
= * x
;
375 if(y
) localwhere
.v
= * y
;
379 ::SetPort( UMAGetWindowPort( window
) ) ;
381 ::LocalToGlobal( &localwhere
) ;
383 if(x
) *x
= localwhere
.h
;
384 if(y
) *y
= localwhere
.v
;
387 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
389 wxPoint origin
= GetClientAreaOrigin() ;
390 if(x
) *x
+= origin
.x
;
391 if(y
) *y
+= origin
.y
;
393 MacWindowToRootWindow( x
, y
) ;
396 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
398 wxPoint origin
= GetClientAreaOrigin() ;
399 MacRootWindowToWindow( x
, y
) ;
400 if(x
) *x
-= origin
.x
;
401 if(y
) *y
-= origin
.y
;
404 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
410 GetParent()->MacWindowToRootWindow( x
, y
) ;
414 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
420 GetParent()->MacRootWindowToWindow( x
, y
) ;
424 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
426 if (m_cursor
== cursor
)
429 if (wxNullCursor
== cursor
)
431 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
436 if ( ! wxWindowBase::SetCursor( cursor
) )
440 wxASSERT_MSG( m_cursor
.Ok(),
441 wxT("cursor must be valid after call to the base version"));
444 wxWindowMac
*mouseWin
;
447 // Change the cursor NOW if we're within the correct window
449 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
451 if ( mouseWin
== this && !wxIsBusy() )
453 m_cursor
.MacInstall() ;
461 // Get size *available for subwindows* i.e. excluding menu bar etc.
462 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
468 ww
-= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
469 hh
-= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
471 if ( (m_vScrollBar
&& m_vScrollBar
->IsShown()) || (m_hScrollBar
&& m_hScrollBar
->IsShown()) )
478 MacClientToRootWindow( &x1
, &y1
) ;
479 MacClientToRootWindow( &w
, &h
) ;
481 wxWindowMac
*iter
= (wxWindowMac
*)this ;
483 int totW
= 10000 , totH
= 10000;
486 if ( iter
->IsTopLevel() )
488 totW
= iter
->m_width
;
489 totH
= iter
->m_height
;
493 iter
= iter
->GetParent() ;
496 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
498 hh
-= MAC_SCROLLBAR_SIZE
;
504 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
506 ww
-= MAC_SCROLLBAR_SIZE
;
518 // ----------------------------------------------------------------------------
520 // ----------------------------------------------------------------------------
524 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
526 wxWindowBase::DoSetToolTip(tooltip
);
529 m_tooltip
->SetWindow(this);
532 #endif // wxUSE_TOOLTIPS
534 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
538 int former_w
= m_width
;
539 int former_h
= m_height
;
541 int actualWidth
= width
;
542 int actualHeight
= height
;
546 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
547 actualWidth
= m_minWidth
;
548 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
549 actualHeight
= m_minHeight
;
550 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
551 actualWidth
= m_maxWidth
;
552 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
553 actualHeight
= m_maxHeight
;
555 bool doMove
= false ;
556 bool doResize
= false ;
558 if ( actualX
!= former_x
|| actualY
!= former_y
)
562 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
567 if ( doMove
|| doResize
)
569 // erase former position
575 m_width
= actualWidth
;
576 m_height
= actualHeight
;
578 // erase new position
582 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
584 MacRepositionScrollBars() ;
587 wxPoint
point(m_x
, m_y
);
588 wxMoveEvent
event(point
, m_windowId
);
589 event
.SetEventObject(this);
590 GetEventHandler()->ProcessEvent(event
) ;
594 MacRepositionScrollBars() ;
595 wxSize
size(m_width
, m_height
);
596 wxSizeEvent
event(size
, m_windowId
);
597 event
.SetEventObject(this);
598 GetEventHandler()->ProcessEvent(event
);
604 // set the size of the window: if the dimensions are positive, just use them,
605 // but if any of them is equal to -1, it means that we must find the value for
606 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
607 // which case -1 is a valid value for x and y)
609 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
610 // the width/height to best suit our contents, otherwise we reuse the current
612 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
614 // get the current size and position...
615 int currentX
, currentY
;
616 GetPosition(¤tX
, ¤tY
);
618 int currentW
,currentH
;
619 GetSize(¤tW
, ¤tH
);
621 // ... and don't do anything (avoiding flicker) if it's already ok
622 if ( x
== currentX
&& y
== currentY
&&
623 width
== currentW
&& height
== currentH
)
625 MacRepositionScrollBars() ; // we might have a real position shift
629 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
631 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
634 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
639 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
641 size
= DoGetBestSize();
646 // just take the current one
653 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
657 size
= DoGetBestSize();
659 //else: already called DoGetBestSize() above
665 // just take the current one
670 DoMoveWindow(x
, y
, width
, height
);
673 // For implementation purposes - sometimes decorations make the client area
676 wxPoint
wxWindowMac::GetClientAreaOrigin() const
678 return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
681 void wxWindowMac::SetTitle(const wxString
& title
)
686 wxString
wxWindowMac::GetTitle() const
691 bool wxWindowMac::Show(bool show
)
693 if ( !wxWindowBase::Show(show
) )
696 MacSuperShown( show
) ;
699 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
700 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
701 if ( win
&& !win
->m_isBeingDeleted
)
712 void wxWindowMac::MacSuperShown( bool show
)
714 wxNode
*node
= GetChildren().First();
717 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
718 if ( child
->m_isShown
)
719 child
->MacSuperShown( show
) ;
724 void wxWindowMac::MacSuperEnabled( bool enabled
)
728 // to be absolutely correct we'd have to invalidate (with eraseBkground
729 // because unter MacOSX the frames are drawn with an addXXX mode)
732 wxNode
*node
= GetChildren().First();
735 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
736 if ( child
->m_isShown
)
737 child
->MacSuperEnabled( enabled
) ;
742 bool wxWindowMac::MacIsReallyShown() const
744 if ( m_isShown
&& (m_parent
!= NULL
) ) {
745 return m_parent
->MacIsReallyShown();
749 bool status = m_isShown ;
750 wxWindowMac * win = this ;
751 while ( status && win->m_parent != NULL )
753 win = win->m_parent ;
754 status = win->m_isShown ;
760 int wxWindowMac::GetCharHeight() const
762 wxClientDC
dc ( (wxWindowMac
*)this ) ;
763 return dc
.GetCharHeight() ;
766 int wxWindowMac::GetCharWidth() const
768 wxClientDC
dc ( (wxWindowMac
*)this ) ;
769 return dc
.GetCharWidth() ;
772 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
773 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
775 const wxFont
*fontToUse
= theFont
;
779 wxClientDC
dc( (wxWindowMac
*) this ) ;
781 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
782 if ( externalLeading
)
783 *externalLeading
= le
;
793 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
794 * we always intersect with the entire window, not only with the client area
797 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
799 if ( MacGetTopLevelWindow() == NULL
)
803 client
= GetClientAreaOrigin( ) ;
804 Rect clientrect
= { -client
.y
, -client
.x
, m_height
- client
.y
, m_width
- client
.x
} ;
807 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
808 SectRect( &clientrect
, &r
, &clientrect
) ;
810 if ( !EmptyRect( &clientrect
) )
812 int top
= 0 , left
= 0 ;
814 MacClientToRootWindow( &left
, &top
) ;
815 OffsetRect( &clientrect
, left
, top
) ;
817 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
821 #if wxUSE_CARET && WXWIN_COMPATIBILITY
822 // ---------------------------------------------------------------------------
823 // Caret manipulation
824 // ---------------------------------------------------------------------------
826 void wxWindowMac::CreateCaret(int w
, int h
)
828 SetCaret(new wxCaret(this, w
, h
));
831 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
833 wxFAIL_MSG("not implemented");
836 void wxWindowMac::ShowCaret(bool show
)
838 wxCHECK_RET( m_caret
, "no caret to show" );
843 void wxWindowMac::DestroyCaret()
848 void wxWindowMac::SetCaretPos(int x
, int y
)
850 wxCHECK_RET( m_caret
, "no caret to move" );
855 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
857 wxCHECK_RET( m_caret
, "no caret to get position of" );
859 m_caret
->GetPosition(x
, y
);
861 #endif // wxUSE_CARET
863 wxWindowMac
*wxGetActiveWindow()
865 // actually this is a windows-only concept
869 // Coordinates relative to the window
870 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
872 // We really dont move the mouse programmatically under mac
875 const wxBrush
& wxWindowMac::MacGetBackgroundBrush()
877 if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
879 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDocumentWindowBackground
) ;
881 else if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) )
883 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
884 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
885 // either a non gray background color or a non control window
887 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
889 wxWindowMac
* parent
= GetParent() ;
892 if ( parent
->MacGetRootWindow() != window
)
894 // we are in a different window on the mac system
900 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
)
901 && parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
903 // if we have any other colours in the hierarchy
904 m_macBackgroundBrush
.SetColour( parent
->m_backgroundColour
) ;
907 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
908 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
910 Rect extent
= { 0 , 0 , 0 , 0 } ;
913 wxSize size
= GetSize() ;
914 parent
->MacClientToRootWindow( &x
, &y
) ;
918 extent
.right
= x
+ size
.x
;
919 extent
.bottom
= y
+ size
.y
;
920 m_macBackgroundBrush
.SetMacThemeBackground( kThemeBackgroundTabPane
, (WXRECTPTR
) &extent
) ; // todo eventually change for inactive
924 parent
= parent
->GetParent() ;
928 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDialogBackgroundActive
) ; // todo eventually change for inactive
933 m_macBackgroundBrush
.SetColour( m_backgroundColour
) ;
936 return m_macBackgroundBrush
;
940 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
942 event
.GetDC()->Clear() ;
945 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
947 wxWindowDC
dc(this) ;
948 wxMacPortSetter
helper(&dc
) ;
950 MacPaintBorders( dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
953 int wxWindowMac::GetScrollPos(int orient
) const
955 if ( orient
== wxHORIZONTAL
)
958 return m_hScrollBar
->GetThumbPosition() ;
963 return m_vScrollBar
->GetThumbPosition() ;
968 // This now returns the whole range, not just the number
969 // of positions that we can scroll.
970 int wxWindowMac::GetScrollRange(int orient
) const
972 if ( orient
== wxHORIZONTAL
)
975 return m_hScrollBar
->GetRange() ;
980 return m_vScrollBar
->GetRange() ;
985 int wxWindowMac::GetScrollThumb(int orient
) const
987 if ( orient
== wxHORIZONTAL
)
990 return m_hScrollBar
->GetThumbSize() ;
995 return m_vScrollBar
->GetThumbSize() ;
1000 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
1002 if ( orient
== wxHORIZONTAL
)
1005 m_hScrollBar
->SetThumbPosition( pos
) ;
1010 m_vScrollBar
->SetThumbPosition( pos
) ;
1014 void wxWindowMac::MacPaintBorders( int left
, int top
)
1019 RGBColor white
= { 0xFFFF, 0xFFFF , 0xFFFF } ;
1020 RGBColor black
= { 0x0000, 0x0000 , 0x0000 } ;
1021 RGBColor face
= { 0xDDDD, 0xDDDD , 0xDDDD } ;
1022 RGBColor shadow
= { 0x4444, 0x4444 , 0x4444 } ;
1025 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
1027 #if wxMAC_USE_THEME_BORDER
1028 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1031 GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
1032 InsetRect( &rect , border , border );
1033 DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
1036 DrawThemePrimaryGroup(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
1038 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
1039 RGBForeColor( &face
);
1040 MoveTo( left
+ 0 , top
+ m_height
- 2 );
1041 LineTo( left
+ 0 , top
+ 0 );
1042 LineTo( left
+ m_width
- 2 , top
+ 0 );
1044 MoveTo( left
+ 2 , top
+ m_height
- 3 );
1045 LineTo( left
+ m_width
- 3 , top
+ m_height
- 3 );
1046 LineTo( left
+ m_width
- 3 , top
+ 2 );
1048 RGBForeColor( sunken
? &face
: &black
);
1049 MoveTo( left
+ 0 , top
+ m_height
- 1 );
1050 LineTo( left
+ m_width
- 1 , top
+ m_height
- 1 );
1051 LineTo( left
+ m_width
- 1 , top
+ 0 );
1053 RGBForeColor( sunken
? &shadow
: &white
);
1054 MoveTo( left
+ 1 , top
+ m_height
- 3 );
1055 LineTo( left
+ 1, top
+ 1 );
1056 LineTo( left
+ m_width
- 3 , top
+ 1 );
1058 RGBForeColor( sunken
? &white
: &shadow
);
1059 MoveTo( left
+ 1 , top
+ m_height
- 2 );
1060 LineTo( left
+ m_width
- 2 , top
+ m_height
- 2 );
1061 LineTo( left
+ m_width
- 2 , top
+ 1 );
1063 RGBForeColor( sunken
? &black
: &face
);
1064 MoveTo( left
+ 2 , top
+ m_height
- 4 );
1065 LineTo( left
+ 2 , top
+ 2 );
1066 LineTo( left
+ m_width
- 4 , top
+ 2 );
1069 else if (HasFlag(wxSIMPLE_BORDER
))
1071 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1072 RGBForeColor( &black
) ;
1073 FrameRect( &rect
) ;
1077 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
1079 if ( child
== m_hScrollBar
)
1080 m_hScrollBar
= NULL
;
1081 if ( child
== m_vScrollBar
)
1082 m_vScrollBar
= NULL
;
1084 wxWindowBase::RemoveChild( child
) ;
1087 // New function that will replace some of the above.
1088 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
1089 int range
, bool refresh
)
1091 if ( orient
== wxHORIZONTAL
)
1095 if ( range
== 0 || thumbVisible
>= range
)
1097 if ( m_hScrollBar
->IsShown() )
1098 m_hScrollBar
->Show(false) ;
1102 if ( !m_hScrollBar
->IsShown() )
1103 m_hScrollBar
->Show(true) ;
1104 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1112 if ( range
== 0 || thumbVisible
>= range
)
1114 if ( m_vScrollBar
->IsShown() )
1115 m_vScrollBar
->Show(false) ;
1119 if ( !m_vScrollBar
->IsShown() )
1120 m_vScrollBar
->Show(true) ;
1121 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1125 MacRepositionScrollBars() ;
1128 // Does a physical scroll
1129 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1131 wxClientDC
dc(this) ;
1132 wxMacPortSetter
helper(&dc
) ;
1135 int width
, height
;
1136 GetClientSize( &width
, &height
) ;
1138 Rect scrollrect
= { dc
.YLOG2DEVMAC(0) , dc
.XLOG2DEVMAC(0) , dc
.YLOG2DEVMAC(height
) , dc
.XLOG2DEVMAC(width
) } ;
1139 RgnHandle updateRgn
= NewRgn() ;
1140 ClipRect( &scrollrect
) ;
1143 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
1144 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
1145 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1147 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1148 InvalWindowRgn( (WindowRef
) MacGetRootWindow() , updateRgn
) ;
1149 DisposeRgn( updateRgn
) ;
1152 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1154 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1155 if (child
== m_vScrollBar
) continue;
1156 if (child
== m_hScrollBar
) continue;
1157 if (child
->IsTopLevel()) continue;
1159 child
->GetPosition( &x
, &y
);
1161 child
->GetSize( &w
, &h
);
1162 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1167 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1169 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1171 wxScrollWinEvent wevent
;
1172 wevent
.SetPosition(event
.GetPosition());
1173 wevent
.SetOrientation(event
.GetOrientation());
1174 wevent
.m_eventObject
= this;
1176 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1177 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1179 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1180 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1182 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1183 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1185 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1186 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1188 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1189 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1191 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1192 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1194 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1195 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1198 GetEventHandler()->ProcessEvent(wevent
);
1202 // Get the window with the focus
1203 wxWindowMac
*wxWindowBase::FindFocus()
1205 return gFocusWindow
;
1208 #if WXWIN_COMPATIBILITY
1209 // If nothing defined for this, try the parent.
1210 // E.g. we may be a button loaded from a resource, with no callback function
1212 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1214 if ( GetEventHandler()->ProcessEvent(event
) )
1217 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1219 #endif // WXWIN_COMPATIBILITY_2
1221 #if WXWIN_COMPATIBILITY
1222 wxObject
* wxWindowMac::GetChild(int number
) const
1224 // Return a pointer to the Nth object in the Panel
1225 wxNode
*node
= GetChildren().First();
1228 node
= node
->Next();
1231 wxObject
*obj
= (wxObject
*)node
->Data();
1237 #endif // WXWIN_COMPATIBILITY
1239 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1241 // panel wants to track the window which was the last to have focus in it,
1242 // so we want to set ourselves as the window which last had focus
1244 // notice that it's also important to do it upwards the tree becaus
1245 // otherwise when the top level panel gets focus, it won't set it back to
1246 // us, but to some other sibling
1248 // CS:don't know if this is still needed:
1249 //wxChildFocusEvent eventFocus(this);
1250 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1255 void wxWindowMac::Clear()
1257 wxClientDC
dc(this);
1258 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1259 dc
.SetBackground(brush
);
1263 // Setup background and foreground colours correctly
1264 void wxWindowMac::SetupColours()
1267 SetBackgroundColour(GetParent()->GetBackgroundColour());
1270 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1273 // Check if we need to send a LEAVE event
1274 if (m_mouseInWindow)
1277 ::GetCursorPos(&pt);
1278 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1280 // Generate a LEAVE event
1281 m_mouseInWindow = FALSE;
1282 MSWOnMouseLeave(pt.x, pt.y, 0);
1287 // This calls the UI-update mechanism (querying windows for
1288 // menu/toolbar/control state information)
1292 // Raise the window to the top of the Z order
1293 void wxWindowMac::Raise()
1297 // Lower the window to the bottom of the Z order
1298 void wxWindowMac::Lower()
1302 void wxWindowMac::DoSetClientSize(int width
, int height
)
1304 if ( width
!= -1 || height
!= -1 )
1307 if ( width
!= -1 && m_vScrollBar
)
1308 width
+= MAC_SCROLLBAR_SIZE
;
1309 if ( height
!= -1 && m_vScrollBar
)
1310 height
+= MAC_SCROLLBAR_SIZE
;
1312 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1313 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1315 DoSetSize( -1 , -1 , width
, height
) ;
1320 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1322 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1326 if ((point
.x
< 0) || (point
.y
< 0) ||
1327 (point
.x
> (m_width
)) || (point
.y
> (m_height
)))
1332 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1333 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1337 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1339 wxPoint
newPoint( point
) ;
1341 if ( !IsTopLevel() )
1347 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1349 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1350 // added the m_isShown test --dmazzoni
1351 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1353 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1362 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1366 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1367 if ( ::FindWindow( pt
, &window
) == 3 )
1370 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1373 // No, this yields the CLIENT are, we need the whole frame. RR.
1374 // point = win->ScreenToClient( point ) ;
1377 ::GetPort( &port
) ;
1378 ::SetPort( UMAGetWindowPort( window
) ) ;
1379 ::GlobalToLocal( &pt
) ;
1382 wxPoint
point( pt
.h
, pt
.v
) ;
1384 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1390 extern int wxBusyCursorCount
;
1391 static wxWindow
*gs_lastWhich
= NULL
;
1393 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1395 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1396 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1400 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) )
1403 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1411 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1413 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1414 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1416 if (child
->MacDispatchMouseEvent(event
))
1423 event
.SetEventObject( this ) ;
1425 if ( wxBusyCursorCount
== 0 )
1427 m_cursor
.MacInstall() ;
1430 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1432 // set focus to this window
1433 if (AcceptsFocus() && FindFocus()!=this)
1438 if ( event
.GetEventType() == wxEVT_MOTION
1439 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1440 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1441 wxToolTip::RelayEvent( this , event
);
1442 #endif // wxUSE_TOOLTIPS
1444 if (gs_lastWhich
!= this)
1446 gs_lastWhich
= this;
1448 // Double clicks must always occur on the same window
1449 if (event
.GetEventType() == wxEVT_LEFT_DCLICK
)
1450 event
.SetEventType( wxEVT_LEFT_DOWN
);
1451 if (event
.GetEventType() == wxEVT_RIGHT_DCLICK
)
1452 event
.SetEventType( wxEVT_RIGHT_DOWN
);
1454 // Same for mouse up events
1455 if (event
.GetEventType() == wxEVT_LEFT_UP
)
1457 if (event
.GetEventType() == wxEVT_RIGHT_UP
)
1461 GetEventHandler()->ProcessEvent( event
) ;
1466 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1470 return m_tooltip
->GetTip() ;
1475 void wxWindowMac::Update()
1477 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1480 win
->MacUpdate( 0 ) ;
1481 #if TARGET_API_MAC_CARBON
1482 if ( QDIsPortBuffered( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) ) )
1484 QDFlushPortBuffer( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) , NULL
) ;
1490 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1492 wxTopLevelWindowMac
* win
= NULL
;
1493 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1496 win
= wxFindWinFromMacWindow( window
) ;
1501 const wxRegion
& wxWindowMac::MacGetVisibleRegion()
1503 RgnHandle visRgn
= NewRgn() ;
1504 RgnHandle tempRgn
= NewRgn() ;
1506 SetRectRgn( visRgn
, 0 , 0 , m_width
, m_height
) ;
1508 //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
1509 if ( IsKindOf( CLASSINFO( wxStaticBox
) ) )
1511 int borderTop
= 14 ;
1512 int borderOther
= 4 ;
1514 SetRectRgn( tempRgn
, borderOther
, borderTop
, m_width
- borderOther
, m_height
- borderOther
) ;
1515 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1518 if ( !IsTopLevel() )
1520 wxWindow
* parent
= GetParent() ;
1523 wxSize size
= parent
->GetSize() ;
1526 parent
->MacWindowToRootWindow( &x
, &y
) ;
1527 MacRootWindowToWindow( &x
, &y
) ;
1528 SetRectRgn( tempRgn
, x
, y
, x
+ size
.x
, y
+ size
.y
) ;
1529 SectRgn( visRgn
, tempRgn
, visRgn
) ;
1530 if ( parent
->IsTopLevel() )
1532 parent
= parent
->GetParent() ;
1535 if ( GetWindowStyle() & wxCLIP_CHILDREN
)
1537 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1539 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1541 if ( !child
->IsTopLevel() && child
->IsShown() )
1543 SetRectRgn( tempRgn
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1544 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1549 if ( (GetWindowStyle() & wxCLIP_SIBLINGS
) && GetParent() )
1551 bool thisWindowThrough
= false ;
1552 for (wxNode
*node
= GetParent()->GetChildren().First(); node
; node
= node
->Next())
1554 wxWindowMac
*sibling
= (wxWindowMac
*)node
->Data();
1555 if ( sibling
== this )
1557 thisWindowThrough
= true ;
1560 if( !thisWindowThrough
)
1565 if ( !sibling
->IsTopLevel() && sibling
->IsShown() )
1567 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
) ;
1568 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1572 m_macVisibleRegion
= visRgn
;
1573 DisposeRgn( visRgn
) ;
1574 DisposeRgn( tempRgn
) ;
1575 return m_macVisibleRegion
;
1578 void wxWindowMac::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
1580 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
1581 // updatergn is always already clipped to our boundaries
1582 // it is in window coordinates, not in client coordinates
1584 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1587 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
1588 RgnHandle ownUpdateRgn
= NewRgn() ;
1589 CopyRgn( updatergn
, ownUpdateRgn
) ;
1591 SectRgn( ownUpdateRgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn
) ;
1593 // newupdate is the update region in client coordinates
1594 RgnHandle newupdate
= NewRgn() ;
1595 wxSize point
= GetClientSize() ;
1596 wxPoint origin
= GetClientAreaOrigin() ;
1597 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1598 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1599 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1600 m_updateRegion
= newupdate
;
1601 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1603 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1605 wxWindowDC
dc(this);
1606 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1607 wxEraseEvent
eevent( GetId(), &dc
);
1608 eevent
.SetEventObject( this );
1609 GetEventHandler()->ProcessEvent( eevent
);
1611 wxNcPaintEvent
eventNc( GetId() );
1612 eventNc
.SetEventObject( this );
1613 GetEventHandler()->ProcessEvent( eventNc
);
1615 DisposeRgn( ownUpdateRgn
) ;
1616 if ( !m_updateRegion
.Empty() )
1619 event
.m_timeStamp
= time
;
1620 event
.SetEventObject(this);
1621 GetEventHandler()->ProcessEvent(event
);
1625 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1627 RgnHandle childupdate
= NewRgn() ;
1628 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1630 // calculate the update region for the child windows by intersecting the window rectangle with our own
1631 // passed in update region and then offset it to be client-wise window coordinates again
1632 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1633 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1634 SectRgn( childupdate
, updatergn
, childupdate
) ;
1635 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1636 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1638 // because dialogs may also be children
1639 child
->MacRedraw( childupdate
, time
, erase
) ;
1642 DisposeRgn( childupdate
) ;
1643 // eventually a draw grow box here
1647 WXHWND
wxWindowMac::MacGetRootWindow() const
1649 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1653 if ( iter
->IsTopLevel() )
1654 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1656 iter
= iter
->GetParent() ;
1658 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1662 void wxWindowMac::MacCreateScrollBars( long style
)
1664 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1666 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1667 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1669 GetClientSize( &width
, &height
) ;
1671 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1672 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1673 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1674 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1676 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1677 vSize
, wxVERTICAL
);
1679 if ( style
& wxVSCROLL
)
1685 m_vScrollBar
->Show(false) ;
1687 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1688 hSize
, wxHORIZONTAL
);
1689 if ( style
& wxHSCROLL
)
1694 m_hScrollBar
->Show(false) ;
1697 // because the create does not take into account the client area origin
1698 MacRepositionScrollBars() ; // we might have a real position shift
1701 void wxWindowMac::MacRepositionScrollBars()
1703 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1704 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1706 // get real client area
1708 int width
= m_width
;
1709 int height
= m_height
;
1711 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1712 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1714 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1715 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1716 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1717 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1724 MacClientToRootWindow( &x
, &y
) ;
1725 MacClientToRootWindow( &w
, &h
) ;
1727 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1729 int totW
= 10000 , totH
= 10000;
1732 if ( iter
->IsTopLevel() )
1734 totW
= iter
->m_width
;
1735 totH
= iter
->m_height
;
1739 iter
= iter
->GetParent() ;
1767 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1771 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1775 bool wxWindowMac::AcceptsFocus() const
1777 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1780 WXWidget
wxWindowMac::MacGetContainerForEmbedding()
1782 return GetParent()->MacGetContainerForEmbedding() ;
1785 void wxWindowMac::MacSuperChangedPosition()
1787 // only window-absolute structures have to be moved i.e. controls
1789 wxNode
*node
= GetChildren().First();
1792 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1793 child
->MacSuperChangedPosition() ;
1794 node
= node
->Next();
1798 void wxWindowMac::MacTopLevelWindowChangedPosition()
1800 // only screen-absolute structures have to be moved i.e. glcanvas
1802 wxNode
*node
= GetChildren().First();
1805 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1806 child
->MacTopLevelWindowChangedPosition() ;
1807 node
= node
->Next();
1810 long wxWindowMac::MacGetLeftBorderSize( ) const
1815 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1818 #if wxMAC_USE_THEME_BORDER
1820 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1825 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1828 #if wxMAC_USE_THEME_BORDER
1830 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1835 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1842 long wxWindowMac::MacGetRightBorderSize( ) const
1844 // they are all symmetric in mac themes
1845 return MacGetLeftBorderSize() ;
1848 long wxWindowMac::MacGetTopBorderSize( ) const
1850 // they are all symmetric in mac themes
1851 return MacGetLeftBorderSize() ;
1854 long wxWindowMac::MacGetBottomBorderSize( ) const
1856 // they are all symmetric in mac themes
1857 return MacGetLeftBorderSize() ;
1860 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1862 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1865 // Find the wxWindowMac at the current mouse position, returning the mouse
1867 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1869 pt
= wxGetMousePosition();
1870 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1874 // Get the current mouse position.
1875 wxPoint
wxGetMousePosition()
1878 wxGetMousePosition(& x
, & y
);
1879 return wxPoint(x
, y
);