PolyCocoaCore.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * PolyCocoaCore.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 2/16/10.
  6. * Copyright 2010 Ivan Safrin. All rights reserved.
  7. *
  8. */
  9. // @package Core
  10. #pragma once
  11. #include "PolyString.h"
  12. #include "PolyGlobals.h"
  13. #include "PolyCore.h"
  14. #include "PolyString.h"
  15. #include "PolyRectangle.h"
  16. #include <vector>
  17. #include <OpenGL/gl.h>
  18. #include <OpenGL/OpenGL.h>
  19. #include "PolyGLRenderer.h"
  20. #include <mach/mach_time.h>
  21. #import <Cocoa/Cocoa.h>
  22. using std::vector;
  23. @class SubstanceView;
  24. namespace Polycode {
  25. class _PolyExport PosixMutex : public CoreMutex {
  26. public:
  27. pthread_mutex_t pMutex;
  28. };
  29. class CocoaEvent {
  30. public:
  31. int eventGroup;
  32. int eventCode;
  33. int mouseX;
  34. int mouseY;
  35. TAUKey keyCode;
  36. wchar_t unicodeChar;
  37. char mouseButton;
  38. static const int INPUT_EVENT = 0;
  39. };
  40. class _PolyExport CocoaCore : public Core {
  41. public:
  42. CocoaCore(SubstanceView *view, int xRes, int yRes, bool fullScreen, int aaLevel, int frameRate);
  43. virtual ~CocoaCore();
  44. void enableMouse(bool newval);
  45. unsigned int getTicks();
  46. bool Update();
  47. void setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel);
  48. void resizeTo(int xRes, int yRes);
  49. void createThread(Threaded *target);
  50. void createFolder(String folderPath);
  51. void copyDiskItem(String itemPath, String destItemPath);
  52. void moveDiskItem(String itemPath, String destItemPath);
  53. void removeDiskItem(String itemPath);
  54. String openFolderPicker();
  55. vector<string> openFilePicker(vector<CoreFileExtension> extensions, bool allowMultiple);
  56. void setCursor(int cursorType);
  57. void copyStringToClipboard(String str);
  58. String getClipboardString();
  59. // static pascal OSStatus coreEventHandler (EventHandlerCallRef next, EventRef event, void *data);
  60. void lockMutex(CoreMutex *mutex);
  61. void unlockMutex(CoreMutex *mutex);
  62. CoreMutex *createMutex();
  63. void checkEvents();
  64. vector<Rectangle> getVideoModes();
  65. int lastMouseY;
  66. int lastMouseX;
  67. CoreMutex *eventMutex;
  68. vector<CocoaEvent> cocoaEvents;
  69. NSOpenGLContext *context;
  70. private:
  71. SubstanceView *glView;
  72. uint64_t initTime;
  73. };
  74. }