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