X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6bc3b8e9680e8aa3d50ae4bb41dad22c6dd3ce1b..daebb84bff054d3833baca58a5dc506de56c64a1:/src/mac/classic/window.cpp?ds=sidebyside diff --git a/src/mac/classic/window.cpp b/src/mac/classic/window.cpp index db17efd0b3..e067f9975a 100644 --- a/src/mac/classic/window.cpp +++ b/src/mac/classic/window.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: windows.cpp +// Name: src/mac/classic/window.cpp // Purpose: wxWindowMac // Author: Stefan Csomor // Modified by: @@ -9,11 +9,8 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "window.h" -#endif +#include "wx/wxprec.h" -#include "wx/setup.h" #include "wx/menu.h" #include "wx/window.h" #include "wx/dc.h" @@ -68,8 +65,6 @@ wxWindowMac* gFocusWindow = NULL ; IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) #endif // __WXUNIVERSAL__/__WXMAC__ -#if !USE_SHARED_LIBRARY - BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase) EVT_NC_PAINT(wxWindowMac::OnNcPaint) EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground) @@ -77,8 +72,6 @@ BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase) EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent) END_EVENT_TABLE() -#endif - #define wxMAC_DEBUG_REDRAW 0 #ifndef wxMAC_DEBUG_REDRAW #define wxMAC_DEBUG_REDRAW 0 @@ -98,10 +91,10 @@ END_EVENT_TABLE() void wxWindowMac::Init() { - m_backgroundTransparent = FALSE; + m_backgroundTransparent = false; // as all windows are created with WS_VISIBLE style... - m_isShown = TRUE; + m_isShown = true; m_x = 0; m_y = 0 ; @@ -131,7 +124,7 @@ wxWindowMac::~wxWindowMac() } } - m_isBeingDeleted = TRUE; + m_isBeingDeleted = true; #ifndef __WXUNIVERSAL__ // VS: make sure there's no wxFrame with last focus set to us: @@ -185,7 +178,7 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, long style, const wxString& name) { - wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") ); + wxCHECK_MSG( parent, false, wxT("can't create wxWindowMac without parent") ); #if wxUSE_STATBOX // wxGTK doesn't allow to create controls with static box as the parent so @@ -199,7 +192,7 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, #endif // wxUSE_STATBOX if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) - return FALSE; + return false; parent->AddChild(this); @@ -220,7 +213,7 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, wxWindowCreateEvent event(this); GetEventHandler()->AddPendingEvent(event); - return TRUE; + return true; } void wxWindowMac::SetFocus() @@ -289,11 +282,11 @@ void wxWindowMac::SetFocus() bool wxWindowMac::Enable(bool enable) { if ( !wxWindowBase::Enable(enable) ) - return FALSE; + return false; MacSuperEnabled( enable ) ; - return TRUE; + return true; } void wxWindowMac::DoCaptureMouse() @@ -362,7 +355,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) { menu->SetInvokingWindow(this); menu->UpdateUI(); - + if ( x == -1 && y == -1 ) { wxPoint mouse = wxGetMousePosition(); @@ -392,7 +385,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) menu->SetInvokingWindow(NULL); - return TRUE; + return true; } #endif @@ -486,17 +479,17 @@ void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const bool wxWindowMac::SetCursor(const wxCursor& cursor) { if (m_cursor == cursor) - return FALSE; + return false; if (wxNullCursor == cursor) { if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) ) - return FALSE ; + return false ; } else { if ( ! wxWindowBase::SetCursor( cursor ) ) - return FALSE ; + return false ; } wxASSERT_MSG( m_cursor.Ok(), @@ -516,7 +509,7 @@ bool wxWindowMac::SetCursor(const wxCursor& cursor) } } - return TRUE ; + return true ; } @@ -645,40 +638,40 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) oldRgn = NewRgn() ; newRgn = NewRgn() ; diffRgn = NewRgn() ; - + // invalidate the differences between the old and the new area - + SetRectRgn(oldRgn , oldPos.x , oldPos.y , oldPos.x + m_width , oldPos.y + m_height ) ; SetRectRgn(newRgn , newPos.x , newPos.y , newPos.x + actualWidth , newPos.y + actualHeight ) ; DiffRgn( newRgn , oldRgn , diffRgn ) ; InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ; DiffRgn( oldRgn , newRgn , diffRgn ) ; InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ; - + // we also must invalidate the border areas, someone might optimize this one day to invalidate only the really // changing pixels... - - if ( MacGetLeftBorderSize() != 0 || MacGetRightBorderSize() != 0 || - MacGetTopBorderSize() != 0 || MacGetBottomBorderSize() != 0 ) + + if ( MacGetLeftBorderSize() != 0 || MacGetRightBorderSize() != 0 || + MacGetTopBorderSize() != 0 || MacGetBottomBorderSize() != 0 ) { - RgnHandle innerOldRgn, innerNewRgn ; - innerOldRgn = NewRgn() ; - innerNewRgn = NewRgn() ; - - SetRectRgn(innerOldRgn , oldPos.x + MacGetLeftBorderSize() , oldPos.y + MacGetTopBorderSize() , - oldPos.x + m_width - MacGetRightBorderSize() , oldPos.y + m_height - MacGetBottomBorderSize() ) ; - DiffRgn( oldRgn , innerOldRgn , diffRgn ) ; - InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ; - - SetRectRgn(innerNewRgn , newPos.x + MacGetLeftBorderSize() , newPos.y + MacGetTopBorderSize() , - newPos.x + actualWidth - MacGetRightBorderSize() , newPos.y + actualHeight - MacGetBottomBorderSize() ) ; - DiffRgn( newRgn , innerNewRgn , diffRgn ) ; - InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ; - - DisposeRgn( innerOldRgn ) ; - DisposeRgn( innerNewRgn ) ; + RgnHandle innerOldRgn, innerNewRgn ; + innerOldRgn = NewRgn() ; + innerNewRgn = NewRgn() ; + + SetRectRgn(innerOldRgn , oldPos.x + MacGetLeftBorderSize() , oldPos.y + MacGetTopBorderSize() , + oldPos.x + m_width - MacGetRightBorderSize() , oldPos.y + m_height - MacGetBottomBorderSize() ) ; + DiffRgn( oldRgn , innerOldRgn , diffRgn ) ; + InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ; + + SetRectRgn(innerNewRgn , newPos.x + MacGetLeftBorderSize() , newPos.y + MacGetTopBorderSize() , + newPos.x + actualWidth - MacGetRightBorderSize() , newPos.y + actualHeight - MacGetBottomBorderSize() ) ; + DiffRgn( newRgn , innerNewRgn , diffRgn ) ; + InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ; + + DisposeRgn( innerOldRgn ) ; + DisposeRgn( innerNewRgn ) ; } - + DisposeRgn(oldRgn) ; DisposeRgn(newRgn) ; DisposeRgn(diffRgn) ; @@ -800,12 +793,12 @@ wxPoint wxWindowMac::GetClientAreaOrigin() const return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) ); } -void wxWindowMac::SetTitle(const wxString& title) +void wxWindowMac::SetLabel(const wxString& label) { - m_label = title ; + m_label = label ; } -wxString wxWindowMac::GetTitle() const +wxString wxWindowMac::GetLabel() const { return m_label ; } @@ -813,12 +806,12 @@ wxString wxWindowMac::GetTitle() const bool wxWindowMac::Show(bool show) { if ( !wxWindowBase::Show(show) ) - return FALSE; + return false; MacSuperShown( show ) ; Refresh() ; - return TRUE; + return true; } void wxWindowMac::MacSuperShown( bool show ) @@ -912,8 +905,8 @@ void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect) return ; if ( !MacIsReallyShown() ) - return ; - + return ; + wxPoint client = GetClientAreaOrigin(); int x1 = -client.x; int y1 = -client.y; @@ -1102,26 +1095,26 @@ void wxWindowMac::MacPaintBorders( int left , int top ) { if( IsTopLevel() ) return ; - + int major,minor; wxGetOsVersion( &major, &minor ); RGBColor white = { 0xFFFF, 0xFFFF , 0xFFFF } ; RGBColor face = { 0xDDDD, 0xDDDD , 0xDDDD } ; - + RGBColor darkShadow = { 0x0000, 0x0000 , 0x0000 } ; RGBColor lightShadow = { 0x4444, 0x4444 , 0x4444 } ; // OS X has lighter border edges than classic: - if (major >= 10) - { - darkShadow.red = 0x8E8E; - darkShadow.green = 0x8E8E; - darkShadow.blue = 0x8E8E; - lightShadow.red = 0xBDBD; - lightShadow.green = 0xBDBD; - lightShadow.blue = 0xBDBD; - } - + if (major >= 10) + { + darkShadow.red = 0x8E8E; + darkShadow.green = 0x8E8E; + darkShadow.blue = 0x8E8E; + lightShadow.red = 0xBDBD; + lightShadow.green = 0xBDBD; + lightShadow.blue = 0xBDBD; + } + PenNormal() ; if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) ) @@ -1232,7 +1225,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) { if( dx == 0 && dy ==0 ) return ; - + { wxClientDC dc(this) ; @@ -1251,7 +1244,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) SectRect( &scrollrect , &r , &scrollrect ) ; } ScrollRect( &scrollrect , dx , dy , updateRgn ) ; - // we also have to scroll the update rgn in this rectangle + // we also have to scroll the update rgn in this rectangle // in order not to loose updates WindowRef rootWindow = (WindowRef) MacGetRootWindow() ; RgnHandle formerUpdateRgn = NewRgn() ; @@ -1293,46 +1286,46 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) } else { - child->SetSize( x+dx, y+dy, w, h ); - } + child->SetSize( x+dx, y+dy, w, h ); + } } - + Update() ; } void wxWindowMac::MacOnScroll(wxScrollEvent &event ) { - if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar ) + if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar ) { wxScrollWinEvent wevent; wevent.SetPosition(event.GetPosition()); wevent.SetOrientation(event.GetOrientation()); - wevent.m_eventObject = this; - - if (event.m_eventType == wxEVT_SCROLL_TOP) - wevent.m_eventType = wxEVT_SCROLLWIN_TOP; - else if (event.m_eventType == wxEVT_SCROLL_BOTTOM) - wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM; - else if (event.m_eventType == wxEVT_SCROLL_LINEUP) - wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP; - else if (event.m_eventType == wxEVT_SCROLL_LINEDOWN) - wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; - else if (event.m_eventType == wxEVT_SCROLL_PAGEUP) - wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; - else if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN) - wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; - else if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK) - wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; - else if (event.m_eventType == wxEVT_SCROLL_THUMBRELEASE) - wevent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE; + wevent.SetEventObject(this); + + if (event.GetEventType() == wxEVT_SCROLL_TOP) + wevent.SetEventType( wxEVT_SCROLLWIN_TOP ); + else if (event.GetEventType() == wxEVT_SCROLL_BOTTOM) + wevent.SetEventType( wxEVT_SCROLLWIN_BOTTOM ); + else if (event.GetEventType() == wxEVT_SCROLL_LINEUP) + wevent.SetEventType( wxEVT_SCROLLWIN_LINEUP ); + else if (event.GetEventType() == wxEVT_SCROLL_LINEDOWN) + wevent.SetEventType( wxEVT_SCROLLWIN_LINEDOWN ); + else if (event.GetEventType() == wxEVT_SCROLL_PAGEUP) + wevent.SetEventType( wxEVT_SCROLLWIN_PAGEUP ); + else if (event.GetEventType() == wxEVT_SCROLL_PAGEDOWN) + wevent.SetEventType( wxEVT_SCROLLWIN_PAGEDOWN ); + else if (event.GetEventType() == wxEVT_SCROLL_THUMBTRACK) + wevent.SetEventType( wxEVT_SCROLLWIN_THUMBTRACK ); + else if (event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE) + wevent.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE ); GetEventHandler()->ProcessEvent(wevent); } } // Get the window with the focus -wxWindowMac *wxWindowBase::FindFocus() +wxWindowMac *wxWindowBase::DoFindFocus() { return gFocusWindow ; } @@ -1404,13 +1397,13 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** { if ((point.x < 0) || (point.y < 0) || (point.x > (m_width)) || (point.y > (m_height))) - return FALSE; + return false; } else { if ((point.x < m_x) || (point.y < m_y) || (point.x > (m_x + m_width)) || (point.y > (m_y + m_height))) - return FALSE; + return false; } WindowRef window = (WindowRef) MacGetRootWindow() ; @@ -1430,12 +1423,12 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** if ( child->MacGetRootWindow() == (WXWindow) window && child->m_isShown ) { if (child->MacGetWindowFromPointSub(newPoint , outWin )) - return TRUE; + return true; } } *outWin = this ; - return TRUE; + return true; } bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMac** outWin ) @@ -1463,7 +1456,7 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa return win->MacGetWindowFromPointSub( point , outWin ) ; } } - return FALSE ; + return false ; } static wxWindow *gs_lastWhich = NULL; @@ -1511,14 +1504,14 @@ bool wxWindowMac::MacSetupCursor( const wxPoint& pt) } bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) -{ +{ if ((event.m_x < m_x) || (event.m_y < m_y) || (event.m_x > (m_x + m_width)) || (event.m_y > (m_y + m_height))) - return FALSE; + return false; if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) /* || IsKindOf( CLASSINFO( wxSpinCtrl ) ) */) - return FALSE ; + return false ; WindowRef window = (WindowRef) MacGetRootWindow() ; @@ -1534,7 +1527,7 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) if ( child->MacGetRootWindow() == (WXWindow) window && child->IsShown() && child->IsEnabled() ) { if (child->MacDispatchMouseEvent(event)) - return TRUE; + return true; } } @@ -1577,14 +1570,14 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) // Same for mouse up events if (event.GetEventType() == wxEVT_LEFT_UP) - return TRUE; + return true; if (event.GetEventType() == wxEVT_RIGHT_UP) - return TRUE; + return true; } GetEventHandler()->ProcessEvent( event ) ; - return TRUE; + return true; } wxString wxWindowMac::MacGetToolTipString( wxPoint &pt ) @@ -1602,7 +1595,7 @@ void wxWindowMac::Update() int top = 0 , left = 0 ; MacWindowToRootWindow( &left , &top ) ; WindowRef rootWindow = (WindowRef) MacGetRootWindow() ; - RgnHandle updateRgn = NewRgn() ; + RgnHandle updateRgn = NewRgn() ; // getting the update region in macos local coordinates GetWindowUpdateRgn( rootWindow , updateRgn ) ; GrafPtr port ; @@ -1700,7 +1693,7 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSibling int borderOther = 4 ; if ( UMAGetSystemVersion() >= 0x1030 ) borderTop += 2 ; - + SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ; DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; } @@ -1803,12 +1796,12 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) hiddenWindows.Append( child ) ; } } - + wxPaintEvent event; - event.m_timeStamp = time ; + event.SetTimestamp(time); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); - + for (wxWindowListNode *node = hiddenWindows.GetFirst(); node; node = node->GetNext()) { wxControl *child = wxDynamicCast( ( wxWindow*)node->GetData() , wxControl ) ; @@ -2080,9 +2073,9 @@ wxPoint wxGetMousePosition() void wxWindowMac::OnMouseEvent( wxMouseEvent &event ) { - if ( event.GetEventType() == wxEVT_RIGHT_DOWN ) - { - // copied from wxGTK : CS + if ( event.GetEventType() == wxEVT_RIGHT_DOWN ) + { + // copied from wxGTK : CS // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN // except that: // @@ -2094,10 +2087,9 @@ void wxWindowMac::OnMouseEvent( wxMouseEvent &event ) this->ClientToScreen(event.GetPosition())); if ( ! GetEventHandler()->ProcessEvent(evtCtx) ) event.Skip() ; - } - else - { - event.Skip() ; - } + } + else + { + event.Skip() ; + } } -