]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/toplevel.cpp
Warning fixes.
[wxWidgets.git] / src / mac / carbon / toplevel.cpp
index 23472b4bf8bbc9577f767277a1cf082001dbe075..a54c02df217ad617d523ae71fef39b5af13647c9 100644 (file)
@@ -49,6 +49,9 @@
 
 #include <ToolUtils.h>
 
+//For targeting OSX
+#include "wx/mac/private.h"
+
 // ----------------------------------------------------------------------------
 // globals
 // ----------------------------------------------------------------------------
@@ -518,15 +521,6 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
                 cursorPoint += cursorTarget->GetPosition() ;
         }
 
-        // update focus
-
-        if ( wxevent.GetEventType() == wxEVT_LEFT_DOWN )
-        {
-            // set focus to this window
-            if (currentMouseWindow->AcceptsFocus() && wxWindow::FindFocus()!=currentMouseWindow)
-                currentMouseWindow->SetFocus();
-        }
-
         // make tooltips current
         
     #if wxUSE_TOOLTIPS
@@ -539,6 +533,15 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
             result = noErr;
         else
         {
+            // if the user code did _not_ handle the event, then perform the
+            // default processing
+            if ( wxevent.GetEventType() == wxEVT_LEFT_DOWN )
+            {
+                // ... that is set focus to this window
+                if (currentMouseWindow->AcceptsFocus() && wxWindow::FindFocus()!=currentMouseWindow)
+                    currentMouseWindow->SetFocus();
+            }
+
             ControlPartCode dummyPart ;
             // if built-in find control is finding the wrong control (ie static box instead of overlaid
             // button, we cannot let the standard handler do its job, but must handle manually
@@ -738,6 +741,7 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTopLevelEventHandler )
 
 // Find an item given the Macintosh Window Reference
 
+#if KEY_wxList_DEPRECATED
 wxList wxWinMacWindowList(wxKEY_INTEGER);
 wxTopLevelWindowMac *wxFindWinFromMacWindow(WindowRef inWindowRef)
 {
@@ -763,7 +767,43 @@ void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win)
 {
     wxWinMacWindowList.DeleteObject(win);
 }
+#else
+
+WX_DECLARE_HASH_MAP(WindowRef, wxTopLevelWindowMac*, wxPointerHash, wxPointerEqual, MacWindowMap);
+
+static MacWindowMap wxWinMacWindowList;
+
+wxTopLevelWindowMac *wxFindWinFromMacWindow(WindowRef inWindowRef)
+{
+    MacWindowMap::iterator node = wxWinMacWindowList.find(inWindowRef);
+
+    return (node == wxWinMacWindowList.end()) ? NULL : node->second;
+}
+
+void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win) ;
+void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win)
+{
+    // adding NULL WindowRef is (first) surely a result of an error and
+    // nothing else :-)
+    wxCHECK_RET( inWindowRef != (WindowRef) NULL, wxT("attempt to add a NULL WindowRef to window list") );
+
+    wxWinMacWindowList[inWindowRef] = win;
+}
 
+void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win) ;
+void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win)
+{
+    MacWindowMap::iterator it;
+    for ( it = wxWinMacWindowList.begin(); it != wxWinMacWindowList.end(); ++it )
+    {
+        if ( it->second == win )
+        {
+            wxWinMacWindowList.erase(it);
+            break;
+        }
+    }
+}
+#endif // deprecated wxList
 
 // ----------------------------------------------------------------------------
 // wxTopLevelWindowMac creation
@@ -945,10 +985,14 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
 
     int x = (int)pos.x;
     int y = (int)pos.y;
-    if ( y < 50 )
-        y = 50 ;
-    if ( x < 20 )
-        x = 20 ;
+    
+    wxRect display = wxGetClientDisplayRect() ;
+
+    if ( x == wxDefaultPosition.x )
+        x = display.x ;
+    
+    if ( y == wxDefaultPosition.y )
+        y = display.y ;
 
     int w = WidthDefault(size.x);
     int h = HeightDefault(size.y);
@@ -983,7 +1027,7 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
     {
         wclass = kDocumentWindowClass ;
     }
-#if ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 )
+#if defined( __WXMAC__ ) && TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 )
     else if ( HasFlag( wxFRAME_DRAWER ) )
     {
         wclass = kDrawerWindowClass;