// -*- objc -*- #include "reflex/application.h" #include #import #include #include "applicationdata.h" #import "cocoaapplication.h" namespace Reflex { static Application* instance = NULL; Application* app () { return instance; } Application::Application () { if (instance) reflex_error("multiple application instance."); instance = this; if (NSApp) [NSApp bind: this]; } Application::~Application () { instance = NULL; } bool Application::run () { if (!*this) return false; [self->cocoa run]; return true; } bool Application::quit () { if (!*this) return false; [self->cocoa terminate: nil]; return true; } bool Application::preference () { return *this; } bool Application::about () { if (!*this) return false; [self->cocoa orderFrontStandardAboutPanel: nil]; return true; } bool Application::set_name (const char* name) { if (!*this || !name) return false; self->name = name; return true; } const char* Application::name () const { if (!*this) return NULL; return self->name.c_str(); } Application::operator bool () const { return self && *self; } bool Application::operator ! () const { return !operator bool(); } }// Reflex