3 * ***** BEGIN GPL 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.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20 * All rights reserved.
22 * The Original Code is: all of this file.
24 * Contributor(s): none yet.
26 * ***** END GPL LICENSE BLOCK *****
29 * @file GHOST_Window.h
30 * Declaration of GHOST_Window class.
33 #ifndef _GHOST_WINDOW_H_
34 #define _GHOST_WINDOW_H_
36 #include "GHOST_IWindow.h"
41 * Platform independent implementation of GHOST_IWindow.
42 * Dimensions are given in screen coordinates that are relative to the
43 * upper-left corner of the screen.
44 * Implements part of the GHOST_IWindow interface and adds some methods to
45 * be implemented by childs of this class.
46 * @author Maarten Gribnau
49 class GHOST_Window : public GHOST_IWindow
53 * @section Interface inherited from GHOST_IWindow left for derived class
55 * virtual bool getValid() const = 0;
56 * virtual void setTitle(const STR_String& title) = 0;
57 * virtual void getTitle(STR_String& title) const = 0;
58 * virtual void getWindowBounds(GHOST_Rect& bounds) const = 0;
59 * virtual void getClientBounds(GHOST_Rect& bounds) const = 0;
60 * virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
61 * virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
62 * virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
63 * virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
64 * virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
65 * virtual GHOST_TWindowState getState() const = 0;
66 * virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
67 * virtual GHOST_TWindowOrder getOrder(void) = 0;
68 * virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
69 * virtual GHOST_TSuccess swapBuffers() = 0;
70 * virtual GHOST_TSuccess activateDrawingContext() = 0;
71 * virtual GHOST_TSuccess invalidate() = 0;
76 * Creates a new window and opens it.
77 * To check if the window was created properly, use the getValid() method.
78 * @param title The text shown in the title bar of the window.
79 * @param left The coordinate of the left edge of the window.
80 * @param top The coordinate of the top edge of the window.
81 * @param width The width the window.
82 * @param heigh The height the window.
83 * @param state The state the window is initially opened with.
84 * @param type The type of drawing context installed in this window.
85 * @param stereoVisual Stereo visual for quad buffered stereo.
88 const STR_String& title,
93 GHOST_TWindowState state,
94 GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
95 const bool stereoVisual = false);
98 * @section Interface inherited from GHOST_IWindow left for derived class
100 * virtual bool getValid() const = 0;
101 * virtual void setTitle(const STR_String& title) = 0;
102 * virtual void getTitle(STR_String& title) const = 0;
103 * virtual void getWindowBounds(GHOST_Rect& bounds) const = 0;
104 * virtual void getClientBounds(GHOST_Rect& bounds) const = 0;
105 * virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
106 * virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
107 * virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
108 * virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
109 * virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
110 * virtual GHOST_TWindowState getState() const = 0;
111 * virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
112 * virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
113 * virtual GHOST_TSuccess swapBuffers() = 0;
114 * virtual GHOST_TSuccess activateDrawingContext() = 0;
115 * virtual GHOST_TSuccess invalidate() = 0;
120 * Closes the window and disposes resources allocated.
122 virtual ~GHOST_Window();
125 * Returns the current cursor shape.
126 * @return The current cursor shape.
128 inline virtual GHOST_TStandardCursor getCursorShape() const;
131 * Set the shape of the cursor.
132 * @param cursor The new cursor shape type id.
133 * @return Indication of success.
135 virtual GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursorShape);
138 * Set the shape of the cursor to a custom cursor.
139 * @param bitmap The bitmap data for the cursor.
140 * @param mask The mask data for the cursor.
141 * @param hotX The X coordinate of the cursor hotspot.
142 * @param hotY The Y coordinate of the cursor hotspot.
143 * @return Indication of success.
145 virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 bitmap[16][2],
146 GHOST_TUns8 mask[16][2],
150 virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap,
152 int sizex, int sizey,
154 int fg_color, int bg_color);
157 * Returns the visibility state of the cursor.
158 * @return The visibility state of the cursor.
160 inline virtual bool getCursorVisibility() const;
163 * Shows or hides the cursor.
164 * @param visible The new visibility state of the cursor.
165 * @return Indication of success.
167 virtual GHOST_TSuccess setCursorVisibility(bool visible);
170 * Sets the cursor grab.
171 * @param grab The new grab state of the cursor.
172 * @return Indication of success.
174 virtual GHOST_TSuccess setCursorGrab(bool grab);
177 * Returns the type of drawing context used in this window.
178 * @return The current type of drawing context.
180 inline virtual GHOST_TDrawingContextType getDrawingContextType();
183 * Tries to install a rendering context in this window.
184 * Child classes do not need to overload this method.
185 * They should overload the installDrawingContext and removeDrawingContext instead.
186 * @param type The type of rendering context installed.
187 * @return Indication as to whether installation has succeeded.
189 virtual GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type);
192 * Returns the window user data.
193 * @return The window user data.
195 inline virtual GHOST_TUserDataPtr getUserData() const
201 * Changes the window user data.
202 * @param data The window user data.
204 virtual void setUserData(const GHOST_TUserDataPtr userData)
206 m_userData = userData;
211 * Tries to install a rendering context in this window.
212 * @param type The type of rendering context installed.
213 * @return Indication as to whether installation has succeeded.
215 virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type) = 0;
218 * Removes the current drawing context.
219 * @return Indication as to whether removal has succeeded.
221 virtual GHOST_TSuccess removeDrawingContext() = 0;
224 * Sets the cursor visibility on the window using
225 * native window system calls.
227 virtual GHOST_TSuccess setWindowCursorVisibility(bool visible) = 0;
230 * Sets the cursor grab on the window using
231 * native window system calls.
233 virtual GHOST_TSuccess setWindowCursorGrab(bool grab) { return GHOST_kSuccess; };
236 * Sets the cursor shape on the window using
237 * native window system calls.
239 virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) = 0;
242 * Sets the cursor shape on the window using
243 * native window system calls.
245 virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2],
246 int hotX, int hotY) = 0;
248 virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
249 int szx, int szy, int hotX, int hotY, int fg, int bg) = 0;
250 /** The the of drawing context installed in this window. */
251 GHOST_TDrawingContextType m_drawingContextType;
253 /** The window user data */
254 GHOST_TUserDataPtr m_userData;
256 /** The current visibility of the cursor */
257 bool m_cursorVisible;
259 /** The current grabbed state of the cursor */
260 bool m_cursorGrabbed;
262 /** The current shape of the cursor */
263 GHOST_TStandardCursor m_cursorShape;
265 /** Stores wether this is a full screen window. */
268 /** Stereo visual created. Only necessary for 'real' stereo support,
269 * ie quad buffered stereo. This is not always possible, depends on
274 /** Full-screen width */
275 GHOST_TUns32 m_fullScreenWidth;
276 /** Full-screen height */
277 GHOST_TUns32 m_fullScreenHeight;
281 inline GHOST_TDrawingContextType GHOST_Window::getDrawingContextType()
283 return m_drawingContextType;
286 inline bool GHOST_Window::getCursorVisibility() const
288 return m_cursorVisible;
291 inline GHOST_TStandardCursor GHOST_Window::getCursorShape() const
293 return m_cursorShape;
296 #endif // _GHOST_WINDOW_H