]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/nonownedwnd.cpp
fixing toolbar repositioning (iOS)
[wxWidgets.git] / src / osx / carbon / nonownedwnd.cpp
index 192f8f5a2455b658740002b4979ae547538fb556..909e6a3ad1fdc553873a81719e93dd377cdf72eb 100644 (file)
@@ -3,7 +3,7 @@
 // Purpose:     implementation of wxNonOwnedWindow
 // Author:      Stefan Csomor
 // Created:     2008-03-24
-// RCS-ID:      $Id: nonownedwnd.cpp 50329 2007-11-29 17:00:58Z VS $
+// RCS-ID:      $Id$
 // Copyright:   (c) Stefan Csomor 2008
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -254,6 +254,7 @@ void wxNonOwnedWindowCarbonImpl::MacSetUnifiedAppearance( bool set )
 
 static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param);
 
+void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent );
 
 // ---------------------------------------------------------------------------
 // Carbon Events
@@ -322,17 +323,13 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
         GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
         charBuf[ numChars - 1 ] = 0;
 
-#if SIZEOF_WCHAR_T == 2
-        uniChar = charBuf[0] ;
-#else
         wxMBConvUTF16 converter ;
         converter.MB2WC( uniChar , (const char*)charBuf , 2 ) ;
-#endif
 
         if ( numChars * 2 > 4 )
             delete[] charBuf ;
     }
-#endif
+#endif // wxUSE_UNICODE
 
     GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode );
     GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
@@ -537,8 +534,9 @@ void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
                     break ;
             }
             break ;
-
-     case kEventMouseWheelMoved :
+     // TODO http://developer.apple.com/qa/qa2005/qa1453.html
+     // add declaration for 10.4 and change to kEventMouseScroll
+    case kEventMouseWheelMoved :
         {
             wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ;
 
@@ -720,8 +718,8 @@ wxMacTopLevelMouseEventHandler(EventHandlerCallRef WXUNUSED(handler),
 
         if ( currentMouseWindow->HandleWindowEvent(wxevent) )
         {
-            if ((currentMouseWindowParent != NULL) &&
-                (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
+            if ( currentMouseWindowParent &&
+                 !currentMouseWindowParent->GetChildren().Member(currentMouseWindow) )
                 currentMouseWindow = NULL;
 
             result = noErr;
@@ -928,7 +926,7 @@ wxNonOwnedWindowEventHandler(EventHandlerCallRef WXUNUSED(handler),
 // mix this in from window.cpp
 pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
 
-pascal OSStatus wxNonOwnedEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
+static pascal OSStatus wxNonOwnedEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
 {
     OSStatus result = eventNotHandledErr ;
 
@@ -1133,7 +1131,7 @@ wxNonOwnedWindowCarbonImpl::~wxNonOwnedWindowCarbonImpl()
         m_macEventHandler = NULL ;
     }
 
-    if ( m_macWindow )
+    if ( m_macWindow && !m_wxPeer->IsNativeWindowWrapper())
         DisposeWindow( m_macWindow );
 
     FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
@@ -1153,7 +1151,7 @@ void wxNonOwnedWindowCarbonImpl::WillBeDestroyed()
     }
 }
 
-void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
+static void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
 {
     InstallWindowEventHandler(window, GetwxNonOwnedEventHandlerUPP(),
         GetEventTypeCount(eventList), eventList, ref, handler );
@@ -1190,11 +1188,18 @@ void wxNonOwnedWindowCarbonImpl::MacInstallTopLevelWindowEventHandler()
 }
 
 void wxNonOwnedWindowCarbonImpl::Create(
-    wxWindow* parent,
-    const wxPoint& pos,
-    const wxSize& size,
-    long style, long extraStyle,
-    const wxString& WXUNUSED(name) )
+    wxWindow* WXUNUSED(parent),
+    WXWindow nativeWindow )
+{
+    m_macWindow = nativeWindow;
+}
+
+void wxNonOwnedWindowCarbonImpl::Create(
+                                        wxWindow* parent,
+                                        const wxPoint& pos,
+                                        const wxSize& size,
+                                        long style, long extraStyle,
+                                        const wxString& WXUNUSED(name) )
 {
 
     OSStatus err = noErr ;
@@ -1220,7 +1225,7 @@ void wxNonOwnedWindowCarbonImpl::Create(
         if (
             ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
             ( style & wxSYSTEM_MENU ) || ( style & wxCAPTION ) ||
-            ( style &wxTINY_CAPTION_HORIZ) ||  ( style &wxTINY_CAPTION_VERT)
+            ( style & wxTINY_CAPTION)
             )
         {
             if ( ( style & wxSTAY_ON_TOP ) )
@@ -1228,7 +1233,7 @@ void wxNonOwnedWindowCarbonImpl::Create(
             else
                 wclass = kFloatingWindowClass ;
 
-            if ( ( style &wxTINY_CAPTION_VERT) )
+            if ( ( style & wxTINY_CAPTION) )
                 attr |= kWindowSideTitlebarAttribute ;
         }
         else
@@ -1327,13 +1332,13 @@ void wxNonOwnedWindowCarbonImpl::Create(
         customWindowDefSpec.defType = kWindowDefProcPtr;
         customWindowDefSpec.u.defProc =
 #ifdef __LP64__
-            (WindowDefUPP) wxShapedMacWindowDef;
+        (WindowDefUPP) wxShapedMacWindowDef;
 #else
-            NewWindowDefUPP(wxShapedMacWindowDef);
+        NewWindowDefUPP(wxShapedMacWindowDef);
 #endif
         err = ::CreateCustomWindow( &customWindowDefSpec, wclass,
-                              attr, &theBoundsRect,
-                              (WindowRef*) &m_macWindow);
+                                   attr, &theBoundsRect,
+                                   (WindowRef*) &m_macWindow);
     }
     else
     {
@@ -1688,3 +1693,11 @@ wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWind
     now->Create( parent, pos, size, style , extraStyle, name );
     return now;
 }
+
+wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow nativeWindow )
+{
+    wxNonOwnedWindowCarbonImpl* now = new wxNonOwnedWindowCarbonImpl( wxpeer );
+    now->Create( parent, nativeWindow );
+    return now;
+}
+