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
)
723 wxNode
*node
= GetChildren().First();
726 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
727 if ( child
->m_isShown
)
728 child
->MacSuperEnabled( enabled
) ;
733 bool wxWindowMac::MacIsReallyShown() const
735 if ( m_isShown
&& (m_parent
!= NULL
) ) {
736 return m_parent
->MacIsReallyShown();
740 bool status = m_isShown ;
741 wxWindowMac * win = this ;
742 while ( status && win->m_parent != NULL )
744 win = win->m_parent ;
745 status = win->m_isShown ;
751 int wxWindowMac::GetCharHeight() const
753 wxClientDC
dc ( (wxWindowMac
*)this ) ;
754 return dc
.GetCharHeight() ;
757 int wxWindowMac::GetCharWidth() const
759 wxClientDC
dc ( (wxWindowMac
*)this ) ;
760 return dc
.GetCharWidth() ;
763 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
764 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
766 const wxFont
*fontToUse
= theFont
;
770 wxClientDC
dc( (wxWindowMac
*) this ) ;
772 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
773 if ( externalLeading
)
774 *externalLeading
= le
;
784 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
785 * we always intersect with the entire window, not only with the client area
788 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
791 client
= GetClientAreaOrigin( ) ;
792 Rect clientrect
= { -client
.y
, -client
.x
, m_height
- client
.y
, m_width
- client
.x
} ;
795 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
796 SectRect( &clientrect
, &r
, &clientrect
) ;
798 if ( !EmptyRect( &clientrect
) )
800 int top
= 0 , left
= 0 ;
802 MacClientToRootWindow( &left
, &top
) ;
803 OffsetRect( &clientrect
, left
, top
) ;
805 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
809 #if wxUSE_CARET && WXWIN_COMPATIBILITY
810 // ---------------------------------------------------------------------------
811 // Caret manipulation
812 // ---------------------------------------------------------------------------
814 void wxWindowMac::CreateCaret(int w
, int h
)
816 SetCaret(new wxCaret(this, w
, h
));
819 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
821 wxFAIL_MSG("not implemented");
824 void wxWindowMac::ShowCaret(bool show
)
826 wxCHECK_RET( m_caret
, "no caret to show" );
831 void wxWindowMac::DestroyCaret()
836 void wxWindowMac::SetCaretPos(int x
, int y
)
838 wxCHECK_RET( m_caret
, "no caret to move" );
843 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
845 wxCHECK_RET( m_caret
, "no caret to get position of" );
847 m_caret
->GetPosition(x
, y
);
849 #endif // wxUSE_CARET
851 wxWindowMac
*wxGetActiveWindow()
853 // actually this is a windows-only concept
857 // Coordinates relative to the window
858 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
860 // We really dont move the mouse programmatically under mac
863 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
865 wxMacDrawingHelper
focus( this ) ;
868 WindowRef window
= MacGetRootWindow() ;
869 Rect rect
= {0, 0 , m_height
, m_width
} ;
870 RgnHandle updateRgn
= GetUpdateRegion().GetWXHRGN() ;
871 SetClip( event
.GetDC()->MacGetCurrentClipRgn() ) ;
873 if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
875 SetThemeWindowBackground( window
, kThemeBrushDocumentWindowBackground
, false ) ;
877 else if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
879 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
880 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
881 // either a non gray background color or a non control window
883 wxWindowMac
* parent
= GetParent() ;
886 if ( parent
->MacGetRootWindow() != window
)
888 // we are in a different window on the mac system
892 //if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() )
894 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
)
895 && parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
897 // if we have any other colours in the hierarchy
898 RGBBackColor( &parent
->m_backgroundColour
.GetPixel()) ;
901 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
902 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
905 GetRegionBounds( updateRgn
, &box
) ;
906 ::ApplyThemeBackground(kThemeBackgroundTabPane
, &box
, kThemeStateActive
,8,true);
913 // we have arrived at a non control item
918 parent
= parent
->GetParent() ;
922 // if there is nothing special -> use default
923 SetThemeWindowBackground( window
, kThemeBrushDialogBackgroundActive
, false ) ;
928 RGBBackColor( &m_backgroundColour
.GetPixel()) ;
933 // event.GetDC()->Clear() ;
936 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
938 wxMacDrawingHelper
focus( this ) ;
945 int wxWindowMac::GetScrollPos(int orient
) const
947 if ( orient
== wxHORIZONTAL
)
950 return m_hScrollBar
->GetThumbPosition() ;
955 return m_vScrollBar
->GetThumbPosition() ;
960 // This now returns the whole range, not just the number
961 // of positions that we can scroll.
962 int wxWindowMac::GetScrollRange(int orient
) const
964 if ( orient
== wxHORIZONTAL
)
967 return m_hScrollBar
->GetRange() ;
972 return m_vScrollBar
->GetRange() ;
977 int wxWindowMac::GetScrollThumb(int orient
) const
979 if ( orient
== wxHORIZONTAL
)
982 return m_hScrollBar
->GetThumbSize() ;
987 return m_vScrollBar
->GetThumbSize() ;
992 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
994 if ( orient
== wxHORIZONTAL
)
997 m_hScrollBar
->SetThumbPosition( pos
) ;
1002 m_vScrollBar
->SetThumbPosition( pos
) ;
1006 void wxWindowMac::MacPaintBorders( )
1011 RGBColor white
= { 0xFFFF, 0xFFFF , 0xFFFF } ;
1012 RGBColor black
= { 0x0000, 0x0000 , 0x0000 } ;
1013 RGBColor face
= { 0xDDDD, 0xDDDD , 0xDDDD } ;
1014 RGBColor shadow
= { 0x4444, 0x4444 , 0x4444 } ;
1017 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
1019 #if wxMAC_USE_THEME_BORDER
1020 Rect rect
= { 0 , 0 , m_height
, m_width
} ;
1023 GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
1024 InsetRect( &rect , border , border );
1025 DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
1028 DrawThemePrimaryGroup(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
1030 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
1031 RGBForeColor( &face
);
1032 MoveTo( 0 , m_height
- 2 );
1034 LineTo( m_width
- 2 , 0 );
1036 MoveTo( 2 , m_height
- 3 );
1037 LineTo( m_width
- 3 , m_height
- 3 );
1038 LineTo( m_width
- 3 , 2 );
1040 RGBForeColor( sunken
? &face
: &black
);
1041 MoveTo( 0 , m_height
- 1 );
1042 LineTo( m_width
- 1 , m_height
- 1 );
1043 LineTo( m_width
- 1 , 0 );
1045 RGBForeColor( sunken
? &shadow
: &white
);
1046 MoveTo( 1 , m_height
- 3 );
1048 LineTo( m_width
- 3 , 1 );
1050 RGBForeColor( sunken
? &white
: &shadow
);
1051 MoveTo( 1 , m_height
- 2 );
1052 LineTo( m_width
- 2 , m_height
- 2 );
1053 LineTo( m_width
- 2 , 1 );
1055 RGBForeColor( sunken
? &black
: &face
);
1056 MoveTo( 2 , m_height
- 4 );
1058 LineTo( m_width
- 4 , 2 );
1061 else if (HasFlag(wxSIMPLE_BORDER
))
1063 Rect rect
= { 0 , 0 , m_height
, m_width
} ;
1064 RGBForeColor( &black
) ;
1065 FrameRect( &rect
) ;
1069 // New function that will replace some of the above.
1070 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
1071 int range
, bool refresh
)
1073 if ( orient
== wxHORIZONTAL
)
1077 if ( range
== 0 || thumbVisible
>= range
)
1079 if ( m_hScrollBar
->IsShown() )
1080 m_hScrollBar
->Show(false) ;
1084 if ( !m_hScrollBar
->IsShown() )
1085 m_hScrollBar
->Show(true) ;
1086 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1094 if ( range
== 0 || thumbVisible
>= range
)
1096 if ( m_vScrollBar
->IsShown() )
1097 m_vScrollBar
->Show(false) ;
1101 if ( !m_vScrollBar
->IsShown() )
1102 m_vScrollBar
->Show(true) ;
1103 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1107 MacRepositionScrollBars() ;
1110 // Does a physical scroll
1111 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1113 wxMacDrawingClientHelper
focus( this ) ;
1116 int width
, height
;
1117 GetClientSize( &width
, &height
) ;
1119 Rect scrollrect
= { 0 , 0 , height
, width
} ;
1121 RgnHandle updateRgn
= NewRgn() ;
1122 ClipRect( &scrollrect
) ;
1125 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
1126 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1128 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1129 InvalWindowRgn( MacGetRootWindow() , updateRgn
) ;
1130 DisposeRgn( updateRgn
) ;
1133 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1135 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1136 if (child
== m_vScrollBar
) continue;
1137 if (child
== m_hScrollBar
) continue;
1138 if (child
->IsTopLevel()) continue;
1140 child
->GetPosition( &x
, &y
);
1142 child
->GetSize( &w
, &h
);
1143 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1148 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1150 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1152 wxScrollWinEvent wevent
;
1153 wevent
.SetPosition(event
.GetPosition());
1154 wevent
.SetOrientation(event
.GetOrientation());
1155 wevent
.m_eventObject
= this;
1157 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1158 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1160 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1161 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1163 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1164 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1166 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1167 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1169 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1170 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1172 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1173 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1175 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1176 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1179 GetEventHandler()->ProcessEvent(wevent
);
1183 // Get the window with the focus
1184 wxWindowMac
*wxWindowBase::FindFocus()
1186 return gFocusWindow
;
1189 #if WXWIN_COMPATIBILITY
1190 // If nothing defined for this, try the parent.
1191 // E.g. we may be a button loaded from a resource, with no callback function
1193 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1195 if ( GetEventHandler()->ProcessEvent(event
) )
1198 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1200 #endif // WXWIN_COMPATIBILITY_2
1202 #if WXWIN_COMPATIBILITY
1203 wxObject
* wxWindowMac::GetChild(int number
) const
1205 // Return a pointer to the Nth object in the Panel
1206 wxNode
*node
= GetChildren().First();
1209 node
= node
->Next();
1212 wxObject
*obj
= (wxObject
*)node
->Data();
1218 #endif // WXWIN_COMPATIBILITY
1220 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1222 // panel wants to track the window which was the last to have focus in it,
1223 // so we want to set ourselves as the window which last had focus
1225 // notice that it's also important to do it upwards the tree becaus
1226 // otherwise when the top level panel gets focus, it won't set it back to
1227 // us, but to some other sibling
1229 // CS:don't know if this is still needed:
1230 //wxChildFocusEvent eventFocus(this);
1231 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1236 void wxWindowMac::Clear()
1238 wxClientDC
dc(this);
1239 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1240 dc
.SetBackground(brush
);
1244 // Setup background and foreground colours correctly
1245 void wxWindowMac::SetupColours()
1248 SetBackgroundColour(GetParent()->GetBackgroundColour());
1251 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1254 // Check if we need to send a LEAVE event
1255 if (m_mouseInWindow)
1258 ::GetCursorPos(&pt);
1259 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1261 // Generate a LEAVE event
1262 m_mouseInWindow = FALSE;
1263 MSWOnMouseLeave(pt.x, pt.y, 0);
1268 // This calls the UI-update mechanism (querying windows for
1269 // menu/toolbar/control state information)
1273 // Raise the window to the top of the Z order
1274 void wxWindowMac::Raise()
1278 // Lower the window to the bottom of the Z order
1279 void wxWindowMac::Lower()
1283 void wxWindowMac::DoSetClientSize(int width
, int height
)
1285 if ( width
!= -1 || height
!= -1 )
1288 if ( width
!= -1 && m_vScrollBar
)
1289 width
+= MAC_SCROLLBAR_SIZE
;
1290 if ( height
!= -1 && m_vScrollBar
)
1291 height
+= MAC_SCROLLBAR_SIZE
;
1293 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1294 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1296 DoSetSize( -1 , -1 , width
, height
) ;
1301 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1303 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1305 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1306 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1309 WindowRef window
= MacGetRootWindow() ;
1311 wxPoint
newPoint( point
) ;
1316 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1318 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1319 // added the m_isShown test --dmazzoni
1320 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1322 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1331 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1334 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1335 if ( ::FindWindow( pt
, &window
) == 3 )
1337 wxPoint
point( screenpoint
) ;
1338 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1341 win
->ScreenToClient( point
) ;
1342 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1348 extern int wxBusyCursorCount
;
1350 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1352 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1353 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1357 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) )
1360 WindowRef window
= MacGetRootWindow() ;
1368 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1370 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1371 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1373 if (child
->MacDispatchMouseEvent(event
))
1381 if ( wxBusyCursorCount
== 0 )
1383 m_cursor
.MacInstall() ;
1386 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1388 // set focus to this window
1389 if (AcceptsFocus() && FindFocus()!=this)
1394 if ( event
.GetEventType() == wxEVT_MOTION
1395 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1396 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1397 wxToolTip::RelayEvent( this , event
);
1398 #endif // wxUSE_TOOLTIPS
1399 GetEventHandler()->ProcessEvent( event
) ;
1403 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1407 return m_tooltip
->GetTip() ;
1412 void wxWindowMac::Update()
1414 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1416 win
->MacUpdate( 0 ) ;
1419 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1421 wxTopLevelWindowMac
* win
= NULL
;
1422 WindowRef window
= MacGetRootWindow() ;
1425 win
= wxFindWinFromMacWindow( window
) ;
1430 void wxWindowMac::MacRedraw( RgnHandle updatergn
, long time
, bool erase
)
1432 // updatergn is always already clipped to our boundaries
1433 // it is in nc-coordinates
1435 WindowRef window
= MacGetRootWindow() ;
1438 // ownUpdateRgn is the area that this window has to invalidate i.e. its own area without its children
1439 RgnHandle ownUpdateRgn
= NewRgn() ;
1440 CopyRgn( updatergn
, ownUpdateRgn
) ;
1441 // subtract all children from updatergn, as soon as we start with transparent windows, these should
1442 // not be subtracted
1444 RgnHandle childarea
= NewRgn() ;
1445 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1447 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1449 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() )
1451 SetRectRgn( childarea
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1452 DiffRgn( ownUpdateRgn
, childarea
, ownUpdateRgn
) ;
1455 DisposeRgn( childarea
) ;
1457 // now intersect this with the client area
1458 // and shift it to client coordinates
1460 RgnHandle newupdate
= NewRgn() ;
1461 wxSize point
= GetClientSize() ;
1462 wxPoint origin
= GetClientAreaOrigin() ;
1464 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1465 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1466 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1467 m_updateRegion
= newupdate
;
1468 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1469 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1471 wxWindowDC
dc(this);
1472 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1473 wxEraseEvent
eevent( GetId(), &dc
);
1474 eevent
.SetEventObject( this );
1475 GetEventHandler()->ProcessEvent( eevent
);
1477 wxNcPaintEvent
eventNc( GetId() );
1478 eventNc
.SetEventObject( this );
1479 GetEventHandler()->ProcessEvent( eventNc
);
1481 DisposeRgn( ownUpdateRgn
) ;
1482 if ( !m_updateRegion
.Empty() )
1485 event
.m_timeStamp
= time
;
1486 event
.SetEventObject(this);
1487 GetEventHandler()->ProcessEvent(event
);
1491 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1493 RgnHandle childupdate
= NewRgn() ;
1494 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1496 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1497 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1498 SectRgn( childupdate
, updatergn
, childupdate
) ;
1499 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1500 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1502 // because dialogs may also be children
1503 child
->MacRedraw( childupdate
, time
, erase
) ;
1506 DisposeRgn( childupdate
) ;
1507 // eventually a draw grow box here
1511 WindowRef
wxWindowMac::MacGetRootWindow() const
1513 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1517 if ( iter
->IsTopLevel() )
1518 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1520 iter
= iter
->GetParent() ;
1522 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1526 void wxWindowMac::MacCreateScrollBars( long style
)
1528 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1530 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1531 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1533 GetClientSize( &width
, &height
) ;
1535 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1536 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1537 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1538 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1540 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1541 vSize
, wxVERTICAL
);
1543 if ( style
& wxVSCROLL
)
1549 m_vScrollBar
->Show(false) ;
1551 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1552 hSize
, wxHORIZONTAL
);
1553 if ( style
& wxHSCROLL
)
1558 m_hScrollBar
->Show(false) ;
1561 // because the create does not take into account the client area origin
1562 MacRepositionScrollBars() ; // we might have a real position shift
1565 void wxWindowMac::MacRepositionScrollBars()
1567 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1568 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1570 // get real client area
1572 int width
= m_width
;
1573 int height
= m_height
;
1575 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1576 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1578 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1579 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1580 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1581 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1588 MacClientToRootWindow( &x
, &y
) ;
1589 MacClientToRootWindow( &w
, &h
) ;
1591 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1593 int totW
= 10000 , totH
= 10000;
1596 if ( iter
->IsTopLevel() )
1598 totW
= iter
->m_width
;
1599 totH
= iter
->m_height
;
1603 iter
= iter
->GetParent() ;
1631 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1635 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1639 bool wxWindowMac::AcceptsFocus() const
1641 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1644 ControlHandle
wxWindowMac::MacGetContainerForEmbedding()
1646 return GetParent()->MacGetContainerForEmbedding() ;
1649 void wxWindowMac::MacSuperChangedPosition()
1651 // only window-absolute structures have to be moved i.e. controls
1653 wxNode
*node
= GetChildren().First();
1656 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1657 child
->MacSuperChangedPosition() ;
1658 node
= node
->Next();
1662 void wxWindowMac::MacTopLevelWindowChangedPosition()
1664 // only screen-absolute structures have to be moved i.e. glcanvas
1666 wxNode
*node
= GetChildren().First();
1669 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1670 child
->MacTopLevelWindowChangedPosition() ;
1671 node
= node
->Next();
1675 bool wxWindowMac::MacSetPortFocusParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* win
)
1677 if ( window
== NULL
)
1683 ::GetPort(&currPort
);
1684 port
= UMAGetWindowPort( window
) ;
1685 if (currPort
!= port
)
1688 // wxASSERT( port->portRect.left == 0 && port->portRect.top == 0 ) ;
1689 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1693 bool wxWindowMac::MacSetPortDrawingParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* win
)
1695 if ( window
== NULL
)
1700 ::GetPort(&currPort
);
1701 port
= UMAGetWindowPort( window
) ;
1702 if (currPort
!= port
)
1704 // wxASSERT( port->portRect.left == 0 && port->portRect.top == 0 ) ;
1705 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1706 ::ClipRect(&clipRect
);
1709 ::RGBBackColor(& win
->GetBackgroundColour().GetPixel() ) ;
1710 ::RGBForeColor(& win
->GetForegroundColour().GetPixel() ) ;
1711 Pattern whiteColor
;
1713 ::BackPat( GetQDGlobalsWhite( &whiteColor
) ) ;
1714 // ::SetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
1718 void wxWindowMac::MacGetPortParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1720 wxASSERT( GetParent() != NULL
) ;
1721 GetParent()->MacGetPortParams( localOrigin
, clipRect
, window
, rootwin
) ;
1722 localOrigin
->h
+= m_x
;
1723 localOrigin
->v
+= m_y
;
1724 OffsetRect(clipRect
, -m_x
, -m_y
);
1729 myClip
.right
= m_width
;
1730 myClip
.bottom
= m_height
;
1731 SectRect(clipRect
, &myClip
, clipRect
);
1734 void wxWindowMac::MacDoGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1736 wxASSERT( GetParent() != NULL
) ;
1738 GetParent()->MacDoGetPortClientParams( localOrigin
, clipRect
, window
, rootwin
) ;
1740 localOrigin
->h
+= m_x
;
1741 localOrigin
->v
+= m_y
;
1742 OffsetRect(clipRect
, -m_x
, -m_y
);
1747 myClip
.right
= m_width
;//width;
1748 myClip
.bottom
= m_height
;// height;
1749 SectRect(clipRect
, &myClip
, clipRect
);
1752 void wxWindowMac::MacGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1754 MacDoGetPortClientParams( localOrigin
, clipRect
, window
, rootwin
) ;
1756 int width
, height
;
1757 GetClientSize( &width
, &height
) ;
1759 client
= GetClientAreaOrigin( ) ;
1761 localOrigin
->h
+= client
.x
;
1762 localOrigin
->v
+= client
.y
;
1763 OffsetRect(clipRect
, -client
.x
, -client
.y
);
1768 myClip
.right
= width
;
1769 myClip
.bottom
= height
;
1770 SectRect(clipRect
, &myClip
, clipRect
);
1773 long wxWindowMac::MacGetLeftBorderSize( ) const
1778 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1781 #if wxMAC_USE_THEME_BORDER
1783 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1788 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1791 #if wxMAC_USE_THEME_BORDER
1793 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1798 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1805 long wxWindowMac::MacGetRightBorderSize( ) const
1807 // they are all symmetric in mac themes
1808 return MacGetLeftBorderSize() ;
1811 long wxWindowMac::MacGetTopBorderSize( ) const
1813 // they are all symmetric in mac themes
1814 return MacGetLeftBorderSize() ;
1817 long wxWindowMac::MacGetBottomBorderSize( ) const
1819 // they are all symmetric in mac themes
1820 return MacGetLeftBorderSize() ;
1823 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1825 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1829 wxMacDrawingHelper::wxMacDrawingHelper( wxWindowMac
* theWindow
)
1835 wxWindowMac
*rootwin
;
1836 m_currentPort
= NULL
;
1838 GetPort( &m_formerPort
) ;
1841 theWindow
->MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1842 m_currentPort
= UMAGetWindowPort( window
) ;
1843 if ( m_formerPort
!= m_currentPort
)
1844 SetPort( m_currentPort
) ;
1845 GetPenState( &m_savedPenState
) ;
1846 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1851 wxMacDrawingHelper::~wxMacDrawingHelper()
1855 SetPort( m_currentPort
) ;
1856 SetPenState( &m_savedPenState
) ;
1857 SetOrigin( 0 , 0 ) ;
1859 GetPortBounds( m_currentPort
, &portRect
) ;
1860 ClipRect( &portRect
) ;
1863 if ( m_formerPort
!= m_currentPort
)
1864 SetPort( m_formerPort
) ;
1867 wxMacDrawingClientHelper::wxMacDrawingClientHelper( wxWindowMac
* theWindow
)
1873 wxWindowMac
*rootwin
;
1874 m_currentPort
= NULL
;
1876 GetPort( &m_formerPort
) ;
1880 theWindow
->MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1881 m_currentPort
= UMAGetWindowPort( window
) ;
1882 if ( m_formerPort
!= m_currentPort
)
1883 SetPort( m_currentPort
) ;
1884 GetPenState( &m_savedPenState
) ;
1885 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1890 wxMacDrawingClientHelper::~wxMacDrawingClientHelper()
1894 SetPort( m_currentPort
) ;
1895 SetPenState( &m_savedPenState
) ;
1896 SetOrigin( 0 , 0 ) ;
1898 GetPortBounds( m_currentPort
, &portRect
) ;
1899 ClipRect( &portRect
) ;
1902 if ( m_formerPort
!= m_currentPort
)
1903 SetPort( m_formerPort
) ;
1906 // Find the wxWindowMac at the current mouse position, returning the mouse
1908 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1910 pt
= wxGetMousePosition();
1911 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1915 // Get the current mouse position.
1916 wxPoint
wxGetMousePosition()
1919 wxGetMousePosition(& x
, & y
);
1920 return wxPoint(x
, y
);