|
Blender
V2.59
|
00001 /* 00002 * $Id: GHOST_Window.cpp 37765 2011-06-23 19:55:47Z blendix $ 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00020 * All rights reserved. 00021 * 00022 * The Original Code is: all of this file. 00023 * 00024 * Contributor(s): none yet. 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00040 #include "GHOST_Window.h" 00041 00042 00043 GHOST_Window::GHOST_Window( 00044 GHOST_TUns32 width, GHOST_TUns32 height, 00045 GHOST_TWindowState state, 00046 GHOST_TDrawingContextType type, 00047 const bool stereoVisual, 00048 const GHOST_TUns16 numOfAASamples) 00049 : 00050 m_drawingContextType(type), 00051 m_cursorVisible(true), 00052 m_cursorGrab(GHOST_kGrabDisable), 00053 m_cursorShape(GHOST_kStandardCursorDefault), 00054 m_stereoVisual(stereoVisual), 00055 m_numOfAASamples(numOfAASamples) 00056 { 00057 m_isUnsavedChanges = false; 00058 m_canAcceptDragOperation = false; 00059 00060 m_progressBarVisible = false; 00061 00062 m_cursorGrabAccumPos[0] = 0; 00063 m_cursorGrabAccumPos[1] = 0; 00064 00065 m_fullScreen = state == GHOST_kWindowStateFullScreen; 00066 if (m_fullScreen) { 00067 m_fullScreenWidth = width; 00068 m_fullScreenHeight = height; 00069 } 00070 } 00071 00072 00073 GHOST_Window::~GHOST_Window() 00074 { 00075 } 00076 00077 void* GHOST_Window::getOSWindow() const 00078 { 00079 return NULL; 00080 } 00081 00082 GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType type) 00083 { 00084 GHOST_TSuccess success = GHOST_kSuccess; 00085 if (type != m_drawingContextType) { 00086 success = removeDrawingContext(); 00087 if (success) { 00088 success = installDrawingContext(type); 00089 m_drawingContextType = type; 00090 } 00091 else { 00092 m_drawingContextType = GHOST_kDrawingContextTypeNone; 00093 } 00094 } 00095 return success; 00096 } 00097 00098 GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible) 00099 { 00100 if (setWindowCursorVisibility(visible)) { 00101 m_cursorVisible = visible; 00102 return GHOST_kSuccess; 00103 } 00104 else { 00105 return GHOST_kFailure; 00106 } 00107 } 00108 00109 GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_Rect *bounds) 00110 { 00111 if(m_cursorGrab == mode) 00112 return GHOST_kSuccess; 00113 00114 if (setWindowCursorGrab(mode)) { 00115 00116 if(mode==GHOST_kGrabDisable) 00117 m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; 00118 else if (bounds) { 00119 m_cursorGrabBounds= *bounds; 00120 } else { /* if bounds not defined, use window */ 00121 getClientBounds(m_cursorGrabBounds); 00122 } 00123 m_cursorGrab = mode; 00124 return GHOST_kSuccess; 00125 } 00126 else { 00127 return GHOST_kFailure; 00128 } 00129 } 00130 00131 GHOST_TSuccess GHOST_Window::getCursorGrabBounds(GHOST_Rect& bounds) 00132 { 00133 bounds= m_cursorGrabBounds; 00134 return (bounds.m_l==-1 && bounds.m_r==-1) ? GHOST_kFailure : GHOST_kSuccess; 00135 } 00136 00137 GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape) 00138 { 00139 if (setWindowCursorShape(cursorShape)) { 00140 m_cursorShape = cursorShape; 00141 return GHOST_kSuccess; 00142 } 00143 else { 00144 return GHOST_kFailure; 00145 } 00146 } 00147 00148 GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], 00149 int hotX, int hotY) 00150 { 00151 return setCustomCursorShape( (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 00152 16, 16, hotX, hotY, 0, 1 ); 00153 } 00154 00155 GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, 00156 int sizex, int sizey, int hotX, int hotY, 00157 int fg_color, int bg_color ) 00158 { 00159 if (setWindowCustomCursorShape(bitmap, mask, sizex, sizey,hotX, hotY, fg_color, bg_color)) { 00160 m_cursorShape = GHOST_kStandardCursorCustom; 00161 return GHOST_kSuccess; 00162 } 00163 else { 00164 return GHOST_kFailure; 00165 } 00166 } 00167 00168 void GHOST_Window::setAcceptDragOperation(bool canAccept) 00169 { 00170 m_canAcceptDragOperation = canAccept; 00171 } 00172 00173 bool GHOST_Window::canAcceptDragOperation() const 00174 { 00175 return m_canAcceptDragOperation; 00176 } 00177 00178 GHOST_TSuccess GHOST_Window::setModifiedState(bool isUnsavedChanges) 00179 { 00180 m_isUnsavedChanges = isUnsavedChanges; 00181 00182 return GHOST_kSuccess; 00183 } 00184 00185 bool GHOST_Window::getModifiedState() 00186 { 00187 return m_isUnsavedChanges; 00188 }