X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..0c9d7ace58512847c3aa4177c650723b6e971a28:/src/mac/classic/toplevel.cpp diff --git a/src/mac/classic/toplevel.cpp b/src/mac/classic/toplevel.cpp index 0149fbc37d..aa5bc6892d 100644 --- a/src/mac/classic/toplevel.cpp +++ b/src/mac/classic/toplevel.cpp @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: mac/toplevel.cpp +// Name: src/mac/classic/toplevel.cpp // Purpose: implements wxTopLevelWindow for Mac // Author: Stefan Csomor // Modified by: // Created: 24.09.01 // RCS-ID: $Id$ // Copyright: (c) 2001-2004 Stefan Csomor -// License: wxWidgets licence +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation "toplevel.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -28,9 +24,10 @@ #pragma hdrstop #endif +#include "wx/toplevel.h" + #ifndef WX_PRECOMP #include "wx/app.h" - #include "wx/toplevel.h" #include "wx/frame.h" #include "wx/string.h" #include "wx/log.h" @@ -39,7 +36,6 @@ #include "wx/mac/uma.h" #include "wx/mac/aga.h" -#include "wx/app.h" #include "wx/tooltip.h" #include "wx/dnd.h" #if wxUSE_SYSTEM_OPTIONS @@ -211,7 +207,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event event.m_x = point.h; event.m_y = point.v; - event.m_timeStamp = when; + event.SetTimestamp(when); wxWindow* focus = wxWindow::FindFocus() ; event.SetEventObject(focus); @@ -269,17 +265,17 @@ pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event if ( button == 0 || GetEventKind( event ) == kEventMouseUp ) modifiers += btnState ; - // temporary hack to support true two button mouse - if ( button == kEventMouseButtonSecondary ) - { - modifiers |= controlKey ; - } + // temporary hack to support true two button mouse + if ( button == kEventMouseButtonSecondary ) + { + modifiers |= controlKey ; + } WindowRef window ; short windowPart = ::FindWindow(point, &window); // either we really are active or we are capturing mouse events - if ( (IsWindowActive(window) && windowPart == inContent) || + if ( (IsWindowActive(window) && windowPart == inContent) || (wxTheApp->s_captureWindow && wxTheApp->s_captureWindow->MacGetTopLevelWindow() == toplevelWindow) ) { switch ( GetEventKind( event ) ) @@ -314,17 +310,17 @@ pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event NULL, sizeof(Point), NULL, &mouseLoc) == noErr) { wxMouseEvent wheelEvent(wxEVT_MOUSEWHEEL); - + wheelEvent.m_x = mouseLoc.h; wheelEvent.m_y = mouseLoc.v; - + wheelEvent.m_wheelRotation = delta; wheelEvent.m_wheelDelta = 1; wheelEvent.m_linesPerAction = 1; wxWindow* currentMouseWindow = NULL; wxWindow::MacGetWindowFromPoint(wxPoint(mouseLoc.h, mouseLoc.v), ¤tMouseWindow); - + if (currentMouseWindow) { currentMouseWindow->GetEventHandler()->ProcessEvent(wheelEvent); @@ -369,10 +365,10 @@ static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRe toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , false) ; result = noErr ; break ; - case kEventWindowShown : - toplevelWindow->Refresh() ; - result = noErr ; - break ; + case kEventWindowShown : + toplevelWindow->Refresh() ; + result = noErr ; + break ; case kEventWindowClose : toplevelWindow->Close() ; result = noErr ; @@ -406,12 +402,12 @@ static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRe wxSize formerSize = toplevelWindow->GetSize() ; - if ( (attributes & kWindowBoundsChangeSizeChanged ) || + if ( (attributes & kWindowBoundsChangeSizeChanged ) || ( attributes & kWindowBoundsChangeOriginChanged ) ) toplevelWindow->SetSize( newContentRect.left , newContentRect.top , newContentRect.right - newContentRect.left , newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING); - + int x , y , w , h ; toplevelWindow->GetPosition( &x , &y ) ; toplevelWindow->GetSize( &w , &h ) ; @@ -421,10 +417,10 @@ static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRe { SetEventParameter( event , kEventParamCurrentBounds , typeQDRectangle, sizeof( adjustedRect ) , &adjustedRect ) ; } - + if ( toplevelWindow->GetSize() != formerSize ) toplevelWindow->Update() ; - + result = noErr ; } break ; @@ -479,7 +475,8 @@ wxTopLevelWindowMac *wxFindWinFromMacWindow(WXWindow inWindowRef) return (wxTopLevelWindowMac *)node->GetData(); } -void wxAssociateWinWithMacWindow(WXWindow inWindowRef, wxTopLevelWindowMac *win) +void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win); +void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win) { // adding NULL WindowRef is (first) surely a result of an error and // (secondly) breaks menu command processing @@ -499,21 +496,21 @@ void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win) // wxTopLevelWindowMac creation // ---------------------------------------------------------------------------- -WXHWND wxTopLevelWindowMac::s_macWindowInUpdate = NULL; +WXWindow wxTopLevelWindowMac::s_macWindowInUpdate = NULL; wxTopLevelWindowMac *wxTopLevelWindowMac::s_macDeactivateWindow = NULL; -bool wxTopLevelWindowMac::s_macWindowCompositing = FALSE; +bool wxTopLevelWindowMac::s_macWindowCompositing = false; void wxTopLevelWindowMac::Init() { m_iconized = - m_maximizeOnShow = FALSE; + m_maximizeOnShow = false; m_macNoEraseUpdateRgn = NewRgn() ; m_macNeedsErasing = false ; m_macWindow = NULL ; - m_macUsesCompositing = FALSE ; + m_macUsesCompositing = false ; #if TARGET_CARBON m_macEventHandler = NULL ; - #endif +#endif } class wxMacDeferredWindowDeleter : public wxObject @@ -553,7 +550,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent, if ( parent ) parent->AddChild(this); - return TRUE; + return true; } wxTopLevelWindowMac::~wxTopLevelWindowMac() @@ -644,7 +641,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, OSStatus err = noErr ; SetName(name); m_windowStyle = style; - m_isShown = FALSE; + m_isShown = false; // create frame. @@ -741,21 +738,21 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, #endif #endif - //this setup lets us have compositing and non-compositing - //windows in the same application. - -#if UNIVERSAL_INTERFACES_VERSION >= 0x0400 + //this setup lets us have compositing and non-compositing + //windows in the same application. + +#if UNIVERSAL_INTERFACES_VERSION >= 0x0400 if ( wxTopLevelWindowMac::s_macWindowCompositing ) { attr |= kWindowCompositingAttribute; - m_macUsesCompositing = TRUE; + m_macUsesCompositing = true; } else #endif { - m_macUsesCompositing = FALSE; + m_macUsesCompositing = false; } - + #if TARGET_CARBON if ( HasFlag(wxFRAME_SHAPED) ) { @@ -774,7 +771,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, } wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") ); - wxAssociateWinWithMacWindow( m_macWindow , this ) ; + wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ; UMASetWTitle( (WindowRef)m_macWindow , title , m_font.GetEncoding() ) ; if ( wxTopLevelWindowMac::s_macWindowCompositing ) { @@ -808,11 +805,11 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, bool wxTopLevelWindowMac::MacEnableCompositing( bool useCompositing ) { bool oldval = s_macWindowCompositing; - s_macWindowCompositing = useCompositing; - return oldval; + s_macWindowCompositing = useCompositing; + return oldval; } -void wxTopLevelWindowMac::MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR clipRect, WXHWND *window , wxWindowMac** rootwin) +void wxTopLevelWindowMac::MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR clipRect, WXWindow *window , wxWindowMac** rootwin) { ((Point*)localOrigin)->h = 0; ((Point*)localOrigin)->v = 0; @@ -905,7 +902,7 @@ void wxTopLevelWindowMac::MacFireMouseEvent( event.m_leftDown = isDown && !controlDown; - event.m_middleDown = FALSE; + event.m_middleDown = false; event.m_rightDown = isDown && controlDown; if ( kind == mouseDown ) @@ -949,7 +946,7 @@ void wxTopLevelWindowMac::MacFireMouseEvent( if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 ) { // This is not right if the second mouse down - // event occured in a differen window. We + // event occurred in a different window. We // correct this in MacDispatchMouseEvent. if ( controlDown ) event.SetEventType(wxEVT_RIGHT_DCLICK ) ; @@ -970,7 +967,7 @@ void wxTopLevelWindowMac::MacFireMouseEvent( event.m_x += m_x; event.m_y += m_y; - event.m_timeStamp = timestamp; + event.SetTimestamp(timestamp); event.SetEventObject(this); if ( wxTheApp->s_captureWindow ) { @@ -1050,7 +1047,7 @@ void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating ) s_macDeactivateWindow=NULL; MacDelayedDeactivation(timestamp); wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId); - event.m_timeStamp = timestamp ; + event.SetTimestamp(timestamp); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); @@ -1062,13 +1059,13 @@ void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating ) long osVersion = UMAGetSystemVersion(); if (osVersion >= 0x1000 && osVersion < 0x1020 ) { - Refresh(TRUE); + Refresh(true); } else { // for the moment we have to resolve some redrawing issues like this // the OS is stealing some redrawing areas as soon as it draws a control - Refresh(TRUE); + Refresh(true); } } @@ -1082,18 +1079,23 @@ void wxTopLevelWindowMac::MacKeyDown( WXEVENTREF ev ) void wxTopLevelWindowMac::SetTitle(const wxString& title) { - wxWindow::SetTitle( title ) ; + wxWindow::SetLabel( title ) ; UMASetWTitle( (WindowRef)m_macWindow , title , m_font.GetEncoding() ) ; } +wxString wxTopLevelWindowMac::GetTitle() const +{ + return wxWindow::GetLabel(); +} + bool wxTopLevelWindowMac::Show(bool show) { if ( !wxWindow::Show(show) ) - return FALSE; + return false; if (show) { - #if wxUSE_SYSTEM_OPTIONS //code contributed by Ryan Wilcox December 18, 2003 + #if wxUSE_SYSTEM_OPTIONS //code contributed by Ryan Wilcox December 18, 2003 if ( (wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) ) && ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1) ) { ::ShowWindow( (WindowRef)m_macWindow ); @@ -1133,7 +1135,7 @@ bool wxTopLevelWindowMac::Show(bool show) Refresh() ; } - return TRUE; + return true; } void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) @@ -1198,10 +1200,10 @@ void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) wxFrame* frame = (wxFrame*) this ; #if wxUSE_STATUSBAR frame->PositionStatusBar(); -#endif +#endif #if wxUSE_TOOLBAR frame->PositionToolBar(); -#endif +#endif } if ( doMove ) wxWindowMac::MacTopLevelWindowChangedPosition() ; // like this only children will be notified @@ -1293,7 +1295,7 @@ void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackgro bool wxTopLevelWindowMac::SetShape(const wxRegion& region) { - wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE, + wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false, _T("Shaped windows must be created with the wxFRAME_SHAPED style.")); #if TARGET_CARBON @@ -1320,9 +1322,9 @@ bool wxTopLevelWindowMac::SetShape(const wxRegion& region) // Tell the window manager that the window has changed shape ReshapeCustomWindow((WindowRef)MacGetWindowRef()); - return TRUE; + return true; #else - return FALSE; + return false; #endif } @@ -1389,10 +1391,10 @@ static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn) if (cachedRegion) { Rect windowRect; - wxShapedMacWindowGetPos(window, &windowRect); //how big is the window - CopyRgn(cachedRegion, rgn); //make a copy of our cached region + wxShapedMacWindowGetPos(window, &windowRect); //how big is the window + CopyRgn(cachedRegion, rgn); //make a copy of our cached region OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window - //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size + //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size } } @@ -1427,7 +1429,7 @@ static SInt32 wxShapedMacWindowHitTest(WindowRef window,SInt32 param) static RgnHandle tempRgn=nil; if(!tempRgn) - tempRgn=NewRgn(); + tempRgn=NewRgn(); SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked @@ -1460,4 +1462,3 @@ static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 #endif // --------------------------------------------------------------------------- -