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_WindowWin32.h
33 * Declaration of GHOST_WindowWin32 class.
36 #ifndef _GHOST_WINDOW_WIN32_H_
37 #define _GHOST_WINDOW_WIN32_H_
43 #include "GHOST_Window.h"
49 * GHOST window on M$ Windows OSs.
50 * @author Maarten Gribnau
53 class GHOST_WindowWin32 : public GHOST_Window {
57 * Creates a new window and opens it.
58 * To check if the window was created properly, use the getValid() method.
59 * @param title The text shown in the title bar of the window.
60 * @param left The coordinate of the left edge of the window.
61 * @param top The coordinate of the top edge of the window.
62 * @param width The width the window.
63 * @param height The height the window.
64 * @param state The state the window is initially opened with.
65 * @param type The type of drawing context installed in this window.
66 * @param stereoVisual Stereo visual for quad buffered stereo.
69 const STR_String& title,
74 GHOST_TWindowState state,
75 GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
76 const bool stereoVisual = false
81 * Closes the window and disposes resources allocated.
83 virtual ~GHOST_WindowWin32();
86 * Returns indication as to whether the window is valid.
87 * @return The validity of the window.
89 virtual bool getValid() const;
92 * Sets the title displayed in the title bar.
93 * @param title The title to display in the title bar.
95 virtual void setTitle(const STR_String& title);
98 * Returns the title displayed in the title bar.
99 * @param title The title displayed in the title bar.
101 virtual void getTitle(STR_String& title) const;
104 * Returns the window rectangle dimensions.
105 * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
106 * @param bounds The bounding rectangle of the window.
108 virtual void getWindowBounds(GHOST_Rect& bounds) const;
111 * Returns the client rectangle dimensions.
112 * The left and top members of the rectangle are always zero.
113 * @param bounds The bounding rectangle of the cleient area of the window.
115 virtual void getClientBounds(GHOST_Rect& bounds) const;
118 * Resizes client rectangle width.
119 * @param width The new width of the client area of the window.
121 virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width);
124 * Resizes client rectangle height.
125 * @param height The new height of the client area of the window.
127 virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height);
130 * Resizes client rectangle.
131 * @param width The new width of the client area of the window.
132 * @param height The new height of the client area of the window.
134 virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height);
137 * Returns the state of the window (normal, minimized, maximized).
138 * @return The state of the window.
140 virtual GHOST_TWindowState getState() const;
143 * Converts a point in screen coordinates to client rectangle coordinates
144 * @param inX The x-coordinate on the screen.
145 * @param inY The y-coordinate on the screen.
146 * @param outX The x-coordinate in the client rectangle.
147 * @param outY The y-coordinate in the client rectangle.
149 virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
152 * Converts a point in screen coordinates to client rectangle coordinates
153 * @param inX The x-coordinate in the client rectangle.
154 * @param inY The y-coordinate in the client rectangle.
155 * @param outX The x-coordinate on the screen.
156 * @param outY The y-coordinate on the screen.
158 virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
161 * Sets the state of the window (normal, minimized, maximized).
162 * @param state The state of the window.
163 * @return Indication of success.
165 virtual GHOST_TSuccess setState(GHOST_TWindowState state);
168 * Sets the order of the window (bottom, top).
169 * @param order The order of the window.
170 * @return Indication of success.
172 virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
175 * Swaps front and back buffers of a window.
176 * @return Indication of success.
178 virtual GHOST_TSuccess swapBuffers();
181 * Activates the drawing context of this window.
182 * @return Indication of success.
184 virtual GHOST_TSuccess activateDrawingContext();
187 * Invalidates the contents of this window.
189 virtual GHOST_TSuccess invalidate();
192 * Returns the name of the window class.
193 * @return The name of the window class.
195 static LPCSTR getWindowClassName() { return s_windowClassName; }
198 * Register a mouse click event (should be called
199 * for any real button press, controls mouse
202 * @param press True the event was a button press.
204 void registerMouseClickEvent(bool press);
207 * Inform the window that it has lost mouse capture,
208 * called in response to native window system messages.
210 void lostMouseCapture();
213 * Loads the windows equivalent of a standard GHOST cursor.
214 * @param visible Flag for cursor visibility.
215 * @param cursorShape The cursor shape.
217 void loadCursor(bool visible, GHOST_TStandardCursor cursorShape) const;
222 * Tries to install a rendering context in this window.
223 * @param type The type of rendering context installed.
224 * @return Indication of success.
226 virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
229 * Removes the current drawing context.
230 * @return Indication of success.
232 virtual GHOST_TSuccess removeDrawingContext();
235 * Sets the cursor visibility on the window using
236 * native window system calls.
238 virtual GHOST_TSuccess setWindowCursorVisibility(bool visible);
241 * Sets the cursor shape on the window using
242 * native window system calls.
244 virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape);
247 * Sets the cursor shape on the window using
248 * native window system calls.
250 virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
252 virtual setWindowCustomCursorShape(
263 /** Window handle. */
265 /** Device context handle. */
267 /** OpenGL rendering context. */
269 /** The first created OpenGL context (for sharing display lists) */
270 static HGLRC s_firsthGLRc;
271 /** Flag for if window has captured the mouse */
272 bool m_hasMouseCaptured;
273 /** Count of number of pressed buttons */
274 int m_nPressedButtons;
275 /** HCURSOR structure of the custom cursor */
276 HCURSOR m_customCursor;
278 static LPCSTR s_windowClassName;
279 static const int s_maxTitleLength;
282 #endif // _GHOST_WINDOW_WIN32_H_