X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ced2fad6f29487fb7db44b7f1876e889535865bc..bc6ca1a9e68a84817092856059d8ee9f5d109d1d:/src/osx/window_osx.cpp diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 5ba3fcaf50..72e3203879 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -67,8 +67,6 @@ #include "wx/osx/uma.h" #else #include "wx/osx/private.h" -// bring in themeing -#include #endif #define MAC_SCROLLBAR_SIZE 15 @@ -128,6 +126,7 @@ void wxWindowMac::Init() m_vScrollBar = NULL ; m_hScrollBarAlwaysShown = false; m_vScrollBarAlwaysShown = false; + m_growBox = NULL ; m_macIsUserPane = true; m_clipChildren = false ; @@ -242,7 +241,11 @@ bool wxWindowMac::Create(wxWindowMac *parent, #ifndef __WXUNIVERSAL__ // Don't give scrollbars to wxControls unless they ask for them - if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar))) + if ( (! IsKindOf(CLASSINFO(wxControl)) +#if wxUSE_STATUSBAR + && ! IsKindOf(CLASSINFO(wxStatusBar)) +#endif + ) || (IsKindOf(CLASSINFO(wxControl)) && ((style & wxHSCROLL) || (style & wxVSCROLL)))) { MacCreateScrollBars( style ) ; @@ -257,10 +260,14 @@ bool wxWindowMac::Create(wxWindowMac *parent, void wxWindowMac::MacChildAdded() { +#if wxUSE_SCROLLBAR if ( m_vScrollBar ) m_vScrollBar->Raise() ; if ( m_hScrollBar ) m_hScrollBar->Raise() ; + if ( m_growBox ) + m_growBox->Raise() ; +#endif } void wxWindowMac::MacPostControlCreate(const wxPoint& WXUNUSED(pos), const wxSize& size) @@ -325,7 +332,7 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant ) break ; default: - wxFAIL_MSG(_T("unexpected window variant")); + wxFAIL_MSG(wxT("unexpected window variant")); break ; } m_peer->SetData(kControlEntireControl, kControlSizeTag, &size ) ; @@ -354,7 +361,7 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant ) break ; default: - wxFAIL_MSG(_T("unexpected window variant")); + wxFAIL_MSG(wxT("unexpected window variant")); break ; } @@ -667,13 +674,14 @@ void wxWindowMac::DoGetClientSize( int *x, int *y ) const int left, top; m_peer->GetContentArea( left, top, ww, hh ); - +#if wxUSE_SCROLLBAR if (m_hScrollBar && m_hScrollBar->IsShown() ) hh -= m_hScrollBar->GetSize().y ; if (m_vScrollBar && m_vScrollBar->IsShown() ) ww -= m_vScrollBar->GetSize().x ; +#endif if (x) *x = ww; if (y) @@ -889,16 +897,21 @@ wxSize wxWindowMac::DoGetBestSize() const r.width = r.height = 16 ; - if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) + if ( 0 ) + { + } +#if wxUSE_SCROLLBAR + else if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) { r.height = 16 ; } - #if wxUSE_SPINBTN +#endif +#if wxUSE_SPINBTN else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) { r.height = 24 ; } - #endif +#endif else { // return wxWindowBase::DoGetBestSize() ; @@ -1019,9 +1032,14 @@ void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight) void wxWindowMac::SetLabel(const wxString& title) { + if ( title == m_label ) + return; + m_label = title ; - if ( m_peer && m_peer->IsOk() && !(IsKindOf( CLASSINFO(wxButton) ) && GetId() == wxID_HELP) ) + InvalidateBestSize(); + + if ( m_peer && m_peer->IsOk() ) m_peer->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ; // do not trigger refreshes upon invisible and possible partly created objects @@ -1042,6 +1060,22 @@ bool wxWindowMac::Show(bool show) if ( m_peer ) m_peer->SetVisibility( show ) ; + wxShowEvent eventShow(GetId(), show); + eventShow.SetEventObject(this); + + HandleWindowEvent(eventShow); + + return true; +} + +bool wxWindowMac::OSXShowWithEffect(bool show, + wxShowEffect effect, + unsigned timeout) +{ + if ( effect == wxSHOW_EFFECT_NONE || + !m_peer || !m_peer->ShowWithEffect(show, effect, timeout) ) + return Show(show); + return true; } @@ -1175,13 +1209,37 @@ wxWindow *wxGetActiveWindow() } // Coordinates relative to the window -void wxWindowMac::WarpPointer(int WXUNUSED(x_pos), int WXUNUSED(y_pos)) +void wxWindowMac::WarpPointer(int x_pos, int y_pos) { - // We really don't move the mouse programmatically under Mac. +#if wxOSX_USE_COCOA_OR_CARBON + int x = x_pos; + int y = y_pos; + DoClientToScreen(&x, &y); + CGPoint cgpoint = CGPointMake( x, y ); + CGWarpMouseCursorPosition( cgpoint ); + + // At least GTK sends a mouse moved event after WarpMouse + wxMouseEvent event(wxEVT_MOTION); + event.m_x = x_pos; + event.m_y = y_pos; + wxMouseState mState = ::wxGetMouseState(); + + event.m_altDown = mState.AltDown(); + event.m_controlDown = mState.ControlDown(); + event.m_leftDown = mState.LeftIsDown(); + event.m_middleDown = mState.MiddleIsDown(); + event.m_rightDown = mState.RightIsDown(); + event.m_metaDown = mState.MetaDown(); + event.m_shiftDown = mState.ShiftDown(); + event.SetId(GetId()); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); +#endif } int wxWindowMac::GetScrollPos(int orient) const { +#if wxUSE_SCROLLBAR if ( orient == wxHORIZONTAL ) { if ( m_hScrollBar ) @@ -1192,7 +1250,7 @@ int wxWindowMac::GetScrollPos(int orient) const if ( m_vScrollBar ) return m_vScrollBar->GetThumbPosition() ; } - +#endif return 0; } @@ -1200,6 +1258,7 @@ int wxWindowMac::GetScrollPos(int orient) const // of positions that we can scroll. int wxWindowMac::GetScrollRange(int orient) const { +#if wxUSE_SCROLLBAR if ( orient == wxHORIZONTAL ) { if ( m_hScrollBar ) @@ -1210,12 +1269,13 @@ int wxWindowMac::GetScrollRange(int orient) const if ( m_vScrollBar ) return m_vScrollBar->GetRange() ; } - +#endif return 0; } int wxWindowMac::GetScrollThumb(int orient) const { +#if wxUSE_SCROLLBAR if ( orient == wxHORIZONTAL ) { if ( m_hScrollBar ) @@ -1226,12 +1286,13 @@ int wxWindowMac::GetScrollThumb(int orient) const if ( m_vScrollBar ) return m_vScrollBar->GetThumbSize() ; } - +#endif return 0; } void wxWindowMac::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) { +#if wxUSE_SCROLLBAR if ( orient == wxHORIZONTAL ) { if ( m_hScrollBar ) @@ -1242,6 +1303,7 @@ void wxWindowMac::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) if ( m_vScrollBar ) m_vScrollBar->SetThumbPosition( pos ) ; } +#endif } void @@ -1275,8 +1337,10 @@ void wxWindowMac::MacPaintGrowBox() if ( IsTopLevel() ) return ; +#if wxUSE_SCROLLBAR if ( MacHasScrollBarCorner() ) { +#if 0 CGContextRef cgContext = (CGContextRef) MacGetCGContextRef() ; wxASSERT( cgContext ) ; @@ -1302,7 +1366,18 @@ void wxWindowMac::MacPaintGrowBox() } CGContextFillRect( cgContext, cgrect ); CGContextRestoreGState( cgContext ); +#else + if (m_growBox) + { + if ( m_backgroundColour.Ok() ) + m_growBox->SetBackgroundColour(m_backgroundColour); + else + m_growBox->SetBackgroundColour(*wxWHITE); + } +#endif } + +#endif } void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(rightOrigin) ) @@ -1363,16 +1438,20 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right void wxWindowMac::RemoveChild( wxWindowBase *child ) { +#if wxUSE_SCROLLBAR if ( child == m_hScrollBar ) m_hScrollBar = NULL ; if ( child == m_vScrollBar ) m_vScrollBar = NULL ; - + if ( child == m_growBox ) + m_growBox = NULL ; +#endif wxWindowBase::RemoveChild( child ) ; } void wxWindowMac::DoUpdateScrollbarVisibility() { +#if wxUSE_SCROLLBAR bool triggerSizeEvent = false; if ( m_hScrollBar ) @@ -1404,18 +1483,21 @@ void wxWindowMac::DoUpdateScrollbarVisibility() event.SetEventObject(this); HandleWindowEvent(event); } +#endif } // New function that will replace some of the above. void wxWindowMac::SetScrollbar(int orient, int pos, int thumb, int range, bool refresh) { +#if wxUSE_SCROLLBAR if ( orient == wxHORIZONTAL && m_hScrollBar ) m_hScrollBar->SetScrollbar(pos, thumb, range, thumb, refresh); else if ( orient == wxVERTICAL && m_vScrollBar ) m_vScrollBar->SetScrollbar(pos, thumb, range, thumb, refresh); DoUpdateScrollbarVisibility(); +#endif } // Does a physical scroll @@ -1444,10 +1526,14 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) child = node->GetData(); if (child == NULL) continue; +#if wxUSE_SCROLLBAR if (child == m_vScrollBar) continue; if (child == m_hScrollBar) continue; + if (child == m_growBox) + continue; +#endif if (child->IsTopLevel()) continue; @@ -1468,6 +1554,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) void wxWindowMac::MacOnScroll( wxScrollEvent &event ) { +#if wxUSE_SCROLLBAR if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar ) { wxScrollWinEvent wevent; @@ -1494,6 +1581,7 @@ void wxWindowMac::MacOnScroll( wxScrollEvent &event ) HandleWindowEvent(wevent); } +#endif } wxWindow *wxWindowBase::DoFindFocus() @@ -1778,7 +1866,7 @@ bool wxWindowMac::MacDoRedraw( long time ) break; } - if ( UseBgCol() && MacGetTopLevelWindow() ) + if ( UseBgCol() ) { dc.SetBackground(GetBackgroundColour()); dc.Clear(); @@ -1831,10 +1919,14 @@ void wxWindowMac::MacPaintChildrenBorders() child = node->GetData(); if (child == NULL) continue; +#if wxUSE_SCROLLBAR if (child == m_vScrollBar) continue; if (child == m_hScrollBar) continue; + if (child == m_growBox) + continue; +#endif if (child->IsTopLevel()) continue; if (!child->IsShown()) @@ -1867,6 +1959,7 @@ WXWindow wxWindowMac::MacGetTopLevelWindowRef() const bool wxWindowMac::MacHasScrollBarCorner() const { +#if wxUSE_SCROLLBAR /* Returns whether the scroll bars in a wxScrolledWindow should be * shortened. Scroll bars should be shortened if either: * @@ -1927,10 +2020,14 @@ bool wxWindowMac::MacHasScrollBarCorner() const // No parent frame found return false ; } +#else + return false; +#endif } void wxWindowMac::MacCreateScrollBars( long style ) { +#if wxUSE_SCROLLBAR wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ; if ( style & ( wxVSCROLL | wxHSCROLL ) ) @@ -1962,22 +2059,32 @@ void wxWindowMac::MacCreateScrollBars( long style ) m_hScrollBar = new wxScrollBar((wxWindow*)this, wxID_ANY, hPoint, hSize , wxHORIZONTAL); m_hScrollBar->SetMinSize( wxDefaultSize ); } + + wxPoint gPoint(width - scrlsize, height - scrlsize); + wxSize gSize(scrlsize, scrlsize); + m_growBox = new wxPanel((wxWindow *)this, wxID_ANY, gPoint, gSize, 0); } // because the create does not take into account the client area origin // we might have a real position shift MacRepositionScrollBars() ; +#endif } bool wxWindowMac::MacIsChildOfClientArea( const wxWindow* child ) const { - bool result = ((child == NULL) || ((child != m_hScrollBar) && (child != m_vScrollBar))); + bool result = ((child == NULL) +#if wxUSE_SCROLLBAR + || ((child != m_hScrollBar) && (child != m_vScrollBar) && (child != m_growBox)) +#endif + ); return result ; } void wxWindowMac::MacRepositionScrollBars() { +#if wxUSE_SCROLLBAR if ( !m_hScrollBar && !m_vScrollBar ) return ; @@ -2000,6 +2107,21 @@ void wxWindowMac::MacRepositionScrollBars() m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE ); if ( m_hScrollBar ) m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE ); + if ( m_growBox ) + { + if ( MacHasScrollBarCorner() ) + { + m_growBox->SetSize( width - scrlsize, height - scrlsize, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING ); + if ( !m_growBox->IsShown() ) + m_growBox->Show(); + } + else + { + if ( m_growBox->IsShown() ) + m_growBox->Hide(); + } + } +#endif } bool wxWindowMac::AcceptsFocus() const @@ -2184,6 +2306,8 @@ bool wxWindowMac::Reparent(wxWindowBase *newParentBase) m_peer->RemoveFromParent(); m_peer->Embed( GetParent()->GetPeer() ); + + MacChildAdded(); return true; }