avalonia-native.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. #include "com.h"
  2. #include "key.h"
  3. #include "stddef.h"
  4. #define AVNCOM(name, id) COMINTERFACE(name, 2e2cda0a, 9ae5, 4f1b, 8e, 20, 08, 1a, 04, 27, 9f, id)
  5. struct IAvnWindowEvents;
  6. struct IAvnWindow;
  7. struct IAvnPopup;
  8. struct IAvnMacOptions;
  9. struct IAvnPlatformThreadingInterface;
  10. struct IAvnSystemDialogEvents;
  11. struct IAvnSystemDialogs;
  12. struct IAvnScreens;
  13. struct IAvnClipboard;
  14. struct IAvnCursor;
  15. struct IAvnCursorFactory;
  16. struct IAvnGlFeature;
  17. struct IAvnGlContext;
  18. struct IAvnGlDisplay;
  19. struct IAvnGlSurfaceRenderTarget;
  20. struct IAvnGlSurfaceRenderingSession;
  21. struct IAvnMenu;
  22. struct IAvnMenuItem;
  23. struct IAvnStringArray;
  24. struct IAvnDndResultCallback;
  25. struct IAvnGCHandleDeallocatorCallback;
  26. struct IAvnMenuEvents;
  27. enum SystemDecorations {
  28. SystemDecorationsNone = 0,
  29. SystemDecorationsBorderOnly = 1,
  30. SystemDecorationsFull = 2,
  31. };
  32. struct AvnSize
  33. {
  34. double Width, Height;
  35. };
  36. struct AvnPixelSize
  37. {
  38. int Width, Height;
  39. };
  40. struct AvnRect
  41. {
  42. double X, Y, Width, Height;
  43. };
  44. struct AvnVector
  45. {
  46. double X, Y;
  47. };
  48. struct AvnPoint
  49. {
  50. double X, Y;
  51. };
  52. struct AvnScreen
  53. {
  54. AvnRect Bounds;
  55. AvnRect WorkingArea;
  56. float PixelDensity;
  57. bool Primary;
  58. };
  59. enum AvnPixelFormat
  60. {
  61. kAvnRgb565,
  62. kAvnRgba8888,
  63. kAvnBgra8888
  64. };
  65. struct AvnFramebuffer
  66. {
  67. void* Data;
  68. int Width;
  69. int Height;
  70. int Stride;
  71. AvnVector Dpi;
  72. AvnPixelFormat PixelFormat;
  73. };
  74. struct AvnColor
  75. {
  76. unsigned char Alpha;
  77. unsigned char Red;
  78. unsigned char Green;
  79. unsigned char Blue;
  80. };
  81. enum AvnRawMouseEventType
  82. {
  83. LeaveWindow,
  84. LeftButtonDown,
  85. LeftButtonUp,
  86. RightButtonDown,
  87. RightButtonUp,
  88. MiddleButtonDown,
  89. MiddleButtonUp,
  90. XButton1Down,
  91. XButton1Up,
  92. XButton2Down,
  93. XButton2Up,
  94. Move,
  95. Wheel,
  96. NonClientLeftButtonDown,
  97. TouchBegin,
  98. TouchUpdate,
  99. TouchEnd,
  100. TouchCancel
  101. };
  102. enum AvnRawKeyEventType
  103. {
  104. KeyDown,
  105. KeyUp
  106. };
  107. enum AvnInputModifiers
  108. {
  109. AvnInputModifiersNone = 0,
  110. Alt = 1,
  111. Control = 2,
  112. Shift = 4,
  113. Windows = 8,
  114. LeftMouseButton = 16,
  115. RightMouseButton = 32,
  116. MiddleMouseButton = 64,
  117. XButton1MouseButton = 128,
  118. XButton2MouseButton = 256
  119. };
  120. enum class AvnDragDropEffects
  121. {
  122. None = 0,
  123. Copy = 1,
  124. Move = 2,
  125. Link = 4,
  126. };
  127. enum class AvnDragEventType
  128. {
  129. Enter,
  130. Over,
  131. Leave,
  132. Drop
  133. };
  134. enum AvnWindowState
  135. {
  136. Normal,
  137. Minimized,
  138. Maximized,
  139. FullScreen,
  140. };
  141. enum AvnStandardCursorType
  142. {
  143. CursorArrow,
  144. CursorIbeam,
  145. CursorWait,
  146. CursorCross,
  147. CursorUpArrow,
  148. CursorSizeWestEast,
  149. CursorSizeNorthSouth,
  150. CursorSizeAll,
  151. CursorNo,
  152. CursorHand,
  153. CursorAppStarting,
  154. CursorHelp,
  155. CursorTopSide,
  156. CursorBottomSize,
  157. CursorLeftSide,
  158. CursorRightSide,
  159. CursorTopLeftCorner,
  160. CursorTopRightCorner,
  161. CursorBottomLeftCorner,
  162. CursorBottomRightCorner,
  163. CursorDragMove,
  164. CursorDragCopy,
  165. CursorDragLink,
  166. CursorNone
  167. };
  168. enum AvnWindowEdge
  169. {
  170. WindowEdgeNorthWest,
  171. WindowEdgeNorth,
  172. WindowEdgeNorthEast,
  173. WindowEdgeWest,
  174. WindowEdgeEast,
  175. WindowEdgeSouthWest,
  176. WindowEdgeSouth,
  177. WindowEdgeSouthEast
  178. };
  179. enum AvnMenuItemToggleType
  180. {
  181. None,
  182. CheckMark,
  183. Radio
  184. };
  185. AVNCOM(IAvaloniaNativeFactory, 01) : IUnknown
  186. {
  187. public:
  188. virtual HRESULT Initialize(IAvnGCHandleDeallocatorCallback* deallocator) = 0;
  189. virtual IAvnMacOptions* GetMacOptions() = 0;
  190. virtual HRESULT CreateWindow(IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnWindow** ppv) = 0;
  191. virtual HRESULT CreatePopup (IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnPopup** ppv) = 0;
  192. virtual HRESULT CreatePlatformThreadingInterface(IAvnPlatformThreadingInterface** ppv) = 0;
  193. virtual HRESULT CreateSystemDialogs (IAvnSystemDialogs** ppv) = 0;
  194. virtual HRESULT CreateScreens (IAvnScreens** ppv) = 0;
  195. virtual HRESULT CreateClipboard(IAvnClipboard** ppv) = 0;
  196. virtual HRESULT CreateDndClipboard(IAvnClipboard** ppv) = 0;
  197. virtual HRESULT CreateCursorFactory(IAvnCursorFactory** ppv) = 0;
  198. virtual HRESULT ObtainGlDisplay(IAvnGlDisplay** ppv) = 0;
  199. virtual HRESULT SetAppMenu(IAvnMenu* menu) = 0;
  200. virtual HRESULT CreateMenu (IAvnMenuEvents* cb, IAvnMenu** ppv) = 0;
  201. virtual HRESULT CreateMenuItem (IAvnMenuItem** ppv) = 0;
  202. virtual HRESULT CreateMenuItemSeperator (IAvnMenuItem** ppv) = 0;
  203. };
  204. AVNCOM(IAvnString, 17) : IUnknown
  205. {
  206. virtual HRESULT Pointer(void**retOut) = 0;
  207. virtual HRESULT Length(int*ret) = 0;
  208. };
  209. AVNCOM(IAvnWindowBase, 02) : IUnknown
  210. {
  211. virtual HRESULT Show() = 0;
  212. virtual HRESULT Hide () = 0;
  213. virtual HRESULT Close() = 0;
  214. virtual HRESULT Activate () = 0;
  215. virtual HRESULT GetClientSize(AvnSize*ret) = 0;
  216. virtual HRESULT GetScaling(double*ret)=0;
  217. virtual HRESULT SetMinMaxSize(AvnSize minSize, AvnSize maxSize) = 0;
  218. virtual HRESULT Resize(double width, double height) = 0;
  219. virtual HRESULT Invalidate (AvnRect rect) = 0;
  220. virtual HRESULT BeginMoveDrag () = 0;
  221. virtual HRESULT BeginResizeDrag (AvnWindowEdge edge) = 0;
  222. virtual HRESULT GetPosition (AvnPoint*ret) = 0;
  223. virtual HRESULT SetPosition (AvnPoint point) = 0;
  224. virtual HRESULT PointToClient (AvnPoint point, AvnPoint*ret) = 0;
  225. virtual HRESULT PointToScreen (AvnPoint point, AvnPoint*ret) = 0;
  226. virtual HRESULT ThreadSafeSetSwRenderedFrame(AvnFramebuffer* fb, IUnknown* dispose) = 0;
  227. virtual HRESULT SetTopMost (bool value) = 0;
  228. virtual HRESULT SetCursor(IAvnCursor* cursor) = 0;
  229. virtual HRESULT CreateGlRenderTarget(IAvnGlSurfaceRenderTarget** ret) = 0;
  230. virtual HRESULT SetMainMenu(IAvnMenu* menu) = 0;
  231. virtual HRESULT ObtainNSWindowHandle(void** retOut) = 0;
  232. virtual HRESULT ObtainNSWindowHandleRetained(void** retOut) = 0;
  233. virtual HRESULT ObtainNSViewHandle(void** retOut) = 0;
  234. virtual HRESULT ObtainNSViewHandleRetained(void** retOut) = 0;
  235. virtual HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point,
  236. IAvnClipboard* clipboard, IAvnDndResultCallback* cb, void* sourceHandle) = 0;
  237. };
  238. AVNCOM(IAvnPopup, 03) : virtual IAvnWindowBase
  239. {
  240. };
  241. AVNCOM(IAvnWindow, 04) : virtual IAvnWindowBase
  242. {
  243. virtual HRESULT ShowDialog (IAvnWindow* parent) = 0;
  244. virtual HRESULT SetCanResize(bool value) = 0;
  245. virtual HRESULT SetDecorations(SystemDecorations value) = 0;
  246. virtual HRESULT SetTitle (void* utf8Title) = 0;
  247. virtual HRESULT SetTitleBarColor (AvnColor color) = 0;
  248. virtual HRESULT SetWindowState(AvnWindowState state) = 0;
  249. virtual HRESULT GetWindowState(AvnWindowState*ret) = 0;
  250. };
  251. AVNCOM(IAvnWindowBaseEvents, 05) : IUnknown
  252. {
  253. virtual HRESULT Paint() = 0;
  254. virtual void Closed() = 0;
  255. virtual void Activated() = 0;
  256. virtual void Deactivated() = 0;
  257. virtual void Resized(const AvnSize& size) = 0;
  258. virtual void PositionChanged (AvnPoint position) = 0;
  259. virtual void RawMouseEvent (AvnRawMouseEventType type,
  260. unsigned int timeStamp,
  261. AvnInputModifiers modifiers,
  262. AvnPoint point,
  263. AvnVector delta) = 0;
  264. virtual bool RawKeyEvent (AvnRawKeyEventType type, unsigned int timeStamp, AvnInputModifiers modifiers, unsigned int key) = 0;
  265. virtual bool RawTextInputEvent (unsigned int timeStamp, const char* text) = 0;
  266. virtual void ScalingChanged(double scaling) = 0;
  267. virtual void RunRenderPriorityJobs() = 0;
  268. virtual AvnDragDropEffects DragEvent(AvnDragEventType type, AvnPoint position,
  269. AvnInputModifiers modifiers, AvnDragDropEffects effects,
  270. IAvnClipboard* clipboard, void* dataObjectHandle) = 0;
  271. };
  272. AVNCOM(IAvnWindowEvents, 06) : IAvnWindowBaseEvents
  273. {
  274. /**
  275. * Closing Event
  276. * Called when the user presses the OS window close button.
  277. * return true to allow the close, return false to prevent close.
  278. */
  279. virtual bool Closing () = 0;
  280. virtual void WindowStateChanged (AvnWindowState state) = 0;
  281. };
  282. AVNCOM(IAvnMacOptions, 07) : IUnknown
  283. {
  284. virtual HRESULT SetShowInDock(int show) = 0;
  285. virtual HRESULT SetApplicationTitle (void* utf8string) = 0;
  286. };
  287. AVNCOM(IAvnActionCallback, 08) : IUnknown
  288. {
  289. virtual void Run() = 0;
  290. };
  291. AVNCOM(IAvnSignaledCallback, 09) : IUnknown
  292. {
  293. virtual void Signaled(int priority, bool priorityContainsMeaningfulValue) = 0;
  294. };
  295. AVNCOM(IAvnLoopCancellation, 0a) : IUnknown
  296. {
  297. virtual void Cancel() = 0;
  298. };
  299. AVNCOM(IAvnPlatformThreadingInterface, 0b) : IUnknown
  300. {
  301. virtual bool GetCurrentThreadIsLoopThread() = 0;
  302. virtual void SetSignaledCallback(IAvnSignaledCallback* cb) = 0;
  303. virtual IAvnLoopCancellation* CreateLoopCancellation() = 0;
  304. virtual HRESULT RunLoop(IAvnLoopCancellation* cancel) = 0;
  305. // Can't pass int* to sharpgentools for some reason
  306. virtual void Signal(int priority) = 0;
  307. virtual IUnknown* StartTimer(int priority, int ms, IAvnActionCallback* callback) = 0;
  308. };
  309. AVNCOM(IAvnSystemDialogEvents, 0c) : IUnknown
  310. {
  311. virtual void OnCompleted (int numResults, void* ptrFirstResult) = 0;
  312. };
  313. AVNCOM(IAvnSystemDialogs, 0d) : IUnknown
  314. {
  315. virtual void SelectFolderDialog (IAvnWindow* parentWindowHandle,
  316. IAvnSystemDialogEvents* events,
  317. const char* title,
  318. const char* initialPath) = 0;
  319. virtual void OpenFileDialog (IAvnWindow* parentWindowHandle,
  320. IAvnSystemDialogEvents* events,
  321. bool allowMultiple,
  322. const char* title,
  323. const char* initialDirectory,
  324. const char* initialFile,
  325. const char* filters) = 0;
  326. virtual void SaveFileDialog (IAvnWindow* parentWindowHandle,
  327. IAvnSystemDialogEvents* events,
  328. const char* title,
  329. const char* initialDirectory,
  330. const char* initialFile,
  331. const char* filters) = 0;
  332. };
  333. AVNCOM(IAvnScreens, 0e) : IUnknown
  334. {
  335. virtual HRESULT GetScreenCount (int* ret) = 0;
  336. virtual HRESULT GetScreen (int index, AvnScreen* ret) = 0;
  337. };
  338. AVNCOM(IAvnClipboard, 0f) : IUnknown
  339. {
  340. virtual HRESULT GetText (char* type, IAvnString**ppv) = 0;
  341. virtual HRESULT SetText (char* type, void* utf8Text) = 0;
  342. virtual HRESULT ObtainFormats(IAvnStringArray**ppv) = 0;
  343. virtual HRESULT GetStrings(char* type, IAvnStringArray**ppv) = 0;
  344. virtual HRESULT Clear() = 0;
  345. };
  346. AVNCOM(IAvnCursor, 10) : IUnknown
  347. {
  348. };
  349. AVNCOM(IAvnCursorFactory, 11) : IUnknown
  350. {
  351. virtual HRESULT GetCursor (AvnStandardCursorType cursorType, IAvnCursor** retOut) = 0;
  352. };
  353. AVNCOM(IAvnGlDisplay, 13) : IUnknown
  354. {
  355. virtual HRESULT CreateContext(IAvnGlContext* share, IAvnGlContext**ppv) = 0;
  356. virtual void LegacyClearCurrentContext() = 0;
  357. virtual HRESULT WrapContext(void* native, IAvnGlContext**ppv) = 0;
  358. virtual void* GetProcAddress(char* proc) = 0;
  359. };
  360. AVNCOM(IAvnGlContext, 14) : IUnknown
  361. {
  362. virtual HRESULT MakeCurrent(IUnknown** ppv) = 0;
  363. virtual HRESULT LegacyMakeCurrent() = 0;
  364. virtual int GetSampleCount() = 0;
  365. virtual int GetStencilSize() = 0;
  366. virtual void* GetNativeHandle() = 0;
  367. };
  368. AVNCOM(IAvnGlSurfaceRenderTarget, 15) : IUnknown
  369. {
  370. virtual HRESULT BeginDrawing(IAvnGlSurfaceRenderingSession** ret) = 0;
  371. };
  372. AVNCOM(IAvnGlSurfaceRenderingSession, 16) : IUnknown
  373. {
  374. virtual HRESULT GetPixelSize(AvnPixelSize* ret) = 0;
  375. virtual HRESULT GetScaling(double* ret) = 0;
  376. };
  377. AVNCOM(IAvnMenu, 17) : IUnknown
  378. {
  379. virtual HRESULT InsertItem (int index, IAvnMenuItem* item) = 0;
  380. virtual HRESULT RemoveItem (IAvnMenuItem* item) = 0;
  381. virtual HRESULT SetTitle (void* utf8String) = 0;
  382. virtual HRESULT Clear () = 0;
  383. };
  384. AVNCOM(IAvnPredicateCallback, 18) : IUnknown
  385. {
  386. virtual bool Evaluate() = 0;
  387. };
  388. AVNCOM(IAvnMenuItem, 19) : IUnknown
  389. {
  390. virtual HRESULT SetSubMenu (IAvnMenu* menu) = 0;
  391. virtual HRESULT SetTitle (void* utf8String) = 0;
  392. virtual HRESULT SetGesture (void* utf8String, AvnInputModifiers modifiers) = 0;
  393. virtual HRESULT SetAction (IAvnPredicateCallback* predicate, IAvnActionCallback* callback) = 0;
  394. virtual HRESULT SetIsChecked (bool isChecked) = 0;
  395. virtual HRESULT SetToggleType (AvnMenuItemToggleType toggleType) = 0;
  396. virtual HRESULT SetIcon (void* data, size_t length) = 0;
  397. };
  398. AVNCOM(IAvnMenuEvents, 1A) : IUnknown
  399. {
  400. /**
  401. * NeedsUpdate
  402. */
  403. virtual void NeedsUpdate () = 0;
  404. };
  405. AVNCOM(IAvnStringArray, 20) : IUnknown
  406. {
  407. virtual unsigned int GetCount() = 0;
  408. virtual HRESULT Get(unsigned int index, IAvnString**ppv) = 0;
  409. };
  410. AVNCOM(IAvnDndResultCallback, 21) : IUnknown
  411. {
  412. virtual void OnDragAndDropComplete(AvnDragDropEffects effecct) = 0;
  413. };
  414. AVNCOM(IAvnGCHandleDeallocatorCallback, 22) : IUnknown
  415. {
  416. virtual void FreeGCHandle(void* handle) = 0;
  417. };
  418. extern "C" IAvaloniaNativeFactory* CreateAvaloniaNative();