Permalink
Browse files

Fullscreen mode works.

  • Loading branch information...
1 parent 86fe02c commit 514d62ad6cc7839be94842181fa04b9f1f9277b3 @jtza8 jtza8 committed with patzy Oct 22, 2011
View
@@ -88,33 +88,33 @@
:4
:6
:5
- :|=|
+ :equal
:9
:7
- :|-|
+ :minus
:8
:0
- :|]|
+ :bracket-right
:o
:u
- :|[|
+ :bracket-left
:i
:p
:return
:l
:j
- :|'|
+ :quote
:k
- (:|;| 41)
- :|\\|
- :|,|
- :|/|
+ (:semicolon 41)
+ :backslash
+ :comma
+ :forwardslash
:n
:m
- :|.|
+ :decimal
:tab
:space
- :|`|
+ :grave
(:backspace 51)
(:escape 53)
:super-r
@@ -236,6 +236,26 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defbitfield ns-window-style
+ (:borderless 0)
+ (:titled #x1)
+ (:closable #x2)
+ (:miniaturizable #x4)
+ (:resizable #x8)
+ (:textured-background #x80))
+
+(defcenum ns-window-level
+ (:normal #x0)
+ (:floating #x3)
+ (:submenu #x3)
+ (:torn-off-menu #x3)
+ (:main-menu #x18)
+ (:status #x19)
+ (:modal-panel #x8)
+ (:pop-up-menu #x65)
+ (:screen-saver #x3e8)
+ (:dock #x14))
+
(defcfun ("NSWindowAllocInit" ns-window-alloc-init) :pointer
(x :int)
(y :int)
@@ -291,6 +311,36 @@
:void
(window :pointer))
+(defcfun ("NSWindowContentView" ns-window-content-view) :pointer
+ (window :pointer))
+
+(defcfun ("NSWindowSetFrame" ns-window-set-frame) :void
+ (window :pointer)
+ (x :int)
+ (y :int)
+ (width :int)
+ (height :int))
+
+(defcfun ("NSWindowSetStyleMask" ns-window-set-style-mask) :void
+ (window :pointer)
+ (style ns-window-style))
+
+(defcfun ("NSWindowSetLevel" ns-window-set-level) :void
+ (window :pointer)
+ (level ns-window-level))
+
+(defcfun ("NSFrameMethod" ns-window-frame) ns-rect
+ (window :pointer))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; NSView ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+(defcfun ("NSFrameMethod" ns-view-frame) ns-rect
+ (view :pointer))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; NSMenu ;;;
@@ -399,12 +449,21 @@
(defcfun ("NSOpenGLContextInit" ns-opengl-context-init) :pointer
(format :pointer))
+(defcfun ("NSOpenGLContextMakeCurrentContext"
+ ns-opengl-context-make-current-context)
+ :void
+ (context :pointer))
+
(defcfun ("NSOpenGLContextSetView" ns-opengl-context-set-view) :void
(context :pointer)
(view :pointer))
+(defcfun ("NSOpenGLContextSetFullScreen" ns-opengl-context-set-full-screen)
+ :void
+ (context :pointer))
+
(defcfun ("NSOpenGLContextClearDrawable" ns-opengl-context-clear-drawable) :void
(context :pointer))
-(defcfun ("NSOpneGLContextFlushBuffer" ns-opengl-context-flush-buffer) :void
+(defcfun ("NSOpenGLContextFlushBuffer" ns-opengl-context-flush-buffer) :void
(context :pointer))
View
@@ -1,12 +1,27 @@
#import <Cocoa/Cocoa.h>
+#import <malloc/malloc.h>
+typedef enum {
+ GlopNoticeWindowClose,
+ GlopNoticeWindowResize
+} GlopNoticeType;
+
+typedef struct glopNotice {
+ GlopNoticeType type;
+ NSWindow *source;
+} GlopNotice;
+
+typedef void(*GlopNoticeCallback)(GlopNotice*);
typedef void(*GlopEventCallback)(NSEvent*);
@interface GlopView : NSView <NSWindowDelegate>
{
GlopEventCallback eventCallback;
+ GlopNoticeCallback noticeCallback;
}
-- (id)initWithEventCallback:(GlopEventCallback)callback;
+- (id)initWithEventCallback:(GlopEventCallback)eventCallbackFunc
+ noticeCallback:(GlopNoticeCallback)noticeCallbackFunc;
+
@end
View
@@ -2,9 +2,11 @@
@implementation GlopView
-- (id)initWithEventCallback:(GlopEventCallback)callback;
+- (id)initWithEventCallback:(GlopEventCallback)eventCallbackFunc
+ noticeCallback:(GlopNoticeCallback)noticeCallbackFunc;
{
- eventCallback = callback;
+ noticeCallback = noticeCallbackFunc;
+ eventCallback = eventCallbackFunc;
return [self init];
}
@@ -48,6 +50,11 @@ - (void)mouseMoved:(NSEvent *)event
eventCallback(event);
}
+- (void)mouseDragged:(NSEvent *)event
+{
+ eventCallback(event);
+}
+
- (void)rightMouseDown:(NSEvent *)event
{
eventCallback(event);
@@ -58,6 +65,11 @@ - (void)rightMouseUp:(NSEvent *)event
eventCallback(event);
}
+- (void)rightMouseDragged:(NSEvent *)event
+{
+ eventCallback(event);
+}
+
- (void)otherMouseDown:(NSEvent *)event
{
eventCallback(event);
@@ -68,6 +80,11 @@ - (void)otherMouseUp:(NSEvent *)event
eventCallback(event);
}
+- (void)otherMouseDragged:(NSEvent *)event
+{
+ eventCallback(event);
+}
+
- (void)scrollWheel:(NSEvent *)event
{
eventCallback(event);
@@ -80,13 +97,27 @@ - (void)flagsChanged:(NSEvent *)event
- (void)windowWillClose:(NSNotification *)notification
{
+ GlopNotice *notice = malloc(sizeof(GlopNotice));
+ notice->type = GlopNoticeWindowClose;
+ notice->source = [notification object];
+ noticeCallback(notice);
+}
+
+- (void)windowDidResize:(NSNotification *)notification
+{
+ GlopNotice *notice = malloc(sizeof(GlopNotice));
+ notice->type = GlopNoticeWindowResize;
+ notice->source = [notification object];
+ noticeCallback(notice);
}
@end
-GlopView *GlopViewInit (GlopEventCallback callback)
+GlopView *GlopViewInit (GlopEventCallback eventCallbackFunc,
+ GlopNoticeCallback noticeCallbackFunc)
{
- return [[GlopView alloc] initWithEventCallback:callback];
+ return [[GlopView alloc] initWithEventCallback:eventCallbackFunc
+ noticeCallback:noticeCallbackFunc];
}
View
@@ -1,4 +1,6 @@
#include <AppKit/AppKit.h>
+#include <malloc/malloc.h>
+#include <string.h>
/******************************************************************************/
@@ -97,6 +99,7 @@ void NSApplicationSharedApplication ()
styleMask:NSClosableWindowMask | NSTitledWindowMask
backing:NSBackingStoreBuffered
defer:NO];
+ [window setFrameTopLeftPoint:NSMakePoint(x, y)];
return window;
}
@@ -161,6 +164,46 @@ void NSWindowDiscardRemainingEvents (NSWindow *window)
beforeEvent:nil];
}
+NSView *NSWindowContentView (NSWindow *window)
+{
+ return [window contentView];
+}
+
+// Implied by NSWindow and NSView without an actual protocol.
+@protocol FrameProtocol
+- (NSRect)frame;
+@end
+
+NSRect *NSFrameMethod (NSObject *object)
+{
+ NSRect *rect = malloc(sizeof(NSRect));
+ NSRect tmp = [(id <FrameProtocol>)object frame];
+ memcpy(rect, &tmp, sizeof(NSRect));
+ return rect;
+}
+
+void NSWindowSetFrameTopLeftPoint (NSWindow *window, int x, int y)
+{
+ [window setFrameTopLeftPoint:NSMakePoint(x, y)];
+}
+
+void NSWindowSetFrame (NSWindow *window, int x, int y, int width, int height)
+{
+ [window setFrame:NSMakeRect(x, y, width, height) display:YES];
+ [window setFrameTopLeftPoint:NSMakePoint(x, y)];
+}
+
+void NSWindowSetStyleMask (NSWindow *window, NSUInteger syleMask)
+{
+ [window setStyleMask:syleMask];
+}
+
+void NSWindowSetLevel (NSWindow *window, NSInteger level)
+{
+ [window setLevel:level];
+}
+
+
/******************************************************************************/
/*** NSMenu ***/
/******************************************************************************/
@@ -221,11 +264,21 @@ void NSMenuAddItemWithTitle (NSMenu *menu, NSString *title, SEL selector,
shareContext:nil];
}
+void NSOpenGLContextMakeCurrentContext (NSOpenGLContext *context)
+{
+ [context makeCurrentContext];
+}
+
void NSOpenGLContextSetView (NSOpenGLContext *context, NSView *view)
{
[context setView:view];
}
+void NSOpenGLContextSetFullScreen (NSOpenGLContext *context)
+{
+ [context setFullScreen];
+}
+
void NSOpenGLContextClearDrawable (NSOpenGLContext *context)
{
[context clearDrawable];
Binary file not shown.
Oops, something went wrong.

0 comments on commit 514d62a

Please sign in to comment.