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 *****
30 * Copyright (C) 2001 NaN Technologies B.V.
31 * @author Maarten Gribnau
39 #include "GHOST_Window.h"
42 GHOST_Window::GHOST_Window(
43 const STR_String& /*title*/,
44 GHOST_TInt32 /*left*/, GHOST_TInt32 /*top*/, GHOST_TUns32 width, GHOST_TUns32 height,
45 GHOST_TWindowState state,
46 GHOST_TDrawingContextType type,
47 const bool stereoVisual)
49 m_drawingContextType(type),
50 m_cursorVisible(true),
51 m_cursorGrabbed(true),
52 m_cursorShape(GHOST_kStandardCursorDefault),
53 m_stereoVisual(stereoVisual)
55 m_fullScreen = state == GHOST_kWindowStateFullScreen;
57 m_fullScreenWidth = width;
58 m_fullScreenHeight = height;
63 GHOST_Window::~GHOST_Window()
68 GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType type)
70 GHOST_TSuccess success = GHOST_kSuccess;
71 if (type != m_drawingContextType) {
72 success = removeDrawingContext();
74 success = installDrawingContext(type);
75 m_drawingContextType = type;
78 m_drawingContextType = GHOST_kDrawingContextTypeNone;
84 GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible)
86 if (setWindowCursorVisibility(visible)) {
87 m_cursorVisible = visible;
88 return GHOST_kSuccess;
91 return GHOST_kFailure;
95 GHOST_TSuccess GHOST_Window::setCursorGrab(bool grab)
97 if(m_cursorGrabbed == grab)
98 return GHOST_kSuccess;
100 if (setWindowCursorGrab(grab)) {
101 m_cursorGrabbed = grab;
102 return GHOST_kSuccess;
105 return GHOST_kFailure;
109 GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape)
111 if (setWindowCursorShape(cursorShape)) {
112 m_cursorShape = cursorShape;
113 return GHOST_kSuccess;
116 return GHOST_kFailure;
120 GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2],
123 return setCustomCursorShape( (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask,
124 16, 16, hotX, hotY, 0, 1 );
127 GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
128 int sizex, int sizey, int hotX, int hotY,
129 int fg_color, int bg_color )
131 if (setWindowCustomCursorShape(bitmap, mask, sizex, sizey,hotX, hotY, fg_color, bg_color)) {
132 m_cursorShape = GHOST_kStandardCursorCustom;
133 return GHOST_kSuccess;
136 return GHOST_kFailure;