]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/app.cpp
reSWIGged
[wxWidgets.git] / src / mac / app.cpp
index 2ff6ed261db929a64e3a4aa4adb7c55b1219e763..465ef52384bb67b0a455df99ddba542c92ac9c58 100644 (file)
@@ -69,6 +69,7 @@
 extern wxList wxPendingDelete;
 extern wxList *wxWinMacWindowList;
 extern wxList *wxWinMacControlList;
+extern size_t g_numberOfThreads;
 
 // statics for implementation
 
@@ -810,7 +811,11 @@ void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
 
             // allocate copy to replace .dylib.* extension with .rsrc
             if (theLibPath != NULL) {
-                theResPath = theLibPath;
+#if wxUSE_UNICODE
+                theResPath = wxString(theLibPath, wxConvLocal);
+#else
+                theResPath = wxString(theLibPath);
+#endif
                 // replace '_core' with '' in case of multi-lib build
                 theResPath.Replace(wxT("_core"), wxEmptyString);
                 // replace ".dylib" shared library extension with ".rsrc"
@@ -836,9 +841,8 @@ void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
                 }
                 if (theErr != noErr) {
 #ifdef __WXDEBUG__
-                    fprintf(stderr,
-                            wxT("unable to open wxMac resource file '%s'\n"),
-                            theResPath.mb_str() );
+                    wxLogDebug( wxT("unable to open wxMac resource file '%s'\n"),
+                                theResPath.mb_str() );
 #endif // __WXDEBUG__
                 }
 
@@ -1250,7 +1254,16 @@ void wxApp::MacDoOneEvent()
         if ( wxTheApp->ProcessIdle() )
             sleepTime = kEventDurationNoWait ;
         else
-            sleepTime = kEventDurationForever ;
+        {
+            if (g_numberOfThreads)
+            {
+                sleepTime = kEventDurationNoWait;
+            }
+            else
+            {
+                sleepTime = kEventDurationSecond;
+            }
+        }
     }
     else if ( status == eventLoopQuitErr )
     {
@@ -1284,7 +1297,16 @@ void wxApp::MacDoOneEvent()
         if ( wxTheApp->ProcessIdle() )
             sleepTime = kEventDurationNoWait;
         else
-            sleepTime = GetCaretTime() / 2 ;
+        {
+            if (g_numberOfThreads)
+            {
+                sleepTime = kEventDurationNoWait;
+            }
+            else
+            {
+                sleepTime = kEventDurationSecond;
+            }
+        }
     }
     if ( event.what != kHighLevelEvent )
         SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v ,  event.where.h + 1 , event.where.v + 1 ) ;
@@ -1735,6 +1757,44 @@ long wxMacTranslateKey(unsigned char key, unsigned char code)
     return retval;
 }
 
+int wxKeyCodeToMacModifier(wxKeyCode key)
+{
+    switch (key)
+    {
+    case WXK_START:
+    case WXK_MENU:
+        return cmdKey;
+
+    case WXK_SHIFT:
+        return shiftKey;
+
+    case WXK_CAPITAL:
+        return alphaLock;
+
+    case WXK_ALT:
+        return optionKey;
+
+    case WXK_CONTROL:
+        return controlKey;
+
+    default:
+        return 0;
+    }
+}
+
+bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below
+{
+// TODO:  Have it use HID Manager on OSX...
+//if OS X > 10.2 (i.e. 10.2.x)
+//a known apple bug prevents the system from determining led
+//states with GetKeys... can only determine caps lock led
+   return !!(GetCurrentKeyModifiers() & wxKeyCodeToMacModifier(key)); 
+//else
+//  KeyMapByteArray keymap; 
+//  GetKeys((BigEndianLong*)keymap);
+//  return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey));
+}
+
 #if !TARGET_CARBON
 void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
 {