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
) ;
650 int wxWindow::GetCharHeight() const
652 wxClientDC
dc ( (wxWindow
*)this ) ;
653 return dc
.GetCharHeight() ;
656 int wxWindow::GetCharWidth() const
658 wxClientDC
dc ( (wxWindow
*)this ) ;
659 return dc
.GetCharWidth() ;
662 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
663 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
665 const wxFont
*fontToUse
= theFont
;
669 wxClientDC
dc( this ) ;
671 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, fontToUse
) ;
672 *externalLeading
= le
;
678 void wxWindow::MacEraseBackground( Rect
*rect
)
680 WindowRef window
= GetMacRootWindow() ;
681 if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
683 UMASetThemeWindowBackground( window
, kThemeBrushDocumentWindowBackground
, false ) ;
685 else if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
687 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
688 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
689 // either a non gray background color or a non control window
691 wxWindow
* parent
= GetParent() ;
694 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
696 // if we have any other colours in the hierarchy
697 RGBBackColor( &parent
->m_backgroundColour
.GetPixel()) ;
700 if( parent
->IsKindOf( CLASSINFO( wxControl
) ) && ((wxControl
*)parent
)->GetMacControl() )
702 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
703 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
705 ApplyThemeBackground (kThemeBackgroundTabPane
, rect
, kThemeStateActive
,8,true);
711 // we have arrived at a non control item
715 parent
= parent
->GetParent() ;
719 // if there is nothing special -> use default
720 UMASetThemeWindowBackground( window
, kThemeBrushDialogBackgroundActive
, false ) ;
725 RGBBackColor( &m_backgroundColour
.GetPixel()) ;
730 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
732 wxWindow
*child
= (wxWindow
*)node
->Data();
736 // child->GetClientSize( &width , &height ) ;
738 Rect clientrect
= { child
->m_x
, child
->m_y
, child
->m_x
+child
->m_width
, child
->m_y
+ child
->m_height
} ;
739 SectRect( &clientrect
, rect
, &clientrect
) ;
741 OffsetRect( &clientrect
, -child
->m_x
, -child
->m_y
) ;
742 if ( child
->GetMacRootWindow() == window
&& child
->IsShown() )
744 wxMacDrawingClientHelper
focus( this ) ;
747 child
->MacEraseBackground( &clientrect
) ;
753 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
755 wxMacDrawingClientHelper
focus( this ) ;
759 GetClientSize( &width
, &height
) ;
760 Rect clientrect
= { 0 , 0 , height
, width
} ;
761 ClipRect( &clientrect
) ;
765 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
766 SectRect( &clientrect
, &r
, &clientrect
) ;
768 InvalRect( &clientrect
) ;
772 MacEraseBackground( &clientrect ) ;
778 // Responds to colour changes: passes event on to children.
779 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
781 wxNode
*node
= GetChildren().First();
784 // Only propagate to non-top-level windows
785 wxWindow
*win
= (wxWindow
*)node
->Data();
786 if ( win
->GetParent() )
788 wxSysColourChangedEvent event2
;
789 event
.m_eventObject
= win
;
790 win
->GetEventHandler()->ProcessEvent(event2
);
797 #if wxUSE_CARET && WXWIN_COMPATIBILITY
798 // ---------------------------------------------------------------------------
799 // Caret manipulation
800 // ---------------------------------------------------------------------------
802 void wxWindow::CreateCaret(int w
, int h
)
804 SetCaret(new wxCaret(this, w
, h
));
807 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
809 wxFAIL_MSG("not implemented");
812 void wxWindow::ShowCaret(bool show
)
814 wxCHECK_RET( m_caret
, "no caret to show" );
819 void wxWindow::DestroyCaret()
824 void wxWindow::SetCaretPos(int x
, int y
)
826 wxCHECK_RET( m_caret
, "no caret to move" );
831 void wxWindow::GetCaretPos(int *x
, int *y
) const
833 wxCHECK_RET( m_caret
, "no caret to get position of" );
835 m_caret
->GetPosition(x
, y
);
837 #endif // wxUSE_CARET
839 wxWindow
*wxGetActiveWindow()
841 // actually this is a windows-only concept
845 // Coordinates relative to the window
846 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
848 // We really dont move the mouse programmatically under mac
851 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
853 // TODO : probably we would adopt the EraseEvent structure
856 int wxWindow::GetScrollPos(int orient
) const
858 if ( orient
== wxHORIZONTAL
)
861 return m_hScrollBar
->GetThumbPosition() ;
866 return m_vScrollBar
->GetThumbPosition() ;
871 // This now returns the whole range, not just the number
872 // of positions that we can scroll.
873 int wxWindow::GetScrollRange(int orient
) const
875 if ( orient
== wxHORIZONTAL
)
878 return m_hScrollBar
->GetRange() ;
883 return m_vScrollBar
->GetRange() ;
888 int wxWindow::GetScrollThumb(int orient
) const
890 if ( orient
== wxHORIZONTAL
)
893 return m_hScrollBar
->GetThumbSize() ;
898 return m_vScrollBar
->GetThumbSize() ;
903 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
905 if ( orient
== wxHORIZONTAL
)
908 m_hScrollBar
->SetThumbPosition( pos
) ;
913 m_vScrollBar
->SetThumbPosition( pos
) ;
917 // New function that will replace some of the above.
918 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
919 int range
, bool refresh
)
921 if ( orient
== wxHORIZONTAL
)
925 if ( range
== 0 || thumbVisible
>= range
)
927 if ( m_hScrollBar
->IsShown() )
928 m_hScrollBar
->Show(false) ;
932 if ( !m_hScrollBar
->IsShown() )
933 m_hScrollBar
->Show(true) ;
934 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, refresh
) ;
942 if ( range
== 0 || thumbVisible
>= range
)
944 if ( m_vScrollBar
->IsShown() )
945 m_vScrollBar
->Show(false) ;
949 if ( !m_vScrollBar
->IsShown() )
950 m_vScrollBar
->Show(true) ;
951 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, refresh
) ;
955 MacRepositionScrollBars() ;
958 // Does a physical scroll
959 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
961 wxMacDrawingClientHelper
focus( this ) ;
965 GetClientSize( &width
, &height
) ;
966 Rect scrollrect
= { 0 , 0 , height
, width
} ;
968 RgnHandle updateRgn
= NewRgn() ;
969 ClipRect( &scrollrect
) ;
972 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
973 SectRect( &scrollrect
, &r
, &scrollrect
) ;
975 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
976 InvalRgn( updateRgn
) ;
977 DisposeRgn( updateRgn
) ;
981 void wxWindow::MacOnScroll(wxScrollEvent
&event
)
983 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
985 wxScrollWinEvent wevent
;
986 wevent
.SetPosition(event
.GetPosition());
987 wevent
.SetOrientation(event
.GetOrientation());
988 wevent
.m_eventObject
= this;
990 switch ( event
.m_eventType
)
992 case wxEVT_SCROLL_TOP
:
993 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
996 case wxEVT_SCROLL_BOTTOM
:
997 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1000 case wxEVT_SCROLL_LINEUP
:
1001 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1004 case wxEVT_SCROLL_LINEDOWN
:
1005 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1008 case wxEVT_SCROLL_PAGEUP
:
1009 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1012 case wxEVT_SCROLL_PAGEDOWN
:
1013 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1016 case wxEVT_SCROLL_THUMBTRACK
:
1017 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1022 GetEventHandler()->ProcessEvent(wevent
);
1026 bool wxWindow::SetFont(const wxFont
& font
)
1028 if ( !wxWindowBase::SetFont(font
) )
1037 // Get the window with the focus
1038 wxWindow
*wxWindowBase::FindFocus()
1040 return gFocusWindow
;
1043 #if WXWIN_COMPATIBILITY
1044 // If nothing defined for this, try the parent.
1045 // E.g. we may be a button loaded from a resource, with no callback function
1047 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
1049 if ( GetEventHandler()->ProcessEvent(event
) )
1052 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1054 #endif // WXWIN_COMPATIBILITY_2
1056 #if WXWIN_COMPATIBILITY
1057 wxObject
* wxWindow::GetChild(int number
) const
1059 // Return a pointer to the Nth object in the Panel
1060 wxNode
*node
= GetChildren().First();
1063 node
= node
->Next();
1066 wxObject
*obj
= (wxObject
*)node
->Data();
1072 #endif // WXWIN_COMPATIBILITY
1074 void wxWindow::Clear()
1076 if ( m_macWindowData
)
1078 wxMacDrawingClientHelper
helper ( this ) ;
1080 wxPoint origin
= GetClientAreaOrigin() ;
1081 GetClientSize( &w
, &h
) ;
1082 UMASetThemeWindowBackground( m_macWindowData
->m_macWindow
, m_macWindowData
->m_macWindowBackgroundTheme
, false ) ;
1083 Rect r
= { origin
.y
, origin
.x
, origin
.y
+h
, origin
.x
+w
} ;
1088 wxClientDC
dc(this);
1089 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1090 dc
.SetBackground(brush
);
1095 // Setup background and foreground colours correctly
1096 void wxWindow::SetupColours()
1099 SetBackgroundColour(GetParent()->GetBackgroundColour());
1102 void wxWindow::OnIdle(wxIdleEvent
& event
)
1105 // Check if we need to send a LEAVE event
1106 if (m_mouseInWindow)
1109 ::GetCursorPos(&pt);
1110 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1112 // Generate a LEAVE event
1113 m_mouseInWindow = FALSE;
1114 MSWOnMouseLeave(pt.x, pt.y, 0);
1119 // This calls the UI-update mechanism (querying windows for
1120 // menu/toolbar/control state information)
1124 // Raise the window to the top of the Z order
1125 void wxWindow::Raise()
1130 // Lower the window to the bottom of the Z order
1131 void wxWindow::Lower()
1136 void wxWindow::DoSetClientSize(int width
, int height
)
1138 if ( width
!= -1 || height
!= -1 )
1141 if ( width
!= -1 && m_vScrollBar
)
1142 width
+= MAC_SCROLLBAR_SIZE
;
1143 if ( height
!= -1 && m_vScrollBar
)
1144 height
+= MAC_SCROLLBAR_SIZE
;
1146 DoSetSize( -1 , -1 , width
, height
) ;
1151 wxWindow
* wxWindow::s_lastMouseWindow
= NULL
;
1153 bool wxWindow::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindow
** outWin
)
1155 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1156 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1159 WindowRef window
= GetMacRootWindow() ;
1161 wxPoint
newPoint( point
) ;
1166 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1168 wxWindow
*child
= (wxWindow
*)node
->Data();
1169 if ( child
->GetMacRootWindow() == window
)
1171 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1180 bool wxWindow::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindow
** outWin
)
1183 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1184 if ( ::FindWindow( pt
, &window
) == 3 )
1186 wxPoint
point( screenpoint
) ;
1187 wxWindow
* win
= wxFindWinFromMacWindow( window
) ;
1188 win
->ScreenToClient( point
) ;
1189 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1194 extern int wxBusyCursorCount
;
1196 bool wxWindow::MacDispatchMouseEvent(wxMouseEvent
& event
)
1198 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1199 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1202 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) )
1205 WindowRef window
= GetMacRootWindow() ;
1213 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1215 wxWindow
*child
= (wxWindow
*)node
->Data();
1216 if ( child
->GetMacRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1218 if (child
->MacDispatchMouseEvent(event
))
1226 if ( wxBusyCursorCount
== 0 )
1228 m_cursor
.MacInstall() ;
1230 GetEventHandler()->ProcessEvent( event
) ;
1234 void wxWindow::MacFireMouseEvent( EventRecord
*ev
)
1236 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
1237 bool isDown
= !(ev
->modifiers
& btnState
) ; // 1 is for up
1238 bool controlDown
= ev
->modifiers
& controlKey
; // for simulating right mouse
1240 event
.m_leftDown
= isDown
&& !controlDown
;
1241 event
.m_middleDown
= FALSE
;
1242 event
.m_rightDown
= isDown
&& controlDown
;
1244 if ( ev
->what
== mouseDown
)
1247 event
.SetEventType(wxEVT_RIGHT_DOWN
) ;
1249 event
.SetEventType(wxEVT_LEFT_DOWN
) ;
1251 else if ( ev
->what
== mouseUp
)
1254 event
.SetEventType(wxEVT_RIGHT_UP
) ;
1256 event
.SetEventType(wxEVT_LEFT_UP
) ;
1260 event
.SetEventType(wxEVT_MOTION
) ;
1263 event
.m_shiftDown
= ev
->modifiers
& shiftKey
;
1264 event
.m_controlDown
= ev
->modifiers
& controlKey
;
1265 event
.m_altDown
= ev
->modifiers
& optionKey
;
1266 event
.m_metaDown
= ev
->modifiers
& cmdKey
;
1268 Point localwhere
= ev
->where
;
1271 ::GetPort( &port
) ;
1272 ::SetPort( UMAGetWindowPort( m_macWindowData
->m_macWindow
) ) ;
1273 ::GlobalToLocal( &localwhere
) ;
1276 event
.m_x
= localwhere
.h
;
1277 event
.m_y
= localwhere
.v
;
1282 wxPoint origin = GetClientAreaOrigin() ;
1284 event.m_x += origin.x ;
1285 event.m_y += origin.y ;
1288 event
.m_timeStamp
= ev
->when
;
1289 event
.SetEventObject(this);
1290 if ( wxTheApp
->s_captureWindow
)
1294 wxTheApp
->s_captureWindow
->ScreenToClient( &x
, &y
) ;
1297 wxTheApp
->s_captureWindow
->GetEventHandler()->ProcessEvent( event
) ;
1298 if ( ev
->what
== mouseUp
)
1300 wxTheApp
->s_captureWindow
= NULL
;
1301 if ( wxBusyCursorCount
== 0 )
1303 m_cursor
.MacInstall() ;
1309 MacDispatchMouseEvent( event
) ;
1313 void wxWindow::MacMouseDown( EventRecord
*ev
, short part
)
1315 MacFireMouseEvent( ev
) ;
1318 void wxWindow::MacMouseUp( EventRecord
*ev
, short part
)
1320 WindowPtr frontWindow
;
1325 MacFireMouseEvent( ev
) ;
1331 void wxWindow::MacMouseMoved( EventRecord
*ev
, short part
)
1333 WindowPtr frontWindow
;
1338 MacFireMouseEvent( ev
) ;
1343 void wxWindow::MacActivate( EventRecord
*ev
, bool inIsActivating
)
1345 wxActivateEvent
event(wxEVT_ACTIVATE
, inIsActivating
);
1346 event
.m_timeStamp
= ev
->when
;
1347 event
.SetEventObject(this);
1349 GetEventHandler()->ProcessEvent(event
);
1351 UMAHighlightAndActivateWindow( m_macWindowData
->m_macWindow
, inIsActivating
) ;
1354 void wxWindow::MacRedraw( RgnHandle updatergn
, long time
)
1356 // updatergn is always already clipped to our boundaries
1357 WindowRef window
= GetMacRootWindow() ;
1358 wxWindow
* win
= wxFindWinFromMacWindow( window
) ;
1360 wxMacDrawingClientHelper
focus( this ) ;
1363 WindowRef window
= GetMacRootWindow() ;
1364 bool eraseBackground
= false ;
1365 if ( m_macWindowData
)
1366 eraseBackground
= true ;
1367 if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
) )
1369 UMASetThemeWindowBackground( window
, kThemeBrushDocumentWindowBackground
, false ) ;
1371 else if ( m_backgroundColour
== wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
1373 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
1374 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
1375 // either a non gray background color or a non control window
1378 wxWindow
* parent
= GetParent() ;
1381 if ( parent
->GetMacRootWindow() != window
)
1383 // we are in a different window on the mac system
1388 if( parent
->IsKindOf( CLASSINFO( wxControl
) ) && ((wxControl
*)parent
)->GetMacControl() )
1390 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) )
1392 // if we have any other colours in the hierarchy
1393 RGBBackColor( &parent
->m_backgroundColour
.GetPixel()) ;
1396 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
1397 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
1399 ApplyThemeBackground(kThemeBackgroundTabPane
, &(**updatergn
).rgnBBox
, kThemeStateActive
,8,true);
1408 parent
= parent
->GetParent() ;
1412 // if there is nothing special -> use default
1413 UMASetThemeWindowBackground( window
, kThemeBrushDialogBackgroundActive
, false ) ;
1418 RGBBackColor( &m_backgroundColour
.GetPixel()) ;
1420 if ( GetParent() && m_backgroundColour
!= GetParent()->GetBackgroundColour() )
1421 eraseBackground
= true ;
1422 SetClip( updatergn
) ;
1423 if ( eraseBackground
)
1425 EraseRgn( updatergn
) ;
1431 m_updateRegion
= updatergn
;
1433 event
.m_timeStamp
= time
;
1434 event
.SetEventObject(this);
1436 GetEventHandler()->ProcessEvent(event
);
1438 RgnHandle childupdate
= NewRgn() ;
1440 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1442 wxWindow
*child
= (wxWindow
*)node
->Data();
1446 child
->GetClientSize( &width
, &height
) ;
1448 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+width
, child
->m_y
+ height
) ;
1449 SectRgn( childupdate
, m_updateRegion
.GetWXHRGN() , childupdate
) ;
1450 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1451 if ( child
->GetMacRootWindow() == window
&& child
->IsShown() )
1453 // because dialogs may also be children
1454 child
->MacRedraw( childupdate
, time
) ;
1457 DisposeRgn( childupdate
) ;
1458 // eventually a draw grow box here
1461 void wxWindow::MacUpdateImmediately()
1463 WindowRef window
= GetMacRootWindow() ;
1466 wxWindow
* win
= wxFindWinFromMacWindow( window
) ;
1467 BeginUpdate( window
) ;
1471 if ( !EmptyRgn( window
->visRgn
) )
1474 win
->MacRedraw( window
->visRgn
, wxTheApp
->sm_lastMessageTime
) ;
1477 wxMacDrawingHelper help( win ) ;
1478 SetOrigin( 0 , 0 ) ;
1479 UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
1480 UMAUpdateControls( window , window->visRgn ) ;
1481 UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
1486 EndUpdate( window
) ;
1490 void wxWindow::MacUpdate( EventRecord
*ev
)
1492 WindowRef window
= (WindowRef
) ev
->message
;
1493 wxWindow
* win
= wxFindWinFromMacWindow( window
) ;
1495 BeginUpdate( window
) ;
1498 // if windowshade gives incompatibility , take the follwing out
1500 if ( !EmptyRgn( window
->visRgn
) )
1503 MacRedraw( window
->visRgn
, ev
->when
) ;
1506 wxMacDrawingHelper help( this ) ;
1507 SetOrigin( 0 , 0 ) ;
1508 UMASetThemeWindowBackground( m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
1509 UMAUpdateControls( window , window->visRgn ) ;
1510 UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ;
1515 EndUpdate( window
) ;
1518 WindowRef
wxWindow::GetMacRootWindow() const
1520 WindowRef window
= NULL
;
1521 wxWindow
*iter
= (wxWindow
*)this ;
1525 if ( iter
->m_macWindowData
)
1526 return iter
->m_macWindowData
->m_macWindow
;
1528 iter
= iter
->GetParent() ;
1530 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1534 void wxWindow::MacCreateScrollBars( long style
)
1536 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1537 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1538 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1540 if ( style
& wxVSCROLL
)
1542 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, wxPoint(m_width
-MAC_SCROLLBAR_SIZE
, 0),
1543 wxSize(MAC_SCROLLBAR_SIZE
, m_height
- adjust
), wxVERTICAL
);
1544 // m_vScrollBar->PushEventHandler( this ) ;
1546 if ( style
& wxHSCROLL
)
1548 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, wxPoint(0 , m_height
-MAC_SCROLLBAR_SIZE
),
1549 wxSize( m_width
- adjust
, MAC_SCROLLBAR_SIZE
), wxHORIZONTAL
);
1550 // m_hScrollBar->PushEventHandler( this ) ;
1553 // because the create does not take into account the client area origin
1554 MacRepositionScrollBars() ; // we might have a real position shift
1557 void wxWindow::MacRepositionScrollBars()
1559 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1560 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1564 m_vScrollBar
->SetSize( m_width
-MAC_SCROLLBAR_SIZE
, 0, MAC_SCROLLBAR_SIZE
, m_height
- adjust
, wxSIZE_USE_EXISTING
);
1568 m_hScrollBar
->SetSize( 0 , m_height
-MAC_SCROLLBAR_SIZE
,m_width
- adjust
, MAC_SCROLLBAR_SIZE
, wxSIZE_USE_EXISTING
);
1572 void wxWindow::MacKeyDown( EventRecord
*ev
)
1577 bool wxWindow::AcceptsFocus() const
1579 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1582 ControlHandle
wxWindow::MacGetContainerForEmbedding()
1584 if ( m_macWindowData
)
1585 return m_macWindowData
->m_macRootControl
;
1587 return GetParent()->MacGetContainerForEmbedding() ;
1590 void wxWindow::MacSuperChangedPosition()
1592 // only window-absolute structures have to be moved i.e. controls
1594 wxNode
*node
= GetChildren().First();
1597 wxWindow
*child
= (wxWindow
*)node
->Data();
1598 child
->MacSuperChangedPosition() ;
1599 node
= node
->Next();
1603 bool wxWindow::MacSetupFocusPort( )
1611 MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1612 return MacSetPortFocusParams( localOrigin
, clipRect
, window
, rootwin
) ;
1615 bool wxWindow::MacSetupFocusClientPort( )
1623 MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1624 return MacSetPortFocusParams( localOrigin
, clipRect
, window
, rootwin
) ;
1627 bool wxWindow::MacSetupDrawingPort( )
1635 MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1636 return MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1639 bool wxWindow::MacSetupDrawingClientPort( )
1647 MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1648 return MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1652 bool wxWindow::MacSetPortFocusParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindow
* win
)
1654 if ( window
== NULL
)
1660 ::GetPort(&currPort
);
1661 port
= UMAGetWindowPort( window
) ;
1662 if (currPort
!= port
)
1665 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1669 bool wxWindow::MacSetPortDrawingParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindow
* win
)
1671 if ( window
== NULL
)
1676 ::GetPort(&currPort
);
1677 port
= UMAGetWindowPort( window
) ;
1678 if (currPort
!= port
)
1681 ::SetOrigin(-localOrigin
.h
, -localOrigin
.v
);
1682 ::ClipRect(&clipRect
);
1685 ::RGBBackColor(& win
->GetBackgroundColour().GetPixel() ) ;
1686 ::RGBForeColor(& win
->GetForegroundColour().GetPixel() ) ;
1687 ::BackPat( &qd
.white
) ;
1688 ::UMASetThemeWindowBackground( win
->m_macWindowData
->m_macWindow
, win
->m_macWindowData
->m_macWindowBackgroundTheme
, false ) ;
1692 void wxWindow::MacGetPortParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindow
** rootwin
)
1694 if ( m_macWindowData
)
1700 clipRect
->right
= m_width
;
1701 clipRect
->bottom
= m_height
;
1702 *window
= m_macWindowData
->m_macWindow
;
1707 wxASSERT( GetParent() != NULL
) ;
1708 GetParent()->MacGetPortParams( localOrigin
, clipRect
, window
, rootwin
) ;
1709 localOrigin
->h
+= m_x
;
1710 localOrigin
->v
+= m_y
;
1711 OffsetRect(clipRect
, -m_x
, -m_y
);
1716 myClip
.right
= m_width
;
1717 myClip
.bottom
= m_height
;
1718 SectRect(clipRect
, &myClip
, clipRect
);
1722 void wxWindow::MacGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindow
** rootwin
)
1724 int width
, height
;
1725 GetClientSize( &width
, &height
) ;
1727 if ( m_macWindowData
)
1733 clipRect
->right
= m_width
;//width;
1734 clipRect
->bottom
= m_height
;// height;
1735 *window
= m_macWindowData
->m_macWindow
;
1740 wxASSERT( GetParent() != NULL
) ;
1742 GetParent()->MacGetPortClientParams( localOrigin
, clipRect
, window
, rootwin
) ;
1744 localOrigin
->h
+= m_x
;
1745 localOrigin
->v
+= m_y
;
1746 OffsetRect(clipRect
, -m_x
, -m_y
);
1751 myClip
.right
= width
;
1752 myClip
.bottom
= height
;
1753 SectRect(clipRect
, &myClip
, clipRect
);
1757 wxMacFocusHelper::wxMacFocusHelper( wxWindow
* theWindow
)
1764 m_currentPort
= NULL
;
1765 GetPort( &m_formerPort
) ;
1769 theWindow
->MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1770 m_currentPort
= UMAGetWindowPort( window
) ;
1771 theWindow
->MacSetPortFocusParams( localOrigin
, clipRect
, window
, rootwin
) ;
1776 wxMacFocusHelper::~wxMacFocusHelper()
1780 SetOrigin( 0 , 0 ) ;
1782 if ( m_formerPort
!= m_currentPort
)
1783 SetPort( m_formerPort
) ;
1786 wxMacDrawingHelper::wxMacDrawingHelper( wxWindow
* theWindow
)
1793 m_currentPort
= NULL
;
1795 GetPort( &m_formerPort
) ;
1798 theWindow
->MacGetPortParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1799 m_currentPort
= UMAGetWindowPort( window
) ;
1800 if ( m_formerPort
!= m_currentPort
)
1801 SetPort( m_currentPort
) ;
1802 GetPenState( &m_savedPenState
) ;
1803 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1808 wxMacDrawingHelper::~wxMacDrawingHelper()
1812 SetPenState( &m_savedPenState
) ;
1813 SetOrigin( 0 , 0 ) ;
1814 ClipRect( &m_currentPort
->portRect
) ;
1817 if ( m_formerPort
!= m_currentPort
)
1818 SetPort( m_formerPort
) ;
1821 wxMacFocusClientHelper::wxMacFocusClientHelper( wxWindow
* theWindow
)
1828 m_currentPort
= NULL
;
1830 GetPort( &m_formerPort
) ;
1834 theWindow
->MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1835 m_currentPort
= UMAGetWindowPort( window
) ;
1836 theWindow
->MacSetPortFocusParams( localOrigin
, clipRect
, window
, rootwin
) ;
1841 wxMacFocusClientHelper::~wxMacFocusClientHelper()
1845 SetOrigin( 0 , 0 ) ;
1847 if ( m_formerPort
!= m_currentPort
)
1848 SetPort( m_formerPort
) ;
1851 wxMacDrawingClientHelper::wxMacDrawingClientHelper( wxWindow
* theWindow
)
1858 m_currentPort
= NULL
;
1860 GetPort( &m_formerPort
) ;
1864 theWindow
->MacGetPortClientParams( &localOrigin
, &clipRect
, &window
, &rootwin
) ;
1865 m_currentPort
= UMAGetWindowPort( window
) ;
1866 if ( m_formerPort
!= m_currentPort
)
1867 SetPort( m_currentPort
) ;
1868 GetPenState( &m_savedPenState
) ;
1869 theWindow
->MacSetPortDrawingParams( localOrigin
, clipRect
, window
, rootwin
) ;
1874 wxMacDrawingClientHelper::~wxMacDrawingClientHelper()
1878 SetPenState( &m_savedPenState
) ;
1879 SetOrigin( 0 , 0 ) ;
1880 ClipRect( &m_currentPort
->portRect
) ;
1883 if ( m_formerPort
!= m_currentPort
)
1884 SetPort( m_formerPort
) ;