diff --git a/stepmania/src/arch/LoadingWindow/LoadingWindow_Cocoa.h b/stepmania/src/arch/LoadingWindow/LoadingWindow_Cocoa.h new file mode 100644 index 0000000000..f89d2e2a01 --- /dev/null +++ b/stepmania/src/arch/LoadingWindow/LoadingWindow_Cocoa.h @@ -0,0 +1,31 @@ +#ifndef LOADING_WINDOW_COCOA +#define LOADING_WINDOW_COCOA +/* + * LoadingWindow_Cocoa.h + * stepmania + * + * Created by Steve Checkoway on Thu Jul 03 2003. + * Copyright (c) 2003 Steve Checkoway. All rights reserved. + * + */ + +#include "LoadingWindow_Null.h" + +extern void MakeNewCocoaWindow(); +extern void DisposeOfCocoaWindow(); +extern void PaintCocoaWindow(); +extern void SetCocoaWindowText(const char *s); + +class LoadingWindow_Cocoa : public LoadingWindow { +public: + LoadingWindow_Cocoa() { MakeNewCocoaWindow(); } + ~LoadingWindow_Cocoa() { DisposeOfCocoaWindow(); } + + void Paint() {} /* Not needed */ + void SetText(CString str) { SetCocoaWindowText(str.c_str()); } +}; + +#undef ARCH_LOADING_WINDOW +#define ARCH_LOADING_WINDOW LoadingWindow_Cocoa + +#endif /* LOADING_WINDOW_COCOA */ \ No newline at end of file diff --git a/stepmania/src/arch/LoadingWindow/LoadingWindow_Cocoa.mm b/stepmania/src/arch/LoadingWindow/LoadingWindow_Cocoa.mm new file mode 100644 index 0000000000..e372c96742 --- /dev/null +++ b/stepmania/src/arch/LoadingWindow/LoadingWindow_Cocoa.mm @@ -0,0 +1,58 @@ +/* + * LoadingWindow_Cocoa.m + * stepmania + * + * Created by Steve Checkoway on Thu Jul 03 2003. + * Copyright (c) 2003 Steve Checkoway. All rights reserved. + * + */ + +#import + +static NSWindow *window; +static NSTextView *text; + +void MakeNewCocoaWindow() { + NSImage *image = [NSImage imageNamed:@"loading"]; + NSSize size = [image size]; + float height = size.height; + NSImageView *iView = [[[NSImageView alloc] initWithFrame:NSMakeRect(0, height, size.width, height)] autorelease]; + NSView *view; + NSRect rect; + rect.origin = NSMakePoint(0, height); + rect.size = size; + rect.size.height += height; + + text = [[[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, rect.size.width, height)] autorelease]; + [text setEditable:NO]; + [text setSelectable:NO]; + [text setDrawsBackground:YES]; + [text setBackgroundColor:[NSColor lightGrayColor]]; + [text setAlignment:NSCenterTextAlignment]; + + [iView setImage:image]; + [iView setImageFrameStyle:NSImageFrameNone]; + + window = [[NSWindow alloc] initWithContentRect:rect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]; + [window setOneShot:YES]; + [window setReleasedWhenClosed:YES]; + [window center]; + [window useOptimizedDrawing:YES]; + [window setViewsNeedDisplay:YES]; + + view = [window contentView]; + [view addSubview:text]; /* This retains text */ + [view addSubview:iView]; /* This retains iView */ + [text setString:@"Initializing Hardware..."]; + + [window makeKeyAndOrderFront:nil]; +} + +void DisposeOfCocoaWindow() { + [window close]; /* Released by setReleasedWhenClosed */ +} + +void SetCocoaWindowText(const char *s) { + [text setString:[NSString stringWithCString:s]]; + [text display]; +}