#include "wx/app.h"
#ifndef WX_PRECOMP
- #include "wx/dc.h"
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/module.h"
#include "wx/cocoa/mbarman.h"
#include "wx/cocoa/NSApplication.h"
+#include "wx/cocoa/dc.h"
+
#import <AppKit/NSApplication.h>
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSThread.h>
}
}
+ /*
+ Cocoa supports -Key value options which set the user defaults key "Key"
+ to the value "value" Some of them are very handy for debugging like
+ -NSShowAllViews YES. Cocoa picks these up from the real argv so
+ our removal of them from the wx copy of it does not affect Cocoa's
+ ability to see them.
+
+ We basically just assume that any "-NS" option and its following
+ argument needs to be removed from argv. We hope that user code does
+ not expect to see -NS options and indeed it's probably a safe bet
+ since most user code accepting options is probably using the
+ double-dash GNU-style syntax.
+ */
+ for(int i=1; i < argc; ++i)
+ {
+ static const wxChar *ARG_NS = wxT("-NS");
+ static const int ARG_NS_LEN = wxStrlen(ARG_NS);
+ if( wxStrncmp(argv[i], ARG_NS, ARG_NS_LEN) == 0 )
+ {
+ // Only eat this option if it has an argument
+ if( (i + 1) < argc )
+ {
+ argc -= 2;
+ memmove(argv + i, argv + i + 2, argc * sizeof(wxChar*));
+ // drop back one position so the next run through the loop
+ // reprocesses the argument at our current index.
+ --i;
+ }
+ }
+ }
+
return wxAppBase::Initialize(argc, argv);
}
{
wxAutoNSAutoreleasePool pool;
- wxDC::CocoaShutdownTextSystem();
+ wxCocoaDCImpl::CocoaShutdownTextSystem();
wxMenuBarManager::DestroyInstance();
[[NSNotificationCenter defaultCenter] removeObserver:sg_cocoaAppObserver];
#endif // __WXDEBUG__
argc = 0;
+#if !wxUSE_UNICODE
argv = NULL;
+#endif
m_cocoaApp = NULL;
m_cocoaAppDelegate = NULL;
}
if(!sm_isEmbedded)
wxMenuBarManager::CreateInstance();
- wxDC::CocoaInitializeTextSystem();
+ wxCocoaDCImpl::CocoaInitializeTextSystem();
return true;
}
}
// Yield to other processes
-bool wxApp::Yield(bool onlyIfNeeded)
+bool wxApp::DoYield(bool onlyIfNeeded, long eventsToProcess)
{
- // MT-FIXME
- static bool s_inYield = false;
-
#if wxUSE_LOG
// disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c
wxLog::Suspend();
#endif // wxUSE_LOG
- if (s_inYield)
+ if (m_isInsideYield)
{
if ( !onlyIfNeeded )
{
return false;
}
- s_inYield = true;
+ m_isInsideYield = true;
+ m_eventsToProcessInsideYield = eventsToProcess;
// Run the event loop until it is out of events
while(1)
{
+ // TODO: implement event filtering using the eventsToProcess mask
+
wxAutoNSAutoreleasePool pool;
/* NOTE: It may be better to use something like
NSEventTrackingRunLoopMode since we don't necessarily want all
wxLog::Resume();
#endif // wxUSE_LOG
- s_inYield = false;
+ m_isInsideYield = false;
return true;
}