GHOST_IWindow.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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. * Declaration of GHOST_IWindow interface class.
  22. */
  23. #ifndef __GHOST_IWINDOW_H__
  24. #define __GHOST_IWINDOW_H__
  25. #include "STR_String.h"
  26. #include "GHOST_Rect.h"
  27. #include "GHOST_Types.h"
  28. /**
  29. * Interface for GHOST windows.
  30. *
  31. * You can create a window with the system's GHOST_ISystem::createWindow
  32. * method.
  33. * \see GHOST_ISystem#createWindow
  34. *
  35. * There are two coordinate systems:
  36. *
  37. * - The screen coordinate system. The origin of the screen is located in the
  38. * upper left corner of the screen.</li>
  39. * - The client rectangle coordinate system. The client rectangle of a window
  40. * is the area that is drawable by the application (excluding title bars etc.).
  41. */
  42. class GHOST_IWindow {
  43. public:
  44. /**
  45. * Destructor.
  46. */
  47. virtual ~GHOST_IWindow()
  48. {
  49. }
  50. /**
  51. * Returns indication as to whether the window is valid.
  52. * \return The validity of the window.
  53. */
  54. virtual bool getValid() const = 0;
  55. /**
  56. * Returns the associated OS object/handle
  57. * \return The associated OS object/handle
  58. */
  59. virtual void *getOSWindow() const = 0;
  60. /**
  61. * Returns the type of drawing context used in this window.
  62. * \return The current type of drawing context.
  63. */
  64. virtual GHOST_TDrawingContextType getDrawingContextType() = 0;
  65. /**
  66. * Tries to install a rendering context in this window.
  67. * \param type The type of rendering context installed.
  68. * \return Indication as to whether installation has succeeded.
  69. */
  70. virtual GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type) = 0;
  71. /**
  72. * Sets the title displayed in the title bar.
  73. * \param title The title to display in the title bar.
  74. */
  75. virtual void setTitle(const STR_String &title) = 0;
  76. /**
  77. * Returns the title displayed in the title bar.
  78. * \param title The title displayed in the title bar.
  79. */
  80. virtual void getTitle(STR_String &title) const = 0;
  81. /**
  82. * Returns the window rectangle dimensions.
  83. * These are screen coordinates.
  84. * \param bounds The bounding rectangle of the window.
  85. */
  86. virtual void getWindowBounds(GHOST_Rect &bounds) const = 0;
  87. /**
  88. * Returns the client rectangle dimensions.
  89. * The left and top members of the rectangle are always zero.
  90. * \param bounds The bounding rectangle of the client area of the window.
  91. */
  92. virtual void getClientBounds(GHOST_Rect &bounds) const = 0;
  93. /**
  94. * Resizes client rectangle width.
  95. * \param width The new width of the client area of the window.
  96. */
  97. virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
  98. /**
  99. * Resizes client rectangle height.
  100. * \param height The new height of the client area of the window.
  101. */
  102. virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
  103. /**
  104. * Resizes client rectangle.
  105. * \param width The new width of the client area of the window.
  106. * \param height The new height of the client area of the window.
  107. */
  108. virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
  109. /**
  110. * Converts a point in screen coordinates to client rectangle coordinates
  111. * \param inX The x-coordinate on the screen.
  112. * \param inY The y-coordinate on the screen.
  113. * \param outX The x-coordinate in the client rectangle.
  114. * \param outY The y-coordinate in the client rectangle.
  115. */
  116. virtual void screenToClient(GHOST_TInt32 inX,
  117. GHOST_TInt32 inY,
  118. GHOST_TInt32 &outX,
  119. GHOST_TInt32 &outY) const = 0;
  120. /**
  121. * Converts a point in screen coordinates to client rectangle coordinates
  122. * \param inX The x-coordinate in the client rectangle.
  123. * \param inY The y-coordinate in the client rectangle.
  124. * \param outX The x-coordinate on the screen.
  125. * \param outY The y-coordinate on the screen.
  126. */
  127. virtual void clientToScreen(GHOST_TInt32 inX,
  128. GHOST_TInt32 inY,
  129. GHOST_TInt32 &outX,
  130. GHOST_TInt32 &outY) const = 0;
  131. /**
  132. * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
  133. */
  134. virtual void setAcceptDragOperation(bool canAccept) = 0;
  135. /**
  136. * Returns acceptance of the dropped object
  137. * Usually called by the "object dropped" event handling function
  138. */
  139. virtual bool canAcceptDragOperation() const = 0;
  140. /**
  141. * Returns the state of the window (normal, minimized, maximized).
  142. * \return The state of the window.
  143. */
  144. virtual GHOST_TWindowState getState() const = 0;
  145. /**
  146. * Sets the state of the window (normal, minimized, maximized).
  147. * \param state The state of the window.
  148. * \return Indication of success.
  149. */
  150. virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
  151. /**
  152. * Sets the window "modified" status, indicating unsaved changes
  153. * \param isUnsavedChanges Unsaved changes or not
  154. * \return Indication of success.
  155. */
  156. virtual GHOST_TSuccess setModifiedState(bool isUnsavedChanges) = 0;
  157. /**
  158. * Gets the window "modified" status, indicating unsaved changes
  159. * \return True if there are unsaved changes
  160. */
  161. virtual bool getModifiedState() = 0;
  162. /**
  163. * Sets the order of the window (bottom, top).
  164. * \param order The order of the window.
  165. * \return Indication of success.
  166. */
  167. virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
  168. /**
  169. * Swaps front and back buffers of a window.
  170. * \return A boolean success indicator.
  171. */
  172. virtual GHOST_TSuccess swapBuffers() = 0;
  173. /**
  174. * Sets the swap interval for swapBuffers.
  175. * \param interval The swap interval to use.
  176. * \return A boolean success indicator.
  177. */
  178. virtual GHOST_TSuccess setSwapInterval(int interval) = 0;
  179. /**
  180. * Gets the current swap interval for swapBuffers.
  181. * \param intervalOut pointer to location to return swap interval
  182. * (left untouched if there is an error)
  183. * \return A boolean success indicator of if swap interval was successfully read.
  184. */
  185. virtual GHOST_TSuccess getSwapInterval(int &intervalOut) = 0;
  186. /**
  187. * Activates the drawing context of this window.
  188. * \return A boolean success indicator.
  189. */
  190. virtual GHOST_TSuccess activateDrawingContext() = 0;
  191. /**
  192. * Gets the OpenGL framebuffer associated with the window's contents.
  193. * \return The name of an OpenGL framebuffer object.
  194. */
  195. virtual unsigned int getDefaultFramebuffer() = 0;
  196. /**
  197. * Invalidates the contents of this window.
  198. * \return Indication of success.
  199. */
  200. virtual GHOST_TSuccess invalidate() = 0;
  201. /**
  202. * Returns the window user data.
  203. * \return The window user data.
  204. */
  205. virtual GHOST_TUserDataPtr getUserData() const = 0;
  206. /**
  207. * Changes the window user data.
  208. * \param userData The window user data.
  209. */
  210. virtual void setUserData(const GHOST_TUserDataPtr userData) = 0;
  211. /**
  212. * Returns the tablet data (pressure etc).
  213. * \return The tablet data (pressure etc).
  214. */
  215. virtual const GHOST_TabletData *GetTabletData() = 0;
  216. /***************************************************************************************
  217. * Progress bar functionality
  218. ***************************************************************************************/
  219. /**
  220. * Sets the progress bar value displayed in the window/application icon
  221. * \param progress The progress %
  222. */
  223. virtual GHOST_TSuccess setProgressBar(float progress) = 0;
  224. /**
  225. * Hides the progress bar in the icon
  226. */
  227. virtual GHOST_TSuccess endProgressBar() = 0;
  228. /***************************************************************************************
  229. * Cursor management functionality
  230. ***************************************************************************************/
  231. /**
  232. * Returns the current cursor shape.
  233. * \return The current cursor shape.
  234. */
  235. virtual GHOST_TStandardCursor getCursorShape() const = 0;
  236. /**
  237. * Set the shape of the cursor.
  238. * \param cursorShape: The new cursor shape type id.
  239. * \return Indication of success.
  240. */
  241. virtual GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursorShape) = 0;
  242. /**
  243. * Set the shape of the cursor to a custom cursor.
  244. * \param bitmap The bitmap data for the cursor.
  245. * \param mask The mask data for the cursor.
  246. * \param hotX The X coordinate of the cursor hotspot.
  247. * \param hotY The Y coordinate of the cursor hotspot.
  248. * \return Indication of success.
  249. */
  250. virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap,
  251. GHOST_TUns8 *mask,
  252. int sizex,
  253. int sizey,
  254. int hotX,
  255. int hotY,
  256. bool canInvertColor) = 0;
  257. /**
  258. * Returns the visibility state of the cursor.
  259. * \return The visibility state of the cursor.
  260. */
  261. virtual bool getCursorVisibility() const = 0;
  262. /**
  263. * Shows or hides the cursor.
  264. * \param visible The new visibility state of the cursor.
  265. * \return Indication of success.
  266. */
  267. virtual GHOST_TSuccess setCursorVisibility(bool visible) = 0;
  268. /**
  269. * Grabs the cursor for a modal operation.
  270. * \param grab The new grab state of the cursor.
  271. * \return Indication of success.
  272. */
  273. virtual GHOST_TSuccess setCursorGrab(GHOST_TGrabCursorMode /*mode*/,
  274. GHOST_TAxisFlag /*wrap_axis*/,
  275. GHOST_Rect * /*bounds*/,
  276. GHOST_TInt32 /*mouse_ungrab_xy*/[2])
  277. {
  278. return GHOST_kSuccess;
  279. }
  280. /** */
  281. virtual GHOST_TSuccess beginFullScreen() const = 0;
  282. virtual GHOST_TSuccess endFullScreen() const = 0;
  283. virtual float getNativePixelSize(void) = 0;
  284. /**
  285. * Returns the recommended DPI for this window.
  286. * \return The recommended DPI for this window.
  287. */
  288. virtual GHOST_TUns16 getDPIHint() = 0;
  289. #ifdef WITH_INPUT_IME
  290. /**
  291. * Enable IME attached to the given window, i.e. allows user-input
  292. * events to be dispatched to the IME.
  293. * \param x Requested x-coordinate of the rectangle
  294. * \param y Requested y-coordinate of the rectangle
  295. * \param w Requested width of the rectangle
  296. * \param h Requested height of the rectangle
  297. * \param complete Whether or not to complete the ongoing composition
  298. * true: Start a new composition
  299. * false: Move the IME windows to the given position without finishing it.
  300. */
  301. virtual void beginIME(
  302. GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 w, GHOST_TInt32 h, int completed) = 0;
  303. /**
  304. * Disable the IME attached to the given window, i.e. prohibits any user-input
  305. * events from being dispatched to the IME.
  306. */
  307. virtual void endIME() = 0;
  308. #endif /* WITH_INPUT_IME */
  309. #ifdef WITH_CXX_GUARDEDALLOC
  310. MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IWindow")
  311. #endif
  312. };
  313. #endif // __GHOST_IWINDOW_H__