X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8907154c1a8a6882c6797d1f16393ddfb23e7f3a..67193066b2d16ca36529216f70d093690d7e1123:/src/mac/classic/toplevel.cpp diff --git a/src/mac/classic/toplevel.cpp b/src/mac/classic/toplevel.cpp index d9d095ca97..aa5bc6892d 100644 --- a/src/mac/classic/toplevel.cpp +++ b/src/mac/classic/toplevel.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: mac/toplevel.cpp +// Name: src/mac/classic/toplevel.cpp // Purpose: implements wxTopLevelWindow for Mac // Author: Stefan Csomor // Modified by: @@ -24,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" @@ -35,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 @@ -265,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 ) ) @@ -310,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); @@ -365,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 ; @@ -402,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 ) ; @@ -417,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 ; @@ -498,19 +498,19 @@ void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win) 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 @@ -550,7 +550,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent, if ( parent ) parent->AddChild(this); - return TRUE; + return true; } wxTopLevelWindowMac::~wxTopLevelWindowMac() @@ -641,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. @@ -738,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) ) { @@ -805,8 +805,8 @@ 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, WXWindow *window , wxWindowMac** rootwin) @@ -902,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 ) @@ -1059,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); } } @@ -1079,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 ); @@ -1130,7 +1135,7 @@ bool wxTopLevelWindowMac::Show(bool show) Refresh() ; } - return TRUE; + return true; } void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) @@ -1195,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 @@ -1290,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 @@ -1317,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 } @@ -1386,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 } } @@ -1424,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 @@ -1457,4 +1462,3 @@ static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 #endif // --------------------------------------------------------------------------- -