1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
19 #include "wx/dcclient.h"
23 #include "wx/layout.h"
24 #include "wx/dialog.h"
25 #include "wx/listbox.h"
26 #include "wx/button.h"
27 #include "wx/settings.h"
28 #include "wx/msgdlg.h"
30 #include "wx/notebook.h"
31 #include "wx/tabctrl.h"
32 // TODO remove the line below, just for lookup-up convenience CS
33 #include "wx/mac/window.h"
35 #include "wx/menuitem.h"
42 #define wxWINDOW_HSCROLL 5998
43 #define wxWINDOW_VSCROLL 5997
44 #define MAC_SCROLLBAR_SIZE 16
46 #include <wx/mac/uma.h>
48 #if wxUSE_DRAG_AND_DROP
54 extern wxList wxPendingDelete
;
55 wxWindow
* gFocusWindow
= NULL
;
57 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
59 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
60 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
61 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
62 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
63 EVT_IDLE(wxWindow::OnIdle
)
64 // EVT_SCROLL(wxWindow::OnScroll)
70 // ===========================================================================
72 // ===========================================================================
74 // ---------------------------------------------------------------------------
75 // wxWindow utility functions
76 // ---------------------------------------------------------------------------
78 // Find an item given the Macintosh Window Reference
80 wxList
*wxWinMacWindowList
= NULL
;
81 wxWindow
*wxFindWinFromMacWindow(WindowRef inWindowRef
)
83 wxNode
*node
= wxWinMacWindowList
->Find((long)inWindowRef
);
86 return (wxWindow
*)node
->Data();
89 void wxAssociateWinWithMacWindow(WindowRef inWindowRef
, wxWindow
*win
)
91 // adding NULL WindowRef is (first) surely a result of an error and
92 // (secondly) breaks menu command processing
93 wxCHECK_RET( inWindowRef
!= (WindowRef
) NULL
, "attempt to add a NULL WindowRef to window list" );
95 if ( !wxWinMacWindowList
->Find((long)inWindowRef
) )
96 wxWinMacWindowList
->Append((long)inWindowRef
, win
);
99 void wxRemoveMacWindowAssociation(wxWindow
*win
)
101 wxWinMacWindowList
->DeleteObject(win
);
104 // ----------------------------------------------------------------------------
105 // constructors and such
106 // ----------------------------------------------------------------------------
108 void wxWindow::Init()
114 m_doubleClickAllowed
= 0;
115 m_winCaptured
= FALSE
;
117 m_isBeingDeleted
= FALSE
;
120 m_mouseInWindow
= FALSE
;
124 m_backgroundTransparent
= FALSE
;
126 // as all windows are created with WS_VISIBLE style...
129 m_macWindowData
= NULL
;
136 m_hScrollBar
= NULL
;
137 m_vScrollBar
= NULL
;
139 #if wxUSE_DRAG_AND_DROP
140 m_pDropTarget
= NULL
;
145 wxWindow::~wxWindow()
147 m_isBeingDeleted
= TRUE
;
149 if ( s_lastMouseWindow
== this )
151 s_lastMouseWindow
= NULL
;
154 if ( gFocusWindow
== this )
156 gFocusWindow
= NULL
;
160 m_parent
->RemoveChild(this);
164 if ( m_macWindowData
)
166 UMADisposeWindow( m_macWindowData
->m_macWindow
) ;
167 delete m_macWindowData
;
168 wxRemoveMacWindowAssociation( this ) ;
173 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
177 const wxString
& name
)
179 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindow without parent") );
181 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
184 parent
->AddChild(this);
188 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
189 m_width
= WidthDefault( size
.x
);
190 m_height
= HeightDefault( size
.y
) ;
192 MacCreateScrollBars( style
) ;
197 void wxWindow::SetFocus()
199 if ( AcceptsFocus() )
205 if ( gFocusWindow
->m_caret
)
207 gFocusWindow
->m_caret
->OnKillFocus();
209 #endif // wxUSE_CARET
210 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
211 if ( control
&& control
->GetMacControl() )
213 UMASetKeyboardFocus( gFocusWindow
->GetMacRootWindow() , control
->GetMacControl() , kControlFocusNoPart
) ;
215 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
216 event
.SetEventObject(gFocusWindow
);
217 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
219 gFocusWindow
= this ;
225 m_caret
->OnSetFocus();
227 #endif // wxUSE_CARET
228 // panel wants to track the window which was the last to have focus in it
229 wxPanel
*panel
= wxDynamicCast(GetParent(), wxPanel
);
232 panel
->SetLastFocus(this);
234 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
235 if ( control
&& control
->GetMacControl() )
237 UMASetKeyboardFocus( gFocusWindow
->GetMacRootWindow() , control
->GetMacControl() , kControlEditTextPart
) ;
240 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
241 event
.SetEventObject(this);
242 GetEventHandler()->ProcessEvent(event
) ;
247 bool wxWindow::Enable(bool enable
)
249 if ( !wxWindowBase::Enable(enable
) )
252 HWND hWnd = GetHwnd();
254 ::EnableWindow(hWnd, (BOOL)enable);
257 wxWindowList::Node
*node
= GetChildren().GetFirst();
260 wxWindow
*child
= node
->GetData();
261 child
->Enable(enable
);
263 node
= node
->GetNext();
269 void wxWindow::CaptureMouse()
271 wxTheApp
->s_captureWindow
= this ;
274 void wxWindow::ReleaseMouse()
276 wxTheApp
->s_captureWindow
= NULL
;
279 #if wxUSE_DRAG_AND_DROP
281 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
283 if ( m_pDropTarget
!= 0 ) {
284 delete m_pDropTarget
;
287 m_pDropTarget
= pDropTarget
;
288 if ( m_pDropTarget
!= 0 )
296 // Old style file-manager drag&drop
297 void wxWindow::DragAcceptFiles(bool accept
)
303 void wxWindow::DoGetSize(int *x
, int *y
) const
309 void wxWindow::DoGetPosition(int *x
, int *y
) const
315 wxPoint
pt(GetParent()->GetClientAreaOrigin());
325 bool wxWindow::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
327 menu
->SetInvokingWindow(this);
329 ClientToScreen( &x
, &y
) ;
331 ::InsertMenu( menu
->GetHMenu() , -1 ) ;
332 long menuResult
= ::PopUpMenuSelect(menu
->GetHMenu() ,y
,x
, 0) ;
333 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
334 ::DeleteMenu( menu
->MacGetMenuId() ) ;
335 menu
->SetInvokingWindow(NULL
);
340 void wxWindow::DoScreenToClient(int *x
, int *y
) const
342 WindowRef window
= GetMacRootWindow() ;
350 ::SetPort( UMAGetWindowPort( window
) ) ;
351 ::GlobalToLocal( &localwhere
) ;
357 MacRootWindowToClient( x
, y
) ;
360 void wxWindow::DoClientToScreen(int *x
, int *y
) const
362 WindowRef window
= GetMacRootWindow() ;
364 MacClientToRootWindow( x
, y
) ;
372 ::SetPort( UMAGetWindowPort( window
) ) ;
373 ::LocalToGlobal( &localwhere
) ;
379 void wxWindow::MacClientToRootWindow( int *x
, int *y
) const
381 if ( m_macWindowData
)
388 GetParent()->MacClientToRootWindow( x
, y
) ;
392 void wxWindow::MacRootWindowToClient( int *x
, int *y
) const
394 if ( m_macWindowData
)
401 GetParent()->MacRootWindowToClient( x
, y
) ;
405 bool wxWindow::SetCursor(const wxCursor
& cursor
)
407 if ( !wxWindowBase::SetCursor(cursor
) )
413 wxASSERT_MSG( m_cursor
.Ok(),
414 wxT("cursor must be valid after call to the base version"));
420 // Change the cursor NOW if we're within the correct window
422 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
424 if ( mouseWin
== this && !wxIsBusy() )
426 cursor
.MacInstall() ;
434 // Get size *available for subwindows* i.e. excluding menu bar etc.
435 void wxWindow::DoGetClientSize(int *x
, int *y
) const
440 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
441 (*x
) -= MAC_SCROLLBAR_SIZE
;
442 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
443 (*y
) -= MAC_SCROLLBAR_SIZE
;
447 // ----------------------------------------------------------------------------
449 // ----------------------------------------------------------------------------
453 void wxWindow::DoSetToolTip(wxToolTip
*tooltip
)
455 wxWindowBase::DoSetToolTip(tooltip
);
458 // m_tooltip->SetWindow(this);
461 #endif // wxUSE_TOOLTIPS
463 void wxWindow::DoMoveWindow(int x
, int y
, int width
, int height
)
465 DoSetSize( x
,y
, width
, height
) ;
468 void wxWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
472 int former_w
= m_width
;
473 int former_h
= m_height
;
475 int currentX
, currentY
;
476 GetPosition(¤tX
, ¤tY
);
477 int currentW
,currentH
;
478 GetSize(¤tW
, ¤tH
);
480 int actualWidth
= width
;
481 int actualHeight
= height
;
484 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
486 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
489 actualWidth
= currentW
;
491 actualHeight
= currentH
;
493 if ( actualX
== currentX
&& actualY
== currentY
&& actualWidth
== currentW
&& actualHeight
== currentH
)
495 MacRepositionScrollBars() ; // we might have a real position shift
499 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
502 bool doMove
= false ;
503 bool doResize
= false ;
505 if ( actualX
!= former_x
|| actualY
!= former_y
)
509 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
514 if ( doMove
|| doResize
)
516 if ( m_macWindowData
)
521 // erase former position
523 wxMacDrawingClientHelper
focus( this ) ;
526 Rect clientrect
= { 0 , 0 , m_height
, m_width
} ;
527 InvalRect( &clientrect
) ;
533 m_width
= actualWidth
;
534 m_height
= actualHeight
;
535 if ( m_macWindowData
)
538 ::MoveWindow(m_macWindowData
->m_macWindow
, m_x
, m_y
, false); // don't make frontmost
541 ::SizeWindow(m_macWindowData
->m_macWindow
, m_width
, m_height
, true);
543 // the OS takes care of invalidating and erasing
545 if ( IsKindOf( CLASSINFO( wxFrame
) ) )
547 wxFrame
* frame
= (wxFrame
*) this ;
548 frame
->PositionStatusBar();
549 frame
->PositionToolBar();
554 // erase new position
556 wxMacDrawingClientHelper
focus( this ) ;
559 Rect clientrect
= { 0 , 0 , m_height
, m_width
} ;
560 InvalRect( &clientrect
) ;
564 wxWindow::MacSuperChangedPosition() ; // like this only children will be notified
566 MacRepositionScrollBars() ;
569 wxMoveEvent
event(wxPoint(m_x
, m_y
), m_windowId
);
570 event
.SetEventObject(this);
571 GetEventHandler()->ProcessEvent(event
) ;
575 MacRepositionScrollBars() ;
576 wxSizeEvent
event(wxSize(m_width
, m_height
), m_windowId
);
577 event
.SetEventObject(this);
578 GetEventHandler()->ProcessEvent(event
);
582 // For implementation purposes - sometimes decorations make the client area
585 wxPoint
wxWindow::GetClientAreaOrigin() const
587 return wxPoint(0, 0);
590 // Makes an adjustment to the window position (for example, a frame that has
591 // a toolbar that it manages itself).
592 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
594 if( !m_macWindowData
)
596 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
598 wxPoint
pt(GetParent()->GetClientAreaOrigin());
599 x
+= pt
.x
; y
+= pt
.y
;
604 void wxWindow::SetTitle(const wxString
& title
)
610 if( wxApp::s_macDefaultEncodingIsPC
)
611 label
= wxMacMakeMacStringFromPC( title
) ;
615 if ( m_macWindowData
)
616 UMASetWTitleC( m_macWindowData
->m_macWindow
, label
) ;
619 wxString
wxWindow::GetTitle() const
624 bool wxWindow::Show(bool show
)
626 if ( !wxWindowBase::Show(show
) )
629 if ( m_macWindowData
)
633 UMAShowWindow( m_macWindowData
->m_macWindow
) ;
634 UMASelectWindow( m_macWindowData
->m_macWindow
) ;
635 // no need to generate events here, they will get them triggered by macos
636 wxSizeEvent
event(wxSize(m_width
, m_height
), m_windowId
);
637 event
.SetEventObject(this);
638 GetEventHandler()->ProcessEvent(event
);
642 UMAHideWindow( m_macWindowData
->m_macWindow
) ;
645 MacSuperShown( show
) ;
651 void wxWindow::MacSuperShown( bool show
)
653 wxNode
*node
= GetChildren().First();
656 wxWindow
*child
= (wxWindow
*)node
->Data();
657 if ( child
->m_isShown
)
658 child
->MacSuperShown( show
) ;
663 int wxWindow::GetCharHeight() const
665 wxClientDC
dc ( (wxWindow
*)this ) ;
666 return dc
.GetCharHeight() ;
669 int wxWindow::GetCharWidth() const
671 wxClientDC
dc ( (wxWindow
*)this ) ;
672 return dc
.GetCharWidth() ;
675 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
676 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
678 const wxFont
*fontToUse
= theFont
;
682 wxClientDC
dc( this ) ;
684 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, fontToUse
) ;
685 *externalLeading
= le
;
691 void wxWindow::MacEraseBackground( Rect
*rect
)
693 WindowRef window
= GetMacRootWindow() ;
694 if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
696 UMASetThemeWindowBackground( window
, kThemeBrushDocumentWindowBackground
, false ) ;
698 else if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
700 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
701 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
702 // either a non gray background color or a non control window
704 wxWindow
* parent
= GetParent() ;
707 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
709 // if we have any other colours in the hierarchy
710 RGBBackColor( &parent
->m_backgroundColour
.GetPixel()) ;
713 if( parent
->IsKindOf( CLASSINFO( wxControl
) ) && ((wxControl
*)parent
)->GetMacControl() )
715 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
716 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
718 ApplyThemeBackground (kThemeBackgroundTabPane
, rect
, kThemeStateActive
,8,true);
724 // we have arrived at a non control item
728 parent
= parent
->GetParent() ;
732 // if there is nothing special -> use default
733 UMASetThemeWindowBackground( window
, kThemeBrushDialogBackgroundActive
, false ) ;
738 RGBBackColor( &m_backgroundColour
.GetPixel()) ;
743 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
745 wxWindow
*child
= (wxWindow
*)node
->Data();
749 // child->GetClientSize( &width , &height ) ;
751 Rect clientrect
= { child
->m_x
, child
->m_y
, child
->m_x
+child
->m_width
, child
->m_y
+ child
->m_height
} ;
752 SectRect( &clientrect
, rect
, &clientrect
) ;
754 OffsetRect( &clientrect
, -child
->m_x
, -child
->m_y
) ;
755 if ( child
->GetMacRootWindow() == window
&& child
->IsShown() )
757 wxMacDrawingClientHelper
focus( this ) ;
760 child
->MacEraseBackground( &clientrect
) ;
766 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
768 wxMacDrawingClientHelper
focus( this ) ;
772 GetClientSize( &width
, &height
) ;
773 Rect clientrect
= { 0 , 0 , height
, width
} ;
774 ClipRect( &clientrect
) ;
778 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
779 SectRect( &clientrect
, &r
, &clientrect
) ;
781 InvalRect( &clientrect
) ;
785 MacEraseBackground( &clientrect ) ;
791 // Responds to colour changes: passes event on to children.
792 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
794 wxNode
*node
= GetChildren().First();
797 // Only propagate to non-top-level windows
798 wxWindow
*win
= (wxWindow
*)node
->Data();
799 if ( win
->GetParent() )
801 wxSysColourChangedEvent event2
;
802 event
.m_eventObject
= win
;
803 win
->GetEventHandler()->ProcessEvent(event2
);
810 #if wxUSE_CARET && WXWIN_COMPATIBILITY
811 // ---------------------------------------------------------------------------
812 // Caret manipulation
813 // ---------------------------------------------------------------------------
815 void wxWindow::CreateCaret(int w
, int h
)
817 SetCaret(new wxCaret(this, w
, h
));
820 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
822 wxFAIL_MSG("not implemented");
825 void wxWindow::ShowCaret(bool show
)
827 wxCHECK_RET( m_caret
, "no caret to show" );
832 void wxWindow::DestroyCaret()
837 void wxWindow::SetCaretPos(int x
, int y
)
839 wxCHECK_RET( m_caret
, "no caret to move" );
844 void wxWindow::GetCaretPos(int *x
, int *y
) const
846 wxCHECK_RET( m_caret
, "no caret to get position of" );
848 m_caret
->GetPosition(x
, y
);
850 #endif // wxUSE_CARET
852 wxWindow
*wxGetActiveWindow()
854 // actually this is a windows-only concept
858 // Coordinates relative to the window
859 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
861 // We really dont move the mouse programmatically under mac
864 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
866 // TODO : probably we would adopt the EraseEvent structure
869 int wxWindow::GetScrollPos(int orient
) const
871 if ( orient
== wxHORIZONTAL
)
874 return m_hScrollBar
->GetThumbPosition() ;
879 return m_vScrollBar
->GetThumbPosition() ;
884 // This now returns the whole range, not just the number
885 // of positions that we can scroll.
886 int wxWindow::GetScrollRange(int orient
) const
888 if ( orient
== wxHORIZONTAL
)
891 return m_hScrollBar
->GetRange() ;
896 return m_vScrollBar
->GetRange() ;
901 int wxWindow::GetScrollThumb(int orient
) const
903 if ( orient
== wxHORIZONTAL
)
906 return m_hScrollBar
->GetThumbSize() ;
911 return m_vScrollBar
->GetThumbSize() ;
916 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
918 if ( orient
== wxHORIZONTAL
)
921 m_hScrollBar
->SetThumbPosition( pos
) ;
926 m_vScrollBar
->SetThumbPosition( pos
) ;
930 void wxWindow::MacPaint( wxPaintEvent
&event
)
935 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) )
937 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
939 wxPen
m_penButton3DShadow( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_3DSHADOW
), 1, wxSOLID
) ;
940 wxPen
m_penButton3DFace( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_3DFACE
), 1, wxSOLID
) ;
942 wxPen wxPen1
= sunken
? *wxWHITE_PEN
: *wxBLACK_PEN
;
943 wxPen wxPen2
= sunken
? m_penButton3DShadow
: m_penButton3DShadow
;
944 wxPen wxPen3
= sunken
? m_penButton3DFace
: m_penButton3DShadow
;
945 wxPen wxPen4
= sunken
? *wxBLACK_PEN
: *wxWHITE_PEN
;
948 dc
.DrawRectangle(0, 0, m_width
, m_height
); // outer - right and button
951 dc
.DrawRectangle(1, 1, m_width
-1, m_height
-1); // outer - left and top
954 dc
.DrawRectangle(0, 0, m_width
-2, m_height
-2); // inner - right and button
957 dc
.DrawLine(0, 0, m_width
-3, 0); // inner - left and top
958 dc
.DrawLine(0, 0, 0, m_height
-3);
960 else if (HasFlag(wxSIMPLE_BORDER
))
962 dc
.SetPen(*wxBLACK_PEN
);
963 dc
.DrawRectangle(0, 0, m_width
, m_height
);
967 // New function that will replace some of the above.
968 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
969 int range
, bool refresh
)
971 if ( orient
== wxHORIZONTAL
)
975 if ( range
== 0 || thumbVisible
>= range
)
977 if ( m_hScrollBar
->IsShown() )
978 m_hScrollBar
->Show(false) ;
982 if ( !m_hScrollBar
->IsShown() )
983 m_hScrollBar
->Show(true) ;
984 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, refresh
) ;
992 if ( range
== 0 || thumbVisible
>= range
)
994 if ( m_vScrollBar
->IsShown() )
995 m_vScrollBar
->Show(false) ;
999 if ( !m_vScrollBar
->IsShown() )
1000 m_vScrollBar
->Show(true) ;
1001 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, refresh
) ;
1005 MacRepositionScrollBars() ;
1008 // Does a physical scroll
1009 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1011 wxMacDrawingClientHelper
focus( this ) ;
1014 int width
, height
;
1015 GetClientSize( &width
, &height
) ;
1016 Rect scrollrect
= { 0 , 0 , height
, width
} ;
1018 RgnHandle updateRgn
= NewRgn() ;
1019 ClipRect( &scrollrect
) ;
1022 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
1023 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1025 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1026 InvalRgn( updateRgn
) ;
1027 DisposeRgn( updateRgn
) ;
1031 void wxWindow::MacOnScroll(wxScrollEvent
&event
)
1033 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1035 wxScrollWinEvent wevent
;
1036 wevent
.SetPosition(event
.GetPosition());
1037 wevent
.SetOrientation(event
.GetOrientation());
1038 wevent
.m_eventObject
= this;
1040 switch ( event
.m_eventType
)
1042 case wxEVT_SCROLL_TOP
:
1043 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1046 case wxEVT_SCROLL_BOTTOM
:
1047 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1050 case wxEVT_SCROLL_LINEUP
:
1051 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1054 case wxEVT_SCROLL_LINEDOWN
:
1055 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1058 case wxEVT_SCROLL_PAGEUP
:
1059 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1062 case wxEVT_SCROLL_PAGEDOWN
:
1063 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1066 case wxEVT_SCROLL_THUMBTRACK
:
1067 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1072 GetEventHandler()->ProcessEvent(wevent
);
1076 bool wxWindow::SetFont(const wxFont
& font
)
1078 if ( !wxWindowBase::SetFont(font
) )
1087 // Get the window with the focus
1088 wxWindow
*wxWindowBase::FindFocus()
1090 return gFocusWindow
;
1093 #if WXWIN_COMPATIBILITY
1094 // If nothing defined for this, try the parent.
1095 // E.g. we may be a button loaded from a resource, with no callback function
1097 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
1099 if ( GetEventHandler()->ProcessEvent(event
) )
1102 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1104 #endif // WXWIN_COMPATIBILITY_2
1106 #if WXWIN_COMPATIBILITY
1107 wxObject
* wxWindow::GetChild(int number
) const
1109 // Return a pointer to the Nth object in the Panel
1110 wxNode
*node
= GetChildren().First();
1113 node
= node
->Next();
1116 wxObject
*obj
= (wxObject
*)node
->Data();
1122 #endif // WXWIN_COMPATIBILITY
1124 void wxWindow::Clear()
1126 if ( m_macWindowData
)
1128 wxMacDrawingClientHelper
helper ( this ) ;
1130 wxPoint origin
= GetClientAreaOrigin() ;
1131 GetClientSize( &w
, &h
) ;
1132 UMASetThemeWindowBackground( m_macWindowData
->m_macWindow
, m_macWindowData
->m_macWindowBackgroundTheme
, false ) ;
1133 Rect r
= { origin
.y
, origin
.x
, origin
.y
+h
, origin
.x
+w
} ;
1138 wxClientDC
dc(this);
1139 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1140 dc
.SetBackground(brush
);
1145 // Setup background and foreground colours correctly
1146 void wxWindow::SetupColours()
1149 SetBackgroundColour(GetParent()->GetBackgroundColour());
1152 void wxWindow::OnIdle(wxIdleEvent
& event
)
1155 // Check if we need to send a LEAVE event
1156 if (m_mouseInWindow)
1159 ::GetCursorPos(&pt);
1160 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1162 // Generate a LEAVE event
1163 m_mouseInWindow = FALSE;
1164 MSWOnMouseLeave(pt.x, pt.y, 0);
1169 // This calls the UI-update mechanism (querying windows for
1170 // menu/toolbar/control state information)
1174 // Raise the window to the top of the Z order
1175 void wxWindow::Raise()
1180 // Lower the window to the bottom of the Z order
1181 void wxWindow::Lower()
1186 void wxWindow::DoSetClientSize(int width
, int height
)
1188 if ( width
!= -1 || height
!= -1 )
1191 if ( width
!= -1 && m_vScrollBar
)
1192 width
+= MAC_SCROLLBAR_SIZE
;
1193 if ( height
!= -1 && m_vScrollBar
)
1194 height
+= MAC_SCROLLBAR_SIZE
;
1196 DoSetSize( -1 , -1 , width
, height
) ;
1201 wxWindow
* wxWindow::s_lastMouseWindow
= NULL
;
1203 bool wxWindow::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindow
** outWin
)
1205 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1206 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1209 WindowRef window
= GetMacRootWindow() ;
1211 wxPoint
newPoint( point
) ;
1216 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1218 wxWindow
*child
= (wxWindow
*)node
->Data();
1219 if ( child
->GetMacRootWindow() == window
)
1221 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1230 bool wxWindow::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindow
** outWin
)
1233 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1234 if ( ::FindWindow( pt
, &window
) == 3 )
1236 wxPoint
point( screenpoint
) ;
1237 wxWindow
* win
= wxFindWinFromMacWindow( window
) ;
1238 win
->ScreenToClient( point
) ;
1239 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1244 extern int wxBusyCursorCount
;
1246 bool wxWindow::MacDispatchMouseEvent(wxMouseEvent
& event
)
1248 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1249 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1252 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) )
1255 WindowRef window
= GetMacRootWindow() ;
1263 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1265 wxWindow
*child
= (wxWindow
*)node
->Data();
1266 if ( child
->GetMacRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1268 if (child
->MacDispatchMouseEvent(event
))
1276 if ( wxBusyCursorCount
== 0 )
1278 m_cursor
.MacInstall() ;
1280 GetEventHandler()->ProcessEvent( event
) ;
1284 void wxWindow::MacFireMouseEvent( EventRecord
*ev
)
1286 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
1287 bool isDown
= !(ev
->modifiers
& btnState
) ; // 1 is for up
1288 bool controlDown
= ev
->modifiers
& controlKey
; // for simulating right mouse
1290 event
.m_leftDown
= isDown
&& !controlDown
;
1291 event
.m_middleDown
= FALSE
;
1292 event
.m_rightDown
= isDown
&& controlDown
;
1294 if ( ev
->what
== mouseDown
)
1297 event
.SetEventType(wxEVT_RIGHT_DOWN
) ;
1299 event
.SetEventType(wxEVT_LEFT_DOWN
) ;
1301 else if ( ev
->what
== mouseUp
)
1304 event
.SetEventType(wxEVT_RIGHT_UP
) ;
1306 event
.SetEventType(wxEVT_LEFT_UP
) ;
1310 event
.SetEventType(wxEVT_MOTION
) ;
1313 event
.m_shiftDown
= ev
->modifiers
& shiftKey
;
1314 event
.m_controlDown
= ev
->modifiers
& controlKey
;
1315 event
.m_altDown
= ev
->modifiers
& optionKey
;
1316 event
.m_metaDown
= ev
->modifiers
& cmdKey
;
1318 Point localwhere
= ev
->where
;
1321 ::GetPort( &port
) ;
1322 ::SetPort( UMAGetWindowPort( m_macWindowData
->m_macWindow
) ) ;
1323 ::GlobalToLocal( &localwhere
) ;
1326 event
.m_x
= localwhere
.h
;
1327 event
.m_y
= localwhere
.v
;
1332 wxPoint origin = GetClientAreaOrigin() ;
1334 event.m_x += origin.x ;
1335 event.m_y += origin.y ;
1338 event
.m_timeStamp
= ev
->when
;
1339 event
.SetEventObject(this);
1340 if ( wxTheApp
->s_captureWindow
)
1344 wxTheApp
->s_captureWindow
->ScreenToClient( &x
, &y
) ;
1347 wxTheApp
->s_captureWindow
->GetEventHandler()->ProcessEvent( event
) ;
1348 if ( ev
->what
== mouseUp
)
1350 wxTheApp
->s_captureWindow
= NULL
;
1351 if ( wxBusyCursorCount
== 0 )
1353 m_cursor
.MacInstall() ;
1359 MacDispatchMouseEvent( event
) ;
1363 void wxWindow::MacMouseDown( EventRecord
*ev
, short part
)
1365 MacFireMouseEvent( ev
) ;
1368 void wxWindow::MacMouseUp( EventRecord
*ev
, short part
)
1370 WindowPtr frontWindow
;
1375 MacFireMouseEvent( ev
) ;
1381 void wxWindow::MacMouseMoved( EventRecord
*ev
, short part
)
1383 WindowPtr frontWindow
;
1388 MacFireMouseEvent( ev
) ;
1393 void wxWindow::MacActivate( EventRecord
*ev
, bool inIsActivating
)
1395 wxActivateEvent
event(wxEVT_ACTIVATE
, inIsActivating
);
1396 event
.m_timeStamp
= ev
->when
;
1397 event
.SetEventObject(this);
1399 GetEventHandler()->ProcessEvent(event
);
1401 UMAHighlightAndActivateWindow( m_macWindowData
->m_macWindow
, inIsActivating
) ;
1404 void wxWindow::MacRedraw( RgnHandle updatergn
, long time
)
1406 // updatergn is always already clipped to our boundaries
1407 WindowRef window
= GetMacRootWindow() ;
1408 wxWindow
* win
= wxFindWinFromMacWindow( window
) ;
1410 wxMacDrawingClientHelper
focus( this ) ;
1413 WindowRef window
= GetMacRootWindow() ;
1414 bool eraseBackground
= false ;
1415 if ( m_macWindowData
)
1416 eraseBackground
= true ;
1417 if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
1419 UMASetThemeWindowBackground( window
, kThemeBrushDocumentWindowBackground
, false ) ;
1421 else if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
1423 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
1424 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
1425 // either a non gray background color or a non control window
1428 wxWindow
* parent
= GetParent() ;
1431 if ( parent
->GetMacRootWindow() != window
)
1433 // we are in a different window on the mac system
1438 if( parent
->IsKindOf( CLASSINFO( wxControl
) ) && ((wxControl
*)parent
)->GetMacControl() )
1440 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
1442 // if we have any other colours in the hierarchy
1443 RGBBackColor( &parent
->m_backgroundColour
.GetPixel()) ;
1446 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
1447 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
1449 ApplyThemeBackground(kThemeBackgroundTabPane
, &(**updatergn
).rgnBBox
, kThemeStateActive
,8,true);
1458 parent
= parent
->GetParent() ;
1462 // if there is nothing special -> use default
1463 UMASetThemeWindowBackground( window
, kThemeBrushDialogBackgroundActive
, false ) ;
1468 RGBBackColor( &m_backgroundColour
.GetPixel()) ;
1470 if ( GetParent() && m_backgroundColour
!= GetParent()->GetBackgroundColour() )
1471 eraseBackground
= true ;
1472 SetClip( updatergn
) ;
1473 if ( eraseBackground
)
1475 EraseRgn( updatergn
) ;
1481 m_updateRegion
= updatergn
;
1483 event
.m_timeStamp
= time
;
1484 event
.SetEventObject(this);
1486 wxPaintEvent
event2( event
) ;
1487 GetEventHandler()->ProcessEvent(event
);
1488 MacPaint( event2
) ;
1490 RgnHandle childupdate
= NewRgn() ;
1492 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1494 wxWindow
*child
= (wxWindow
*)node
->Data();
1498 child
->GetClientSize( &width
, &height
) ;
1500 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+width
, child
->m_y
+ height
) ;
1501 SectRgn( childupdate
, m_updateRegion
.GetWXHRGN() , childupdate
) ;
1502 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1503 if ( child
->GetMacRootWindow() == window
&& child
->IsShown() )
1505 // because dialogs may also be children
1506 child
->MacRedraw( childupdate
, time
) ;
1509 DisposeRgn( childupdate
) ;
1510 // eventually a draw grow box here
1513 void wxWindow::MacUpdateImmediately()
1515 WindowRef window
= GetMacRootWindow() ;
1518 wxWindow
* win
= wxFindWinFromMacWindow( window
) ;
1519 BeginUpdate( window
) ;
1523 if ( !EmptyRgn( window
->visRgn
) )
1526 win
->MacRedraw( window
->visRgn
, wxTheApp
->sm_lastMessageTime
) ;
1529 wxMacDrawingHelper help( win ) ;
1530 SetOrigin( 0 , 0 ) ;
1531 UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
1532 UMAUpdateControls( window , window->visRgn ) ;
1533 UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
1538 EndUpdate( window
) ;
1542 void wxWindow::MacUpdate( EventRecord
*ev
)
1544 WindowRef window
= (WindowRef
) ev
->message
;
1545 wxWindow
* win
= wxFindWinFromMacWindow( window
) ;
1547 BeginUpdate( window
) ;
1550 // if windowshade gives incompatibility , take the follwing out
1552 if ( !EmptyRgn( window
->visRgn
) )
1555 MacRedraw( window
->visRgn
, ev
->when
) ;
1558 wxMacDrawingHelper help( this ) ;
1559 SetOrigin( 0 , 0 ) ;
1560 UMASetThemeWindowBackground( m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
1561 UMAUpdateControls( window , window->visRgn ) ;
1562 UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ;
1567 EndUpdate( window
) ;
1570 WindowRef
wxWindow::GetMacRootWindow() const
1572 WindowRef window
= NULL
;
1573 wxWindow
*iter
= (wxWindow
*)this ;
1577 if ( iter
->m_macWindowData
)
1578 return iter
->m_macWindowData
->m_macWindow
;
1580 iter
= iter
->GetParent() ;
1582 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1586 void wxWindow::MacCreateScrollBars( long style
)
1588 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1589 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1590 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1592 if ( style
& wxVSCROLL
)
1594 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, wxPoint(m_width
-MAC_SCROLLBAR_SIZE
, 0),
1595 wxSize(MAC_SCROLLBAR_SIZE
, m_height
- adjust
), wxVERTICAL
);
1596 // m_vScrollBar->PushEventHandler( this ) ;
1598 if ( style
& wxHSCROLL
)
1600 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, wxPoint(0 , m_height
-MAC_SCROLLBAR_SIZE
),
1601 wxSize( m_width
- adjust
, MAC_SCROLLBAR_SIZE
), wxHORIZONTAL
);
1602 // m_hScrollBar->PushEventHandler( this ) ;
1605 // because the create does not take into account the client area origin
1606 MacRepositionScrollBars() ; // we might have a real position shift
1609 void wxWindow::MacRepositionScrollBars()
1611 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1612 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1616 m_vScrollBar
->SetSize( m_width
-MAC_SCROLLBAR_SIZE
, 0, MAC_SCROLLBAR_SIZE
, m_height
- adjust
, wxSIZE_USE_EXISTING
);
1620 m_hScrollBar
->SetSize( 0 , m_height
-MAC_SCROLLBAR_SIZE
,m_width
- adjust
, MAC_SCROLLBAR_SIZE
, wxSIZE_USE_EXISTING
);
1624 void wxWindow::MacKeyDown( EventRecord
*ev
)
1629 bool wxWindow::AcceptsFocus() const
1631 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1634 ControlHandle
wxWindow::MacGetContainerForEmbedding()
1636 if ( m_macWindowData
)
1637 return m_macWindowData
->m_macRootControl
;
1639 return GetParent()->MacGetContainerForEmbedding() ;
1642 void wxWindow::MacSuperChangedPosition()
1644 // only window-absolute structures have to be moved i.e. controls
1646 wxNode
*node
= GetChildren().First();
1649 wxWindow
*child
= (wxWindow
*)node
->Data();
1650 child
->MacSuperChangedPosition() ;
1651 node
= node
->Next();
1655 bool wxWindow::MacSetupFocusPort( )
1663 MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1664 return MacSetPortFocusParams( localOrigin
, clipRect
, window
, rootwin
) ;
1667 bool wxWindow::MacSetupFocusClientPort( )
1675 MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1676 return MacSetPortFocusParams( localOrigin
, clipRect
, window
, rootwin
) ;
1679 bool wxWindow::MacSetupDrawingPort( )
1687 MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1688 return MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1691 bool wxWindow::MacSetupDrawingClientPort( )
1699 MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1700 return MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1704 bool wxWindow::MacSetPortFocusParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindow
* win
)
1706 if ( window
== NULL
)
1712 ::GetPort(&currPort
);
1713 port
= UMAGetWindowPort( window
) ;
1714 if (currPort
!= port
)
1717 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1721 bool wxWindow::MacSetPortDrawingParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindow
* win
)
1723 if ( window
== NULL
)
1728 ::GetPort(&currPort
);
1729 port
= UMAGetWindowPort( window
) ;
1730 if (currPort
!= port
)
1733 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1734 ::ClipRect(&clipRect
);
1737 ::RGBBackColor(& win
->GetBackgroundColour().GetPixel() ) ;
1738 ::RGBForeColor(& win
->GetForegroundColour().GetPixel() ) ;
1739 ::BackPat( &qd
.white
) ;
1740 ::UMASetThemeWindowBackground( win
->m_macWindowData
->m_macWindow
, win
->m_macWindowData
->m_macWindowBackgroundTheme
, false ) ;
1744 void wxWindow::MacGetPortParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindow
** rootwin
)
1746 if ( m_macWindowData
)
1752 clipRect
->right
= m_width
;
1753 clipRect
->bottom
= m_height
;
1754 *window
= m_macWindowData
->m_macWindow
;
1759 wxASSERT( GetParent() != NULL
) ;
1760 GetParent()->MacGetPortParams( localOrigin
, clipRect
, window
, rootwin
) ;
1761 localOrigin
->h
+= m_x
;
1762 localOrigin
->v
+= m_y
;
1763 OffsetRect(clipRect
, -m_x
, -m_y
);
1768 myClip
.right
= m_width
;
1769 myClip
.bottom
= m_height
;
1770 SectRect(clipRect
, &myClip
, clipRect
);
1774 void wxWindow::MacGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindow
** rootwin
)
1776 int width
, height
;
1777 GetClientSize( &width
, &height
) ;
1779 if ( m_macWindowData
)
1785 clipRect
->right
= m_width
;//width;
1786 clipRect
->bottom
= m_height
;// height;
1787 *window
= m_macWindowData
->m_macWindow
;
1792 wxASSERT( GetParent() != NULL
) ;
1794 GetParent()->MacGetPortClientParams( localOrigin
, clipRect
, window
, rootwin
) ;
1796 localOrigin
->h
+= m_x
;
1797 localOrigin
->v
+= m_y
;
1798 OffsetRect(clipRect
, -m_x
, -m_y
);
1803 myClip
.right
= width
;
1804 myClip
.bottom
= height
;
1805 SectRect(clipRect
, &myClip
, clipRect
);
1809 wxMacFocusHelper::wxMacFocusHelper( wxWindow
* theWindow
)
1816 m_currentPort
= NULL
;
1817 GetPort( &m_formerPort
) ;
1821 theWindow
->MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1822 m_currentPort
= UMAGetWindowPort( window
) ;
1823 theWindow
->MacSetPortFocusParams( localOrigin
, clipRect
, window
, rootwin
) ;
1828 wxMacFocusHelper::~wxMacFocusHelper()
1832 SetOrigin( 0 , 0 ) ;
1834 if ( m_formerPort
!= m_currentPort
)
1835 SetPort( m_formerPort
) ;
1838 wxMacDrawingHelper::wxMacDrawingHelper( wxWindow
* theWindow
)
1845 m_currentPort
= NULL
;
1847 GetPort( &m_formerPort
) ;
1850 theWindow
->MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1851 m_currentPort
= UMAGetWindowPort( window
) ;
1852 if ( m_formerPort
!= m_currentPort
)
1853 SetPort( m_currentPort
) ;
1854 GetPenState( &m_savedPenState
) ;
1855 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1860 wxMacDrawingHelper::~wxMacDrawingHelper()
1864 SetPenState( &m_savedPenState
) ;
1865 SetOrigin( 0 , 0 ) ;
1866 ClipRect( &m_currentPort
->portRect
) ;
1869 if ( m_formerPort
!= m_currentPort
)
1870 SetPort( m_formerPort
) ;
1873 wxMacFocusClientHelper::wxMacFocusClientHelper( wxWindow
* theWindow
)
1880 m_currentPort
= NULL
;
1882 GetPort( &m_formerPort
) ;
1886 theWindow
->MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1887 m_currentPort
= UMAGetWindowPort( window
) ;
1888 theWindow
->MacSetPortFocusParams( localOrigin
, clipRect
, window
, rootwin
) ;
1893 wxMacFocusClientHelper::~wxMacFocusClientHelper()
1897 SetOrigin( 0 , 0 ) ;
1899 if ( m_formerPort
!= m_currentPort
)
1900 SetPort( m_formerPort
) ;
1903 wxMacDrawingClientHelper::wxMacDrawingClientHelper( wxWindow
* theWindow
)
1910 m_currentPort
= NULL
;
1912 GetPort( &m_formerPort
) ;
1916 theWindow
->MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1917 m_currentPort
= UMAGetWindowPort( window
) ;
1918 if ( m_formerPort
!= m_currentPort
)
1919 SetPort( m_currentPort
) ;
1920 GetPenState( &m_savedPenState
) ;
1921 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1926 wxMacDrawingClientHelper::~wxMacDrawingClientHelper()
1930 SetPenState( &m_savedPenState
) ;
1931 SetOrigin( 0 , 0 ) ;
1932 ClipRect( &m_currentPort
->portRect
) ;
1935 if ( m_formerPort
!= m_currentPort
)
1936 SetPort( m_formerPort
) ;