1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowMac
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
18 #include "wx/window.h"
20 #include "wx/dcclient.h"
24 #include "wx/layout.h"
25 #include "wx/dialog.h"
26 #include "wx/listbox.h"
27 #include "wx/scrolbar.h"
28 #include "wx/statbox.h"
29 #include "wx/button.h"
30 #include "wx/settings.h"
31 #include "wx/msgdlg.h"
33 #include "wx/notebook.h"
34 #include "wx/tabctrl.h"
35 #include "wx/tooltip.h"
36 #include "wx/statusbr.h"
37 #include "wx/menuitem.h"
44 #define wxWINDOW_HSCROLL 5998
45 #define wxWINDOW_VSCROLL 5997
46 #define MAC_SCROLLBAR_SIZE 16
48 #include "wx/mac/uma.h"
51 #include <ToolUtils.h>
54 #if wxUSE_DRAG_AND_DROP
60 extern wxList wxPendingDelete
;
61 wxWindowMac
* gFocusWindow
= NULL
;
63 #ifdef __WXUNIVERSAL__
64 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
66 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
67 #endif // __WXUNIVERSAL__/__WXMAC__
69 #if !USE_SHARED_LIBRARY
71 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
72 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
73 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
74 EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged
)
75 EVT_INIT_DIALOG(wxWindowMac::OnInitDialog
)
76 EVT_IDLE(wxWindowMac::OnIdle
)
77 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
82 #define wxMAC_DEBUG_REDRAW 0
83 #ifndef wxMAC_DEBUG_REDRAW
84 #define wxMAC_DEBUG_REDRAW 0
87 #define wxMAC_USE_THEME_BORDER 0
90 // ===========================================================================
92 // ===========================================================================
95 // ----------------------------------------------------------------------------
96 // constructors and such
97 // ----------------------------------------------------------------------------
99 void wxWindowMac::Init()
105 m_doubleClickAllowed
= 0;
106 m_winCaptured
= FALSE
;
108 m_isBeingDeleted
= FALSE
;
111 m_mouseInWindow
= FALSE
;
115 m_backgroundTransparent
= FALSE
;
117 // as all windows are created with WS_VISIBLE style...
125 m_hScrollBar
= NULL
;
126 m_vScrollBar
= NULL
;
130 wxWindowMac::~wxWindowMac()
132 // deleting a window while it is shown invalidates the region
134 wxWindowMac
* iter
= this ;
136 if ( iter
->IsTopLevel() )
141 iter
= iter
->GetParent() ;
146 m_isBeingDeleted
= TRUE
;
148 if ( s_lastMouseWindow
== this )
150 s_lastMouseWindow
= NULL
;
153 if ( gFocusWindow
== this )
155 gFocusWindow
= NULL
;
159 m_parent
->RemoveChild(this);
165 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
169 const wxString
& name
)
171 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
173 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
176 parent
->AddChild(this);
180 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
181 m_width
= WidthDefault( size
.x
);
182 m_height
= HeightDefault( size
.y
) ;
183 #ifndef __WXUNIVERSAL__
184 if ( ! IsKindOf( CLASSINFO ( wxControl
) ) && ! IsKindOf( CLASSINFO( wxStatusBar
) ) )
186 MacCreateScrollBars( style
) ;
192 void wxWindowMac::SetFocus()
194 if ( gFocusWindow
== this )
197 if ( AcceptsFocus() )
203 if ( gFocusWindow
->m_caret
)
205 gFocusWindow
->m_caret
->OnKillFocus();
207 #endif // wxUSE_CARET
208 #ifndef __WXUNIVERSAL__
209 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
210 if ( control
&& control
->GetMacControl() )
212 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNoPart
) ;
213 control
->MacRedrawControl() ;
216 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
217 event
.SetEventObject(gFocusWindow
);
218 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
220 gFocusWindow
= this ;
226 m_caret
->OnSetFocus();
228 #endif // wxUSE_CARET
229 // panel wants to track the window which was the last to have focus in it
230 wxChildFocusEvent
eventFocus(this);
231 GetEventHandler()->ProcessEvent(eventFocus
);
233 #ifndef __WXUNIVERSAL__
234 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
235 if ( control
&& control
->GetMacControl() )
237 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlEditTextPart
) ;
240 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
241 event
.SetEventObject(this);
242 GetEventHandler()->ProcessEvent(event
) ;
247 bool wxWindowMac::Enable(bool enable
)
249 if ( !wxWindowBase::Enable(enable
) )
252 MacSuperEnabled( enable
) ;
257 void wxWindowMac::CaptureMouse()
259 wxTheApp
->s_captureWindow
= this ;
262 wxWindow
* wxWindowBase::GetCapture()
264 return wxTheApp
->s_captureWindow
;
267 void wxWindowMac::ReleaseMouse()
269 wxTheApp
->s_captureWindow
= NULL
;
272 #if wxUSE_DRAG_AND_DROP
274 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
276 if ( m_dropTarget
!= 0 ) {
280 m_dropTarget
= pDropTarget
;
281 if ( m_dropTarget
!= 0 )
289 // Old style file-manager drag&drop
290 void wxWindowMac::DragAcceptFiles(bool accept
)
296 void wxWindowMac::DoGetSize(int *x
, int *y
) const
299 if(y
) *y
= m_height
;
302 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
308 if ( !IsTopLevel() && GetParent())
310 wxPoint
pt(GetParent()->GetClientAreaOrigin());
319 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
321 menu
->SetInvokingWindow(this);
323 ClientToScreen( &x
, &y
) ;
325 ::InsertMenu( (MenuHandle
) menu
->GetHMenu() , -1 ) ;
326 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
327 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
328 ::DeleteMenu( menu
->MacGetMenuId() ) ;
329 menu
->SetInvokingWindow(NULL
);
335 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
337 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
339 Point localwhere
= {0,0} ;
341 if(x
) localwhere
.h
= * x
;
342 if(y
) localwhere
.v
= * y
;
346 ::SetPort( UMAGetWindowPort( window
) ) ;
347 ::GlobalToLocal( &localwhere
) ;
350 if(x
) *x
= localwhere
.h
;
351 if(y
) *y
= localwhere
.v
;
353 MacRootWindowToWindow( x
, y
) ;
355 x
-= MacGetLeftBorderSize() ;
357 y
-= MacGetTopBorderSize() ;
360 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
362 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
365 x
+= MacGetLeftBorderSize() ;
367 y
+= MacGetTopBorderSize() ;
369 MacWindowToRootWindow( x
, y
) ;
371 Point localwhere
= { 0,0 };
372 if(x
) localwhere
.h
= * x
;
373 if(y
) localwhere
.v
= * y
;
377 ::SetPort( UMAGetWindowPort( window
) ) ;
379 ::LocalToGlobal( &localwhere
) ;
381 if(x
) *x
= localwhere
.h
;
382 if(y
) *y
= localwhere
.v
;
385 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
387 wxPoint origin
= GetClientAreaOrigin() ;
388 if(x
) *x
+= origin
.x
;
389 if(y
) *y
+= origin
.y
;
391 MacWindowToRootWindow( x
, y
) ;
394 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
396 wxPoint origin
= GetClientAreaOrigin() ;
397 MacRootWindowToWindow( x
, y
) ;
398 if(x
) *x
-= origin
.x
;
399 if(y
) *y
-= origin
.y
;
402 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
408 GetParent()->MacWindowToRootWindow( x
, y
) ;
412 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
418 GetParent()->MacRootWindowToWindow( x
, y
) ;
422 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
424 if (m_cursor
== cursor
)
427 if (wxNullCursor
== cursor
)
429 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
434 if ( ! wxWindowBase::SetCursor( cursor
) )
438 wxASSERT_MSG( m_cursor
.Ok(),
439 wxT("cursor must be valid after call to the base version"));
442 wxWindowMac
*mouseWin
;
445 // Change the cursor NOW if we're within the correct window
447 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
449 if ( mouseWin
== this && !wxIsBusy() )
451 m_cursor
.MacInstall() ;
459 // Get size *available for subwindows* i.e. excluding menu bar etc.
460 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
466 ww
-= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
467 hh
-= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
469 if ( (m_vScrollBar
&& m_vScrollBar
->IsShown()) || (m_hScrollBar
&& m_hScrollBar
->IsShown()) )
476 MacClientToRootWindow( &x1
, &y1
) ;
477 MacClientToRootWindow( &w
, &h
) ;
479 wxWindowMac
*iter
= (wxWindowMac
*)this ;
481 int totW
= 10000 , totH
= 10000;
484 if ( iter
->IsTopLevel() )
486 totW
= iter
->m_width
;
487 totH
= iter
->m_height
;
491 iter
= iter
->GetParent() ;
494 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
496 hh
-= MAC_SCROLLBAR_SIZE
;
502 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
504 ww
-= MAC_SCROLLBAR_SIZE
;
516 // ----------------------------------------------------------------------------
518 // ----------------------------------------------------------------------------
522 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
524 wxWindowBase::DoSetToolTip(tooltip
);
527 m_tooltip
->SetWindow(this);
530 #endif // wxUSE_TOOLTIPS
532 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
536 int former_w
= m_width
;
537 int former_h
= m_height
;
539 int actualWidth
= width
;
540 int actualHeight
= height
;
544 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
545 actualWidth
= m_minWidth
;
546 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
547 actualHeight
= m_minHeight
;
548 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
549 actualWidth
= m_maxWidth
;
550 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
551 actualHeight
= m_maxHeight
;
553 bool doMove
= false ;
554 bool doResize
= false ;
556 if ( actualX
!= former_x
|| actualY
!= former_y
)
560 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
565 if ( doMove
|| doResize
)
567 // erase former position
573 m_width
= actualWidth
;
574 m_height
= actualHeight
;
576 // erase new position
580 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
582 MacRepositionScrollBars() ;
585 wxPoint
point(m_x
, m_y
);
586 wxMoveEvent
event(point
, m_windowId
);
587 event
.SetEventObject(this);
588 GetEventHandler()->ProcessEvent(event
) ;
592 MacRepositionScrollBars() ;
593 wxSize
size(m_width
, m_height
);
594 wxSizeEvent
event(size
, m_windowId
);
595 event
.SetEventObject(this);
596 GetEventHandler()->ProcessEvent(event
);
602 // set the size of the window: if the dimensions are positive, just use them,
603 // but if any of them is equal to -1, it means that we must find the value for
604 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
605 // which case -1 is a valid value for x and y)
607 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
608 // the width/height to best suit our contents, otherwise we reuse the current
610 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
612 // get the current size and position...
613 int currentX
, currentY
;
614 GetPosition(¤tX
, ¤tY
);
616 int currentW
,currentH
;
617 GetSize(¤tW
, ¤tH
);
619 // ... and don't do anything (avoiding flicker) if it's already ok
620 if ( x
== currentX
&& y
== currentY
&&
621 width
== currentW
&& height
== currentH
)
623 MacRepositionScrollBars() ; // we might have a real position shift
627 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
629 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
632 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
637 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
639 size
= DoGetBestSize();
644 // just take the current one
651 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
655 size
= DoGetBestSize();
657 //else: already called DoGetBestSize() above
663 // just take the current one
668 DoMoveWindow(x
, y
, width
, height
);
671 // For implementation purposes - sometimes decorations make the client area
674 wxPoint
wxWindowMac::GetClientAreaOrigin() const
676 return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
679 void wxWindow::SetTitle(const wxString
& title
)
684 wxString
wxWindow::GetTitle() const
689 bool wxWindowMac::Show(bool show
)
691 if ( !wxWindowBase::Show(show
) )
694 MacSuperShown( show
) ;
697 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
698 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
699 if ( win
&& !win
->m_isBeingDeleted
)
710 void wxWindowMac::MacSuperShown( bool show
)
712 wxNode
*node
= GetChildren().First();
715 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
716 if ( child
->m_isShown
)
717 child
->MacSuperShown( show
) ;
722 void wxWindowMac::MacSuperEnabled( bool enabled
)
726 // to be absolutely correct we'd have to invalidate (with eraseBkground
727 // because unter MacOSX the frames are drawn with an addXXX mode)
730 wxNode
*node
= GetChildren().First();
733 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
734 if ( child
->m_isShown
)
735 child
->MacSuperEnabled( enabled
) ;
740 bool wxWindowMac::MacIsReallyShown() const
742 if ( m_isShown
&& (m_parent
!= NULL
) ) {
743 return m_parent
->MacIsReallyShown();
747 bool status = m_isShown ;
748 wxWindowMac * win = this ;
749 while ( status && win->m_parent != NULL )
751 win = win->m_parent ;
752 status = win->m_isShown ;
758 int wxWindowMac::GetCharHeight() const
760 wxClientDC
dc ( (wxWindowMac
*)this ) ;
761 return dc
.GetCharHeight() ;
764 int wxWindowMac::GetCharWidth() const
766 wxClientDC
dc ( (wxWindowMac
*)this ) ;
767 return dc
.GetCharWidth() ;
770 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
771 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
773 const wxFont
*fontToUse
= theFont
;
777 wxClientDC
dc( (wxWindowMac
*) this ) ;
779 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
780 if ( externalLeading
)
781 *externalLeading
= le
;
791 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
792 * we always intersect with the entire window, not only with the client area
795 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
797 if ( MacGetTopLevelWindow() == NULL
)
801 client
= GetClientAreaOrigin( ) ;
802 Rect clientrect
= { -client
.y
, -client
.x
, m_height
- client
.y
, m_width
- client
.x
} ;
805 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
806 SectRect( &clientrect
, &r
, &clientrect
) ;
808 if ( !EmptyRect( &clientrect
) )
810 int top
= 0 , left
= 0 ;
812 MacClientToRootWindow( &left
, &top
) ;
813 OffsetRect( &clientrect
, left
, top
) ;
815 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
819 #if wxUSE_CARET && WXWIN_COMPATIBILITY
820 // ---------------------------------------------------------------------------
821 // Caret manipulation
822 // ---------------------------------------------------------------------------
824 void wxWindowMac::CreateCaret(int w
, int h
)
826 SetCaret(new wxCaret(this, w
, h
));
829 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
831 wxFAIL_MSG("not implemented");
834 void wxWindowMac::ShowCaret(bool show
)
836 wxCHECK_RET( m_caret
, "no caret to show" );
841 void wxWindowMac::DestroyCaret()
846 void wxWindowMac::SetCaretPos(int x
, int y
)
848 wxCHECK_RET( m_caret
, "no caret to move" );
853 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
855 wxCHECK_RET( m_caret
, "no caret to get position of" );
857 m_caret
->GetPosition(x
, y
);
859 #endif // wxUSE_CARET
861 wxWindowMac
*wxGetActiveWindow()
863 // actually this is a windows-only concept
867 // Coordinates relative to the window
868 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
870 // We really dont move the mouse programmatically under mac
873 const wxBrush
& wxWindowMac::MacGetBackgroundBrush()
875 if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
877 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDocumentWindowBackground
) ;
879 else if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) )
881 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
882 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
883 // either a non gray background color or a non control window
885 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
887 wxWindowMac
* parent
= GetParent() ;
890 if ( parent
->MacGetRootWindow() != window
)
892 // we are in a different window on the mac system
898 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
)
899 && parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
901 // if we have any other colours in the hierarchy
902 m_macBackgroundBrush
.SetColour( parent
->m_backgroundColour
) ;
905 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
906 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
908 Rect extent
= { 0 , 0 , 0 , 0 } ;
911 wxSize size
= GetSize() ;
912 parent
->MacClientToRootWindow( &x
, &y
) ;
916 extent
.right
= x
+ size
.x
;
917 extent
.bottom
= y
+ size
.y
;
918 m_macBackgroundBrush
.SetMacThemeBackground( kThemeBackgroundTabPane
, (WXRECTPTR
) &extent
) ; // todo eventually change for inactive
922 parent
= parent
->GetParent() ;
926 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDialogBackgroundActive
) ; // todo eventually change for inactive
931 m_macBackgroundBrush
.SetColour( m_backgroundColour
) ;
934 return m_macBackgroundBrush
;
938 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
940 event
.GetDC()->Clear() ;
943 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
945 wxWindowDC
dc(this) ;
946 wxMacPortSetter
helper(&dc
) ;
948 MacPaintBorders( dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
951 int wxWindowMac::GetScrollPos(int orient
) const
953 if ( orient
== wxHORIZONTAL
)
956 return m_hScrollBar
->GetThumbPosition() ;
961 return m_vScrollBar
->GetThumbPosition() ;
966 // This now returns the whole range, not just the number
967 // of positions that we can scroll.
968 int wxWindowMac::GetScrollRange(int orient
) const
970 if ( orient
== wxHORIZONTAL
)
973 return m_hScrollBar
->GetRange() ;
978 return m_vScrollBar
->GetRange() ;
983 int wxWindowMac::GetScrollThumb(int orient
) const
985 if ( orient
== wxHORIZONTAL
)
988 return m_hScrollBar
->GetThumbSize() ;
993 return m_vScrollBar
->GetThumbSize() ;
998 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
1000 if ( orient
== wxHORIZONTAL
)
1003 m_hScrollBar
->SetThumbPosition( pos
) ;
1008 m_vScrollBar
->SetThumbPosition( pos
) ;
1012 void wxWindowMac::MacPaintBorders( int left
, int top
)
1017 RGBColor white
= { 0xFFFF, 0xFFFF , 0xFFFF } ;
1018 RGBColor black
= { 0x0000, 0x0000 , 0x0000 } ;
1019 RGBColor face
= { 0xDDDD, 0xDDDD , 0xDDDD } ;
1020 RGBColor shadow
= { 0x4444, 0x4444 , 0x4444 } ;
1023 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
1025 #if wxMAC_USE_THEME_BORDER
1026 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1029 GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
1030 InsetRect( &rect , border , border );
1031 DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
1034 DrawThemePrimaryGroup(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
1036 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
1037 RGBForeColor( &face
);
1038 MoveTo( left
+ 0 , top
+ m_height
- 2 );
1039 LineTo( left
+ 0 , top
+ 0 );
1040 LineTo( left
+ m_width
- 2 , top
+ 0 );
1042 MoveTo( left
+ 2 , top
+ m_height
- 3 );
1043 LineTo( left
+ m_width
- 3 , top
+ m_height
- 3 );
1044 LineTo( left
+ m_width
- 3 , top
+ 2 );
1046 RGBForeColor( sunken
? &face
: &black
);
1047 MoveTo( left
+ 0 , top
+ m_height
- 1 );
1048 LineTo( left
+ m_width
- 1 , top
+ m_height
- 1 );
1049 LineTo( left
+ m_width
- 1 , top
+ 0 );
1051 RGBForeColor( sunken
? &shadow
: &white
);
1052 MoveTo( left
+ 1 , top
+ m_height
- 3 );
1053 LineTo( left
+ 1, top
+ 1 );
1054 LineTo( left
+ m_width
- 3 , top
+ 1 );
1056 RGBForeColor( sunken
? &white
: &shadow
);
1057 MoveTo( left
+ 1 , top
+ m_height
- 2 );
1058 LineTo( left
+ m_width
- 2 , top
+ m_height
- 2 );
1059 LineTo( left
+ m_width
- 2 , top
+ 1 );
1061 RGBForeColor( sunken
? &black
: &face
);
1062 MoveTo( left
+ 2 , top
+ m_height
- 4 );
1063 LineTo( left
+ 2 , top
+ 2 );
1064 LineTo( left
+ m_width
- 4 , top
+ 2 );
1067 else if (HasFlag(wxSIMPLE_BORDER
))
1069 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1070 RGBForeColor( &black
) ;
1071 FrameRect( &rect
) ;
1075 // New function that will replace some of the above.
1076 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
1077 int range
, bool refresh
)
1079 if ( orient
== wxHORIZONTAL
)
1083 if ( range
== 0 || thumbVisible
>= range
)
1085 if ( m_hScrollBar
->IsShown() )
1086 m_hScrollBar
->Show(false) ;
1090 if ( !m_hScrollBar
->IsShown() )
1091 m_hScrollBar
->Show(true) ;
1092 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1100 if ( range
== 0 || thumbVisible
>= range
)
1102 if ( m_vScrollBar
->IsShown() )
1103 m_vScrollBar
->Show(false) ;
1107 if ( !m_vScrollBar
->IsShown() )
1108 m_vScrollBar
->Show(true) ;
1109 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1113 MacRepositionScrollBars() ;
1116 // Does a physical scroll
1117 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1119 wxClientDC
dc(this) ;
1120 wxMacPortSetter
helper(&dc
) ;
1123 int width
, height
;
1124 GetClientSize( &width
, &height
) ;
1126 Rect scrollrect
= { dc
.YLOG2DEVMAC(0) , dc
.XLOG2DEVMAC(0) , dc
.YLOG2DEVMAC(height
) , dc
.XLOG2DEVMAC(width
) } ;
1127 RgnHandle updateRgn
= NewRgn() ;
1128 ClipRect( &scrollrect
) ;
1131 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
1132 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
1133 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1135 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1136 InvalWindowRgn( (WindowRef
) MacGetRootWindow() , updateRgn
) ;
1137 DisposeRgn( updateRgn
) ;
1140 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1142 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1143 if (child
== m_vScrollBar
) continue;
1144 if (child
== m_hScrollBar
) continue;
1145 if (child
->IsTopLevel()) continue;
1147 child
->GetPosition( &x
, &y
);
1149 child
->GetSize( &w
, &h
);
1150 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1155 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1157 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1159 wxScrollWinEvent wevent
;
1160 wevent
.SetPosition(event
.GetPosition());
1161 wevent
.SetOrientation(event
.GetOrientation());
1162 wevent
.m_eventObject
= this;
1164 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1165 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1167 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1168 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1170 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1171 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1173 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1174 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1176 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1177 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1179 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1180 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1182 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1183 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1186 GetEventHandler()->ProcessEvent(wevent
);
1190 // Get the window with the focus
1191 wxWindowMac
*wxWindowBase::FindFocus()
1193 return gFocusWindow
;
1196 #if WXWIN_COMPATIBILITY
1197 // If nothing defined for this, try the parent.
1198 // E.g. we may be a button loaded from a resource, with no callback function
1200 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1202 if ( GetEventHandler()->ProcessEvent(event
) )
1205 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1207 #endif // WXWIN_COMPATIBILITY_2
1209 #if WXWIN_COMPATIBILITY
1210 wxObject
* wxWindowMac::GetChild(int number
) const
1212 // Return a pointer to the Nth object in the Panel
1213 wxNode
*node
= GetChildren().First();
1216 node
= node
->Next();
1219 wxObject
*obj
= (wxObject
*)node
->Data();
1225 #endif // WXWIN_COMPATIBILITY
1227 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1229 // panel wants to track the window which was the last to have focus in it,
1230 // so we want to set ourselves as the window which last had focus
1232 // notice that it's also important to do it upwards the tree becaus
1233 // otherwise when the top level panel gets focus, it won't set it back to
1234 // us, but to some other sibling
1236 // CS:don't know if this is still needed:
1237 //wxChildFocusEvent eventFocus(this);
1238 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1243 void wxWindowMac::Clear()
1245 wxClientDC
dc(this);
1246 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1247 dc
.SetBackground(brush
);
1251 // Setup background and foreground colours correctly
1252 void wxWindowMac::SetupColours()
1255 SetBackgroundColour(GetParent()->GetBackgroundColour());
1258 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1261 // Check if we need to send a LEAVE event
1262 if (m_mouseInWindow)
1265 ::GetCursorPos(&pt);
1266 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1268 // Generate a LEAVE event
1269 m_mouseInWindow = FALSE;
1270 MSWOnMouseLeave(pt.x, pt.y, 0);
1275 // This calls the UI-update mechanism (querying windows for
1276 // menu/toolbar/control state information)
1280 // Raise the window to the top of the Z order
1281 void wxWindowMac::Raise()
1285 // Lower the window to the bottom of the Z order
1286 void wxWindowMac::Lower()
1290 void wxWindowMac::DoSetClientSize(int width
, int height
)
1292 if ( width
!= -1 || height
!= -1 )
1295 if ( width
!= -1 && m_vScrollBar
)
1296 width
+= MAC_SCROLLBAR_SIZE
;
1297 if ( height
!= -1 && m_vScrollBar
)
1298 height
+= MAC_SCROLLBAR_SIZE
;
1300 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1301 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1303 DoSetSize( -1 , -1 , width
, height
) ;
1308 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1310 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1314 if ((point
.x
< 0) || (point
.y
< 0) ||
1315 (point
.x
> (m_width
)) || (point
.y
> (m_height
)))
1320 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1321 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1325 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1327 wxPoint
newPoint( point
) ;
1329 if ( !IsTopLevel() )
1335 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1337 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1338 // added the m_isShown test --dmazzoni
1339 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1341 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1350 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1354 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1355 if ( ::FindWindow( pt
, &window
) == 3 )
1358 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1361 // No, this yields the CLIENT are, we need the whole frame. RR.
1362 // point = win->ScreenToClient( point ) ;
1365 ::GetPort( &port
) ;
1366 ::SetPort( UMAGetWindowPort( window
) ) ;
1367 ::GlobalToLocal( &pt
) ;
1370 wxPoint
point( pt
.h
, pt
.v
) ;
1372 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1378 extern int wxBusyCursorCount
;
1380 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1382 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1383 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1387 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) )
1390 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1398 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1400 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1401 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1403 if (child
->MacDispatchMouseEvent(event
))
1411 if ( wxBusyCursorCount
== 0 )
1413 m_cursor
.MacInstall() ;
1416 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1418 // set focus to this window
1419 if (AcceptsFocus() && FindFocus()!=this)
1424 if ( event
.GetEventType() == wxEVT_MOTION
1425 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1426 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1427 wxToolTip::RelayEvent( this , event
);
1428 #endif // wxUSE_TOOLTIPS
1430 GetEventHandler()->ProcessEvent( event
) ;
1435 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1439 return m_tooltip
->GetTip() ;
1444 void wxWindowMac::Update()
1446 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1449 win
->MacUpdate( 0 ) ;
1450 if ( QDIsPortBuffered( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) ) )
1452 QDFlushPortBuffer( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) , NULL
) ;
1457 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1459 wxTopLevelWindowMac
* win
= NULL
;
1460 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1463 win
= wxFindWinFromMacWindow( window
) ;
1468 const wxRegion
& wxWindowMac::MacGetVisibleRegion()
1470 RgnHandle visRgn
= NewRgn() ;
1471 RgnHandle tempRgn
= NewRgn() ;
1473 SetRectRgn( visRgn
, 0 , 0 , m_width
, m_height
) ;
1475 //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
1476 if ( IsKindOf( CLASSINFO( wxStaticBox
) ) )
1478 int borderTop
= 14 ;
1479 int borderOther
= 4 ;
1481 SetRectRgn( tempRgn
, borderOther
, borderTop
, m_width
- borderOther
, m_height
- borderOther
) ;
1482 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1485 if ( !IsTopLevel() )
1487 wxWindow
* parent
= GetParent() ;
1490 wxSize size
= parent
->GetSize() ;
1493 parent
->MacWindowToRootWindow( &x
, &y
) ;
1494 MacRootWindowToWindow( &x
, &y
) ;
1495 SetRectRgn( tempRgn
, x
, y
, x
+ size
.x
, y
+ size
.y
) ;
1496 SectRgn( visRgn
, tempRgn
, visRgn
) ;
1497 if ( parent
->IsTopLevel() )
1499 parent
= parent
->GetParent() ;
1502 if ( GetWindowStyle() & wxCLIP_CHILDREN
)
1504 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1506 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1508 if ( !child
->IsTopLevel() && child
->IsShown() )
1510 SetRectRgn( tempRgn
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1511 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1516 if ( (GetWindowStyle() & wxCLIP_SIBLINGS
) && GetParent() )
1518 bool thisWindowThrough
= false ;
1519 for (wxNode
*node
= GetParent()->GetChildren().First(); node
; node
= node
->Next())
1521 wxWindowMac
*sibling
= (wxWindowMac
*)node
->Data();
1522 if ( sibling
== this )
1524 thisWindowThrough
= true ;
1527 if( !thisWindowThrough
)
1532 if ( !sibling
->IsTopLevel() && sibling
->IsShown() )
1534 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
) ;
1535 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1539 m_macVisibleRegion
= visRgn
;
1540 DisposeRgn( visRgn
) ;
1541 DisposeRgn( tempRgn
) ;
1542 return m_macVisibleRegion
;
1545 void wxWindowMac::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
1547 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
1548 // updatergn is always already clipped to our boundaries
1549 // it is in window coordinates, not in client coordinates
1551 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1554 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
1555 RgnHandle ownUpdateRgn
= NewRgn() ;
1556 CopyRgn( updatergn
, ownUpdateRgn
) ;
1558 SectRgn( ownUpdateRgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn
) ;
1560 // newupdate is the update region in client coordinates
1561 RgnHandle newupdate
= NewRgn() ;
1562 wxSize point
= GetClientSize() ;
1563 wxPoint origin
= GetClientAreaOrigin() ;
1564 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1565 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1566 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1567 m_updateRegion
= newupdate
;
1568 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1570 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1572 wxWindowDC
dc(this);
1573 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1574 wxEraseEvent
eevent( GetId(), &dc
);
1575 eevent
.SetEventObject( this );
1576 GetEventHandler()->ProcessEvent( eevent
);
1578 wxNcPaintEvent
eventNc( GetId() );
1579 eventNc
.SetEventObject( this );
1580 GetEventHandler()->ProcessEvent( eventNc
);
1582 DisposeRgn( ownUpdateRgn
) ;
1583 if ( !m_updateRegion
.Empty() )
1586 event
.m_timeStamp
= time
;
1587 event
.SetEventObject(this);
1588 GetEventHandler()->ProcessEvent(event
);
1592 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1594 RgnHandle childupdate
= NewRgn() ;
1595 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1597 // calculate the update region for the child windows by intersecting the window rectangle with our own
1598 // passed in update region and then offset it to be client-wise window coordinates again
1599 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1600 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1601 SectRgn( childupdate
, updatergn
, childupdate
) ;
1602 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1603 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1605 // because dialogs may also be children
1606 child
->MacRedraw( childupdate
, time
, erase
) ;
1609 DisposeRgn( childupdate
) ;
1610 // eventually a draw grow box here
1614 WXHWND
wxWindowMac::MacGetRootWindow() const
1616 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1620 if ( iter
->IsTopLevel() )
1621 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1623 iter
= iter
->GetParent() ;
1625 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1629 void wxWindowMac::MacCreateScrollBars( long style
)
1631 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1633 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1634 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1636 GetClientSize( &width
, &height
) ;
1638 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1639 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1640 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1641 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1643 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1644 vSize
, wxVERTICAL
);
1646 if ( style
& wxVSCROLL
)
1652 m_vScrollBar
->Show(false) ;
1654 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1655 hSize
, wxHORIZONTAL
);
1656 if ( style
& wxHSCROLL
)
1661 m_hScrollBar
->Show(false) ;
1664 // because the create does not take into account the client area origin
1665 MacRepositionScrollBars() ; // we might have a real position shift
1668 void wxWindowMac::MacRepositionScrollBars()
1670 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1671 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1673 // get real client area
1675 int width
= m_width
;
1676 int height
= m_height
;
1678 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1679 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1681 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1682 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1683 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1684 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1691 MacClientToRootWindow( &x
, &y
) ;
1692 MacClientToRootWindow( &w
, &h
) ;
1694 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1696 int totW
= 10000 , totH
= 10000;
1699 if ( iter
->IsTopLevel() )
1701 totW
= iter
->m_width
;
1702 totH
= iter
->m_height
;
1706 iter
= iter
->GetParent() ;
1734 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1738 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1742 bool wxWindowMac::AcceptsFocus() const
1744 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1747 WXWidget
wxWindowMac::MacGetContainerForEmbedding()
1749 return GetParent()->MacGetContainerForEmbedding() ;
1752 void wxWindowMac::MacSuperChangedPosition()
1754 // only window-absolute structures have to be moved i.e. controls
1756 wxNode
*node
= GetChildren().First();
1759 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1760 child
->MacSuperChangedPosition() ;
1761 node
= node
->Next();
1765 void wxWindowMac::MacTopLevelWindowChangedPosition()
1767 // only screen-absolute structures have to be moved i.e. glcanvas
1769 wxNode
*node
= GetChildren().First();
1772 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1773 child
->MacTopLevelWindowChangedPosition() ;
1774 node
= node
->Next();
1777 long wxWindowMac::MacGetLeftBorderSize( ) const
1782 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1785 #if wxMAC_USE_THEME_BORDER
1787 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1792 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1795 #if wxMAC_USE_THEME_BORDER
1797 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1802 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1809 long wxWindowMac::MacGetRightBorderSize( ) const
1811 // they are all symmetric in mac themes
1812 return MacGetLeftBorderSize() ;
1815 long wxWindowMac::MacGetTopBorderSize( ) const
1817 // they are all symmetric in mac themes
1818 return MacGetLeftBorderSize() ;
1821 long wxWindowMac::MacGetBottomBorderSize( ) const
1823 // they are all symmetric in mac themes
1824 return MacGetLeftBorderSize() ;
1827 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1829 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1832 // Find the wxWindowMac at the current mouse position, returning the mouse
1834 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1836 pt
= wxGetMousePosition();
1837 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1841 // Get the current mouse position.
1842 wxPoint
wxGetMousePosition()
1845 wxGetMousePosition(& x
, & y
);
1846 return wxPoint(x
, y
);