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"
50 #if wxUSE_DRAG_AND_DROP
56 extern wxList wxPendingDelete
;
57 wxWindowMac
* gFocusWindow
= NULL
;
59 #ifdef __WXUNIVERSAL__
60 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
62 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
63 #endif // __WXUNIVERSAL__/__WXMAC__
65 #if !USE_SHARED_LIBRARY
67 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
68 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
69 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
70 EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged
)
71 EVT_INIT_DIALOG(wxWindowMac::OnInitDialog
)
72 EVT_IDLE(wxWindowMac::OnIdle
)
73 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
78 #define wxMAC_USE_THEME_BORDER 0
81 // ===========================================================================
83 // ===========================================================================
86 // ----------------------------------------------------------------------------
87 // constructors and such
88 // ----------------------------------------------------------------------------
90 void wxWindowMac::Init()
96 m_doubleClickAllowed
= 0;
97 m_winCaptured
= FALSE
;
99 m_isBeingDeleted
= FALSE
;
102 m_mouseInWindow
= FALSE
;
106 m_backgroundTransparent
= FALSE
;
108 // as all windows are created with WS_VISIBLE style...
116 m_hScrollBar
= NULL
;
117 m_vScrollBar
= NULL
;
119 #if wxUSE_DRAG_AND_DROP
120 m_pDropTarget
= NULL
;
125 wxWindowMac::~wxWindowMac()
127 // deleting a window while it is shown invalidates the region
129 wxWindowMac
* iter
= this ;
131 if ( iter
->IsTopLevel() )
136 iter
= iter
->GetParent() ;
141 m_isBeingDeleted
= TRUE
;
143 if ( s_lastMouseWindow
== this )
145 s_lastMouseWindow
= NULL
;
148 if ( gFocusWindow
== this )
150 gFocusWindow
= NULL
;
154 m_parent
->RemoveChild(this);
160 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
164 const wxString
& name
)
166 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
168 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
171 parent
->AddChild(this);
175 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
176 m_width
= WidthDefault( size
.x
);
177 m_height
= HeightDefault( size
.y
) ;
178 #ifndef __WXUNIVERSAL__
179 if ( ! IsKindOf( CLASSINFO ( wxControl
) ) && ! IsKindOf( CLASSINFO( wxStatusBar
) ) )
181 MacCreateScrollBars( style
) ;
187 void wxWindowMac::SetFocus()
189 if ( gFocusWindow
== this )
192 if ( AcceptsFocus() )
198 if ( gFocusWindow
->m_caret
)
200 gFocusWindow
->m_caret
->OnKillFocus();
202 #endif // wxUSE_CARET
203 #ifndef __WXUNIVERSAL__
204 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
205 if ( control
&& control
->GetMacControl() )
207 UMASetKeyboardFocus( gFocusWindow
->MacGetRootWindow() , control
->GetMacControl() , kControlFocusNoPart
) ;
208 control
->MacRedrawControl() ;
211 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
212 event
.SetEventObject(gFocusWindow
);
213 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
215 gFocusWindow
= this ;
221 m_caret
->OnSetFocus();
223 #endif // wxUSE_CARET
224 // panel wants to track the window which was the last to have focus in it
225 wxChildFocusEvent
eventFocus(this);
226 GetEventHandler()->ProcessEvent(eventFocus
);
228 #ifndef __WXUNIVERSAL__
229 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
230 if ( control
&& control
->GetMacControl() )
232 UMASetKeyboardFocus( gFocusWindow
->MacGetRootWindow() , control
->GetMacControl() , kControlEditTextPart
) ;
235 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
236 event
.SetEventObject(this);
237 GetEventHandler()->ProcessEvent(event
) ;
242 bool wxWindowMac::Enable(bool enable
)
244 if ( !wxWindowBase::Enable(enable
) )
247 MacSuperEnabled( enable
) ;
252 void wxWindowMac::CaptureMouse()
254 wxTheApp
->s_captureWindow
= this ;
257 wxWindow
* wxWindowBase::GetCapture()
259 return wxTheApp
->s_captureWindow
;
262 void wxWindowMac::ReleaseMouse()
264 wxTheApp
->s_captureWindow
= NULL
;
267 #if wxUSE_DRAG_AND_DROP
269 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
271 if ( m_pDropTarget
!= 0 ) {
272 delete m_pDropTarget
;
275 m_pDropTarget
= pDropTarget
;
276 if ( m_pDropTarget
!= 0 )
284 // Old style file-manager drag&drop
285 void wxWindowMac::DragAcceptFiles(bool accept
)
291 void wxWindowMac::DoGetSize(int *x
, int *y
) const
294 if(y
) *y
= m_height
;
297 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
303 if ( !IsTopLevel() && GetParent())
305 wxPoint
pt(GetParent()->GetClientAreaOrigin());
314 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
316 menu
->SetInvokingWindow(this);
318 ClientToScreen( &x
, &y
) ;
320 ::InsertMenu( menu
->GetHMenu() , -1 ) ;
321 long menuResult
= ::PopUpMenuSelect(menu
->GetHMenu() ,y
,x
, 0) ;
322 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
323 ::DeleteMenu( menu
->MacGetMenuId() ) ;
324 menu
->SetInvokingWindow(NULL
);
330 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
332 WindowRef window
= MacGetRootWindow() ;
334 Point localwhere
= {0,0} ;
336 if(x
) localwhere
.h
= * x
;
337 if(y
) localwhere
.v
= * y
;
341 ::SetPort( UMAGetWindowPort( window
) ) ;
342 ::GlobalToLocal( &localwhere
) ;
345 if(x
) *x
= localwhere
.h
;
346 if(y
) *y
= localwhere
.v
;
348 MacRootWindowToClient( x
, y
) ;
351 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
353 WindowRef window
= MacGetRootWindow() ;
355 MacClientToRootWindow( x
, y
) ;
357 Point localwhere
= { 0,0 };
358 if(x
) localwhere
.h
= * x
;
359 if(y
) localwhere
.v
= * y
;
363 ::SetPort( UMAGetWindowPort( window
) ) ;
364 ::SetOrigin( 0 , 0 ) ;
365 ::LocalToGlobal( &localwhere
) ;
367 if(x
) *x
= localwhere
.h
;
368 if(y
) *y
= localwhere
.v
;
371 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
373 wxPoint origin
= GetClientAreaOrigin() ;
374 if(x
) *x
+= origin
.x
;
375 if(y
) *y
+= origin
.y
;
377 MacWindowToRootWindow( x
, y
) ;
380 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
382 wxPoint origin
= GetClientAreaOrigin() ;
383 MacRootWindowToWindow( x
, y
) ;
384 if(x
) *x
-= origin
.x
;
385 if(y
) *y
-= origin
.y
;
388 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
394 GetParent()->MacWindowToRootWindow( x
, y
) ;
398 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
404 GetParent()->MacRootWindowToWindow( x
, y
) ;
408 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
410 if (m_cursor
== cursor
)
413 if (wxNullCursor
== cursor
)
415 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
420 if ( ! wxWindowBase::SetCursor( cursor
) )
424 wxASSERT_MSG( m_cursor
.Ok(),
425 wxT("cursor must be valid after call to the base version"));
428 wxWindowMac
*mouseWin
;
431 // Change the cursor NOW if we're within the correct window
433 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
435 if ( mouseWin
== this && !wxIsBusy() )
437 m_cursor
.MacInstall() ;
445 // Get size *available for subwindows* i.e. excluding menu bar etc.
446 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
452 ww
-= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
453 hh
-= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
455 if ( (m_vScrollBar
&& m_vScrollBar
->IsShown()) || (m_hScrollBar
&& m_hScrollBar
->IsShown()) )
462 MacClientToRootWindow( &x1
, &y1
) ;
463 MacClientToRootWindow( &w
, &h
) ;
465 wxWindowMac
*iter
= (wxWindowMac
*)this ;
467 int totW
= 10000 , totH
= 10000;
470 if ( iter
->IsTopLevel() )
472 totW
= iter
->m_width
;
473 totH
= iter
->m_height
;
477 iter
= iter
->GetParent() ;
480 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
482 hh
-= MAC_SCROLLBAR_SIZE
;
488 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
490 ww
-= MAC_SCROLLBAR_SIZE
;
502 // ----------------------------------------------------------------------------
504 // ----------------------------------------------------------------------------
508 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
510 wxWindowBase::DoSetToolTip(tooltip
);
513 m_tooltip
->SetWindow(this);
516 #endif // wxUSE_TOOLTIPS
518 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
522 int former_w
= m_width
;
523 int former_h
= m_height
;
525 int actualWidth
= width
;
526 int actualHeight
= height
;
530 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
531 actualWidth
= m_minWidth
;
532 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
533 actualHeight
= m_minHeight
;
534 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
535 actualWidth
= m_maxWidth
;
536 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
537 actualHeight
= m_maxHeight
;
539 bool doMove
= false ;
540 bool doResize
= false ;
542 if ( actualX
!= former_x
|| actualY
!= former_y
)
546 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
551 if ( doMove
|| doResize
)
553 // erase former position
554 wxMacDrawingHelper
focus( this ) ;
557 Rect clientrect
= { 0 , 0 , m_height
, m_width
} ;
558 // ClipRect( &clientrect ) ;
559 InvalWindowRect( MacGetRootWindow() , &clientrect
) ;
564 m_width
= actualWidth
;
565 m_height
= actualHeight
;
566 // erase new position
569 wxMacDrawingHelper
focus( this ) ;
572 Rect clientrect
= { 0 , 0 , m_height
, m_width
} ;
573 // ClipRect( &clientrect ) ;
574 InvalWindowRect( MacGetRootWindow() , &clientrect
) ;
579 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
581 MacRepositionScrollBars() ;
584 wxPoint
point(m_x
, m_y
);
585 wxMoveEvent
event(point
, m_windowId
);
586 event
.SetEventObject(this);
587 GetEventHandler()->ProcessEvent(event
) ;
591 MacRepositionScrollBars() ;
592 wxSize
size(m_width
, m_height
);
593 wxSizeEvent
event(size
, m_windowId
);
594 event
.SetEventObject(this);
595 GetEventHandler()->ProcessEvent(event
);
601 // set the size of the window: if the dimensions are positive, just use them,
602 // but if any of them is equal to -1, it means that we must find the value for
603 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
604 // which case -1 is a valid value for x and y)
606 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
607 // the width/height to best suit our contents, otherwise we reuse the current
609 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
611 // get the current size and position...
612 int currentX
, currentY
;
613 GetPosition(¤tX
, ¤tY
);
615 int currentW
,currentH
;
616 GetSize(¤tW
, ¤tH
);
618 // ... and don't do anything (avoiding flicker) if it's already ok
619 if ( x
== currentX
&& y
== currentY
&&
620 width
== currentW
&& height
== currentH
)
622 MacRepositionScrollBars() ; // we might have a real position shift
626 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
628 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
631 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
636 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
638 size
= DoGetBestSize();
643 // just take the current one
650 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
654 size
= DoGetBestSize();
656 //else: already called DoGetBestSize() above
662 // just take the current one
667 DoMoveWindow(x
, y
, width
, height
);
670 // For implementation purposes - sometimes decorations make the client area
673 wxPoint
wxWindowMac::GetClientAreaOrigin() const
675 return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
678 void wxWindow::SetTitle(const wxString
& title
)
683 wxString
wxWindow::GetTitle() const
688 bool wxWindowMac::Show(bool show
)
690 if ( !wxWindowBase::Show(show
) )
693 MacSuperShown( show
) ;
696 WindowRef window
= MacGetRootWindow() ;
697 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
698 if ( win
&& !win
->m_isBeingDeleted
)
709 void wxWindowMac::MacSuperShown( bool show
)
711 wxNode
*node
= GetChildren().First();
714 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
715 if ( child
->m_isShown
)
716 child
->MacSuperShown( show
) ;
721 void wxWindowMac::MacSuperEnabled( bool enabled
)
725 // to be absolutely correct we'd have to invalidate (with eraseBkground
726 // because unter MacOSX the frames are drawn with an addXXX mode)
729 wxNode
*node
= GetChildren().First();
732 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
733 if ( child
->m_isShown
)
734 child
->MacSuperEnabled( enabled
) ;
739 bool wxWindowMac::MacIsReallyShown() const
741 if ( m_isShown
&& (m_parent
!= NULL
) ) {
742 return m_parent
->MacIsReallyShown();
746 bool status = m_isShown ;
747 wxWindowMac * win = this ;
748 while ( status && win->m_parent != NULL )
750 win = win->m_parent ;
751 status = win->m_isShown ;
757 int wxWindowMac::GetCharHeight() const
759 wxClientDC
dc ( (wxWindowMac
*)this ) ;
760 return dc
.GetCharHeight() ;
763 int wxWindowMac::GetCharWidth() const
765 wxClientDC
dc ( (wxWindowMac
*)this ) ;
766 return dc
.GetCharWidth() ;
769 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
770 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
772 const wxFont
*fontToUse
= theFont
;
776 wxClientDC
dc( (wxWindowMac
*) this ) ;
778 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
779 if ( externalLeading
)
780 *externalLeading
= le
;
790 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
791 * we always intersect with the entire window, not only with the client area
794 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
797 client
= GetClientAreaOrigin( ) ;
798 Rect clientrect
= { -client
.y
, -client
.x
, m_height
- client
.y
, m_width
- client
.x
} ;
801 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
802 SectRect( &clientrect
, &r
, &clientrect
) ;
804 if ( !EmptyRect( &clientrect
) )
806 int top
= 0 , left
= 0 ;
808 MacClientToRootWindow( &left
, &top
) ;
809 OffsetRect( &clientrect
, left
, top
) ;
811 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
815 #if wxUSE_CARET && WXWIN_COMPATIBILITY
816 // ---------------------------------------------------------------------------
817 // Caret manipulation
818 // ---------------------------------------------------------------------------
820 void wxWindowMac::CreateCaret(int w
, int h
)
822 SetCaret(new wxCaret(this, w
, h
));
825 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
827 wxFAIL_MSG("not implemented");
830 void wxWindowMac::ShowCaret(bool show
)
832 wxCHECK_RET( m_caret
, "no caret to show" );
837 void wxWindowMac::DestroyCaret()
842 void wxWindowMac::SetCaretPos(int x
, int y
)
844 wxCHECK_RET( m_caret
, "no caret to move" );
849 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
851 wxCHECK_RET( m_caret
, "no caret to get position of" );
853 m_caret
->GetPosition(x
, y
);
855 #endif // wxUSE_CARET
857 wxWindowMac
*wxGetActiveWindow()
859 // actually this is a windows-only concept
863 // Coordinates relative to the window
864 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
866 // We really dont move the mouse programmatically under mac
869 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
871 wxMacDrawingHelper
focus( this ) ;
874 WindowRef window
= MacGetRootWindow() ;
875 Rect rect
= {0, 0 , m_height
, m_width
} ;
876 RgnHandle updateRgn
= GetUpdateRegion().GetWXHRGN() ;
877 SetClip( event
.GetDC()->MacGetCurrentClipRgn() ) ;
879 if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
881 SetThemeWindowBackground( window
, kThemeBrushDocumentWindowBackground
, false ) ;
883 else if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
885 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
886 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
887 // either a non gray background color or a non control window
889 wxWindowMac
* parent
= GetParent() ;
892 if ( parent
->MacGetRootWindow() != window
)
894 // we are in a different window on the mac system
898 //if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() )
900 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
)
901 && parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
903 // if we have any other colours in the hierarchy
904 RGBBackColor( &parent
->m_backgroundColour
.GetPixel()) ;
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
) ))
911 GetRegionBounds( updateRgn
, &box
) ;
912 ::ApplyThemeBackground(kThemeBackgroundTabPane
, &box
, kThemeStateActive
,8,true);
919 // we have arrived at a non control item
924 parent
= parent
->GetParent() ;
928 // if there is nothing special -> use default
929 SetThemeWindowBackground( window
, kThemeBrushDialogBackgroundActive
, false ) ;
934 RGBBackColor( &m_backgroundColour
.GetPixel()) ;
939 // event.GetDC()->Clear() ;
942 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
944 wxMacDrawingHelper
focus( this ) ;
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( )
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
= { 0 , 0 , m_height
, m_width
} ;
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( 0 , m_height
- 2 );
1040 LineTo( m_width
- 2 , 0 );
1042 MoveTo( 2 , m_height
- 3 );
1043 LineTo( m_width
- 3 , m_height
- 3 );
1044 LineTo( m_width
- 3 , 2 );
1046 RGBForeColor( sunken
? &face
: &black
);
1047 MoveTo( 0 , m_height
- 1 );
1048 LineTo( m_width
- 1 , m_height
- 1 );
1049 LineTo( m_width
- 1 , 0 );
1051 RGBForeColor( sunken
? &shadow
: &white
);
1052 MoveTo( 1 , m_height
- 3 );
1054 LineTo( m_width
- 3 , 1 );
1056 RGBForeColor( sunken
? &white
: &shadow
);
1057 MoveTo( 1 , m_height
- 2 );
1058 LineTo( m_width
- 2 , m_height
- 2 );
1059 LineTo( m_width
- 2 , 1 );
1061 RGBForeColor( sunken
? &black
: &face
);
1062 MoveTo( 2 , m_height
- 4 );
1064 LineTo( m_width
- 4 , 2 );
1067 else if (HasFlag(wxSIMPLE_BORDER
))
1069 Rect rect
= { 0 , 0 , m_height
, m_width
} ;
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 wxMacDrawingClientHelper
focus( this ) ;
1122 int width
, height
;
1123 GetClientSize( &width
, &height
) ;
1125 Rect scrollrect
= { 0 , 0 , height
, width
} ;
1127 RgnHandle updateRgn
= NewRgn() ;
1128 ClipRect( &scrollrect
) ;
1131 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
1132 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1134 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1135 InvalWindowRgn( MacGetRootWindow() , updateRgn
) ;
1136 DisposeRgn( updateRgn
) ;
1139 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1141 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1142 if (child
== m_vScrollBar
) continue;
1143 if (child
== m_hScrollBar
) continue;
1144 if (child
->IsTopLevel()) continue;
1146 child
->GetPosition( &x
, &y
);
1148 child
->GetSize( &w
, &h
);
1149 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1154 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1156 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1158 wxScrollWinEvent wevent
;
1159 wevent
.SetPosition(event
.GetPosition());
1160 wevent
.SetOrientation(event
.GetOrientation());
1161 wevent
.m_eventObject
= this;
1163 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1164 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1166 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1167 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1169 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1170 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1172 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1173 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1175 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1176 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1178 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1179 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1181 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1182 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1185 GetEventHandler()->ProcessEvent(wevent
);
1189 // Get the window with the focus
1190 wxWindowMac
*wxWindowBase::FindFocus()
1192 return gFocusWindow
;
1195 #if WXWIN_COMPATIBILITY
1196 // If nothing defined for this, try the parent.
1197 // E.g. we may be a button loaded from a resource, with no callback function
1199 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1201 if ( GetEventHandler()->ProcessEvent(event
) )
1204 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1206 #endif // WXWIN_COMPATIBILITY_2
1208 #if WXWIN_COMPATIBILITY
1209 wxObject
* wxWindowMac::GetChild(int number
) const
1211 // Return a pointer to the Nth object in the Panel
1212 wxNode
*node
= GetChildren().First();
1215 node
= node
->Next();
1218 wxObject
*obj
= (wxObject
*)node
->Data();
1224 #endif // WXWIN_COMPATIBILITY
1226 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1228 // panel wants to track the window which was the last to have focus in it,
1229 // so we want to set ourselves as the window which last had focus
1231 // notice that it's also important to do it upwards the tree becaus
1232 // otherwise when the top level panel gets focus, it won't set it back to
1233 // us, but to some other sibling
1235 // CS:don't know if this is still needed:
1236 //wxChildFocusEvent eventFocus(this);
1237 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1242 void wxWindowMac::Clear()
1244 wxClientDC
dc(this);
1245 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1246 dc
.SetBackground(brush
);
1250 // Setup background and foreground colours correctly
1251 void wxWindowMac::SetupColours()
1254 SetBackgroundColour(GetParent()->GetBackgroundColour());
1257 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1260 // Check if we need to send a LEAVE event
1261 if (m_mouseInWindow)
1264 ::GetCursorPos(&pt);
1265 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1267 // Generate a LEAVE event
1268 m_mouseInWindow = FALSE;
1269 MSWOnMouseLeave(pt.x, pt.y, 0);
1274 // This calls the UI-update mechanism (querying windows for
1275 // menu/toolbar/control state information)
1279 // Raise the window to the top of the Z order
1280 void wxWindowMac::Raise()
1284 // Lower the window to the bottom of the Z order
1285 void wxWindowMac::Lower()
1289 void wxWindowMac::DoSetClientSize(int width
, int height
)
1291 if ( width
!= -1 || height
!= -1 )
1294 if ( width
!= -1 && m_vScrollBar
)
1295 width
+= MAC_SCROLLBAR_SIZE
;
1296 if ( height
!= -1 && m_vScrollBar
)
1297 height
+= MAC_SCROLLBAR_SIZE
;
1299 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1300 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1302 DoSetSize( -1 , -1 , width
, height
) ;
1307 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1309 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1311 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1312 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1315 WindowRef window
= MacGetRootWindow() ;
1317 wxPoint
newPoint( point
) ;
1322 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1324 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1325 // added the m_isShown test --dmazzoni
1326 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1328 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1337 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1340 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1341 if ( ::FindWindow( pt
, &window
) == 3 )
1343 wxPoint
point( screenpoint
) ;
1344 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1347 win
->ScreenToClient( point
) ;
1348 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1354 extern int wxBusyCursorCount
;
1356 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1358 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1359 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1363 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) )
1366 WindowRef window
= MacGetRootWindow() ;
1374 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1376 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1377 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1379 if (child
->MacDispatchMouseEvent(event
))
1387 if ( wxBusyCursorCount
== 0 )
1389 m_cursor
.MacInstall() ;
1392 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1394 // set focus to this window
1395 if (AcceptsFocus() && FindFocus()!=this)
1400 if ( event
.GetEventType() == wxEVT_MOTION
1401 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1402 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1403 wxToolTip::RelayEvent( this , event
);
1404 #endif // wxUSE_TOOLTIPS
1405 GetEventHandler()->ProcessEvent( event
) ;
1409 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1413 return m_tooltip
->GetTip() ;
1418 void wxWindowMac::Update()
1420 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1422 win
->MacUpdate( 0 ) ;
1425 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1427 wxTopLevelWindowMac
* win
= NULL
;
1428 WindowRef window
= MacGetRootWindow() ;
1431 win
= wxFindWinFromMacWindow( window
) ;
1436 void wxWindowMac::MacRedraw( RgnHandle updatergn
, long time
, bool erase
)
1438 // updatergn is always already clipped to our boundaries
1439 // it is in nc-coordinates
1441 WindowRef window
= MacGetRootWindow() ;
1444 // ownUpdateRgn is the area that this window has to invalidate i.e. its own area without its children
1445 RgnHandle ownUpdateRgn
= NewRgn() ;
1446 CopyRgn( updatergn
, ownUpdateRgn
) ;
1447 // subtract all children from updatergn, as soon as we start with transparent windows, these should
1448 // not be subtracted
1450 RgnHandle childarea
= NewRgn() ;
1451 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1453 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1455 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() )
1457 SetRectRgn( childarea
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1458 DiffRgn( ownUpdateRgn
, childarea
, ownUpdateRgn
) ;
1461 DisposeRgn( childarea
) ;
1463 // now intersect this with the client area
1464 // and shift it to client coordinates
1466 RgnHandle newupdate
= NewRgn() ;
1467 wxSize point
= GetClientSize() ;
1468 wxPoint origin
= GetClientAreaOrigin() ;
1470 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1471 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1472 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1473 m_updateRegion
= newupdate
;
1474 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1475 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1477 wxWindowDC
dc(this);
1478 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1479 wxEraseEvent
eevent( GetId(), &dc
);
1480 eevent
.SetEventObject( this );
1481 GetEventHandler()->ProcessEvent( eevent
);
1483 wxNcPaintEvent
eventNc( GetId() );
1484 eventNc
.SetEventObject( this );
1485 GetEventHandler()->ProcessEvent( eventNc
);
1487 DisposeRgn( ownUpdateRgn
) ;
1488 if ( !m_updateRegion
.Empty() )
1491 event
.m_timeStamp
= time
;
1492 event
.SetEventObject(this);
1493 GetEventHandler()->ProcessEvent(event
);
1497 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1499 RgnHandle childupdate
= NewRgn() ;
1500 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1502 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1503 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1504 SectRgn( childupdate
, updatergn
, childupdate
) ;
1505 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1506 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1508 // because dialogs may also be children
1509 child
->MacRedraw( childupdate
, time
, erase
) ;
1512 DisposeRgn( childupdate
) ;
1513 // eventually a draw grow box here
1517 WindowRef
wxWindowMac::MacGetRootWindow() const
1519 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1523 if ( iter
->IsTopLevel() )
1524 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1526 iter
= iter
->GetParent() ;
1528 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1532 void wxWindowMac::MacCreateScrollBars( long style
)
1534 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1536 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1537 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1539 GetClientSize( &width
, &height
) ;
1541 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1542 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1543 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1544 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1546 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1547 vSize
, wxVERTICAL
);
1549 if ( style
& wxVSCROLL
)
1555 m_vScrollBar
->Show(false) ;
1557 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1558 hSize
, wxHORIZONTAL
);
1559 if ( style
& wxHSCROLL
)
1564 m_hScrollBar
->Show(false) ;
1567 // because the create does not take into account the client area origin
1568 MacRepositionScrollBars() ; // we might have a real position shift
1571 void wxWindowMac::MacRepositionScrollBars()
1573 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1574 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1576 // get real client area
1578 int width
= m_width
;
1579 int height
= m_height
;
1581 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1582 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1584 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1585 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1586 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1587 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1594 MacClientToRootWindow( &x
, &y
) ;
1595 MacClientToRootWindow( &w
, &h
) ;
1597 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1599 int totW
= 10000 , totH
= 10000;
1602 if ( iter
->IsTopLevel() )
1604 totW
= iter
->m_width
;
1605 totH
= iter
->m_height
;
1609 iter
= iter
->GetParent() ;
1637 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1641 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1645 bool wxWindowMac::AcceptsFocus() const
1647 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1650 ControlHandle
wxWindowMac::MacGetContainerForEmbedding()
1652 return GetParent()->MacGetContainerForEmbedding() ;
1655 void wxWindowMac::MacSuperChangedPosition()
1657 // only window-absolute structures have to be moved i.e. controls
1659 wxNode
*node
= GetChildren().First();
1662 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1663 child
->MacSuperChangedPosition() ;
1664 node
= node
->Next();
1668 void wxWindowMac::MacTopLevelWindowChangedPosition()
1670 // only screen-absolute structures have to be moved i.e. glcanvas
1672 wxNode
*node
= GetChildren().First();
1675 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1676 child
->MacTopLevelWindowChangedPosition() ;
1677 node
= node
->Next();
1681 bool wxWindowMac::MacSetPortFocusParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* win
)
1683 if ( window
== NULL
)
1689 ::GetPort(&currPort
);
1690 port
= UMAGetWindowPort( window
) ;
1691 if (currPort
!= port
)
1694 // wxASSERT( port->portRect.left == 0 && port->portRect.top == 0 ) ;
1695 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1699 bool wxWindowMac::MacSetPortDrawingParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* win
)
1701 if ( window
== NULL
)
1706 ::GetPort(&currPort
);
1707 port
= UMAGetWindowPort( window
) ;
1708 if (currPort
!= port
)
1710 // wxASSERT( port->portRect.left == 0 && port->portRect.top == 0 ) ;
1711 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1712 ::ClipRect(&clipRect
);
1715 ::RGBBackColor(& win
->GetBackgroundColour().GetPixel() ) ;
1716 ::RGBForeColor(& win
->GetForegroundColour().GetPixel() ) ;
1717 Pattern whiteColor
;
1719 ::BackPat( GetQDGlobalsWhite( &whiteColor
) ) ;
1720 // ::SetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
1724 void wxWindowMac::MacGetPortParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1726 wxASSERT( GetParent() != NULL
) ;
1727 GetParent()->MacGetPortParams( localOrigin
, clipRect
, window
, rootwin
) ;
1728 localOrigin
->h
+= m_x
;
1729 localOrigin
->v
+= m_y
;
1730 OffsetRect(clipRect
, -m_x
, -m_y
);
1735 myClip
.right
= m_width
;
1736 myClip
.bottom
= m_height
;
1737 SectRect(clipRect
, &myClip
, clipRect
);
1740 void wxWindowMac::MacDoGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1742 wxASSERT( GetParent() != NULL
) ;
1744 GetParent()->MacDoGetPortClientParams( localOrigin
, clipRect
, window
, rootwin
) ;
1746 localOrigin
->h
+= m_x
;
1747 localOrigin
->v
+= m_y
;
1748 OffsetRect(clipRect
, -m_x
, -m_y
);
1753 myClip
.right
= m_width
;//width;
1754 myClip
.bottom
= m_height
;// height;
1755 SectRect(clipRect
, &myClip
, clipRect
);
1758 void wxWindowMac::MacGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1760 MacDoGetPortClientParams( localOrigin
, clipRect
, window
, rootwin
) ;
1762 int width
, height
;
1763 GetClientSize( &width
, &height
) ;
1765 client
= GetClientAreaOrigin( ) ;
1767 localOrigin
->h
+= client
.x
;
1768 localOrigin
->v
+= client
.y
;
1769 OffsetRect(clipRect
, -client
.x
, -client
.y
);
1774 myClip
.right
= width
;
1775 myClip
.bottom
= height
;
1776 SectRect(clipRect
, &myClip
, clipRect
);
1779 long wxWindowMac::MacGetLeftBorderSize( ) const
1784 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1787 #if wxMAC_USE_THEME_BORDER
1789 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1794 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1797 #if wxMAC_USE_THEME_BORDER
1799 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1804 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1811 long wxWindowMac::MacGetRightBorderSize( ) const
1813 // they are all symmetric in mac themes
1814 return MacGetLeftBorderSize() ;
1817 long wxWindowMac::MacGetTopBorderSize( ) const
1819 // they are all symmetric in mac themes
1820 return MacGetLeftBorderSize() ;
1823 long wxWindowMac::MacGetBottomBorderSize( ) const
1825 // they are all symmetric in mac themes
1826 return MacGetLeftBorderSize() ;
1829 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1831 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1835 wxMacDrawingHelper::wxMacDrawingHelper( wxWindowMac
* theWindow
)
1841 wxWindowMac
*rootwin
;
1842 m_currentPort
= NULL
;
1844 GetPort( &m_formerPort
) ;
1847 theWindow
->MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1848 m_currentPort
= UMAGetWindowPort( window
) ;
1849 if ( m_formerPort
!= m_currentPort
)
1850 SetPort( m_currentPort
) ;
1851 GetPenState( &m_savedPenState
) ;
1852 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1857 wxMacDrawingHelper::~wxMacDrawingHelper()
1861 SetPort( m_currentPort
) ;
1862 SetPenState( &m_savedPenState
) ;
1863 SetOrigin( 0 , 0 ) ;
1865 GetPortBounds( m_currentPort
, &portRect
) ;
1866 ClipRect( &portRect
) ;
1869 if ( m_formerPort
!= m_currentPort
)
1870 SetPort( m_formerPort
) ;
1873 wxMacDrawingClientHelper::wxMacDrawingClientHelper( wxWindowMac
* theWindow
)
1879 wxWindowMac
*rootwin
;
1880 m_currentPort
= NULL
;
1882 GetPort( &m_formerPort
) ;
1886 theWindow
->MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1887 m_currentPort
= UMAGetWindowPort( window
) ;
1888 if ( m_formerPort
!= m_currentPort
)
1889 SetPort( m_currentPort
) ;
1890 GetPenState( &m_savedPenState
) ;
1891 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1896 wxMacDrawingClientHelper::~wxMacDrawingClientHelper()
1900 SetPort( m_currentPort
) ;
1901 SetPenState( &m_savedPenState
) ;
1902 SetOrigin( 0 , 0 ) ;
1904 GetPortBounds( m_currentPort
, &portRect
) ;
1905 ClipRect( &portRect
) ;
1908 if ( m_formerPort
!= m_currentPort
)
1909 SetPort( m_formerPort
) ;
1912 // Find the wxWindowMac at the current mouse position, returning the mouse
1914 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1916 pt
= wxGetMousePosition();
1917 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1921 // Get the current mouse position.
1922 wxPoint
wxGetMousePosition()
1925 wxGetMousePosition(& x
, & y
);
1926 return wxPoint(x
, y
);