PolyCocoaCore.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #include <unistd.h>
  22. #import <Cocoa/Cocoa.h>
  23. using std::vector;
  24. @class SubstanceView;
  25. namespace Polycode {
  26. class _PolyExport PosixMutex : public CoreMutex {
  27. public:
  28. pthread_mutex_t pMutex;
  29. };
  30. class CocoaEvent {
  31. public:
  32. int eventGroup;
  33. int eventCode;
  34. int mouseX;
  35. int mouseY;
  36. TAUKey keyCode;
  37. wchar_t unicodeChar;
  38. char mouseButton;
  39. static const int INPUT_EVENT = 0;
  40. };
  41. class _PolyExport CocoaCore : public Core {
  42. public:
  43. CocoaCore(SubstanceView *view, int xRes, int yRes, bool fullScreen, int aaLevel, int frameRate);
  44. virtual ~CocoaCore();
  45. void enableMouse(bool newval);
  46. unsigned int getTicks();
  47. bool Update();
  48. void setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel);
  49. void resizeTo(int xRes, int yRes);
  50. void createThread(Threaded *target);
  51. void createFolder(String folderPath);
  52. void copyDiskItem(String itemPath, String destItemPath);
  53. void moveDiskItem(String itemPath, String destItemPath);
  54. void removeDiskItem(String itemPath);
  55. String openFolderPicker();
  56. vector<string> openFilePicker(vector<CoreFileExtension> extensions, bool allowMultiple);
  57. void setCursor(int cursorType);
  58. void copyStringToClipboard(String str);
  59. String getClipboardString();
  60. // static pascal OSStatus coreEventHandler (EventHandlerCallRef next, EventRef event, void *data);
  61. void lockMutex(CoreMutex *mutex);
  62. void unlockMutex(CoreMutex *mutex);
  63. CoreMutex *createMutex();
  64. void checkEvents();
  65. vector<Rectangle> getVideoModes();
  66. int lastMouseY;
  67. int lastMouseX;
  68. CoreMutex *eventMutex;
  69. vector<CocoaEvent> cocoaEvents;
  70. NSOpenGLContext *context;
  71. private:
  72. SubstanceView *glView;
  73. uint64_t initTime;
  74. };
  75. }