add back ghost/guardedalloc from trunk
authorJoseph Eagar <joeedh@gmail.com>
Wed, 11 May 2011 20:37:11 +0000 (20:37 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Wed, 11 May 2011 20:37:11 +0000 (20:37 +0000)
110 files changed:
intern/ghost/CMakeLists.txt [new file with mode: 0644]
intern/ghost/GHOST_C-api.h [new file with mode: 0644]
intern/ghost/GHOST_IEvent.h [new file with mode: 0644]
intern/ghost/GHOST_IEventConsumer.h [new file with mode: 0644]
intern/ghost/GHOST_ISystem.h [new file with mode: 0644]
intern/ghost/GHOST_ISystemPaths.h [new file with mode: 0644]
intern/ghost/GHOST_ITimerTask.h [new file with mode: 0644]
intern/ghost/GHOST_IWindow.h [new file with mode: 0644]
intern/ghost/GHOST_Path-api.h [new file with mode: 0644]
intern/ghost/GHOST_Rect.h [new file with mode: 0644]
intern/ghost/GHOST_Types.h [new file with mode: 0644]
intern/ghost/SConscript [new file with mode: 0644]
intern/ghost/doc/ghost_interface.cfg [new file with mode: 0644]
intern/ghost/intern/GHOST_Buttons.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_Buttons.h [new file with mode: 0644]
intern/ghost/intern/GHOST_C-api.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_CallbackEventConsumer.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_CallbackEventConsumer.h [new file with mode: 0644]
intern/ghost/intern/GHOST_Debug.h [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManager.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManager.h [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManagerCarbon.h [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManagerCocoa.h [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManagerCocoa.mm [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManagerWin32.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManagerWin32.h [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManagerX11.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_DisplayManagerX11.h [new file with mode: 0644]
intern/ghost/intern/GHOST_DropTargetWin32.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_DropTargetWin32.h [new file with mode: 0644]
intern/ghost/intern/GHOST_Event.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventButton.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventCursor.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventDragnDrop.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventKey.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventManager.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_EventManager.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventNDOF.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventPrinter.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_EventPrinter.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventString.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventTrackpad.h [new file with mode: 0644]
intern/ghost/intern/GHOST_EventWheel.h [new file with mode: 0644]
intern/ghost/intern/GHOST_ISystem.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_ISystemPaths.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_ModifierKeys.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_ModifierKeys.h [new file with mode: 0644]
intern/ghost/intern/GHOST_NDOFManager.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_NDOFManager.h [new file with mode: 0644]
intern/ghost/intern/GHOST_Path-api.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_Rect.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_System.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_System.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemCarbon.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemCarbon.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemCocoa.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemCocoa.mm [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPaths.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsCarbon.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsCarbon.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsCocoa.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsCocoa.mm [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsWin32.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsWin32.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsX11.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsX11.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemWin32.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemWin32.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemX11.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemX11.h [new file with mode: 0644]
intern/ghost/intern/GHOST_TaskbarWin32.h [new file with mode: 0644]
intern/ghost/intern/GHOST_TimerManager.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_TimerManager.h [new file with mode: 0644]
intern/ghost/intern/GHOST_TimerTask.h [new file with mode: 0644]
intern/ghost/intern/GHOST_Window.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_Window.h [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowCarbon.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowCarbon.h [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowCocoa.h [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowCocoa.mm [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowManager.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowManager.h [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowWin32.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowWin32.h [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowX11.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_WindowX11.h [new file with mode: 0644]
intern/ghost/test/gears/GHOST_C-Test.c [new file with mode: 0644]
intern/ghost/test/gears/GHOST_Test.cpp [new file with mode: 0644]
intern/ghost/test/multitest/Basic.c [new file with mode: 0644]
intern/ghost/test/multitest/Basic.h [new file with mode: 0644]
intern/ghost/test/multitest/EventToBuf.c [new file with mode: 0644]
intern/ghost/test/multitest/EventToBuf.h [new file with mode: 0644]
intern/ghost/test/multitest/GL.h [new file with mode: 0644]
intern/ghost/test/multitest/MultiTest.c [new file with mode: 0644]
intern/ghost/test/multitest/ScrollBar.c [new file with mode: 0644]
intern/ghost/test/multitest/ScrollBar.h [new file with mode: 0644]
intern/ghost/test/multitest/Util.c [new file with mode: 0644]
intern/ghost/test/multitest/Util.h [new file with mode: 0644]
intern/ghost/test/multitest/WindowData.c [new file with mode: 0644]
intern/ghost/test/multitest/WindowData.h [new file with mode: 0644]
intern/guardedalloc/CMakeLists.txt [new file with mode: 0644]
intern/guardedalloc/MEM_guardedalloc.h [new file with mode: 0644]
intern/guardedalloc/MEM_sys_types.h [new file with mode: 0644]
intern/guardedalloc/SConscript [new file with mode: 0644]
intern/guardedalloc/cpp/mallocn.cpp [new file with mode: 0644]
intern/guardedalloc/intern/mallocn.c [new file with mode: 0644]
intern/guardedalloc/intern/mmap_win.c [new file with mode: 0644]
intern/guardedalloc/mmap_win.h [new file with mode: 0644]
intern/guardedalloc/test/simpletest/memtest.c [new file with mode: 0644]

diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d42be40
--- /dev/null
@@ -0,0 +1,173 @@
+# $Id$
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2006, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+       .
+       ../string
+       ../../source/blender/imbuf
+       ../../source/blender/makesdna
+       ${GLEW_INCLUDE_PATH}
+)
+
+set(SRC
+       intern/GHOST_Buttons.cpp
+       intern/GHOST_CallbackEventConsumer.cpp
+       intern/GHOST_C-api.cpp
+       intern/GHOST_Path-api.cpp
+       intern/GHOST_DisplayManager.cpp
+       intern/GHOST_EventManager.cpp
+       intern/GHOST_EventPrinter.cpp
+       intern/GHOST_ISystem.cpp
+       intern/GHOST_ISystemPaths.cpp
+       intern/GHOST_ModifierKeys.cpp
+       intern/GHOST_NDOFManager.cpp
+       intern/GHOST_Path-api.cpp
+       intern/GHOST_Rect.cpp
+       intern/GHOST_System.cpp
+       intern/GHOST_TimerManager.cpp
+       intern/GHOST_Window.cpp
+       intern/GHOST_WindowManager.cpp
+
+       GHOST_C-api.h
+       GHOST_IEvent.h
+       GHOST_IEventConsumer.h
+       GHOST_ISystem.h
+       GHOST_ISystemPaths.h
+       GHOST_ITimerTask.h
+       GHOST_IWindow.h
+       GHOST_Path-api.h
+       GHOST_Rect.h
+       GHOST_Types.h
+       intern/GHOST_Buttons.h
+       intern/GHOST_CallbackEventConsumer.h
+       intern/GHOST_Debug.h
+       intern/GHOST_DisplayManager.h
+       intern/GHOST_Event.h
+       intern/GHOST_EventButton.h
+       intern/GHOST_EventCursor.h
+       intern/GHOST_EventDragnDrop.h
+       intern/GHOST_EventKey.h
+       intern/GHOST_EventManager.h
+       intern/GHOST_EventNDOF.h
+       intern/GHOST_EventPrinter.h
+       intern/GHOST_EventString.h
+       intern/GHOST_EventTrackpad.h
+       intern/GHOST_EventWheel.h
+       intern/GHOST_ModifierKeys.h
+       intern/GHOST_NDOFManager.h
+       intern/GHOST_System.h
+       intern/GHOST_SystemPaths.h
+       intern/GHOST_TimerManager.h
+       intern/GHOST_TimerTask.h
+       intern/GHOST_Window.h
+       intern/GHOST_WindowManager.h
+)
+
+if(APPLE)
+       if(WITH_COCOA)
+               list(APPEND SRC
+                       intern/GHOST_DisplayManagerCocoa.mm
+                       intern/GHOST_SystemCocoa.mm
+                       intern/GHOST_SystemPathsCocoa.mm
+                       intern/GHOST_WindowCocoa.mm
+                       
+                       intern/GHOST_DisplayManagerCocoa.h
+                       intern/GHOST_SystemCocoa.h
+                       intern/GHOST_SystemPathsCocoa.h
+                       intern/GHOST_WindowCocoa.h
+               )
+       else()
+               list(APPEND SRC
+                       intern/GHOST_DisplayManagerCarbon.cpp
+                       intern/GHOST_SystemCarbon.cpp
+                       intern/GHOST_SystemPathsCarbon.cpp
+                       intern/GHOST_WindowCarbon.cpp
+
+                       intern/GHOST_DisplayManagerCarbon.h
+                       intern/GHOST_SystemCarbon.h
+                       intern/GHOST_SystemPathsCarbon.h
+                       intern/GHOST_WindowCarbon.h
+               )
+       endif()
+
+       if(WITH_CODEC_QUICKTIME)
+               add_definitions(-DWITH_QUICKTIME)
+       endif()
+
+elseif(UNIX)
+
+       if(WITH_X11_XINPUT)
+               add_definitions(-DWITH_X11_XINPUT)
+       endif()
+
+       list(APPEND INC ${X11_X11_INCLUDE_PATH})
+
+       list(APPEND SRC
+               intern/GHOST_DisplayManagerX11.cpp
+               intern/GHOST_SystemX11.cpp
+               intern/GHOST_SystemPathsX11.cpp
+               intern/GHOST_WindowX11.cpp
+
+               intern/GHOST_DisplayManagerX11.h
+               intern/GHOST_SystemX11.h
+               intern/GHOST_SystemPathsX11.h
+               intern/GHOST_WindowX11.h
+       )
+
+       if(NOT WITH_INSTALL_PORTABLE)
+               add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
+       endif()
+
+       if(X11_XF86keysym_INCLUDE_PATH)
+               add_definitions(-DWITH_XF86KEYSYM)
+               list(APPEND INC ${X11_XF86keysym_INCLUDE_PATH})
+       endif()
+
+elseif(WIN32)
+       if(MSVC)
+               set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
+       endif()
+
+       list(APPEND INC ${WINTAB_INC})
+
+       list(APPEND SRC
+               intern/GHOST_DisplayManagerWin32.cpp
+               intern/GHOST_SystemWin32.cpp
+               intern/GHOST_SystemPathsWin32.cpp
+               intern/GHOST_WindowWin32.cpp
+               intern/GHOST_DropTargetWin32.cpp
+
+               intern/GHOST_DisplayManagerWin32.h
+               intern/GHOST_DropTargetWin32.h
+               intern/GHOST_SystemWin32.h
+               intern/GHOST_SystemPathsWin32.h
+               intern/GHOST_WindowWin32.h
+               intern/GHOST_TaskbarWin32.h
+       )
+endif()
+
+blender_add_lib(bf_intern_ghost "${SRC}" "${INC}")
+
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
new file mode 100644 (file)
index 0000000..7583723
--- /dev/null
@@ -0,0 +1,864 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+/** \ingroup GHOST
+ *
+ * \file       GHOST_C-api.h
+ * \brief GHOST C-API function and type declarations.
+ */
+
+#ifndef        GHOST_C_API_H
+#define GHOST_C_API_H
+
+#include "GHOST_Types.h"
+
+#ifdef __cplusplus
+extern "C" { 
+#endif
+
+/**
+ * Creates a &quot;handle&quot; for a C++ GHOST object.
+ * A handle is just an opaque pointer to an empty struct.
+ * In the API the pointer is casted to the actual C++ class.
+ * \param      name    Name of the handle to create.
+ */
+
+GHOST_DECLARE_HANDLE(GHOST_SystemHandle);
+GHOST_DECLARE_HANDLE(GHOST_TimerTaskHandle);
+GHOST_DECLARE_HANDLE(GHOST_WindowHandle);
+GHOST_DECLARE_HANDLE(GHOST_EventHandle);
+GHOST_DECLARE_HANDLE(GHOST_RectangleHandle);
+GHOST_DECLARE_HANDLE(GHOST_EventConsumerHandle);
+
+
+/**
+ * Definition of a callback routine that receives events.
+ * @param event The event received.
+ * @param userdata The callback's user data, supplied to GHOST_CreateSystem.
+ */
+typedef int (*GHOST_EventCallbackProcPtr)(GHOST_EventHandle event, GHOST_TUserDataPtr userdata);
+
+
+/**
+ * Creates the one and only system.
+ * @return a handle to the system.
+ */
+extern GHOST_SystemHandle GHOST_CreateSystem(void);
+
+/**
+ * Disposes the one and only system.
+ * @param systemhandle The handle to the system
+ * @return An indication of success.
+ */
+extern GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle);
+
+
+/**
+ * Creates an event consumer object
+ * @param eventCallback The event callback routine.
+ * @param userdata             Pointer to user data returned to the callback routine.
+ */
+extern GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback, GHOST_TUserDataPtr userdata);
+
+/**
+ * Disposes an event consumer object
+ * @param consumerhandle       Handle to the event consumer.
+ * @return An indication of success.
+ */
+extern GHOST_TSuccess GHOST_DisposeEventConsumer(GHOST_EventConsumerHandle consumerhandle);
+
+
+/**
+ * Returns the system time.
+ * Returns the number of milliseconds since the start of the system process.
+ * Based on ANSI clock() routine.
+ * @param systemhandle The handle to the system
+ * @return The number of milliseconds.
+ */
+extern GHOST_TUns64 GHOST_GetMilliSeconds(GHOST_SystemHandle systemhandle);
+
+/**
+ * Installs a timer.
+ * Note that, on most operating systems, messages need to be processed in order 
+ * for the timer callbacks to be invoked.
+ * @param systemhandle The handle to the system
+ * @param delay                The time to wait for the first call to the timerProc (in milliseconds)
+ * @param interval     The interval between calls to the timerProc (in milliseconds)
+ * @param timerProc    The callback invoked when the interval expires,
+ * @param userData     Placeholder for user data.
+ * @return A timer task (0 if timer task installation failed).
+ */
+extern GHOST_TimerTaskHandle GHOST_InstallTimer(GHOST_SystemHandle systemhandle,
+                                                                                               GHOST_TUns64 delay,
+                                                                                               GHOST_TUns64 interval,
+                                                                                               GHOST_TimerProcPtr timerProc,
+                                                                                               GHOST_TUserDataPtr userData);
+
+/**
+ * Removes a timer.
+ * @param systemhandle The handle to the system
+ * @param timerTask Timer task to be removed.
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_RemoveTimer(GHOST_SystemHandle systemhandle,
+                                                                               GHOST_TimerTaskHandle timertaskhandle);
+
+/***************************************************************************************
+ ** Display/window management functionality
+ ***************************************************************************************/
+
+/**
+ * Returns the number of displays on this system.
+ * @param systemhandle The handle to the system
+ * @return The number of displays.
+ */
+extern GHOST_TUns8 GHOST_GetNumDisplays(GHOST_SystemHandle systemhandle);
+
+/**
+ * Returns the dimensions of the main display on this system.
+ * @param systemhandle The handle to the system
+ * @param width                A pointer the width gets put in
+ * @param height       A pointer the height gets put in
+ * @return void.
+ */
+extern void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
+                                                                                  GHOST_TUns32* width,
+                                                                                  GHOST_TUns32* height);
+
+/**
+ * Create a new window.
+ * The new window is added to the list of windows managed. 
+ * Never explicitly delete the window, use disposeWindow() instead.
+ * @param systemhandle The handle to the system
+ * @param      title   The name of the window (displayed in the title bar of the window if the OS supports it).
+ * @param      left    The coordinate of the left edge of the window.
+ * @param      top             The coordinate of the top edge of the window.
+ * @param      width   The width the window.
+ * @param      height  The height the window.
+ * @param      state   The state of the window when opened.
+ * @param      type    The type of drawing context installed in this window.
+ * @param stereoVisual         Stereo visual for quad buffered stereo.
+ * @param numOfAASamples       Number of samples used for AA (zero if no AA)
+ * @return     A handle to the new window ( == NULL if creation failed).
+ */
+extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
+       const char* title,
+       GHOST_TInt32 left,
+       GHOST_TInt32 top,
+       GHOST_TUns32 width,
+       GHOST_TUns32 height,
+       GHOST_TWindowState state,
+       GHOST_TDrawingContextType type,
+       const int stereoVisual,
+       const GHOST_TUns16 numOfAASamples);
+
+/**
+ * Returns the window user data.
+ * @param windowhandle The handle to the window
+ * @return The window user data.
+ */
+extern GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle);
+       
+/**
+ * Changes the window user data.
+ * @param windowhandle The handle to the window
+ * @param data The window user data.
+ */
+extern void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle, 
+       GHOST_TUserDataPtr userdata);
+
+/**
+ * Dispose a window.
+ * @param systemhandle The handle to the system
+ * @param      window Handle to the window to be disposed.
+ * @return     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle,
+                                                                                 GHOST_WindowHandle windowhandle);
+
+/**
+ * Returns whether a window is valid.
+ * @param systemhandle The handle to the system
+ * @param      window Handle to the window to be checked.
+ * @return     Indication of validity.
+ */
+extern int GHOST_ValidWindow(GHOST_SystemHandle systemhandle,
+                                                                               GHOST_WindowHandle windowhandle);
+
+/**
+ * Begins full screen mode.
+ * @param systemhandle The handle to the system
+ * @param setting      The new setting of the display.
+ * @return                     A handle to the window displayed in full screen.
+ *                                     This window is invalid after full screen has been ended.
+ */
+extern GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
+       GHOST_DisplaySetting* setting,
+       const int stereoVisual);
+
+/**
+ * Ends full screen mode.
+ * @param systemhandle The handle to the system
+ * @return     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle);
+
+/**
+ * Returns current full screen mode status.
+ * @param systemhandle The handle to the system
+ * @return The current status.
+ */
+extern int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle);
+
+/***************************************************************************************
+ ** Event management functionality
+ ***************************************************************************************/
+
+/**
+ * Retrieves events from the system and stores them in the queue.
+ * @param systemhandle The handle to the system
+ * @param waitForEvent Boolean to indicate that ProcessEvents should
+ * wait (block) until the next event before returning.
+ * @return Indication of the presence of events.
+ */
+extern int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent);
+
+/**
+ * Retrieves events from the queue and send them to the event consumers.
+ * @param systemhandle The handle to the system
+ * @return Indication of the presence of events.
+ */
+extern int GHOST_DispatchEvents(GHOST_SystemHandle systemhandle);
+
+/**
+ * Adds the given event consumer to our list.
+ * @param systemhandle The handle to the system
+ * @param consumerhandle The event consumer to add.
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle,
+                                                                                         GHOST_EventConsumerHandle consumerhandle);
+
+/**
+ * Remove the given event consumer to our list.
+ * @param systemhandle The handle to the system
+ * @param consumerhandle The event consumer to remove.
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle,
+                                                                                         GHOST_EventConsumerHandle consumerhandle);
+
+/***************************************************************************************
+ ** Progress bar functionality
+ ***************************************************************************************/
+
+/**
+ * Sets the progress bar value displayed in the window/application icon
+ * @param windowhandle The handle to the window
+ * @param progress The progress % (0.0 to 1.0)
+ */
+extern GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle, float progress);
+
+/**
+ * Hides the progress bar in the icon
+ * @param windowhandle The handle to the window
+ */
+extern GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle);
+       
+       
+/***************************************************************************************
+ ** N-degree of freedom device management functionality
+ ***************************************************************************************/
+/**
+* Open N-degree of freedom devices
+ */
+extern int GHOST_OpenNDOF(GHOST_SystemHandle systemhandle, 
+                           GHOST_WindowHandle windowhandle,
+                          GHOST_NDOFLibraryInit_fp setNdofLibraryInit, 
+                          GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+                          GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen
+                          );
+
+/***************************************************************************************
+ ** Cursor management functionality
+ ***************************************************************************************/
+
+/**
+ * Returns the current cursor shape.
+ * @param windowhandle The handle to the window
+ * @return     The current cursor shape.
+ */
+extern GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle);
+
+/**
+ * Set the shape of the cursor.
+ * @param windowhandle The handle to the window
+ * @param      cursor  The new cursor shape type id.
+ * @return     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
+                                                                                  GHOST_TStandardCursor cursorshape);
+
+/**
+ * Set the shape of the cursor to a custom cursor.
+ * @param windowhandle The handle to the window
+ * @param      bitmap  The bitmap data for the cursor.
+ * @param      mask    The mask data for the cursor.
+ * @param      hotX    The X coordinate of the cursor hotspot.
+ * @param      hotY    The Y coordinate of the cursor hotspot.
+ * @return     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
+                                                                                                GHOST_TUns8 bitmap[16][2], 
+                                                                                                GHOST_TUns8 mask[16][2], 
+                                                                                                int hotX, 
+                                                                                                int hotY);
+/**
+ * Set the shape of the cursor to a custom cursor of specified size.
+ * @param windowhandle The handle to the window
+ * @param      bitmap  The bitmap data for the cursor.
+ * @param      mask    The mask data for the cursor.
+ * @parm    sizex, sizey  The size of the cursor
+ * @param      hotX    The X coordinate of the cursor hotspot.
+ * @param      hotY    The Y coordinate of the cursor hotspot.
+ * @param   fg_color, bg_color  Colors of the cursor
+ * @return     Indication of success.
+  */
+extern GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
+                                                                                                GHOST_TUns8 *bitmap, 
+                                                                                                GHOST_TUns8 *mask, 
+                                                                                                int sizex, int sizey, 
+                                                                                                int hotX,  int hotY,
+                                                                                                int fg_color, int bg_color );
+
+/**
+ * Returns the visibility state of the cursor.
+ * @param windowhandle The handle to the window
+ * @return     The visibility state of the cursor.
+ */
+extern int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle);
+
+/**
+ * Shows or hides the cursor.
+ * @param windowhandle The handle to the window
+ * @param      visible The new visibility state of the cursor.
+ * @return     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle,
+                                                                                               int visible);
+
+/**
+ * Returns the current location of the cursor (location in screen coordinates)
+ * @param systemhandle The handle to the system
+ * @param x                    The x-coordinate of the cursor.
+ * @param y                    The y-coordinate of the cursor.
+ * @return                     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
+                                                                                         GHOST_TInt32* x,
+                                                                                         GHOST_TInt32* y);
+
+/**
+ * Updates the location of the cursor (location in screen coordinates).
+ * Not all operating systems allow the cursor to be moved (without the input device being moved).
+ * @param systemhandle The handle to the system
+ * @param x                    The x-coordinate of the cursor.
+ * @param y                    The y-coordinate of the cursor.
+ * @return                     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
+                                                                                         GHOST_TInt32 x,
+                                                                                         GHOST_TInt32 y);
+
+/**
+ * Grabs the cursor for a modal operation, to keep receiving
+ * events when the mouse is outside the window. X11 only, others
+ * do this automatically.
+ * @param windowhandle The handle to the window
+ * @param      mode The new grab state of the cursor.
+ * @param      bounds The grab ragion (optional) - left,top,right,bottom
+ * @return     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
+                                                                                               GHOST_TGrabCursorMode mode,
+                                                                                               int* bounds);
+
+/***************************************************************************************
+ ** Access to mouse button and keyboard states.
+ ***************************************************************************************/
+
+/**
+ * Returns the state of a modifier key (ouside the message queue).
+ * @param systemhandle The handle to the system
+ * @param mask         The modifier key state to retrieve.
+ * @param isDown       Pointer to return modifier state in.
+ * @return                     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
+                                                                                               GHOST_TModifierKeyMask mask,
+                                                                                               int* isDown);
+
+/**
+ * Returns the state of a mouse button (ouside the message queue).
+ * @param systemhandle The handle to the system
+ * @param mask         The button state to retrieve.
+ * @param isDown       Pointer to return button state in.
+ * @return                     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
+                                                                                  GHOST_TButtonMask mask,
+                                                                                  int* isDown);
+
+
+/***************************************************************************************
+ ** Drag'n'drop operations
+ ***************************************************************************************/
+
+/**
+ * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
+ */
+extern void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept);
+       
+       
+/**
+ * Returns the event type.
+ * @param eventhandle The handle to the event
+ * @return The event type.
+ */
+extern GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle);
+
+/**
+ * Returns the time this event was generated.
+ * @param eventhandle The handle to the event
+ * @return The event generation time.
+ */
+extern GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle);
+
+/**
+ * Returns the window this event was generated on, 
+ * or NULL if it is a 'system' event.
+ * @param eventhandle The handle to the event
+ * @return The generating window.
+ */
+extern GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle);
+
+/**
+ * Returns the event data.
+ * @param eventhandle The handle to the event
+ * @return The event data.
+ */
+extern GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle);
+
+/**
+ * Returns the timer callback.
+ * @param timertaskhandle      The handle to the timertask
+ * @return The timer callback.
+ */
+extern GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle);
+
+/**
+ * Changes the timer callback.
+ * @param timertaskhandle The handle to the timertask
+ * @param timerProc The timer callback.
+ */
+extern void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
+                                                          GHOST_TimerProcPtr timerProc);
+
+/**
+ * Returns the timer user data.
+ * @param timertaskhandle      The handle to the timertask
+ * @return The timer user data.
+ */
+extern GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle);
+       
+/**
+ * Changes the time user data.
+ * @param timertaskhandle      The handle to the timertask
+ * @param data The timer user data.
+ */
+extern void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
+                                                                          GHOST_TUserDataPtr userData);
+
+/**
+ * Returns indication as to whether the window is valid.
+ * @param windowhandle The handle to the window
+ * @return The validity of the window.
+ */
+extern int GHOST_GetValid(GHOST_WindowHandle windowhandle) ;
+
+/**
+ * Returns the type of drawing context used in this window.
+ * @param windowhandle The handle to the window
+ * @return The current type of drawing context.
+ */
+extern GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle);
+
+/**
+ * Tries to install a rendering context in this window.
+ * @param windowhandle The handle to the window
+ * @param type The type of rendering context installed.
+ * @return Indication as to whether installation has succeeded.
+ */
+extern GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle,
+                                                                                                 GHOST_TDrawingContextType type);
+
+/**
+ * Sets the title displayed in the title bar.
+ * @param windowhandle The handle to the window
+ * @param title        The title to display in the title bar.
+ */
+extern void GHOST_SetTitle(GHOST_WindowHandle windowhandle,
+                                                  const char* title);
+
+/**
+ * Returns the title displayed in the title bar. The title
+ * should be free'd with free().
+ * 
+ * @param windowhandle The handle to the window
+ * @return The title, free with free().
+ */
+extern char* GHOST_GetTitle(GHOST_WindowHandle windowhandle);
+
+/**
+ * Returns the window rectangle dimensions.
+ * These are screen coordinates.
+ * @param windowhandle The handle to the window
+ * @return A handle to the bounding rectangle of the window.
+ */
+extern GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle);
+
+/**
+ * Returns the client rectangle dimensions.
+ * The left and top members of the rectangle are always zero.
+ * @param windowhandle The handle to the window
+ * @return A handle to the bounding rectangle of the window.
+ */
+extern GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle);
+
+/**
+ * Disposes a rectangle object
+ * @param rectanglehandle      Handle to the rectangle.
+ */
+void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle);
+
+/**
+ * Resizes client rectangle width.
+ * @param windowhandle The handle to the window
+ * @param width The new width of the client area of the window.
+ * @return     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle,
+                                                                                  GHOST_TUns32 width);
+
+/**
+ * Resizes client rectangle height.
+ * @param windowhandle The handle to the window
+ * @param height The new height of the client area of the window.
+ * @return     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle,
+                                                                                       GHOST_TUns32 height);
+
+/**
+ * Resizes client rectangle.
+ * @param windowhandle The handle to the window
+ * @param width                The new width of the client area of the window.
+ * @param height       The new height of the client area of the window.
+ * @return                     Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle,
+                                                                                 GHOST_TUns32 width,
+                                                                                 GHOST_TUns32 height);
+
+/**
+ * Converts a point in screen coordinates to client rectangle coordinates
+ * @param windowhandle The handle to the window
+ * @param inX  The x-coordinate on the screen.
+ * @param inY  The y-coordinate on the screen.
+ * @param outX The x-coordinate in the client rectangle.
+ * @param outY The y-coordinate in the client rectangle.
+ */
+extern void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle,
+                                                                GHOST_TInt32 inX,
+                                                                GHOST_TInt32 inY,
+                                                                GHOST_TInt32* outX,
+                                                                GHOST_TInt32* outY) ;
+
+/**
+ * Converts a point in screen coordinates to client rectangle coordinates
+ * @param windowhandle The handle to the window
+ * @param inX  The x-coordinate in the client rectangle.
+ * @param inY  The y-coordinate in the client rectangle.
+ * @param outX The x-coordinate on the screen.
+ * @param outY The y-coordinate on the screen.
+ */
+extern void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle,
+                                                                GHOST_TInt32 inX,
+                                                                GHOST_TInt32 inY,
+                                                                GHOST_TInt32* outX,
+                                                                GHOST_TInt32* outY);
+
+/**
+ * Returns the state of the window (normal, minimized, maximized).
+ * @param windowhandle The handle to the window
+ * @return The state of the window.
+ */
+extern GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle);
+
+/**
+ * Sets the state of the window (normal, minimized, maximized).
+ * @param windowhandle The handle to the window
+ * @param state The state of the window.
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
+                                                                                  GHOST_TWindowState state);
+
+       
+/**
+ * Sets the window "modified" status, indicating unsaved changes
+ * @param windowhandle The handle to the window
+ * @param isUnsavedChanges Unsaved changes or not
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle,
+                                                                                                  GHOST_TUns8 isUnsavedChanges);
+       
+/**
+ * Sets the order of the window (bottom, top).
+ * @param windowhandle The handle to the window
+ * @param order The order of the window.
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
+                                                                                  GHOST_TWindowOrder order);
+
+/**
+ * Swaps front and back buffers of a window.
+ * @param windowhandle The handle to the window
+ * @return     An intean success indicator.
+ */
+extern GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle);
+
+/**
+ * Activates the drawing context of this window.
+ * @param windowhandle The handle to the window
+ * @return     An intean success indicator.
+ */
+extern GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle);
+
+/**
+ * Invalidates the contents of this window.
+ * @param windowhandle The handle to the window
+ * @return Indication of success.
+ */
+extern GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle);
+
+/**
+ * Returns the status of the tablet
+ * @param windowhandle The handle to the window
+ * @return Status of tablet
+ */
+extern const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle);
+
+/**
+ * Access to rectangle width.
+ * @param rectanglehandle The handle to the rectangle
+ * @return     width of the rectangle
+ */
+extern GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle);
+
+/**
+ * Access to rectangle height.
+ * @param rectanglehandle The handle to the rectangle
+ * @return     height of the rectangle
+ */
+extern GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle);
+
+/**
+ * Gets all members of the rectangle.
+ * @param rectanglehandle The handle to the rectangle
+ * @param      l       Pointer to return left coordinate in.
+ * @param      t       Pointer to return top coordinate in.
+ * @param      r       Pointer to return right coordinate in.
+ * @param      b       Pointer to return bottom coordinate in.
+ */
+extern void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                          GHOST_TInt32* l,
+                                                          GHOST_TInt32* t,
+                                                          GHOST_TInt32* r,
+                                                          GHOST_TInt32* b);
+
+/**
+ * Sets all members of the rectangle.
+ * @param rectanglehandle The handle to the rectangle
+ * @param      l       requested left coordinate of the rectangle
+ * @param      t       requested top coordinate of the rectangle
+ * @param      r       requested right coordinate of the rectangle
+ * @param      b       requested bottom coordinate of the rectangle
+ */
+extern void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                          GHOST_TInt32 l,
+                                                          GHOST_TInt32 t,
+                                                          GHOST_TInt32 r,
+                                                          GHOST_TInt32 b);
+
+/**
+ * Returns whether this rectangle is empty.
+ * Empty rectangles are rectangles that have width==0 and/or height==0.
+ * @param rectanglehandle The handle to the rectangle
+ * @return     intean value (true == empty rectangle)
+ */
+extern GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle);
+
+/**
+ * Returns whether this rectangle is valid.
+ * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, emapty rectangles are valid.
+ * @param rectanglehandle The handle to the rectangle
+ * @return     intean value (true==valid rectangle)
+ */
+extern GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle);
+
+/**
+ * Grows (or shrinks the rectangle).
+ * The method avoids negative insets making the rectangle invalid
+ * @param rectanglehandle The handle to the rectangle
+ * @param      i       The amount of offset given to each extreme (negative values shrink the rectangle).
+ */
+extern void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                                GHOST_TInt32 i);
+
+/**
+ * Does a union of the rectangle given and this rectangle.
+ * The result is stored in this rectangle.
+ * @param rectanglehandle The handle to the rectangle
+ * @param      r       The rectangle that is input for the union operation.
+ */
+extern void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                                GHOST_RectangleHandle anotherrectanglehandle);
+
+/**
+ * Grows the rectangle to included a point.
+ * @param rectanglehandle The handle to the rectangle
+ * @param      x       The x-coordinate of the point.
+ * @param      y       The y-coordinate of the point.
+ */
+extern void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                                         GHOST_TInt32 x,
+                                                                         GHOST_TInt32 y);
+
+/**
+ * Returns whether the point is inside this rectangle.
+ * Point on the boundary is considered inside.
+ * @param rectanglehandle The handle to the rectangle
+ * @param x    x-coordinate of point to test.
+ * @param y y-coordinate of point to test.
+ * @return intean value (true if point is inside).
+ */
+extern GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                                                         GHOST_TInt32 x,
+                                                                                         GHOST_TInt32 y);
+
+/**
+ * Returns whether the rectangle is inside this rectangle.
+ * @param rectanglehandle The handle to the rectangle
+ * @param      r       rectangle to test.
+ * @return     visibility (not, partially or fully visible).
+ */
+extern GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle,
+                                                                                                         GHOST_RectangleHandle anotherrectanglehandle);
+
+/**
+ * Sets rectangle members.
+ * Sets rectangle members such that it is centered at the given location.
+ * @param rectanglehandle The handle to the rectangle
+ * @param      cx      requested center x-coordinate of the rectangle
+ * @param      cy      requested center y-coordinate of the rectangle
+ */
+extern void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                                        GHOST_TInt32 cx,
+                                                                        GHOST_TInt32 cy);
+
+/**
+ * Sets rectangle members.
+ * Sets rectangle members such that it is centered at the given location,
+ * with the width requested.
+ * @param rectanglehandle The handle to the rectangle
+ * @param      cx      requested center x-coordinate of the rectangle
+ * @param      cy      requested center y-coordinate of the rectangle
+ * @param      w       requested width of the rectangle
+ * @param      h       requested height of the rectangle
+ */
+extern void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
+                                                                        GHOST_TInt32 cx,
+                                                                        GHOST_TInt32 cy,
+                                                                        GHOST_TInt32 w,
+                                                                        GHOST_TInt32 h);
+
+/**
+ * Clips a rectangle.
+ * Updates the rectangle given such that it will fit within this one.
+ * This can result in an empty rectangle.
+ * @param rectanglehandle The handle to the rectangle
+ * @param      r       the rectangle to clip
+ * @return     whether clipping has occurred
+ */
+extern GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                                                 GHOST_RectangleHandle anotherrectanglehandle);
+
+/**
+ * Return the data from the clipboad
+ * @param      return the selection instead, X11 only feature
+ * @return     clipboard data
+ */
+extern GHOST_TUns8* GHOST_getClipboard(int selection);
+
+/**
+ * Put data to the Clipboard
+ * @param      set the selection instead, X11 only feature
+ */
+extern void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection);
+
+
+
+/**
+ * Toggles console
+ * @action     0 - Hides
+ *                     1 - Shows
+ *                     2 - Toggles
+ *                     3 - Hides if it runs not from  command line
+ *                     * - Does nothing
+ * @return current status (1 -visible, 0 - hidden)
+ */
+extern int GHOST_toggleConsole(int action);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/intern/ghost/GHOST_IEvent.h b/intern/ghost/GHOST_IEvent.h
new file mode 100644 (file)
index 0000000..bb13179
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/GHOST_IEvent.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_IEvent interface class.
+ */
+
+#ifndef _GHOST_IEVENT_H_
+#define _GHOST_IEVENT_H_
+
+#include <stddef.h>
+#include "GHOST_Types.h"
+
+class GHOST_IWindow;
+
+/**
+ * Interface class for events received from GHOST.
+ * You should not need to inherit this class. The system will pass these events
+ * to the GHOST_IEventConsumer::processEvent() method of event consumers.<br>
+ * Use the getType() method to retrieve the type of event and the getData() 
+ * method to get the event data out. Using the event type you can cast the 
+ * event data to the correct event dat structure.
+ * @see GHOST_IEventConsumer#processEvent
+ * @see GHOST_TEventType
+ * @author     Maarten Gribnau
+ * @date       May 31, 2001
+ */
+class GHOST_IEvent
+{
+public:
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_IEvent()
+       {
+       }
+
+       /**
+        * Returns the event type.
+        * @return The event type.
+        */
+       virtual GHOST_TEventType getType() = 0;
+
+       /**
+        * Returns the time this event was generated.
+        * @return The event generation time.
+        */
+       virtual GHOST_TUns64 getTime() = 0;
+
+       /**
+        * Returns the window this event was generated on, 
+        * or NULL if it is a 'system' event.
+        * @return The generating window.
+        */
+       virtual GHOST_IWindow* getWindow() = 0;
+       
+       /**
+        * Returns the event data.
+        * @return The event data.
+        */
+       virtual GHOST_TEventDataPtr getData() = 0;
+       
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+       void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_IEvent"); }
+       void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
+};
+
+#endif // _GHOST_IEVENT_H_
+
diff --git a/intern/ghost/GHOST_IEventConsumer.h b/intern/ghost/GHOST_IEventConsumer.h
new file mode 100644 (file)
index 0000000..246ba8a
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/GHOST_IEventConsumer.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_IEventConsumer interface class.
+ */
+
+#ifndef _GHOST_IEVENT_CONSUMER_H_
+#define _GHOST_IEVENT_CONSUMER_H_
+
+#include "GHOST_IEvent.h"
+
+/**
+ * Interface class for objects interested in receiving events.
+ * Objects interested in events should inherit this class and implement the
+ * processEvent() method. They should then be registered with the system that
+ * they want to receive events. The system will call the processEvent() method
+ * for every installed event consumer to pass events.
+ * @see GHOST_ISystem#addEventConsumer
+ * @author     Maarten Gribnau
+ * @date       May 14, 2001
+ */
+class GHOST_IEventConsumer
+{
+public:
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_IEventConsumer()
+       {
+       }
+
+       /**
+        * This method is called by the system when it has events to dispatch.
+        * @see GHOST_ISystem#dispatchEvents
+        * @param       event   The event that can be handled or ignored.
+        * @return      Indication as to whether the event was handled.
+        */
+       virtual bool processEvent(GHOST_IEvent* event) = 0;
+       
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+       void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_IEventConsumer"); }
+       void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
+};
+
+#endif // _GHOST_EVENT_CONSUMER_H_
+
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
new file mode 100644 (file)
index 0000000..69e1007
--- /dev/null
@@ -0,0 +1,410 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/GHOST_ISystem.h
+ *  \ingroup GHOST
+ * %Main interface file for C++ Api with declaration of GHOST_ISystem interface
+ * class.
+ * Contains the doxygen documentation main page.
+ */
+
+#ifndef _GHOST_ISYSTEM_H_
+#define _GHOST_ISYSTEM_H_
+
+#include "GHOST_Types.h"
+#include "GHOST_ITimerTask.h"
+#include "GHOST_IWindow.h"
+
+class GHOST_IEventConsumer;
+
+/**
+ * \page GHOSTPage GHOST
+ *
+ * \section intro Introduction
+ *
+ * GHOST is yet another acronym. It stands for "Generic Handy Operating System
+ * Toolkit". It has been created to replace the OpenGL utility tool kit  
+ * <a href="http://www.opengl.org/developers/documentation/glut.html">GLUT</a>.
+ * GLUT was used in <a href="http://www.blender3d.com">Blender</a> until the
+ * point that Blender needed to be ported to Apple's Mac OSX. Blender needed a
+ * number of modifications in GLUT to work but the GLUT sources for OSX were
+ * unavailable at the time. The decision was made to build our own replacement
+ * for GLUT. In those days, NaN Technologies BV was the company that developed 
+ * Blender. 
+ * <br><br>
+ * Enough history. What does GHOST have to offer?<br>
+ * In short: everything that Blender needed from GLUT to run on all it's supported
+ * operating systems and some extra's.
+ * This includes :
+ * <ul>
+ * <li> Time(r) management.</li>
+ * <li> Display/window management (windows are only created on the main display).
+ * <li> Event management.</li>
+ * <li> Cursor shape management (no custom cursors for now).</li>
+ * <li> Access to the state of the mouse buttons and the keyboard.</li>
+ * <li> Menus for windows with events generated when they are accessed (this is
+ *     work in progress).</li>
+ * </ul>
+ * Font management has been moved to a separate library.
+ *
+ * \section platforms Platforms
+ *
+ * \section Building GHOST
+ *
+ * \section interface Interface
+ * GHOST has two programming interfaces:
+ * <ul>
+ * <li>The C-API. For programs written in C.</li>
+ * <li>The C++-API. For programs written in C++.</li>
+ * </ul>
+ * GHOST itself is writtem in C++ and the C-API is a wrapper around the C++ 
+ * API.
+ *
+ * \subsection cplusplus_api The C++ API consists of the following files:
+ * <ul>
+ * <li>GHOST_IEvent.h</li>
+ * <li>GHOST_IEventConsumer.h</li>
+ * <li>GHOST_ISystem.h</li>
+ * <li>GHOST_ITimerTask.h</li>
+ * <li>GHOST_IWindow.h</li>
+ * <li>GHOST_Rect.h</li>
+ * <li>GHOST_Types.h</li>
+ * </ul>
+ * For an example of using the C++-API, have a look at the GHOST_C-Test.cpp
+ * program in the ?/ghost/test/gears/ directory.
+ *
+ * \subsection c_api The C-API
+ * To use GHOST in programs written in C, include the file GHOST_C-API.h in 
+ * your program. This file includes the GHOST_Types.h file for all GHOST types
+ * and defines functions that give you access to the same functionality present
+ * in the C++ API.<br>
+ * For an example of using the C-API, have a look at the GHOST_C-Test.c program
+ * in the ?/ghost/test/gears/ directory.
+ *
+ * \section work Work in progress
+ * \todo write WIP section
+ */
+/** \interface GHOST_ISystem
+ * Interface for classes that provide access to the operating system.
+ * There should be only one system class in an application.
+ * Therefore, the routines to create and dispose the system are static.
+ * Provides:
+ *     -# Time(r) management.
+ *     -# Display/window management (windows are only created on the main display).
+ *     -# Event management.
+ *     -# Cursor shape management (no custom cursors for now).
+ *     -# Access to the state of the mouse buttons and the keyboard.
+ *     -# Menus for windows with events generated when they are accessed (this is
+ *     work in progress).
+ * @author     Maarten Gribnau
+ * @date       May 30, 2001
+ */
+class GHOST_ISystem
+{
+public:
+       /**
+        * Creates the one and only system.
+        * @return An indication of success.
+        */
+       static GHOST_TSuccess createSystem();
+
+       /**
+        * Disposes the one and only system.
+        * @return An indication of success.
+        */
+       static GHOST_TSuccess disposeSystem();
+
+       /**
+        * Returns a pointer to the one and only system (nil if it hasn't been created).
+        * @return A pointer to the system.
+        */
+       static GHOST_ISystem* getSystem();
+
+protected:
+       /**
+        * Constructor.
+        * Protected default constructor to force use of static createSystem member.
+        */
+       GHOST_ISystem() {}
+
+       /**
+        * Destructor.
+        * Protected default constructor to force use of static dispose member.
+        */
+       virtual ~GHOST_ISystem() {}
+
+public:
+       /***************************************************************************************
+        ** Time(r) functionality
+        ***************************************************************************************/
+
+       /**
+        * Returns the system time.
+        * Returns the number of milliseconds since the start of the system process.
+        * Based on ANSI clock() routine.
+        * @return The number of milliseconds.
+        */
+       virtual GHOST_TUns64 getMilliSeconds() const = 0;
+
+       /**
+        * Installs a timer.
+        * Note that, on most operating systems, messages need to be processed in order 
+        * for the timer callbacks to be invoked.
+        * @param delay         The time to wait for the first call to the timerProc (in milliseconds)
+        * @param interval      The interval between calls to the timerProc (in milliseconds)
+        * @param timerProc     The callback invoked when the interval expires,
+        * @param userData      Placeholder for user data.
+        * @return A timer task (0 if timer task installation failed).
+        */
+       virtual GHOST_ITimerTask* installTimer(GHOST_TUns64 delay, GHOST_TUns64 interval, GHOST_TimerProcPtr timerProc, GHOST_TUserDataPtr userData = 0) = 0;
+
+       /**
+        * Removes a timer.
+        * @param timerTask Timer task to be removed.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess removeTimer(GHOST_ITimerTask* timerTask) = 0;
+
+       /***************************************************************************************
+        ** Display/window management functionality
+        ***************************************************************************************/
+
+       /**
+        * Returns the number of displays on this system.
+        * @return The number of displays.
+        */
+       virtual GHOST_TUns8 getNumDisplays() const = 0;
+
+       /**
+        * Returns the dimensions of the main display on this system.
+        * @return The dimension of the main display.
+        */
+       virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const = 0;
+       
+       /**
+        * Create a new window.
+        * The new window is added to the list of windows managed. 
+        * Never explicitly delete the window, use disposeWindow() instead.
+        * @param       title                   The name of the window (displayed in the title bar of the window if the OS supports it).
+        * @param       left                    The coordinate of the left edge of the window.
+        * @param       top                             The coordinate of the top edge of the window.
+        * @param       width                   The width the window.
+        * @param       height                  The height the window.
+        * @param       state                   The state of the window when opened.
+        * @param       type                    The type of drawing context installed in this window.
+        * @param       stereoVisual    Create a stereo visual for quad buffered stereo.
+        * @param       numOfAASamples  Number of samples used for AA (zero if no AA)
+        * @param       parentWindow    Parent (embedder) window
+        * @return      The new window (or 0 if creation failed).
+        */
+       virtual GHOST_IWindow* createWindow(
+               const STR_String& title,
+               GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
+               GHOST_TWindowState state, GHOST_TDrawingContextType type,
+               const bool stereoVisual = false,
+               const GHOST_TUns16 numOfAASamples = 0,
+               const GHOST_TEmbedderWindowID parentWindow = 0) = 0;
+
+       /**
+        * Dispose a window.
+        * @param       window Pointer to the window to be disposed.
+        * @return      Indication of success.
+        */
+       virtual GHOST_TSuccess disposeWindow(GHOST_IWindow* window) = 0;
+
+       /**
+        * Returns whether a window is valid.
+        * @param       window Pointer to the window to be checked.
+        * @return      Indication of validity.
+        */
+       virtual bool validWindow(GHOST_IWindow* window) = 0;
+
+       /**
+        * Begins full screen mode.
+        * @param setting       The new setting of the display.
+        * @param window        Window displayed in full screen.
+        *                                      This window is invalid after full screen has been ended.
+        * @return      Indication of success.
+        */
+       virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
+               const bool stereoVisual) = 0;
+
+       /**
+        * Ends full screen mode.
+        * @return      Indication of success.
+        */
+       virtual GHOST_TSuccess endFullScreen(void) = 0;
+
+       /**
+        * Returns current full screen mode status.
+        * @return The current status.
+        */
+       virtual bool getFullScreen(void) = 0;
+
+       /***************************************************************************************
+        ** Event management functionality
+        ***************************************************************************************/
+
+       /**
+        * Retrieves events from the system and stores them in the queue.
+        * @param waitForEvent Flag to wait for an event (or return immediately).
+        * @return Indication of the presence of events.
+        */
+       virtual bool processEvents(bool waitForEvent) = 0;
+       
+       /**
+        * Retrieves events from the queue and send them to the event consumers.
+        * @return Indication of the presence of events.
+        */
+       virtual bool dispatchEvents() = 0;
+
+       /**
+        * Adds the given event consumer to our list.
+        * @param consumer The event consumer to add.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer) = 0;
+
+       /**
+        * Removes the given event consumer to our list.
+        * @param consumer The event consumer to remove.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess removeEventConsumer(GHOST_IEventConsumer* consumer) = 0;
+
+        /***************************************************************************************
+        ** N-degree of freedom device management functionality
+        ***************************************************************************************/
+
+   /**
+    * Starts the N-degree of freedom device manager
+    */
+   virtual int openNDOF(GHOST_IWindow*,
+       GHOST_NDOFLibraryInit_fp setNdofLibraryInit, 
+       GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+       GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen
+       // original patch only
+      // GHOST_NDOFEventHandler_fp setNdofEventHandler
+       ) = 0;
+
+
+       /***************************************************************************************
+        ** Cursor management functionality
+        ***************************************************************************************/
+
+       /**
+        * Returns the current location of the cursor (location in screen coordinates)
+        * @param x                     The x-coordinate of the cursor.
+        * @param y                     The y-coordinate of the cursor.
+        * @return                      Indication of success.
+        */
+       virtual GHOST_TSuccess getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const = 0;
+
+       /**
+        * Updates the location of the cursor (location in screen coordinates).
+        * Not all operating systems allow the cursor to be moved (without the input device being moved).
+        * @param x                     The x-coordinate of the cursor.
+        * @param y                     The y-coordinate of the cursor.
+        * @return                      Indication of success.
+        */
+       virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) = 0;
+
+       /***************************************************************************************
+        ** Access to mouse button and keyboard states.
+        ***************************************************************************************/
+
+       /**
+        * Returns the state of a modifier key (ouside the message queue).
+        * @param mask          The modifier key state to retrieve.
+        * @param isDown        The state of a modifier key (true == pressed).
+        * @return                      Indication of success.
+        */
+       virtual GHOST_TSuccess getModifierKeyState(GHOST_TModifierKeyMask mask, bool& isDown) const = 0;
+
+       /**
+        * Returns the state of a mouse button (ouside the message queue).
+        * @param mask          The button state to retrieve.
+        * @param isDown        Button state.
+        * @return                      Indication of success.
+        */
+       virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const = 0;
+
+       /**
+        * Toggles console
+        * @action      0 - Hides
+        *                      1 - Shows
+        *                      2 - Toggles
+        *                      3 - Hides if it runs not from  command line
+        *                      * - Does nothing
+        * @return current status (1 -visible, 0 - hidden)
+        */
+       virtual int toggleConsole(int action) = 0;
+       
+       /***************************************************************************************
+        ** Access to clipboard.
+        ***************************************************************************************/
+       
+       /**
+        * Returns the selection buffer
+        * @return Returns "unsinged char" from X11 XA_CUT_BUFFER0 buffer
+        *
+        */
+        virtual GHOST_TUns8* getClipboard(bool selection) const = 0;
+
+       /**
+        * Put data to the Clipboard
+        */
+       virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
+
+       
+protected:
+       /**
+        * Initialize the system.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess init() = 0;
+
+       /**
+        * Shut the system down.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess exit() = 0;
+
+       /** The one and only system */
+       static GHOST_ISystem* m_system;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+       void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_ISystem"); }
+       void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
+};
+
+#endif // _GHOST_ISYSTEM_H_
+
diff --git a/intern/ghost/GHOST_ISystemPaths.h b/intern/ghost/GHOST_ISystemPaths.h
new file mode 100644 (file)
index 0000000..5c9b3c1
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/GHOST_ISystemPaths.h
+ *  \ingroup GHOST
+ */
+
+#ifndef _GHOST_ISYSTEMPATHS_H_
+#define _GHOST_ISYSTEMPATHS_H_
+
+#include "GHOST_Types.h"
+
+class GHOST_ISystemPaths
+{
+public:
+       /**
+        * Creates the one and only system.
+        * @return An indication of success.
+        */
+       static GHOST_TSuccess create();
+
+       /**
+        * Disposes the one and only system.
+        * @return An indication of success.
+        */
+       static GHOST_TSuccess dispose();
+
+       /**
+        * Returns a pointer to the one and only system (nil if it hasn't been created).
+        * @return A pointer to the system.
+        */
+       static GHOST_ISystemPaths* get();
+
+protected:
+       /**
+        * Constructor.
+        * Protected default constructor to force use of static createSystem member.
+        */
+       GHOST_ISystemPaths() {}
+
+       /**
+        * Destructor.
+        * Protected default constructor to force use of static dispose member.
+        */
+       virtual ~GHOST_ISystemPaths() {}
+
+public:
+       /**
+        * Determine the base dir in which shared resources are located. It will first try to use
+        * "unpack and run" path, then look for properly installed path, not including versioning.
+        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
+        */
+       virtual const GHOST_TUns8* getSystemDir() const = 0;
+
+       /**
+        * Determine the base dir in which user configuration is stored, not including versioning.
+        * If needed, it will create the base directory.
+        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
+        */
+       virtual const GHOST_TUns8* getUserDir() const = 0;
+
+       /**
+         * Determine the directory of the current binary
+         * @return Unsigned char string pointing to the binary dir
+         */
+        virtual const GHOST_TUns8* getBinaryDir() const = 0;
+
+        /**
+         * Add the file to the operating system most recently used files
+         */
+        virtual void addToSystemRecentFiles(const char* filename) const = 0;
+
+private:
+       /** The one and only system paths*/
+       static GHOST_ISystemPaths* m_systemPaths;
+};
+
+#endif
diff --git a/intern/ghost/GHOST_ITimerTask.h b/intern/ghost/GHOST_ITimerTask.h
new file mode 100644 (file)
index 0000000..e6b7137
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/GHOST_ITimerTask.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_ITimerTask interface class.
+ */
+
+#ifndef _GHOST_ITIMER_TASK_H_
+#define _GHOST_ITIMER_TASK_H_
+
+#include "GHOST_Types.h"
+
+
+/**
+ * Interface for a timer task.
+ * Timer tasks are created by the system and can be installed by the system.
+ * After installation, the timer callback-procedure or "timerProc" will be called 
+ * periodically. You should not need to inherit this class. It is passed to the
+ * application in the timer-callback.<br>
+ * <br>
+ * Note that GHOST processes timers in the UI thread. You should ask GHOST 
+ * process messages in order for the timer-callbacks to be called.
+ * @see GHOST_ISystem#installTimer
+ * @see GHOST_TimerProcPtr
+ * @author     Maarten Gribnau
+ * @date       May 31, 2001
+ */
+class GHOST_ITimerTask
+{
+public:
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_ITimerTask()
+       {
+       }
+
+       /**
+        * Returns the timer callback.
+        * @return The timer callback.
+        */
+       virtual GHOST_TimerProcPtr getTimerProc() const = 0;
+
+       /**
+        * Changes the timer callback.
+        * @param timerProc The timer callback.
+        */
+       virtual void setTimerProc(const GHOST_TimerProcPtr timerProc) = 0;
+
+       /**
+        * Returns the timer user data.
+        * @return The timer user data.
+        */
+       virtual GHOST_TUserDataPtr getUserData() const = 0;
+       
+       /**
+        * Changes the time user data.
+        * @param data The timer user data.
+        */
+       virtual void setUserData(const GHOST_TUserDataPtr userData) = 0;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+       void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_ITimerTask"); }
+       void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
+};
+
+#endif // _GHOST_ITIMER_TASK_H_
+
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
new file mode 100644 (file)
index 0000000..97c525e
--- /dev/null
@@ -0,0 +1,317 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/GHOST_IWindow.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_IWindow interface class.
+ */
+
+#ifndef _GHOST_IWINDOW_H_
+#define _GHOST_IWINDOW_H_
+
+#include "STR_String.h"
+#include "GHOST_Rect.h"
+#include "GHOST_Types.h"
+
+
+/**
+ * Interface for GHOST windows.
+ *
+ * You can create a window with the system's GHOST_ISystem::createWindow 
+ * method.
+ * @see GHOST_ISystem#createWindow
+ *
+ * There are two coordinate systems:
+ * <ul>
+ * <li>The screen coordinate system. The origin of the screen is located in the
+ * upper left corner of the screen.</li> 
+ * <li>The client rectangle coordinate system. The client rectangle of a window
+ * is the area that is drawable by the application (excluding title bars etc.).
+ * </li> 
+ * </ul>
+ * @author     Maarten Gribnau
+ * @date       May 31, 2001
+ */
+class GHOST_IWindow
+{
+public:
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_IWindow()
+       {
+       }
+
+       /**
+        * Returns indication as to whether the window is valid.
+        * @return The validity of the window.
+        */
+       virtual bool getValid() const = 0;
+
+       /**
+        * Returns the associated OS object/handle
+        * @return The associated OS object/handle
+        */
+       virtual void* getOSWindow() const = 0;
+
+       /**
+        * Returns the type of drawing context used in this window.
+        * @return The current type of drawing context.
+        */
+       virtual GHOST_TDrawingContextType getDrawingContextType() = 0;
+
+       /**
+        * Tries to install a rendering context in this window.
+        * @param type  The type of rendering context installed.
+        * @return Indication as to whether installation has succeeded.
+        */
+       virtual GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type) = 0;
+
+       /**
+        * Sets the title displayed in the title bar.
+        * @param title The title to display in the title bar.
+        */
+       virtual void setTitle(const STR_String& title) = 0;
+
+       /**
+        * Returns the title displayed in the title bar.
+        * @param title The title displayed in the title bar.
+        */
+       virtual void getTitle(STR_String& title) const = 0;
+
+       /**
+        * Returns the window rectangle dimensions.
+        * These are screen coordinates.
+        * @param bounds The bounding rectangle of the window.
+        */
+       virtual void getWindowBounds(GHOST_Rect& bounds) const = 0;
+       
+       /**
+        * Returns the client rectangle dimensions.
+        * The left and top members of the rectangle are always zero.
+        * @param bounds The bounding rectangle of the client area of the window.
+        */
+       virtual void getClientBounds(GHOST_Rect& bounds) const = 0;
+
+       /**
+        * Resizes client rectangle width.
+        * @param width The new width of the client area of the window.
+        */
+       virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
+
+       /**
+        * Resizes client rectangle height.
+        * @param height The new height of the client area of the window.
+        */
+       virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
+
+       /**
+        * Resizes client rectangle.
+        * @param width         The new width of the client area of the window.
+        * @param height        The new height of the client area of the window.
+        */
+       virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
+
+       /**
+        * Converts a point in screen coordinates to client rectangle coordinates
+        * @param inX   The x-coordinate on the screen.
+        * @param inY   The y-coordinate on the screen.
+        * @param outX  The x-coordinate in the client rectangle.
+        * @param outY  The y-coordinate in the client rectangle.
+        */
+       virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
+
+       /**
+        * Converts a point in screen coordinates to client rectangle coordinates
+        * @param inX   The x-coordinate in the client rectangle.
+        * @param inY   The y-coordinate in the client rectangle.
+        * @param outX  The x-coordinate on the screen.
+        * @param outY  The y-coordinate on the screen.
+        */
+       virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
+
+       /**
+        * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
+        */
+       virtual void setAcceptDragOperation(bool canAccept) = 0;
+       
+       /**
+        * Returns acceptance of the dropped object
+        * Usually called by the "object dropped" event handling function
+        */
+       virtual bool canAcceptDragOperation() const = 0;
+       
+       /**
+        * Returns the state of the window (normal, minimized, maximized).
+        * @return The state of the window.
+        */
+       virtual GHOST_TWindowState getState() const = 0;
+
+       /**
+        * Sets the state of the window (normal, minimized, maximized).
+        * @param state The state of the window.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
+
+       /**
+        * Sets the window "modified" status, indicating unsaved changes
+        * @param isUnsavedChanges Unsaved changes or not
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess setModifiedState(bool isUnsavedChanges) = 0;
+       
+       /**
+        * Gets the window "modified" status, indicating unsaved changes
+        * @return True if there are unsaved changes
+        */
+       virtual bool getModifiedState() = 0;
+       
+       /**
+        * Sets the order of the window (bottom, top).
+        * @param order The order of the window.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
+
+       /**
+        * Swaps front and back buffers of a window.
+        * @return      A boolean success indicator.
+        */
+       virtual GHOST_TSuccess swapBuffers() = 0;
+
+       /**
+        * Activates the drawing context of this window.
+        * @return      A boolean success indicator.
+        */
+       virtual GHOST_TSuccess activateDrawingContext() = 0;
+
+       /**
+        * Invalidates the contents of this window.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess invalidate() = 0;
+       
+       /**
+        * Returns the window user data.
+        * @return The window user data.
+        */
+       virtual GHOST_TUserDataPtr getUserData() const = 0;
+       
+       /**
+        * Changes the window user data.
+        * @param data The window user data.
+        */
+       virtual void setUserData(const GHOST_TUserDataPtr userData) = 0;
+       
+       /**
+        * Returns the tablet data (pressure etc).
+        * @return The tablet data (pressure etc).
+        */
+       virtual const GHOST_TabletData* GetTabletData() = 0;
+       
+       /***************************************************************************************
+        ** Progress bar functionality
+        ***************************************************************************************/
+       
+       /**
+     * Sets the progress bar value displayed in the window/application icon
+        * @param progress The progress %
+        */
+       virtual GHOST_TSuccess setProgressBar(float progress) = 0;
+       
+       /**
+        * Hides the progress bar in the icon
+        */
+       virtual GHOST_TSuccess endProgressBar() = 0;
+       
+       /***************************************************************************************
+        ** Cursor management functionality
+        ***************************************************************************************/
+
+       /**
+        * Returns the current cursor shape.
+        * @return      The current cursor shape.
+        */
+       virtual GHOST_TStandardCursor getCursorShape() const = 0;
+
+       /**
+        * Set the shape of the cursor.
+        * @param       cursor  The new cursor shape type id.
+        * @return      Indication of success.
+        */
+       virtual GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursorShape) = 0;
+
+       /**
+        * Set the shape of the cursor to a custom cursor.
+        * @param       bitmap  The bitmap data for the cursor.
+        * @param       mask    The mask data for the cursor.
+        * @param       hotX    The X coordinate of the cursor hotspot.
+        * @param       hotY    The Y coordinate of the cursor hotspot.
+        * @return      Indication of success.
+        */
+       virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 bitmap[16][2], 
+                                                                                               GHOST_TUns8 mask[16][2], 
+                                                                                               int hotX, 
+                                                                                               int hotY) = 0;
+                                                                                               
+       virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap, 
+                                                                                               GHOST_TUns8 *mask, 
+                                                                                               int sizex, int sizey, 
+                                                                                               int hotX, int hotY, 
+                                                                                               int fg_color, int bg_color) = 0;
+
+       /**
+        * Returns the visibility state of the cursor.
+        * @return      The visibility state of the cursor.
+        */
+       virtual bool getCursorVisibility() const = 0;
+
+       /**
+        * Shows or hides the cursor.
+        * @param       visible The new visibility state of the cursor.
+        * @return      Indication of success.
+        */
+       virtual GHOST_TSuccess setCursorVisibility(bool visible) = 0;
+
+       /**
+        * Grabs the cursor for a modal operation.
+        * @param       grab The new grab state of the cursor.
+        * @return      Indication of success.
+        */
+       virtual GHOST_TSuccess setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_Rect *bounds) { return GHOST_kSuccess; };
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+       void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_IWindow"); }
+       void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
+};
+
+#endif // _GHOST_IWINDOW_H_
+
diff --git a/intern/ghost/GHOST_Path-api.h b/intern/ghost/GHOST_Path-api.h
new file mode 100644 (file)
index 0000000..790a529
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2010 by Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/GHOST_Path-api.h
+ *  \ingroup GHOST
+ */
+
+
+#ifndef        GHOST_PATH_API_H
+#define GHOST_PATH_API_H
+
+#include "GHOST_Types.h"
+
+#ifdef __cplusplus
+extern "C" { 
+#endif
+
+GHOST_DECLARE_HANDLE(GHOST_SystemPathsHandle);
+
+/**
+ * Creates the one and only instance of the system path access.
+ * @return An indication of success.
+ */
+extern GHOST_TSuccess GHOST_CreateSystemPaths(void);
+
+/**
+ * Disposes the one and only system.
+ * @return An indication of success.
+ */
+extern GHOST_TSuccess GHOST_DisposeSystemPaths(void);
+
+/**
+ * Determine the base dir in which shared resources are located. It will first try to use
+ * "unpack and run" path, then look for properly installed path, not including versioning.
+ * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
+ */
+extern const GHOST_TUns8* GHOST_getSystemDir(void);
+
+/**
+ * Determine the base dir in which user configuration is stored, not including versioning.
+ * @return Unsigned char string pointing to user dir (eg ~).
+ */
+extern const GHOST_TUns8* GHOST_getUserDir(void);
+
+
+/**
+ * Determine the dir in which the binary file is found.
+ * @return Unsigned char string pointing to binary dir (eg ~/usr/local/bin/).
+ */
+extern const GHOST_TUns8* GHOST_getBinaryDir(void);
+
+/**
+* Add the file to the operating system most recently used files
+*/
+extern void GHOST_addToSystemRecentFiles(const char* filename);
+
+#ifdef __cplusplus
+} 
+#endif
+
+#endif
diff --git a/intern/ghost/GHOST_Rect.h b/intern/ghost/GHOST_Rect.h
new file mode 100644 (file)
index 0000000..c654a45
--- /dev/null
@@ -0,0 +1,259 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_Debug.h
+ *  \ingroup GHOST
+ * Macro's used in GHOST debug target.
+ */
+
+#ifndef _H_GHOST_Rect
+#define _H_GHOST_Rect
+
+#include "GHOST_Types.h"
+
+
+/**
+ * Implements rectangle functionality.
+ * The four extreme coordinates are stored as left, top, right and bottom.
+ * To be valid, a rectangle should have a left coordinate smaller than or equal to right.
+ * To be valid, a rectangle should have a top coordinate smaller than or equal to bottom.
+ * @author     Maarten Gribnau
+ * @date       May 10, 2001
+ */
+
+class GHOST_Rect {
+public:
+
+       /**
+        * Constructs a rectangle with the given values.
+        * @param       l       requested left coordinate of the rectangle
+        * @param       t       requested top coordinate of the rectangle
+        * @param       r       requested right coordinate of the rectangle
+        * @param       b       requested bottom coordinate of the rectangle
+        */
+       GHOST_Rect(GHOST_TInt32 l=0, GHOST_TInt32 t=0, GHOST_TInt32 r=0, GHOST_TInt32 b=0)
+               : m_l(l), m_t(t), m_r(r), m_b(b) {}
+
+       /**
+        * Copy constructor.
+        * @param       r       rectangle to copy
+        */
+       GHOST_Rect(const GHOST_Rect& r)
+               : m_l(r.m_l), m_t(r.m_t), m_r(r.m_r), m_b(r.m_b) {}
+       
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_Rect() {};
+
+       /**
+        * Access to rectangle width.
+        * @return      width of the rectangle
+        */
+       virtual inline GHOST_TInt32 getWidth() const;
+
+       /**
+        * Access to rectangle height.
+        * @return      height of the rectangle
+        */
+       virtual inline GHOST_TInt32 getHeight() const;
+
+       /**
+        * Sets all members of the rectangle.
+        * @param       l       requested left coordinate of the rectangle
+        * @param       t       requested top coordinate of the rectangle
+        * @param       r       requested right coordinate of the rectangle
+        * @param       b       requested bottom coordinate of the rectangle
+        */
+       virtual inline void set(GHOST_TInt32 l, GHOST_TInt32 t, GHOST_TInt32 r, GHOST_TInt32 b);
+
+       /**
+        * Returns whether this rectangle is empty.
+        * Empty rectangles are rectangles that have width==0 and/or height==0.
+        * @return      boolean value (true==empty rectangle)
+        */
+       virtual inline bool isEmpty() const;
+
+       /**
+        * Returns whether this rectangle is valid.
+        * Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, emapty rectangles are valid.
+        * @return      boolean value (true==valid rectangle)
+        */
+       virtual inline bool isValid() const;
+
+       /**
+        * Grows (or shrinks the rectangle).
+        * The method avoids negative insets making the rectangle invalid
+        * @param       i       The amount of offset given to each extreme (negative values shrink the rectangle).
+        */
+       virtual void inset(GHOST_TInt32 i);
+
+       /**
+        * Does a union of the rectangle given and this rectangle.
+        * The result is stored in this rectangle.
+        * @param       r       The rectangle that is input for the union operation.
+        */
+       virtual inline void unionRect(const GHOST_Rect& r);
+
+       /**
+        * Grows the rectangle to included a point.
+        * @param       x       The x-coordinate of the point.
+        * @param       y       The y-coordinate of the point.
+        */
+       virtual inline void unionPoint(GHOST_TInt32 x, GHOST_TInt32 y);
+
+       /**
+        * Grows the rectangle to included a point.
+        * @param       x       The x-coordinate of the point.
+        * @param       y       The y-coordinate of the point.
+        */
+       virtual inline void wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32 ofs);
+
+       /**
+        * Returns whether the point is inside this rectangle.
+        * Point on the boundary is considered inside.
+        * @param x     x-coordinate of point to test.
+        * @param y y-coordinate of point to test.
+        * @return boolean value (true if point is inside).
+        */
+       virtual inline bool isInside(GHOST_TInt32 x, GHOST_TInt32 y) const;
+
+       /**
+        * Returns whether the rectangle is inside this rectangle.
+        * @param       r       rectangle to test.
+        * @return      visibility (not, partially or fully visible).
+        */
+       virtual GHOST_TVisibility getVisibility(GHOST_Rect& r) const;
+
+       /**
+        * Sets rectangle members.
+        * Sets rectangle members such that it is centered at the given location.
+        * @param       cx      requested center x-coordinate of the rectangle
+        * @param       cy      requested center y-coordinate of the rectangle
+        */
+       virtual void setCenter(GHOST_TInt32 cx, GHOST_TInt32 cy);
+
+       /**
+        * Sets rectangle members.
+        * Sets rectangle members such that it is centered at the given location,
+        * with the width requested.
+        * @param       cx      requested center x-coordinate of the rectangle
+        * @param       cy      requested center y-coordinate of the rectangle
+        * @param       w       requested width of the rectangle
+        * @param       h       requested height of the rectangle
+        */
+       virtual void setCenter(GHOST_TInt32 cx, GHOST_TInt32 cy, GHOST_TInt32 w, GHOST_TInt32 h);
+
+       /**
+        * Clips a rectangle.
+        * Updates the rectangle given such that it will fit within this one.
+        * This can result in an empty rectangle.
+        * @param       r       the rectangle to clip
+        * @return      whether clipping has occurred
+        */
+       virtual bool clip(GHOST_Rect& r) const;
+
+       /** Left coordinate of the rectangle */
+       GHOST_TInt32 m_l;
+       /** Top coordinate of the rectangle */
+       GHOST_TInt32 m_t;
+       /** Right coordinate of the rectangle */
+       GHOST_TInt32 m_r;
+       /** Bottom coordinate of the rectangle */
+       GHOST_TInt32 m_b;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+       void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_Rect"); }
+       void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
+};
+
+
+inline GHOST_TInt32 GHOST_Rect::getWidth() const
+{
+       return m_r - m_l;
+}
+
+inline GHOST_TInt32 GHOST_Rect::getHeight() const
+{
+       return m_b - m_t;
+}
+
+inline void GHOST_Rect::set(GHOST_TInt32 l, GHOST_TInt32 t, GHOST_TInt32 r, GHOST_TInt32 b)
+{
+       m_l = l; m_t = t; m_r = r; m_b = b;
+}
+
+inline bool    GHOST_Rect::isEmpty() const
+{
+       return (getWidth() == 0) || (getHeight() == 0);
+}
+
+inline bool GHOST_Rect::isValid() const
+{
+       return (m_l <= m_r) && (m_t <= m_b);
+}
+
+inline void GHOST_Rect::unionRect(const GHOST_Rect& r)
+{
+       if (r.m_l < m_l) m_l = r.m_l;
+       if (r.m_r > m_r) m_r = r.m_r;
+       if (r.m_t < m_t) m_t = r.m_t;
+       if (r.m_b > m_b) m_b = r.m_b;
+}
+
+inline void GHOST_Rect::unionPoint(GHOST_TInt32 x, GHOST_TInt32 y)
+{
+       if (x < m_l) m_l = x;
+       if (x > m_r) m_r = x;
+       if (y < m_t) m_t = y;
+       if (y > m_b) m_b = y;
+}
+#include <stdio.h>
+inline void GHOST_Rect::wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32 ofs)
+{
+       GHOST_TInt32 w= getWidth();
+       GHOST_TInt32 h= getHeight();
+
+       /* highly unlikely but avoid eternal loop */
+       if(w-ofs*2 <= 0 || h-ofs*2 <= 0)
+               return;
+       while(x-ofs < m_l)              x+= w-(ofs*2);
+       while(y-ofs < m_t)              y+= h-(ofs*2);
+       while(x+ofs > m_r)              x-= w-(ofs*2);
+       while(y+ofs > m_b)              y-= h-(ofs*2);
+}
+
+inline bool GHOST_Rect::isInside(GHOST_TInt32 x, GHOST_TInt32 y) const
+{
+       return (x >= m_l) && (x <= m_r) && (y >= m_t) && (y <= m_b);
+}
+
+#endif // _H_GHOST_Rect
+
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
new file mode 100644 (file)
index 0000000..705f491
--- /dev/null
@@ -0,0 +1,516 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/GHOST_Types.h
+ *  \ingroup GHOST
+ */
+
+
+#ifndef _GHOST_TYPES_H_
+#define _GHOST_TYPES_H_
+
+#ifdef WITH_CXX_GUARDEDALLOC
+#include "MEM_guardedalloc.h"
+#endif
+
+#define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
+
+typedef        char                            GHOST_TInt8;
+typedef        unsigned char           GHOST_TUns8;
+typedef short                          GHOST_TInt16;
+typedef unsigned short         GHOST_TUns16;
+typedef        int                                     GHOST_TInt32;
+typedef        unsigned int            GHOST_TUns32;
+
+#ifdef WIN32
+#define WM_BLND_NDOF_AXIS      WM_USER + 1
+#define WM_BLND_NDOF_BTN       WM_USER + 2
+#endif
+
+#if defined(WIN32) && !defined(FREE_WINDOWS)
+typedef __int64                                GHOST_TInt64;
+typedef unsigned __int64       GHOST_TUns64;
+#else
+typedef long long                      GHOST_TInt64;
+typedef unsigned long long     GHOST_TUns64;
+#endif
+
+typedef void*                          GHOST_TUserDataPtr;
+
+typedef enum
+{
+       GHOST_kFailure = 0,
+       GHOST_kSuccess
+} GHOST_TSuccess;
+
+/* Xtilt and Ytilt represent how much the pen is tilted away from 
+ * vertically upright in either the X or Y direction, with X and Y the
+ * axes of the tablet surface.
+ * In other words, Xtilt and Ytilt are components of a vector created by projecting
+ * the pen's angle in 3D space vertically downwards on to the XY plane
+ * --Matt
+ */
+typedef enum {
+       GHOST_kTabletModeNone = 0,
+       GHOST_kTabletModeStylus,
+       GHOST_kTabletModeEraser
+} GHOST_TTabletMode;
+
+typedef struct GHOST_TabletData {
+       GHOST_TTabletMode Active; /* 0=None, 1=Stylus, 2=Eraser */
+       float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
+       float Xtilt;    /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
+       float Ytilt;    /* as above */
+} GHOST_TabletData;
+
+
+typedef enum {
+       GHOST_kNotVisible = 0,
+       GHOST_kPartiallyVisible,
+       GHOST_kFullyVisible
+} GHOST_TVisibility;
+
+
+typedef enum {
+       GHOST_kFireTimeNever = 0xFFFFFFFF
+} GHOST_TFireTimeConstant;
+
+typedef enum {
+    GHOST_kModifierKeyLeftShift = 0,
+    GHOST_kModifierKeyRightShift,
+    GHOST_kModifierKeyLeftAlt,
+    GHOST_kModifierKeyRightAlt,
+    GHOST_kModifierKeyLeftControl,
+    GHOST_kModifierKeyRightControl,
+    GHOST_kModifierKeyOS,
+    GHOST_kModifierKeyNumMasks
+} GHOST_TModifierKeyMask;
+
+
+typedef enum {
+       GHOST_kWindowStateNormal = 0,
+       GHOST_kWindowStateMaximized,
+       GHOST_kWindowStateMinimized,
+       GHOST_kWindowStateFullScreen,
+       GHOST_kWindowStateEmbedded,
+       GHOST_kWindowState8Normal = 8,
+       GHOST_kWindowState8Maximized,
+       GHOST_kWindowState8Minimized,
+       GHOST_kWindowState8FullScreen,
+       GHOST_kWindowStateModified,
+       GHOST_kWindowStateUnModified
+} GHOST_TWindowState;
+
+
+/** Constants for the answer to the blender exit request */
+typedef enum {
+       GHOST_kExitCancel = 0,
+       GHOST_kExitNow
+} GHOST_TExitRequestResponse;
+
+typedef enum {
+       GHOST_kWindowOrderTop = 0,
+       GHOST_kWindowOrderBottom
+} GHOST_TWindowOrder;
+
+
+typedef enum {
+       GHOST_kDrawingContextTypeNone = 0,
+       GHOST_kDrawingContextTypeOpenGL
+} GHOST_TDrawingContextType;
+
+
+typedef enum {
+       GHOST_kButtonMaskLeft = 0,
+       GHOST_kButtonMaskMiddle,
+       GHOST_kButtonMaskRight,
+       GHOST_kButtonMaskButton4,
+       GHOST_kButtonMaskButton5,
+       GHOST_kButtonNumMasks
+} GHOST_TButtonMask;
+
+
+typedef enum {
+       GHOST_kEventUnknown = 0,
+
+       GHOST_kEventCursorMove,         /// Mouse move event
+       GHOST_kEventButtonDown,         /// Mouse button event
+       GHOST_kEventButtonUp,           /// Mouse button event
+       GHOST_kEventWheel,                      /// Mouse wheel event
+       GHOST_kEventTrackpad,           /// Trackpad event
+
+       GHOST_kEventNDOFMotion,         /// N degree of freedom device motion event
+       GHOST_kEventNDOFButton,         /// N degree of freedom device button event
+
+       GHOST_kEventKeyDown,
+       GHOST_kEventKeyUp,
+//     GHOST_kEventKeyAuto,
+
+       GHOST_kEventQuit,
+
+       GHOST_kEventWindowClose,
+       GHOST_kEventWindowActivate,
+       GHOST_kEventWindowDeactivate,
+       GHOST_kEventWindowUpdate,
+       GHOST_kEventWindowSize,
+       GHOST_kEventWindowMove,
+       
+       GHOST_kEventDraggingEntered,
+       GHOST_kEventDraggingUpdated,
+       GHOST_kEventDraggingExited,
+       GHOST_kEventDraggingDropDone,
+       
+       GHOST_kEventOpenMainFile, // Needed for Cocoa to open double-clicked .blend file at startup
+
+       GHOST_kEventTimer,
+
+       GHOST_kNumEventTypes
+} GHOST_TEventType;
+
+
+typedef enum {
+       GHOST_kStandardCursorFirstCursor = 0,
+       GHOST_kStandardCursorDefault = 0,
+       GHOST_kStandardCursorRightArrow,
+       GHOST_kStandardCursorLeftArrow,
+       GHOST_kStandardCursorInfo, 
+       GHOST_kStandardCursorDestroy,
+       GHOST_kStandardCursorHelp,    
+       GHOST_kStandardCursorCycle,
+       GHOST_kStandardCursorSpray,
+       GHOST_kStandardCursorWait,
+       GHOST_kStandardCursorText,
+       GHOST_kStandardCursorCrosshair,
+       GHOST_kStandardCursorUpDown,
+       GHOST_kStandardCursorLeftRight,
+       GHOST_kStandardCursorTopSide,
+       GHOST_kStandardCursorBottomSide,
+       GHOST_kStandardCursorLeftSide,
+       GHOST_kStandardCursorRightSide,
+       GHOST_kStandardCursorTopLeftCorner,
+       GHOST_kStandardCursorTopRightCorner,
+       GHOST_kStandardCursorBottomRightCorner,
+       GHOST_kStandardCursorBottomLeftCorner,
+       GHOST_kStandardCursorCopy,
+       GHOST_kStandardCursorCustom, 
+       GHOST_kStandardCursorNumCursors, 
+       GHOST_kStandardCursorPencil
+} GHOST_TStandardCursor;
+
+
+typedef enum {
+       GHOST_kKeyUnknown = -1,
+       GHOST_kKeyBackSpace,
+       GHOST_kKeyTab,
+       GHOST_kKeyLinefeed,
+       GHOST_kKeyClear,
+       GHOST_kKeyEnter  = 0x0D,
+       
+       GHOST_kKeyEsc    = 0x1B,
+       GHOST_kKeySpace  = ' ',
+       GHOST_kKeyQuote  = 0x27,
+       GHOST_kKeyComma  = ',',
+       GHOST_kKeyMinus  = '-',
+       GHOST_kKeyPeriod = '.',
+       GHOST_kKeySlash  = '/',
+
+       // Number keys
+       GHOST_kKey0 = '0',
+       GHOST_kKey1,
+       GHOST_kKey2,
+       GHOST_kKey3,
+       GHOST_kKey4,
+       GHOST_kKey5,
+       GHOST_kKey6,
+       GHOST_kKey7,
+       GHOST_kKey8,
+       GHOST_kKey9,
+
+       GHOST_kKeySemicolon = ';',
+       GHOST_kKeyEqual     = '=',
+
+       // Character keys
+       GHOST_kKeyA = 'A',
+       GHOST_kKeyB,
+       GHOST_kKeyC,
+       GHOST_kKeyD,
+       GHOST_kKeyE,
+       GHOST_kKeyF,
+       GHOST_kKeyG,
+       GHOST_kKeyH,
+       GHOST_kKeyI,
+       GHOST_kKeyJ,
+       GHOST_kKeyK,
+       GHOST_kKeyL,
+       GHOST_kKeyM,
+       GHOST_kKeyN,
+       GHOST_kKeyO,
+       GHOST_kKeyP,
+       GHOST_kKeyQ,
+       GHOST_kKeyR,
+       GHOST_kKeyS,
+       GHOST_kKeyT,
+       GHOST_kKeyU,
+       GHOST_kKeyV,
+       GHOST_kKeyW,
+       GHOST_kKeyX,
+       GHOST_kKeyY,
+       GHOST_kKeyZ,
+
+       GHOST_kKeyLeftBracket  = '[',
+       GHOST_kKeyRightBracket = ']',
+       GHOST_kKeyBackslash    = 0x5C,
+       GHOST_kKeyAccentGrave  = '`',
+
+       
+       GHOST_kKeyLeftShift = 0x100,
+       GHOST_kKeyRightShift,
+       GHOST_kKeyLeftControl,
+       GHOST_kKeyRightControl,
+       GHOST_kKeyLeftAlt,
+       GHOST_kKeyRightAlt,
+       GHOST_kKeyOS,           // Command key on Apple, Windows key(s) on Windows
+       GHOST_kKeyGrLess ,              // German PC only!
+
+       GHOST_kKeyCapsLock,
+       GHOST_kKeyNumLock,
+       GHOST_kKeyScrollLock,
+
+       GHOST_kKeyLeftArrow,
+       GHOST_kKeyRightArrow,
+       GHOST_kKeyUpArrow,
+       GHOST_kKeyDownArrow,
+
+       GHOST_kKeyPrintScreen,
+       GHOST_kKeyPause,
+
+       GHOST_kKeyInsert,
+       GHOST_kKeyDelete,
+       GHOST_kKeyHome,
+       GHOST_kKeyEnd,
+       GHOST_kKeyUpPage,
+       GHOST_kKeyDownPage,
+
+       // Numpad keys
+       GHOST_kKeyNumpad0,
+       GHOST_kKeyNumpad1,
+       GHOST_kKeyNumpad2,
+       GHOST_kKeyNumpad3,
+       GHOST_kKeyNumpad4,
+       GHOST_kKeyNumpad5,
+       GHOST_kKeyNumpad6,
+       GHOST_kKeyNumpad7,
+       GHOST_kKeyNumpad8,
+       GHOST_kKeyNumpad9,
+       GHOST_kKeyNumpadPeriod,
+       GHOST_kKeyNumpadEnter,
+       GHOST_kKeyNumpadPlus,
+       GHOST_kKeyNumpadMinus,
+       GHOST_kKeyNumpadAsterisk,
+       GHOST_kKeyNumpadSlash,
+
+       // Function keys
+       GHOST_kKeyF1,
+       GHOST_kKeyF2,
+       GHOST_kKeyF3,
+       GHOST_kKeyF4,
+       GHOST_kKeyF5,
+       GHOST_kKeyF6,
+       GHOST_kKeyF7,
+       GHOST_kKeyF8,
+       GHOST_kKeyF9,
+       GHOST_kKeyF10,
+       GHOST_kKeyF11,
+       GHOST_kKeyF12,
+       GHOST_kKeyF13,
+       GHOST_kKeyF14,
+       GHOST_kKeyF15,
+       GHOST_kKeyF16,
+       GHOST_kKeyF17,
+       GHOST_kKeyF18,
+       GHOST_kKeyF19,
+       GHOST_kKeyF20,
+       GHOST_kKeyF21,
+       GHOST_kKeyF22,
+       GHOST_kKeyF23,
+       GHOST_kKeyF24,
+       
+       // Multimedia keypad buttons
+       GHOST_kKeyMediaPlay,
+       GHOST_kKeyMediaStop,
+       GHOST_kKeyMediaFirst,
+       GHOST_kKeyMediaLast
+} GHOST_TKey;
+
+typedef enum {
+       GHOST_kGrabDisable = 0, /* grab not set */
+       GHOST_kGrabNormal,      /* no cursor adjustments */
+       GHOST_kGrabWrap,                /* wrap the mouse location to prevent limiting screen bounds */
+       GHOST_kGrabHide,                /* hide the mouse while grabbing and restore the original location on release (numbuts) */
+} GHOST_TGrabCursorMode;
+
+typedef void* GHOST_TEventDataPtr;
+
+typedef struct {
+       /** The x-coordinate of the cursor position. */
+       GHOST_TInt32 x;
+       /** The y-coordinate of the cursor position. */
+       GHOST_TInt32 y;
+} GHOST_TEventCursorData;
+
+typedef struct {
+       /** The mask of the mouse button. */
+       GHOST_TButtonMask button;
+} GHOST_TEventButtonData;
+
+typedef struct {
+       /** Displacement of a mouse wheel. */
+       GHOST_TInt32 z; 
+} GHOST_TEventWheelData;
+
+typedef enum {
+       GHOST_kTrackpadEventUnknown =0,
+       GHOST_kTrackpadEventScroll,
+       GHOST_kTrackpadEventRotate,
+       GHOST_kTrackpadEventSwipe, /* Reserved, not used for now */
+       GHOST_kTrackpadEventMagnify
+} GHOST_TTrackpadEventSubTypes;
+       
+
+typedef struct {
+       /** The event subtype */
+       GHOST_TTrackpadEventSubTypes subtype;
+       /** The x-location of the trackpad event */
+       GHOST_TInt32 x;
+       /** The y-location of the trackpad event */
+       GHOST_TInt32 y;
+       /** The x-delta or value of the trackpad event */
+       GHOST_TInt32 deltaX;
+       /** The y-delta (currently only for scroll subtype) of the trackpad event */
+       GHOST_TInt32 deltaY;
+} GHOST_TEventTrackpadData;
+
+
+typedef enum {
+       GHOST_kDragnDropTypeUnknown =0,
+       GHOST_kDragnDropTypeFilenames, /*Array of strings representing file names (full path) */
+       GHOST_kDragnDropTypeString, /* Unformatted text UTF-8 string */
+       GHOST_kDragnDropTypeBitmap /*Bitmap image data */
+} GHOST_TDragnDropTypes;
+
+typedef struct {
+       /** The x-coordinate of the cursor position. */
+       GHOST_TInt32 x;
+       /** The y-coordinate of the cursor position. */
+       GHOST_TInt32 y;
+       /** The dropped item type */
+       GHOST_TDragnDropTypes dataType;
+       /** The "dropped content" */
+       GHOST_TEventDataPtr data;
+} GHOST_TEventDragnDropData;
+
+typedef struct {
+       int count;
+       GHOST_TUns8 **strings;
+} GHOST_TStringArray;
+
+
+/* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
+/* as all USB device controls are likely to use ints, this is also more future proof */
+//typedef struct {
+//   /** N-degree of freedom device data */
+//   float tx, ty, tz;   /** -x left, +y up, +z forward */
+//   float rx, ry, rz;
+//   float dt;
+//} GHOST_TEventNDOFData;
+
+typedef struct {
+   /** N-degree of freedom device data v2*/
+   int changed;
+   GHOST_TUns64 client;
+   GHOST_TUns64 address;
+   GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
+   GHOST_TInt16 rx, ry, rz;
+   GHOST_TInt16 buttons;
+   GHOST_TUns64 time;
+   GHOST_TUns64 delta;
+} GHOST_TEventNDOFData;
+
+typedef int     (*GHOST_NDOFLibraryInit_fp)(void);
+typedef void    (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
+typedef void*   (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
+
+// original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
+// not necessary faster, but better integration with other events. 
+
+//typedef int     (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
+//typedef void     (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
+
+typedef struct {
+       /** The key code. */
+       GHOST_TKey              key;
+       /** The ascii code for the key event ('\0' if none). */
+       char                    ascii;
+} GHOST_TEventKeyData;
+
+typedef struct {
+       /** Number of pixels on a line. */
+       GHOST_TUns32    xPixels;
+       /** Number of lines. */
+       GHOST_TUns32    yPixels;
+       /** Numberof bits per pixel. */
+       GHOST_TUns32    bpp;
+       /** Refresh rate (in Hertz). */
+       GHOST_TUns32    frequency;
+} GHOST_DisplaySetting;
+
+
+#ifdef _WIN32
+typedef long GHOST_TEmbedderWindowID;
+#endif // _WIN32
+
+#ifndef _WIN32
+// I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
+typedef int GHOST_TEmbedderWindowID;
+#endif // _WIN32
+
+/**
+ * A timer task callback routine.
+ * @param task The timer task object.
+ * @param time The current time.
+ */
+#ifdef __cplusplus
+class GHOST_ITimerTask;
+typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
+#else
+struct GHOST_TimerTaskHandle__;
+typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
+#endif
+
+#endif // _GHOST_TYPES_H_
+
diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript
new file mode 100644 (file)
index 0000000..b67545f
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+import sys
+import os
+
+Import ('env')
+
+window_system = env['OURPLATFORM']
+
+sources = env.Glob('intern/*.cpp')
+if window_system == 'darwin':
+    sources += env.Glob('intern/*.mm')
+
+
+pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_SystemPaths', 'GHOST_Window', 'GHOST_DropTarget']
+defs=['_USE_MATH_DEFINES']
+
+if window_system in ('linux2', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'freebsd9', 'irix6', 'aix4', 'aix5'):
+    for f in pf:
+        try:
+            sources.remove('intern' + os.sep + f + 'Win32.cpp')
+            sources.remove('intern' + os.sep + f + 'Carbon.cpp')
+        except ValueError:
+            pass
+    defs += ['PREFIX=\\"/usr/local/\\"']  # XXX, make an option
+    defs += ['WITH_X11_XINPUT']  # XXX, make an option
+
+elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc'):
+    for f in pf:
+        try:
+            sources.remove('intern' + os.sep + f + 'X11.cpp')
+            sources.remove('intern' + os.sep + f + 'Carbon.cpp')
+        except ValueError:
+            pass
+elif window_system == 'darwin':
+    if env['WITH_GHOST_COCOA']:
+        if env['WITH_BF_QUICKTIME']:
+            defs.append('WITH_QUICKTIME')
+        if env['USE_QTKIT']:
+            defs.append('USE_QTKIT')
+        for f in pf:
+            try:
+                sources.remove('intern' + os.sep + f + 'Win32.cpp')
+                sources.remove('intern' + os.sep + f + 'X11.cpp')
+                sources.remove('intern' + os.sep + f + 'Carbon.cpp')
+            except ValueError:
+                pass
+    else:
+        for f in pf:
+            try:
+                sources.remove('intern' + os.sep + f + 'Win32.cpp')
+                sources.remove('intern' + os.sep + f + 'X11.cpp')
+                sources.remove('intern' + os.sep + f + 'Cocoa.mm')
+            except ValueError:
+                pass
+
+else:
+    print "Unknown window system specified."
+    Exit()
+
+if env['BF_GHOST_DEBUG']:
+    defs.append('BF_GHOST_DEBUG')
+
+incs = '. ../string #extern/glew/include #source/blender/imbuf #source/blender/makesdna ' + env['BF_OPENGL_INC']
+if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc'):
+    incs = env['BF_WINTAB_INC'] + ' ' + incs
+
+if window_system in ('win32-vc', 'win64-vc'):
+    env.BlenderLib ('bf_intern_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15]) #, cc_compileflags=env['CCFLAGS'].append('/WX') ) 
+else:
+    env.BlenderLib ('bf_intern_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15] ) 
diff --git a/intern/ghost/doc/ghost_interface.cfg b/intern/ghost/doc/ghost_interface.cfg
new file mode 100644 (file)
index 0000000..ebe4153
--- /dev/null
@@ -0,0 +1,626 @@
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project. 
+PROJECT_NAME = "GHOST (Generic Handy Operating System Toolkit)"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+PROJECT_NUMBER = 1.0
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+OUTPUT_DIRECTORY = ./interface
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese, 
+# Korean, Hungarian, Norwegian, Spanish, Romanian, Russian, Croatian, 
+# Polish, Portuguese and Slovene.
+OUTPUT_LANGUAGE = English
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES 
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation. 
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation. 
+EXTRACT_STATIC = YES
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled. 
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these class will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled. 
+HIDE_UNDOC_CLASSES = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this. 
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed. 
+REPEAT_BRIEF = YES
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description. 
+ALWAYS_DETAILED_SEC = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used. 
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. It is allowed to use relative paths in the argument list.
+STRIP_FROM_PATH = 
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation. 
+INTERNAL_DOCS = NO
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a class diagram (in Html and LaTeX) for classes with base or 
+# super classes. Setting the tag to NO turns the diagrams off. 
+CLASS_DIAGRAMS = YES
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation. 
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible. 
+STRIP_CODE_COMMENTS = YES
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower case letters. If set to YES upper case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# users are adviced to set this option to NO.
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden. 
+HIDE_SCOPE_NAMES = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this. 
+VERBATIM_HEADERS = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put list of the files that are included by a file in the documentation 
+# of that file. 
+SHOW_INCLUDE_FILES = YES
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments  will behave just like the Qt-style comments (thus requiring an 
+# explict @brief command for a brief description. 
+JAVADOC_AUTOBRIEF = YES
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# reimplements. 
+INHERIT_DOCS = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members. 
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order. 
+SORT_MEMBER_DOCS = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+DISTRIBUTE_GROUP_DOC = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments. 
+TAB_SIZE = 4
+
+# The ENABLE_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif. 
+ENABLED_SECTION = 
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+GENERATE_TESTLIST = YES
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines. 
+ALIASES = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used. 
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used. 
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled. 
+WARN_IF_UNDOCUMENTED = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. 
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr. 
+WARN_LOGFILE = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces. 
+INPUT = ..
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included. 
+FILE_PATTERNS = *.h *.cpp *.c
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used. 
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag. 
+EXCLUDE = 
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. 
+EXCLUDE_PATTERNS = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command). 
+EXAMPLE_PATH = ../test
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included. 
+EXAMPLE_PATTERNS = *.h *.cpp *.c
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command). 
+IMAGE_PATH = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output. 
+INPUT_FILTER  = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse. 
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces. 
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20]) 
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers. 
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output. 
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path. 
+HTML_OUTPUT = html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+HTML_HEADER = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+HTML_FOOTER = 
+
+# The HTML_STYLESHEET tag can be used to specify a user defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet 
+HTML_STYLESHEET = 
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used. 
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation. 
+GENERATE_HTMLHELP = YES
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it. 
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation. 
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side pannel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript and frames is required (for instance Netscape 4.0+ 
+# or Internet explorer 4.0+). 
+GENERATE_TREEVIEW = YES
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown. 
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output. 
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path. 
+LATEX_OUTPUT = latex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general. 
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used. 
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output. 
+EXTRA_PACKAGES = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing! 
+LATEX_HEADER = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer. 
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation. 
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML. 
+LATEX_BATCHMODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimised for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path. 
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general. 
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using a WORD or other. 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links. 
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assigments. You only have to provide 
+# replacements, missing definitions are set to their default value. 
+RTF_STYLESHEET_FILE = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages 
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path. 
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3) 
+MAN_EXTENSION = .3
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation. Warning: This feature 
+# is still experimental and very incomplete.
+GENERATE_XML = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files. 
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES. 
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_PREDEFINED tags. 
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found. 
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor. 
+INCLUDE_PATH = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used. 
+INCLUDE_FILE_PATTERNS = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. 
+PREDEFINED = 
+
+# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition. 
+EXPAND_AS_DEFINED = 
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tagfiles. 
+TAGFILES = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads. 
+GENERATE_TAGFILE = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed. 
+ALLEXTERNALS = 
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl'). 
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default) 
+HAVE_DOT = YES
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes. 
+COLLABORATION_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to 
+# YES then doxygen will generate a graph for each documented file showing 
+# the direct and indirect include dependencies of the file with other 
+# documented files. 
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to 
+# YES then doxygen will generate a graph for each documented header file showing 
+# the documented files that directly or indirectly include this file 
+INCLUDED_BY_GRAPH = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one. 
+GRAPHICAL_HIERARCHY = YES
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found on the path. 
+DOT_PATH = 
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images. 
+MAX_DOT_GRAPH_WIDTH = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images. 
+MAX_DOT_GRAPH_HEIGHT = 1024
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs. 
+GENERATE_LEGEND = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored. 
+SEARCHENGINE = NO
+
+# The CGI_NAME tag should be the name of the CGI script that 
+# starts the search engine (doxysearch) with the correct parameters. 
+# A script with this name will be generated by doxygen. 
+CGI_NAME= search.cgi
+
+# The CGI_URL tag should be the absolute URL to the directory where the 
+# cgi binaries are located. See the documentation of your http daemon for 
+# details. 
+CGI_URL= 
+
+# The DOC_URL tag should be the absolute URL to the directory where the 
+# documentation is located. If left blank the absolute path to the 
+# documentation, with file:// prepended to it, will be used. 
+DOC_URL= 
+
+# The DOC_ABSPATH tag should be the absolute path to the directory where the 
+# documentation is located. If left blank the directory on the local machine 
+# will be used. 
+DOC_ABSPATH= 
+
+# The BIN_ABSPATH tag must point to the directory where the doxysearch binary 
+# is installed. 
+BIN_ABSPATH= /bin
+
+# The EXT_DOC_PATHS tag can be used to specify one or more paths to 
+# documentation generated for other projects. This allows doxysearch to search 
+# the documentation for these projects as well. 
+EXT_DOC_PATHS= 
diff --git a/intern/ghost/intern/GHOST_Buttons.cpp b/intern/ghost/intern/GHOST_Buttons.cpp
new file mode 100644 (file)
index 0000000..9f20c10
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_Buttons.cpp
+ *  \ingroup GHOST
+ */
+
+
+#include "GHOST_Buttons.h"
+
+
+
+GHOST_Buttons::GHOST_Buttons()
+{
+       clear();
+}
+
+
+bool GHOST_Buttons::get(GHOST_TButtonMask mask) const
+{
+    switch (mask) {
+    case GHOST_kButtonMaskLeft:
+        return m_ButtonLeft;
+    case GHOST_kButtonMaskMiddle:
+        return m_ButtonMiddle;
+    case GHOST_kButtonMaskRight:
+        return m_ButtonRight;
+    default:
+        return false;
+    }
+}
+
+void GHOST_Buttons::set(GHOST_TButtonMask mask, bool down)
+{
+    switch (mask) {
+    case GHOST_kButtonMaskLeft:
+        m_ButtonLeft = down; break;
+    case GHOST_kButtonMaskMiddle:
+        m_ButtonMiddle = down; break;
+    case GHOST_kButtonMaskRight:
+        m_ButtonRight = down; break;
+    default:
+        break;
+    }
+}
+
+void GHOST_Buttons::clear()
+{
+    m_ButtonLeft = false;
+    m_ButtonMiddle = false;
+    m_ButtonRight = false;
+}
+
+GHOST_Buttons::~GHOST_Buttons() {}
diff --git a/intern/ghost/intern/GHOST_Buttons.h b/intern/ghost/intern/GHOST_Buttons.h
new file mode 100644 (file)
index 0000000..bf5bdb1
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_Buttons.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_Buttons struct.
+ */
+
+#ifndef _GHOST_BUTTONS_H_
+#define _GHOST_BUTTONS_H_
+
+#include "GHOST_Types.h"
+
+
+/**
+ * This struct stores the state of the mouse buttons.
+ * Buttons can be set using button masks. 
+ * @author     Maarten Gribnau
+ * @date       May 15, 2001
+ */
+struct GHOST_Buttons {
+    /**
+     * Constructor.
+     */
+    GHOST_Buttons();
+
+       virtual ~GHOST_Buttons();
+    
+    /**
+     * Returns the state of a single button.
+     * @param mask. Key button to return.
+     * @return The state of the button (pressed == true).
+     */
+    virtual bool get(GHOST_TButtonMask mask) const;
+    
+    /**
+     * Updates the state of a single button.
+     * @param mask. Button state to update.
+     * @param down. The new state of the button.
+     */
+    virtual void set(GHOST_TButtonMask mask, bool down);
+    
+    /**
+     * Sets the state of all buttons to up.
+     */
+    virtual void clear(); 
+    
+    GHOST_TUns8 m_ButtonLeft           : 1;
+    GHOST_TUns8 m_ButtonMiddle         : 1;
+    GHOST_TUns8 m_ButtonRight          : 1;
+};
+
+#endif // _GHOST_BUTTONS_H_
+
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
new file mode 100644 (file)
index 0000000..7ba8d7d
--- /dev/null
@@ -0,0 +1,885 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_C-api.cpp
+ *  \ingroup GHOST
+ */
+
+
+/*
+
+ * GHOST_C-Api.cpp
+ *
+ * C Api for GHOST
+ *
+ * Version: $Id$
+ */
+
+#include <stdlib.h>
+
+#include "intern/GHOST_Debug.h"
+#include "GHOST_C-api.h"
+#include "GHOST_ISystem.h"
+#include "GHOST_IEvent.h"
+#include "GHOST_IEventConsumer.h"
+#include "intern/GHOST_CallbackEventConsumer.h"
+
+GHOST_SystemHandle GHOST_CreateSystem(void)
+{
+       GHOST_ISystem::createSystem();
+       GHOST_ISystem* system = GHOST_ISystem::getSystem();
+
+       return (GHOST_SystemHandle)system;
+}
+
+
+
+GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+       return system->disposeSystem();
+}
+
+
+GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback, GHOST_TUserDataPtr userdata)
+{
+       return (GHOST_EventConsumerHandle) new GHOST_CallbackEventConsumer (eventCallback, userdata);
+}
+
+
+GHOST_TSuccess GHOST_DisposeEventConsumer(GHOST_EventConsumerHandle consumerhandle)
+{
+       delete ((GHOST_CallbackEventConsumer*)consumerhandle);
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TUns64 GHOST_GetMilliSeconds(GHOST_SystemHandle systemhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+       return system->getMilliSeconds();
+}
+
+
+
+GHOST_TimerTaskHandle GHOST_InstallTimer(GHOST_SystemHandle systemhandle,
+                                                                                GHOST_TUns64 delay,
+                                                                                GHOST_TUns64 interval,
+                                                                                GHOST_TimerProcPtr timerproc,
+                                                                                GHOST_TUserDataPtr userdata)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+       return (GHOST_TimerTaskHandle) system->installTimer(delay, interval, timerproc, userdata);
+}
+
+
+
+GHOST_TSuccess GHOST_RemoveTimer(GHOST_SystemHandle systemhandle,
+                                                                GHOST_TimerTaskHandle timertaskhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
+
+       return system->removeTimer(timertask);
+}
+
+
+
+GHOST_TUns8 GHOST_GetNumDisplays(GHOST_SystemHandle systemhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+       return system->getNumDisplays();
+}
+
+
+
+void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
+                                                                       GHOST_TUns32* width,
+                                                                       GHOST_TUns32* height)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       
+       system->getMainDisplayDimensions(*width, *height);
+}
+
+
+
+GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
+                                                                         const char* title,
+                                                                         GHOST_TInt32 left,
+                                                                         GHOST_TInt32 top,
+                                                                         GHOST_TUns32 width,
+                                                                         GHOST_TUns32 height,
+                                                                         GHOST_TWindowState state,
+                                                                         GHOST_TDrawingContextType type,
+                                                                         const int stereoVisual,
+                                                                         const GHOST_TUns16 numOfAASamples)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       bool bstereoVisual;
+
+       if(stereoVisual)
+               bstereoVisual = true;
+       else
+               bstereoVisual = false;
+
+       return (GHOST_WindowHandle) system->createWindow(title, left, top, width, height,
+               state, type, bstereoVisual, numOfAASamples);
+}
+
+GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->getUserData();
+}
+void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle, GHOST_TUserDataPtr userdata)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       window->setUserData(userdata);
+}
+
+GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle,
+                                                                  GHOST_WindowHandle windowhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       
+       return system->disposeWindow(window);
+}
+
+
+
+int GHOST_ValidWindow(GHOST_SystemHandle systemhandle,
+                                                                GHOST_WindowHandle windowhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       
+       return (int) system->validWindow(window);
+}
+
+
+
+GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
+                                                                                GHOST_DisplaySetting* setting,
+                                                                                const int stereoVisual)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       GHOST_IWindow* window = NULL;
+       bool bstereoVisual;
+
+       if(stereoVisual)
+               bstereoVisual = true;
+       else
+               bstereoVisual = false;
+       
+       system->beginFullScreen(*setting, &window, bstereoVisual);
+
+       return (GHOST_WindowHandle)window;
+}
+
+
+
+GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+       return system->endFullScreen();
+}
+
+
+
+int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+       return (int) system->getFullScreen();
+}
+
+
+
+int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       
+       return (int) system->processEvents(waitForEvent?true:false);
+}
+
+
+
+int GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       
+       return (int) system->dispatchEvents();
+}
+
+
+GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       
+       return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
+}
+
+GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+       return system->removeEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
+}
+
+GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle,float progress)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setProgressBar(progress);
+}
+
+GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->endProgressBar();
+}
+
+
+int GHOST_OpenNDOF(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle,
+   GHOST_NDOFLibraryInit_fp setNdofLibraryInit, 
+    GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+    GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen)
+  //original patch only
+  /*  GHOST_NDOFEventHandler_fp setNdofEventHandler)*/
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+    return system->openNDOF((GHOST_IWindow*) windowhandle,
+        setNdofLibraryInit, setNdofLibraryShutdown, setNdofDeviceOpen);
+//     original patch
+//        setNdofLibraryInit, setNdofLibraryShutdown, setNdofDeviceOpen, setNdofEventHandler);
+}
+
+
+
+GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->getCursorShape();
+}
+
+
+
+GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
+                                                                       GHOST_TStandardCursor cursorshape)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setCursorShape(cursorshape);
+}
+
+GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
+                                                                                 GHOST_TUns8 bitmap[16][2], 
+                                                                                 GHOST_TUns8 mask[16][2], 
+                                                                                 int hotX, 
+                                                                                 int hotY)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setCustomCursorShape(bitmap, mask, hotX, hotY);
+}
+
+GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
+                                                                                 GHOST_TUns8 *bitmap, 
+                                                                                 GHOST_TUns8 *mask, 
+                                                                                 int sizex, 
+                                                                                 int sizey,
+                                                                                 int hotX, 
+                                                                                 int hotY, 
+                                                                                 int fg_color, 
+                                                                                 int bg_color)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setCustomCursorShape(bitmap, mask, sizex, sizey, 
+                                                                                               hotX, hotY, fg_color, bg_color);
+}
+
+
+
+int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return (int) window->getCursorVisibility();
+}
+
+
+
+GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle,
+                                                                                int visible)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setCursorVisibility(visible?true:false);
+}
+
+
+
+GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
+                                                                          GHOST_TInt32* x,
+                                                                          GHOST_TInt32* y)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       
+       return system->getCursorPosition(*x, *y);
+}
+
+
+
+GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
+                                                                          GHOST_TInt32 x,
+                                                                          GHOST_TInt32 y)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       
+       return system->setCursorPosition(x, y);
+}
+
+
+GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
+                                                                               GHOST_TGrabCursorMode mode,
+                                                                               int *bounds)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       GHOST_Rect bounds_rect, bounds_win;
+
+       if(bounds) {
+               /* if this is X11 specific we need a function that converts */
+               window->getClientBounds(bounds_win);
+               window->clientToScreen(bounds[0], bounds_win.getHeight() - bounds[1], bounds_rect.m_l, bounds_rect.m_t);
+               window->clientToScreen(bounds[2], bounds_win.getHeight() - bounds[3], bounds_rect.m_r, bounds_rect.m_b);
+
+       }
+       
+       return window->setCursorGrab(mode, bounds ? &bounds_rect:NULL);
+}
+
+
+GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
+                                                                                GHOST_TModifierKeyMask mask,
+                                                                                int* isDown)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       GHOST_TSuccess result;
+       bool isdown= false;
+       
+       result = system->getModifierKeyState(mask, isdown);
+       *isDown = (int) isdown;
+
+       return result;
+}
+
+
+
+GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
+                                                                       GHOST_TButtonMask mask,
+                                                                       int* isDown)
+{
+       GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+       GHOST_TSuccess result;
+       bool isdown= false;
+       
+       result = system->getButtonState(mask, isdown);
+       *isDown = (int) isdown;
+
+       return result;
+}
+
+
+void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       window->setAcceptDragOperation(canAccept);
+}
+
+
+GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
+{
+       GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
+       
+       return event->getType();
+}
+
+
+
+GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle)
+{
+       GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
+
+       return event->getTime();
+}
+
+
+GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle)
+{
+       GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
+
+       return (GHOST_WindowHandle) event->getWindow();
+}
+
+
+GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
+{
+       GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
+       
+       return event->getData();
+}
+
+
+
+GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle)
+{
+       GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
+       
+       return timertask->getTimerProc();
+}
+
+
+
+void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
+                                               GHOST_TimerProcPtr timerproc)
+{
+       GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
+       
+       timertask->setTimerProc(timerproc);
+}
+
+
+
+GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle)
+{
+       GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
+
+       return timertask->getUserData();
+}
+
+       
+
+void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
+                                                               GHOST_TUserDataPtr userdata)
+{
+       GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
+       
+       timertask->setUserData(userdata);
+}
+
+
+
+int GHOST_GetValid(GHOST_WindowHandle windowhandle) 
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return (int) window->getValid();
+}
+
+
+
+GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->getDrawingContextType();
+}
+
+
+
+GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle,
+                                                                                  GHOST_TDrawingContextType type)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setDrawingContextType(type);
+}
+
+
+
+void GHOST_SetTitle(GHOST_WindowHandle windowhandle,
+                                       const char* title)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       
+       window->setTitle(title);
+}
+
+
+char* GHOST_GetTitle(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       STR_String title;
+
+       window->getTitle(title);
+
+       char *ctitle = (char*) malloc(title.Length() + 1);
+
+       if (ctitle == NULL) return NULL;
+       strcpy(ctitle, title.Ptr());
+               
+       return ctitle;
+}
+
+
+
+GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle) 
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       GHOST_Rect* rectangle = NULL;
+
+       rectangle = new GHOST_Rect();
+       window->getWindowBounds(*rectangle);
+
+       return (GHOST_RectangleHandle)rectangle;
+}
+
+
+
+GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle) 
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       GHOST_Rect* rectangle = NULL;
+
+       rectangle = new GHOST_Rect();
+       window->getClientBounds(*rectangle);
+
+       return (GHOST_RectangleHandle)rectangle;
+}
+
+
+
+void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle)
+{
+       delete (GHOST_Rect*) rectanglehandle;
+}
+
+
+
+GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle,
+                                                                       GHOST_TUns32 width)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setClientWidth(width);
+}
+
+
+
+GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle,
+                                                                        GHOST_TUns32 height)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setClientHeight(height);
+}
+
+
+
+GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle,
+                                                                  GHOST_TUns32 width,
+                                                                  GHOST_TUns32 height)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setClientSize(width, height);
+}
+
+
+
+void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle,
+                                                 GHOST_TInt32 inX,
+                                                 GHOST_TInt32 inY,
+                                                 GHOST_TInt32* outX,
+                                                 GHOST_TInt32* outY) 
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       window->screenToClient(inX, inY, *outX, *outY);
+}
+
+
+
+void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle,
+                                                 GHOST_TInt32 inX,
+                                                 GHOST_TInt32 inY,
+                                                 GHOST_TInt32* outX,
+                                                 GHOST_TInt32* outY)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       window->clientToScreen(inX, inY, *outX, *outY);
+}
+
+
+
+GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->getState();
+}
+
+
+
+GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
+                                                                       GHOST_TWindowState state)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->setState(state);
+}
+
+
+GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       
+       return window->setModifiedState(isUnsavedChanges);
+}      
+
+
+GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
+                                                                       GHOST_TWindowOrder order)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       
+       return window->setOrder(order);
+}
+
+
+
+GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->swapBuffers();
+}
+
+
+
+GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+       
+       return window->activateDrawingContext();
+}
+
+
+
+GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
+{
+       GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+       return window->invalidate();
+}
+
+
+extern const GHOST_TabletData* GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
+{
+       return ((GHOST_IWindow*)windowhandle)->GetTabletData();
+}
+
+
+GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
+{
+       return ((GHOST_Rect*)rectanglehandle)->getWidth();
+}
+
+
+
+GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
+{
+       return ((GHOST_Rect*)rectanglehandle)->getHeight();
+}
+
+
+
+void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                          GHOST_TInt32* l,
+                                                          GHOST_TInt32* t,
+                                                          GHOST_TInt32* r,
+                                                          GHOST_TInt32* b)
+{
+       GHOST_Rect *rect= (GHOST_Rect*) rectanglehandle;
+       
+       *l= rect->m_l;
+       *t= rect->m_t;
+       *r= rect->m_r;
+       *b= rect->m_b;
+}
+
+
+void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
+                                               GHOST_TInt32 l,
+                                               GHOST_TInt32 t,
+                                               GHOST_TInt32 r,
+                                               GHOST_TInt32 b)
+{
+       ((GHOST_Rect*)rectanglehandle)->set(l, t, r, b);
+}
+
+
+
+GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle)
+{
+       GHOST_TSuccess result = GHOST_kFailure;
+
+       if (((GHOST_Rect*)rectanglehandle)->isEmpty())
+               result = GHOST_kSuccess;
+
+       return result;
+}
+
+
+
+GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle)
+{
+       GHOST_TSuccess result = GHOST_kFailure;
+
+       if(((GHOST_Rect*)rectanglehandle)->isValid())
+               result = GHOST_kSuccess;
+
+       return result;
+}
+
+
+
+void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                 GHOST_TInt32 i)
+{
+       ((GHOST_Rect*)rectanglehandle)->inset(i);
+}
+
+
+
+void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                 GHOST_RectangleHandle anotherrectanglehandle)
+{
+       ((GHOST_Rect*)rectanglehandle)->unionRect(*(GHOST_Rect*)anotherrectanglehandle);
+}
+
+
+
+void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                          GHOST_TInt32 x,
+                                                          GHOST_TInt32 y)
+{
+       ((GHOST_Rect*)rectanglehandle)->unionPoint(x, y);
+}
+
+
+
+GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                                          GHOST_TInt32 x,
+                                                                          GHOST_TInt32 y)
+{
+       GHOST_TSuccess result = GHOST_kFailure;
+
+       if (((GHOST_Rect*)rectanglehandle)->isInside(x, y))
+               result = GHOST_kSuccess;
+
+       return result;
+}
+
+
+
+GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle,
+                                                                                          GHOST_RectangleHandle anotherrectanglehandle)
+{
+       GHOST_TVisibility visible = GHOST_kNotVisible;
+
+       visible = ((GHOST_Rect*)rectanglehandle)->getVisibility(*(GHOST_Rect*)anotherrectanglehandle);
+
+       return visible;
+}
+
+
+
+void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                         GHOST_TInt32 cx,
+                                                         GHOST_TInt32 cy)
+{
+       ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy);
+}
+
+
+
+void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
+                                                         GHOST_TInt32 cx,
+                                                         GHOST_TInt32 cy,
+                                                         GHOST_TInt32 w,
+                                                         GHOST_TInt32 h)
+{
+       ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy, w, h);
+}
+
+
+
+GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
+                                                                  GHOST_RectangleHandle anotherrectanglehandle)
+{
+       GHOST_TSuccess result = GHOST_kFailure;
+
+       if (((GHOST_Rect*)rectanglehandle)->clip(*(GHOST_Rect*)anotherrectanglehandle))
+               result = GHOST_kSuccess;
+
+       return result;
+}
+
+GHOST_TUns8* GHOST_getClipboard(int selection)
+{
+       GHOST_ISystem* system = GHOST_ISystem::getSystem();
+       return system->getClipboard(selection);
+}
+
+void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
+{
+       GHOST_ISystem* system = GHOST_ISystem::getSystem();
+       system->putClipboard(buffer, selection);
+}
+
+int GHOST_toggleConsole(int action)
+{
+       GHOST_ISystem* system = GHOST_ISystem::getSystem();
+       return system->toggleConsole(action);
+}
diff --git a/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp b/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp
new file mode 100644 (file)
index 0000000..64ec784
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_CallbackEventConsumer.cpp
+ *  \ingroup GHOST
+ */
+
+
+/**
+
+ * $Id$
+ * Copyright (C) 2001 NaN Technologies B.V.
+ * @author     Maarten Gribnau
+ * @date       October 25, 2001
+ */
+
+#include "GHOST_Debug.h"
+#include "GHOST_C-api.h"
+#include "GHOST_CallbackEventConsumer.h"
+
+GHOST_CallbackEventConsumer::GHOST_CallbackEventConsumer(GHOST_EventCallbackProcPtr eventCallback,
+                                                                                                               GHOST_TUserDataPtr userData)
+{
+       m_eventCallback = eventCallback;
+       m_userData = userData;
+}
+
+
+bool GHOST_CallbackEventConsumer::processEvent(GHOST_IEvent* event)
+{
+       return m_eventCallback((GHOST_EventHandle)event, m_userData) != 0;
+}
diff --git a/intern/ghost/intern/GHOST_CallbackEventConsumer.h b/intern/ghost/intern/GHOST_CallbackEventConsumer.h
new file mode 100644 (file)
index 0000000..b0d8160
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_CallbackEventConsumer.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_CallbackEventConsumer class.
+ */
+
+#ifndef _GHOST_CALLBACK_EVENT_CONSUMER_H_
+#define _GHOST_CALLBACK_EVENT_CONSUMER_H_
+
+#include "GHOST_IEventConsumer.h"
+#include "GHOST_C-api.h"
+
+/**
+ * Event consumer that will forward events to a call-back routine.
+ * Especially useful for the C-API.
+ * @author     Maarten Gribnau
+ * @date       October 25, 2001
+ */
+class GHOST_CallbackEventConsumer : public GHOST_IEventConsumer
+{
+public:
+       /**
+        * Constructor.
+        * @param       eventCallback   The call-back routine invoked.
+        * @param       userData                The data passed back though the call-back routine.
+        */
+       GHOST_CallbackEventConsumer(
+               GHOST_EventCallbackProcPtr eventCallback, 
+               GHOST_TUserDataPtr userData);
+
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_CallbackEventConsumer(void)
+       {
+       }
+
+       /**
+        * This method is called by an event producer when an event is available.
+        * @param event The event that can be handled or ignored.
+        * @return Indication as to whether the event was handled.
+        */
+       virtual bool processEvent(GHOST_IEvent* event);
+
+protected:
+       /** The call-back routine invoked. */
+       GHOST_EventCallbackProcPtr      m_eventCallback;
+       /** The data passed back though the call-back routine. */
+       GHOST_TUserDataPtr                      m_userData;
+};
+
+#endif // _GHOST_CALLBACK_EVENT_CONSUMER_H_
+
diff --git a/intern/ghost/intern/GHOST_Debug.h b/intern/ghost/intern/GHOST_Debug.h
new file mode 100644 (file)
index 0000000..e77f3b9
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_Debug.h
+ *  \ingroup GHOST
+ * Macro's used in GHOST debug target.
+ */
+
+#ifndef _GHOST_DEBUG_H_
+#define _GHOST_DEBUG_H_
+
+#if defined(WIN32) && !defined(FREE_WINDOWS)
+       #ifdef DEBUG
+               #pragma warning (disable:4786) // suppress stl-MSVC debug info warning
+               // #define GHOST_DEBUG
+       #endif // DEBUG
+#endif // WIN32
+
+#ifdef BF_GHOST_DEBUG 
+       #define GHOST_DEBUG // spit ghost events to stdout
+#endif // BF_GHOST_DEBUG 
+
+#ifdef GHOST_DEBUG
+       #include <iostream>
+       #include <stdio.h> //for printf()
+#endif // GHOST_DEBUG
+
+
+#ifdef GHOST_DEBUG
+       #define GHOST_PRINT(x) { std::cout << x; }
+       #define GHOST_PRINTF(x, ...) { printf(x, __VA_ARGS__); }
+#else  // GHOST_DEBUG
+       #define GHOST_PRINT(x)
+       #define GHOST_PRINTF(x, ...)
+#endif // GHOST_DEBUG
+
+
+#ifdef GHOST_DEBUG
+       #define GHOST_ASSERT(x, info) { if (!(x)) {GHOST_PRINT("assertion failed: "); GHOST_PRINT(info); GHOST_PRINT("\n"); } }
+#else  // GHOST_DEBUG
+       #define GHOST_ASSERT(x, info)
+#endif // GHOST_DEBUG
+
+#endif // _GHOST_DEBUG_H_
+
diff --git a/intern/ghost/intern/GHOST_DisplayManager.cpp b/intern/ghost/intern/GHOST_DisplayManager.cpp
new file mode 100644 (file)
index 0000000..80466ef
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManager.cpp
+ *  \ingroup GHOST
+ */
+
+
+/**
+ * Copyright (C) 2001 NaN Technologies B.V.
+ * @author     Maarten Gribnau
+ * @date       September 21, 2001
+ */
+
+#include "GHOST_DisplayManager.h"
+#include "GHOST_Debug.h"
+
+
+GHOST_DisplayManager::GHOST_DisplayManager(
+       void)
+: m_settingsInitialized(false)
+{
+}
+
+
+GHOST_DisplayManager::~GHOST_DisplayManager(void)
+{
+}
+
+
+GHOST_TSuccess
+GHOST_DisplayManager::initialize(
+       void)
+{
+       GHOST_TSuccess success;
+       if (!m_settingsInitialized) {
+               success = initializeSettings();
+               m_settingsInitialized = true;
+       }
+       else {
+               success = GHOST_kSuccess;
+       }
+       return success;
+}
+
+
+GHOST_TSuccess
+GHOST_DisplayManager::getNumDisplays(
+       GHOST_TUns8& /*numDisplays*/) const
+{
+       // Don't know if we have a display...
+       return GHOST_kFailure;
+}
+
+
+GHOST_TSuccess
+GHOST_DisplayManager::getNumDisplaySettings(
+       GHOST_TUns8 display, 
+       GHOST_TInt32& numSettings) const
+{
+       GHOST_TSuccess success;
+
+       GHOST_ASSERT(m_settingsInitialized, "GHOST_DisplayManager::getNumDisplaySettings(): m_settingsInitialized=false");
+       GHOST_TUns8 numDisplays;
+       success = getNumDisplays(numDisplays);
+       if (success == GHOST_kSuccess) {
+               if (display < numDisplays) {
+                       numSettings = m_settings[display].size();
+               }
+               else {
+                       success = GHOST_kFailure;
+               }
+       }
+       return success;
+}
+
+
+GHOST_TSuccess
+GHOST_DisplayManager::getDisplaySetting(
+       GHOST_TUns8 display, 
+       GHOST_TInt32 index, 
+       GHOST_DisplaySetting& setting) const
+{
+       GHOST_TSuccess success;
+
+       GHOST_ASSERT(m_settingsInitialized, "GHOST_DisplayManager::getNumDisplaySettings(): m_settingsInitialized=false");
+       GHOST_TUns8 numDisplays;
+       success = getNumDisplays(numDisplays);
+       if (success == GHOST_kSuccess) {
+               if (display < numDisplays && ((GHOST_TUns8)index < m_settings[display].size())) {
+                       setting = m_settings[display][index];
+               }
+               else {
+                       success = GHOST_kFailure;
+               }
+       }
+       return success;
+}
+
+
+GHOST_TSuccess
+GHOST_DisplayManager::getCurrentDisplaySetting(
+       GHOST_TUns8 /*display*/,
+       GHOST_DisplaySetting& /*setting*/) const
+{
+       return GHOST_kFailure;
+}
+
+
+GHOST_TSuccess
+GHOST_DisplayManager::setCurrentDisplaySetting(
+       GHOST_TUns8 /*display*/,
+       const GHOST_DisplaySetting& /*setting*/)
+{
+       return GHOST_kFailure;
+}
+
+
+GHOST_TSuccess
+GHOST_DisplayManager::findMatch(
+       GHOST_TUns8 display, 
+       const GHOST_DisplaySetting& setting, 
+       GHOST_DisplaySetting& match) const
+{
+       GHOST_TSuccess success = GHOST_kSuccess;
+       GHOST_ASSERT(m_settingsInitialized, "GHOST_DisplayManager::findMatch(): m_settingsInitialized=false");
+
+       int criteria[4] = { setting.xPixels, setting.yPixels, setting.bpp, setting.frequency };
+       int capabilities[4];
+       double field, score;
+       double best = 1e12; // A big number
+       int found = 0;
+
+       // Look at all the display modes
+       for (int i = 0; (i < (int)m_settings[display].size()); i++) {
+               // Store the capabilities of the display device
+               capabilities[0] = m_settings[display][i].xPixels;
+               capabilities[1] = m_settings[display][i].yPixels;
+               capabilities[2] = m_settings[display][i].bpp;
+               capabilities[3] = m_settings[display][i].frequency;
+
+               // Match against all the fields of the display settings
+               score = 0;
+               for (int j = 0; j < 4; j++) {
+                       field = capabilities[j] - criteria[j];
+                       score += field * field;
+               }
+
+               if (score < best) {
+                       found = i;
+                       best = score;
+               }
+       }
+       
+       match = m_settings[display][found];
+       
+       GHOST_PRINT("GHOST_DisplayManager::findMatch(): settings of match:\n");
+       GHOST_PRINT("  setting.xPixels=" << match.xPixels << "\n");
+       GHOST_PRINT("  setting.yPixels=" << match.yPixels << "\n");
+       GHOST_PRINT("  setting.bpp=" << match.bpp << "\n");
+       GHOST_PRINT("  setting.frequency=" << match.frequency << "\n");
+
+       return success;
+}
+
+
+GHOST_TSuccess
+GHOST_DisplayManager::initializeSettings(
+       void)
+{
+       GHOST_TUns8 numDisplays;
+       GHOST_TSuccess success = getNumDisplays(numDisplays);
+       if (success == GHOST_kSuccess) {
+               for (GHOST_TUns8 display = 0; (display < numDisplays) && (success == GHOST_kSuccess); display++) {
+                       GHOST_DisplaySettings displaySettings;
+                       m_settings.push_back(displaySettings);
+                       GHOST_TInt32 numSettings;
+                       success = getNumDisplaySettings(display, numSettings);
+                       if (success == GHOST_kSuccess) {
+                               GHOST_TInt32 index;
+                               GHOST_DisplaySetting setting;
+                               for (index = 0; (index < numSettings) && (success == GHOST_kSuccess); index++) {
+                                       success = getDisplaySetting(display, index, setting);
+                                       m_settings[display].push_back(setting);
+                               }
+                       }
+                       else {
+                               break;
+                       }
+               }
+       }
+       return success;
+}
diff --git a/intern/ghost/intern/GHOST_DisplayManager.h b/intern/ghost/intern/GHOST_DisplayManager.h
new file mode 100644 (file)
index 0000000..16e702f
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManager.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_DisplayManager class.
+ */
+
+#ifndef _GHOST_DISPLAY_MANAGER_H_
+#define _GHOST_DISPLAY_MANAGER_H_
+
+#include "GHOST_Types.h"
+
+#include <vector>
+
+/**
+ * Manages system displays  (platform independent implementation).
+ * @author     Maarten Gribnau
+ * @date       September 21, 2001
+ */
+class GHOST_DisplayManager
+{
+public:
+       enum { kMainDisplay = 0 };
+       /**
+        * Constructor.
+        */
+       GHOST_DisplayManager(void);
+       
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_DisplayManager(void);
+
+       /**
+        * Initializes the list with devices and settings.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess initialize(void);
+
+       /**
+        * Returns the number of display devices on this system.
+        * @param numDisplays The number of displays on this system.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getNumDisplays(GHOST_TUns8& numDisplays) const;
+
+       /**
+        * Returns the number of display settings for this display device.
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The number of settings of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param index   The setting index to be returned.
+        * @param setting The setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const;
+
+       /**
+        * Changes the current setting for this display device.
+        * The setting given to this method is matched againts the available diplay settings.
+        * The best match is activated (@see findMatch()).
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The setting of the display device to be matched and activated.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting);
+
+protected:
+       typedef std::vector<GHOST_DisplaySetting> GHOST_DisplaySettings;
+
+       /**
+        * Finds the best display settings match.
+        * @param display       The index of the display device.
+        * @param setting       The setting to match.
+        * @param match         The optimal display setting.
+        * @return Indication of success.
+        */
+       GHOST_TSuccess findMatch(GHOST_TUns8 display, const GHOST_DisplaySetting& setting, GHOST_DisplaySetting& match) const;
+
+       /**
+        * Retrieves settings for each display device and stores them.
+        * @return Indication of success.
+        */
+       GHOST_TSuccess initializeSettings(void);
+       
+       /** Tells whether the list of display modes has been stored already. */
+       bool m_settingsInitialized;
+       /** The list with display settings for the main display. */
+       std::vector<GHOST_DisplaySettings> m_settings;
+};
+
+
+#endif // _GHOST_DISPLAY_MANAGER_H_
+
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp b/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp
new file mode 100644 (file)
index 0000000..077b380
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerCarbon.cpp
+ *  \ingroup GHOST
+ */
+
+
+/**
+
+ * $Id$
+ * Copyright (C) 2001 NaN Technologies B.V.
+ * @author     Maarten Gribnau
+ * @date       September 21, 2001
+ */
+
+#include "GHOST_DisplayManagerCarbon.h"
+#include "GHOST_Debug.h"
+
+// We do not support multiple monitors at the moment
+
+
+GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(void)
+{
+       if (::CGGetActiveDisplayList(0, NULL, &m_numDisplays) != CGDisplayNoErr)
+       {
+               m_numDisplays = 0;
+               m_displayIDs = NULL;
+       }
+       if (m_numDisplays > 0)
+       {
+               m_displayIDs = new CGDirectDisplayID [m_numDisplays];
+               GHOST_ASSERT((m_displayIDs!=NULL), "GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(): memory allocation failed");
+               ::CGGetActiveDisplayList(m_numDisplays, m_displayIDs, &m_numDisplays);
+       }
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplays(GHOST_TUns8& numDisplays) const
+{
+       numDisplays = (GHOST_TUns8) m_numDisplays;
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCarbon::getNumDisplaySettings(): only main display is supported");
+       
+       CFArrayRef displayModes;
+       displayModes = ::CGDisplayAvailableModes(m_displayIDs[display]);
+       CFIndex numModes = ::CFArrayGetCount(displayModes);
+       numSettings = (GHOST_TInt32)numModes;
+       
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCarbon::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCarbon::getDisplaySetting(): only main display is supported");
+       
+       CFArrayRef displayModes;
+       CGDirectDisplayID d = m_displayIDs[display];
+       displayModes = ::CGDisplayAvailableModes(d);
+       //CFIndex numModes = ::CFArrayGetCount(displayModes);/*unused*/
+       //GHOST_TInt32 numSettings = (GHOST_TInt32)numModes; /*unused*/
+        CFDictionaryRef displayModeValues = (CFDictionaryRef)::CFArrayGetValueAtIndex(displayModes, index);
+                       
+       setting.xPixels         = getValue(displayModeValues, kCGDisplayWidth);
+       setting.yPixels         = getValue(displayModeValues, kCGDisplayHeight);
+       setting.bpp                     = getValue(displayModeValues, kCGDisplayBitsPerPixel);
+       setting.frequency       = getValue(displayModeValues, kCGDisplayRefreshRate);
+                       
+#ifdef GHOST_DEBUG
+       printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
+#endif // GHOST_DEBUG
+
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(): only main display is supported");
+        
+       CFDictionaryRef displayModeValues = ::CGDisplayCurrentMode(m_displayIDs[display]);
+       
+       setting.xPixels         = getValue(displayModeValues, kCGDisplayWidth);
+       setting.yPixels         = getValue(displayModeValues, kCGDisplayHeight);
+       setting.bpp                     = getValue(displayModeValues, kCGDisplayBitsPerPixel);
+       setting.frequency       = getValue(displayModeValues, kCGDisplayRefreshRate);
+
+#ifdef GHOST_DEBUG
+       printf("current display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
+#endif // GHOST_DEBUG
+
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting)
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): only main display is supported");
+
+#ifdef GHOST_DEBUG
+       printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): requested settings:\n");
+       printf("  setting.xPixels=%d\n", setting.xPixels);
+       printf("  setting.yPixels=%d\n", setting.yPixels);
+       printf("  setting.bpp=%d\n", setting.bpp);
+       printf("  setting.frequency=%d\n", setting.frequency);
+#endif // GHOST_DEBUG
+
+       CFDictionaryRef displayModeValues = ::CGDisplayBestModeForParametersAndRefreshRate(
+               m_displayIDs[display],
+               (size_t)setting.bpp,
+               (size_t)setting.xPixels,
+               (size_t)setting.yPixels,
+               (CGRefreshRate)setting.frequency,
+               NULL);
+
+#ifdef GHOST_DEBUG
+       printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): switching to:\n");
+       printf("  setting.xPixels=%d\n", getValue(displayModeValues, kCGDisplayWidth));
+       printf("  setting.yPixels=%d\n", getValue(displayModeValues, kCGDisplayHeight));
+       printf("  setting.bpp=%d\n", getValue(displayModeValues, kCGDisplayBitsPerPixel));
+       printf("  setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate));
+#endif // GHOST_DEBUG
+
+       CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
+        
+       return err == CGDisplayNoErr ? GHOST_kSuccess : GHOST_kFailure;
+}
+
+
+long GHOST_DisplayManagerCarbon::getValue(CFDictionaryRef values, CFStringRef key) const
+{
+    CFNumberRef numberValue = (CFNumberRef) CFDictionaryGetValue(values, key);
+    
+    if (!numberValue)
+    {
+        return -1;
+    }
+    
+    long intValue;
+    
+    if (!CFNumberGetValue(numberValue, kCFNumberLongType, &intValue))
+    {
+        return -1;
+    }
+    
+    return intValue;
+}
+
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.h b/intern/ghost/intern/GHOST_DisplayManagerCarbon.h
new file mode 100644 (file)
index 0000000..6637bee
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerCarbon.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_DisplayManagerCarbon class.
+ */
+
+#ifndef _GHOST_DISPLAY_MANAGER_CARBON_H_
+#define _GHOST_DISPLAY_MANAGER_CARBON_H_
+
+#ifndef __APPLE__
+#error Apple only!
+#endif // __APPLE__
+
+#include "GHOST_DisplayManager.h"
+
+#define __CARBONSOUND__
+#include <Carbon/Carbon.h>
+
+/**
+ * Manages system displays  (Mac OSX/Carbon implementation).
+ * @see GHOST_DisplayManager
+ * @author     Maarten Gribnau
+ * @date       September 21, 2001
+ */
+class GHOST_DisplayManagerCarbon : public GHOST_DisplayManager
+{
+public:
+       /**
+        * Constructor.
+        */
+       GHOST_DisplayManagerCarbon(void);
+
+       /**
+        * Returns the number of display devices on this system.
+        * @param numDisplays The number of displays on this system.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getNumDisplays(GHOST_TUns8& numDisplays) const;
+
+       /**
+        * Returns the number of display settings for this display device.
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The number of settings of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param index   The setting index to be returned.
+        * @param setting The setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const;
+
+       /**
+        * Changes the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting);
+
+protected:
+       /**
+        * Returns a value from a dictionary.
+        * @param       values  Dictionary to return value from.
+        * @param       key     Key to return value for.
+        * @return The value for this key.
+        */
+       long getValue(CFDictionaryRef values, CFStringRef key) const;
+       
+       /** Cached number of displays. */
+       CGDisplayCount m_numDisplays;
+       /** Cached display id's for each display. */
+       CGDirectDisplayID* m_displayIDs;
+};
+
+
+#endif // _GHOST_DISPLAY_MANAGER_CARBON_H_
+
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
new file mode 100644 (file)
index 0000000..2248019
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerCocoa.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_DisplayManagerCocoa class.
+ */
+
+#ifndef _GHOST_DISPLAY_MANAGER_COCOA_H_
+#define _GHOST_DISPLAY_MANAGER_COCOA_H_
+
+#ifndef __APPLE__
+#error Apple only!
+#endif // __APPLE__
+
+#include "GHOST_DisplayManager.h"
+
+/**
+ * Manages system displays  (Mac OSX/Cocoa implementation).
+ * @see GHOST_DisplayManager
+ * @author     Maarten Gribnau
+ * @date       September 21, 2001
+ */
+class GHOST_DisplayManagerCocoa : public GHOST_DisplayManager
+{
+public:
+       /**
+        * Constructor.
+        */
+       GHOST_DisplayManagerCocoa(void);
+
+       /**
+        * Returns the number of display devices on this system.
+        * @param numDisplays The number of displays on this system.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getNumDisplays(GHOST_TUns8& numDisplays) const;
+
+       /**
+        * Returns the number of display settings for this display device.
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The number of settings of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param index   The setting index to be returned.
+        * @param setting The setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const;
+
+       /**
+        * Changes the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting);
+
+protected:     
+       //Do not cache values as OS X supports screen hot plug
+       /** Cached number of displays. */
+       //CGDisplayCount m_numDisplays;
+       /** Cached display id's for each display. */
+       //CGDirectDisplayID* m_displayIDs;
+};
+
+
+#endif // _GHOST_DISPLAY_MANAGER_COCOA_H_
+
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
new file mode 100644 (file)
index 0000000..ab3abdd
--- /dev/null
@@ -0,0 +1,168 @@
+/**
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s):     Maarten Gribnau 09/2001
+                                       Damien Plisson  10/2009
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <Cocoa/Cocoa.h>
+
+#include "GHOST_DisplayManagerCocoa.h"
+#include "GHOST_Debug.h"
+
+// We do not support multiple monitors at the moment
+
+
+GHOST_DisplayManagerCocoa::GHOST_DisplayManagerCocoa(void)
+{
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::getNumDisplays(GHOST_TUns8& numDisplays) const
+{
+       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+       
+       numDisplays = (GHOST_TUns8) [[NSScreen screens] count];
+       
+       [pool drain];
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getNumDisplaySettings(): only main display is supported");
+       
+       numSettings = (GHOST_TInt32)3; //Width, Height, BitsPerPixel
+       
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const
+{
+       //Note that only current display setting is available
+       NSScreen *askedDisplay;
+       
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getDisplaySetting(): only main display is supported");
+       
+       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+       
+       if (display == kMainDisplay) //Screen #0 may not be the main one
+               askedDisplay = [NSScreen mainScreen];
+       else
+               askedDisplay = [[NSScreen screens] objectAtIndex:display];
+       
+       if(askedDisplay == nil) {
+               [pool drain];
+               return GHOST_kFailure;
+       }
+       
+       NSRect frame = [askedDisplay visibleFrame];
+       setting.xPixels = frame.size.width;
+       setting.yPixels = frame.size.height;
+       
+       setting.bpp = NSBitsPerPixelFromDepth([askedDisplay depth]);
+       
+       setting.frequency = 0; //No more CRT display...
+                               
+#ifdef GHOST_DEBUG
+       printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
+#endif // GHOST_DEBUG
+
+       [pool drain];
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const
+{
+       NSScreen *askedDisplay;
+       
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getCurrentDisplaySetting(): only main display is supported");
+    
+       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];     
+
+       if (display == kMainDisplay) //Screen #0 may not be the main one
+               askedDisplay = [NSScreen mainScreen];
+       else
+               askedDisplay = [[NSScreen screens] objectAtIndex:display];
+       
+       if(askedDisplay == nil) {
+               [pool drain];
+               return GHOST_kFailure;
+       }
+       
+       NSRect frame = [askedDisplay visibleFrame];
+       setting.xPixels = frame.size.width;
+       setting.yPixels = frame.size.height;
+       
+       setting.bpp = NSBitsPerPixelFromDepth([askedDisplay depth]);
+       
+       setting.frequency = 0; //No more CRT display...
+
+#ifdef GHOST_DEBUG
+       printf("current display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
+#endif // GHOST_DEBUG
+
+       [pool drain];
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting)
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): only main display is supported");
+
+#ifdef GHOST_DEBUG
+       printf("GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): requested settings:\n");
+       printf("  setting.xPixels=%d\n", setting.xPixels);
+       printf("  setting.yPixels=%d\n", setting.yPixels);
+       printf("  setting.bpp=%d\n", setting.bpp);
+       printf("  setting.frequency=%d\n", setting.frequency);
+#endif // GHOST_DEBUG
+
+       //Display configuration is no more available in 10.6
+       
+/*     CFDictionaryRef displayModeValues = ::CGDisplayBestModeForParametersAndRefreshRate(
+               m_displayIDs[display],
+               (size_t)setting.bpp,
+               (size_t)setting.xPixels,
+               (size_t)setting.yPixels,
+               (CGRefreshRate)setting.frequency,
+               NULL);*/
+
+#ifdef GHOST_DEBUG
+/*     printf("GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): switching to:\n");
+       printf("  setting.xPixels=%d\n", getValue(displayModeValues, kCGDisplayWidth));
+       printf("  setting.yPixels=%d\n", getValue(displayModeValues, kCGDisplayHeight));
+       printf("  setting.bpp=%d\n", getValue(displayModeValues, kCGDisplayBitsPerPixel));
+       printf("  setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate)); */
+#endif // GHOST_DEBUG
+
+       //CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
+        
+       return /*err == CGDisplayNoErr ? GHOST_kSuccess :*/ GHOST_kFailure;
+}
diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
new file mode 100644 (file)
index 0000000..30d9aa3
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerWin32.cpp
+ *  \ingroup GHOST
+ *  \author    Maarten Gribnau
+ *  \date      September 21, 2001
+ */
+
+#include "GHOST_DisplayManagerWin32.h"
+#include "GHOST_Debug.h"
+
+// We do not support multiple monitors at the moment
+#include <windows.h>
+#define COMPILE_MULTIMON_STUBS
+#ifndef FREE_WINDOWS
+#include <multimon.h>
+#endif
+
+
+GHOST_DisplayManagerWin32::GHOST_DisplayManagerWin32(void)
+{
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplays(GHOST_TUns8& numDisplays) const
+{
+       // We do not support multiple monitors at the moment
+       numDisplays = ::GetSystemMetrics(SM_CMONITORS);
+       return numDisplays > 0 ? GHOST_kSuccess : GHOST_kFailure;
+}
+
+
+/*
+ * When you call EnumDisplaySettings with iModeNum set to zero, the operating system 
+ * initializes and caches information about the display device. When you call 
+ * EnumDisplaySettings with iModeNum set to a non-zero value, the function returns 
+ * the information that was cached the last time the function was called with iModeNum
+ * set to zero. 
+ */
+GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerWin32::getNumDisplaySettings(): only main displlay is supported");
+       numSettings = 0;
+       DEVMODE dm;
+       while (::EnumDisplaySettings(NULL, numSettings, &dm)) {
+               numSettings++;
+       }
+       return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerWin32::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerWin32::getDisplaySetting(): only main display is supported");
+       GHOST_TSuccess success;
+       DEVMODE dm;
+       if (::EnumDisplaySettings(NULL, index, &dm)) {
+#ifdef GHOST_DEBUG
+               printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency);
+#endif // GHOST_DEBUG
+               setting.xPixels         = dm.dmPelsWidth;
+               setting.yPixels         = dm.dmPelsHeight;
+               setting.bpp                     = dm.dmBitsPerPel;
+               /* When you call the EnumDisplaySettings function, the dmDisplayFrequency member
+                * may return with the value 0 or 1. These values represent the display hardware's
+                * default refresh rate. This default rate is typically set by switches on a display 
+                * card or computer motherboard, or by a configuration program that does not use 
+                * Win32 display functions such as ChangeDisplaySettings. 
+                */
+               /* First, we tried to explicitly set the frequency to 60 if EnumDisplaySettings
+                * returned 0 or 1 but this doesn't work since later on an exact match will
+                * be searched. And this will never happen if we change it to 60. Now we rely
+                * on the default h/w setting.
+                */
+               setting.frequency = dm.dmDisplayFrequency;
+               success = GHOST_kSuccess;
+       }
+       else {
+               success = GHOST_kFailure;
+       }
+       return success;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerWin32::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerWin32::getCurrentDisplaySetting(): only main display is supported");
+       return getDisplaySetting(kMainDisplay, ENUM_CURRENT_SETTINGS, setting);
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerWin32::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting)
+{
+       GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerWin32::setCurrentDisplaySetting(): only main display is supported");
+
+       GHOST_DisplaySetting match;
+       findMatch(display, setting, match);
+       DEVMODE dm;
+       int i = 0;
+       while (::EnumDisplaySettings(NULL, i++, &dm)) {
+               if ((dm.dmBitsPerPel == match.bpp) &&
+                       (dm.dmPelsWidth == match.xPixels) &&
+                       (dm.dmPelsHeight == match.yPixels) &&
+                       (dm.dmDisplayFrequency == match.frequency)) {
+                       break;
+               }
+       }
+       /*
+       dm.dmBitsPerPel = match.bpp;
+       dm.dmPelsWidth = match.xPixels;
+       dm.dmPelsHeight = match.yPixels;
+       dm.dmDisplayFrequency = match.frequency;
+       dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
+       dm.dmSize = sizeof(DEVMODE);
+       dm.dmDriverExtra = 0;
+       */
+#ifdef GHOST_DEBUG
+       printf("display change: Requested settings:\n");
+       printf("  dmBitsPerPel=%d\n", dm.dmBitsPerPel);
+       printf("  dmPelsWidth=%d\n", dm.dmPelsWidth);
+       printf("  dmPelsHeight=%d\n", dm.dmPelsHeight);
+       printf("  dmDisplayFrequency=%d\n", dm.dmDisplayFrequency);
+#endif // GHOST_DEBUG
+
+       LONG status = ::ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
+#ifdef GHOST_DEBUG
+       switch (status)
+       {
+       case DISP_CHANGE_SUCCESSFUL:
+               printf("display change: The settings change was successful.\n");
+               break;
+       case DISP_CHANGE_RESTART:
+               printf("display change: The computer must be restarted in order for the graphics mode to work.\n");
+               break;
+       case DISP_CHANGE_BADFLAGS:
+               printf("display change: An invalid set of flags was passed in.\n");
+               break;
+       case DISP_CHANGE_BADPARAM:
+               printf("display change: An invalid parameter was passed in. This can include an invalid flag or combination of flags.\n");
+               break;
+       case DISP_CHANGE_FAILED:
+               printf("display change: The display driver failed the specified graphics mode.\n");
+               break;
+       case DISP_CHANGE_BADMODE:
+               printf("display change: The graphics mode is not supported.\n");
+               break;
+       case DISP_CHANGE_NOTUPDATED:
+               printf("display change: Windows NT: Unable to write settings to the registry.\n");
+               break;
+       default:
+               printf("display change: Return value invalid\n");
+               break;
+       }
+#endif // GHOST_DEBUG
+       return status == DISP_CHANGE_SUCCESSFUL? GHOST_kSuccess : GHOST_kFailure;
+}
diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.h b/intern/ghost/intern/GHOST_DisplayManagerWin32.h
new file mode 100644 (file)
index 0000000..9a3a79f
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerWin32.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_DisplayManagerWin32 class.
+ */
+
+#ifndef _GHOST_DISPLAY_MANAGER_WIN32_H_
+#define _GHOST_DISPLAY_MANAGER_WIN32_H_
+
+#ifndef WIN32
+#error WIN32 only!
+#endif // WIN32
+
+#include "GHOST_DisplayManager.h"
+
+
+/**
+ * Manages system displays  (WIN32 implementation).
+ * @author     Maarten Gribnau
+ * @date       September 21, 2001
+ */
+class GHOST_DisplayManagerWin32 : public GHOST_DisplayManager
+{
+public:
+       /**
+        * Constructor.
+        */
+       GHOST_DisplayManagerWin32(void);
+
+       /**
+        * Returns the number of display devices on this system.
+        * @param numDisplays The number of displays on this system.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getNumDisplays(GHOST_TUns8& numDisplays) const;
+
+       /**
+        * Returns the number of display settings for this display device.
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The number of settings of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param index   The setting index to be returned.
+        * @param setting The setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const;
+
+       /**
+        * Changes the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+       virtual GHOST_TSuccess setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting);
+
+protected:
+};
+
+
+#endif // _GHOST_DISPLAY_MANAGER_WIN32_H_
+
diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp
new file mode 100644 (file)
index 0000000..fe5e447
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerX11.cpp
+ *  \ingroup GHOST
+ */
+
+
+#include "GHOST_DisplayManagerX11.h"
+#include "GHOST_SystemX11.h"
+
+
+
+GHOST_DisplayManagerX11::
+GHOST_DisplayManagerX11(
+       GHOST_SystemX11 *system
+) :
+       GHOST_DisplayManager(),
+       m_system(system)
+{
+       //nothing to do.
+}
+
+       GHOST_TSuccess 
+GHOST_DisplayManagerX11::
+getNumDisplays(
+       GHOST_TUns8& numDisplays
+) const{       
+       numDisplays =  m_system->getNumDisplays();
+       return GHOST_kSuccess;
+}
+
+
+       GHOST_TSuccess 
+GHOST_DisplayManagerX11::
+getNumDisplaySettings(
+       GHOST_TUns8 display,
+       GHOST_TInt32& numSettings
+) const{
+       
+       // We only have one X11 setting at the moment.
+       GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");    
+       numSettings = GHOST_TInt32(1);
+       return GHOST_kSuccess;
+}
+
+       GHOST_TSuccess 
+GHOST_DisplayManagerX11::
+getDisplaySetting(
+       GHOST_TUns8 display,
+       GHOST_TInt32 index,
+       GHOST_DisplaySetting& setting
+) const {
+       
+       GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");    
+       GHOST_ASSERT(index < 1, "Requested setting outside of valid range.\n"); 
+       
+       Display * x_display = m_system->getXDisplay();
+
+       if (x_display == NULL) {
+               return GHOST_kFailure;
+       }
+
+       setting.xPixels  = DisplayWidth(x_display, DefaultScreen(x_display));
+       setting.yPixels = DisplayHeight(x_display, DefaultScreen(x_display));
+       setting.bpp = DefaultDepth(x_display,DefaultScreen(x_display));
+
+       // Don't think it's possible to get this value from X!
+       // So let's guess!!
+       setting.frequency = 60;
+
+       return GHOST_kSuccess;
+}
+       
+       GHOST_TSuccess 
+GHOST_DisplayManagerX11::
+getCurrentDisplaySetting(
+       GHOST_TUns8 display,
+       GHOST_DisplaySetting& setting
+) const {
+       return getDisplaySetting(display,GHOST_TInt32(0),setting);
+}
+
+
+       GHOST_TSuccess 
+GHOST_DisplayManagerX11::
+setCurrentDisplaySetting(
+       GHOST_TUns8 display,
+       const GHOST_DisplaySetting& setting
+){
+       // This is never going to work robustly in X 
+       // but it's currently part of the full screen interface
+
+       // we fudge it for now.
+
+       return GHOST_kSuccess;
+}
+
+
+
+
diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.h b/intern/ghost/intern/GHOST_DisplayManagerX11.h
new file mode 100644 (file)
index 0000000..435d438
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerX11.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_DisplayManagerX11 class.
+ */
+
+#ifndef _GHOST_DISPLAY_MANAGER_X11_H_
+#define _GHOST_DISPLAY_MANAGER_X11_H_
+
+#include "GHOST_DisplayManager.h"
+
+
+class GHOST_SystemX11;
+
+/**
+ * Manages system displays  (X11 implementation).
+ * @author     Laurence Bourn
+ * @date       October 26, 2001
+ */
+class GHOST_DisplayManagerX11 : public GHOST_DisplayManager
+{
+public:
+       /**
+        * Constructor.
+        */
+       GHOST_DisplayManagerX11(
+               GHOST_SystemX11 *system
+       );
+
+       /**
+        * Returns the number of display devices on this system.
+        * @param numDisplays The number of displays on this system.
+        * @return Indication of success.
+        */
+               GHOST_TSuccess 
+       getNumDisplays(
+               GHOST_TUns8& numDisplays
+       ) const;
+
+       /**
+        * Returns the number of display settings for this display device.
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The number of settings of the display device with this index.
+        * @return Indication of success.
+        */
+               GHOST_TSuccess 
+       getNumDisplaySettings(
+               GHOST_TUns8 display,
+               GHOST_TInt32& numSettings
+       ) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param index   The setting index to be returned.
+        * @param setting The setting of the display device with this index.
+        * @return Indication of success.
+        */
+               GHOST_TSuccess 
+       getDisplaySetting(
+               GHOST_TUns8 display,
+               GHOST_TInt32 index,
+               GHOST_DisplaySetting& setting
+       ) const;
+
+       /**
+        * Returns the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+               GHOST_TSuccess 
+       getCurrentDisplaySetting(
+               GHOST_TUns8 display,
+               GHOST_DisplaySetting& setting
+       ) const;
+
+       /**
+        * Changes the current setting for this display device. 
+        * @param display The index of the display to query with 0 <= display < getNumDisplays().
+        * @param setting The current setting of the display device with this index.
+        * @return Indication of success.
+        */
+               GHOST_TSuccess 
+       setCurrentDisplaySetting(
+               GHOST_TUns8 display,
+               const GHOST_DisplaySetting& setting
+       );
+
+private :
+
+       GHOST_SystemX11 * m_system;
+};
+
+
+#endif // 
+
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
new file mode 100644 (file)
index 0000000..2e77da4
--- /dev/null
@@ -0,0 +1,431 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DropTargetWin32.cpp
+ *  \ingroup GHOST
+ */
+
+#include "GHOST_Debug.h"
+#include "GHOST_DropTargetWin32.h"
+
+#ifdef GHOST_DEBUG
+// utility
+void printLastError(void);
+#endif // GHOST_DEBUG
+
+
+GHOST_DropTargetWin32::GHOST_DropTargetWin32(GHOST_WindowWin32 * window, GHOST_SystemWin32 * system)
+:
+m_window(window),
+m_system(system)
+{
+       m_cRef = 1;
+       m_hWnd = window->getHWND();
+       m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
+       
+       // register our window as drop target
+       ::RegisterDragDrop(m_hWnd, this);
+}
+
+GHOST_DropTargetWin32::~GHOST_DropTargetWin32()
+{
+       ::RevokeDragDrop(m_hWnd);
+}
+
+
+/* 
+ *     IUnknown::QueryInterface
+ */
+HRESULT __stdcall GHOST_DropTargetWin32::QueryInterface (REFIID riid, void ** ppvObj)
+{
+
+       if (!ppvObj)
+               return E_INVALIDARG;
+       *ppvObj = NULL;
+
+       if(riid == IID_IUnknown || riid == IID_IDropTarget)
+       {
+               AddRef();
+               *ppvObj = (void*)this;
+               return S_OK;
+       }
+       else
+       {
+               *ppvObj = 0;
+               return E_NOINTERFACE;
+       }
+}
+
+
+/* 
+ *     IUnknown::AddRef 
+ */
+
+ULONG __stdcall GHOST_DropTargetWin32::AddRef(void)
+{
+       return ::InterlockedIncrement(&m_cRef);
+}
+
+/* 
+ * IUnknown::Release
+ */
+ULONG __stdcall GHOST_DropTargetWin32::Release(void)
+{
+       ULONG refs = ::InterlockedDecrement(&m_cRef);
+               
+       if(refs == 0)
+       {
+               delete this;
+               return 0;
+       }
+       else
+       {
+               return refs;
+       }
+}
+
+/* 
+ * Implementation of IDropTarget::DragEnter
+ */
+HRESULT __stdcall GHOST_DropTargetWin32::DragEnter(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect)
+{
+       // we accept all drop by default
+       m_window->setAcceptDragOperation(true);
+       *pdwEffect = DROPEFFECT_NONE;
+       
+       m_draggedObjectType = getGhostType(pDataObject);
+       m_system->pushDragDropEvent(GHOST_kEventDraggingEntered, m_draggedObjectType, m_window, pt.x, pt.y, NULL);
+       return S_OK;
+}
+
+/* 
+ * Implementation of IDropTarget::DragOver
+ */
+HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD grfKeyState, POINTL pt, DWORD * pdwEffect)
+{
+       if(m_window->canAcceptDragOperation())
+       {
+               *pdwEffect = allowedDropEffect(*pdwEffect);
+       }
+       else
+       {
+               *pdwEffect = DROPEFFECT_NONE;
+               //*pdwEffect = DROPEFFECT_COPY; // XXX Uncomment to test drop. Drop will not be called if pdwEffect == DROPEFFECT_NONE.
+       }
+       m_system->pushDragDropEvent(GHOST_kEventDraggingUpdated, m_draggedObjectType, m_window, pt.x, pt.y, NULL);
+       return S_OK;
+}
+
+/* 
+ * Implementation of IDropTarget::DragLeave
+ */
+HRESULT __stdcall GHOST_DropTargetWin32::DragLeave(void)
+{
+       m_system->pushDragDropEvent(GHOST_kEventDraggingExited, m_draggedObjectType, m_window, 0, 0, NULL);
+       m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
+       return S_OK;
+}
+
+/* Implementation of IDropTarget::Drop
+ * This function will not be called if pdwEffect is set to DROPEFFECT_NONE in 
+ * the implementation of IDropTarget::DragOver
+ */
+HRESULT __stdcall GHOST_DropTargetWin32::Drop(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect)
+{
+       void * data = getGhostData(pDataObject);
+       if(m_window->canAcceptDragOperation())
+       {
+               *pdwEffect = allowedDropEffect(*pdwEffect);
+
+       }
+       else
+       {
+               *pdwEffect = DROPEFFECT_NONE;
+       }
+       if (data)
+               m_system->pushDragDropEvent(GHOST_kEventDraggingDropDone, m_draggedObjectType, m_window, pt.x, pt.y, data );
+               
+       m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
+       return S_OK;
+}
+
+/* 
+ * Helpers
+ */
+DWORD GHOST_DropTargetWin32::allowedDropEffect(DWORD dwAllowed)
+{
+       DWORD dwEffect = DROPEFFECT_NONE;
+       if(dwAllowed & DROPEFFECT_COPY) 
+               dwEffect = DROPEFFECT_COPY;
+
+       return dwEffect;
+}
+
+GHOST_TDragnDropTypes GHOST_DropTargetWin32::getGhostType(IDataObject * pDataObject)
+{
+       /* Text
+        * Note: Unicode text is aviable as CF_TEXT too, the system can do the 
+        * conversion, but we do the conversion ourself with WC_NO_BEST_FIT_CHARS.
+        */
+       FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+       if(pDataObject->QueryGetData(&fmtetc) == S_OK)
+       {
+               return GHOST_kDragnDropTypeString;
+       }
+
+       // Filesnames
+       fmtetc.cfFormat = CF_HDROP;
+       if(pDataObject->QueryGetData(&fmtetc) == S_OK)
+       {
+               return GHOST_kDragnDropTypeFilenames;
+       }
+
+       return GHOST_kDragnDropTypeUnknown;
+}
+
+void * GHOST_DropTargetWin32::getGhostData(IDataObject * pDataObject)
+{
+       GHOST_TDragnDropTypes type = getGhostType(pDataObject);
+       switch(type)
+       {
+               case GHOST_kDragnDropTypeFilenames:
+                       return getDropDataAsFilenames(pDataObject);
+                       break;
+               case GHOST_kDragnDropTypeString:
+                       return getDropDataAsString(pDataObject);
+                       break;
+               case GHOST_kDragnDropTypeBitmap:
+                       //return getDropDataAsBitmap(pDataObject);
+                       break;
+               default:
+#ifdef GHOST_DEBUG
+                       ::printf("\nGHOST_kDragnDropTypeUnknown");
+#endif // GHOST_DEBUG
+                       return NULL;
+                       break;
+       }
+       return NULL;
+}
+
+void * GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject * pDataObject)
+{
+       UINT  totfiles, nvalid=0;
+       WCHAR fpath [MAX_PATH]; 
+       char * temp_path;
+       GHOST_TStringArray *strArray = NULL;
+       FORMATETC fmtetc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+       STGMEDIUM stgmed;
+       HDROP hdrop;
+
+       // Check if dataobject supplies the format we want.
+       // Double checking here, first in getGhostType.
+       if(pDataObject->QueryGetData(&fmtetc) == S_OK)
+       {
+               if(pDataObject->GetData(&fmtetc, &stgmed) == S_OK)
+               {
+                       hdrop = (HDROP)::GlobalLock(stgmed.hGlobal);
+
+                       totfiles = ::DragQueryFileW ( hdrop, -1, NULL, 0 );
+                       if (!totfiles)
+                       {
+                               ::GlobalUnlock(stgmed.hGlobal);
+                               return NULL;
+                       }
+
+                       strArray = (GHOST_TStringArray*) ::malloc(sizeof(GHOST_TStringArray));
+                       strArray->count = 0;
+                       strArray->strings = (GHOST_TUns8**) ::malloc(totfiles*sizeof(GHOST_TUns8*));
+
+                       for ( UINT nfile = 0; nfile < totfiles; nfile++ )
+                       {
+                               if ( ::DragQueryFileW ( hdrop, nfile, fpath, MAX_PATH ) > 0 )
+                               {
+                                       if ( !WideCharToANSI(fpath, temp_path) )
+                                       {
+                                               continue;
+                                       } 
+                                       // Just ignore paths that could not be converted verbatim.
+                                       if (strpbrk(temp_path, "?"))
+                                       {
+#ifdef GHOST_DEBUG
+                                               ::printf("\ndiscarding path that contains illegal characters: %s", temp_path);
+#endif // GHOST_DEBUG
+                                               ::free(temp_path);
+                                               temp_path = NULL;
+                                               continue;
+                                       }
+                                       strArray->strings[nvalid] = (GHOST_TUns8*) temp_path;
+                                       strArray->count = nvalid+1;
+                                       nvalid++;
+                               }
+                       }
+                       // Free up memory.
+                       ::GlobalUnlock(stgmed.hGlobal);
+                       ::ReleaseStgMedium(&stgmed);
+                       
+                       return strArray;
+               }
+       }
+       return NULL;
+}
+
+void * GHOST_DropTargetWin32::getDropDataAsString(IDataObject * pDataObject)
+{
+       char* tmp_string;
+       FORMATETC fmtetc = { CF_UNICODETEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+       STGMEDIUM stgmed;
+
+       // Try unicode first.
+       // Check if dataobject supplies the format we want.
+       if(pDataObject->QueryGetData(&fmtetc) == S_OK)
+       {
+               if(pDataObject->GetData(&fmtetc, &stgmed) == S_OK)
+               {
+                       LPCWSTR wstr = (LPCWSTR)::GlobalLock(stgmed.hGlobal);
+                       if ( !WideCharToANSI(wstr, tmp_string) )
+                       {
+                               ::GlobalUnlock(stgmed.hGlobal);
+                               return NULL;
+                       }
+                       // Free memory
+                       ::GlobalUnlock(stgmed.hGlobal);
+                       ::ReleaseStgMedium(&stgmed);
+#ifdef GHOST_DEBUG
+                       ::printf("\n<converted droped unicode string>\n%s\n</droped converted unicode string>\n",tmp_string);
+#endif // GHOST_DEBUG
+                       return tmp_string;
+               }
+       }
+
+       fmtetc.cfFormat = CF_TEXT;
+
+       if(pDataObject->QueryGetData(&fmtetc) == S_OK)
+       {
+               if(pDataObject->GetData(&fmtetc, &stgmed) == S_OK)
+               {
+                       char * str = (char*)::GlobalLock(stgmed.hGlobal);
+                       
+                       tmp_string = (char*)::malloc(::strlen(str)+1);
+                       if ( !tmp_string )
+                       {
+                               ::GlobalUnlock(stgmed.hGlobal);
+                               return NULL;
+                       }
+
+                       if ( !::strcpy(tmp_string, str) )
+                       {
+                               ::free(tmp_string);
+                               ::GlobalUnlock(stgmed.hGlobal);
+                               return NULL;
+                       }
+                       // Free memory
+                       ::GlobalUnlock(stgmed.hGlobal);
+                       ::ReleaseStgMedium(&stgmed);
+
+                       return tmp_string;
+               }
+       }
+       
+       return NULL;
+}
+
+int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char * &out)
+{
+       int size;
+       out = NULL; //caller should free if != NULL
+
+       // Get the required size.
+       size = ::WideCharToMultiByte(CP_ACP,            //System Default Codepage
+                                                               0x00000400,             // WC_NO_BEST_FIT_CHARS
+                                                               in,
+                                                               -1,                             //-1 null terminated, makes output null terminated too.
+                                                               NULL,
+                                                               0,
+                                                               NULL,NULL
+                       );
+       
+       if(!size) 
+       {
+#ifdef GHOST_DEBUG
+               ::printLastError();
+#endif // GHOST_DEBUG
+               return 0;
+       }
+
+       out = (char*)::malloc(size);
+       if (!out)
+       {
+               ::printf("\nmalloc failed!!!");
+               return 0;
+       }
+
+       size = ::WideCharToMultiByte(CP_ACP,
+                                                               0x00000400,
+                                                               in,
+                                                               -1,
+                                                               (LPSTR) out,
+                                                               size,
+                                                               NULL,NULL
+                       );
+
+       if(!size)
+       {
+#ifdef GHOST_DEBUG
+               ::printLastError();
+#endif //GHOST_DEBUG
+               ::free(out);
+               out = NULL;
+       }
+       return size;
+}
+
+#ifdef GHOST_DEBUG
+void printLastError(void)
+{
+       LPTSTR s;
+       DWORD err;
+
+       err = GetLastError();
+       if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+               FORMAT_MESSAGE_FROM_SYSTEM,
+               NULL,
+               err,
+               0,
+               (LPTSTR)&s,
+               0,
+               NULL)
+       )
+       {
+               printf("\nLastError: (%d) %s\n", (int)err, s);
+               LocalFree(s);
+       }
+}
+#endif // GHOST_DEBUG
+
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.h b/intern/ghost/intern/GHOST_DropTargetWin32.h
new file mode 100644 (file)
index 0000000..0a553b6
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DropTargetWin32.h
+ *  \ingroup GHOST
+ */
+
+#ifndef _GHOST_DROP_TARGET_WIN32_H_
+#define _GHOST_DROP_TARGET_WIN32_H_
+
+#include <windows.h>
+#include <string.h>
+#include <GHOST_Types.h>
+#include "GHOST_WindowWin32.h"
+#include "GHOST_SystemWin32.h"
+
+class GHOST_DropTargetWin32 : public IDropTarget
+{
+public:
+       /* IUnknownd implementation.
+        * Enables clients to get pointers to other interfaces on a given object 
+        * through the QueryInterface method, and manage the existence of the object
+        * through the AddRef and Release methods. All other COM interfaces are 
+        * inherited, directly or indirectly, from IUnknown. Therefore, the three 
+        * methods in IUnknown are the first entries in the VTable for every interface. 
+        */
+       HRESULT __stdcall QueryInterface (REFIID riid, void ** ppvObj);
+       ULONG   __stdcall AddRef (void);
+       ULONG   __stdcall Release (void);
+
+       /* IDropTarget implementation
+        + The IDropTarget interface is one of the interfaces you implement to 
+        provide drag-and-drop operations in your application. It contains methods 
+        used in any application that can be a target for data during a 
+        drag-and-drop operation. A drop-target application is responsible for:
+        * 
+        *      - Determining the effect of the drop on the target application.
+        *      - Incorporating any valid dropped data when the drop occurs.
+        *      - Communicating target feedback to the source so the source application
+        *        can provide appropriate visual feedback such as setting the cursor.
+        *      - Implementing drag scrolling.
+        *      - Registering and revoking its application windows as drop targets.
+        * 
+        * The IDropTarget interface contains methods that handle all these 
+        * responsibilities except registering and revoking the application window 
+        * as a drop target, for which you must call the RegisterDragDrop and the 
+        * RevokeDragDrop functions.
+        */
+       
+       HRESULT __stdcall DragEnter (IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect);
+       HRESULT __stdcall DragOver (DWORD grfKeyState, POINTL pt, DWORD * pdwEffect);
+       HRESULT __stdcall DragLeave (void);
+       HRESULT __stdcall Drop (IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect);
+
+       /**
+        * Constructor
+        * With the modifier keys, we want to distinguish left and right keys.
+        * Sometimes this is not possible (Windows ME for instance). Then, we want
+        * events generated for both keys.
+        * @param window        The window to register as drop target.
+        * @param system        The associated system.
+        */
+       GHOST_DropTargetWin32(GHOST_WindowWin32 * window, GHOST_SystemWin32 * system);
+
+       /**
+        * Destructor
+        * Do NOT destroy directly. Use Release() instead to make COM happy.
+        */
+       ~GHOST_DropTargetWin32();
+
+private:
+
+       /* Internal helper functions */
+
+       /**
+        * Base the effect on those allowed by the dropsource.
+        * @param dwAllowed Drop sources allowed drop effect.
+        * @return The allowed drop effect.
+        */
+       DWORD allowedDropEffect(DWORD dwAllowed);
+
+       /**
+        * Query DataObject for the data types it supports.
+        * @param pDataObject Pointer to the DataObject.
+        * @return GHOST data type.
+        */
+       GHOST_TDragnDropTypes getGhostType(IDataObject * pDataObject);
+
+       /**
+        * Get data to pass in event.
+        * It checks the type and calls specific functions for each type.
+        * @param pDataObject Pointer to the DataObject.
+        * @return Pointer to data.
+        */
+       void * getGhostData(IDataObject * pDataObject);
+
+       /**
+        * Allocate data as file array to pass in event.
+        * @param pDataObject Pointer to the DataObject.
+        * @return Pointer to data.
+        */
+       void * getDropDataAsFilenames(IDataObject * pDataObject);
+
+       /**
+        * Allocate data as string to pass in event.
+        * @param pDataObject Pointer to the DataObject.
+        * @return Pointer to data.
+        */
+       void * getDropDataAsString(IDataObject * pDataObject);
+
+       /**
+        * Convert Unicode to ANSI, replacing unconvertable chars with '?'.
+        * The ANSI codepage is the system default codepage, 
+        * and can change from system to system.
+        * @param in LPCWSTR.
+        * @param out char *. Is set to NULL on failure.
+        * @return 0 on failure. Else the size of the string including '\0'.
+        */
+       int WideCharToANSI(LPCWSTR in, char * &out);
+
+       /* Private member variables */
+       /* COM reference count. */
+       LONG    m_cRef; 
+       /* Handle of the associated window. */
+       HWND    m_hWnd;
+       /* The associated GHOST_WindowWin32. */
+       GHOST_WindowWin32 * m_window;
+       /* The System. */
+       GHOST_SystemWin32 * m_system;
+       /* Data type of the dragged object */
+       GHOST_TDragnDropTypes m_draggedObjectType;
+
+};
+
+#endif  // _GHOST_DROP_TARGET_WIN32_H_
diff --git a/intern/ghost/intern/GHOST_Event.h b/intern/ghost/intern/GHOST_Event.h
new file mode 100644 (file)
index 0000000..cfcbe2e
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_Event.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_Event class.
+ */
+
+#ifndef _GHOST_EVENT_H_
+#define _GHOST_EVENT_H_
+
+#include "GHOST_IEvent.h"
+
+
+/**
+ * Base class for events received the operating system.
+ * @author     Maarten Gribnau
+ * @date       May 11, 2001
+ */
+class GHOST_Event : public GHOST_IEvent
+{
+public:
+       /**
+        * Constructor.
+        * @param msec  The time this event was generated.
+        * @param type  The type of this event.
+        * @param window The generating window (or NULL if system event).
+        */
+       GHOST_Event(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window)
+               : m_type(type), m_time(msec), m_window(window), m_data(0)
+       {
+       }
+
+       /**
+        * Returns the event type.
+        * @return The event type.
+        */
+       virtual GHOST_TEventType getType()
+       { 
+               return m_type;
+       }
+
+       /**
+        * Returns the time this event was generated.
+        * @return The event generation time.
+        */
+       virtual GHOST_TUns64 getTime()
+       {
+               return m_time;
+       }
+
+       /**
+        * Returns the window this event was generated on, 
+        * or NULL if it is a 'system' event.
+        * @return The generating window.
+        */
+       virtual GHOST_IWindow* getWindow()
+       {
+               return m_window;
+       }
+
+       /**
+        * Returns the event data.
+        * @return The event data.
+        */
+       virtual GHOST_TEventDataPtr getData()
+       {
+               return m_data;
+       }
+
+protected:
+       /** Type of this event. */
+       GHOST_TEventType m_type;
+       /** The time this event was generated. */
+       GHOST_TUns64 m_time;
+       /** Pointer to the generating window. */
+       GHOST_IWindow* m_window;
+       /** Pointer to the event data. */
+       GHOST_TEventDataPtr m_data;
+};
+
+#endif // _GHOST_EVENT_H_
+
diff --git a/intern/ghost/intern/GHOST_EventButton.h b/intern/ghost/intern/GHOST_EventButton.h
new file mode 100644 (file)
index 0000000..3016917
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventButton.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_EventButton class.
+ */
+
+#ifndef _GHOST_EVENT_BUTTON_H_
+#define _GHOST_EVENT_BUTTON_H_
+
+#include "GHOST_Event.h"
+
+/**
+ * Mouse button event.
+ * @author     Maarten Gribnau
+ * @date       May 11, 2001
+ */
+class GHOST_EventButton : public GHOST_Event
+{
+public:
+       /**
+        * Constructor.
+        * @param time          The time this event was generated.
+        * @param type          The type of this event.
+        * @param x                     The x-coordinate of the location the cursor was at at the time of the event.
+        * @param y                     The y-coordinate of the location the cursor was at at the time of the event.
+        * @param buttons       The state of the buttons  was at at the time of the event.
+        */
+       GHOST_EventButton(GHOST_TUns64 time, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TButtonMask button)
+               : GHOST_Event(time, type, window)
+       {
+               m_buttonEventData.button = button;
+               m_data = &m_buttonEventData;
+       }
+
+protected:
+       /** The button event data. */
+       GHOST_TEventButtonData m_buttonEventData;
+};
+
+#endif // _GHOST_EVENT_BUTTON_H_
+
diff --git a/intern/ghost/intern/GHOST_EventCursor.h b/intern/ghost/intern/GHOST_EventCursor.h
new file mode 100644 (file)
index 0000000..db4dcb7
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventCursor.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_EventCursor class.
+ */
+
+#ifndef _GHOST_EVENT_CURSOR_H_
+#define _GHOST_EVENT_CURSOR_H_
+
+#include "GHOST_Event.h"
+
+/**
+ * Cursor event.
+ * @author     Maarten Gribnau
+ * @date       May 11, 2001
+ */
+class GHOST_EventCursor : public GHOST_Event
+{
+public:
+       /**
+        * Constructor.
+        * @param msec          The time this event was generated.
+        * @param type          The type of this event.
+        * @param x                     The x-coordinate of the location the cursor was at at the time of the event.
+        * @param y                     The y-coordinate of the location the cursor was at at the time of the event.
+        */
+       GHOST_EventCursor(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TInt32 x, GHOST_TInt32 y)
+               : GHOST_Event(msec, type, window)
+       {
+               m_cursorEventData.x = x;
+               m_cursorEventData.y = y;
+               m_data = &m_cursorEventData;
+       }
+
+protected:
+       /** The x,y-coordinates of the cursor position. */
+       GHOST_TEventCursorData m_cursorEventData;
+};
+
+
+#endif // _GHOST_EVENT_CURSOR_H_
+
diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.h b/intern/ghost/intern/GHOST_EventDragnDrop.h
new file mode 100644 (file)
index 0000000..7ddfe36
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Damien Plisson 11/2009
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventDragnDrop.h
+ *  \ingroup GHOST
+ */
+
+
+#ifndef _GHOST_EVENT_DRAGNDROP_H_
+#define _GHOST_EVENT_DRAGNDROP_H_
+
+#include "GHOST_Event.h"
+extern "C" {
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+};
+
+/**
+ * Drag & drop event
+ * 
+ * The dragging sequence is performed in four phases:
+ * 
+ * <li> Start sequence (GHOST_kEventDraggingEntered) that tells a drag'n'drop operation has started. Already gives the object data type,
+ * and the entering mouse location
+ *
+ * <li> Update mouse position (GHOST_kEventDraggingUpdated) sent upon each mouse move until the drag'n'drop operation stops, to give the updated mouse position.
+ * Useful to highlight a potential destination, and update the status (through GHOST_setAcceptDragOperation) telling if the object can be dropped at
+ * the current cursor position.
+ *
+ * <li> Abort drag'n'drop sequence (GHOST_kEventDraggingExited) sent when the user moved the mouse outside the window.
+ *
+ * <li> Send the dropped data (GHOST_kEventDraggingDropDone)
+ *
+ * <li> Outside of the normal sequence, dropped data can be sent (GHOST_kEventDraggingDropOnIcon). This can happen when the user drops an object
+ * on the application icon. (Also used in OSX to pass the filename of the document the user doubled-clicked in the finder)
+ *
+ * <br><br>Note that the mouse positions are given in Blender coordinates (y=0 at bottom)
+ *
+ * <br>Currently supported object types :
+ * <li>UTF-8 string
+ * <li>array of strings representing filenames (GHOST_TStringArray)
+ * <li>bitmap ImBuf
+ */
+class GHOST_EventDragnDrop : public GHOST_Event
+{
+public:
+       /**
+        * Constructor.
+        * @param time          The time this event was generated.
+        * @param type          The type of this event.
+        * @param dataType      The type of the drop candidate object
+        * @param window        The window where the event occurred
+        * @param x                     The x-coordinate of the location the cursor was at at the time of the event.
+        * @param y                     The y-coordinate of the location the cursor was at at the time of the event.
+        * @param data          The "content" dropped in the window
+        */
+       GHOST_EventDragnDrop(GHOST_TUns64 time, GHOST_TEventType type, GHOST_TDragnDropTypes dataType, GHOST_IWindow* window,
+                                                int x, int y, GHOST_TEventDataPtr data)
+               : GHOST_Event(time, type, window)
+       {
+               m_dragnDropEventData.x = x;
+               m_dragnDropEventData.y = y;
+               m_dragnDropEventData.dataType = dataType;
+               m_dragnDropEventData.data = data;
+               m_data = &m_dragnDropEventData;
+       }
+       
+       ~GHOST_EventDragnDrop()
+       {
+               //Free the dropped object data
+               if (m_dragnDropEventData.data == NULL)
+                       return;
+               
+               switch (m_dragnDropEventData.dataType) {
+                       case GHOST_kDragnDropTypeBitmap:
+                               IMB_freeImBuf((ImBuf*)m_dragnDropEventData.data);
+                               break;
+                       case GHOST_kDragnDropTypeFilenames:
+                       {
+                               GHOST_TStringArray *strArray = (GHOST_TStringArray*)m_dragnDropEventData.data;
+                               int i;
+                               
+                               for (i=0;i<strArray->count;i++)
+                                       free(strArray->strings[i]);
+                               
+                               free(strArray);
+                       }
+                               break;
+                       case GHOST_kDragnDropTypeString:
+                               free(m_dragnDropEventData.data);
+                       break;
+
+                       default:
+                               break;
+               }
+       }
+       
+       
+
+protected:
+       /** The x,y-coordinates of the cursor position. */
+       GHOST_TEventDragnDropData m_dragnDropEventData;
+};
+
+#endif // _GHOST_EVENT_DRAGNDROP_H_
+
diff --git a/intern/ghost/intern/GHOST_EventKey.h b/intern/ghost/intern/GHOST_EventKey.h
new file mode 100644 (file)
index 0000000..3581cd8
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventKey.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_EventKey class.
+ */
+
+#ifndef _GHOST_EVENT_KEY_H_
+#define _GHOST_EVENT_KEY_H_
+
+#include "GHOST_Event.h"
+
+/**
+ * Key event.
+ * @author     Maarten Gribnau
+ * @date       May 11, 2001
+ */
+class GHOST_EventKey : public GHOST_Event
+{
+public:
+       /**
+        * Constructor.
+        * @param msec  The time this event was generated.
+        * @param type  The type of key event.
+        * @param key   The key code of the key.
+        */
+       GHOST_EventKey(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TKey key)
+               : GHOST_Event(msec, type, window)
+       {
+               m_keyEventData.key = key;
+               m_keyEventData.ascii = '\0';
+               m_data = &m_keyEventData;
+       }
+       
+       /**
+        * Constructor.
+        * @param msec  The time this event was generated.
+        * @param type  The type of key event.
+        * @param key   The key code of the key.
+        * @param ascii The ascii code for the key event.
+        */
+       GHOST_EventKey(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TKey key, char ascii)
+               : GHOST_Event(msec, type, window)
+       {
+               m_keyEventData.key = key;
+               m_keyEventData.ascii = ascii;
+               m_data = &m_keyEventData;
+       }
+               
+protected:
+       /** The key event data. */
+       GHOST_TEventKeyData m_keyEventData;
+};
+
+#endif // _GHOST_EVENT_KEY_H_
+
diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp
new file mode 100644 (file)
index 0000000..1483555
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventManager.cpp
+ *  \ingroup GHOST
+ */
+
+
+/**
+
+ * $Id$
+ * Copyright (C) 2001 NaN Technologies B.V.
+ * @author     Maarten Gribnau
+ * @date       May 14, 2001
+ */
+
+#include "GHOST_EventManager.h"
+#include <algorithm>
+#include "GHOST_Debug.h"
+
+
+GHOST_EventManager::GHOST_EventManager()
+{
+}
+
+
+GHOST_EventManager::~GHOST_EventManager()
+{
+       disposeEvents();
+
+       TConsumerVector::iterator iter= m_consumers.begin();
+       while (iter != m_consumers.end())
+       {
+               GHOST_IEventConsumer* consumer = *iter;
+               delete consumer;
+               m_consumers.erase(iter);
+               iter = m_consumers.begin();
+       }
+}
+
+
+GHOST_TUns32 GHOST_EventManager::getNumEvents()
+{
+       return (GHOST_TUns32) m_events.size();
+}
+
+
+GHOST_TUns32 GHOST_EventManager::getNumEvents(GHOST_TEventType type)
+{
+       GHOST_TUns32 numEvents = 0;
+       TEventStack::iterator p;
+       for (p = m_events.begin(); p != m_events.end(); p++) {
+               if ((*p)->getType() == type) {
+                       numEvents++;
+               }
+       }
+       return numEvents;
+}
+
+
+GHOST_IEvent* GHOST_EventManager::peekEvent()
+{
+       GHOST_IEvent* event = 0;
+       if (m_events.size() > 0) {
+               event = m_events.back();
+       }
+       return event;
+}
+
+
+GHOST_TSuccess GHOST_EventManager::pushEvent(GHOST_IEvent* event)
+{
+       GHOST_TSuccess success;
+       GHOST_ASSERT(event, "invalid event");
+       if (m_events.size() < m_events.max_size()) {
+               m_events.push_front(event);
+               success = GHOST_kSuccess;
+       }
+       else {
+               success = GHOST_kFailure;
+       }
+       return success;
+}
+
+
+bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event)
+{
+       bool handled;
+       if (event) {
+               handled = true;
+               TConsumerVector::iterator iter;
+               for (iter = m_consumers.begin(); iter != m_consumers.end(); iter++) {
+                       if ((*iter)->processEvent(event)) {
+                               handled = false;
+                       }
+               }
+       }
+       else {
+               handled = false;
+       }
+       return handled;
+}
+
+
+bool GHOST_EventManager::dispatchEvent()
+{
+       GHOST_IEvent* event = popEvent(); 
+       bool handled = false;
+       if (event) {
+               handled = dispatchEvent(event);
+               delete event;
+       }
+       return handled;
+}
+
+
+bool GHOST_EventManager::dispatchEvents()
+{
+       bool handled;
+       if (getNumEvents()) {
+               handled = true;
+               while (getNumEvents()) {
+                       if (!dispatchEvent()) {
+                               handled = false;
+                       }
+               }
+       }
+       else {
+               handled = false;
+       }
+       return handled;
+}
+
+
+GHOST_TSuccess GHOST_EventManager::addConsumer(GHOST_IEventConsumer* consumer)
+{
+       GHOST_TSuccess success;
+       GHOST_ASSERT(consumer, "invalid consumer");
+       
+       // Check to see whether the consumer is already in our list
+       TConsumerVector::const_iterator iter = std::find(m_consumers.begin(), m_consumers.end(), consumer);
+
+       if (iter == m_consumers.end()) {
+               // Add the consumer
+               m_consumers.push_back(consumer);
+               success = GHOST_kSuccess;
+       }
+       else {
+               success = GHOST_kFailure;
+       }
+       return success;
+}
+
+
+GHOST_TSuccess GHOST_EventManager::removeConsumer(GHOST_IEventConsumer* consumer)
+{
+       GHOST_TSuccess success;
+       GHOST_ASSERT(consumer, "invalid consumer");
+
+       // Check to see whether the consumer is in our list
+       TConsumerVector::iterator iter = std::find(m_consumers.begin(), m_consumers.end(), consumer);
+
+       if (iter != m_consumers.end()) {
+               // Remove the consumer
+               m_consumers.erase(iter);
+               success = GHOST_kSuccess;
+       }
+       else {
+               success = GHOST_kFailure;
+       }
+       return success;
+}
+
+
+void GHOST_EventManager::removeWindowEvents(GHOST_IWindow* window)
+{
+       TEventStack::iterator iter;
+       iter = m_events.begin();
+       while (iter != m_events.end())
+       {
+               GHOST_IEvent* event = *iter;
+               if (event->getWindow() == window)
+               {
+            GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n");
+                       /*
+                        * Found an event for this window, remove it.
+                        * The iterator will become invalid.
+                        */
+                       delete event;
+                       m_events.erase(iter);
+                       iter = m_events.begin();
+               }
+               else
+               {
+                       iter++;
+               }
+       }
+}
+
+void GHOST_EventManager::removeTypeEvents(GHOST_TEventType type, GHOST_IWindow* window)
+{
+       TEventStack::iterator iter;
+       iter = m_events.begin();
+       while (iter != m_events.end())
+       {
+               GHOST_IEvent* event = *iter;
+               if ((event->getType() == type) && (!window || (event->getWindow() == window)))
+               {
+            GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n");
+                       /*
+                        * Found an event of this type for the window, remove it.
+                        * The iterator will become invalid.
+                        */
+                       delete event;
+                       m_events.erase(iter);
+                       iter = m_events.begin();
+               }
+               else
+               {
+                       iter++;
+               }
+       }
+}
+
+
+GHOST_IEvent* GHOST_EventManager::popEvent()
+{
+       GHOST_IEvent* event = peekEvent();
+       if (event) {
+               m_events.pop_back();
+       }
+       return event;
+}
+
+
+void GHOST_EventManager::disposeEvents()
+{
+       while (m_events.size() > 0) {
+               GHOST_ASSERT(m_events[0], "invalid event");
+               delete m_events[0];
+               m_events.pop_front();
+       }
+}
diff --git a/intern/ghost/intern/GHOST_EventManager.h b/intern/ghost/intern/GHOST_EventManager.h
new file mode 100644 (file)
index 0000000..9e68a13
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventManager.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_EventManager class.
+ */
+
+#ifndef _GHOST_EVENT_MANAGER_H_
+#define _GHOST_EVENT_MANAGER_H_
+
+#include <deque>
+#include <vector>
+
+#include "GHOST_IEventConsumer.h"
+
+
+/**
+ * Manages an event stack and a list of event consumers.
+ * The stack works on a FIFO (First In First Out) basis.
+ * Events are pushed on the front of the stack and retrieved from the back.
+ * Ownership of the event is transferred to the event manager as soon as an event is pushed.
+ * Ownership of the event is transferred from the event manager as soon as an event is popped.
+ * Events can be dispatched to the event consumers.
+ */
+class GHOST_EventManager
+{
+public:
+       /**
+        * Constructor.
+        */
+       GHOST_EventManager();
+
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_EventManager();
+
+       /**
+        * Returns the number of events currently on the stack.
+        * @return The number of events on the stack.
+        */
+       virtual GHOST_TUns32    getNumEvents();
+
+       /**
+        * Returns the number of events of a certain type currently on the stack.
+        * @param type The type of events to be counted.
+        * @return The number of events on the stack of this type.
+        */
+       virtual GHOST_TUns32    getNumEvents(GHOST_TEventType type);
+
+       /**
+        * Return the event at the top of the stack without removal.
+        * Do not delete the event!
+        * @return The event at the top of the stack.
+        */
+       virtual GHOST_IEvent* peekEvent();
+
+       /**
+        * Pushes an event on the stack.
+        * To dispatch it, call dispatchEvent() or dispatchEvents().
+        * Do not delete the event!
+        * @param event The event to push on the stack.
+        */
+       virtual GHOST_TSuccess pushEvent(GHOST_IEvent* event);
+
+       /**
+        * Dispatches the given event directly, bypassing the event stack.
+        * @return Indication as to whether any of the consumers handled the event.
+        */
+       virtual bool dispatchEvent(GHOST_IEvent* event);
+
+       /**
+        * Dispatches the event at the back of the stack.
+        * The event will be removed from the stack.
+        * @return Indication as to whether any of the consumers handled the event.
+        */
+       virtual bool dispatchEvent();
+
+       /**
+        * Dispatches all the events on the stack.
+        * The event stack will be empty afterwards.
+        * @return Indication as to whether any of the consumers handled the events.
+        */
+       virtual bool dispatchEvents();
+
+       /**
+        * Adds a consumer to the list of event consumers.
+        * @param consumer The consumer added to the list.
+        * @return Indication as to whether addition has succeeded.
+        */
+       virtual GHOST_TSuccess addConsumer(GHOST_IEventConsumer* consumer);
+
+       /**
+        * Removes a consumer from the list of event consumers.
+        * @param consumer The consumer removed from the list.
+        * @return Indication as to whether removal has succeeded.
+        */
+       virtual GHOST_TSuccess removeConsumer(GHOST_IEventConsumer* consumer);
+
+       /**
+        * Removes all events for a window from the stack.
+        * @param       window  The window to remove events for.
+        */
+               virtual void
+        removeWindowEvents(
+               GHOST_IWindow* window
+        );
+
+       /**
+        * Removes all events of a certain type from the stack.
+        * The window parameter is optional. If non-null, the routine will remove
+        * events only associated with that window.
+        * @param       type    The type of events to be removed.
+        * @param       window  The window to remove the events for.
+        */
+               virtual void
+       removeTypeEvents(
+               GHOST_TEventType type,
+               GHOST_IWindow* window = 0
+       );
+
+protected:
+       /**
+        * Returns the event at the top of the stack and removes it.
+        * Delete the event after use!
+        * @return The event at the top of the stack.
+        */
+       virtual GHOST_IEvent* popEvent();
+
+       /**
+        * Removes all events from the stack.
+        */
+       virtual void disposeEvents();
+
+       /** A stack with events. */
+       typedef std::deque<GHOST_IEvent*> TEventStack;
+       
+       /** The event stack. */
+       std::deque<GHOST_IEvent*> m_events;
+
+       /** A vector with event consumers. */
+       typedef std::vector<GHOST_IEventConsumer*> TConsumerVector;
+
+       /** The list with event consumers. */
+       TConsumerVector m_consumers;
+};
+
+#endif // _GHOST_EVENT_MANAGER_H_
+
diff --git a/intern/ghost/intern/GHOST_EventNDOF.h b/intern/ghost/intern/GHOST_EventNDOF.h
new file mode 100644 (file)
index 0000000..70861b0
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventNDOF.h
+ *  \ingroup GHOST
+ */
+
+
+#ifndef _GHOST_EVENT_NDOF_H_
+#define _GHOST_EVENT_NDOF_H_
+
+#include "GHOST_Event.h"
+
+/**
+ * N-degree of freedom device event.
+ */
+class GHOST_EventNDOF : public GHOST_Event
+{
+public:
+       /**
+        * Constructor.
+        * @param msec          The time this event was generated.
+        * @param type          The type of this event.
+        * @param x                     The x-coordinate of the location the cursor was at at the time of the event.
+        * @param y                     The y-coordinate of the location the cursor was at at the time of the event.
+        */
+       GHOST_EventNDOF(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, 
+        GHOST_TEventNDOFData data)
+               : GHOST_Event(msec, type, window)
+       {
+               m_ndofEventData = data;
+               m_data = &m_ndofEventData;
+       }
+
+protected:
+       /** translation & rotation from the device. */
+       GHOST_TEventNDOFData m_ndofEventData;
+};
+
+
+#endif // _GHOST_EVENT_NDOF_H_
+
diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp
new file mode 100644 (file)
index 0000000..139c4be
--- /dev/null
@@ -0,0 +1,347 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventPrinter.cpp
+ *  \ingroup GHOST
+ * Declaration of GHOST_EventPrinter class.
+ */
+
+#include "GHOST_EventPrinter.h"
+#include <iostream>
+#include "GHOST_EventKey.h"
+#include "GHOST_EventDragnDrop.h"
+#include "GHOST_Debug.h"
+
+
+bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event)
+{
+       bool handled = true;
+       
+       GHOST_ASSERT(event, "event==0");
+
+       if (event->getType() == GHOST_kEventWindowUpdate) return false;
+
+       std::cout << "\nGHOST_EventPrinter::processEvent, time: " << (GHOST_TInt32)event->getTime() << ", type: ";
+       switch (event->getType()) {
+       case GHOST_kEventUnknown:
+               std::cout << "GHOST_kEventUnknown"; handled = false;    
+               break;
+
+       case GHOST_kEventButtonUp:
+               {
+               GHOST_TEventButtonData* buttonData = (GHOST_TEventButtonData*)((GHOST_IEvent*)event)->getData();
+               std::cout << "GHOST_kEventCursorButtonUp, button: " << buttonData->button;
+               }
+               break;
+       case GHOST_kEventButtonDown:
+               {
+               GHOST_TEventButtonData* buttonData = (GHOST_TEventButtonData*)((GHOST_IEvent*)event)->getData();
+               std::cout << "GHOST_kEventButtonDown, button: " << buttonData->button;
+               }
+               break;
+
+       case GHOST_kEventWheel:
+               {
+               GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*)((GHOST_IEvent*)event)->getData();
+               std::cout << "GHOST_kEventWheel, z: " << wheelData->z;
+               }
+               break;
+
+       case GHOST_kEventCursorMove:
+               {
+               GHOST_TEventCursorData* cursorData = (GHOST_TEventCursorData*)((GHOST_IEvent*)event)->getData();
+               std::cout << "GHOST_kEventCursorMove, (x,y): (" << cursorData->x << "," << cursorData->y << ")";
+               }
+               break;
+
+       case GHOST_kEventKeyUp:
+               {
+               GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*)((GHOST_IEvent*)event)->getData();
+               STR_String str;
+               getKeyString(keyData->key, str);
+               std::cout << "GHOST_kEventKeyUp, key: " << str.Ptr();
+               }
+               break;
+       case GHOST_kEventKeyDown:
+               {
+               GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*)((GHOST_IEvent*)event)->getData();
+               STR_String str;
+               getKeyString(keyData->key, str);
+               std::cout << "GHOST_kEventKeyDown, key: " << str.Ptr();
+               }
+               break;
+                       
+       case GHOST_kEventDraggingEntered:
+               {
+                       GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData();
+                       std::cout << "GHOST_kEventDraggingEntered, dragged object type : " << dragnDropData->dataType;
+                       std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y;
+               }
+               break;
+                       
+       case GHOST_kEventDraggingUpdated:
+               {
+                       GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData();
+                       std::cout << "GHOST_kEventDraggingUpdated, dragged object type : " << dragnDropData->dataType;
+                       std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y;
+               }
+               break;
+
+       case GHOST_kEventDraggingExited:
+               {
+                       GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData();
+                       std::cout << "GHOST_kEventDraggingExited, dragged object type : " << dragnDropData->dataType;
+               }
+               break;
+       
+       case GHOST_kEventDraggingDropDone:
+               {
+                       GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData();
+                       std::cout << "GHOST_kEventDraggingDropDone,";
+                       std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y;
+                       switch (dragnDropData->dataType) {
+                               case GHOST_kDragnDropTypeString:
+                                       std::cout << " type : GHOST_kDragnDropTypeString,";
+                                       std::cout << "\n  String received = " << (char*)dragnDropData->data;
+                                       break;
+                               case GHOST_kDragnDropTypeFilenames:
+                               {
+                                       GHOST_TStringArray *strArray = (GHOST_TStringArray*)dragnDropData->data;
+                                       int i;
+                                       std::cout << " type : GHOST_kDragnDropTypeFilenames,";
+                                       std::cout << "\n  Received " << strArray->count << " filename" << (strArray->count > 1 ? "s:" : ":");
+                                       for (i=0;i<strArray->count;i++)
+                                               std::cout << "\n        File[" << i << "] : " << strArray->strings[i];
+                               }
+                                       break;
+                               default:
+                                       break;
+                       }
+               }
+               break;
+
+       case GHOST_kEventOpenMainFile:
+               {
+                       GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData();
+                       
+                       if (eventData)
+                               std::cout << "GHOST_kEventOpenMainFile for path : " << (char*)eventData;
+                       else
+                               std::cout << "GHOST_kEventOpenMainFile with no path specified!!";
+               }
+               break;
+                       
+       case GHOST_kEventQuit:
+               std::cout << "GHOST_kEventQuit"; 
+               break;
+       case GHOST_kEventWindowClose:
+               std::cout << "GHOST_kEventWindowClose"; 
+               break;
+       case GHOST_kEventWindowActivate:
+               std::cout << "GHOST_kEventWindowActivate"; 
+               break;
+       case GHOST_kEventWindowDeactivate:
+               std::cout << "GHOST_kEventWindowDeactivate"; 
+               break;
+       case GHOST_kEventWindowUpdate:
+               std::cout << "GHOST_kEventWindowUpdate"; 
+               break;
+       case GHOST_kEventWindowSize:
+               std::cout << "GHOST_kEventWindowSize"; 
+               break;
+
+       default:
+               std::cout << "not found"; handled = false; 
+               break;
+       }
+       return handled;
+}
+
+
+void GHOST_EventPrinter::getKeyString(GHOST_TKey key, STR_String& str) const
+{
+       if ((key >= GHOST_kKeyComma) && (key <= GHOST_kKeyRightBracket)) {
+               str = ((char)key);
+       } else if ((key >= GHOST_kKeyNumpad0) && (key <= GHOST_kKeyNumpad9)) {
+               int number = key - GHOST_kKeyNumpad0;
+               STR_String numberStr (number);
+               str = "Numpad";
+               str += numberStr;
+#if defined(__sun__) || defined(__sun)
+       } else if (key == 268828432) { /* solaris keyboards are messed up */
+                /* This should really test XK_F11 but that doesn't work */
+               str = "F11";
+       } else if (key == 268828433) { /* solaris keyboards are messed up */
+                /* This should really test XK_F12 but that doesn't work */
+               str = "F12";
+#endif
+       } else if ((key >= GHOST_kKeyF1) && (key <= GHOST_kKeyF24)) {
+               int number = key - GHOST_kKeyF1 + 1;
+               STR_String numberStr (number);
+               str = "F";
+               str += numberStr;
+       } else {
+               switch (key)
+               {
+               case GHOST_kKeyBackSpace:
+                       str = "BackSpace";
+                       break;
+               case GHOST_kKeyTab:
+                       str = "Tab";
+                       break;
+               case GHOST_kKeyLinefeed:
+                       str = "Linefeed";
+                       break;
+               case GHOST_kKeyClear:
+                       str = "Clear";
+                       break;
+               case GHOST_kKeyEnter:
+                       str = "Enter";
+                       break;
+               case GHOST_kKeyEsc:
+                       str = "Esc";
+                       break;
+               case GHOST_kKeySpace:
+                       str = "Space";
+                       break;
+               case GHOST_kKeyQuote:
+                       str = "Quote";
+                       break;
+               case GHOST_kKeyBackslash:
+                       str = "\\";
+                       break;
+               case GHOST_kKeyAccentGrave:
+                       str = "`";
+                       break;
+               case GHOST_kKeyLeftShift:
+                       str = "LeftShift";
+                       break;
+               case GHOST_kKeyRightShift:
+                       str = "RightShift";
+                       break;
+               case GHOST_kKeyLeftControl:
+                       str = "LeftControl";
+                       break;
+               case GHOST_kKeyRightControl:
+                       str = "RightControl";
+                       break;
+               case GHOST_kKeyLeftAlt:
+                       str = "LeftAlt";
+                       break;
+               case GHOST_kKeyRightAlt:
+                       str = "RightAlt";
+                       break;
+               case GHOST_kKeyOS:
+                       str = "OS";
+                       break;
+               case GHOST_kKeyGrLess:
+            // PC german!
+                       str = "GrLess";
+                       break;
+               case GHOST_kKeyCapsLock:
+                       str = "CapsLock";
+                       break;
+               case GHOST_kKeyNumLock:
+                       str = "NumLock";
+                       break;
+               case GHOST_kKeyScrollLock:
+                       str = "ScrollLock";
+                       break;
+               case GHOST_kKeyLeftArrow:
+                       str = "LeftArrow";
+                       break;
+               case GHOST_kKeyRightArrow:
+                       str = "RightArrow";
+                       break;
+               case GHOST_kKeyUpArrow:
+                       str = "UpArrow";
+                       break;
+               case GHOST_kKeyDownArrow:
+                       str = "DownArrow";
+                       break;
+               case GHOST_kKeyPrintScreen:
+                       str = "PrintScreen";
+                       break;
+               case GHOST_kKeyPause:
+                       str = "Pause";
+                       break;
+               case GHOST_kKeyInsert:
+                       str = "Insert";
+                       break;
+               case GHOST_kKeyDelete:
+                       str = "Delete";
+                       break;
+               case GHOST_kKeyHome:
+                       str = "Home";
+                       break;
+               case GHOST_kKeyEnd:
+                       str = "End";
+                       break;
+               case GHOST_kKeyUpPage:
+                       str = "UpPage";
+                       break;
+               case GHOST_kKeyDownPage:
+                       str = "DownPage";
+                       break;
+               case GHOST_kKeyNumpadPeriod:
+                       str = "NumpadPeriod";
+                       break;
+               case GHOST_kKeyNumpadEnter:
+                       str = "NumpadEnter";
+                       break;
+               case GHOST_kKeyNumpadPlus:
+                       str = "NumpadPlus";
+                       break;
+               case GHOST_kKeyNumpadMinus:
+                       str = "NumpadMinus";
+                       break;
+               case GHOST_kKeyNumpadAsterisk:
+                       str = "NumpadAsterisk";
+                       break;
+               case GHOST_kKeyNumpadSlash:
+                       str = "NumpadSlash";
+                       break;
+               case GHOST_kKeyMediaPlay:
+                       str = "MediaPlayPause";
+                       break;
+               case GHOST_kKeyMediaStop:
+                       str = "MediaStop";
+                       break;
+               case GHOST_kKeyMediaFirst:
+                       str = "MediaFirst";
+                       break;
+               case GHOST_kKeyMediaLast:
+                       str = "MediaLast";
+                       break;
+               default:
+                       str = "unknown";
+                       break;
+               }
+       }
+}
+
diff --git a/intern/ghost/intern/GHOST_EventPrinter.h b/intern/ghost/intern/GHOST_EventPrinter.h
new file mode 100644 (file)
index 0000000..74c379e
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_EventPrinter.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_EventPrinter class.
+ */
+
+#ifndef _GHOST_EVENT_PRINTER_H_
+#define _GHOST_EVENT_PRINTER_H_
+
+#include "GHOST_IEventConsumer.h"
+
+#include "STR_String.h"
+
+/**
+ * An Event consumer that prints all the events to standard out.
+ * Really useful when debugging.
+ */
+class GHOST_EventPrinter : public GHOST_IEventConsumer
+{
+public:
+       /**
+        * Prints all the events received to std out.
+        * @param event The event that can be handled or not.
+        * @return Indication as to whether the event was handled.
+        */
+       virtual bool processEvent(GHOST_IEvent* event);
+
+protected:
+       /**
+        * Converts GHOST key code to a readable string.
+        * @param key The GHOST key code to convert.
+        * @param str The GHOST key code converted to a readable string.
+        */
+       void    getKeyString(GHOST_TKey key, STR_String& str) const;
+};
+
+#endif // _GHOST_EVENT_PRINTER_H_
+
diff --git a/intern/ghost/intern/GHOST_EventString.h b/intern/ghost/intern/GHOST_EventString.h
new file mode 100644 (file)
index 0000000..e5fe50d
--- /dev/null
+++ b/