GHOST_C-api.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software Foundation,
  14. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. *
  16. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  17. * All rights reserved.
  18. */
  19. /** \file
  20. * \ingroup GHOST
  21. * \brief GHOST C-API function and type declarations.
  22. */
  23. #ifndef __GHOST_C_API_H__
  24. #define __GHOST_C_API_H__
  25. #include "GHOST_Types.h"
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /**
  30. * Creates a "handle" for a C++ GHOST object.
  31. * A handle is just an opaque pointer to an empty struct.
  32. * In the API the pointer is cast to the actual C++ class.
  33. * The 'name' argument to the macro is the name of the handle to create.
  34. */
  35. GHOST_DECLARE_HANDLE(GHOST_SystemHandle);
  36. GHOST_DECLARE_HANDLE(GHOST_TimerTaskHandle);
  37. GHOST_DECLARE_HANDLE(GHOST_WindowHandle);
  38. GHOST_DECLARE_HANDLE(GHOST_EventHandle);
  39. GHOST_DECLARE_HANDLE(GHOST_RectangleHandle);
  40. GHOST_DECLARE_HANDLE(GHOST_EventConsumerHandle);
  41. GHOST_DECLARE_HANDLE(GHOST_ContextHandle);
  42. /**
  43. * Definition of a callback routine that receives events.
  44. * \param event The event received.
  45. * \param userdata The callback's user data, supplied to GHOST_CreateSystem.
  46. */
  47. typedef int (*GHOST_EventCallbackProcPtr)(GHOST_EventHandle event, GHOST_TUserDataPtr userdata);
  48. /**
  49. * Creates the one and only system.
  50. * \return a handle to the system.
  51. */
  52. extern GHOST_SystemHandle GHOST_CreateSystem(void);
  53. /**
  54. * Disposes the one and only system.
  55. * \param systemhandle The handle to the system
  56. * \return An indication of success.
  57. */
  58. extern GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle);
  59. /**
  60. * Creates an event consumer object
  61. * \param eventCallback The event callback routine.
  62. * \param userdata Pointer to user data returned to the callback routine.
  63. */
  64. extern GHOST_EventConsumerHandle GHOST_CreateEventConsumer(
  65. GHOST_EventCallbackProcPtr eventCallback, GHOST_TUserDataPtr userdata);
  66. /**
  67. * Disposes an event consumer object
  68. * \param consumerhandle Handle to the event consumer.
  69. * \return An indication of success.
  70. */
  71. extern GHOST_TSuccess GHOST_DisposeEventConsumer(GHOST_EventConsumerHandle consumerhandle);
  72. /**
  73. * Returns the system time.
  74. * Returns the number of milliseconds since the start of the system process.
  75. * Based on ANSI clock() routine.
  76. * \param systemhandle The handle to the system
  77. * \return The number of milliseconds.
  78. */
  79. extern GHOST_TUns64 GHOST_GetMilliSeconds(GHOST_SystemHandle systemhandle);
  80. /**
  81. * Installs a timer.
  82. * Note that, on most operating systems, messages need to be processed in order
  83. * for the timer callbacks to be invoked.
  84. * \param systemhandle The handle to the system
  85. * \param delay The time to wait for the first call to the timerProc (in milliseconds)
  86. * \param interval The interval between calls to the timerProc (in milliseconds)
  87. * \param timerProc The callback invoked when the interval expires,
  88. * \param userData Placeholder for user data.
  89. * \return A timer task (0 if timer task installation failed).
  90. */
  91. extern GHOST_TimerTaskHandle GHOST_InstallTimer(GHOST_SystemHandle systemhandle,
  92. GHOST_TUns64 delay,
  93. GHOST_TUns64 interval,
  94. GHOST_TimerProcPtr timerProc,
  95. GHOST_TUserDataPtr userData);
  96. /**
  97. * Removes a timer.
  98. * \param systemhandle The handle to the system
  99. * \param timertaskhandle Timer task to be removed.
  100. * \return Indication of success.
  101. */
  102. extern GHOST_TSuccess GHOST_RemoveTimer(GHOST_SystemHandle systemhandle,
  103. GHOST_TimerTaskHandle timertaskhandle);
  104. /***************************************************************************************
  105. * Display/window management functionality
  106. ***************************************************************************************/
  107. /**
  108. * Returns the number of displays on this system.
  109. * \param systemhandle The handle to the system
  110. * \return The number of displays.
  111. */
  112. extern GHOST_TUns8 GHOST_GetNumDisplays(GHOST_SystemHandle systemhandle);
  113. /**
  114. * Returns the dimensions of the main display on this system.
  115. * \param systemhandle The handle to the system
  116. * \param width A pointer the width gets put in
  117. * \param height A pointer the height gets put in
  118. * \return void.
  119. */
  120. extern void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
  121. GHOST_TUns32 *width,
  122. GHOST_TUns32 *height);
  123. /**
  124. * Returns the dimensions of all displays combine
  125. * (the current workspace).
  126. * No need to worry about overlapping monitors.
  127. * \param systemhandle The handle to the system
  128. * \param width A pointer the width gets put in
  129. * \param height A pointer the height gets put in
  130. * \return void.
  131. */
  132. extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
  133. GHOST_TUns32 *width,
  134. GHOST_TUns32 *height);
  135. /**
  136. * Create a new window.
  137. * The new window is added to the list of windows managed.
  138. * Never explicitly delete the window, use disposeWindow() instead.
  139. * \param systemhandle The handle to the system
  140. * \param title The name of the window
  141. * (displayed in the title bar of the window if the OS supports it).
  142. * \param left The coordinate of the left edge of the window.
  143. * \param top The coordinate of the top edge of the window.
  144. * \param width The width the window.
  145. * \param height The height the window.
  146. * \param state The state of the window when opened.
  147. * \param type The type of drawing context installed in this window.
  148. * \param glSettings: Misc OpenGL options.
  149. * \return A handle to the new window ( == NULL if creation failed).
  150. */
  151. extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
  152. const char *title,
  153. GHOST_TInt32 left,
  154. GHOST_TInt32 top,
  155. GHOST_TUns32 width,
  156. GHOST_TUns32 height,
  157. GHOST_TWindowState state,
  158. GHOST_TDrawingContextType type,
  159. GHOST_GLSettings glSettings);
  160. /**
  161. * Create a new offscreen context.
  162. * Never explicitly delete the context, use disposeContext() instead.
  163. * \param systemhandle The handle to the system
  164. * \return A handle to the new context ( == NULL if creation failed).
  165. */
  166. extern GHOST_ContextHandle GHOST_CreateOpenGLContext(GHOST_SystemHandle systemhandle);
  167. /**
  168. * Dispose of a context.
  169. * \param systemhandle The handle to the system
  170. * \param contexthandle Handle to the context to be disposed.
  171. * \return Indication of success.
  172. */
  173. extern GHOST_TSuccess GHOST_DisposeOpenGLContext(GHOST_SystemHandle systemhandle,
  174. GHOST_ContextHandle contexthandle);
  175. /**
  176. * Returns the window user data.
  177. * \param windowhandle The handle to the window
  178. * \return The window user data.
  179. */
  180. extern GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle);
  181. /**
  182. * Changes the window user data.
  183. * \param windowhandle The handle to the window
  184. * \param userdata The window user data.
  185. */
  186. extern void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle, GHOST_TUserDataPtr userdata);
  187. /**
  188. * Dispose a window.
  189. * \param systemhandle The handle to the system
  190. * \param windowhandle Handle to the window to be disposed.
  191. * \return Indication of success.
  192. */
  193. extern GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle,
  194. GHOST_WindowHandle windowhandle);
  195. /**
  196. * Returns whether a window is valid.
  197. * \param systemhandle The handle to the system
  198. * \param windowhandle Handle to the window to be checked.
  199. * \return Indication of validity.
  200. */
  201. extern int GHOST_ValidWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle);
  202. /**
  203. * Begins full screen mode.
  204. * \param systemhandle The handle to the system
  205. * \param setting The new setting of the display.
  206. * \param stereoVisual Option for stereo display.
  207. * \return A handle to the window displayed in full screen.
  208. * This window is invalid after full screen has been ended.
  209. */
  210. extern GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
  211. GHOST_DisplaySetting *setting,
  212. const int stereoVisual);
  213. /**
  214. * Ends full screen mode.
  215. * \param systemhandle The handle to the system
  216. * \return Indication of success.
  217. */
  218. extern GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle);
  219. /**
  220. * Returns current full screen mode status.
  221. * \param systemhandle The handle to the system
  222. * \return The current status.
  223. */
  224. extern int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle);
  225. /***************************************************************************************
  226. * Event management functionality
  227. ***************************************************************************************/
  228. /**
  229. * Retrieves events from the system and stores them in the queue.
  230. * \param systemhandle The handle to the system
  231. * \param waitForEvent Boolean to indicate that ProcessEvents should
  232. * wait (block) until the next event before returning.
  233. * \return Indication of the presence of events.
  234. */
  235. extern int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent);
  236. /**
  237. * Retrieves events from the queue and send them to the event consumers.
  238. * \param systemhandle The handle to the system
  239. */
  240. extern void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle);
  241. /**
  242. * Adds the given event consumer to our list.
  243. * \param systemhandle The handle to the system
  244. * \param consumerhandle The event consumer to add.
  245. * \return Indication of success.
  246. */
  247. extern GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle,
  248. GHOST_EventConsumerHandle consumerhandle);
  249. /**
  250. * Remove the given event consumer to our list.
  251. * \param systemhandle The handle to the system
  252. * \param consumerhandle The event consumer to remove.
  253. * \return Indication of success.
  254. */
  255. extern GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle,
  256. GHOST_EventConsumerHandle consumerhandle);
  257. /***************************************************************************************
  258. * Progress bar functionality
  259. ***************************************************************************************/
  260. /**
  261. * Sets the progress bar value displayed in the window/application icon
  262. * \param windowhandle The handle to the window
  263. * \param progress The progress % (0.0 to 1.0)
  264. */
  265. extern GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle, float progress);
  266. /**
  267. * Hides the progress bar in the icon
  268. * \param windowhandle The handle to the window
  269. */
  270. extern GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle);
  271. /***************************************************************************************
  272. * Cursor management functionality
  273. ***************************************************************************************/
  274. /**
  275. * Returns the current cursor shape.
  276. * \param windowhandle The handle to the window
  277. * \return The current cursor shape.
  278. */
  279. extern GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle);
  280. /**
  281. * Set the shape of the cursor.
  282. * \param windowhandle The handle to the window
  283. * \param cursorshape The new cursor shape type id.
  284. * \return Indication of success.
  285. */
  286. extern GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
  287. GHOST_TStandardCursor cursorshape);
  288. /**
  289. * Set the shape of the cursor to a custom cursor of specified size.
  290. * \param windowhandle The handle to the window
  291. * \param bitmap The bitmap data for the cursor.
  292. * \param mask The mask data for the cursor.
  293. * \param sizex The width of the cursor
  294. * \param sizey The height of the cursor
  295. * \param hotX The X coordinate of the cursor hotspot.
  296. * \param hotY The Y coordinate of the cursor hotspot.
  297. * \param canInvertColor Let macOS invert cursor color to match platform convention.
  298. * \return Indication of success.
  299. */
  300. extern GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
  301. GHOST_TUns8 *bitmap,
  302. GHOST_TUns8 *mask,
  303. int sizex,
  304. int sizey,
  305. int hotX,
  306. int hotY,
  307. GHOST_TUns8 canInvertColor);
  308. /**
  309. * Returns the visibility state of the cursor.
  310. * \param windowhandle The handle to the window
  311. * \return The visibility state of the cursor.
  312. */
  313. extern int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle);
  314. /**
  315. * Shows or hides the cursor.
  316. * \param windowhandle The handle to the window
  317. * \param visible The new visibility state of the cursor.
  318. * \return Indication of success.
  319. */
  320. extern GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle, int visible);
  321. /**
  322. * Returns the current location of the cursor (location in screen coordinates)
  323. * \param systemhandle The handle to the system
  324. * \param x The x-coordinate of the cursor.
  325. * \param y The y-coordinate of the cursor.
  326. * \return Indication of success.
  327. */
  328. extern GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
  329. GHOST_TInt32 *x,
  330. GHOST_TInt32 *y);
  331. /**
  332. * Updates the location of the cursor (location in screen coordinates).
  333. * Not all operating systems allow the cursor to be moved (without the input device being moved).
  334. * \param systemhandle The handle to the system
  335. * \param x The x-coordinate of the cursor.
  336. * \param y The y-coordinate of the cursor.
  337. * \return Indication of success.
  338. */
  339. extern GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
  340. GHOST_TInt32 x,
  341. GHOST_TInt32 y);
  342. /**
  343. * Grabs the cursor for a modal operation, to keep receiving
  344. * events when the mouse is outside the window. X11 only, others
  345. * do this automatically.
  346. * \param windowhandle The handle to the window
  347. * \param mode The new grab state of the cursor.
  348. * \param bounds The grab region (optional) - left,top,right,bottom
  349. * \param mouse_ungrab_xy XY for new mouse location (optional) - x,y
  350. * \return Indication of success.
  351. */
  352. extern GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
  353. GHOST_TGrabCursorMode mode,
  354. GHOST_TAxisFlag warp_axis,
  355. int bounds[4],
  356. const int mouse_ungrab_xy[2]);
  357. /***************************************************************************************
  358. * Access to mouse button and keyboard states.
  359. ***************************************************************************************/
  360. /**
  361. * Returns the state of a modifier key (ouside the message queue).
  362. * \param systemhandle The handle to the system
  363. * \param mask The modifier key state to retrieve.
  364. * \param isDown Pointer to return modifier state in.
  365. * \return Indication of success.
  366. */
  367. extern GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
  368. GHOST_TModifierKeyMask mask,
  369. int *isDown);
  370. /**
  371. * Returns the state of a mouse button (ouside the message queue).
  372. * \param systemhandle The handle to the system
  373. * \param mask The button state to retrieve.
  374. * \param isDown Pointer to return button state in.
  375. * \return Indication of success.
  376. */
  377. extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
  378. GHOST_TButtonMask mask,
  379. int *isDown);
  380. #ifdef WITH_INPUT_NDOF
  381. /***************************************************************************************
  382. * Access to 3D mouse.
  383. ***************************************************************************************/
  384. /**
  385. * Sets 3D mouse dead-zone.
  386. * \param deadzone: Dead-zone of the 3D mouse (both for rotation and pan) relative to full range.
  387. */
  388. extern void GHOST_setNDOFDeadZone(float deadzone);
  389. #endif
  390. /***************************************************************************************
  391. * Drag'n'drop operations
  392. ***************************************************************************************/
  393. /**
  394. * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
  395. */
  396. extern void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept);
  397. /**
  398. * Returns the event type.
  399. * \param eventhandle The handle to the event
  400. * \return The event type.
  401. */
  402. extern GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle);
  403. /**
  404. * Returns the time this event was generated.
  405. * \param eventhandle The handle to the event
  406. * \return The event generation time.
  407. */
  408. extern GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle);
  409. /**
  410. * Returns the window this event was generated on,
  411. * or NULL if it is a 'system' event.
  412. * \param eventhandle The handle to the event
  413. * \return The generating window.
  414. */
  415. extern GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle);
  416. /**
  417. * Returns the event data.
  418. * \param eventhandle The handle to the event
  419. * \return The event data.
  420. */
  421. extern GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle);
  422. /**
  423. * Returns the timer callback.
  424. * \param timertaskhandle The handle to the timertask
  425. * \return The timer callback.
  426. */
  427. extern GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle);
  428. /**
  429. * Changes the timer callback.
  430. * \param timertaskhandle The handle to the timertask
  431. * \param timerProc The timer callback.
  432. */
  433. extern void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
  434. GHOST_TimerProcPtr timerProc);
  435. /**
  436. * Returns the timer user data.
  437. * \param timertaskhandle The handle to the timertask
  438. * \return The timer user data.
  439. */
  440. extern GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle);
  441. /**
  442. * Changes the time user data.
  443. * \param timertaskhandle The handle to the timertask
  444. * \param userdata The timer user data.
  445. */
  446. extern void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
  447. GHOST_TUserDataPtr userdata);
  448. /**
  449. * Returns indication as to whether the window is valid.
  450. * \param windowhandle The handle to the window
  451. * \return The validity of the window.
  452. */
  453. extern int GHOST_GetValid(GHOST_WindowHandle windowhandle);
  454. /**
  455. * Returns the type of drawing context used in this window.
  456. * \param windowhandle The handle to the window
  457. * \return The current type of drawing context.
  458. */
  459. extern GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle);
  460. /**
  461. * Tries to install a rendering context in this window.
  462. * \param windowhandle The handle to the window
  463. * \param type The type of rendering context installed.
  464. * \return Indication as to whether installation has succeeded.
  465. */
  466. extern GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle,
  467. GHOST_TDrawingContextType type);
  468. /**
  469. * Sets the title displayed in the title bar.
  470. * \param windowhandle The handle to the window
  471. * \param title The title to display in the title bar.
  472. */
  473. extern void GHOST_SetTitle(GHOST_WindowHandle windowhandle, const char *title);
  474. /**
  475. * Returns the title displayed in the title bar. The title
  476. * should be free'd with free().
  477. *
  478. * \param windowhandle The handle to the window
  479. * \return The title, free with free().
  480. */
  481. extern char *GHOST_GetTitle(GHOST_WindowHandle windowhandle);
  482. /**
  483. * Returns the window rectangle dimensions.
  484. * These are screen coordinates.
  485. * \param windowhandle The handle to the window
  486. * \return A handle to the bounding rectangle of the window.
  487. */
  488. extern GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle);
  489. /**
  490. * Returns the client rectangle dimensions.
  491. * The left and top members of the rectangle are always zero.
  492. * \param windowhandle The handle to the window
  493. * \return A handle to the bounding rectangle of the window.
  494. */
  495. extern GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle);
  496. /**
  497. * Disposes a rectangle object
  498. * \param rectanglehandle Handle to the rectangle.
  499. */
  500. void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle);
  501. /**
  502. * Resizes client rectangle width.
  503. * \param windowhandle The handle to the window
  504. * \param width The new width of the client area of the window.
  505. * \return Indication of success.
  506. */
  507. extern GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle, GHOST_TUns32 width);
  508. /**
  509. * Resizes client rectangle height.
  510. * \param windowhandle The handle to the window
  511. * \param height The new height of the client area of the window.
  512. * \return Indication of success.
  513. */
  514. extern GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle, GHOST_TUns32 height);
  515. /**
  516. * Resizes client rectangle.
  517. * \param windowhandle The handle to the window
  518. * \param width The new width of the client area of the window.
  519. * \param height The new height of the client area of the window.
  520. * \return Indication of success.
  521. */
  522. extern GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle,
  523. GHOST_TUns32 width,
  524. GHOST_TUns32 height);
  525. /**
  526. * Converts a point in screen coordinates to client rectangle coordinates
  527. * \param windowhandle The handle to the window
  528. * \param inX The x-coordinate on the screen.
  529. * \param inY The y-coordinate on the screen.
  530. * \param outX The x-coordinate in the client rectangle.
  531. * \param outY The y-coordinate in the client rectangle.
  532. */
  533. extern void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle,
  534. GHOST_TInt32 inX,
  535. GHOST_TInt32 inY,
  536. GHOST_TInt32 *outX,
  537. GHOST_TInt32 *outY);
  538. /**
  539. * Converts a point in screen coordinates to client rectangle coordinates
  540. * \param windowhandle The handle to the window
  541. * \param inX The x-coordinate in the client rectangle.
  542. * \param inY The y-coordinate in the client rectangle.
  543. * \param outX The x-coordinate on the screen.
  544. * \param outY The y-coordinate on the screen.
  545. */
  546. extern void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle,
  547. GHOST_TInt32 inX,
  548. GHOST_TInt32 inY,
  549. GHOST_TInt32 *outX,
  550. GHOST_TInt32 *outY);
  551. /**
  552. * Returns the state of the window (normal, minimized, maximized).
  553. * \param windowhandle The handle to the window
  554. * \return The state of the window.
  555. */
  556. extern GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle);
  557. /**
  558. * Sets the state of the window (normal, minimized, maximized).
  559. * \param windowhandle The handle to the window
  560. * \param state The state of the window.
  561. * \return Indication of success.
  562. */
  563. extern GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
  564. GHOST_TWindowState state);
  565. /**
  566. * Sets the window "modified" status, indicating unsaved changes
  567. * \param windowhandle The handle to the window
  568. * \param isUnsavedChanges Unsaved changes or not
  569. * \return Indication of success.
  570. */
  571. extern GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle,
  572. GHOST_TUns8 isUnsavedChanges);
  573. /**
  574. * Sets the order of the window (bottom, top).
  575. * \param windowhandle The handle to the window
  576. * \param order The order of the window.
  577. * \return Indication of success.
  578. */
  579. extern GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
  580. GHOST_TWindowOrder order);
  581. /**
  582. * Swaps front and back buffers of a window.
  583. * \param windowhandle The handle to the window
  584. * \return A success indicator.
  585. */
  586. extern GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle);
  587. /**
  588. * Sets the swap interval for swapBuffers.
  589. * \param interval The swap interval to use.
  590. * \return A boolean success indicator.
  591. */
  592. extern GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interval);
  593. /**
  594. * Gets the current swap interval for swapBuffers.
  595. * \param windowhandle: The handle to the window
  596. * \param intervalOut: pointer to location to return swap interval
  597. * (left untouched if there is an error)
  598. * \return A boolean success indicator of if swap interval was successfully read.
  599. */
  600. extern GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int *intervalOut);
  601. /**
  602. * Activates the drawing context of this window.
  603. * \param windowhandle The handle to the window
  604. * \return A success indicator.
  605. */
  606. extern GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle);
  607. /**
  608. * Invalidates the contents of this window.
  609. * \param windowhandle The handle to the window
  610. * \return Indication of success.
  611. */
  612. extern GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle);
  613. /**
  614. * Activates the drawing context of this context.
  615. * \param contexthandle The handle to the context
  616. * \return A success indicator.
  617. */
  618. extern GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthandle);
  619. /**
  620. * Release the drawing context bound to this thread.
  621. * \param contexthandle The handle to the context
  622. * \return A success indicator.
  623. */
  624. extern GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle);
  625. /**
  626. * Get the OpenGL framebuffer handle that serves as a default framebuffer.
  627. */
  628. extern unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windwHandle);
  629. /**
  630. * Set which tablet API to use. Only affects Windows, other platforms have a single API.
  631. * \param systemhandle The handle to the system
  632. * \param api Enum indicating which API to use.
  633. */
  634. extern void GHOST_SetTabletAPI(GHOST_SystemHandle systemhandle, GHOST_TTabletAPI api);
  635. /**
  636. * Returns the status of the tablet
  637. * \param windowhandle The handle to the window
  638. * \return Status of tablet
  639. */
  640. extern const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle);
  641. /**
  642. * Access to rectangle width.
  643. * \param rectanglehandle The handle to the rectangle
  644. * \return width of the rectangle
  645. */
  646. extern GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle);
  647. /**
  648. * Access to rectangle height.
  649. * \param rectanglehandle The handle to the rectangle
  650. * \return height of the rectangle
  651. */
  652. extern GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle);
  653. /**
  654. * Gets all members of the rectangle.
  655. * \param rectanglehandle The handle to the rectangle
  656. * \param l Pointer to return left coordinate in.
  657. * \param t Pointer to return top coordinate in.
  658. * \param r Pointer to return right coordinate in.
  659. * \param b Pointer to return bottom coordinate in.
  660. */
  661. extern void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
  662. GHOST_TInt32 *l,
  663. GHOST_TInt32 *t,
  664. GHOST_TInt32 *r,
  665. GHOST_TInt32 *b);
  666. /**
  667. * Sets all members of the rectangle.
  668. * \param rectanglehandle The handle to the rectangle
  669. * \param l requested left coordinate of the rectangle
  670. * \param t requested top coordinate of the rectangle
  671. * \param r requested right coordinate of the rectangle
  672. * \param b requested bottom coordinate of the rectangle
  673. */
  674. extern void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
  675. GHOST_TInt32 l,
  676. GHOST_TInt32 t,
  677. GHOST_TInt32 r,
  678. GHOST_TInt32 b);
  679. /**
  680. * Returns whether this rectangle is empty.
  681. * Empty rectangles are rectangles that have width==0 and/or height==0.
  682. * \param rectanglehandle The handle to the rectangle
  683. * \return Success value (true == empty rectangle)
  684. */
  685. extern GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle);
  686. /**
  687. * Returns whether this rectangle is valid.
  688. * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b.
  689. * Thus, empty rectangles are valid.
  690. * \param rectanglehandle The handle to the rectangle
  691. * \return Success value (true == valid rectangle)
  692. */
  693. extern GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle);
  694. /**
  695. * Grows (or shrinks the rectangle).
  696. * The method avoids negative insets making the rectangle invalid
  697. * \param rectanglehandle The handle to the rectangle
  698. * \param i The amount of offset given to each extreme (negative values shrink the rectangle).
  699. */
  700. extern void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle, GHOST_TInt32 i);
  701. /**
  702. * Does a union of the rectangle given and this rectangle.
  703. * The result is stored in this rectangle.
  704. * \param rectanglehandle The handle to the rectangle
  705. * \param anotherrectanglehandle The rectangle that is input for the union operation.
  706. */
  707. extern void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
  708. GHOST_RectangleHandle anotherrectanglehandle);
  709. /**
  710. * Grows the rectangle to included a point.
  711. * \param rectanglehandle The handle to the rectangle
  712. * \param x The x-coordinate of the point.
  713. * \param y The y-coordinate of the point.
  714. */
  715. extern void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
  716. GHOST_TInt32 x,
  717. GHOST_TInt32 y);
  718. /**
  719. * Returns whether the point is inside this rectangle.
  720. * Point on the boundary is considered inside.
  721. * \param rectanglehandle The handle to the rectangle
  722. * \param x x-coordinate of point to test.
  723. * \param y y-coordinate of point to test.
  724. * \return Success value (true if point is inside).
  725. */
  726. extern GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
  727. GHOST_TInt32 x,
  728. GHOST_TInt32 y);
  729. /**
  730. * Returns whether the rectangle is inside this rectangle.
  731. * \param rectanglehandle The handle to the rectangle
  732. * \param anotherrectanglehandle The rectangle to test.
  733. * \return visibility (not, partially or fully visible).
  734. */
  735. extern GHOST_TVisibility GHOST_GetRectangleVisibility(
  736. GHOST_RectangleHandle rectanglehandle, GHOST_RectangleHandle anotherrectanglehandle);
  737. /**
  738. * Sets rectangle members.
  739. * Sets rectangle members such that it is centered at the given location.
  740. * \param rectanglehandle The handle to the rectangle
  741. * \param cx Requested center x-coordinate of the rectangle
  742. * \param cy Requested center y-coordinate of the rectangle
  743. */
  744. extern void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
  745. GHOST_TInt32 cx,
  746. GHOST_TInt32 cy);
  747. /**
  748. * Sets rectangle members.
  749. * Sets rectangle members such that it is centered at the given location,
  750. * with the width requested.
  751. * \param rectanglehandle The handle to the rectangle
  752. * \param cx requested center x-coordinate of the rectangle
  753. * \param cy requested center y-coordinate of the rectangle
  754. * \param w requested width of the rectangle
  755. * \param h requested height of the rectangle
  756. */
  757. extern void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
  758. GHOST_TInt32 cx,
  759. GHOST_TInt32 cy,
  760. GHOST_TInt32 w,
  761. GHOST_TInt32 h);
  762. /**
  763. * Clips a rectangle.
  764. * Updates the rectangle given such that it will fit within this one.
  765. * This can result in an empty rectangle.
  766. * \param rectanglehandle The handle to the rectangle
  767. * \param anotherrectanglehandle The rectangle to clip
  768. * \return Whether clipping has occurred
  769. */
  770. extern GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
  771. GHOST_RectangleHandle anotherrectanglehandle);
  772. /**
  773. * Return the data from the clipboard
  774. * \param selection Boolean to return the selection instead, X11 only feature.
  775. * \return clipboard data
  776. */
  777. extern GHOST_TUns8 *GHOST_getClipboard(int selection);
  778. /**
  779. * Put data to the Clipboard
  780. * \param buffer the string buffer to set.
  781. * \param selection Set the selection instead, X11 only feature.
  782. */
  783. extern void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection);
  784. /**
  785. * Toggles console
  786. * \param action
  787. * - 0: Hides
  788. * - 1: Shows
  789. * - 2: Toggles
  790. * - 3: Hides if it runs not from command line
  791. * - *: Does nothing
  792. * \return current status (1 -visible, 0 - hidden)
  793. */
  794. extern int GHOST_toggleConsole(int action);
  795. /**
  796. * Use native pixel size (MacBook pro 'retina'), if supported.
  797. */
  798. extern int GHOST_UseNativePixels(void);
  799. /**
  800. * Focus window after opening, or put them in the background.
  801. */
  802. extern void GHOST_UseWindowFocus(int use_focus);
  803. /**
  804. * If window was opened using native pixel size, it returns scaling factor.
  805. */
  806. extern float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle);
  807. /**
  808. * Returns the suggested DPI for this window.
  809. */
  810. extern GHOST_TUns16 GHOST_GetDPIHint(GHOST_WindowHandle windowhandle);
  811. /**
  812. * Enable IME attached to the given window, i.e. allows user-input
  813. * events to be dispatched to the IME.
  814. * \param windowhandle Window handle of the caller
  815. * \param x Requested x-coordinate of the rectangle
  816. * \param y Requested y-coordinate of the rectangle
  817. * \param w Requested width of the rectangle
  818. * \param h Requested height of the rectangle
  819. * \param complete Whether or not to complete the ongoing composition
  820. * true: Start a new composition
  821. * false: Move the IME windows to the given position without finishing it.
  822. */
  823. extern void GHOST_BeginIME(GHOST_WindowHandle windowhandle,
  824. GHOST_TInt32 x,
  825. GHOST_TInt32 y,
  826. GHOST_TInt32 w,
  827. GHOST_TInt32 h,
  828. int complete);
  829. /**
  830. * Disable the IME attached to the given window, i.e. prohibits any user-input
  831. * events from being dispatched to the IME.
  832. * \param windowhandle The window handle of the caller
  833. */
  834. extern void GHOST_EndIME(GHOST_WindowHandle windowhandle);
  835. #ifdef __cplusplus
  836. }
  837. #endif
  838. #endif