#include <java/lang/Object.h>
#include <java/lang/Error.h>
-#include <org/xwt/plat/Carbon.h>
-#include <org/xwt/plat/Carbon$CarbonSurface.h>
-#include <org/xwt/plat/Carbon$GLCarbonSurface.h>
-#include <org/xwt/plat/Carbon$GLCarbonDoubleBuffer.h>
-#include <org/xwt/plat/Carbon$CarbonMessage.h>
-#include <org/xwt/plat/Carbon$CarbonOpenGL.h>
-#include <org/xwt/plat/Carbon$FileDialogHelper.h>
+#include <org/xwt/plat/Darwin.h>
+#include <org/xwt/plat/Darwin$CarbonSurface.h>
+#include <org/xwt/plat/Darwin$GLCarbonSurface.h>
+#include <org/xwt/plat/Darwin$GLCarbonDoubleBuffer.h>
+#include <org/xwt/plat/Darwin$CarbonMessage.h>
+#include <org/xwt/plat/Darwin$CarbonOpenGL.h>
+#include <org/xwt/plat/Darwin$FileDialogHelper.h>
#include <org/xwt/plat/GCJ$Retainer.h>
#include <org/xwt/Proxy.h>
#include <org/xwt/util/Semaphore.h>
namespace org { namespace xwt { namespace plat {
-namespace carbon { }
-using namespace carbon;
+namespace darwin { }
+using namespace darwin;
#pragma mark ------ Carbon Namespace ------
-namespace carbon {
- // We put everything that isn't in org.xwt.plat.Carbon in
- // org.xwt.plat.carbon to prevent namespace conflicts
+namespace darwin {
+ // We put everything that isn't in org.xwt.plat.Darwin in
+ // org.xwt.plat.darwin to prevent namespace conflicts
template <bool CHECK> static inline int CompileTimeCheck() { const int something_is_wrong=1; something_is_wrong++; return 0; }
template <> static inline int CompileTimeCheck<true>() { return 0; }
const static UInt32 kEventCarbonMessage = 'xwtb';
const static UInt32 kEventParamCarbonMessage = 'xwtc';
- pascal OSStatus carbon::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData);
+ pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData);
void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData);
} // end namespace
-jboolean Carbon::isJaguar() {
+jboolean Darwin::isJaguar() {
SInt32 version;
OSStatus r = Gestalt(gestaltSystemVersion, &version);
checkStatus(r,"Gestalt");
return version >= 0x1020;
}
-void Carbon$CarbonMessage::natInit() {
+void Darwin$CarbonMessage::natInit() {
OSStatus r;
EventHandlerUPP upp = NewEventHandlerUPP(carbonMessageEventHandler);
checkStatus(r,"InstallEventHandler");
}
-void Carbon$CarbonMessage::add(Carbon$CarbonMessage *msg) {
+void Darwin$CarbonMessage::add(Darwin$CarbonMessage *msg) {
EventRef event;
OSStatus r;
}
-pascal OSStatus carbon::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
+pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
UInt32 eKind = GetEventKind(e);
UInt32 eClass = GetEventClass(e);
OSStatus r;
- Carbon$CarbonMessage *msg;
+ Darwin$CarbonMessage *msg;
if(eClass != kEventClassCarbonMessage || eKind != kEventCarbonMessage)
return eventNotHandledErr;
r = GetEventParameter(e,kEventParamCarbonMessage,typeVoidPtr,NULL,sizeof(msg),NULL,&msg);
#pragma mark ------ Utility Functions ------
-void carbon::funcFailed(char *func,int r){
+void darwin::funcFailed(char *func,int r){
fprintf(stderr,"%s() failed (%d)\n",func,r);
exit(EXIT_FAILURE);
}
#pragma mark ----- Carbon Surface Methods ----
-void Carbon$CarbonSurface::natSyncCursor(jint n) {
+void Darwin$CarbonSurface::natSyncCursor(jint n) {
ThemeCursor c;
// see Carbon.java for what these numbers mean
switch(n) {
SetThemeCursor(c);
}
-void Carbon$CarbonSurface::natSetInvisible(jboolean b) {
+void Darwin$CarbonSurface::natSetInvisible(jboolean b) {
WindowRef window = (WindowRef) rawWindowRef;
fprintf(stderr,"Making window %s\n",b?"invisible":"visible");
if(b) HideWindow(window);
else ShowWindow(window);
}
-void Carbon$CarbonSurface::nat_setMaximized(jboolean b) {
+void Darwin$CarbonSurface::nat_setMaximized(jboolean b) {
WindowRef window = (WindowRef) rawWindowRef;
Point ideal = { 10000, 10000 };
OSStatus r = ZoomWindowIdeal(window,(b?inZoomOut:inZoomIn),&ideal);
checkStatus(r,"ZoomWindowIdeal");
}
-void Carbon$CarbonSurface::nat_setMinimized(jboolean b) {
+void Darwin$CarbonSurface::nat_setMinimized(jboolean b) {
WindowRef window = (WindowRef) rawWindowRef;
if((IsWindowCollapsed(window) ? 1 : 0) == (b ? 1 : 0)) return;
OSStatus r = CollapseWindow(window,b);
checkStatus(r,"CollapseWindow");
}
-void Carbon$CarbonSurface::natSetTitleBarText(jstring js) {
+void Darwin$CarbonSurface::natSetTitleBarText(jstring js) {
SmartCFString s = js;
WindowRef window = (WindowRef) rawWindowRef;
SetWindowTitleWithCFString(window,s);
}
-void Carbon$CarbonSurface::natToBack() {
+void Darwin$CarbonSurface::natToBack() {
WindowRef window = (WindowRef) rawWindowRef;
SendBehind(window,NULL);
}
-void Carbon$CarbonSurface::natToFront() {
+void Darwin$CarbonSurface::natToFront() {
WindowRef window = (WindowRef) rawWindowRef;
fprintf(stderr,"SelectWindow()\n");
SelectWindow(window);
}
#pragma mark ---- Window Event Handler ----
-namespace carbon {
+namespace darwin {
static const EventTypeSpec eventTypeSpecs[] = {
// kEventClassCommand
// { kEventClassCommand, ??? },
};
pascal OSStatus windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
- Carbon$CarbonSurface *surface = (Carbon$CarbonSurface*) userData;
+ Darwin$CarbonSurface *surface = (Darwin$CarbonSurface*) userData;
UInt32 eKind = GetEventKind(e);
UInt32 eClass = GetEventClass(e);
OSStatus r;
r = GetEventParameter(e,kEventParamDirectObject,typeWindowRef,NULL,sizeof(window),NULL,&window);
checkStatus(r,"kEventClassWindow/GetEventParameter");
- if((RawData*)window != surface->rawWindowRef) Carbon::abort(JvNewStringLatin1("window != surface->window"));
+ if((RawData*)window != surface->rawWindowRef) Darwin::abort(JvNewStringLatin1("window != surface->window"));
switch(eKind) {
case kEventWindowUpdate: {
- surface->Dirty(0,0,surface->width,surface->height);
+ surface->Dirty(0,0,surface->root->width,surface->root->height);
return noErr;
}
case kEventWindowBoundsChanged: {
}
} // end namespace
-void Carbon$CarbonSurface::natInit(jboolean framed) {
+void Darwin$CarbonSurface::natInit(jboolean framed) {
WindowRef window;
Rect rect;
WindowClass wc = framed ? kDocumentWindowClass : kPlainWindowClass;
rawEventHandlerUPP = (RawData*) upp;
}
-void Carbon$CarbonSurface::natDispose() {
+void Darwin$CarbonSurface::natDispose() {
WindowRef window = (WindowRef) rawWindowRef;
DisposeWindow(window);
}
-void Carbon$CarbonSurface::natSetIcon(org::xwt::Picture *_p) {
+void Darwin$CarbonSurface::natSetIcon(org::xwt::Picture *_p) {
}
-void Carbon$CarbonSurface::natSetLocation(jint x, jint y) {
+void Darwin$CarbonSurface::natSetLocation(jint x, jint y) {
WindowRef window = (WindowRef) rawWindowRef;
Rect rect;
OSStatus r = GetWindowBounds(window,kWindowStructureRgn,&rect);
checkStatus(r,"ConstrainWindowToScreen");
}
-void Carbon$CarbonSurface::natSetSize(jint w, jint h) {
+void Darwin$CarbonSurface::natSetSize(jint w, jint h) {
WindowRef window = (WindowRef) rawWindowRef;
Rect rect;
OSStatus r = GetWindowBounds(window,kWindowStructureRgn,&rect);
checkStatus(r,"ConstrainWindowToScreen");
}
-void Carbon$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint maxh) {
+void Darwin$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint maxh) {
WindowRef window = (WindowRef) rawWindowRef;
const int maxMax = 32767;
const int minMinW = 80;
#pragma mark ------ Carbon Methods ------
-void carbon::fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData) {
- Carbon$FileDialogHelper *helper = (Carbon$FileDialogHelper*) userData;
+void darwin::fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData) {
+ Darwin$FileDialogHelper *helper = (Darwin$FileDialogHelper*) userData;
NavDialogRef dialog = callBackParms->context;
OSStatus r;
switch(callBackSelector) {
}
}
-void Carbon::natFileDialog(Carbon$FileDialogHelper *helper,jstring suggestion_, jboolean write) {
+void Darwin::natFileDialog(Darwin$FileDialogHelper *helper,jstring suggestion_, jboolean write) {
NavDialogRef dlg;
SmartCFString suggestion = suggestion_;
CFStringRef message = CFSTR("By selecting a file in this dialog you are giving this XWT application permission to access that file.");
WindowRef window = FrontWindow();
NavDialogCreationOptions options;
- NavEventUPP handler = NewNavEventUPP(carbon::fileDialogEventHandler);
+ NavEventUPP handler = NewNavEventUPP(darwin::fileDialogEventHandler);
NavGetDefaultDialogCreationOptions(&options);
options.optionFlags =
NavDialogRun(dlg);
}
-jstring Carbon::natGetClipBoard() {
+jstring Darwin::natGetClipBoard() {
ScrapRef scrap;
OSStatus r;
Size size,size2;
return js;
}
-void Carbon::natSetClipBoard(jstring js) {
+void Darwin::natSetClipBoard(jstring js) {
unsigned int length = js->length();
ScrapRef scrap;
OSStatus r;
checkStatus(r,"PutScrapFlavor");
}
-Proxy *Carbon::natDetectProxy() {
+Proxy *Darwin::natDetectProxy() {
using org::xwt::Proxy;
Proxy *p=0;
CFStringRef string;
*/
}
-jint Carbon::cgScreenWidth() {
+jint Darwin::cgScreenWidth() {
return CGDisplayPixelsWide(kCGDirectMainDisplay);
}
-jint Carbon::cgScreenHeight() {
+jint Darwin::cgScreenHeight() {
return CGDisplayPixelsHigh(kCGDirectMainDisplay);
}
-void Carbon::_newBrowserWindow(jstring js) {
+void Darwin::_newBrowserWindow(jstring js) {
SmartCFString cfs = js;
CFURLRef url = CFURLCreateWithString(kCFAllocatorDefault,cfs,NULL);
SmartCFString scheme = CFURLCopyScheme(url);
CFRelease(url);
}
-void Carbon::_exit() {
+void Darwin::_exit() {
QuitApplicationEventLoop();
}
OSErr CPSSetFrontProcess(ProcessSerialNumber *psn);
}
#endif
-void Carbon::natInit() {
+void Darwin::natInit() {
OSStatus r;
#ifdef XWT_CARBON_NO_BUNDLE_HACK
{
#endif
}
-void Carbon::_running() {
+void Darwin::_running() {
RunApplicationEventLoop();
ExitToShell();
}
#pragma mark ------ OpenGL Functions -----
-void Carbon$CarbonOpenGL::activateSharedContext() {
+void Darwin$CarbonOpenGL::activateSharedContext() {
AGLContext ctx = (AGLContext) rawSharedContext;
aglSetCurrentContext(ctx);
}
-jboolean Carbon$CarbonOpenGL::initPixelFormat() {
+jboolean Darwin$CarbonOpenGL::initPixelFormat() {
GLint attr[] = {
AGL_NO_RECOVERY,
AGL_RGBA,
return rawPixelFormat != 0;
}
-void Carbon$CarbonOpenGL::initSharedContext() {
+void Darwin$CarbonOpenGL::initSharedContext() {
AGLPixelFormat fmt = (AGLPixelFormat) rawPixelFormat;
rawSharedContext = (RawData*) aglCreateContext(fmt,NULL);
checkStatus(rawSharedContext,"aglCreateContext");
}
-void Carbon$GLCarbonDoubleBuffer::natInit() {
+void Darwin$GLCarbonDoubleBuffer::natInit() {
WindowClass wc = kPlainWindowClass;
WindowAttributes attr = 0;
WindowRef window;
rawCTX = (RawData*) ctx;
}
-void Carbon$GLCarbonDoubleBuffer::activateContext() {
+void Darwin$GLCarbonDoubleBuffer::activateContext() {
AGLContext ctx = (AGLContext) rawCTX;
aglSetCurrentContext(ctx);
}
-void Carbon$GLCarbonDoubleBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) {
+void Darwin$GLCarbonDoubleBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) {
WindowRef window = (WindowRef) rawWindowRef;
AGLContext ctx = (AGLContext) rawCTX;
aglDestroyContext(ctx);
DisposeWindow(window);
}
-void Carbon$GLCarbonSurface::natBlit(Carbon$GLCarbonDoubleBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) {
+void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonDoubleBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) {
AGLContext ctx = (AGLContext) rawCTX;
int sx2 = sx1 + (dx2-dx1);
int sy2 = sy1 + (dy2-dy1);
glFlush();
}
-void Carbon$GLCarbonSurface::natReshape(jint w, jint h) {
+void Darwin$GLCarbonSurface::natReshape(jint w, jint h) {
AGLContext ctx = (AGLContext) rawCTX;
aglSetCurrentContext (ctx);
checkGLError();
}
-void Carbon$GLCarbonSurface::natInit() {
+void Darwin$GLCarbonSurface::natInit() {
WindowRef window = (WindowRef) rawWindowRef;
AGLContext ctx,shared;
AGLPixelFormat fmt;
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}
-void Carbon$GLCarbonSurface::natDispose() {
+void Darwin$GLCarbonSurface::natDispose() {
AGLContext ctx = (AGLContext) rawCTX;
aglDestroyContext(ctx);
- Carbon$CarbonSurface::natDispose();
+ Darwin$CarbonSurface::natDispose();
}
} } } // end namepsace org::xwt::plat