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
1443 RgnHandle eraseRgn
= NewRgn() ;
1444 CopyRgn( ownUpdateRgn
, eraseRgn
) ;
1446 RgnHandle childarea
= NewRgn() ;
1447 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1449 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1451 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() )
1453 SetRectRgn( childarea
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1454 DiffRgn( eraseRgn
, childarea
, eraseRgn
) ;
1457 DisposeRgn( childarea
) ;
1459 // now intersect this with the client area
1460 // and shift it to client coordinates
1462 RgnHandle newupdate
= NewRgn() ;
1463 wxSize point
= GetClientSize() ;
1464 wxPoint origin
= GetClientAreaOrigin() ;
1466 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1467 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1468 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1469 m_updateRegion
= newupdate
;
1470 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1471 if ( erase
&& !EmptyRgn(eraseRgn
) )
1473 wxWindowDC
dc(this);
1474 dc
.SetClippingRegion(wxRegion(eraseRgn
));
1475 wxEraseEvent
eevent( GetId(), &dc
);
1476 eevent
.SetEventObject( this );
1477 GetEventHandler()->ProcessEvent( eevent
);
1479 wxNcPaintEvent
eventNc( GetId() );
1480 eventNc
.SetEventObject( this );
1481 GetEventHandler()->ProcessEvent( eventNc
);
1483 DisposeRgn( ownUpdateRgn
) ;
1484 DisposeRgn( eraseRgn
) ;
1485 if ( !m_updateRegion
.Empty() )
1488 event
.m_timeStamp
= time
;
1489 event
.SetEventObject(this);
1490 GetEventHandler()->ProcessEvent(event
);
1494 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1496 RgnHandle childupdate
= NewRgn() ;
1497 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1499 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1500 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1501 SectRgn( childupdate
, updatergn
, childupdate
) ;
1502 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1503 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1505 // because dialogs may also be children
1506 child
->MacRedraw( childupdate
, time
, erase
) ;
1509 DisposeRgn( childupdate
) ;
1510 // eventually a draw grow box here
1514 WindowRef
wxWindowMac::MacGetRootWindow() const
1516 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1520 if ( iter
->IsTopLevel() )
1521 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1523 iter
= iter
->GetParent() ;
1525 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1529 void wxWindowMac::MacCreateScrollBars( long style
)
1531 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1533 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1534 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1536 GetClientSize( &width
, &height
) ;
1538 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1539 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1540 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1541 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1543 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1544 vSize
, wxVERTICAL
);
1546 if ( style
& wxVSCROLL
)
1552 m_vScrollBar
->Show(false) ;
1554 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1555 hSize
, wxHORIZONTAL
);
1556 if ( style
& wxHSCROLL
)
1561 m_hScrollBar
->Show(false) ;
1564 // because the create does not take into account the client area origin
1565 MacRepositionScrollBars() ; // we might have a real position shift
1568 void wxWindowMac::MacRepositionScrollBars()
1570 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1571 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1573 // get real client area
1575 int width
= m_width
;
1576 int height
= m_height
;
1578 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1579 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1581 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1582 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1583 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1584 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1591 MacClientToRootWindow( &x
, &y
) ;
1592 MacClientToRootWindow( &w
, &h
) ;
1594 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1596 int totW
= 10000 , totH
= 10000;
1599 if ( iter
->IsTopLevel() )
1601 totW
= iter
->m_width
;
1602 totH
= iter
->m_height
;
1606 iter
= iter
->GetParent() ;
1634 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1638 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1642 bool wxWindowMac::AcceptsFocus() const
1644 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1647 ControlHandle
wxWindowMac::MacGetContainerForEmbedding()
1649 return GetParent()->MacGetContainerForEmbedding() ;
1652 void wxWindowMac::MacSuperChangedPosition()
1654 // only window-absolute structures have to be moved i.e. controls
1656 wxNode
*node
= GetChildren().First();
1659 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1660 child
->MacSuperChangedPosition() ;
1661 node
= node
->Next();
1665 void wxWindowMac::MacTopLevelWindowChangedPosition()
1667 // only screen-absolute structures have to be moved i.e. glcanvas
1669 wxNode
*node
= GetChildren().First();
1672 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1673 child
->MacTopLevelWindowChangedPosition() ;
1674 node
= node
->Next();
1678 bool wxWindowMac::MacSetPortFocusParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* win
)
1680 if ( window
== NULL
)
1686 ::GetPort(&currPort
);
1687 port
= UMAGetWindowPort( window
) ;
1688 if (currPort
!= port
)
1691 // wxASSERT( port->portRect.left == 0 && port->portRect.top == 0 ) ;
1692 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1696 bool wxWindowMac::MacSetPortDrawingParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* win
)
1698 if ( window
== NULL
)
1703 ::GetPort(&currPort
);
1704 port
= UMAGetWindowPort( window
) ;
1705 if (currPort
!= port
)
1707 // wxASSERT( port->portRect.left == 0 && port->portRect.top == 0 ) ;
1708 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1709 ::ClipRect(&clipRect
);
1712 ::RGBBackColor(& win
->GetBackgroundColour().GetPixel() ) ;
1713 ::RGBForeColor(& win
->GetForegroundColour().GetPixel() ) ;
1714 Pattern whiteColor
;
1716 ::BackPat( GetQDGlobalsWhite( &whiteColor
) ) ;
1717 // ::SetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
1721 void wxWindowMac::MacGetPortParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1723 wxASSERT( GetParent() != NULL
) ;
1724 GetParent()->MacGetPortParams( localOrigin
, clipRect
, window
, rootwin
) ;
1725 localOrigin
->h
+= m_x
;
1726 localOrigin
->v
+= m_y
;
1727 OffsetRect(clipRect
, -m_x
, -m_y
);
1732 myClip
.right
= m_width
;
1733 myClip
.bottom
= m_height
;
1734 SectRect(clipRect
, &myClip
, clipRect
);
1737 void wxWindowMac::MacDoGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1739 wxASSERT( GetParent() != NULL
) ;
1741 GetParent()->MacDoGetPortClientParams( localOrigin
, clipRect
, window
, rootwin
) ;
1743 localOrigin
->h
+= m_x
;
1744 localOrigin
->v
+= m_y
;
1745 OffsetRect(clipRect
, -m_x
, -m_y
);
1750 myClip
.right
= m_width
;//width;
1751 myClip
.bottom
= m_height
;// height;
1752 SectRect(clipRect
, &myClip
, clipRect
);
1755 void wxWindowMac::MacGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
)
1757 MacDoGetPortClientParams( localOrigin
, clipRect
, window
, rootwin
) ;
1759 int width
, height
;
1760 GetClientSize( &width
, &height
) ;
1762 client
= GetClientAreaOrigin( ) ;
1764 localOrigin
->h
+= client
.x
;
1765 localOrigin
->v
+= client
.y
;
1766 OffsetRect(clipRect
, -client
.x
, -client
.y
);
1771 myClip
.right
= width
;
1772 myClip
.bottom
= height
;
1773 SectRect(clipRect
, &myClip
, clipRect
);
1776 long wxWindowMac::MacGetLeftBorderSize( ) const
1781 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1784 #if wxMAC_USE_THEME_BORDER
1786 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1791 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1794 #if wxMAC_USE_THEME_BORDER
1796 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1801 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1808 long wxWindowMac::MacGetRightBorderSize( ) const
1810 // they are all symmetric in mac themes
1811 return MacGetLeftBorderSize() ;
1814 long wxWindowMac::MacGetTopBorderSize( ) const
1816 // they are all symmetric in mac themes
1817 return MacGetLeftBorderSize() ;
1820 long wxWindowMac::MacGetBottomBorderSize( ) const
1822 // they are all symmetric in mac themes
1823 return MacGetLeftBorderSize() ;
1826 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1828 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1832 wxMacDrawingHelper::wxMacDrawingHelper( wxWindowMac
* theWindow
)
1838 wxWindowMac
*rootwin
;
1839 m_currentPort
= NULL
;
1841 GetPort( &m_formerPort
) ;
1844 theWindow
->MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1845 m_currentPort
= UMAGetWindowPort( window
) ;
1846 if ( m_formerPort
!= m_currentPort
)
1847 SetPort( m_currentPort
) ;
1848 GetPenState( &m_savedPenState
) ;
1849 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1854 wxMacDrawingHelper::~wxMacDrawingHelper()
1858 SetPort( m_currentPort
) ;
1859 SetPenState( &m_savedPenState
) ;
1860 SetOrigin( 0 , 0 ) ;
1862 GetPortBounds( m_currentPort
, &portRect
) ;
1863 ClipRect( &portRect
) ;
1866 if ( m_formerPort
!= m_currentPort
)
1867 SetPort( m_formerPort
) ;
1870 wxMacDrawingClientHelper::wxMacDrawingClientHelper( wxWindowMac
* theWindow
)
1876 wxWindowMac
*rootwin
;
1877 m_currentPort
= NULL
;
1879 GetPort( &m_formerPort
) ;
1883 theWindow
->MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1884 m_currentPort
= UMAGetWindowPort( window
) ;
1885 if ( m_formerPort
!= m_currentPort
)
1886 SetPort( m_currentPort
) ;
1887 GetPenState( &m_savedPenState
) ;
1888 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1893 wxMacDrawingClientHelper::~wxMacDrawingClientHelper()
1897 SetPort( m_currentPort
) ;
1898 SetPenState( &m_savedPenState
) ;
1899 SetOrigin( 0 , 0 ) ;
1901 GetPortBounds( m_currentPort
, &portRect
) ;
1902 ClipRect( &portRect
) ;
1905 if ( m_formerPort
!= m_currentPort
)
1906 SetPort( m_formerPort
) ;
1909 // Find the wxWindowMac at the current mouse position, returning the mouse
1911 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1913 pt
= wxGetMousePosition();
1914 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1918 // Get the current mouse position.
1919 wxPoint
wxGetMousePosition()
1922 wxGetMousePosition(& x
, & y
);
1923 return wxPoint(x
, y
);