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"
38 #include "wx/spinctrl.h"
45 #define wxWINDOW_HSCROLL 5998
46 #define wxWINDOW_VSCROLL 5997
47 #define MAC_SCROLLBAR_SIZE 16
49 #include "wx/mac/uma.h"
52 #include <ToolUtils.h>
55 #if wxUSE_DRAG_AND_DROP
61 extern wxList wxPendingDelete
;
62 wxWindowMac
* gFocusWindow
= NULL
;
64 #ifdef __WXUNIVERSAL__
65 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
67 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
68 #endif // __WXUNIVERSAL__/__WXMAC__
70 #if !USE_SHARED_LIBRARY
72 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
73 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
74 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
75 EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged
)
76 EVT_INIT_DIALOG(wxWindowMac::OnInitDialog
)
77 EVT_IDLE(wxWindowMac::OnIdle
)
78 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
83 #define wxMAC_DEBUG_REDRAW 0
84 #ifndef wxMAC_DEBUG_REDRAW
85 #define wxMAC_DEBUG_REDRAW 0
88 #define wxMAC_USE_THEME_BORDER 0
91 // ===========================================================================
93 // ===========================================================================
96 // ----------------------------------------------------------------------------
97 // constructors and such
98 // ----------------------------------------------------------------------------
100 void wxWindowMac::Init()
106 m_doubleClickAllowed
= 0;
107 m_winCaptured
= FALSE
;
109 m_isBeingDeleted
= FALSE
;
112 m_mouseInWindow
= FALSE
;
116 m_backgroundTransparent
= FALSE
;
118 // as all windows are created with WS_VISIBLE style...
126 m_hScrollBar
= NULL
;
127 m_vScrollBar
= NULL
;
129 m_label
= wxEmptyString
;
133 wxWindowMac::~wxWindowMac()
135 // deleting a window while it is shown invalidates the region
137 wxWindowMac
* iter
= this ;
139 if ( iter
->IsTopLevel() )
144 iter
= iter
->GetParent() ;
149 m_isBeingDeleted
= TRUE
;
151 #ifndef __WXUNIVERSAL__
152 // VS: make sure there's no wxFrame with last focus set to us:
153 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
155 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
158 if ( frame
->GetLastFocus() == this )
160 frame
->SetLastFocus((wxWindow
*)NULL
);
165 #endif // __WXUNIVERSAL__
167 if ( s_lastMouseWindow
== this )
169 s_lastMouseWindow
= NULL
;
172 if ( gFocusWindow
== this )
174 gFocusWindow
= NULL
;
178 m_parent
->RemoveChild(this);
184 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
188 const wxString
& name
)
190 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
192 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
195 parent
->AddChild(this);
199 AdjustForParentClientOrigin(m_x
, m_y
, wxSIZE_USE_EXISTING
);
200 m_width
= WidthDefault( size
.x
);
201 m_height
= HeightDefault( size
.y
) ;
202 #ifndef __WXUNIVERSAL__
203 // Don't give scrollbars to wxControls unless they ask for them
204 if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
))) ||
205 (IsKindOf(CLASSINFO(wxControl
)) && ( style
& wxHSCROLL
|| style
& wxVSCROLL
)))
207 MacCreateScrollBars( style
) ;
213 void wxWindowMac::SetFocus()
215 if ( gFocusWindow
== this )
218 if ( AcceptsFocus() )
224 if ( gFocusWindow
->m_caret
)
226 gFocusWindow
->m_caret
->OnKillFocus();
228 #endif // wxUSE_CARET
229 #ifndef __WXUNIVERSAL__
230 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
231 if ( control
&& control
->GetMacControl() )
233 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNoPart
) ;
234 control
->MacRedrawControl() ;
237 wxFocusEvent
event(wxEVT_KILL_FOCUS
, gFocusWindow
->m_windowId
);
238 event
.SetEventObject(gFocusWindow
);
239 gFocusWindow
->GetEventHandler()->ProcessEvent(event
) ;
241 gFocusWindow
= this ;
247 m_caret
->OnSetFocus();
249 #endif // wxUSE_CARET
250 // panel wants to track the window which was the last to have focus in it
251 wxChildFocusEvent
eventFocus(this);
252 GetEventHandler()->ProcessEvent(eventFocus
);
254 #ifndef __WXUNIVERSAL__
255 wxControl
* control
= wxDynamicCast( gFocusWindow
, wxControl
) ;
256 if ( control
&& control
->GetMacControl() )
258 UMASetKeyboardFocus( (WindowRef
) gFocusWindow
->MacGetRootWindow() , (ControlHandle
) control
->GetMacControl() , kControlFocusNextPart
) ;
261 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
262 event
.SetEventObject(this);
263 GetEventHandler()->ProcessEvent(event
) ;
268 bool wxWindowMac::Enable(bool enable
)
270 if ( !wxWindowBase::Enable(enable
) )
273 MacSuperEnabled( enable
) ;
278 void wxWindowMac::DoCaptureMouse()
280 wxTheApp
->s_captureWindow
= this ;
283 wxWindow
* wxWindowBase::GetCapture()
285 return wxTheApp
->s_captureWindow
;
288 void wxWindowMac::DoReleaseMouse()
290 wxTheApp
->s_captureWindow
= NULL
;
293 #if wxUSE_DRAG_AND_DROP
295 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
297 if ( m_dropTarget
!= 0 ) {
301 m_dropTarget
= pDropTarget
;
302 if ( m_dropTarget
!= 0 )
310 // Old style file-manager drag&drop
311 void wxWindowMac::DragAcceptFiles(bool accept
)
317 void wxWindowMac::DoGetSize(int *x
, int *y
) const
320 if(y
) *y
= m_height
;
323 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
329 if ( !IsTopLevel() && GetParent())
331 wxPoint
pt(GetParent()->GetClientAreaOrigin());
340 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
342 menu
->SetInvokingWindow(this);
344 ClientToScreen( &x
, &y
) ;
346 ::InsertMenu( (MenuHandle
) menu
->GetHMenu() , -1 ) ;
347 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
348 menu
->MacMenuSelect( this , TickCount() , HiWord(menuResult
) , LoWord(menuResult
) ) ;
349 ::DeleteMenu( menu
->MacGetMenuId() ) ;
350 menu
->SetInvokingWindow(NULL
);
356 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
358 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
360 Point localwhere
= {0,0} ;
362 if(x
) localwhere
.h
= * x
;
363 if(y
) localwhere
.v
= * y
;
367 ::SetPort( UMAGetWindowPort( window
) ) ;
368 ::GlobalToLocal( &localwhere
) ;
371 if(x
) *x
= localwhere
.h
;
372 if(y
) *y
= localwhere
.v
;
374 MacRootWindowToWindow( x
, y
) ;
376 x
-= MacGetLeftBorderSize() ;
378 y
-= MacGetTopBorderSize() ;
381 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
383 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
386 x
+= MacGetLeftBorderSize() ;
388 y
+= MacGetTopBorderSize() ;
390 MacWindowToRootWindow( x
, y
) ;
392 Point localwhere
= { 0,0 };
393 if(x
) localwhere
.h
= * x
;
394 if(y
) localwhere
.v
= * y
;
398 ::SetPort( UMAGetWindowPort( window
) ) ;
400 ::LocalToGlobal( &localwhere
) ;
402 if(x
) *x
= localwhere
.h
;
403 if(y
) *y
= localwhere
.v
;
406 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
408 wxPoint origin
= GetClientAreaOrigin() ;
409 if(x
) *x
+= origin
.x
;
410 if(y
) *y
+= origin
.y
;
412 MacWindowToRootWindow( x
, y
) ;
415 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
417 wxPoint origin
= GetClientAreaOrigin() ;
418 MacRootWindowToWindow( x
, y
) ;
419 if(x
) *x
-= origin
.x
;
420 if(y
) *y
-= origin
.y
;
423 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
429 GetParent()->MacWindowToRootWindow( x
, y
) ;
433 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
439 GetParent()->MacRootWindowToWindow( x
, y
) ;
443 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
445 if (m_cursor
== cursor
)
448 if (wxNullCursor
== cursor
)
450 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
455 if ( ! wxWindowBase::SetCursor( cursor
) )
459 wxASSERT_MSG( m_cursor
.Ok(),
460 wxT("cursor must be valid after call to the base version"));
463 wxWindowMac
*mouseWin
;
466 // Change the cursor NOW if we're within the correct window
468 if ( MacGetWindowFromPoint( wxPoint( pt
.h
, pt
.v
) , &mouseWin
) )
470 if ( mouseWin
== this && !wxIsBusy() )
472 m_cursor
.MacInstall() ;
480 // Get size *available for subwindows* i.e. excluding menu bar etc.
481 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
487 ww
-= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
488 hh
-= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
490 if ( (m_vScrollBar
&& m_vScrollBar
->IsShown()) || (m_hScrollBar
&& m_hScrollBar
->IsShown()) )
497 MacClientToRootWindow( &x1
, &y1
) ;
498 MacClientToRootWindow( &w
, &h
) ;
500 wxWindowMac
*iter
= (wxWindowMac
*)this ;
502 int totW
= 10000 , totH
= 10000;
505 if ( iter
->IsTopLevel() )
507 totW
= iter
->m_width
;
508 totH
= iter
->m_height
;
512 iter
= iter
->GetParent() ;
515 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
517 hh
-= MAC_SCROLLBAR_SIZE
;
523 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
525 ww
-= MAC_SCROLLBAR_SIZE
;
537 // ----------------------------------------------------------------------------
539 // ----------------------------------------------------------------------------
543 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
545 wxWindowBase::DoSetToolTip(tooltip
);
548 m_tooltip
->SetWindow(this);
551 #endif // wxUSE_TOOLTIPS
553 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
557 int former_w
= m_width
;
558 int former_h
= m_height
;
560 int actualWidth
= width
;
561 int actualHeight
= height
;
565 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
566 actualWidth
= m_minWidth
;
567 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
568 actualHeight
= m_minHeight
;
569 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
570 actualWidth
= m_maxWidth
;
571 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
572 actualHeight
= m_maxHeight
;
574 bool doMove
= false ;
575 bool doResize
= false ;
577 if ( actualX
!= former_x
|| actualY
!= former_y
)
581 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
586 if ( doMove
|| doResize
)
588 // erase former position
594 m_width
= actualWidth
;
595 m_height
= actualHeight
;
597 // erase new position
601 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
603 MacRepositionScrollBars() ;
606 wxPoint
point(m_x
, m_y
);
607 wxMoveEvent
event(point
, m_windowId
);
608 event
.SetEventObject(this);
609 GetEventHandler()->ProcessEvent(event
) ;
613 MacRepositionScrollBars() ;
614 wxSize
size(m_width
, m_height
);
615 wxSizeEvent
event(size
, m_windowId
);
616 event
.SetEventObject(this);
617 GetEventHandler()->ProcessEvent(event
);
623 // set the size of the window: if the dimensions are positive, just use them,
624 // but if any of them is equal to -1, it means that we must find the value for
625 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
626 // which case -1 is a valid value for x and y)
628 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
629 // the width/height to best suit our contents, otherwise we reuse the current
631 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
633 // get the current size and position...
634 int currentX
, currentY
;
635 GetPosition(¤tX
, ¤tY
);
637 int currentW
,currentH
;
638 GetSize(¤tW
, ¤tH
);
640 // ... and don't do anything (avoiding flicker) if it's already ok
641 if ( x
== currentX
&& y
== currentY
&&
642 width
== currentW
&& height
== currentH
)
644 MacRepositionScrollBars() ; // we might have a real position shift
648 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
650 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
653 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
658 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
660 size
= DoGetBestSize();
665 // just take the current one
672 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
676 size
= DoGetBestSize();
678 //else: already called DoGetBestSize() above
684 // just take the current one
689 DoMoveWindow(x
, y
, width
, height
);
692 // For implementation purposes - sometimes decorations make the client area
695 wxPoint
wxWindowMac::GetClientAreaOrigin() const
697 return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
700 void wxWindowMac::SetTitle(const wxString
& title
)
705 wxString
wxWindowMac::GetTitle() const
710 bool wxWindowMac::Show(bool show
)
712 if ( !wxWindowBase::Show(show
) )
716 WindowRef window = (WindowRef) MacGetRootWindow() ;
717 wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
718 if ( win == NULL && win->m_isBeingDeleted )
721 MacSuperShown( show
) ;
726 if ( win && !win->m_isBeingDeleted )
737 void wxWindowMac::MacSuperShown( bool show
)
739 wxNode
*node
= GetChildren().First();
742 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
743 if ( child
->m_isShown
)
744 child
->MacSuperShown( show
) ;
749 void wxWindowMac::MacSuperEnabled( bool enabled
)
753 // to be absolutely correct we'd have to invalidate (with eraseBkground
754 // because unter MacOSX the frames are drawn with an addXXX mode)
757 wxNode
*node
= GetChildren().First();
760 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
761 if ( child
->m_isShown
)
762 child
->MacSuperEnabled( enabled
) ;
767 bool wxWindowMac::MacIsReallyShown() const
769 if ( m_isShown
&& (m_parent
!= NULL
) ) {
770 return m_parent
->MacIsReallyShown();
774 bool status = m_isShown ;
775 wxWindowMac * win = this ;
776 while ( status && win->m_parent != NULL )
778 win = win->m_parent ;
779 status = win->m_isShown ;
785 int wxWindowMac::GetCharHeight() const
787 wxClientDC
dc ( (wxWindowMac
*)this ) ;
788 return dc
.GetCharHeight() ;
791 int wxWindowMac::GetCharWidth() const
793 wxClientDC
dc ( (wxWindowMac
*)this ) ;
794 return dc
.GetCharWidth() ;
797 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
798 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
800 const wxFont
*fontToUse
= theFont
;
804 wxClientDC
dc( (wxWindowMac
*) this ) ;
806 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
807 if ( externalLeading
)
808 *externalLeading
= le
;
818 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
819 * we always intersect with the entire window, not only with the client area
822 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
824 if ( MacGetTopLevelWindow() == NULL
)
827 wxPoint client
= GetClientAreaOrigin();
830 int x2
= m_width
- client
.x
;
831 int y2
= m_height
- client
.y
;
833 if (IsKindOf( CLASSINFO(wxButton
)))
835 // buttons have an "aura"
842 Rect clientrect
= { y1
, x1
, y2
, x2
};
846 Rect r
= { rect
->y
, rect
->x
, rect
->y
+ rect
->height
, rect
->x
+ rect
->width
} ;
847 SectRect( &clientrect
, &r
, &clientrect
) ;
850 if ( !EmptyRect( &clientrect
) )
852 int top
= 0 , left
= 0 ;
854 MacClientToRootWindow( &left
, &top
) ;
855 OffsetRect( &clientrect
, left
, top
) ;
857 MacGetTopLevelWindow()->MacInvalidate( &clientrect
, eraseBack
) ;
861 #if wxUSE_CARET && WXWIN_COMPATIBILITY
862 // ---------------------------------------------------------------------------
863 // Caret manipulation
864 // ---------------------------------------------------------------------------
866 void wxWindowMac::CreateCaret(int w
, int h
)
868 SetCaret(new wxCaret(this, w
, h
));
871 void wxWindowMac::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
873 wxFAIL_MSG("not implemented");
876 void wxWindowMac::ShowCaret(bool show
)
878 wxCHECK_RET( m_caret
, "no caret to show" );
883 void wxWindowMac::DestroyCaret()
888 void wxWindowMac::SetCaretPos(int x
, int y
)
890 wxCHECK_RET( m_caret
, "no caret to move" );
895 void wxWindowMac::GetCaretPos(int *x
, int *y
) const
897 wxCHECK_RET( m_caret
, "no caret to get position of" );
899 m_caret
->GetPosition(x
, y
);
901 #endif // wxUSE_CARET
903 wxWindowMac
*wxGetActiveWindow()
905 // actually this is a windows-only concept
909 // Coordinates relative to the window
910 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
912 // We really dont move the mouse programmatically under mac
915 const wxBrush
& wxWindowMac::MacGetBackgroundBrush()
917 if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
919 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDocumentWindowBackground
) ;
921 else if ( m_backgroundColour
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) )
923 // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
924 // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
925 // either a non gray background color or a non control window
927 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
929 wxWindowMac
* parent
= GetParent() ;
932 if ( parent
->MacGetRootWindow() != window
)
934 // we are in a different window on the mac system
940 if ( parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
)
941 && parent
->m_backgroundColour
!= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
943 // if we have any other colours in the hierarchy
944 m_macBackgroundBrush
.SetColour( parent
->m_backgroundColour
) ;
947 // if we have the normal colours in the hierarchy but another control etc. -> use it's background
948 if ( parent
->IsKindOf( CLASSINFO( wxNotebook
) ) || parent
->IsKindOf( CLASSINFO( wxTabCtrl
) ))
950 Rect extent
= { 0 , 0 , 0 , 0 } ;
953 wxSize size
= parent
->GetSize() ;
954 parent
->MacClientToRootWindow( &x
, &y
) ;
958 extent
.right
= x
+ size
.x
;
959 extent
.bottom
= y
+ size
.y
;
960 m_macBackgroundBrush
.SetMacThemeBackground( kThemeBackgroundTabPane
, (WXRECTPTR
) &extent
) ; // todo eventually change for inactive
964 parent
= parent
->GetParent() ;
968 m_macBackgroundBrush
.SetMacTheme( kThemeBrushDialogBackgroundActive
) ; // todo eventually change for inactive
973 m_macBackgroundBrush
.SetColour( m_backgroundColour
) ;
976 return m_macBackgroundBrush
;
980 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
982 event
.GetDC()->Clear() ;
985 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
987 wxWindowDC
dc(this) ;
988 wxMacPortSetter
helper(&dc
) ;
990 MacPaintBorders( dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
993 int wxWindowMac::GetScrollPos(int orient
) const
995 if ( orient
== wxHORIZONTAL
)
998 return m_hScrollBar
->GetThumbPosition() ;
1003 return m_vScrollBar
->GetThumbPosition() ;
1008 // This now returns the whole range, not just the number
1009 // of positions that we can scroll.
1010 int wxWindowMac::GetScrollRange(int orient
) const
1012 if ( orient
== wxHORIZONTAL
)
1015 return m_hScrollBar
->GetRange() ;
1020 return m_vScrollBar
->GetRange() ;
1025 int wxWindowMac::GetScrollThumb(int orient
) const
1027 if ( orient
== wxHORIZONTAL
)
1030 return m_hScrollBar
->GetThumbSize() ;
1035 return m_vScrollBar
->GetThumbSize() ;
1040 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
1042 if ( orient
== wxHORIZONTAL
)
1045 m_hScrollBar
->SetThumbPosition( pos
) ;
1050 m_vScrollBar
->SetThumbPosition( pos
) ;
1054 void wxWindowMac::MacPaintBorders( int left
, int top
)
1059 RGBColor white
= { 0xFFFF, 0xFFFF , 0xFFFF } ;
1060 RGBColor black
= { 0x0000, 0x0000 , 0x0000 } ;
1061 RGBColor face
= { 0xDDDD, 0xDDDD , 0xDDDD } ;
1062 RGBColor shadow
= { 0x4444, 0x4444 , 0x4444 } ;
1065 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
1067 #if wxMAC_USE_THEME_BORDER
1068 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1071 GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
1072 InsetRect( &rect , border , border );
1073 DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
1076 DrawThemePrimaryGroup(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
1078 bool sunken
= HasFlag( wxSUNKEN_BORDER
) ;
1079 RGBForeColor( &face
);
1080 MoveTo( left
+ 0 , top
+ m_height
- 2 );
1081 LineTo( left
+ 0 , top
+ 0 );
1082 LineTo( left
+ m_width
- 2 , top
+ 0 );
1084 MoveTo( left
+ 2 , top
+ m_height
- 3 );
1085 LineTo( left
+ m_width
- 3 , top
+ m_height
- 3 );
1086 LineTo( left
+ m_width
- 3 , top
+ 2 );
1088 RGBForeColor( sunken
? &face
: &black
);
1089 MoveTo( left
+ 0 , top
+ m_height
- 1 );
1090 LineTo( left
+ m_width
- 1 , top
+ m_height
- 1 );
1091 LineTo( left
+ m_width
- 1 , top
+ 0 );
1093 RGBForeColor( sunken
? &shadow
: &white
);
1094 MoveTo( left
+ 1 , top
+ m_height
- 3 );
1095 LineTo( left
+ 1, top
+ 1 );
1096 LineTo( left
+ m_width
- 3 , top
+ 1 );
1098 RGBForeColor( sunken
? &white
: &shadow
);
1099 MoveTo( left
+ 1 , top
+ m_height
- 2 );
1100 LineTo( left
+ m_width
- 2 , top
+ m_height
- 2 );
1101 LineTo( left
+ m_width
- 2 , top
+ 1 );
1103 RGBForeColor( sunken
? &black
: &face
);
1104 MoveTo( left
+ 2 , top
+ m_height
- 4 );
1105 LineTo( left
+ 2 , top
+ 2 );
1106 LineTo( left
+ m_width
- 4 , top
+ 2 );
1109 else if (HasFlag(wxSIMPLE_BORDER
))
1111 Rect rect
= { top
, left
, m_height
+ top
, m_width
+ left
} ;
1112 RGBForeColor( &black
) ;
1113 FrameRect( &rect
) ;
1117 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
1119 if ( child
== m_hScrollBar
)
1120 m_hScrollBar
= NULL
;
1121 if ( child
== m_vScrollBar
)
1122 m_vScrollBar
= NULL
;
1124 wxWindowBase::RemoveChild( child
) ;
1127 // New function that will replace some of the above.
1128 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
1129 int range
, bool refresh
)
1131 if ( orient
== wxHORIZONTAL
)
1135 if ( range
== 0 || thumbVisible
>= range
)
1137 if ( m_hScrollBar
->IsShown() )
1138 m_hScrollBar
->Show(false) ;
1142 if ( !m_hScrollBar
->IsShown() )
1143 m_hScrollBar
->Show(true) ;
1144 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1152 if ( range
== 0 || thumbVisible
>= range
)
1154 if ( m_vScrollBar
->IsShown() )
1155 m_vScrollBar
->Show(false) ;
1159 if ( !m_vScrollBar
->IsShown() )
1160 m_vScrollBar
->Show(true) ;
1161 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
1165 MacRepositionScrollBars() ;
1168 // Does a physical scroll
1169 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
1171 wxClientDC
dc(this) ;
1172 wxMacPortSetter
helper(&dc
) ;
1175 int width
, height
;
1176 GetClientSize( &width
, &height
) ;
1178 Rect scrollrect
= { dc
.YLOG2DEVMAC(0) , dc
.XLOG2DEVMAC(0) , dc
.YLOG2DEVMAC(height
) , dc
.XLOG2DEVMAC(width
) } ;
1179 RgnHandle updateRgn
= NewRgn() ;
1180 ClipRect( &scrollrect
) ;
1183 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
1184 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
1185 SectRect( &scrollrect
, &r
, &scrollrect
) ;
1187 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
1188 InvalWindowRgn( (WindowRef
) MacGetRootWindow() , updateRgn
) ;
1189 DisposeRgn( updateRgn
) ;
1192 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1194 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1195 if (child
== m_vScrollBar
) continue;
1196 if (child
== m_hScrollBar
) continue;
1197 if (child
->IsTopLevel()) continue;
1199 child
->GetPosition( &x
, &y
);
1201 child
->GetSize( &w
, &h
);
1202 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
1207 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
1209 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
1211 wxScrollWinEvent wevent
;
1212 wevent
.SetPosition(event
.GetPosition());
1213 wevent
.SetOrientation(event
.GetOrientation());
1214 wevent
.m_eventObject
= this;
1216 if (event
.m_eventType
== wxEVT_SCROLL_TOP
) {
1217 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
1219 if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
) {
1220 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
1222 if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
) {
1223 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
1225 if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
) {
1226 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1228 if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
) {
1229 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
1231 if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
) {
1232 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
1234 if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
) {
1235 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
1238 GetEventHandler()->ProcessEvent(wevent
);
1242 // Get the window with the focus
1243 wxWindowMac
*wxWindowBase::FindFocus()
1245 return gFocusWindow
;
1248 #if WXWIN_COMPATIBILITY
1249 // If nothing defined for this, try the parent.
1250 // E.g. we may be a button loaded from a resource, with no callback function
1252 void wxWindowMac::OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
)
1254 if ( GetEventHandler()->ProcessEvent(event
) )
1257 m_parent
->GetEventHandler()->OnCommand(win
, event
);
1259 #endif // WXWIN_COMPATIBILITY_2
1261 #if WXWIN_COMPATIBILITY
1262 wxObject
* wxWindowMac::GetChild(int number
) const
1264 // Return a pointer to the Nth object in the Panel
1265 wxNode
*node
= GetChildren().First();
1268 node
= node
->Next();
1271 wxObject
*obj
= (wxObject
*)node
->Data();
1277 #endif // WXWIN_COMPATIBILITY
1279 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
1281 // panel wants to track the window which was the last to have focus in it,
1282 // so we want to set ourselves as the window which last had focus
1284 // notice that it's also important to do it upwards the tree becaus
1285 // otherwise when the top level panel gets focus, it won't set it back to
1286 // us, but to some other sibling
1288 // CS:don't know if this is still needed:
1289 //wxChildFocusEvent eventFocus(this);
1290 //(void)GetEventHandler()->ProcessEvent(eventFocus);
1295 void wxWindowMac::Clear()
1297 wxClientDC
dc(this);
1298 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1299 dc
.SetBackground(brush
);
1303 // Setup background and foreground colours correctly
1304 void wxWindowMac::SetupColours()
1307 SetBackgroundColour(GetParent()->GetBackgroundColour());
1310 void wxWindowMac::OnIdle(wxIdleEvent
& event
)
1313 // Check if we need to send a LEAVE event
1314 if (m_mouseInWindow)
1317 ::GetCursorPos(&pt);
1318 if (::WindowFromPoint(pt) != (HWND) GetHWND())
1320 // Generate a LEAVE event
1321 m_mouseInWindow = FALSE;
1322 MSWOnMouseLeave(pt.x, pt.y, 0);
1327 // This calls the UI-update mechanism (querying windows for
1328 // menu/toolbar/control state information)
1332 // Raise the window to the top of the Z order
1333 void wxWindowMac::Raise()
1337 // Lower the window to the bottom of the Z order
1338 void wxWindowMac::Lower()
1342 void wxWindowMac::DoSetClientSize(int width
, int height
)
1344 if ( width
!= -1 || height
!= -1 )
1347 if ( width
!= -1 && m_vScrollBar
)
1348 width
+= MAC_SCROLLBAR_SIZE
;
1349 if ( height
!= -1 && m_vScrollBar
)
1350 height
+= MAC_SCROLLBAR_SIZE
;
1352 width
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1353 height
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1355 DoSetSize( -1 , -1 , width
, height
) ;
1360 wxWindowMac
* wxWindowMac::s_lastMouseWindow
= NULL
;
1362 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
)
1366 if ((point
.x
< 0) || (point
.y
< 0) ||
1367 (point
.x
> (m_width
)) || (point
.y
> (m_height
)))
1372 if ((point
.x
< m_x
) || (point
.y
< m_y
) ||
1373 (point
.x
> (m_x
+ m_width
)) || (point
.y
> (m_y
+ m_height
)))
1377 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1379 wxPoint
newPoint( point
) ;
1381 if ( !IsTopLevel() )
1387 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1389 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1390 // added the m_isShown test --dmazzoni
1391 if ( child
->MacGetRootWindow() == window
&& child
->m_isShown
)
1393 if (child
->MacGetWindowFromPointSub(newPoint
, outWin
))
1402 bool wxWindowMac::MacGetWindowFromPoint( const wxPoint
&screenpoint
, wxWindowMac
** outWin
)
1406 Point pt
= { screenpoint
.y
, screenpoint
.x
} ;
1407 if ( ::FindWindow( pt
, &window
) == 3 )
1410 wxWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1413 // No, this yields the CLIENT are, we need the whole frame. RR.
1414 // point = win->ScreenToClient( point ) ;
1417 ::GetPort( &port
) ;
1418 ::SetPort( UMAGetWindowPort( window
) ) ;
1419 ::GlobalToLocal( &pt
) ;
1422 wxPoint
point( pt
.h
, pt
.v
) ;
1424 return win
->MacGetWindowFromPointSub( point
, outWin
) ;
1430 extern int wxBusyCursorCount
;
1431 static wxWindow
*gs_lastWhich
= NULL
;
1433 bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent
& event
)
1435 if ((event
.m_x
< m_x
) || (event
.m_y
< m_y
) ||
1436 (event
.m_x
> (m_x
+ m_width
)) || (event
.m_y
> (m_y
+ m_height
)))
1440 if ( IsKindOf( CLASSINFO ( wxStaticBox
) ) || IsKindOf( CLASSINFO( wxSpinCtrl
) ))
1443 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1451 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1453 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1454 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && child
->IsEnabled() )
1456 if (child
->MacDispatchMouseEvent(event
))
1463 event
.SetEventObject( this ) ;
1465 if ( wxBusyCursorCount
== 0 )
1467 m_cursor
.MacInstall() ;
1470 if ( event
.GetEventType() == wxEVT_LEFT_DOWN
)
1472 // set focus to this window
1473 if (AcceptsFocus() && FindFocus()!=this)
1478 if ( event
.GetEventType() == wxEVT_MOTION
1479 || event
.GetEventType() == wxEVT_ENTER_WINDOW
1480 || event
.GetEventType() == wxEVT_LEAVE_WINDOW
)
1481 wxToolTip::RelayEvent( this , event
);
1482 #endif // wxUSE_TOOLTIPS
1484 if (gs_lastWhich
!= this)
1486 gs_lastWhich
= this;
1488 // Double clicks must always occur on the same window
1489 if (event
.GetEventType() == wxEVT_LEFT_DCLICK
)
1490 event
.SetEventType( wxEVT_LEFT_DOWN
);
1491 if (event
.GetEventType() == wxEVT_RIGHT_DCLICK
)
1492 event
.SetEventType( wxEVT_RIGHT_DOWN
);
1494 // Same for mouse up events
1495 if (event
.GetEventType() == wxEVT_LEFT_UP
)
1497 if (event
.GetEventType() == wxEVT_RIGHT_UP
)
1501 GetEventHandler()->ProcessEvent( event
) ;
1506 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
1510 return m_tooltip
->GetTip() ;
1515 void wxWindowMac::Update()
1517 wxTopLevelWindowMac
* win
= MacGetTopLevelWindow( ) ;
1520 win
->MacUpdate( 0 ) ;
1521 #if TARGET_API_MAC_CARBON
1522 if ( QDIsPortBuffered( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) ) )
1524 QDFlushPortBuffer( GetWindowPort( (WindowRef
) win
->MacGetWindowRef() ) , NULL
) ;
1530 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
1532 wxTopLevelWindowMac
* win
= NULL
;
1533 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1536 win
= wxFindWinFromMacWindow( window
) ;
1541 const wxRegion
& wxWindowMac::MacGetVisibleRegion()
1543 RgnHandle visRgn
= NewRgn() ;
1544 RgnHandle tempRgn
= NewRgn() ;
1546 SetRectRgn( visRgn
, 0 , 0 , m_width
, m_height
) ;
1548 //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
1549 if ( IsKindOf( CLASSINFO( wxStaticBox
) ) )
1551 int borderTop
= 14 ;
1552 int borderOther
= 4 ;
1554 SetRectRgn( tempRgn
, borderOther
, borderTop
, m_width
- borderOther
, m_height
- borderOther
) ;
1555 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1558 if ( !IsTopLevel() )
1560 wxWindow
* parent
= GetParent() ;
1563 wxSize size
= parent
->GetSize() ;
1566 parent
->MacWindowToRootWindow( &x
, &y
) ;
1567 MacRootWindowToWindow( &x
, &y
) ;
1568 SetRectRgn( tempRgn
, x
, y
, x
+ size
.x
, y
+ size
.y
) ;
1569 SectRgn( visRgn
, tempRgn
, visRgn
) ;
1570 if ( parent
->IsTopLevel() )
1572 parent
= parent
->GetParent() ;
1575 if ( GetWindowStyle() & wxCLIP_CHILDREN
)
1577 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1579 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1581 if ( !child
->IsTopLevel() && child
->IsShown() )
1583 SetRectRgn( tempRgn
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1584 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1589 if ( (GetWindowStyle() & wxCLIP_SIBLINGS
) && GetParent() )
1591 bool thisWindowThrough
= false ;
1592 for (wxNode
*node
= GetParent()->GetChildren().First(); node
; node
= node
->Next())
1594 wxWindowMac
*sibling
= (wxWindowMac
*)node
->Data();
1595 if ( sibling
== this )
1597 thisWindowThrough
= true ;
1600 if( !thisWindowThrough
)
1605 if ( !sibling
->IsTopLevel() && sibling
->IsShown() )
1607 SetRectRgn( tempRgn
, sibling
->m_x
- m_x
, sibling
->m_y
- m_y
, sibling
->m_x
+ sibling
->m_width
- m_x
, sibling
->m_y
+ sibling
->m_height
- m_y
) ;
1608 DiffRgn( visRgn
, tempRgn
, visRgn
) ;
1612 m_macVisibleRegion
= visRgn
;
1613 DisposeRgn( visRgn
) ;
1614 DisposeRgn( tempRgn
) ;
1615 return m_macVisibleRegion
;
1618 void wxWindowMac::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
1620 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
1621 // updatergn is always already clipped to our boundaries
1622 // it is in window coordinates, not in client coordinates
1624 WindowRef window
= (WindowRef
) MacGetRootWindow() ;
1627 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
1628 RgnHandle ownUpdateRgn
= NewRgn() ;
1629 CopyRgn( updatergn
, ownUpdateRgn
) ;
1631 SectRgn( ownUpdateRgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn
) ;
1633 // newupdate is the update region in client coordinates
1634 RgnHandle newupdate
= NewRgn() ;
1635 wxSize point
= GetClientSize() ;
1636 wxPoint origin
= GetClientAreaOrigin() ;
1637 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
1638 SectRgn( newupdate
, ownUpdateRgn
, newupdate
) ;
1639 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
1640 m_updateRegion
= newupdate
;
1641 DisposeRgn( newupdate
) ; // it's been cloned to m_updateRegion
1643 if ( erase
&& !EmptyRgn(ownUpdateRgn
) )
1645 wxWindowDC
dc(this);
1646 dc
.SetClippingRegion(wxRegion(ownUpdateRgn
));
1647 wxEraseEvent
eevent( GetId(), &dc
);
1648 eevent
.SetEventObject( this );
1649 GetEventHandler()->ProcessEvent( eevent
);
1651 wxNcPaintEvent
eventNc( GetId() );
1652 eventNc
.SetEventObject( this );
1653 GetEventHandler()->ProcessEvent( eventNc
);
1655 DisposeRgn( ownUpdateRgn
) ;
1656 if ( !m_updateRegion
.Empty() )
1659 event
.m_timeStamp
= time
;
1660 event
.SetEventObject(this);
1661 GetEventHandler()->ProcessEvent(event
);
1665 // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
1667 RgnHandle childupdate
= NewRgn() ;
1668 for (wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
1670 // calculate the update region for the child windows by intersecting the window rectangle with our own
1671 // passed in update region and then offset it to be client-wise window coordinates again
1672 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1673 SetRectRgn( childupdate
, child
->m_x
, child
->m_y
, child
->m_x
+ child
->m_width
, child
->m_y
+ child
->m_height
) ;
1674 SectRgn( childupdate
, updatergn
, childupdate
) ;
1675 OffsetRgn( childupdate
, -child
->m_x
, -child
->m_y
) ;
1676 if ( child
->MacGetRootWindow() == window
&& child
->IsShown() && !EmptyRgn( childupdate
) )
1678 // because dialogs may also be children
1679 child
->MacRedraw( childupdate
, time
, erase
) ;
1682 DisposeRgn( childupdate
) ;
1683 // eventually a draw grow box here
1687 WXHWND
wxWindowMac::MacGetRootWindow() const
1689 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1693 if ( iter
->IsTopLevel() )
1694 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
1696 iter
= iter
->GetParent() ;
1698 wxASSERT_MSG( 1 , "No valid mac root window" ) ;
1702 void wxWindowMac::MacCreateScrollBars( long style
)
1704 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, "attempt to create window twice" ) ;
1706 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
1707 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1: 0 ;
1709 GetClientSize( &width
, &height
) ;
1711 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1712 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1713 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1714 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1716 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
1717 vSize
, wxVERTICAL
);
1719 if ( style
& wxVSCROLL
)
1725 m_vScrollBar
->Show(false) ;
1727 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
1728 hSize
, wxHORIZONTAL
);
1729 if ( style
& wxHSCROLL
)
1734 m_hScrollBar
->Show(false) ;
1737 // because the create does not take into account the client area origin
1738 MacRepositionScrollBars() ; // we might have a real position shift
1741 void wxWindowMac::MacRepositionScrollBars()
1743 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
1744 int adjust
= hasBoth
? MAC_SCROLLBAR_SIZE
- 1 : 0 ;
1746 // get real client area
1748 int width
= m_width
;
1749 int height
= m_height
;
1751 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
1752 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
1754 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
1755 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
1756 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
1757 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
1764 MacClientToRootWindow( &x
, &y
) ;
1765 MacClientToRootWindow( &w
, &h
) ;
1767 wxWindowMac
*iter
= (wxWindowMac
*)this ;
1769 int totW
= 10000 , totH
= 10000;
1772 if ( iter
->IsTopLevel() )
1774 totW
= iter
->m_width
;
1775 totH
= iter
->m_height
;
1779 iter
= iter
->GetParent() ;
1807 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1811 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
1815 bool wxWindowMac::AcceptsFocus() const
1817 return MacCanFocus() && wxWindowBase::AcceptsFocus();
1820 WXWidget
wxWindowMac::MacGetContainerForEmbedding()
1822 return GetParent()->MacGetContainerForEmbedding() ;
1825 void wxWindowMac::MacSuperChangedPosition()
1827 // only window-absolute structures have to be moved i.e. controls
1829 wxNode
*node
= GetChildren().First();
1832 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1833 child
->MacSuperChangedPosition() ;
1834 node
= node
->Next();
1838 void wxWindowMac::MacTopLevelWindowChangedPosition()
1840 // only screen-absolute structures have to be moved i.e. glcanvas
1842 wxNode
*node
= GetChildren().First();
1845 wxWindowMac
*child
= (wxWindowMac
*)node
->Data();
1846 child
->MacTopLevelWindowChangedPosition() ;
1847 node
= node
->Next();
1850 long wxWindowMac::MacGetLeftBorderSize( ) const
1855 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
1858 #if wxMAC_USE_THEME_BORDER
1860 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1865 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
1868 #if wxMAC_USE_THEME_BORDER
1870 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
1875 else if (m_windowStyle
&wxSIMPLE_BORDER
)
1882 long wxWindowMac::MacGetRightBorderSize( ) const
1884 // they are all symmetric in mac themes
1885 return MacGetLeftBorderSize() ;
1888 long wxWindowMac::MacGetTopBorderSize( ) const
1890 // they are all symmetric in mac themes
1891 return MacGetLeftBorderSize() ;
1894 long wxWindowMac::MacGetBottomBorderSize( ) const
1896 // they are all symmetric in mac themes
1897 return MacGetLeftBorderSize() ;
1900 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
1902 return style
& ~( wxDOUBLE_BORDER
| wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxBORDER
| wxSTATIC_BORDER
) ;
1905 // Find the wxWindowMac at the current mouse position, returning the mouse
1907 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
1909 pt
= wxGetMousePosition();
1910 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
1914 // Get the current mouse position.
1915 wxPoint
wxGetMousePosition()
1918 wxGetMousePosition(& x
, & y
);
1919 return wxPoint(x
, y
);