3 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. The Blender
9 * Foundation also sells licenses for use in proprietary software under
10 * the Blender License. See http://www.blender.org/BL/ for information
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 * All rights reserved.
25 * The Original Code is: all of this file.
27 * Contributor(s): none yet.
29 * ***** END GPL/BL DUAL LICENSE BLOCK *****
32 * @file GHOST_Window.h
33 * Declaration of GHOST_Window class.
36 #ifndef _GHOST_WINDOW_H_
37 #define _GHOST_WINDOW_H_
39 #include "GHOST_IWindow.h"
44 * Platform independent implementation of GHOST_IWindow.
45 * Dimensions are given in screen coordinates that are relative to the
46 * upper-left corner of the screen.
47 * Implements part of the GHOST_IWindow interface and adds some methods to
48 * be implemented by childs of this class.
49 * @author Maarten Gribnau
52 class GHOST_Window : public GHOST_IWindow
56 * @section Interface inherited from GHOST_IWindow left for derived class
58 * virtual bool getValid() const = 0;
59 * virtual void setTitle(const STR_String& title) = 0;
60 * virtual void getTitle(STR_String& title) const = 0;
61 * virtual void getWindowBounds(GHOST_Rect& bounds) const = 0;
62 * virtual void getClientBounds(GHOST_Rect& bounds) const = 0;
63 * virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
64 * virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
65 * virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
66 * virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
67 * virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
68 * virtual GHOST_TWindowState getState() const = 0;
69 * virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
70 * virtual GHOST_TWindowOrder getOrder(void) = 0;
71 * virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
72 * virtual GHOST_TSuccess swapBuffers() = 0;
73 * virtual GHOST_TSuccess activateDrawingContext() = 0;
74 * virtual GHOST_TSuccess invalidate() = 0;
79 * Creates a new window and opens it.
80 * To check if the window was created properly, use the getValid() method.
81 * @param title The text shown in the title bar of the window.
82 * @param left The coordinate of the left edge of the window.
83 * @param top The coordinate of the top edge of the window.
84 * @param width The width the window.
85 * @param heigh The height the window.
86 * @param state The state the window is initially opened with.
87 * @param type The type of drawing context installed in this window.
88 * @param stereoVisual Stereo visual for quad buffered stereo.
91 const STR_String& title,
96 GHOST_TWindowState state,
97 GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
98 const bool stereoVisual = false);
101 * @section Interface inherited from GHOST_IWindow left for derived class
103 * virtual bool getValid() const = 0;
104 * virtual void setTitle(const STR_String& title) = 0;
105 * virtual void getTitle(STR_String& title) const = 0;
106 * virtual void getWindowBounds(GHOST_Rect& bounds) const = 0;
107 * virtual void getClientBounds(GHOST_Rect& bounds) const = 0;
108 * virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
109 * virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
110 * virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
111 * virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
112 * virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
113 * virtual GHOST_TWindowState getState() const = 0;
114 * virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
115 * virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
116 * virtual GHOST_TSuccess swapBuffers() = 0;
117 * virtual GHOST_TSuccess activateDrawingContext() = 0;
118 * virtual GHOST_TSuccess invalidate() = 0;
123 * Closes the window and disposes resources allocated.
125 virtual ~GHOST_Window();
128 * Returns the current cursor shape.
129 * @return The current cursor shape.
131 inline virtual GHOST_TStandardCursor getCursorShape() const;
134 * Set the shape of the cursor.
135 * @param cursor The new cursor shape type id.
136 * @return Indication of success.
138 virtual GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursorShape);
141 * Set the shape of the cursor to a custom cursor.
142 * @param bitmap The bitmap data for the cursor.
143 * @param mask The mask data for the cursor.
144 * @param hotX The X coordinate of the cursor hotspot.
145 * @param hotY The Y coordinate of the cursor hotspot.
146 * @return Indication of success.
148 virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 bitmap[16][2],
149 GHOST_TUns8 mask[16][2],
154 * Returns the visibility state of the cursor.
155 * @return The visibility state of the cursor.
157 inline virtual bool getCursorVisibility() const;
160 * Shows or hides the cursor.
161 * @param visible The new visibility state of the cursor.
162 * @return Indication of success.
164 virtual GHOST_TSuccess setCursorVisibility(bool visible);
167 * Returns the type of drawing context used in this window.
168 * @return The current type of drawing context.
170 inline virtual GHOST_TDrawingContextType getDrawingContextType();
173 * Tries to install a rendering context in this window.
174 * Child classes do not need to overload this method.
175 * They should overload the installDrawingContext and removeDrawingContext instead.
176 * @param type The type of rendering context installed.
177 * @return Indication as to whether installation has succeeded.
179 virtual GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type);
182 * Returns the window user data.
183 * @return The window user data.
185 inline virtual GHOST_TUserDataPtr getUserData() const
191 * Changes the window user data.
192 * @param data The window user data.
194 virtual void setUserData(const GHOST_TUserDataPtr userData)
196 m_userData = userData;
201 * Tries to install a rendering context in this window.
202 * @param type The type of rendering context installed.
203 * @return Indication as to whether installation has succeeded.
205 virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type) = 0;
208 * Removes the current drawing context.
209 * @return Indication as to whether removal has succeeded.
211 virtual GHOST_TSuccess removeDrawingContext() = 0;
214 * Sets the cursor visibility on the window using
215 * native window system calls.
217 virtual GHOST_TSuccess setWindowCursorVisibility(bool visible) = 0;
220 * Sets the cursor shape on the window using
221 * native window system calls.
223 virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) = 0;
226 * Sets the cursor shape on the window using
227 * native window system calls.
229 virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY) = 0;
231 /** The the of drawing context installed in this window. */
232 GHOST_TDrawingContextType m_drawingContextType;
234 /** The window user data */
235 GHOST_TUserDataPtr m_userData;
237 /** The current visibility of the cursor */
238 bool m_cursorVisible;
240 /** The current shape of the cursor */
241 GHOST_TStandardCursor m_cursorShape;
243 /** Stores wether this is a full screen window. */
246 /** Stereo visual created. Only necessary for 'real' stereo support,
247 * ie quad buffered stereo. This is not always possible, depends on
252 /** Full-screen width */
253 GHOST_TUns32 m_fullScreenWidth;
254 /** Full-screen height */
255 GHOST_TUns32 m_fullScreenHeight;
259 inline GHOST_TDrawingContextType GHOST_Window::getDrawingContextType()
261 return m_drawingContextType;
264 inline bool GHOST_Window::getCursorVisibility() const
266 return m_cursorVisible;
269 inline GHOST_TStandardCursor GHOST_Window::getCursorShape() const
271 return m_cursorShape;
274 #endif // _GHOST_WINDOW_H