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 #ifndef __WXUNIVERSAL__
152 // VS: make sure there's no wxFrame with last focus set to us:
153 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
155 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
158 if ( frame
->GetLastFocus() == this )
160 frame
->SetLastFocus((wxWindow
*)NULL
);
165 #endif // __WXUNIVERSAL__
167 if ( s_lastMouseWindow
== this )
169 s_lastMouseWindow
= NULL
;
172 if ( gFocusWindow
== this )
174 gFocusWindow
= NULL
;
178 m_parent
->RemoveChild(this);
184 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
188 const wxString
& name
)
190 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
192 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
195 parent
->AddChild(this);
199 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
200 m_width
= WidthDefault( size
.x
);
201 m_height
= HeightDefault( size
.y
) ;
202 #ifndef __WXUNIVERSAL__
203 if ( ! IsKindOf( CLASSINFO ( wxControl
) ) && ! IsKindOf( CLASSINFO( wxStatusBar
) ) )
205 MacCreateScrollBars( style
) ;
211 void wxWindowMac::SetFocus()
213 if ( gFocusWindow
== this )
216 if ( AcceptsFocus() )
222 if ( gFocusWindow
->m_caret
)
224 gFocusWindow
->m_caret
->OnKillFocus();
226 #endif // wxUSE_CARET
227 #ifndef __WXUNIVERSAL__
228 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
229 if ( control
&& control
->GetMacControl() )
231 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNoPart
) ;
232 control
->MacRedrawControl() ;
235 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
236 event
.SetEventObject(gFocusWindow
);
237 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
239 gFocusWindow
= this ;
245 m_caret
->OnSetFocus();
247 #endif // wxUSE_CARET
248 // panel wants to track the window which was the last to have focus in it
249 wxChildFocusEvent
eventFocus(this);
250 GetEventHandler()->ProcessEvent(eventFocus
);
252 #ifndef __WXUNIVERSAL__
253 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
254 if ( control
&& control
->GetMacControl() )
256 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNextPart
) ;
259 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
260 event
.SetEventObject(this);
261 GetEventHandler()->ProcessEvent(event
) ;
266 bool wxWindowMac::Enable(bool enable
)
268 if ( !wxWindowBase::Enable(enable
) )
271 MacSuperEnabled( enable
) ;
276 void wxWindowMac::DoCaptureMouse()
278 wxTheApp
->s_captureWindow
= this ;
281 wxWindow
* wxWindowBase::GetCapture()
283 return wxTheApp
->s_captureWindow
;
286 void wxWindowMac::DoReleaseMouse()
288 wxTheApp
->s_captureWindow
= NULL
;
291 #if wxUSE_DRAG_AND_DROP
293 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
295 if ( m_dropTarget
!= 0 ) {
299 m_dropTarget
= pDropTarget
;
300 if ( m_dropTarget
!= 0 )
308 // Old style file-manager drag&drop
309 void wxWindowMac::DragAcceptFiles(bool accept
)
315 void wxWindowMac::DoGetSize(int *x
, int *y
) const
318 if(y
) *y
= m_height
;
321 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
327 if ( !IsTopLevel() && GetParent())
329 wxPoint
pt(GetParent()->GetClientAreaOrigin());
338 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
340 menu
->SetInvokingWindow(this);
342 ClientToScreen( &x
, &y
) ;
344 ::InsertMenu( (MenuHandle
) menu
->GetHMenu() , -1 ) ;
345 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
346 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
347 ::DeleteMenu( menu
->MacGetMenuId() ) ;
348 menu
->SetInvokingWindow(NULL
);
354 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
356 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
358 Point localwhere
= {0,0} ;
360 if(x
) localwhere
.h
= * x
;
361 if(y
) localwhere
.v
= * y
;
365 ::SetPort( UMAGetWindowPort( window
) ) ;
366 ::GlobalToLocal( &localwhere
) ;
369 if(x
) *x
= localwhere
.h
;
370 if(y
) *y
= localwhere
.v
;
372 MacRootWindowToWindow( x
, y
) ;
374 x
-= MacGetLeftBorderSize() ;
376 y
-= MacGetTopBorderSize() ;
379 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
381 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
384 x
+= MacGetLeftBorderSize() ;
386 y
+= MacGetTopBorderSize() ;
388 MacWindowToRootWindow( x
, y
) ;
390 Point localwhere
= { 0,0 };
391 if(x
) localwhere
.h
= * x
;
392 if(y
) localwhere
.v
= * y
;
396 ::SetPort( UMAGetWindowPort( window
) ) ;
398 ::LocalToGlobal( &localwhere
) ;
400 if(x
) *x
= localwhere
.h
;
401 if(y
) *y
= localwhere
.v
;
404 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
406 wxPoint origin
= GetClientAreaOrigin() ;
407 if(x
) *x
+= origin
.x
;
408 if(y
) *y
+= origin
.y
;
410 MacWindowToRootWindow( x
, y
) ;
413 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
415 wxPoint origin
= GetClientAreaOrigin() ;
416 MacRootWindowToWindow( x
, y
) ;
417 if(x
) *x
-= origin
.x
;
418 if(y
) *y
-= origin
.y
;
421 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
427 GetParent()->MacWindowToRootWindow( x
, y
) ;
431 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
437 GetParent()->MacRootWindowToWindow( x
, y
) ;
441 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
443 if (m_cursor
== cursor
)
446 if (wxNullCursor
== cursor
)
448 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
453 if ( ! wxWindowBase::SetCursor( cursor
) )
457 wxASSERT_MSG( m_cursor
.Ok(),
458 wxT("cursor must be valid after call to the base version"));
461 wxWindowMac
*mouseWin
;
464 // Change the cursor NOW if we're within the correct window
466 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
468 if ( mouseWin
== this && !wxIsBusy() )
470 m_cursor
.MacInstall() ;
478 // Get size *available for subwindows* i.e. excluding menu bar etc.
479 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
485 ww
-= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
486 hh
-= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
488 if ( (m_vScrollBar
&& m_vScrollBar
->IsShown()) || (m_hScrollBar
&& m_hScrollBar
->IsShown()) )
495 MacClientToRootWindow( &x1
, &y1
) ;
496 MacClientToRootWindow( &w
, &h
) ;
498 wxWindowMac
*iter
= (wxWindowMac
*)this ;
500 int totW
= 10000 , totH
= 10000;
503 if ( iter
->IsTopLevel() )
505 totW
= iter
->m_width
;
506 totH
= iter
->m_height
;
510 iter
= iter
->GetParent() ;
513 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
515 hh
-= MAC_SCROLLBAR_SIZE
;
521 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
523 ww
-= MAC_SCROLLBAR_SIZE
;
535 // ----------------------------------------------------------------------------
537 // ----------------------------------------------------------------------------
541 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
543 wxWindowBase::DoSetToolTip(tooltip
);
546 m_tooltip
->SetWindow(this);
549 #endif // wxUSE_TOOLTIPS
551 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
555 int former_w
= m_width
;
556 int former_h
= m_height
;
558 int actualWidth
= width
;
559 int actualHeight
= height
;
563 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
564 actualWidth
= m_minWidth
;
565 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
566 actualHeight
= m_minHeight
;
567 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
568 actualWidth
= m_maxWidth
;
569 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
570 actualHeight
= m_maxHeight
;
572 bool doMove
= false ;
573 bool doResize
= false ;
575 if ( actualX
!= former_x
|| actualY
!= former_y
)
579 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
584 if ( doMove
|| doResize
)
586 // erase former position
592 m_width
= actualWidth
;
593 m_height
= actualHeight
;
595 // erase new position
599 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
601 MacRepositionScrollBars() ;
604 wxPoint
point(m_x
, m_y
);
605 wxMoveEvent
event(point
, m_windowId
);
606 event
.SetEventObject(this);
607 GetEventHandler()->ProcessEvent(event
) ;
611 MacRepositionScrollBars() ;
612 wxSize
size(m_width
, m_height
);
613 wxSizeEvent
event(size
, m_windowId
);
614 event
.SetEventObject(this);
615 GetEventHandler()->ProcessEvent(event
);
621 // set the size of the window: if the dimensions are positive, just use them,
622 // but if any of them is equal to -1, it means that we must find the value for
623 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
624 // which case -1 is a valid value for x and y)
626 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
627 // the width/height to best suit our contents, otherwise we reuse the current
629 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
631 // get the current size and position...
632 int currentX
, currentY
;
633 GetPosition(¤tX
, ¤tY
);
635 int currentW
,currentH
;
636 GetSize(¤tW
, ¤tH
);
638 // ... and don't do anything (avoiding flicker) if it's already ok
639 if ( x
== currentX
&& y
== currentY
&&
640 width
== currentW
&& height
== currentH
)
642 MacRepositionScrollBars() ; // we might have a real position shift
646 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
648 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
651 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
656 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
658 size
= DoGetBestSize();
663 // just take the current one
670 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
674 size
= DoGetBestSize();
676 //else: already called DoGetBestSize() above
682 // just take the current one
687 DoMoveWindow(x
, y
, width
, height
);
690 // For implementation purposes - sometimes decorations make the client area
693 wxPoint
wxWindowMac::GetClientAreaOrigin() const
695 return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
698 void wxWindowMac::SetTitle(const wxString
& title
)
703 wxString
wxWindowMac::GetTitle() const
708 bool wxWindowMac::Show(bool show
)
710 if ( !wxWindowBase::Show(show
) )
714 WindowRef window = (WindowRef) MacGetRootWindow() ;
715 wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
716 if ( win == NULL && win->m_isBeingDeleted )
719 MacSuperShown( show
) ;
724 if ( win && !win->m_isBeingDeleted )
735 void wxWindowMac::MacSuperShown( bool show
)
737 wxNode
*node
= GetChildren().First();
740 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
741 if ( child
->m_isShown
)
742 child
->MacSuperShown( show
) ;
747 void wxWindowMac::MacSuperEnabled( bool enabled
)
751 // to be absolutely correct we'd have to invalidate (with eraseBkground
752 // because unter MacOSX the frames are drawn with an addXXX mode)
755 wxNode
*node
= GetChildren().First();
758 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
759 if ( child
->m_isShown
)
760 child
->MacSuperEnabled( enabled
) ;
765 bool wxWindowMac::MacIsReallyShown() const
767 if ( m_isShown
&& (m_parent
!= NULL
) ) {
768 return m_parent
->MacIsReallyShown();
772 bool status = m_isShown ;
773 wxWindowMac * win = this ;
774 while ( status && win->m_parent != NULL )
776 win = win->m_parent ;
777 status = win->m_isShown ;
783 int wxWindowMac::GetCharHeight() const
785 wxClientDC
dc ( (wxWindowMac
*)this ) ;
786 return dc
.GetCharHeight() ;
789 int wxWindowMac::GetCharWidth() const
791 wxClientDC
dc ( (wxWindowMac
*)this ) ;
792 return dc
.GetCharWidth() ;
795 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
796 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
798 const wxFont
*fontToUse
= theFont
;
802 wxClientDC
dc( (wxWindowMac
*) this ) ;
804 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
805 if ( externalLeading
)
806 *externalLeading
= le
;
816 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
817 * we always intersect with the entire window, not only with the client area
820 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
822 if ( MacGetTopLevelWindow() == NULL
)
825 wxPoint client
= GetClientAreaOrigin();
828 int x2
= m_width
- client
.x
;
829 int y2
= m_height
- client
.y
;
831 if (IsKindOf( CLASSINFO(wxButton
)))
833 // buttons have an "aura"
840 Rect clientrect
= { y1
, x1
, y2
, x2
};
844 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
845 SectRect( &clientrect
, &r
, &clientrect
) ;
848 if ( !EmptyRect( &clientrect
) )
850 int top
= 0 , left
= 0 ;
852 MacClientToRootWindow( &left
, &top
) ;
853 OffsetRect( &clientrect
, left
, top
) ;
855 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
859 #if wxUSE_CARET && WXWIN_COMPATIBILITY
860 // ---------------------------------------------------------------------------
861 // Caret manipulation
862 // ---------------------------------------------------------------------------
864 void wxWindowMac::CreateCaret(int w
, int h
)
866 SetCaret(new wxCaret(this, w
, h
));
869 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
871 wxFAIL_MSG("not implemented");
874 void wxWindowMac::ShowCaret(bool show
)
876 wxCHECK_RET( m_caret
, "no caret to show" );
881 void wxWindowMac::DestroyCaret()
886 void wxWindowMac::SetCaretPos(int x
, int y
)
888 wxCHECK_RET( m_caret
, "no caret to move" );
893 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
895 wxCHECK_RET( m_caret
, "no caret to get position of" );
897 m_caret
->GetPosition(x
, y
);
899 #endif // wxUSE_CARET
901 wxWindowMac
*wxGetActiveWindow()
903 // actually this is a windows-only concept
907 // Coordinates relative to the window
908 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
910 // We really dont move the mouse programmatically under mac
913 const wxBrush
& wxWindowMac::MacGetBackgroundBrush()
915 if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
917 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDocumentWindowBackground
) ;
919 else if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) )
921 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
922 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
923 // either a non gray background color or a non control window
925 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
927 wxWindowMac
* parent
= GetParent() ;
930 if ( parent
->MacGetRootWindow() != window
)
932 // we are in a different window on the mac system
938 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
)
939 && parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
941 // if we have any other colours in the hierarchy
942 m_macBackgroundBrush
.SetColour( parent
->m_backgroundColour
) ;
945 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
946 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
948 Rect extent
= { 0 , 0 , 0 , 0 } ;
951 wxSize size
= parent
->GetSize() ;
952 parent
->MacClientToRootWindow( &x
, &y
) ;
956 extent
.right
= x
+ size
.x
;
957 extent
.bottom
= y
+ size
.y
;
958 m_macBackgroundBrush
.SetMacThemeBackground( kThemeBackgroundTabPane
, (WXRECTPTR
) &extent
) ; // todo eventually change for inactive
962 parent
= parent
->GetParent() ;
966 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDialogBackgroundActive
) ; // todo eventually change for inactive
971 m_macBackgroundBrush
.SetColour( m_backgroundColour
) ;
974 return m_macBackgroundBrush
;
978 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
980 event
.GetDC()->Clear() ;
983 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
985 wxWindowDC
dc(this) ;
986 wxMacPortSetter
helper(&dc
) ;
988 MacPaintBorders( dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
991 int wxWindowMac::GetScrollPos(int orient
) const
993 if ( orient
== wxHORIZONTAL
)
996 return m_hScrollBar
->GetThumbPosition() ;
1001 return m_vScrollBar
->GetThumbPosition() ;
1006 // This now returns the whole range, not just the number
1007 // of positions that we can scroll.
1008 int wxWindowMac::GetScrollRange(int orient
) const
1010 if ( orient
== wxHORIZONTAL
)
1013 return m_hScrollBar
->GetRange() ;
1018 return m_vScrollBar
->GetRange() ;
1023 int wxWindowMac::GetScrollThumb(int orient
) const
1025 if ( orient
== wxHORIZONTAL
)
1028 return m_hScrollBar
->GetThumbSize() ;
1033 return m_vScrollBar
->GetThumbSize() ;
1038 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
1040 if ( orient
== wxHORIZONTAL
)
1043 m_hScrollBar
->SetThumbPosition( pos
) ;
1048 m_vScrollBar
->SetThumbPosition( pos
) ;
1052 void wxWindowMac::MacPaintBorders( int left
, int top
)
1057 RGBColor white
= { 0xFFFF, 0xFFFF , 0xFFFF } ;
1058 RGBColor black
= { 0x0000, 0x0000 , 0x0000 } ;
1059 RGBColor face
= { 0xDDDD, 0xDDDD , 0xDDDD } ;
1060 RGBColor shadow
= { 0x4444, 0x4444 , 0x4444 } ;
1063 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
1065 #if wxMAC_USE_THEME_BORDER
1066 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1069 GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
1070 InsetRect( &rect , border , border );
1071 DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
1074 DrawThemePrimaryGroup(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
1076 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
1077 RGBForeColor( &face
);
1078 MoveTo( left
+ 0 , top
+ m_height
- 2 );
1079 LineTo( left
+ 0 , top
+ 0 );
1080 LineTo( left
+ m_width
- 2 , top
+ 0 );
1082 MoveTo( left
+ 2 , top
+ m_height
- 3 );
1083 LineTo( left
+ m_width
- 3 , top
+ m_height
- 3 );
1084 LineTo( left
+ m_width
- 3 , top
+ 2 );
1086 RGBForeColor( sunken
? &face
: &black
);
1087 MoveTo( left
+ 0 , top
+ m_height
- 1 );
1088 LineTo( left
+ m_width
- 1 , top
+ m_height
- 1 );
1089 LineTo( left
+ m_width
- 1 , top
+ 0 );
1091 RGBForeColor( sunken
? &shadow
: &white
);
1092 MoveTo( left
+ 1 , top
+ m_height
- 3 );
1093 LineTo( left
+ 1, top
+ 1 );
1094 LineTo( left
+ m_width
- 3 , top
+ 1 );
1096 RGBForeColor( sunken
? &white
: &shadow
);
1097 MoveTo( left
+ 1 , top
+ m_height
- 2 );
1098 LineTo( left
+ m_width
- 2 , top
+ m_height
- 2 );
1099 LineTo( left
+ m_width
- 2 , top
+ 1 );
1101 RGBForeColor( sunken
? &black
: &face
);
1102 MoveTo( left
+ 2 , top
+ m_height
- 4 );
1103 LineTo( left
+ 2 , top
+ 2 );
1104 LineTo( left
+ m_width
- 4 , top
+ 2 );
1107 else if (HasFlag(wxSIMPLE_BORDER
))
1109 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1110 RGBForeColor( &black
) ;
1111 FrameRect( &rect
) ;
1115 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
1117 if ( child
== m_hScrollBar
)
1118 m_hScrollBar
= NULL
;
1119 if ( child
== m_vScrollBar
)
1120 m_vScrollBar
= NULL
;
1122 wxWindowBase::RemoveChild( child
) ;
1125 // New function that will replace some of the above.
1126 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
1127 int range
, bool refresh
)
1129 if ( orient
== wxHORIZONTAL
)
1133 if ( range
== 0 || thumbVisible
>= range
)
1135 if ( m_hScrollBar
->IsShown() )
1136 m_hScrollBar
->Show(false) ;
1140 if ( !m_hScrollBar
->IsShown() )
1141 m_hScrollBar
->Show(true) ;
1142 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1150 if ( range
== 0 || thumbVisible
>= range
)
1152 if ( m_vScrollBar
->IsShown() )
1153 m_vScrollBar
->Show(false) ;
1157 if ( !m_vScrollBar
->IsShown() )
1158 m_vScrollBar
->Show(true) ;
1159 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1163 MacRepositionScrollBars() ;
1166 // Does a physical scroll
1167 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1169 wxClientDC
dc(this) ;
1170 wxMacPortSetter
helper(&dc
) ;
1173 int width
, height
;
1174 GetClientSize( &width
, &height
) ;
1176 Rect scrollrect
= { dc
.YLOG2DEVMAC(0) , dc
.XLOG2DEVMAC(0) , dc
.YLOG2DEVMAC(height
) , dc
.XLOG2DEVMAC(width
) } ;
1177 RgnHandle updateRgn
= NewRgn() ;
1178 ClipRect( &scrollrect
) ;
1181 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
1182 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
1183 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1185 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1186 InvalWindowRgn( (WindowRef
) MacGetRootWindow() , updateRgn
) ;
1187 DisposeRgn( updateRgn
) ;
1190 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1192 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1193 if (child
== m_vScrollBar
) continue;
1194 if (child
== m_hScrollBar
) continue;
1195 if (child
->IsTopLevel()) continue;
1197 child
->GetPosition( &x
, &y
);
1199 child
->GetSize( &w
, &h
);
1200 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1205 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1207 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1209 wxScrollWinEvent wevent
;
1210 wevent
.SetPosition(event
.GetPosition());
1211 wevent
.SetOrientation(event
.GetOrientation());
1212 wevent
.m_eventObject
= this;
1214 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1215 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1217 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1218 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1220 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1221 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1223 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1224 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1226 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1227 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1229 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1230 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1232 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1233 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1236 GetEventHandler()->ProcessEvent(wevent
);
1240 // Get the window with the focus
1241 wxWindowMac
*wxWindowBase::FindFocus()
1243 return gFocusWindow
;
1246 #if WXWIN_COMPATIBILITY
1247 // If nothing defined for this, try the parent.
1248 // E.g. we may be a button loaded from a resource, with no callback function
1250 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1252 if ( GetEventHandler()->ProcessEvent(event
) )
1255 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1257 #endif // WXWIN_COMPATIBILITY_2
1259 #if WXWIN_COMPATIBILITY
1260 wxObject
* wxWindowMac::GetChild(int number
) const
1262 // Return a pointer to the Nth object in the Panel
1263 wxNode
*node
= GetChildren().First();
1266 node
= node
->Next();
1269 wxObject
*obj
= (wxObject
*)node
->Data();
1275 #endif // WXWIN_COMPATIBILITY
1277 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1279 // panel wants to track the window which was the last to have focus in it,
1280 // so we want to set ourselves as the window which last had focus
1282 // notice that it's also important to do it upwards the tree becaus
1283 // otherwise when the top level panel gets focus, it won't set it back to
1284 // us, but to some other sibling
1286 // CS:don't know if this is still needed:
1287 //wxChildFocusEvent eventFocus(this);
1288 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1293 void wxWindowMac::Clear()
1295 wxClientDC
dc(this);
1296 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1297 dc
.SetBackground(brush
);
1301 // Setup background and foreground colours correctly
1302 void wxWindowMac::SetupColours()
1305 SetBackgroundColour(GetParent()->GetBackgroundColour());
1308 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1311 // Check if we need to send a LEAVE event
1312 if (m_mouseInWindow)
1315 ::GetCursorPos(&pt);
1316 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1318 // Generate a LEAVE event
1319 m_mouseInWindow = FALSE;
1320 MSWOnMouseLeave(pt.x, pt.y, 0);
1325 // This calls the UI-update mechanism (querying windows for
1326 // menu/toolbar/control state information)
1330 // Raise the window to the top of the Z order
1331 void wxWindowMac::Raise()
1335 // Lower the window to the bottom of the Z order
1336 void wxWindowMac::Lower()
1340 void wxWindowMac::DoSetClientSize(int width
, int height
)
1342 if ( width
!= -1 || height
!= -1 )
1345 if ( width
!= -1 && m_vScrollBar
)
1346 width
+= MAC_SCROLLBAR_SIZE
;
1347 if ( height
!= -1 && m_vScrollBar
)
1348 height
+= MAC_SCROLLBAR_SIZE
;
1350 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1351 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1353 DoSetSize( -1 , -1 , width
, height
) ;
1358 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1360 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1364 if ((point
.x
< 0) || (point
.y
< 0) ||
1365 (point
.x
> (m_width
)) || (point
.y
> (m_height
)))
1370 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1371 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1375 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1377 wxPoint
newPoint( point
) ;
1379 if ( !IsTopLevel() )
1385 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1387 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1388 // added the m_isShown test --dmazzoni
1389 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1391 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1400 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1404 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1405 if ( ::FindWindow( pt
, &window
) == 3 )
1408 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1411 // No, this yields the CLIENT are, we need the whole frame. RR.
1412 // point = win->ScreenToClient( point ) ;
1415 ::GetPort( &port
) ;
1416 ::SetPort( UMAGetWindowPort( window
) ) ;
1417 ::GlobalToLocal( &pt
) ;
1420 wxPoint
point( pt
.h
, pt
.v
) ;
1422 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1428 extern int wxBusyCursorCount
;
1429 static wxWindow
*gs_lastWhich
= NULL
;
1431 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1433 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1434 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1438 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) || IsKindOf( CLASSINFO( wxSpinCtrl
) ))
1441 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1449 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1451 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1452 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1454 if (child
->MacDispatchMouseEvent(event
))
1461 event
.SetEventObject( this ) ;
1463 if ( wxBusyCursorCount
== 0 )
1465 m_cursor
.MacInstall() ;
1468 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1470 // set focus to this window
1471 if (AcceptsFocus() && FindFocus()!=this)
1476 if ( event
.GetEventType() == wxEVT_MOTION
1477 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1478 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1479 wxToolTip::RelayEvent( this , event
);
1480 #endif // wxUSE_TOOLTIPS
1482 if (gs_lastWhich
!= this)
1484 gs_lastWhich
= this;
1486 // Double clicks must always occur on the same window
1487 if (event
.GetEventType() == wxEVT_LEFT_DCLICK
)
1488 event
.SetEventType( wxEVT_LEFT_DOWN
);
1489 if (event
.GetEventType() == wxEVT_RIGHT_DCLICK
)
1490 event
.SetEventType( wxEVT_RIGHT_DOWN
);
1492 // Same for mouse up events
1493 if (event
.GetEventType() == wxEVT_LEFT_UP
)
1495 if (event
.GetEventType() == wxEVT_RIGHT_UP
)
1499 GetEventHandler()->ProcessEvent( event
) ;
1504 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1508 return m_tooltip
->GetTip() ;
1513 void wxWindowMac::Update()
1515 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1518 win
->MacUpdate( 0 ) ;
1519 #if TARGET_API_MAC_CARBON
1520 if ( QDIsPortBuffered( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) ) )
1522 QDFlushPortBuffer( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) , NULL
) ;
1528 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1530 wxTopLevelWindowMac
* win
= NULL
;
1531 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1534 win
= wxFindWinFromMacWindow( window
) ;
1539 const wxRegion
& wxWindowMac::MacGetVisibleRegion()
1541 RgnHandle visRgn
= NewRgn() ;
1542 RgnHandle tempRgn
= NewRgn() ;
1544 SetRectRgn( visRgn
, 0 , 0 , m_width
, m_height
) ;
1546 //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
1547 if ( IsKindOf( CLASSINFO( wxStaticBox
) ) )
1549 int borderTop
= 14 ;
1550 int borderOther
= 4 ;
1552 SetRectRgn( tempRgn
, borderOther
, borderTop
, m_width
- borderOther
, m_height
- borderOther
) ;
1553 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1556 if ( !IsTopLevel() )
1558 wxWindow
* parent
= GetParent() ;
1561 wxSize size
= parent
->GetSize() ;
1564 parent
->MacWindowToRootWindow( &x
, &y
) ;
1565 MacRootWindowToWindow( &x
, &y
) ;
1566 SetRectRgn( tempRgn
, x
, y
, x
+ size
.x
, y
+ size
.y
) ;
1567 SectRgn( visRgn
, tempRgn
, visRgn
) ;
1568 if ( parent
->IsTopLevel() )
1570 parent
= parent
->GetParent() ;
1573 if ( GetWindowStyle() & wxCLIP_CHILDREN
)
1575 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1577 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1579 if ( !child
->IsTopLevel() && child
->IsShown() )
1581 SetRectRgn( tempRgn
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1582 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1587 if ( (GetWindowStyle() & wxCLIP_SIBLINGS
) && GetParent() )
1589 bool thisWindowThrough
= false ;
1590 for (wxNode
*node
= GetParent()->GetChildren().First(); node
; node
= node
->Next())
1592 wxWindowMac
*sibling
= (wxWindowMac
*)node
->Data();
1593 if ( sibling
== this )
1595 thisWindowThrough
= true ;
1598 if( !thisWindowThrough
)
1603 if ( !sibling
->IsTopLevel() && sibling
->IsShown() )
1605 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
) ;
1606 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1610 m_macVisibleRegion
= visRgn
;
1611 DisposeRgn( visRgn
) ;
1612 DisposeRgn( tempRgn
) ;
1613 return m_macVisibleRegion
;
1616 void wxWindowMac::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
1618 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
1619 // updatergn is always already clipped to our boundaries
1620 // it is in window coordinates, not in client coordinates
1622 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1625 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
1626 RgnHandle ownUpdateRgn
= NewRgn() ;
1627 CopyRgn( updatergn
, ownUpdateRgn
) ;
1629 SectRgn( ownUpdateRgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn
) ;
1631 // newupdate is the update region in client coordinates
1632 RgnHandle newupdate
= NewRgn() ;
1633 wxSize point
= GetClientSize() ;
1634 wxPoint origin
= GetClientAreaOrigin() ;
1635 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1636 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1637 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1638 m_updateRegion
= newupdate
;
1639 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1641 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1643 wxWindowDC
dc(this);
1644 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1645 wxEraseEvent
eevent( GetId(), &dc
);
1646 eevent
.SetEventObject( this );
1647 GetEventHandler()->ProcessEvent( eevent
);
1649 wxNcPaintEvent
eventNc( GetId() );
1650 eventNc
.SetEventObject( this );
1651 GetEventHandler()->ProcessEvent( eventNc
);
1653 DisposeRgn( ownUpdateRgn
) ;
1654 if ( !m_updateRegion
.Empty() )
1657 event
.m_timeStamp
= time
;
1658 event
.SetEventObject(this);
1659 GetEventHandler()->ProcessEvent(event
);
1663 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1665 RgnHandle childupdate
= NewRgn() ;
1666 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1668 // calculate the update region for the child windows by intersecting the window rectangle with our own
1669 // passed in update region and then offset it to be client-wise window coordinates again
1670 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1671 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1672 SectRgn( childupdate
, updatergn
, childupdate
) ;
1673 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1674 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1676 // because dialogs may also be children
1677 child
->MacRedraw( childupdate
, time
, erase
) ;
1680 DisposeRgn( childupdate
) ;
1681 // eventually a draw grow box here
1685 WXHWND
wxWindowMac::MacGetRootWindow() const
1687 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1691 if ( iter
->IsTopLevel() )
1692 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1694 iter
= iter
->GetParent() ;
1696 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1700 void wxWindowMac::MacCreateScrollBars( long style
)
1702 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1704 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1705 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1707 GetClientSize( &width
, &height
) ;
1709 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1710 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1711 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1712 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1714 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1715 vSize
, wxVERTICAL
);
1717 if ( style
& wxVSCROLL
)
1723 m_vScrollBar
->Show(false) ;
1725 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1726 hSize
, wxHORIZONTAL
);
1727 if ( style
& wxHSCROLL
)
1732 m_hScrollBar
->Show(false) ;
1735 // because the create does not take into account the client area origin
1736 MacRepositionScrollBars() ; // we might have a real position shift
1739 void wxWindowMac::MacRepositionScrollBars()
1741 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1742 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1744 // get real client area
1746 int width
= m_width
;
1747 int height
= m_height
;
1749 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1750 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1752 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1753 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1754 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1755 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1762 MacClientToRootWindow( &x
, &y
) ;
1763 MacClientToRootWindow( &w
, &h
) ;
1765 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1767 int totW
= 10000 , totH
= 10000;
1770 if ( iter
->IsTopLevel() )
1772 totW
= iter
->m_width
;
1773 totH
= iter
->m_height
;
1777 iter
= iter
->GetParent() ;
1805 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1809 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1813 bool wxWindowMac::AcceptsFocus() const
1815 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1818 WXWidget
wxWindowMac::MacGetContainerForEmbedding()
1820 return GetParent()->MacGetContainerForEmbedding() ;
1823 void wxWindowMac::MacSuperChangedPosition()
1825 // only window-absolute structures have to be moved i.e. controls
1827 wxNode
*node
= GetChildren().First();
1830 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1831 child
->MacSuperChangedPosition() ;
1832 node
= node
->Next();
1836 void wxWindowMac::MacTopLevelWindowChangedPosition()
1838 // only screen-absolute structures have to be moved i.e. glcanvas
1840 wxNode
*node
= GetChildren().First();
1843 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1844 child
->MacTopLevelWindowChangedPosition() ;
1845 node
= node
->Next();
1848 long wxWindowMac::MacGetLeftBorderSize( ) const
1853 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1856 #if wxMAC_USE_THEME_BORDER
1858 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1863 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1866 #if wxMAC_USE_THEME_BORDER
1868 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1873 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1880 long wxWindowMac::MacGetRightBorderSize( ) const
1882 // they are all symmetric in mac themes
1883 return MacGetLeftBorderSize() ;
1886 long wxWindowMac::MacGetTopBorderSize( ) const
1888 // they are all symmetric in mac themes
1889 return MacGetLeftBorderSize() ;
1892 long wxWindowMac::MacGetBottomBorderSize( ) const
1894 // they are all symmetric in mac themes
1895 return MacGetLeftBorderSize() ;
1898 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1900 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1903 // Find the wxWindowMac at the current mouse position, returning the mouse
1905 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1907 pt
= wxGetMousePosition();
1908 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1912 // Get the current mouse position.
1913 wxPoint
wxGetMousePosition()
1916 wxGetMousePosition(& x
, & y
);
1917 return wxPoint(x
, y
);