🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.1 KiB

  1. #include "testnative.h"
  2. #ifdef TEST_NATIVE_COCOA
  3. #include <Cocoa/Cocoa.h>
  4. static void *CreateWindowCocoa(int w, int h);
  5. static void DestroyWindowCocoa(void *window);
  6. NativeWindowFactory CocoaWindowFactory = {
  7. "cocoa",
  8. CreateWindowCocoa,
  9. DestroyWindowCocoa
  10. };
  11. static void *CreateWindowCocoa(int w, int h)
  12. {
  13. NSAutoreleasePool *pool;
  14. NSWindow *nswindow;
  15. NSRect rect;
  16. unsigned int style;
  17. pool = [[NSAutoreleasePool alloc] init];
  18. rect.origin.x = 0;
  19. rect.origin.y = 0;
  20. rect.size.width = w;
  21. rect.size.height = h;
  22. rect.origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - rect.origin.y - rect.size.height;
  23. style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
  24. nswindow = [[NSWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE];
  25. [nswindow makeKeyAndOrderFront:nil];
  26. [pool release];
  27. return nswindow;
  28. }
  29. static void DestroyWindowCocoa(void *window)
  30. {
  31. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  32. NSWindow *nswindow = (NSWindow *)window;
  33. [nswindow close];
  34. [pool release];
  35. }
  36. #endif