diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-05-19 13:57:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-05-19 13:57:55 +0400 |
commit | 9c9a5b882d007c1b75136cfe9a0c4c3ec8769d26 (patch) | |
tree | 9f4eadd5d54515690acd4ec4a0effe1ac5f4bc7f | |
parent | f8f282fc96c4593bd7a0e1db7a095b2fc5205570 (diff) |
style cleanup: ghost
32 files changed, 3014 insertions, 2979 deletions
diff --git a/intern/ghost/intern/GHOST_Buttons.cpp b/intern/ghost/intern/GHOST_Buttons.cpp index 1f56cf44b56..6b90383ee6b 100644 --- a/intern/ghost/intern/GHOST_Buttons.cpp +++ b/intern/ghost/intern/GHOST_Buttons.cpp @@ -42,37 +42,38 @@ GHOST_Buttons::GHOST_Buttons() 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; - } + 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; - } + 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; + m_ButtonLeft = false; + m_ButtonMiddle = false; + m_ButtonRight = false; } -GHOST_Buttons::~GHOST_Buttons() {} +GHOST_Buttons::~GHOST_Buttons() { +} diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 8442f82d886..ad43798bc60 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -50,7 +50,7 @@ GHOST_SystemHandle GHOST_CreateSystem(void) { GHOST_ISystem::createSystem(); - GHOST_ISystem* system = GHOST_ISystem::getSystem(); + GHOST_ISystem *system = GHOST_ISystem::getSystem(); return (GHOST_SystemHandle)system; } @@ -59,7 +59,7 @@ GHOST_SystemHandle GHOST_CreateSystem(void) GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return system->disposeSystem(); } @@ -68,20 +68,20 @@ GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle) GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback, GHOST_TUserDataPtr userdata) { - return (GHOST_EventConsumerHandle) new GHOST_CallbackEventConsumer (eventCallback, userdata); + return (GHOST_EventConsumerHandle) new GHOST_CallbackEventConsumer(eventCallback, userdata); } GHOST_TSuccess GHOST_DisposeEventConsumer(GHOST_EventConsumerHandle consumerhandle) { - delete ((GHOST_CallbackEventConsumer*)consumerhandle); + delete ((GHOST_CallbackEventConsumer *)consumerhandle); return GHOST_kSuccess; } GHOST_TUns64 GHOST_GetMilliSeconds(GHOST_SystemHandle systemhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return system->getMilliSeconds(); } @@ -89,12 +89,12 @@ GHOST_TUns64 GHOST_GetMilliSeconds(GHOST_SystemHandle systemhandle) GHOST_TimerTaskHandle GHOST_InstallTimer(GHOST_SystemHandle systemhandle, - GHOST_TUns64 delay, - GHOST_TUns64 interval, - GHOST_TimerProcPtr timerproc, - GHOST_TUserDataPtr userdata) + GHOST_TUns64 delay, + GHOST_TUns64 interval, + GHOST_TimerProcPtr timerproc, + GHOST_TUserDataPtr userdata) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return (GHOST_TimerTaskHandle) system->installTimer(delay, interval, timerproc, userdata); } @@ -102,10 +102,10 @@ GHOST_TimerTaskHandle GHOST_InstallTimer(GHOST_SystemHandle systemhandle, GHOST_TSuccess GHOST_RemoveTimer(GHOST_SystemHandle systemhandle, - GHOST_TimerTaskHandle timertaskhandle) + GHOST_TimerTaskHandle timertaskhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; - GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; + GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle; return system->removeTimer(timertask); } @@ -114,7 +114,7 @@ GHOST_TSuccess GHOST_RemoveTimer(GHOST_SystemHandle systemhandle, GHOST_TUns8 GHOST_GetNumDisplays(GHOST_SystemHandle systemhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return system->getNumDisplays(); } @@ -122,10 +122,10 @@ GHOST_TUns8 GHOST_GetNumDisplays(GHOST_SystemHandle systemhandle) void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle, - GHOST_TUns32* width, - GHOST_TUns32* height) + GHOST_TUns32 *width, + GHOST_TUns32 *height) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; system->getMainDisplayDimensions(*width, *height); } @@ -133,46 +133,46 @@ void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle, 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; + 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) + if (stereoVisual) bstereoVisual = true; else bstereoVisual = false; return (GHOST_WindowHandle) system->createWindow(title, left, top, width, height, - state, type, bstereoVisual, numOfAASamples); + state, type, bstereoVisual, numOfAASamples); } GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) 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; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; window->setUserData(userdata); } GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle, - GHOST_WindowHandle windowhandle) + GHOST_WindowHandle windowhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return system->disposeWindow(window); } @@ -180,10 +180,10 @@ GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle, int GHOST_ValidWindow(GHOST_SystemHandle systemhandle, - GHOST_WindowHandle windowhandle) + GHOST_WindowHandle windowhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return (int) system->validWindow(window); } @@ -191,14 +191,14 @@ int GHOST_ValidWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle, - GHOST_DisplaySetting* setting, - const int stereoVisual) + GHOST_DisplaySetting *setting, + const int stereoVisual) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; - GHOST_IWindow* window = NULL; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; + GHOST_IWindow *window = NULL; bool bstereoVisual; - if(stereoVisual) + if (stereoVisual) bstereoVisual = true; else bstereoVisual = false; @@ -212,7 +212,7 @@ GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle, GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return system->endFullScreen(); } @@ -221,7 +221,7 @@ GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle) int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return (int) system->getFullScreen(); } @@ -230,16 +230,16 @@ int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle) int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; - return (int) system->processEvents(waitForEvent?true:false); + return (int) system->processEvents(waitForEvent ? true : false); } int GHOST_DispatchEvents(GHOST_SystemHandle systemhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return (int) system->dispatchEvents(); } @@ -247,28 +247,28 @@ int GHOST_DispatchEvents(GHOST_SystemHandle systemhandle) GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; - return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle); + return system->addEventConsumer((GHOST_CallbackEventConsumer *)consumerhandle); } GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; - return system->removeEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle); + return system->removeEventConsumer((GHOST_CallbackEventConsumer *)consumerhandle); } -GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle,float progress) +GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle, float progress) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->setProgressBar(progress); } GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->endProgressBar(); } @@ -276,7 +276,7 @@ GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle) GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->getCursorShape(); } @@ -284,45 +284,45 @@ GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle) GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle, - GHOST_TStandardCursor cursorshape) + GHOST_TStandardCursor cursorshape) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + 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_TUns8 bitmap[16][2], + GHOST_TUns8 mask[16][2], + int hotX, + int hotY) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + 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_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; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; - return window->setCustomCursorShape(bitmap, mask, sizex, sizey, - hotX, hotY, fg_color, bg_color); + 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; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return (int) window->getCursorVisibility(); } @@ -330,20 +330,20 @@ int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle) GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle, - int visible) + int visible) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; - return window->setCursorVisibility(visible?true:false); + return window->setCursorVisibility(visible ? true : false); } GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle, - GHOST_TInt32* x, - GHOST_TInt32* y) + GHOST_TInt32 *x, + GHOST_TInt32 *y) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return system->getCursorPosition(*x, *y); } @@ -351,23 +351,23 @@ GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle, GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle, - GHOST_TInt32 x, - GHOST_TInt32 y) + GHOST_TInt32 x, + GHOST_TInt32 y) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; return system->setCursorPosition(x, y); } GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle, - GHOST_TGrabCursorMode mode, - int *bounds) + GHOST_TGrabCursorMode mode, + int *bounds) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; GHOST_Rect bounds_rect, bounds_win; - if(bounds) { + 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); @@ -375,17 +375,17 @@ GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle, } - return window->setCursorGrab(mode, bounds ? &bounds_rect:NULL); + return window->setCursorGrab(mode, bounds ? &bounds_rect : NULL); } GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle, - GHOST_TModifierKeyMask mask, - int* isDown) + GHOST_TModifierKeyMask mask, + int *isDown) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; GHOST_TSuccess result; - bool isdown= false; + bool isdown = false; result = system->getModifierKeyState(mask, isdown); *isDown = (int) isdown; @@ -396,12 +396,12 @@ GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle, GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, - GHOST_TButtonMask mask, - int* isDown) + GHOST_TButtonMask mask, + int *isDown) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; GHOST_TSuccess result; - bool isdown= false; + bool isdown = false; result = system->getButtonState(mask, isdown); *isDown = (int) isdown; @@ -412,7 +412,7 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; window->setAcceptDragOperation(canAccept); } @@ -420,7 +420,7 @@ void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 c GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle) { - GHOST_IEvent* event = (GHOST_IEvent*) eventhandle; + GHOST_IEvent *event = (GHOST_IEvent *) eventhandle; return event->getType(); } @@ -429,7 +429,7 @@ GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle) GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle) { - GHOST_IEvent* event = (GHOST_IEvent*) eventhandle; + GHOST_IEvent *event = (GHOST_IEvent *) eventhandle; return event->getTime(); } @@ -437,7 +437,7 @@ GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle) GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle) { - GHOST_IEvent* event = (GHOST_IEvent*) eventhandle; + GHOST_IEvent *event = (GHOST_IEvent *) eventhandle; return (GHOST_WindowHandle) event->getWindow(); } @@ -445,7 +445,7 @@ GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle) GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle) { - GHOST_IEvent* event = (GHOST_IEvent*) eventhandle; + GHOST_IEvent *event = (GHOST_IEvent *) eventhandle; return event->getData(); } @@ -454,7 +454,7 @@ GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle) GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle) { - GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle; + GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle; return timertask->getTimerProc(); } @@ -462,9 +462,9 @@ GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle) void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle, - GHOST_TimerProcPtr timerproc) + GHOST_TimerProcPtr timerproc) { - GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle; + GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle; timertask->setTimerProc(timerproc); } @@ -473,17 +473,17 @@ void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle, GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle) { - GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle; + GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle; return timertask->getUserData(); } - + void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle, - GHOST_TUserDataPtr userdata) + GHOST_TUserDataPtr userdata) { - GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle; + GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle; timertask->setUserData(userdata); } @@ -492,7 +492,7 @@ void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle, int GHOST_GetValid(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return (int) window->getValid(); } @@ -501,7 +501,7 @@ int GHOST_GetValid(GHOST_WindowHandle windowhandle) GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->getDrawingContextType(); } @@ -509,9 +509,9 @@ GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowh GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle, - GHOST_TDrawingContextType type) + GHOST_TDrawingContextType type) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->setDrawingContextType(type); } @@ -519,26 +519,26 @@ GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle, void GHOST_SetTitle(GHOST_WindowHandle windowhandle, - const char* title) + const char *title) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; window->setTitle(title); } -char* GHOST_GetTitle(GHOST_WindowHandle windowhandle) +char *GHOST_GetTitle(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; STR_String title; window->getTitle(title); - char *ctitle = (char*) malloc(title.Length() + 1); + char *ctitle = (char *) malloc(title.Length() + 1); if (ctitle == NULL) return NULL; strcpy(ctitle, title.Ptr()); - + return ctitle; } @@ -546,8 +546,8 @@ char* GHOST_GetTitle(GHOST_WindowHandle windowhandle) GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; - GHOST_Rect* rectangle = NULL; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; + GHOST_Rect *rectangle = NULL; rectangle = new GHOST_Rect(); window->getWindowBounds(*rectangle); @@ -559,8 +559,8 @@ GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle) GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; - GHOST_Rect* rectangle = NULL; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; + GHOST_Rect *rectangle = NULL; rectangle = new GHOST_Rect(); window->getClientBounds(*rectangle); @@ -572,15 +572,15 @@ GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle) void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle) { - delete (GHOST_Rect*) rectanglehandle; + delete (GHOST_Rect *) rectanglehandle; } GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle, - GHOST_TUns32 width) + GHOST_TUns32 width) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->setClientWidth(width); } @@ -588,9 +588,9 @@ GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle, GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle, - GHOST_TUns32 height) + GHOST_TUns32 height) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->setClientHeight(height); } @@ -598,10 +598,10 @@ GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle, GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle, - GHOST_TUns32 width, - GHOST_TUns32 height) + GHOST_TUns32 width, + GHOST_TUns32 height) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->setClientSize(width, height); } @@ -609,12 +609,12 @@ GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle, void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle, - GHOST_TInt32 inX, - GHOST_TInt32 inY, - GHOST_TInt32* outX, - GHOST_TInt32* outY) + GHOST_TInt32 inX, + GHOST_TInt32 inY, + GHOST_TInt32 *outX, + GHOST_TInt32 *outY) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; window->screenToClient(inX, inY, *outX, *outY); } @@ -622,12 +622,12 @@ void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle, void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle, - GHOST_TInt32 inX, - GHOST_TInt32 inY, - GHOST_TInt32* outX, - GHOST_TInt32* outY) + GHOST_TInt32 inX, + GHOST_TInt32 inY, + GHOST_TInt32 *outX, + GHOST_TInt32 *outY) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; window->clientToScreen(inX, inY, *outX, *outY); } @@ -636,7 +636,7 @@ void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle, GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->getState(); } @@ -644,9 +644,9 @@ GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle) GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle, - GHOST_TWindowState state) + GHOST_TWindowState state) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->setState(state); } @@ -654,16 +654,16 @@ GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle, GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->setModifiedState(isUnsavedChanges); } GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle, - GHOST_TWindowOrder order) + GHOST_TWindowOrder order) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->setOrder(order); } @@ -672,7 +672,7 @@ GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle, GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->swapBuffers(); } @@ -681,7 +681,7 @@ GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle) GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->activateDrawingContext(); } @@ -690,54 +690,54 @@ GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandl GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle) { - GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; return window->invalidate(); } -extern const GHOST_TabletData* GHOST_GetTabletData(GHOST_WindowHandle windowhandle) +extern const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle) { - return ((GHOST_IWindow*)windowhandle)->GetTabletData(); + return ((GHOST_IWindow *)windowhandle)->GetTabletData(); } GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle) { - return ((GHOST_Rect*)rectanglehandle)->getWidth(); + return ((GHOST_Rect *)rectanglehandle)->getWidth(); } GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle) { - return ((GHOST_Rect*)rectanglehandle)->getHeight(); + return ((GHOST_Rect *)rectanglehandle)->getHeight(); } void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle, - GHOST_TInt32* l, - GHOST_TInt32* t, - GHOST_TInt32* r, - GHOST_TInt32* b) + 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; + 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_TInt32 l, + GHOST_TInt32 t, + GHOST_TInt32 r, + GHOST_TInt32 b) { - ((GHOST_Rect*)rectanglehandle)->set(l, t, r, b); + ((GHOST_Rect *)rectanglehandle)->set(l, t, r, b); } @@ -746,7 +746,7 @@ GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle) { GHOST_TSuccess result = GHOST_kFailure; - if (((GHOST_Rect*)rectanglehandle)->isEmpty()) + if (((GHOST_Rect *)rectanglehandle)->isEmpty()) result = GHOST_kSuccess; return result; @@ -758,7 +758,7 @@ GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle) { GHOST_TSuccess result = GHOST_kFailure; - if(((GHOST_Rect*)rectanglehandle)->isValid()) + if (((GHOST_Rect *)rectanglehandle)->isValid()) result = GHOST_kSuccess; return result; @@ -767,37 +767,37 @@ GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle) void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle, - GHOST_TInt32 i) + GHOST_TInt32 i) { - ((GHOST_Rect*)rectanglehandle)->inset(i); + ((GHOST_Rect *)rectanglehandle)->inset(i); } void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle, - GHOST_RectangleHandle anotherrectanglehandle) + GHOST_RectangleHandle anotherrectanglehandle) { - ((GHOST_Rect*)rectanglehandle)->unionRect(*(GHOST_Rect*)anotherrectanglehandle); + ((GHOST_Rect *)rectanglehandle)->unionRect(*(GHOST_Rect *)anotherrectanglehandle); } void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle, - GHOST_TInt32 x, - GHOST_TInt32 y) + GHOST_TInt32 x, + GHOST_TInt32 y) { - ((GHOST_Rect*)rectanglehandle)->unionPoint(x, y); + ((GHOST_Rect *)rectanglehandle)->unionPoint(x, y); } GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle, - GHOST_TInt32 x, - GHOST_TInt32 y) + GHOST_TInt32 x, + GHOST_TInt32 y) { GHOST_TSuccess result = GHOST_kFailure; - if (((GHOST_Rect*)rectanglehandle)->isInside(x, y)) + if (((GHOST_Rect *)rectanglehandle)->isInside(x, y)) result = GHOST_kSuccess; return result; @@ -806,11 +806,11 @@ GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle, GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle, - GHOST_RectangleHandle anotherrectanglehandle) + GHOST_RectangleHandle anotherrectanglehandle) { GHOST_TVisibility visible = GHOST_kNotVisible; - visible = ((GHOST_Rect*)rectanglehandle)->getVisibility(*(GHOST_Rect*)anotherrectanglehandle); + visible = ((GHOST_Rect *)rectanglehandle)->getVisibility(*(GHOST_Rect *)anotherrectanglehandle); return visible; } @@ -818,56 +818,56 @@ GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectangleha void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle, - GHOST_TInt32 cx, - GHOST_TInt32 cy) + GHOST_TInt32 cx, + GHOST_TInt32 cy) { - ((GHOST_Rect*)rectanglehandle)->setCenter(cx, 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_TInt32 cx, + GHOST_TInt32 cy, + GHOST_TInt32 w, + GHOST_TInt32 h) { - ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy, w, h); + ((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy, w, h); } GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle, - GHOST_RectangleHandle anotherrectanglehandle) + GHOST_RectangleHandle anotherrectanglehandle) { GHOST_TSuccess result = GHOST_kFailure; - if (((GHOST_Rect*)rectanglehandle)->clip(*(GHOST_Rect*)anotherrectanglehandle)) + if (((GHOST_Rect *)rectanglehandle)->clip(*(GHOST_Rect *)anotherrectanglehandle)) result = GHOST_kSuccess; return result; } -GHOST_TUns8* GHOST_getClipboard(int selection) +GHOST_TUns8 *GHOST_getClipboard(int selection) { - GHOST_ISystem* system = GHOST_ISystem::getSystem(); + GHOST_ISystem *system = GHOST_ISystem::getSystem(); return system->getClipboard(selection); } void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection) { - GHOST_ISystem* system = GHOST_ISystem::getSystem(); + GHOST_ISystem *system = GHOST_ISystem::getSystem(); system->putClipboard(buffer, selection); } int GHOST_toggleConsole(int action) { - GHOST_ISystem* system = GHOST_ISystem::getSystem(); + GHOST_ISystem *system = GHOST_ISystem::getSystem(); return system->toggleConsole(action); } int GHOST_confirmQuit(GHOST_WindowHandle windowhandle){ - GHOST_ISystem* system = GHOST_ISystem::getSystem(); - return system->confirmQuit((GHOST_IWindow*) windowhandle); + GHOST_ISystem *system = GHOST_ISystem::getSystem(); + return system->confirmQuit((GHOST_IWindow *) windowhandle); } diff --git a/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp b/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp index 49590c77eaa..2e602f33b43 100644 --- a/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp +++ b/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp @@ -49,7 +49,7 @@ GHOST_CallbackEventConsumer::GHOST_CallbackEventConsumer(GHOST_EventCallbackProc } -bool GHOST_CallbackEventConsumer::processEvent(GHOST_IEvent* event) +bool GHOST_CallbackEventConsumer::processEvent(GHOST_IEvent *event) { return m_eventCallback((GHOST_EventHandle)event, m_userData) != 0; } diff --git a/intern/ghost/intern/GHOST_DisplayManager.cpp b/intern/ghost/intern/GHOST_DisplayManager.cpp index ca0d53b8297..380fb817ab0 100644 --- a/intern/ghost/intern/GHOST_DisplayManager.cpp +++ b/intern/ghost/intern/GHOST_DisplayManager.cpp @@ -41,8 +41,8 @@ GHOST_DisplayManager::GHOST_DisplayManager( - void) -: m_settingsInitialized(false) + void) + : m_settingsInitialized(false) { } @@ -54,7 +54,7 @@ GHOST_DisplayManager::~GHOST_DisplayManager(void) GHOST_TSuccess GHOST_DisplayManager::initialize( - void) + void) { GHOST_TSuccess success; if (!m_settingsInitialized) { @@ -70,7 +70,7 @@ GHOST_DisplayManager::initialize( GHOST_TSuccess GHOST_DisplayManager::getNumDisplays( - GHOST_TUns8& /*numDisplays*/) const + GHOST_TUns8& /*numDisplays*/) const { // Don't know if we have a display... return GHOST_kFailure; @@ -79,8 +79,8 @@ GHOST_DisplayManager::getNumDisplays( GHOST_TSuccess GHOST_DisplayManager::getNumDisplaySettings( - GHOST_TUns8 display, - GHOST_TInt32& numSettings) const + GHOST_TUns8 display, + GHOST_TInt32& numSettings) const { GHOST_TSuccess success; @@ -101,9 +101,9 @@ GHOST_DisplayManager::getNumDisplaySettings( GHOST_TSuccess GHOST_DisplayManager::getDisplaySetting( - GHOST_TUns8 display, - GHOST_TInt32 index, - GHOST_DisplaySetting& setting) const + GHOST_TUns8 display, + GHOST_TInt32 index, + GHOST_DisplaySetting& setting) const { GHOST_TSuccess success; @@ -124,8 +124,8 @@ GHOST_DisplayManager::getDisplaySetting( GHOST_TSuccess GHOST_DisplayManager::getCurrentDisplaySetting( - GHOST_TUns8 /*display*/, - GHOST_DisplaySetting& /*setting*/) const + GHOST_TUns8 /*display*/, + GHOST_DisplaySetting& /*setting*/) const { return GHOST_kFailure; } @@ -133,8 +133,8 @@ GHOST_DisplayManager::getCurrentDisplaySetting( GHOST_TSuccess GHOST_DisplayManager::setCurrentDisplaySetting( - GHOST_TUns8 /*display*/, - const GHOST_DisplaySetting& /*setting*/) + GHOST_TUns8 /*display*/, + const GHOST_DisplaySetting& /*setting*/) { return GHOST_kFailure; } @@ -142,18 +142,18 @@ GHOST_DisplayManager::setCurrentDisplaySetting( GHOST_TSuccess GHOST_DisplayManager::findMatch( - GHOST_TUns8 display, - const GHOST_DisplaySetting& setting, - GHOST_DisplaySetting& match) const + 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] = { - (int)setting.xPixels, - (int)setting.yPixels, - (int)setting.bpp, - (int)setting.frequency + (int)setting.xPixels, + (int)setting.yPixels, + (int)setting.bpp, + (int)setting.frequency }; int capabilities[4]; double field, score; @@ -195,7 +195,7 @@ GHOST_DisplayManager::findMatch( GHOST_TSuccess GHOST_DisplayManager::initializeSettings( - void) + void) { GHOST_TUns8 numDisplays; GHOST_TSuccess success = getNumDisplays(numDisplays); diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp b/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp index 1449da7b096..7752ae8cbc0 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp @@ -52,8 +52,8 @@ GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(void) } if (m_numDisplays > 0) { - m_displayIDs = new CGDirectDisplayID [m_numDisplays]; - GHOST_ASSERT((m_displayIDs!=NULL), "GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(): memory allocation failed"); + 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); } } @@ -68,7 +68,7 @@ GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplays(GHOST_TUns8& numDispla GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const { - GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCarbon::getNumDisplaySettings(): only main display is supported"); + GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getNumDisplaySettings(): only main display is supported"); CFArrayRef displayModes; displayModes = ::CGDisplayAvailableModes(m_displayIDs[display]); @@ -81,19 +81,19 @@ GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplaySettings(GHOST_TUns8 dis 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"); + 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); + 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); + 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); @@ -105,14 +105,14 @@ GHOST_TSuccess GHOST_DisplayManagerCarbon::getDisplaySetting(GHOST_TUns8 display GHOST_TSuccess GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const { - GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(): only main display is supported"); + 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); + 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); @@ -124,7 +124,7 @@ GHOST_TSuccess GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(GHOST_TUns8 GHOST_TSuccess GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting) { - GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): only main display is supported"); + GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): only main display is supported"); #ifdef GHOST_DEBUG printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): requested settings:\n"); @@ -135,12 +135,12 @@ GHOST_TSuccess GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(GHOST_TUns8 #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); + 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"); @@ -158,20 +158,20 @@ GHOST_TSuccess GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(GHOST_TUns8 long GHOST_DisplayManagerCarbon::getValue(CFDictionaryRef values, CFStringRef key) const { - CFNumberRef numberValue = (CFNumberRef) CFDictionaryGetValue(values, key); + CFNumberRef numberValue = (CFNumberRef) CFDictionaryGetValue(values, key); - if (!numberValue) - { - return -1; - } + if (!numberValue) + { + return -1; + } - long intValue; + long intValue; - if (!CFNumberGetValue(numberValue, kCFNumberLongType, &intValue)) - { - return -1; - } + if (!CFNumberGetValue(numberValue, kCFNumberLongType, &intValue)) + { + return -1; + } - return intValue; + return intValue; } diff --git a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp index 8d2348dcf5c..fbfbce264a5 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp @@ -45,7 +45,7 @@ GHOST_DisplayManagerSDL::GHOST_DisplayManagerSDL(GHOST_SystemSDL *system) GHOST_TSuccess GHOST_DisplayManagerSDL::getNumDisplays(GHOST_TUns8& numDisplays) const { - numDisplays= SDL_GetNumVideoDisplays(); + numDisplays = SDL_GetNumVideoDisplays(); return GHOST_kSuccess; } @@ -140,8 +140,10 @@ GHOST_DisplayManagerSDL:: setCurrentDisplaySetting(GHOST_TUns8 display, SDL_GetDisplayMode(display, i, &mode); if (setting.xPixels > mode.w || - setting.yPixels > mode.h) + setting.yPixels > mode.h) + { continue; + } x = setting.xPixels - mode.w; y = setting.yPixels - mode.h; @@ -175,7 +177,7 @@ GHOST_DisplayManagerSDL:: setCurrentDisplaySetting(GHOST_TUns8 display, } else { /* this is a problem for the BGE player :S, perhaps SDL2 will resolve at some point. - * we really need SDL_SetDisplayModeForDisplay() to become an API func! - campbell */ + * we really need SDL_SetDisplayModeForDisplay() to become an API func! - campbell */ printf("no windows available, cant fullscreen"); /* do not fail, we will try again later when the window is created - wander */ diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp index b7d62a8109e..83df9971158 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp @@ -67,7 +67,7 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplays(GHOST_TUns8& numDisplay */ GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const { - GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerWin32::getNumDisplaySettings(): only main displlay is supported"); + GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerWin32::getNumDisplaySettings(): only main displlay is supported"); numSettings = 0; DEVMODE dm; while (::EnumDisplaySettings(NULL, numSettings, &dm)) { @@ -79,16 +79,16 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplaySettings(GHOST_TUns8 disp 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_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; + 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 @@ -112,14 +112,14 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::getDisplaySetting(GHOST_TUns8 display, GHOST_TSuccess GHOST_DisplayManagerWin32::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const { - GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerWin32::getCurrentDisplaySetting(): only main display is supported"); + 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_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerWin32::setCurrentDisplaySetting(): only main display is supported"); GHOST_DisplaySetting match; findMatch(display, setting, match); @@ -127,21 +127,22 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::setCurrentDisplaySetting(GHOST_TUns8 d 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)) { + (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; - */ + * 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); @@ -154,31 +155,31 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::setCurrentDisplaySetting(GHOST_TUns8 d #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; + 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; + return status == DISP_CHANGE_SUCCESSFUL ? GHOST_kSuccess : GHOST_kFailure; } diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp index c13c242bc7e..0f07435d417 100644 --- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp +++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp @@ -43,10 +43,10 @@ void printLastError(void); #endif // GHOST_DEBUG -GHOST_DropTargetWin32::GHOST_DropTargetWin32(GHOST_WindowWin32 * window, GHOST_SystemWin32 * system) -: -m_window(window), -m_system(system) +GHOST_DropTargetWin32::GHOST_DropTargetWin32(GHOST_WindowWin32 *window, GHOST_SystemWin32 *system) + : + m_window(window), + m_system(system) { m_cRef = 1; m_hWnd = window->getHWND(); @@ -63,23 +63,22 @@ GHOST_DropTargetWin32::~GHOST_DropTargetWin32() /* - * IUnknown::QueryInterface + * IUnknown::QueryInterface */ -HRESULT __stdcall GHOST_DropTargetWin32::QueryInterface (REFIID riid, void ** ppvObj) +HRESULT __stdcall GHOST_DropTargetWin32::QueryInterface(REFIID riid, void **ppvObj) { if (!ppvObj) return E_INVALIDARG; *ppvObj = NULL; - if(riid == IID_IUnknown || riid == IID_IDropTarget) + if (riid == IID_IUnknown || riid == IID_IDropTarget) { AddRef(); - *ppvObj = (void*)this; + *ppvObj = (void *)this; return S_OK; } - else - { + else { *ppvObj = 0; return E_NOINTERFACE; } @@ -102,13 +101,12 @@ ULONG __stdcall GHOST_DropTargetWin32::Release(void) { ULONG refs = ::InterlockedDecrement(&m_cRef); - if(refs == 0) + if (refs == 0) { delete this; return 0; } - else - { + else { return refs; } } @@ -116,7 +114,7 @@ ULONG __stdcall GHOST_DropTargetWin32::Release(void) /* * Implementation of IDropTarget::DragEnter */ -HRESULT __stdcall GHOST_DropTargetWin32::DragEnter(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect) +HRESULT __stdcall GHOST_DropTargetWin32::DragEnter(IDataObject *pDataObject, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { // we accept all drop by default m_window->setAcceptDragOperation(true); @@ -130,14 +128,13 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragEnter(IDataObject * pDataObject, DW /* * Implementation of IDropTarget::DragOver */ -HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD grfKeyState, POINTL pt, DWORD * pdwEffect) +HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { - if(m_window->canAcceptDragOperation()) + if (m_window->canAcceptDragOperation()) { *pdwEffect = allowedDropEffect(*pdwEffect); } - else - { + else { *pdwEffect = DROPEFFECT_NONE; //*pdwEffect = DROPEFFECT_COPY; // XXX Uncomment to test drop. Drop will not be called if pdwEffect == DROPEFFECT_NONE. } @@ -159,20 +156,19 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragLeave(void) * 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) +HRESULT __stdcall GHOST_DropTargetWin32::Drop(IDataObject *pDataObject, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { - void * data = getGhostData(pDataObject); - if(m_window->canAcceptDragOperation()) + void *data = getGhostData(pDataObject); + if (m_window->canAcceptDragOperation()) { *pdwEffect = allowedDropEffect(*pdwEffect); } - else - { + else { *pdwEffect = DROPEFFECT_NONE; } if (data) - m_system->pushDragDropEvent(GHOST_kEventDraggingDropDone, m_draggedObjectType, m_window, pt.x, pt.y, data ); + m_system->pushDragDropEvent(GHOST_kEventDraggingDropDone, m_draggedObjectType, m_window, pt.x, pt.y, data); m_draggedObjectType = GHOST_kDragnDropTypeUnknown; return S_OK; @@ -185,27 +181,27 @@ HRESULT __stdcall GHOST_DropTargetWin32::Drop(IDataObject * pDataObject, DWORD g DWORD GHOST_DropTargetWin32::allowedDropEffect(DWORD dwAllowed) { DWORD dwEffect = DROPEFFECT_NONE; - if(dwAllowed & DROPEFFECT_COPY) + if (dwAllowed & DROPEFFECT_COPY) dwEffect = DROPEFFECT_COPY; return dwEffect; } -GHOST_TDragnDropTypes GHOST_DropTargetWin32::getGhostType(IDataObject * pDataObject) +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) + if (pDataObject->QueryGetData(&fmtetc) == S_OK) { return GHOST_kDragnDropTypeString; } // Filesnames fmtetc.cfFormat = CF_HDROP; - if(pDataObject->QueryGetData(&fmtetc) == S_OK) + if (pDataObject->QueryGetData(&fmtetc) == S_OK) { return GHOST_kDragnDropTypeFilenames; } @@ -213,10 +209,10 @@ GHOST_TDragnDropTypes GHOST_DropTargetWin32::getGhostType(IDataObject * pDataObj return GHOST_kDragnDropTypeUnknown; } -void * GHOST_DropTargetWin32::getGhostData(IDataObject * pDataObject) +void *GHOST_DropTargetWin32::getGhostData(IDataObject *pDataObject) { GHOST_TDragnDropTypes type = getGhostType(pDataObject); - switch(type) + switch (type) { case GHOST_kDragnDropTypeFilenames: return getDropDataAsFilenames(pDataObject); @@ -237,11 +233,11 @@ void * GHOST_DropTargetWin32::getGhostData(IDataObject * pDataObject) return NULL; } -void * GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject * pDataObject) +void *GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject *pDataObject) { - UINT totfiles, nvalid=0; - WCHAR fpath [MAX_PATH]; - char * temp_path; + 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; @@ -249,35 +245,35 @@ void * GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject * pDataObject) // Check if dataobject supplies the format we want. // Double checking here, first in getGhostType. - if(pDataObject->QueryGetData(&fmtetc) == S_OK) + if (pDataObject->QueryGetData(&fmtetc) == S_OK) { - if(pDataObject->GetData(&fmtetc, &stgmed) == S_OK) + if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK) { - hdrop = (HDROP)::GlobalLock(stgmed.hGlobal); + hdrop = (HDROP) ::GlobalLock(stgmed.hGlobal); - totfiles = ::DragQueryFileW ( hdrop, -1, NULL, 0 ); + totfiles = ::DragQueryFileW(hdrop, -1, NULL, 0); if (!totfiles) { ::GlobalUnlock(stgmed.hGlobal); return NULL; } - strArray = (GHOST_TStringArray*) ::malloc(sizeof(GHOST_TStringArray)); + strArray = (GHOST_TStringArray *) ::malloc(sizeof(GHOST_TStringArray)); strArray->count = 0; - strArray->strings = (GHOST_TUns8**) ::malloc(totfiles*sizeof(GHOST_TUns8*)); + strArray->strings = (GHOST_TUns8 **) ::malloc(totfiles * sizeof(GHOST_TUns8 *)); - for ( UINT nfile = 0; nfile < totfiles; nfile++ ) + for (UINT nfile = 0; nfile < totfiles; nfile++) { - if ( ::DragQueryFileW ( hdrop, nfile, fpath, MAX_PATH ) > 0 ) + if (::DragQueryFileW(hdrop, nfile, fpath, MAX_PATH) > 0) { - if ( !(temp_path = alloc_utf_8_from_16(fpath, 0)) ) + if (!(temp_path = alloc_utf_8_from_16(fpath, 0)) ) { continue; } // Just ignore paths that could not be converted verbatim. - strArray->strings[nvalid] = (GHOST_TUns8*) temp_path; - strArray->count = nvalid+1; + strArray->strings[nvalid] = (GHOST_TUns8 *) temp_path; + strArray->count = nvalid + 1; nvalid++; } } @@ -291,20 +287,20 @@ void * GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject * pDataObject) return NULL; } -void * GHOST_DropTargetWin32::getDropDataAsString(IDataObject * pDataObject) +void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject) { - char* tmp_string; + 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->QueryGetData(&fmtetc) == S_OK) { - if(pDataObject->GetData(&fmtetc, &stgmed) == S_OK) + if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK) { - LPCWSTR wstr = (LPCWSTR)::GlobalLock(stgmed.hGlobal); - if ( !(tmp_string = alloc_utf_8_from_16((wchar_t*)wstr, 0)) ) + LPCWSTR wstr = (LPCWSTR) ::GlobalLock(stgmed.hGlobal); + if (!(tmp_string = alloc_utf_8_from_16((wchar_t *)wstr, 0)) ) { ::GlobalUnlock(stgmed.hGlobal); return NULL; @@ -313,7 +309,7 @@ void * GHOST_DropTargetWin32::getDropDataAsString(IDataObject * pDataObject) ::GlobalUnlock(stgmed.hGlobal); ::ReleaseStgMedium(&stgmed); #ifdef GHOST_DEBUG - ::printf("\n<converted droped unicode string>\n%s\n</droped converted unicode string>\n",tmp_string); + ::printf("\n<converted droped unicode string>\n%s\n</droped converted unicode string>\n", tmp_string); #endif // GHOST_DEBUG return tmp_string; } @@ -321,20 +317,20 @@ void * GHOST_DropTargetWin32::getDropDataAsString(IDataObject * pDataObject) fmtetc.cfFormat = CF_TEXT; - if(pDataObject->QueryGetData(&fmtetc) == S_OK) + if (pDataObject->QueryGetData(&fmtetc) == S_OK) { - if(pDataObject->GetData(&fmtetc, &stgmed) == S_OK) + if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK) { - char * str = (char*)::GlobalLock(stgmed.hGlobal); + char *str = (char *)::GlobalLock(stgmed.hGlobal); - tmp_string = (char*)::malloc(::strlen(str)+1); - if ( !tmp_string ) + tmp_string = (char *)::malloc(::strlen(str) + 1); + if (!tmp_string) { ::GlobalUnlock(stgmed.hGlobal); return NULL; } - if ( !::strcpy(tmp_string, str) ) + if (!::strcpy(tmp_string, str) ) { ::free(tmp_string); ::GlobalUnlock(stgmed.hGlobal); @@ -357,16 +353,16 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char * &out) 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 - ); + 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) + if (!size) { #ifdef GHOST_DEBUG ::printLastError(); @@ -374,7 +370,7 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char * &out) return 0; } - out = (char*)::malloc(size); + out = (char *)::malloc(size); if (!out) { ::printf("\nmalloc failed!!!"); @@ -382,15 +378,15 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char * &out) } size = ::WideCharToMultiByte(CP_ACP, - 0x00000400, - in, - -1, - (LPSTR) out, - size, - NULL,NULL - ); - - if(!size) + 0x00000400, + in, + -1, + (LPSTR) out, + size, + NULL, NULL + ); + + if (!size) { #ifdef GHOST_DEBUG ::printLastError(); @@ -408,15 +404,15 @@ void printLastError(void) DWORD err; err = GetLastError(); - if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - err, - 0, - (LPTSTR)&s, - 0, - NULL) - ) + 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); diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp index 8c2a7f7d1e8..4c03dad2e73 100644 --- a/intern/ghost/intern/GHOST_EventManager.cpp +++ b/intern/ghost/intern/GHOST_EventManager.cpp @@ -51,10 +51,9 @@ GHOST_EventManager::~GHOST_EventManager() { disposeEvents(); - TConsumerVector::iterator iter= m_consumers.begin(); - while (iter != m_consumers.end()) - { - GHOST_IEventConsumer* consumer = *iter; + 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(); @@ -81,9 +80,9 @@ GHOST_TUns32 GHOST_EventManager::getNumEvents(GHOST_TEventType type) } -GHOST_IEvent* GHOST_EventManager::peekEvent() +GHOST_IEvent *GHOST_EventManager::peekEvent() { - GHOST_IEvent* event = 0; + GHOST_IEvent *event = 0; if (m_events.size() > 0) { event = m_events.back(); } @@ -91,7 +90,7 @@ GHOST_IEvent* GHOST_EventManager::peekEvent() } -GHOST_TSuccess GHOST_EventManager::pushEvent(GHOST_IEvent* event) +GHOST_TSuccess GHOST_EventManager::pushEvent(GHOST_IEvent *event) { GHOST_TSuccess success; GHOST_ASSERT(event, "invalid event"); @@ -106,7 +105,7 @@ GHOST_TSuccess GHOST_EventManager::pushEvent(GHOST_IEvent* event) } -bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event) +bool GHOST_EventManager::dispatchEvent(GHOST_IEvent *event) { bool handled; if (event) { @@ -127,7 +126,7 @@ bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event) bool GHOST_EventManager::dispatchEvent() { - GHOST_IEvent* event = popEvent(); + GHOST_IEvent *event = popEvent(); bool handled = false; if (event) { handled = dispatchEvent(event); @@ -155,7 +154,7 @@ bool GHOST_EventManager::dispatchEvents() } -GHOST_TSuccess GHOST_EventManager::addConsumer(GHOST_IEventConsumer* consumer) +GHOST_TSuccess GHOST_EventManager::addConsumer(GHOST_IEventConsumer *consumer) { GHOST_TSuccess success; GHOST_ASSERT(consumer, "invalid consumer"); @@ -175,7 +174,7 @@ GHOST_TSuccess GHOST_EventManager::addConsumer(GHOST_IEventConsumer* consumer) } -GHOST_TSuccess GHOST_EventManager::removeConsumer(GHOST_IEventConsumer* consumer) +GHOST_TSuccess GHOST_EventManager::removeConsumer(GHOST_IEventConsumer *consumer) { GHOST_TSuccess success; GHOST_ASSERT(consumer, "invalid consumer"); @@ -195,16 +194,16 @@ GHOST_TSuccess GHOST_EventManager::removeConsumer(GHOST_IEventConsumer* consumer } -void GHOST_EventManager::removeWindowEvents(GHOST_IWindow* window) +void GHOST_EventManager::removeWindowEvents(GHOST_IWindow *window) { TEventStack::iterator iter; iter = m_events.begin(); while (iter != m_events.end()) { - GHOST_IEvent* event = *iter; + GHOST_IEvent *event = *iter; if (event->getWindow() == window) { - GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n"); + GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n"); /* * Found an event for this window, remove it. * The iterator will become invalid. @@ -213,23 +212,22 @@ void GHOST_EventManager::removeWindowEvents(GHOST_IWindow* window) m_events.erase(iter); iter = m_events.begin(); } - else - { + else { iter++; } } } -void GHOST_EventManager::removeTypeEvents(GHOST_TEventType type, GHOST_IWindow* window) +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; + GHOST_IEvent *event = *iter; if ((event->getType() == type) && (!window || (event->getWindow() == window))) { - GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n"); + GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n"); /* * Found an event of this type for the window, remove it. * The iterator will become invalid. @@ -238,17 +236,16 @@ void GHOST_EventManager::removeTypeEvents(GHOST_TEventType type, GHOST_IWindow* m_events.erase(iter); iter = m_events.begin(); } - else - { + else { iter++; } } } -GHOST_IEvent* GHOST_EventManager::popEvent() +GHOST_IEvent *GHOST_EventManager::popEvent() { - GHOST_IEvent* event = peekEvent(); + GHOST_IEvent *event = peekEvent(); if (event) { m_events.pop_back(); } diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp index 1b5f28aae3b..4b7be84ac81 100644 --- a/intern/ghost/intern/GHOST_EventPrinter.cpp +++ b/intern/ghost/intern/GHOST_EventPrinter.cpp @@ -38,7 +38,7 @@ #include <stdio.h> -bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event) +bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event) { bool handled = true; @@ -48,136 +48,136 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event) 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_kEventUnknown: + std::cout << "GHOST_kEventUnknown"; handled = false; + break; - case GHOST_kEventButtonUp: + case GHOST_kEventButtonUp: { - GHOST_TEventButtonData* buttonData = (GHOST_TEventButtonData*)((GHOST_IEvent*)event)->getData(); - std::cout << "GHOST_kEventCursorButtonUp, button: " << buttonData->button; + GHOST_TEventButtonData *buttonData = (GHOST_TEventButtonData *)((GHOST_IEvent *)event)->getData(); + std::cout << "GHOST_kEventCursorButtonUp, button: " << buttonData->button; } break; - case GHOST_kEventButtonDown: + case GHOST_kEventButtonDown: { - GHOST_TEventButtonData* buttonData = (GHOST_TEventButtonData*)((GHOST_IEvent*)event)->getData(); - std::cout << "GHOST_kEventButtonDown, button: " << buttonData->button; + GHOST_TEventButtonData *buttonData = (GHOST_TEventButtonData *)((GHOST_IEvent *)event)->getData(); + std::cout << "GHOST_kEventButtonDown, button: " << buttonData->button; } break; - case GHOST_kEventWheel: + case GHOST_kEventWheel: { - GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*)((GHOST_IEvent*)event)->getData(); - std::cout << "GHOST_kEventWheel, z: " << wheelData->z; + GHOST_TEventWheelData *wheelData = (GHOST_TEventWheelData *)((GHOST_IEvent *)event)->getData(); + std::cout << "GHOST_kEventWheel, z: " << wheelData->z; } break; - case GHOST_kEventCursorMove: + case GHOST_kEventCursorMove: { - GHOST_TEventCursorData* cursorData = (GHOST_TEventCursorData*)((GHOST_IEvent*)event)->getData(); - std::cout << "GHOST_kEventCursorMove, (x,y): (" << cursorData->x << "," << cursorData->y << ")"; + GHOST_TEventCursorData *cursorData = (GHOST_TEventCursorData *)((GHOST_IEvent *)event)->getData(); + std::cout << "GHOST_kEventCursorMove, (x,y): (" << cursorData->x << "," << cursorData->y << ")"; } break; - case GHOST_kEventKeyUp: + case GHOST_kEventKeyUp: { - GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*)((GHOST_IEvent*)event)->getData(); - char str[32]= {'\0'}; - getKeyString(keyData->key, str); - std::cout << "GHOST_kEventKeyUp, key: " << str; + GHOST_TEventKeyData *keyData = (GHOST_TEventKeyData *)((GHOST_IEvent *)event)->getData(); + char str[32] = {'\0'}; + getKeyString(keyData->key, str); + std::cout << "GHOST_kEventKeyUp, key: " << str; } break; - case GHOST_kEventKeyDown: + case GHOST_kEventKeyDown: { - GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*)((GHOST_IEvent*)event)->getData(); - char str[32]= {'\0'}; - getKeyString(keyData->key, str); - std::cout << "GHOST_kEventKeyDown, key: " << str; + GHOST_TEventKeyData *keyData = (GHOST_TEventKeyData *)((GHOST_IEvent *)event)->getData(); + char str[32] = {'\0'}; + getKeyString(keyData->key, str); + std::cout << "GHOST_kEventKeyDown, key: " << str; } break; - case GHOST_kEventDraggingEntered: + case GHOST_kEventDraggingEntered: { - GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + 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: + case GHOST_kEventDraggingUpdated: { - GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + 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: + case GHOST_kEventDraggingExited: { - GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + GHOST_TEventDragnDropData *dragnDropData = (GHOST_TEventDragnDropData *)((GHOST_IEvent *)event)->getData(); std::cout << "GHOST_kEventDraggingExited, dragged object type : " << dragnDropData->dataType; } break; - case GHOST_kEventDraggingDropDone: + case GHOST_kEventDraggingDropDone: { - GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + 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; + std::cout << "\n String received = " << (char *)dragnDropData->data; break; case GHOST_kDragnDropTypeFilenames: { - GHOST_TStringArray *strArray = (GHOST_TStringArray*)dragnDropData->data; + 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]; + for (i = 0; i < strArray->count; i++) + std::cout << "\n File["<< i << "] : " << strArray->strings[i]; } - break; + break; default: break; } } break; - case GHOST_kEventOpenMainFile: + case GHOST_kEventOpenMainFile: { - GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData(); + GHOST_TEventDataPtr eventData = ((GHOST_IEvent *)event)->getData(); if (eventData) - std::cout << "GHOST_kEventOpenMainFile for path : " << (char*)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; + 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; + default: + std::cout << "not found"; handled = false; + break; } return handled; } @@ -187,154 +187,159 @@ void GHOST_EventPrinter::getKeyString(GHOST_TKey key, char str[32]) const { if ((key >= GHOST_kKeyComma) && (key <= GHOST_kKeyRightBracket)) { sprintf(str, "%c", (char)key); - } else if ((key >= GHOST_kKeyNumpad0) && (key <= GHOST_kKeyNumpad9)) { + } + else if ((key >= GHOST_kKeyNumpad0) && (key <= GHOST_kKeyNumpad9)) { sprintf(str, "Numpad %d", (key - GHOST_kKeyNumpad0)); #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 */ + } + else if (key == 268828432) { /* solaris keyboards are messed up */ + /* This should really test XK_F11 but that doesn't work */ strcpy(str, "F11"); - } else if (key == 268828433) { /* solaris keyboards are messed up */ - /* This should really test XK_F12 but that doesn't work */ + } + else if (key == 268828433) { /* solaris keyboards are messed up */ + /* This should really test XK_F12 but that doesn't work */ strcpy(str, "F12"); #endif - } else if ((key >= GHOST_kKeyF1) && (key <= GHOST_kKeyF24)) { + } + else if ((key >= GHOST_kKeyF1) && (key <= GHOST_kKeyF24)) { sprintf(str, "F%d", key - GHOST_kKeyF1 + 1); - } else { - const char *tstr= NULL; + } + else { + const char *tstr = NULL; switch (key) { - case GHOST_kKeyBackSpace: - tstr = "BackSpace"; - break; - case GHOST_kKeyTab: - tstr = "Tab"; - break; - case GHOST_kKeyLinefeed: - tstr = "Linefeed"; - break; - case GHOST_kKeyClear: - tstr = "Clear"; - break; - case GHOST_kKeyEnter: - tstr = "Enter"; - break; - case GHOST_kKeyEsc: - tstr = "Esc"; - break; - case GHOST_kKeySpace: - tstr = "Space"; - break; - case GHOST_kKeyQuote: - tstr = "Quote"; - break; - case GHOST_kKeyBackslash: - tstr = "\\"; - break; - case GHOST_kKeyAccentGrave: - tstr = "`"; - break; - case GHOST_kKeyLeftShift: - tstr = "LeftShift"; - break; - case GHOST_kKeyRightShift: - tstr = "RightShift"; - break; - case GHOST_kKeyLeftControl: - tstr = "LeftControl"; - break; - case GHOST_kKeyRightControl: - tstr = "RightControl"; - break; - case GHOST_kKeyLeftAlt: - tstr = "LeftAlt"; - break; - case GHOST_kKeyRightAlt: - tstr = "RightAlt"; - break; - case GHOST_kKeyOS: - tstr = "OS"; - break; - case GHOST_kKeyGrLess: - // PC german! - tstr = "GrLess"; - break; - case GHOST_kKeyCapsLock: - tstr = "CapsLock"; - break; - case GHOST_kKeyNumLock: - tstr = "NumLock"; - break; - case GHOST_kKeyScrollLock: - tstr = "ScrollLock"; - break; - case GHOST_kKeyLeftArrow: - tstr = "LeftArrow"; - break; - case GHOST_kKeyRightArrow: - tstr = "RightArrow"; - break; - case GHOST_kKeyUpArrow: - tstr = "UpArrow"; - break; - case GHOST_kKeyDownArrow: - tstr = "DownArrow"; - break; - case GHOST_kKeyPrintScreen: - tstr = "PrintScreen"; - break; - case GHOST_kKeyPause: - tstr = "Pause"; - break; - case GHOST_kKeyInsert: - tstr = "Insert"; - break; - case GHOST_kKeyDelete: - tstr = "Delete"; - break; - case GHOST_kKeyHome: - tstr = "Home"; - break; - case GHOST_kKeyEnd: - tstr = "End"; - break; - case GHOST_kKeyUpPage: - tstr = "UpPage"; - break; - case GHOST_kKeyDownPage: - tstr = "DownPage"; - break; - case GHOST_kKeyNumpadPeriod: - tstr = "NumpadPeriod"; - break; - case GHOST_kKeyNumpadEnter: - tstr = "NumpadEnter"; - break; - case GHOST_kKeyNumpadPlus: - tstr = "NumpadPlus"; - break; - case GHOST_kKeyNumpadMinus: - tstr = "NumpadMinus"; - break; - case GHOST_kKeyNumpadAsterisk: - tstr = "NumpadAsterisk"; - break; - case GHOST_kKeyNumpadSlash: - tstr = "NumpadSlash"; - break; - case GHOST_kKeyMediaPlay: - tstr = "MediaPlayPause"; - break; - case GHOST_kKeyMediaStop: - tstr = "MediaStop"; - break; - case GHOST_kKeyMediaFirst: - tstr = "MediaFirst"; - break; - case GHOST_kKeyMediaLast: - tstr = "MediaLast"; - break; - default: - tstr = "unknown"; - break; + case GHOST_kKeyBackSpace: + tstr = "BackSpace"; + break; + case GHOST_kKeyTab: + tstr = "Tab"; + break; + case GHOST_kKeyLinefeed: + tstr = "Linefeed"; + break; + case GHOST_kKeyClear: + tstr = "Clear"; + break; + case GHOST_kKeyEnter: + tstr = "Enter"; + break; + case GHOST_kKeyEsc: + tstr = "Esc"; + break; + case GHOST_kKeySpace: + tstr = "Space"; + break; + case GHOST_kKeyQuote: + tstr = "Quote"; + break; + case GHOST_kKeyBackslash: + tstr = "\\"; + break; + case GHOST_kKeyAccentGrave: + tstr = "`"; + break; + case GHOST_kKeyLeftShift: + tstr = "LeftShift"; + break; + case GHOST_kKeyRightShift: + tstr = "RightShift"; + break; + case GHOST_kKeyLeftControl: + tstr = "LeftControl"; + break; + case GHOST_kKeyRightControl: + tstr = "RightControl"; + break; + case GHOST_kKeyLeftAlt: + tstr = "LeftAlt"; + break; + case GHOST_kKeyRightAlt: + tstr = "RightAlt"; + break; + case GHOST_kKeyOS: + tstr = "OS"; + break; + case GHOST_kKeyGrLess: + // PC german! + tstr = "GrLess"; + break; + case GHOST_kKeyCapsLock: + tstr = "CapsLock"; + break; + case GHOST_kKeyNumLock: + tstr = "NumLock"; + break; + case GHOST_kKeyScrollLock: + tstr = "ScrollLock"; + break; + case GHOST_kKeyLeftArrow: + tstr = "LeftArrow"; + break; + case GHOST_kKeyRightArrow: + tstr = "RightArrow"; + break; + case GHOST_kKeyUpArrow: + tstr = "UpArrow"; + break; + case GHOST_kKeyDownArrow: + tstr = "DownArrow"; + break; + case GHOST_kKeyPrintScreen: + tstr = "PrintScreen"; + break; + case GHOST_kKeyPause: + tstr = "Pause"; + break; + case GHOST_kKeyInsert: + tstr = "Insert"; + break; + case GHOST_kKeyDelete: + tstr = "Delete"; + break; + case GHOST_kKeyHome: + tstr = "Home"; + break; + case GHOST_kKeyEnd: + tstr = "End"; + break; + case GHOST_kKeyUpPage: + tstr = "UpPage"; + break; + case GHOST_kKeyDownPage: + tstr = "DownPage"; + break; + case GHOST_kKeyNumpadPeriod: + tstr = "NumpadPeriod"; + break; + case GHOST_kKeyNumpadEnter: + tstr = "NumpadEnter"; + break; + case GHOST_kKeyNumpadPlus: + tstr = "NumpadPlus"; + break; + case GHOST_kKeyNumpadMinus: + tstr = "NumpadMinus"; + break; + case GHOST_kKeyNumpadAsterisk: + tstr = "NumpadAsterisk"; + break; + case GHOST_kKeyNumpadSlash: + tstr = "NumpadSlash"; + break; + case GHOST_kKeyMediaPlay: + tstr = "MediaPlayPause"; + break; + case GHOST_kKeyMediaStop: + tstr = "MediaStop"; + break; + case GHOST_kKeyMediaFirst: + tstr = "MediaFirst"; + break; + case GHOST_kKeyMediaLast: + tstr = "MediaLast"; + break; + default: + tstr = "unknown"; + break; } sprintf(str, "%s", tstr); diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp index 66d8a3176bd..e983bd8214a 100644 --- a/intern/ghost/intern/GHOST_ISystem.cpp +++ b/intern/ghost/intern/GHOST_ISystem.cpp @@ -40,25 +40,25 @@ #include "GHOST_ISystem.h" #ifdef WITH_HEADLESS -# include "GHOST_SystemNULL.h" +# include "GHOST_SystemNULL.h" #elif defined(WITH_GHOST_SDL) -# include "GHOST_SystemSDL.h" +# include "GHOST_SystemSDL.h" #elif defined(WIN32) -# include "GHOST_SystemWin32.h" +# include "GHOST_SystemWin32.h" #else -# ifdef __APPLE__ -# ifdef GHOST_COCOA -# include "GHOST_SystemCocoa.h" -# else -# include "GHOST_SystemCarbon.h" -# endif -# else -# include "GHOST_SystemX11.h" -# endif +# ifdef __APPLE__ +# ifdef GHOST_COCOA +# include "GHOST_SystemCocoa.h" +# else +# include "GHOST_SystemCarbon.h" +# endif +# else +# include "GHOST_SystemX11.h" +# endif #endif -GHOST_ISystem* GHOST_ISystem::m_system = 0; +GHOST_ISystem *GHOST_ISystem::m_system = 0; GHOST_TSuccess GHOST_ISystem::createSystem() @@ -70,17 +70,17 @@ GHOST_TSuccess GHOST_ISystem::createSystem() #elif defined(WITH_GHOST_SDL) m_system = new GHOST_SystemSDL(); #elif defined(WIN32) - m_system = new GHOST_SystemWin32 (); + m_system = new GHOST_SystemWin32(); #else -# ifdef __APPLE__ -# ifdef GHOST_COCOA - m_system = new GHOST_SystemCocoa (); -# else - m_system = new GHOST_SystemCarbon (); -# endif -# else - m_system = new GHOST_SystemX11 (); -# endif +# ifdef __APPLE__ +# ifdef GHOST_COCOA + m_system = new GHOST_SystemCocoa(); +# else + m_system = new GHOST_SystemCarbon(); +# endif +# else + m_system = new GHOST_SystemX11(); +# endif #endif success = m_system != 0 ? GHOST_kSuccess : GHOST_kFailure; } @@ -107,7 +107,7 @@ GHOST_TSuccess GHOST_ISystem::disposeSystem() } -GHOST_ISystem* GHOST_ISystem::getSystem() +GHOST_ISystem *GHOST_ISystem::getSystem() { return m_system; } diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp index 55fc2c3796f..0ad9dd48d2b 100644 --- a/intern/ghost/intern/GHOST_ISystemPaths.cpp +++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp @@ -40,21 +40,21 @@ #include "GHOST_ISystemPaths.h" #ifdef WIN32 -# include "GHOST_SystemPathsWin32.h" +# include "GHOST_SystemPathsWin32.h" #else -# ifdef __APPLE__ -# ifdef GHOST_COCOA -# include "GHOST_SystemPathsCocoa.h" -# else -# include "GHOST_SystemPathsCarbon.h" -# endif -# else -# include "GHOST_SystemPathsX11.h" -# endif +# ifdef __APPLE__ +# ifdef GHOST_COCOA +# include "GHOST_SystemPathsCocoa.h" +# else +# include "GHOST_SystemPathsCarbon.h" +# endif +# else +# include "GHOST_SystemPathsX11.h" +# endif #endif -GHOST_ISystemPaths* GHOST_ISystemPaths::m_systemPaths = 0; +GHOST_ISystemPaths *GHOST_ISystemPaths::m_systemPaths = 0; GHOST_TSuccess GHOST_ISystemPaths::create() @@ -62,17 +62,17 @@ GHOST_TSuccess GHOST_ISystemPaths::create() GHOST_TSuccess success; if (!m_systemPaths) { #ifdef WIN32 - m_systemPaths = new GHOST_SystemPathsWin32 (); + m_systemPaths = new GHOST_SystemPathsWin32(); #else -# ifdef __APPLE__ -# ifdef GHOST_COCOA - m_systemPaths = new GHOST_SystemPathsCocoa (); -# else - m_systemPaths = new GHOST_SystemPathsCarbon (); -# endif -# else - m_systemPaths = new GHOST_SystemPathsX11 (); -# endif +# ifdef __APPLE__ +# ifdef GHOST_COCOA + m_systemPaths = new GHOST_SystemPathsCocoa(); +# else + m_systemPaths = new GHOST_SystemPathsCarbon(); +# endif +# else + m_systemPaths = new GHOST_SystemPathsX11(); +# endif #endif success = m_systemPaths != 0 ? GHOST_kSuccess : GHOST_kFailure; } @@ -95,7 +95,7 @@ GHOST_TSuccess GHOST_ISystemPaths::dispose() return success; } -GHOST_ISystemPaths* GHOST_ISystemPaths::get() +GHOST_ISystemPaths *GHOST_ISystemPaths::get() { if (!m_systemPaths) { create(); diff --git a/intern/ghost/intern/GHOST_ModifierKeys.cpp b/intern/ghost/intern/GHOST_ModifierKeys.cpp index 553a45fd948..a02e6218891 100644 --- a/intern/ghost/intern/GHOST_ModifierKeys.cpp +++ b/intern/ghost/intern/GHOST_ModifierKeys.cpp @@ -52,17 +52,17 @@ GHOST_TKey GHOST_ModifierKeys::getModifierKeyCode(GHOST_TModifierKeyMask mask) { GHOST_TKey key; switch (mask) { - case GHOST_kModifierKeyLeftShift: key = GHOST_kKeyLeftShift; break; - case GHOST_kModifierKeyRightShift: key = GHOST_kKeyRightShift; break; - case GHOST_kModifierKeyLeftAlt: key = GHOST_kKeyLeftAlt; break; - case GHOST_kModifierKeyRightAlt: key = GHOST_kKeyRightAlt; break; - case GHOST_kModifierKeyLeftControl: key = GHOST_kKeyLeftControl; break; - case GHOST_kModifierKeyRightControl: key = GHOST_kKeyRightControl; break; - case GHOST_kModifierKeyOS: key = GHOST_kKeyOS; break; - default: - // Should not happen - key = GHOST_kKeyUnknown; - break; + case GHOST_kModifierKeyLeftShift: key = GHOST_kKeyLeftShift; break; + case GHOST_kModifierKeyRightShift: key = GHOST_kKeyRightShift; break; + case GHOST_kModifierKeyLeftAlt: key = GHOST_kKeyLeftAlt; break; + case GHOST_kModifierKeyRightAlt: key = GHOST_kKeyRightAlt; break; + case GHOST_kModifierKeyLeftControl: key = GHOST_kKeyLeftControl; break; + case GHOST_kModifierKeyRightControl: key = GHOST_kKeyRightControl; break; + case GHOST_kModifierKeyOS: key = GHOST_kKeyOS; break; + default: + // Should not happen + key = GHOST_kKeyUnknown; + break; } return key; } @@ -70,69 +70,69 @@ GHOST_TKey GHOST_ModifierKeys::getModifierKeyCode(GHOST_TModifierKeyMask mask) bool GHOST_ModifierKeys::get(GHOST_TModifierKeyMask mask) const { - switch (mask) { - case GHOST_kModifierKeyLeftShift: - return m_LeftShift; - case GHOST_kModifierKeyRightShift: - return m_RightShift; - case GHOST_kModifierKeyLeftAlt: - return m_LeftAlt; - case GHOST_kModifierKeyRightAlt: - return m_RightAlt; - case GHOST_kModifierKeyLeftControl: - return m_LeftControl; - case GHOST_kModifierKeyRightControl: - return m_RightControl; - case GHOST_kModifierKeyOS: - return m_OS; - default: - return false; - } + switch (mask) { + case GHOST_kModifierKeyLeftShift: + return m_LeftShift; + case GHOST_kModifierKeyRightShift: + return m_RightShift; + case GHOST_kModifierKeyLeftAlt: + return m_LeftAlt; + case GHOST_kModifierKeyRightAlt: + return m_RightAlt; + case GHOST_kModifierKeyLeftControl: + return m_LeftControl; + case GHOST_kModifierKeyRightControl: + return m_RightControl; + case GHOST_kModifierKeyOS: + return m_OS; + default: + return false; + } } void GHOST_ModifierKeys::set(GHOST_TModifierKeyMask mask, bool down) { - switch (mask) { - case GHOST_kModifierKeyLeftShift: - m_LeftShift = down; break; - case GHOST_kModifierKeyRightShift: - m_RightShift = down; break; - case GHOST_kModifierKeyLeftAlt: - m_LeftAlt = down; break; - case GHOST_kModifierKeyRightAlt: - m_RightAlt = down; break; - case GHOST_kModifierKeyLeftControl: - m_LeftControl = down; break; - case GHOST_kModifierKeyRightControl: - m_RightControl = down; break; - case GHOST_kModifierKeyOS: - m_OS = down; break; - default: - break; - } + switch (mask) { + case GHOST_kModifierKeyLeftShift: + m_LeftShift = down; break; + case GHOST_kModifierKeyRightShift: + m_RightShift = down; break; + case GHOST_kModifierKeyLeftAlt: + m_LeftAlt = down; break; + case GHOST_kModifierKeyRightAlt: + m_RightAlt = down; break; + case GHOST_kModifierKeyLeftControl: + m_LeftControl = down; break; + case GHOST_kModifierKeyRightControl: + m_RightControl = down; break; + case GHOST_kModifierKeyOS: + m_OS = down; break; + default: + break; + } } void GHOST_ModifierKeys::clear() { - m_LeftShift = false; - m_RightShift = false; - m_LeftAlt = false; - m_RightAlt = false; - m_LeftControl = false; - m_RightControl = false; - m_OS = false; + m_LeftShift = false; + m_RightShift = false; + m_LeftAlt = false; + m_RightAlt = false; + m_LeftControl = false; + m_RightControl = false; + m_OS = false; } bool GHOST_ModifierKeys::equals(const GHOST_ModifierKeys& keys) const { return (m_LeftShift == keys.m_LeftShift) && - (m_RightShift == keys.m_RightShift) && - (m_LeftAlt == keys.m_LeftAlt) && - (m_RightAlt == keys.m_RightAlt) && - (m_LeftControl == keys.m_LeftControl) && - (m_RightControl == keys.m_RightControl) && - (m_OS == keys.m_OS); + (m_RightShift == keys.m_RightShift) && + (m_LeftAlt == keys.m_LeftAlt) && + (m_RightAlt == keys.m_RightAlt) && + (m_LeftControl == keys.m_LeftControl) && + (m_RightControl == keys.m_RightControl) && + (m_OS == keys.m_OS); } diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp index e5f523ca8ef..79102967f3e 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.cpp +++ b/intern/ghost/intern/GHOST_NDOFManager.cpp @@ -32,12 +32,12 @@ #ifdef DEBUG_NDOF_MOTION // printable version of each GHOST_TProgress value -static const char* progress_string[] = - {"not started","starting","in progress","finishing","finished"}; +static const char *progress_string[] = +{"not started", "starting", "in progress", "finishing", "finished"}; #endif #ifdef DEBUG_NDOF_BUTTONS -static const char* ndof_button_names[] = { +static const char *ndof_button_names[] = { // used internally, never sent "NDOF_BUTTON_NONE", // these two are available from any 3Dconnexion device @@ -309,13 +309,13 @@ void GHOST_NDOFManager::updateRotation(short r[3], GHOST_TUns64 time) m_motionEventPending = true; } -void GHOST_NDOFManager::sendButtonEvent(NDOF_ButtonT button, bool press, GHOST_TUns64 time, GHOST_IWindow* window) +void GHOST_NDOFManager::sendButtonEvent(NDOF_ButtonT button, bool press, GHOST_TUns64 time, GHOST_IWindow *window) { GHOST_ASSERT(button > NDOF_BUTTON_NONE && button < NDOF_BUTTON_LAST, - "rogue button trying to escape NDOF manager"); + "rogue button trying to escape NDOF manager"); - GHOST_EventNDOFButton* event = new GHOST_EventNDOFButton(time, window); - GHOST_TEventNDOFButtonData* data = (GHOST_TEventNDOFButtonData*) event->getData(); + GHOST_EventNDOFButton *event = new GHOST_EventNDOFButton(time, window); + GHOST_TEventNDOFButtonData *data = (GHOST_TEventNDOFButtonData *) event->getData(); data->action = press ? GHOST_kPress : GHOST_kRelease; data->button = button; @@ -327,10 +327,10 @@ void GHOST_NDOFManager::sendButtonEvent(NDOF_ButtonT button, bool press, GHOST_T m_system.pushEvent(event); } -void GHOST_NDOFManager::sendKeyEvent(GHOST_TKey key, bool press, GHOST_TUns64 time, GHOST_IWindow* window) +void GHOST_NDOFManager::sendKeyEvent(GHOST_TKey key, bool press, GHOST_TUns64 time, GHOST_IWindow *window) { GHOST_TEventType type = press ? GHOST_kEventKeyDown : GHOST_kEventKeyUp; - GHOST_EventKey* event = new GHOST_EventKey(time, type, window, key); + GHOST_EventKey *event = new GHOST_EventKey(time, type, window, key); #ifdef DEBUG_NDOF_BUTTONS printf("keyboard %s\n", press ? "down" : "up"); @@ -341,7 +341,7 @@ void GHOST_NDOFManager::sendKeyEvent(GHOST_TKey key, bool press, GHOST_TUns64 ti void GHOST_NDOFManager::updateButton(int button_number, bool press, GHOST_TUns64 time) { - GHOST_IWindow* window = m_system.getWindowManager()->getActiveWindow(); + GHOST_IWindow *window = m_system.getWindowManager()->getActiveWindow(); #ifdef DEBUG_NDOF_BUTTONS printf("ndof: button %d -> ", button_number); @@ -403,14 +403,14 @@ void GHOST_NDOFManager::setDeadZone(float dz) GHOST_PRINTF("ndof: dead zone set to %.2f\n", dz); } -static bool atHomePosition(GHOST_TEventNDOFMotionData* ndof) +static bool atHomePosition(GHOST_TEventNDOFMotionData *ndof) { #define HOME(foo) (ndof->foo == 0.f) return HOME(tx) && HOME(ty) && HOME(tz) && HOME(rx) && HOME(ry) && HOME(rz); #undef HOME } -static bool nearHomePosition(GHOST_TEventNDOFMotionData* ndof, float threshold) +static bool nearHomePosition(GHOST_TEventNDOFMotionData *ndof, float threshold) { if (threshold == 0.f) { return atHomePosition(ndof); @@ -429,14 +429,14 @@ bool GHOST_NDOFManager::sendMotionEvent() m_motionEventPending = false; // any pending motion is handled right now - GHOST_IWindow* window = m_system.getWindowManager()->getActiveWindow(); + GHOST_IWindow *window = m_system.getWindowManager()->getActiveWindow(); if (window == NULL) { return false; // delivery will fail, so don't bother sending } - GHOST_EventNDOFMotion* event = new GHOST_EventNDOFMotion(m_motionTime, window); - GHOST_TEventNDOFMotionData* data = (GHOST_TEventNDOFMotionData*) event->getData(); + GHOST_EventNDOFMotion *event = new GHOST_EventNDOFMotion(m_motionTime, window); + GHOST_TEventNDOFMotionData *data = (GHOST_TEventNDOFMotionData *) event->getData(); // scale axis values here to normalize them to around +/- 1 // they are scaled again for overall sensitivity in the WM based on user prefs diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp index 6c1627905e0..939e1272434 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp @@ -28,7 +28,7 @@ GHOST_NDOFManagerWin32::GHOST_NDOFManagerWin32(GHOST_System& sys) - : GHOST_NDOFManager(sys) + : GHOST_NDOFManager(sys) { setDeadZone(0.1f); } diff --git a/intern/ghost/intern/GHOST_Path-api.cpp b/intern/ghost/intern/GHOST_Path-api.cpp index 1d5410700c6..e92623352b4 100644 --- a/intern/ghost/intern/GHOST_Path-api.cpp +++ b/intern/ghost/intern/GHOST_Path-api.cpp @@ -45,27 +45,27 @@ GHOST_TSuccess GHOST_DisposeSystemPaths(void) return GHOST_ISystemPaths::dispose(); } -const GHOST_TUns8* GHOST_getSystemDir() +const GHOST_TUns8 *GHOST_getSystemDir() { - GHOST_ISystemPaths* systemPaths = GHOST_ISystemPaths::get(); + GHOST_ISystemPaths *systemPaths = GHOST_ISystemPaths::get(); return systemPaths ? systemPaths->getSystemDir() : 0; } -const GHOST_TUns8* GHOST_getUserDir() +const GHOST_TUns8 *GHOST_getUserDir() { - GHOST_ISystemPaths* systemPaths = GHOST_ISystemPaths::get(); + GHOST_ISystemPaths *systemPaths = GHOST_ISystemPaths::get(); return systemPaths ? systemPaths->getUserDir() : 0; /* shouldn't be NULL */ } -const GHOST_TUns8* GHOST_getBinaryDir() +const GHOST_TUns8 *GHOST_getBinaryDir() { - GHOST_ISystemPaths* systemPaths = GHOST_ISystemPaths::get(); + GHOST_ISystemPaths *systemPaths = GHOST_ISystemPaths::get(); return systemPaths ? systemPaths->getBinaryDir() : 0; /* shouldn't be NULL */ } -void GHOST_addToSystemRecentFiles(const char* filename) +void GHOST_addToSystemRecentFiles(const char *filename) { - GHOST_ISystemPaths* systemPaths = GHOST_ISystemPaths::get(); + GHOST_ISystemPaths *systemPaths = GHOST_ISystemPaths::get(); if (systemPaths) { systemPaths->addToSystemRecentFiles(filename); } diff --git a/intern/ghost/intern/GHOST_Rect.cpp b/intern/ghost/intern/GHOST_Rect.cpp index 0717259b369..dc30b3eb220 100644 --- a/intern/ghost/intern/GHOST_Rect.cpp +++ b/intern/ghost/intern/GHOST_Rect.cpp @@ -97,10 +97,10 @@ GHOST_TVisibility GHOST_Rect::getVisibility(GHOST_Rect& r) const void GHOST_Rect::setCenter(GHOST_TInt32 cx, GHOST_TInt32 cy) { - GHOST_TInt32 offset = cx - (m_l + (m_r - m_l)/2); + GHOST_TInt32 offset = cx - (m_l + (m_r - m_l) / 2); m_l += offset; m_r += offset; - offset = cy - (m_t + (m_b - m_t)/2); + offset = cy - (m_t + (m_b - m_t) / 2); m_t += offset; m_b += offset; } diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 974f66c666a..ee21128ecbb 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -45,12 +45,12 @@ GHOST_System::GHOST_System() - : m_displayManager(0), - m_timerManager(0), - m_windowManager(0), - m_eventManager(0) + : m_displayManager(0), + m_timerManager(0), + m_windowManager(0), + m_eventManager(0) #ifdef WITH_INPUT_NDOF - , m_ndofManager(0) + , m_ndofManager(0) #endif { } @@ -73,13 +73,13 @@ GHOST_TUns64 GHOST_System::getMilliSeconds() const } -GHOST_ITimerTask* GHOST_System::installTimer(GHOST_TUns64 delay, +GHOST_ITimerTask *GHOST_System::installTimer(GHOST_TUns64 delay, GHOST_TUns64 interval, GHOST_TimerProcPtr timerProc, GHOST_TUserDataPtr userData) { GHOST_TUns64 millis = getMilliSeconds(); - GHOST_TimerTask* timer = new GHOST_TimerTask(millis+delay, interval, timerProc, userData); + GHOST_TimerTask *timer = new GHOST_TimerTask(millis + delay, interval, timerProc, userData); if (timer) { if (m_timerManager->addTimer(timer) == GHOST_kSuccess) { // Check to see whether we need to fire the timer right away @@ -94,17 +94,17 @@ GHOST_ITimerTask* GHOST_System::installTimer(GHOST_TUns64 delay, } -GHOST_TSuccess GHOST_System::removeTimer(GHOST_ITimerTask* timerTask) +GHOST_TSuccess GHOST_System::removeTimer(GHOST_ITimerTask *timerTask) { GHOST_TSuccess success = GHOST_kFailure; if (timerTask) { - success = m_timerManager->removeTimer((GHOST_TimerTask*)timerTask); + success = m_timerManager->removeTimer((GHOST_TimerTask *)timerTask); } return success; } -GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow* window) +GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow *window) { GHOST_TSuccess success; @@ -132,14 +132,14 @@ GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow* window) } -bool GHOST_System::validWindow(GHOST_IWindow* window) +bool GHOST_System::validWindow(GHOST_IWindow *window) { return m_windowManager->getWindowFound(window); } -GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, - const bool stereoVisual, const GHOST_TUns16 numOfAASamples) +GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow **window, + const bool stereoVisual, const GHOST_TUns16 numOfAASamples) { GHOST_TSuccess success = GHOST_kFailure; GHOST_ASSERT(m_windowManager, "GHOST_System::beginFullScreen(): invalid window manager") @@ -151,7 +151,7 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting); if (success == GHOST_kSuccess) { //GHOST_PRINT("GHOST_System::beginFullScreen(): creating full-screen window\n"); - success = createFullScreenWindow((GHOST_Window**)window, stereoVisual, numOfAASamples); + success = createFullScreenWindow((GHOST_Window **)window, stereoVisual, numOfAASamples); if (success == GHOST_kSuccess) { m_windowManager->beginFullScreen(*window, stereoVisual); } @@ -168,11 +168,11 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting } -GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window) +GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow **window) { GHOST_TSuccess success = GHOST_kFailure; GHOST_ASSERT(m_windowManager, "GHOST_System::updateFullScreen(): invalid window manager"); - if(m_displayManager) { + if (m_displayManager) { if (m_windowManager->getFullScreen()) { success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting); } @@ -233,7 +233,7 @@ bool GHOST_System::dispatchEvents() } -GHOST_TSuccess GHOST_System::addEventConsumer(GHOST_IEventConsumer* consumer) +GHOST_TSuccess GHOST_System::addEventConsumer(GHOST_IEventConsumer *consumer) { GHOST_TSuccess success; if (m_eventManager) { @@ -245,7 +245,7 @@ GHOST_TSuccess GHOST_System::addEventConsumer(GHOST_IEventConsumer* consumer) return success; } -GHOST_TSuccess GHOST_System::removeEventConsumer(GHOST_IEventConsumer* consumer) +GHOST_TSuccess GHOST_System::removeEventConsumer(GHOST_IEventConsumer *consumer) { GHOST_TSuccess success; if (m_eventManager) { @@ -257,7 +257,7 @@ GHOST_TSuccess GHOST_System::removeEventConsumer(GHOST_IEventConsumer* consumer) return success; } -GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent* event) +GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent *event) { GHOST_TSuccess success; if (m_eventManager) { @@ -296,9 +296,9 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown GHOST_TSuccess GHOST_System::init() { - m_timerManager = new GHOST_TimerManager (); - m_windowManager = new GHOST_WindowManager (); - m_eventManager = new GHOST_EventManager (); + m_timerManager = new GHOST_TimerManager(); + m_windowManager = new GHOST_WindowManager(); + m_eventManager = new GHOST_EventManager(); #ifdef GHOST_DEBUG if (m_eventManager) { @@ -309,7 +309,8 @@ GHOST_TSuccess GHOST_System::init() if (m_timerManager && m_windowManager && m_eventManager) { return GHOST_kSuccess; - } else { + } + else { return GHOST_kFailure; } } @@ -346,7 +347,7 @@ GHOST_TSuccess GHOST_System::exit() } -GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window** window, const bool stereoVisual, const GHOST_TUns16 numOfAASamples) +GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window, const bool stereoVisual, const GHOST_TUns16 numOfAASamples) { GHOST_TSuccess success; GHOST_ASSERT(m_displayManager, "GHOST_System::createFullScreenWindow(): invalid display manager") @@ -355,20 +356,20 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window** window, const success = m_displayManager->getCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, settings); if (success) { //GHOST_PRINT("GHOST_System::createFullScreenWindow(): creating full-screen window\n"); - *window = (GHOST_Window*)createWindow( - STR_String (""), - 0, 0, settings.xPixels, settings.yPixels, - GHOST_kWindowStateFullScreen, - GHOST_kDrawingContextTypeOpenGL, - stereoVisual, - numOfAASamples); + *window = (GHOST_Window *)createWindow( + STR_String(""), + 0, 0, settings.xPixels, settings.yPixels, + GHOST_kWindowStateFullScreen, + GHOST_kDrawingContextTypeOpenGL, + stereoVisual, + numOfAASamples); success = *window == 0 ? GHOST_kFailure : GHOST_kSuccess; } return success; } -int GHOST_System::confirmQuit(GHOST_IWindow * window) const +int GHOST_System::confirmQuit(GHOST_IWindow *window) const { return 1; } diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp index 5db392e1706..fc4ca8f8f61 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.cpp +++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp @@ -61,21 +61,21 @@ /* blender class and types events */ enum { - kEventClassBlender = 'blnd' + kEventClassBlender = 'blnd' }; enum { - kEventBlenderNdofAxis = 1, - kEventBlenderNdofButtons = 2 + kEventBlenderNdofAxis = 1, + kEventBlenderNdofButtons = 2 }; -const EventTypeSpec kEvents[] = +const EventTypeSpec kEvents[] = { { kEventClassAppleEvent, kEventAppleEvent }, /* - { kEventClassApplication, kEventAppActivated }, - { kEventClassApplication, kEventAppDeactivated }, -*/ + { kEventClassApplication, kEventAppActivated }, + { kEventClassApplication, kEventAppDeactivated }, + */ { kEventClassKeyboard, kEventRawKeyDown }, { kEventClassKeyboard, kEventRawKeyRepeat }, { kEventClassKeyboard, kEventRawKeyUp }, @@ -87,9 +87,9 @@ const EventTypeSpec kEvents[] = { kEventClassMouse, kEventMouseDragged }, { kEventClassMouse, kEventMouseWheelMoved }, - { kEventClassWindow, kEventWindowClickZoomRgn } , /* for new zoom behaviour */ + { kEventClassWindow, kEventWindowClickZoomRgn }, /* for new zoom behaviour */ { kEventClassWindow, kEventWindowZoom }, /* for new zoom behaviour */ - { kEventClassWindow, kEventWindowExpand } , /* for new zoom behaviour */ + { kEventClassWindow, kEventWindowExpand }, /* for new zoom behaviour */ { kEventClassWindow, kEventWindowExpandAll }, /* for new zoom behaviour */ { kEventClassWindow, kEventWindowClose }, @@ -110,111 +110,114 @@ const EventTypeSpec kEvents[] = static GHOST_TButtonMask convertButton(EventMouseButton button) { switch (button) { - case kEventMouseButtonPrimary: - return GHOST_kButtonMaskLeft; - case kEventMouseButtonSecondary: - return GHOST_kButtonMaskRight; - case kEventMouseButtonTertiary: - default: - return GHOST_kButtonMaskMiddle; + case kEventMouseButtonPrimary: + return GHOST_kButtonMaskLeft; + case kEventMouseButtonSecondary: + return GHOST_kButtonMaskRight; + case kEventMouseButtonTertiary: + default: + return GHOST_kButtonMaskMiddle; } } static GHOST_TKey convertKey(int rawCode) { - /* This bit of magic converts the rawCode into a virtual - * Mac key based on the current keyboard mapping, but - * without regard to the modifiers (so we don't get 'a' - * and 'A' for example. - */ - static UInt32 dummy= 0; + /* This bit of magic converts the rawCode into a virtual + * Mac key based on the current keyboard mapping, but + * without regard to the modifiers (so we don't get 'a' + * and 'A' for example. + */ + static UInt32 dummy = 0; Handle transData = (Handle) GetScriptManagerVariable(smKCHRCache); unsigned char vk = KeyTranslate(transData, rawCode, &dummy); - /* Map numpad based on rawcodes first, otherwise they - * look like non-numpad events. - * Added too: mapping the number keys, for french keyboards etc (ton) - */ + /* Map numpad based on rawcodes first, otherwise they + * look like non-numpad events. + * Added too: mapping the number keys, for french keyboards etc (ton) + */ // printf("GHOST: vk: %d %c raw: %d\n", vk, vk, rawCode); switch (rawCode) { - case 18: return GHOST_kKey1; - case 19: return GHOST_kKey2; - case 20: return GHOST_kKey3; - case 21: return GHOST_kKey4; - case 23: return GHOST_kKey5; - case 22: return GHOST_kKey6; - case 26: return GHOST_kKey7; - case 28: return GHOST_kKey8; - case 25: return GHOST_kKey9; - case 29: return GHOST_kKey0; - - case 82: return GHOST_kKeyNumpad0; - case 83: return GHOST_kKeyNumpad1; - case 84: return GHOST_kKeyNumpad2; - case 85: return GHOST_kKeyNumpad3; - case 86: return GHOST_kKeyNumpad4; - case 87: return GHOST_kKeyNumpad5; - case 88: return GHOST_kKeyNumpad6; - case 89: return GHOST_kKeyNumpad7; - case 91: return GHOST_kKeyNumpad8; - case 92: return GHOST_kKeyNumpad9; - case 65: return GHOST_kKeyNumpadPeriod; - case 76: return GHOST_kKeyNumpadEnter; - case 69: return GHOST_kKeyNumpadPlus; - case 78: return GHOST_kKeyNumpadMinus; - case 67: return GHOST_kKeyNumpadAsterisk; - case 75: return GHOST_kKeyNumpadSlash; + case 18: return GHOST_kKey1; + case 19: return GHOST_kKey2; + case 20: return GHOST_kKey3; + case 21: return GHOST_kKey4; + case 23: return GHOST_kKey5; + case 22: return GHOST_kKey6; + case 26: return GHOST_kKey7; + case 28: return GHOST_kKey8; + case 25: return GHOST_kKey9; + case 29: return GHOST_kKey0; + + case 82: return GHOST_kKeyNumpad0; + case 83: return GHOST_kKeyNumpad1; + case 84: return GHOST_kKeyNumpad2; + case 85: return GHOST_kKeyNumpad3; + case 86: return GHOST_kKeyNumpad4; + case 87: return GHOST_kKeyNumpad5; + case 88: return GHOST_kKeyNumpad6; + case 89: return GHOST_kKeyNumpad7; + case 91: return GHOST_kKeyNumpad8; + case 92: return GHOST_kKeyNumpad9; + case 65: return GHOST_kKeyNumpadPeriod; + case 76: return GHOST_kKeyNumpadEnter; + case 69: return GHOST_kKeyNumpadPlus; + case 78: return GHOST_kKeyNumpadMinus; + case 67: return GHOST_kKeyNumpadAsterisk; + case 75: return GHOST_kKeyNumpadSlash; } if ((vk >= 'a') && (vk <= 'z')) { return (GHOST_TKey) (vk - 'a' + GHOST_kKeyA); - } else if ((vk >= '0') && (vk <= '9')) { + } + else if ((vk >= '0') && (vk <= '9')) { return (GHOST_TKey) (vk - '0' + GHOST_kKey0); - } else if (vk==16) { + } + else if (vk == 16) { switch (rawCode) { - case 122: return GHOST_kKeyF1; - case 120: return GHOST_kKeyF2; - case 99: return GHOST_kKeyF3; - case 118: return GHOST_kKeyF4; - case 96: return GHOST_kKeyF5; - case 97: return GHOST_kKeyF6; - case 98: return GHOST_kKeyF7; - case 100: return GHOST_kKeyF8; - case 101: return GHOST_kKeyF9; - case 109: return GHOST_kKeyF10; - case 103: return GHOST_kKeyF11; - case 111: return GHOST_kKeyF12; // Never get, is used for ejecting the CD! + case 122: return GHOST_kKeyF1; + case 120: return GHOST_kKeyF2; + case 99: return GHOST_kKeyF3; + case 118: return GHOST_kKeyF4; + case 96: return GHOST_kKeyF5; + case 97: return GHOST_kKeyF6; + case 98: return GHOST_kKeyF7; + case 100: return GHOST_kKeyF8; + case 101: return GHOST_kKeyF9; + case 109: return GHOST_kKeyF10; + case 103: return GHOST_kKeyF11; + case 111: return GHOST_kKeyF12; // Never get, is used for ejecting the CD! } - } else { + } + else { switch (vk) { - case kUpArrowCharCode: return GHOST_kKeyUpArrow; - case kDownArrowCharCode: return GHOST_kKeyDownArrow; - case kLeftArrowCharCode: return GHOST_kKeyLeftArrow; - case kRightArrowCharCode: return GHOST_kKeyRightArrow; - - case kReturnCharCode: return GHOST_kKeyEnter; - case kBackspaceCharCode: return GHOST_kKeyBackSpace; - case kDeleteCharCode: return GHOST_kKeyDelete; - case kEscapeCharCode: return GHOST_kKeyEsc; - case kTabCharCode: return GHOST_kKeyTab; - case kSpaceCharCode: return GHOST_kKeySpace; - - case kHomeCharCode: return GHOST_kKeyHome; - case kEndCharCode: return GHOST_kKeyEnd; - case kPageUpCharCode: return GHOST_kKeyUpPage; - case kPageDownCharCode: return GHOST_kKeyDownPage; - - case '-': return GHOST_kKeyMinus; - case '=': return GHOST_kKeyEqual; - case ',': return GHOST_kKeyComma; - case '.': return GHOST_kKeyPeriod; - case '/': return GHOST_kKeySlash; - case ';': return GHOST_kKeySemicolon; - case '\'': return GHOST_kKeyQuote; - case '\\': return GHOST_kKeyBackslash; - case '[': return GHOST_kKeyLeftBracket; - case ']': return GHOST_kKeyRightBracket; - case '`': return GHOST_kKeyAccentGrave; + case kUpArrowCharCode: return GHOST_kKeyUpArrow; + case kDownArrowCharCode: return GHOST_kKeyDownArrow; + case kLeftArrowCharCode: return GHOST_kKeyLeftArrow; + case kRightArrowCharCode: return GHOST_kKeyRightArrow; + + case kReturnCharCode: return GHOST_kKeyEnter; + case kBackspaceCharCode: return GHOST_kKeyBackSpace; + case kDeleteCharCode: return GHOST_kKeyDelete; + case kEscapeCharCode: return GHOST_kKeyEsc; + case kTabCharCode: return GHOST_kKeyTab; + case kSpaceCharCode: return GHOST_kKeySpace; + + case kHomeCharCode: return GHOST_kKeyHome; + case kEndCharCode: return GHOST_kKeyEnd; + case kPageUpCharCode: return GHOST_kKeyUpPage; + case kPageDownCharCode: return GHOST_kKeyDownPage; + + case '-': return GHOST_kKeyMinus; + case '=': return GHOST_kKeyEqual; + case ',': return GHOST_kKeyComma; + case '.': return GHOST_kKeyPeriod; + case '/': return GHOST_kKeySlash; + case ';': return GHOST_kKeySemicolon; + case '\'': return GHOST_kKeyQuote; + case '\\': return GHOST_kKeyBackslash; + case '[': return GHOST_kKeyLeftBracket; + case ']': return GHOST_kKeyRightBracket; + case '`': return GHOST_kKeyAccentGrave; } } @@ -233,117 +236,117 @@ static GHOST_TKey convertKey(int rawCode) static unsigned char convertRomanToLatin(unsigned char ascii) { - if(ascii<128) return ascii; - - switch(ascii) { - case 128: return 142; - case 129: return 143; - case 130: return 128; - case 131: return 201; - case 132: return 209; - case 133: return 214; - case 134: return 220; - case 135: return 225; - case 136: return 224; - case 137: return 226; - case 138: return 228; - case 139: return 227; - case 140: return 229; - case 141: return 231; - case 142: return 233; - case 143: return 232; - case 144: return 234; - case 145: return 235; - case 146: return 237; - case 147: return 236; - case 148: return 238; - case 149: return 239; - case 150: return 241; - case 151: return 243; - case 152: return 242; - case 153: return 244; - case 154: return 246; - case 155: return 245; - case 156: return 250; - case 157: return 249; - case 158: return 251; - case 159: return 252; - case 160: return 0; - case 161: return 176; - case 162: return 162; - case 163: return 163; - case 164: return 167; - case 165: return 183; - case 166: return 182; - case 167: return 223; - case 168: return 174; - case 169: return 169; - case 170: return 174; - case 171: return 180; - case 172: return 168; - case 173: return 0; - case 174: return 198; - case 175: return 216; - case 176: return 0; - case 177: return 177; - case 178: return 0; - case 179: return 0; - case 180: return 165; - case 181: return 181; - case 182: return 0; - case 183: return 0; - case 184: return 215; - case 185: return 0; - case 186: return 0; - case 187: return 170; - case 188: return 186; - case 189: return 0; - case 190: return 230; - case 191: return 248; - case 192: return 191; - case 193: return 161; - case 194: return 172; - case 195: return 0; - case 196: return 0; - case 197: return 0; - case 198: return 0; - case 199: return 171; - case 200: return 187; - case 201: return 201; - case 202: return 0; - case 203: return 192; - case 204: return 195; - case 205: return 213; - case 206: return 0; - case 207: return 0; - case 208: return 0; - case 209: return 0; - case 210: return 0; + if (ascii < 128) return ascii; - case 214: return 247; - - case 229: return 194; - case 230: return 202; - case 231: return 193; - case 232: return 203; - case 233: return 200; - case 234: return 205; - case 235: return 206; - case 236: return 207; - case 237: return 204; - case 238: return 211; - case 239: return 212; - case 240: return 0; - case 241: return 210; - case 242: return 218; - case 243: return 219; - case 244: return 217; - case 245: return 0; - case 246: return 0; - case 247: return 0; - case 248: return 0; - case 249: return 0; - case 250: return 0; + switch (ascii) { + case 128: return 142; + case 129: return 143; + case 130: return 128; + case 131: return 201; + case 132: return 209; + case 133: return 214; + case 134: return 220; + case 135: return 225; + case 136: return 224; + case 137: return 226; + case 138: return 228; + case 139: return 227; + case 140: return 229; + case 141: return 231; + case 142: return 233; + case 143: return 232; + case 144: return 234; + case 145: return 235; + case 146: return 237; + case 147: return 236; + case 148: return 238; + case 149: return 239; + case 150: return 241; + case 151: return 243; + case 152: return 242; + case 153: return 244; + case 154: return 246; + case 155: return 245; + case 156: return 250; + case 157: return 249; + case 158: return 251; + case 159: return 252; + case 160: return 0; + case 161: return 176; + case 162: return 162; + case 163: return 163; + case 164: return 167; + case 165: return 183; + case 166: return 182; + case 167: return 223; + case 168: return 174; + case 169: return 169; + case 170: return 174; + case 171: return 180; + case 172: return 168; + case 173: return 0; + case 174: return 198; + case 175: return 216; + case 176: return 0; + case 177: return 177; + case 178: return 0; + case 179: return 0; + case 180: return 165; + case 181: return 181; + case 182: return 0; + case 183: return 0; + case 184: return 215; + case 185: return 0; + case 186: return 0; + case 187: return 170; + case 188: return 186; + case 189: return 0; + case 190: return 230; + case 191: return 248; + case 192: return 191; + case 193: return 161; + case 194: return 172; + case 195: return 0; + case 196: return 0; + case 197: return 0; + case 198: return 0; + case 199: return 171; + case 200: return 187; + case 201: return 201; + case 202: return 0; + case 203: return 192; + case 204: return 195; + case 205: return 213; + case 206: return 0; + case 207: return 0; + case 208: return 0; + case 209: return 0; + case 210: return 0; + + case 214: return 247; + + case 229: return 194; + case 230: return 202; + case 231: return 193; + case 232: return 203; + case 233: return 200; + case 234: return 205; + case 235: return 206; + case 236: return 207; + case 237: return 204; + case 238: return 211; + case 239: return 212; + case 240: return 0; + case 241: return 210; + case 242: return 218; + case 243: return 219; + case 244: return 217; + case 245: return 0; + case 246: return 0; + case 247: return 0; + case 248: return 0; + case 249: return 0; + case 250: return 0; default: return 0; @@ -357,13 +360,13 @@ static unsigned char convertRomanToLatin(unsigned char ascii) GHOST_SystemCarbon::GHOST_SystemCarbon() : m_modifierMask(0) { - m_displayManager = new GHOST_DisplayManagerCarbon (); + m_displayManager = new GHOST_DisplayManagerCarbon(); GHOST_ASSERT(m_displayManager, "GHOST_SystemCarbon::GHOST_SystemCarbon(): m_displayManager==0\n"); m_displayManager->initialize(); UnsignedWide micros; ::Microseconds(µs); - m_start_time = UnsignedWideToUInt64(micros)/1000; + m_start_time = UnsignedWideToUInt64(micros) / 1000; m_ignoreWindowSizedMessages = false; } @@ -381,7 +384,6 @@ GHOST_TUns64 GHOST_SystemCarbon::getMilliSeconds() const return (millis / 1000) - m_start_time; } - GHOST_TUns8 GHOST_SystemCarbon::getNumDisplays() const { // We do not support multiple monitors at the moment @@ -398,22 +400,21 @@ void GHOST_SystemCarbon::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUn } -GHOST_IWindow* GHOST_SystemCarbon::createWindow( - const STR_String& title, - GHOST_TInt32 left, - GHOST_TInt32 top, - GHOST_TUns32 width, - GHOST_TUns32 height, - GHOST_TWindowState state, - GHOST_TDrawingContextType type, - bool stereoVisual, - const GHOST_TUns16 numOfAASamples, - const GHOST_TEmbedderWindowID parentWindow -) +GHOST_IWindow *GHOST_SystemCarbon::createWindow( + const STR_String& title, + GHOST_TInt32 left, + GHOST_TInt32 top, + GHOST_TUns32 width, + GHOST_TUns32 height, + GHOST_TWindowState state, + GHOST_TDrawingContextType type, + bool stereoVisual, + const GHOST_TUns16 numOfAASamples, + const GHOST_TEmbedderWindowID parentWindow) { - GHOST_IWindow* window = 0; + GHOST_IWindow *window = 0; - window = new GHOST_WindowCarbon (title, left, top, width, height, state, type); + window = new GHOST_WindowCarbon(title, left, top, width, height, state, type); if (window) { if (window->getValid()) { @@ -435,18 +436,18 @@ GHOST_IWindow* GHOST_SystemCarbon::createWindow( return window; } -GHOST_TSuccess GHOST_SystemCarbon::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, const bool stereoVisual) +GHOST_TSuccess GHOST_SystemCarbon::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow **window, const bool stereoVisual) { GHOST_TSuccess success = GHOST_kFailure; // need yo make this Carbon all on 10.5 for fullscreen to work correctly CGCaptureAllDisplays(); - success = GHOST_System::beginFullScreen( setting, window, stereoVisual); + success = GHOST_System::beginFullScreen(setting, window, stereoVisual); - if( success != GHOST_kSuccess ) { - // fullscreen failed for other reasons, release - CGReleaseAllDisplays(); + if (success != GHOST_kSuccess) { + // fullscreen failed for other reasons, release + CGReleaseAllDisplays(); } return success; @@ -459,8 +460,8 @@ GHOST_TSuccess GHOST_SystemCarbon::endFullScreen(void) } /* this is an old style low level event queue. - As we want to handle our own timers, this is ok. - the full screen hack should be removed */ + * As we want to handle our own timers, this is ok. + * the full screen hack should be removed */ bool GHOST_SystemCarbon::processEvents(bool waitForEvent) { bool anyProcessed = false; @@ -469,7 +470,7 @@ bool GHOST_SystemCarbon::processEvents(bool waitForEvent) // SetMouseCoalescingEnabled(false, NULL); do { - GHOST_TimerManager* timerMgr = getTimerManager(); + GHOST_TimerManager *timerMgr = getTimerManager(); if (waitForEvent) { GHOST_TUns64 next = timerMgr->nextFireTime(); @@ -477,8 +478,9 @@ bool GHOST_SystemCarbon::processEvents(bool waitForEvent) if (next == GHOST_kFireTimeNever) { timeOut = kEventDurationForever; - } else { - timeOut = (double)(next - getMilliSeconds())/1000.0; + } + else { + timeOut = (double)(next - getMilliSeconds()) / 1000.0; if (timeOut < 0.0) timeOut = 0.0; } @@ -492,26 +494,27 @@ bool GHOST_SystemCarbon::processEvents(bool waitForEvent) if (getFullScreen()) { // Check if the full-screen window is dirty - GHOST_IWindow* window = m_windowManager->getFullScreenWindow(); - if (((GHOST_WindowCarbon*)window)->getFullScreenDirty()) { - pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) ); + GHOST_IWindow *window = m_windowManager->getFullScreenWindow(); + if (((GHOST_WindowCarbon *)window)->getFullScreenDirty()) { + pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) ); anyProcessed = true; } } /* end loop when no more events available */ - while (::ReceiveNextEvent(0, NULL, 0, true, &event)==noErr) { - OSStatus status= ::SendEventToEventTarget(event, ::GetEventDispatcherTarget()); - if (status==noErr) { + while (::ReceiveNextEvent(0, NULL, 0, true, &event) == noErr) { + OSStatus status = ::SendEventToEventTarget(event, ::GetEventDispatcherTarget()); + if (status == noErr) { anyProcessed = true; - } else { - UInt32 i= ::GetEventClass(event); + } + else { + UInt32 i = ::GetEventClass(event); - /* Ignore 'cgs ' class, no documentation on what they - * are, but we get a lot of them - */ - if (i!='cgs ') { - if (i!='tblt') { // tablet event. we use the one packaged in the mouse event + /* Ignore 'cgs ' class, no documentation on what they + * are, but we get a lot of them + */ + if (i != 'cgs ') { + if (i != 'tblt') { // tablet event. we use the one packaged in the mouse event ; //printf("Missed - Class: '%.4s', Kind: %d\n", &i, ::GetEventKind(event)); } } @@ -538,7 +541,7 @@ GHOST_TSuccess GHOST_SystemCarbon::getCursorPosition(GHOST_TInt32& x, GHOST_TInt GHOST_TSuccess GHOST_SystemCarbon::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) { - float xf=(float)x, yf=(float)y; + float xf = (float)x, yf = (float)y; CGAssociateMouseAndMouseCursorPosition(false); CGSetLocalEventsSuppressionInterval(0); @@ -585,7 +588,8 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1); buf[FIRSTFILEBUFLG - 1] = '\0'; return 1; - } else { + } + else { return 0; } } @@ -605,28 +609,28 @@ OSErr GHOST_SystemCarbon::sAEHandlerOpenDocs(const AppleEvent *event, AppleEvent OSErr err; err = AEGetParamDesc(event, keyDirectObject, typeAEList, &docs); - if (err != noErr) return err; + if (err != noErr) return err; err = AECountItems(&docs, &ndocs); - if (err==noErr) { + if (err == noErr) { int i; - for (i=0; i<ndocs; i++) { + for (i = 0; i < ndocs; i++) { FSSpec fss; AEKeyword kwd; DescType actType; Size actSize; - err = AEGetNthPtr(&docs, i+1, typeFSS, &kwd, &actType, &fss, sizeof(fss), &actSize); - if (err!=noErr) + err = AEGetNthPtr(&docs, i + 1, typeFSS, &kwd, &actType, &fss, sizeof(fss), &actSize); + if (err != noErr) break; - if (i==0) { + if (i == 0) { FSRef fsref; - if (FSpMakeFSRef(&fss, &fsref)!=noErr) + if (FSpMakeFSRef(&fss, &fsref) != noErr) break; - if (FSRefMakePath(&fsref, (UInt8*) g_firstFileBuf, sizeof(g_firstFileBuf))!=noErr) + if (FSRefMakePath(&fsref, (UInt8 *) g_firstFileBuf, sizeof(g_firstFileBuf)) != noErr) break; g_hasFirstFile = true; @@ -648,9 +652,9 @@ OSErr GHOST_SystemCarbon::sAEHandlerPrintDocs(const AppleEvent *event, AppleEven OSErr GHOST_SystemCarbon::sAEHandlerQuit(const AppleEvent *event, AppleEvent *reply, SInt32 refCon) { - GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon; + GHOST_SystemCarbon *sys = (GHOST_SystemCarbon *) refCon; - sys->pushEvent( new GHOST_Event(sys->getMilliSeconds(), GHOST_kEventQuit, NULL) ); + sys->pushEvent(new GHOST_Event(sys->getMilliSeconds(), GHOST_kEventQuit, NULL) ); return noErr; } @@ -698,47 +702,47 @@ OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event) // Check if the event was send to a GHOST window ::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &windowRef); - window = (GHOST_WindowCarbon*) ::GetWRefCon(windowRef); + window = (GHOST_WindowCarbon *) ::GetWRefCon(windowRef); if (!validWindow(window)) { return err; } //if (!getFullScreen()) { - err = noErr; - switch(::GetEventKind(event)) - { - case kEventWindowClose: - pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) ); - break; - case kEventWindowActivated: - m_windowManager->setActiveWindow(window); - window->loadCursor(window->getCursorVisibility(), window->getCursorShape()); - pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) ); - break; - case kEventWindowDeactivated: - m_windowManager->setWindowInactive(window); - pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) ); - break; - case kEventWindowUpdate: - //if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n"); - pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) ); - break; - case kEventWindowBoundsChanged: - if (!m_ignoreWindowSizedMessages) - { - window->updateDrawingContext(); - pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) ); - } - break; - default: - err = eventNotHandledErr; - break; - } + err = noErr; + switch (::GetEventKind(event)) + { + case kEventWindowClose: + pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) ); + break; + case kEventWindowActivated: + m_windowManager->setActiveWindow(window); + window->loadCursor(window->getCursorVisibility(), window->getCursorShape()); + pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) ); + break; + case kEventWindowDeactivated: + m_windowManager->setWindowInactive(window); + pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) ); + break; + case kEventWindowUpdate: + //if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n"); + pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) ); + break; + case kEventWindowBoundsChanged: + if (!m_ignoreWindowSizedMessages) + { + window->updateDrawingContext(); + pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) ); + } + break; + default: + err = eventNotHandledErr; + break; + } // } //else { - //window = (GHOST_WindowCarbon*) m_windowManager->getFullScreenWindow(); - //GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen window event, " << window << "\n"); - //::RemoveEventFromQueue(::GetMainEventQueue(), event); + //window = (GHOST_WindowCarbon*) m_windowManager->getFullScreenWindow(); + //GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen window event, " << window << "\n"); + //::RemoveEventFromQueue(::GetMainEventQueue(), event); //} return err; @@ -746,11 +750,11 @@ OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event) OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event) { - GHOST_IWindow* window = m_windowManager->getActiveWindow(); + GHOST_IWindow *window = m_windowManager->getActiveWindow(); TabletPointRec tabletPointRecord; - TabletProximityRec tabletProximityRecord; + TabletProximityRec tabletProximityRecord; UInt32 anInt32; - GHOST_TabletData& ct=((GHOST_WindowCarbon*)window)->GetCarbonTabletData(); + GHOST_TabletData& ct = ((GHOST_WindowCarbon *)window)->GetCarbonTabletData(); OSStatus err = eventNotHandledErr; ct.Pressure = 0; @@ -758,11 +762,11 @@ OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event) ct.Ytilt = 0; // is there an embedded tablet event inside this mouse event? - if(noErr == GetEventParameter(event, kEventParamTabletEventType, typeUInt32, NULL, sizeof(UInt32), NULL, (void *)&anInt32)) + if (noErr == GetEventParameter(event, kEventParamTabletEventType, typeUInt32, NULL, sizeof(UInt32), NULL, (void *)&anInt32)) { // yes there is one! // Embedded tablet events can either be a proximity or pointer event. - if(anInt32 == kEventTabletPoint) + if (anInt32 == kEventTabletPoint) { //GHOST_PRINT("Embedded pointer event!\n"); @@ -771,28 +775,29 @@ OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event) // error and go on. This can occur when a proximity event is embedded in // a mouse event and you did not check the mouse event to see which type // of tablet event was embedded. - if(noErr == GetEventParameter(event, kEventParamTabletPointRec, - typeTabletPointRec, NULL, - sizeof(TabletPointRec), - NULL, (void *)&tabletPointRecord)) + if (noErr == GetEventParameter(event, kEventParamTabletPointRec, + typeTabletPointRec, NULL, + sizeof(TabletPointRec), + NULL, (void *)&tabletPointRecord)) { ct.Pressure = tabletPointRecord.pressure / 65535.0f; ct.Xtilt = tabletPointRecord.tiltX / 32767.0f; /* can be positive or negative */ ct.Ytilt = tabletPointRecord.tiltY / 32767.0f; /* can be positive or negative */ } - } else { + } + else { //GHOST_PRINT("Embedded proximity event\n"); // Extract the Tablet Proximity record from the event. - if(noErr == GetEventParameter(event, kEventParamTabletProximityRec, - typeTabletProximityRec, NULL, - sizeof(TabletProximityRec), - NULL, (void *)&tabletProximityRecord)) + if (noErr == GetEventParameter(event, kEventParamTabletProximityRec, + typeTabletProximityRec, NULL, + sizeof(TabletProximityRec), + NULL, (void *)&tabletProximityRecord)) { if (tabletProximityRecord.enterProximity) { //pointer is entering tablet area proximity - switch(tabletProximityRecord.pointerType) + switch (tabletProximityRecord.pointerType) { case 1: /* stylus */ ct.Active = GHOST_kTabletModeStylus; @@ -807,25 +812,26 @@ OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event) ct.Active = GHOST_kTabletModeNone; break; } - } else { + } + else { // pointer is leaving - return to mouse ct.Active = GHOST_kTabletModeNone; } } } - err = noErr; + err = noErr; } return err; } OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event) { - OSStatus err = eventNotHandledErr; - GHOST_IWindow* window = m_windowManager->getActiveWindow(); + OSStatus err = eventNotHandledErr; + GHOST_IWindow *window = m_windowManager->getActiveWindow(); UInt32 kind = ::GetEventKind(event); switch (kind) - { + { case kEventMouseDown: case kEventMouseUp: // Handle Mac application responsibilities @@ -863,29 +869,29 @@ OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event) break; } case kEventMouseWheelMoved: + { + OSStatus status; + //UInt32 modifiers; + EventMouseWheelAxis axis; + SInt32 delta; + //status = ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers); + //GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); + status = ::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis); + GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); + if (axis == kEventMouseWheelAxisY) { - OSStatus status; - //UInt32 modifiers; - EventMouseWheelAxis axis; - SInt32 delta; - //status = ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers); - //GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); - status = ::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis); + status = ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta); GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); - if (axis == kEventMouseWheelAxisY) - { - status = ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta); - GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); - /* - * Limit mouse wheel delta to plus and minus one. - */ - delta = delta > 0 ? 1 : -1; - pushEvent(new GHOST_EventWheel(getMilliSeconds(), window, delta)); - err = noErr; - } + /* + * Limit mouse wheel delta to plus and minus one. + */ + delta = delta > 0 ? 1 : -1; + pushEvent(new GHOST_EventWheel(getMilliSeconds(), window, delta)); + err = noErr; } - break; } + break; + } return err; } @@ -893,8 +899,8 @@ OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event) OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event) { - OSStatus err = eventNotHandledErr; - GHOST_IWindow* window = m_windowManager->getActiveWindow(); + OSStatus err = eventNotHandledErr; + GHOST_IWindow *window = m_windowManager->getActiveWindow(); UInt32 kind = ::GetEventKind(event); UInt32 modifiers; UInt32 rawCode; @@ -919,35 +925,37 @@ OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event) ::GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &ascii); key = convertKey(rawCode); - ascii= convertRomanToLatin(ascii); + ascii = convertRomanToLatin(ascii); - // if (key!=GHOST_kKeyUnknown) { - GHOST_TEventType type; - if (kind == kEventRawKeyDown) { - type = GHOST_kEventKeyDown; - } else if (kind == kEventRawKeyRepeat) { - type = GHOST_kEventKeyDown; /* XXX, fixme */ - } else { - type = GHOST_kEventKeyUp; - } - pushEvent( new GHOST_EventKey( getMilliSeconds(), type, window, key, ascii, NULL) ); + // if (key!=GHOST_kKeyUnknown) { + GHOST_TEventType type; + if (kind == kEventRawKeyDown) { + type = GHOST_kEventKeyDown; + } + else if (kind == kEventRawKeyRepeat) { + type = GHOST_kEventKeyDown; /* XXX, fixme */ + } + else { + type = GHOST_kEventKeyUp; + } + pushEvent(new GHOST_EventKey(getMilliSeconds(), type, window, key, ascii, NULL) ); // } break; case kEventRawKeyModifiersChanged: - /* ugh */ + /* ugh */ ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); if ((modifiers & shiftKey) != (m_modifierMask & shiftKey)) { - pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & shiftKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) ); + pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & shiftKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) ); } if ((modifiers & controlKey) != (m_modifierMask & controlKey)) { - pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & controlKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) ); + pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & controlKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) ); } if ((modifiers & optionKey) != (m_modifierMask & optionKey)) { - pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & optionKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) ); + pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & optionKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) ); } if ((modifiers & cmdKey) != (m_modifierMask & cmdKey)) { - pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyOS) ); + pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyOS) ); } m_modifierMask = modifiers; @@ -964,17 +972,17 @@ OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event) bool GHOST_SystemCarbon::handleMouseDown(EventRef event) { - WindowPtr window; - short part; - BitMap screenBits; - bool handled = true; - GHOST_WindowCarbon* ghostWindow; - Point mousePos = {0 , 0}; + WindowPtr window; + short part; + BitMap screenBits; + bool handled = true; + GHOST_WindowCarbon *ghostWindow; + Point mousePos = {0, 0}; ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos); part = ::FindWindow(mousePos, &window); - ghostWindow = (GHOST_WindowCarbon*) ::GetWRefCon(window); + ghostWindow = (GHOST_WindowCarbon *) ::GetWRefCon(window); switch (part) { case inMenuBar: @@ -995,7 +1003,7 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event) ::DragWindow(window, mousePos, &GetQDGlobalsScreenBits(&screenBits)->bounds); m_ignoreWindowSizedMessages = false; - pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, ghostWindow) ); + pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, ghostWindow) ); break; @@ -1009,7 +1017,8 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event) EventMouseButton button; ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button); pushEvent(new GHOST_EventButton(getMilliSeconds(), GHOST_kEventButtonDown, ghostWindow, convertButton(button))); - } else { + } + else { handled = false; } break; @@ -1020,7 +1029,7 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event) { // todo: add option-close, because itÿs in the HIG // if (event.modifiers & optionKey) { - // Close the clean documents, others will be confirmed one by one. + // Close the clean documents, others will be confirmed one by one. //} // else { pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, ghostWindow)); @@ -1040,23 +1049,24 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event) int macState; macState = ghostWindow->getMac_windowState(); - if ( macState== 0) + if (macState == 0) ::ZoomWindow(window, part, true); else - if (macState == 2) { // always ok - ::ZoomWindow(window, part, true); - ghostWindow->setMac_windowState(1); - } else { // need to force size again + if (macState == 2) { // always ok + ::ZoomWindow(window, part, true); + ghostWindow->setMac_windowState(1); + } + else { // need to force size again // GHOST_TUns32 scr_x,scr_y; /*unused*/ - Rect outAvailableRect; + Rect outAvailableRect; - ghostWindow->setMac_windowState(2); - ::GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect); + ghostWindow->setMac_windowState(2); + ::GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect); - //this->getMainDisplayDimensions(scr_x,scr_y); - ::SizeWindow (window, outAvailableRect.right-outAvailableRect.left,outAvailableRect.bottom-outAvailableRect.top-1,false); - ::MoveWindow (window, outAvailableRect.left, outAvailableRect.top,true); - } + //this->getMainDisplayDimensions(scr_x,scr_y); + ::SizeWindow(window, outAvailableRect.right - outAvailableRect.left, outAvailableRect.bottom - outAvailableRect.top - 1, false); + ::MoveWindow(window, outAvailableRect.left, outAvailableRect.top, true); + } } break; @@ -1072,11 +1082,11 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event) bool GHOST_SystemCarbon::handleMenuCommand(GHOST_TInt32 menuResult) { - short menuID; - short menuItem; - UInt32 command; - bool handled; - OSErr err; + short menuID; + short menuItem; + UInt32 command; + bool handled; + OSErr err; menuID = HiWord(menuResult); menuItem = LoWord(menuResult); @@ -1088,7 +1098,7 @@ bool GHOST_SystemCarbon::handleMenuCommand(GHOST_TInt32 menuResult) if (err || command == 0) { } else { - switch(command) { + switch (command) { } } @@ -1097,11 +1107,11 @@ bool GHOST_SystemCarbon::handleMenuCommand(GHOST_TInt32 menuResult) } -OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData) +OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData) { - GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) userData; + GHOST_SystemCarbon *sys = (GHOST_SystemCarbon *) userData; OSStatus err = eventNotHandledErr; - GHOST_IWindow* window; + GHOST_IWindow *window; #ifdef WITH_INPUT_NDOF GHOST_TEventNDOFData data; #endif @@ -1124,7 +1134,7 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even case kEventClassKeyboard: err = sys->handleKeyEvent(event); break; - case kEventClassBlender : + case kEventClassBlender: #ifdef WITH_INPUT_NDOF window = sys->m_windowManager->getActiveWindow(); sys->m_ndofManager->GHOST_NDOFGetDatas(data); @@ -1134,7 +1144,7 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even { case 1: sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data)); - // printf("motion\n"); + // printf("motion\n"); break; case 2: sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFButton, window, data)); @@ -1144,7 +1154,7 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even #endif err = noErr; break; - default : + default: ; break; } @@ -1152,48 +1162,49 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even return err; } -GHOST_TUns8* GHOST_SystemCarbon::getClipboard(bool selection) const +GHOST_TUns8 *GHOST_SystemCarbon::getClipboard(bool selection) const { PasteboardRef inPasteboard; PasteboardItemID itemID; CFDataRef flavorData; OSStatus err = noErr; - GHOST_TUns8 * temp_buff; + GHOST_TUns8 *temp_buff; CFRange range; OSStatus syncFlags; err = PasteboardCreate(kPasteboardClipboard, &inPasteboard); - if(err != noErr) { return NULL;} + if (err != noErr) { return NULL; } - syncFlags = PasteboardSynchronize( inPasteboard ); - /* as we always get in a new string, we can safely ignore sync flags if not an error*/ - if(syncFlags <0) { return NULL;} + syncFlags = PasteboardSynchronize(inPasteboard); + /* as we always get in a new string, we can safely ignore sync flags if not an error*/ + if (syncFlags < 0) { return NULL; } - err = PasteboardGetItemIdentifier( inPasteboard, 1, &itemID ); - if(err != noErr) { return NULL;} + err = PasteboardGetItemIdentifier(inPasteboard, 1, &itemID); + if (err != noErr) { return NULL; } - err = PasteboardCopyItemFlavorData( inPasteboard, itemID, CFSTR("public.utf8-plain-text"), &flavorData); - if(err != noErr) { return NULL;} + err = PasteboardCopyItemFlavorData(inPasteboard, itemID, CFSTR("public.utf8-plain-text"), &flavorData); + if (err != noErr) { return NULL; } range = CFRangeMake(0, CFDataGetLength(flavorData)); - temp_buff = (GHOST_TUns8*) malloc(range.length+1); + temp_buff = (GHOST_TUns8 *) malloc(range.length + 1); - CFDataGetBytes(flavorData, range, (UInt8*)temp_buff); + CFDataGetBytes(flavorData, range, (UInt8 *)temp_buff); temp_buff[range.length] = '\0'; - if(temp_buff) { + if (temp_buff) { return temp_buff; - } else { + } + else { return NULL; } } void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const { - if(selection) {return;} // for copying the selection, used on X11 + if (selection) {return; } // for copying the selection, used on X11 PasteboardRef inPasteboard; CFDataRef textData = NULL; @@ -1201,26 +1212,26 @@ void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const OSStatus syncFlags; err = PasteboardCreate(kPasteboardClipboard, &inPasteboard); - if(err != noErr) { return;} + if (err != noErr) { return; } - syncFlags = PasteboardSynchronize( inPasteboard ); + syncFlags = PasteboardSynchronize(inPasteboard); /* as we always put in a new string, we can safely ignore sync flags */ - if(syncFlags <0) { return;} + if (syncFlags < 0) { return; } - err = PasteboardClear( inPasteboard ); - if(err != noErr) { return;} + err = PasteboardClear(inPasteboard); + if (err != noErr) { return; } - textData = CFDataCreate(kCFAllocatorDefault, (UInt8*)buffer, strlen(buffer)); + textData = CFDataCreate(kCFAllocatorDefault, (UInt8 *)buffer, strlen(buffer)); if (textData) { - err = PasteboardPutItemFlavor( inPasteboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), textData, 0); - if(err != noErr) { - if(textData) { CFRelease(textData);} - return; - } + err = PasteboardPutItemFlavor(inPasteboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), textData, 0); + if (err != noErr) { + if (textData) { CFRelease(textData); } + return; + } } - if(textData) { + if (textData) { CFRelease(textData); } } diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp b/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp index 02d45131f5a..f4be03ac2f3 100644 --- a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp @@ -44,27 +44,27 @@ GHOST_SystemPathsCarbon::~GHOST_SystemPathsCarbon() { } -const GHOST_TUns8* GHOST_SystemPathsCarbon::getSystemDir() const +const GHOST_TUns8 *GHOST_SystemPathsCarbon::getSystemDir() const { - return (GHOST_TUns8*)"/Library/Application Support"; + return (GHOST_TUns8 *)"/Library/Application Support"; } -const GHOST_TUns8* GHOST_SystemPathsCarbon::getUserDir() const +const GHOST_TUns8 *GHOST_SystemPathsCarbon::getUserDir() const { static char usrPath[256] = ""; - char* env = getenv("HOME"); + char *env = getenv("HOME"); if (env) { strncpy(usrPath, env, 245); - usrPath[245]=0; + usrPath[245] = 0; strcat(usrPath, "/Library/Application Support"); - return (GHOST_TUns8*) usrPath; + return (GHOST_TUns8 *) usrPath; } else return NULL; } -const GHOST_TUns8* GHOST_SystemPathsCarbon::getBinaryDir() const +const GHOST_TUns8 *GHOST_SystemPathsCarbon::getBinaryDir() const { CFURLRef bundleURL; CFStringRef pathStr; @@ -76,10 +76,10 @@ const GHOST_TUns8* GHOST_SystemPathsCarbon::getBinaryDir() const CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII); CFRelease(pathStr); CFRelease(bundleURL); - return (GHOST_TUns8*)path; + return (GHOST_TUns8 *)path; } -void GHOST_SystemPathsCarbon::addToSystemRecentFiles(const char* filename) const +void GHOST_SystemPathsCarbon::addToSystemRecentFiles(const char *filename) const { /* XXXXX TODO: Implementation for Carbon if possible */ diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp index 0023ceb87f0..ecf10463079 100644 --- a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp @@ -69,46 +69,46 @@ GHOST_SystemPathsWin32::~GHOST_SystemPathsWin32() { } -const GHOST_TUns8* GHOST_SystemPathsWin32::getSystemDir() const +const GHOST_TUns8 *GHOST_SystemPathsWin32::getSystemDir() const { - static char knownpath[MAX_PATH*3] = {0}; /* 1 utf-16 might translante into 3 utf-8. 2 utf-16 translates into 4 utf-8*/ + static char knownpath[MAX_PATH * 3] = {0}; /* 1 utf-16 might translante into 3 utf-8. 2 utf-16 translates into 4 utf-8*/ wchar_t knownpath_16[MAX_PATH]; HRESULT hResult = SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath_16); if (hResult == S_OK) { - conv_utf_16_to_8(knownpath_16,knownpath,MAX_PATH*3); - return (GHOST_TUns8*)knownpath; + conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3); + return (GHOST_TUns8 *)knownpath; } return NULL; } -const GHOST_TUns8* GHOST_SystemPathsWin32::getUserDir() const +const GHOST_TUns8 *GHOST_SystemPathsWin32::getUserDir() const { - static char knownpath[MAX_PATH*3] = {0}; - wchar_t knownpath_16[MAX_PATH]; + static char knownpath[MAX_PATH * 3] = {0}; + wchar_t knownpath_16[MAX_PATH]; HRESULT hResult = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath_16); if (hResult == S_OK) { - conv_utf_16_to_8(knownpath_16,knownpath,MAX_PATH*3); - return (GHOST_TUns8*)knownpath; + conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3); + return (GHOST_TUns8 *)knownpath; } return NULL; } -const GHOST_TUns8* GHOST_SystemPathsWin32::getBinaryDir() const +const GHOST_TUns8 *GHOST_SystemPathsWin32::getBinaryDir() const { - static char fullname[MAX_PATH*3] = {0}; - wchar_t fullname_16[MAX_PATH*3]; + static char fullname[MAX_PATH * 3] = {0}; + wchar_t fullname_16[MAX_PATH * 3]; - if(GetModuleFileNameW(0, fullname_16, MAX_PATH)) { - conv_utf_16_to_8(fullname_16,fullname,MAX_PATH*3); - return (GHOST_TUns8*)fullname; + if (GetModuleFileNameW(0, fullname_16, MAX_PATH)) { + conv_utf_16_to_8(fullname_16, fullname, MAX_PATH * 3); + return (GHOST_TUns8 *)fullname; } return NULL; diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp index a2b457cc262..237d4c0f787 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.cpp +++ b/intern/ghost/intern/GHOST_SystemSDL.cpp @@ -39,18 +39,18 @@ GHOST_SystemSDL::GHOST_SystemSDL() : GHOST_System() { - if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0) { - printf ("Error initializing SDL: %s\n", SDL_GetError()); + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { + printf("Error initializing SDL: %s\n", SDL_GetError()); } /* SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); */ - /* SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); */ - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); + /* SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); */ + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); } GHOST_SystemSDL::~GHOST_SystemSDL() @@ -71,9 +71,9 @@ GHOST_SystemSDL::createWindow(const STR_String& title, const GHOST_TEmbedderWindowID parentWindow ) { - GHOST_WindowSDL *window= NULL; + GHOST_WindowSDL *window = NULL; - window= new GHOST_WindowSDL (this, title, left, top, width, height, state, parentWindow, type, stereoVisual, 1); + window = new GHOST_WindowSDL(this, title, left, top, width, height, state, parentWindow, type, stereoVisual, 1); if (window) { if (GHOST_kWindowStateFullScreen == state) { @@ -93,7 +93,7 @@ GHOST_SystemSDL::createWindow(const STR_String& title, } else { delete window; - window= NULL; + window = NULL; } } return window; @@ -120,8 +120,8 @@ GHOST_SystemSDL::getMainDisplayDimensions(GHOST_TUns32& width, { SDL_DisplayMode mode; SDL_GetCurrentDisplayMode(0, &mode); /* note, always 0 display */ - width= mode.w; - height= mode.h; + width = mode.w; + height = mode.h; } GHOST_TUns8 @@ -133,7 +133,7 @@ GHOST_SystemSDL::getNumDisplays() const GHOST_TSuccess GHOST_SystemSDL::getModifierKeys(GHOST_ModifierKeys& keys) const { - SDL_Keymod mod= SDL_GetModState(); + SDL_Keymod mod = SDL_GetModState(); keys.set(GHOST_kModifierKeyLeftShift, (mod & KMOD_LSHIFT) != 0); keys.set(GHOST_kModifierKeyRightShift, (mod & KMOD_RSHIFT) != 0); @@ -141,12 +141,12 @@ GHOST_SystemSDL::getModifierKeys(GHOST_ModifierKeys& keys) const keys.set(GHOST_kModifierKeyRightControl, (mod & KMOD_RCTRL) != 0); keys.set(GHOST_kModifierKeyLeftAlt, (mod & KMOD_LALT) != 0); keys.set(GHOST_kModifierKeyRightAlt, (mod & KMOD_RALT) != 0); - keys.set(GHOST_kModifierKeyOS, (mod & (KMOD_LGUI|KMOD_RGUI)) != 0); + keys.set(GHOST_kModifierKeyOS, (mod & (KMOD_LGUI | KMOD_RGUI)) != 0); return GHOST_kSuccess; } -#define GXMAP(k,x,y) case x: k= y; break; +#define GXMAP(k, x, y) case x: k = y; break static GHOST_TKey convertSDLKey(SDL_Scancode key) @@ -154,97 +154,101 @@ convertSDLKey(SDL_Scancode key) GHOST_TKey type; if ((key >= SDL_SCANCODE_A) && (key <= SDL_SCANCODE_Z)) { - type= GHOST_TKey( key - SDL_SCANCODE_A + int(GHOST_kKeyA)); - } else if ((key >= SDL_SCANCODE_1) && (key <= SDL_SCANCODE_0)) { - type= (key == SDL_SCANCODE_0) ? GHOST_kKey0 : GHOST_TKey(key - SDL_SCANCODE_1 + int(GHOST_kKey1)); - } else if ((key >= SDL_SCANCODE_F1) && (key <= SDL_SCANCODE_F12)) { - type= GHOST_TKey(key - SDL_SCANCODE_F1 + int(GHOST_kKeyF1)); - } else if ((key >= SDL_SCANCODE_F13) && (key <= SDL_SCANCODE_F24)) { - type= GHOST_TKey(key - SDL_SCANCODE_F13 + int(GHOST_kKeyF13)); - } else { - switch(key) { + type = GHOST_TKey(key - SDL_SCANCODE_A + int(GHOST_kKeyA)); + } + else if ((key >= SDL_SCANCODE_1) && (key <= SDL_SCANCODE_0)) { + type = (key == SDL_SCANCODE_0) ? GHOST_kKey0 : GHOST_TKey(key - SDL_SCANCODE_1 + int(GHOST_kKey1)); + } + else if ((key >= SDL_SCANCODE_F1) && (key <= SDL_SCANCODE_F12)) { + type = GHOST_TKey(key - SDL_SCANCODE_F1 + int(GHOST_kKeyF1)); + } + else if ((key >= SDL_SCANCODE_F13) && (key <= SDL_SCANCODE_F24)) { + type = GHOST_TKey(key - SDL_SCANCODE_F13 + int(GHOST_kKeyF13)); + } + else { + switch (key) { /* TODO SDL_SCANCODE_NONUSBACKSLASH */ - GXMAP(type,SDL_SCANCODE_BACKSPACE, GHOST_kKeyBackSpace); - GXMAP(type,SDL_SCANCODE_TAB, GHOST_kKeyTab); - GXMAP(type,SDL_SCANCODE_RETURN, GHOST_kKeyEnter); - GXMAP(type,SDL_SCANCODE_ESCAPE, GHOST_kKeyEsc); - GXMAP(type,SDL_SCANCODE_SPACE, GHOST_kKeySpace); - - GXMAP(type,SDL_SCANCODE_SEMICOLON, GHOST_kKeySemicolon); - GXMAP(type,SDL_SCANCODE_PERIOD, GHOST_kKeyPeriod); - GXMAP(type,SDL_SCANCODE_COMMA, GHOST_kKeyComma); - GXMAP(type,SDL_SCANCODE_APOSTROPHE, GHOST_kKeyQuote); - GXMAP(type,SDL_SCANCODE_GRAVE, GHOST_kKeyAccentGrave); - GXMAP(type,SDL_SCANCODE_MINUS, GHOST_kKeyMinus); - GXMAP(type,SDL_SCANCODE_EQUALS, GHOST_kKeyEqual); - - GXMAP(type,SDL_SCANCODE_SLASH, GHOST_kKeySlash); - GXMAP(type,SDL_SCANCODE_BACKSLASH, GHOST_kKeyBackslash); - GXMAP(type,SDL_SCANCODE_KP_EQUALS, GHOST_kKeyEqual); - GXMAP(type,SDL_SCANCODE_LEFTBRACKET, GHOST_kKeyLeftBracket); - GXMAP(type,SDL_SCANCODE_RIGHTBRACKET, GHOST_kKeyRightBracket); - GXMAP(type,SDL_SCANCODE_PAUSE, GHOST_kKeyPause); - - GXMAP(type,SDL_SCANCODE_LSHIFT, GHOST_kKeyLeftShift); - GXMAP(type,SDL_SCANCODE_RSHIFT, GHOST_kKeyRightShift); - GXMAP(type,SDL_SCANCODE_LCTRL, GHOST_kKeyLeftControl); - GXMAP(type,SDL_SCANCODE_RCTRL, GHOST_kKeyRightControl); - GXMAP(type,SDL_SCANCODE_LALT, GHOST_kKeyLeftAlt); - GXMAP(type,SDL_SCANCODE_RALT, GHOST_kKeyRightAlt); - GXMAP(type,SDL_SCANCODE_LGUI, GHOST_kKeyOS); - GXMAP(type,SDL_SCANCODE_RGUI, GHOST_kKeyOS); - - GXMAP(type,SDL_SCANCODE_INSERT, GHOST_kKeyInsert); - GXMAP(type,SDL_SCANCODE_DELETE, GHOST_kKeyDelete); - GXMAP(type,SDL_SCANCODE_HOME, GHOST_kKeyHome); - GXMAP(type,SDL_SCANCODE_END, GHOST_kKeyEnd); - GXMAP(type,SDL_SCANCODE_PAGEUP, GHOST_kKeyUpPage); - GXMAP(type,SDL_SCANCODE_PAGEDOWN, GHOST_kKeyDownPage); - - GXMAP(type,SDL_SCANCODE_LEFT, GHOST_kKeyLeftArrow); - GXMAP(type,SDL_SCANCODE_RIGHT, GHOST_kKeyRightArrow); - GXMAP(type,SDL_SCANCODE_UP, GHOST_kKeyUpArrow); - GXMAP(type,SDL_SCANCODE_DOWN, GHOST_kKeyDownArrow); - - GXMAP(type,SDL_SCANCODE_CAPSLOCK, GHOST_kKeyCapsLock); - GXMAP(type,SDL_SCANCODE_SCROLLLOCK, GHOST_kKeyScrollLock); - GXMAP(type,SDL_SCANCODE_NUMLOCKCLEAR, GHOST_kKeyNumLock); - GXMAP(type,SDL_SCANCODE_PRINTSCREEN, GHOST_kKeyPrintScreen); - - /* keypad events */ - - /* note, sdl defines a bunch of kp defines I never saw before like - * SDL_SCANCODE_KP_PERCENT, SDL_SCANCODE_KP_XOR - campbell */ - GXMAP(type,SDL_SCANCODE_KP_0, GHOST_kKeyNumpad0); - GXMAP(type,SDL_SCANCODE_KP_1, GHOST_kKeyNumpad1); - GXMAP(type,SDL_SCANCODE_KP_2, GHOST_kKeyNumpad2); - GXMAP(type,SDL_SCANCODE_KP_3, GHOST_kKeyNumpad3); - GXMAP(type,SDL_SCANCODE_KP_4, GHOST_kKeyNumpad4); - GXMAP(type,SDL_SCANCODE_KP_5, GHOST_kKeyNumpad5); - GXMAP(type,SDL_SCANCODE_KP_6, GHOST_kKeyNumpad6); - GXMAP(type,SDL_SCANCODE_KP_7, GHOST_kKeyNumpad7); - GXMAP(type,SDL_SCANCODE_KP_8, GHOST_kKeyNumpad8); - GXMAP(type,SDL_SCANCODE_KP_9, GHOST_kKeyNumpad9); - GXMAP(type,SDL_SCANCODE_KP_PERIOD, GHOST_kKeyNumpadPeriod); - - GXMAP(type,SDL_SCANCODE_KP_ENTER, GHOST_kKeyNumpadEnter); - GXMAP(type,SDL_SCANCODE_KP_PLUS, GHOST_kKeyNumpadPlus); - GXMAP(type,SDL_SCANCODE_KP_MINUS, GHOST_kKeyNumpadMinus); - GXMAP(type,SDL_SCANCODE_KP_MULTIPLY, GHOST_kKeyNumpadAsterisk); - GXMAP(type,SDL_SCANCODE_KP_DIVIDE, GHOST_kKeyNumpadSlash); - - /* Media keys in some keyboards and laptops with XFree86/Xorg */ - GXMAP(type,SDL_SCANCODE_AUDIOPLAY, GHOST_kKeyMediaPlay); - GXMAP(type,SDL_SCANCODE_AUDIOSTOP, GHOST_kKeyMediaStop); - GXMAP(type,SDL_SCANCODE_AUDIOPREV, GHOST_kKeyMediaFirst); - // GXMAP(type,XF86XK_AudioRewind, GHOST_kKeyMediaFirst); - GXMAP(type,SDL_SCANCODE_AUDIONEXT, GHOST_kKeyMediaLast); - - default: - printf("Unknown\n"); - type= GHOST_kKeyUnknown; - break; + GXMAP(type, SDL_SCANCODE_BACKSPACE, GHOST_kKeyBackSpace); + GXMAP(type, SDL_SCANCODE_TAB, GHOST_kKeyTab); + GXMAP(type, SDL_SCANCODE_RETURN, GHOST_kKeyEnter); + GXMAP(type, SDL_SCANCODE_ESCAPE, GHOST_kKeyEsc); + GXMAP(type, SDL_SCANCODE_SPACE, GHOST_kKeySpace); + + GXMAP(type, SDL_SCANCODE_SEMICOLON, GHOST_kKeySemicolon); + GXMAP(type, SDL_SCANCODE_PERIOD, GHOST_kKeyPeriod); + GXMAP(type, SDL_SCANCODE_COMMA, GHOST_kKeyComma); + GXMAP(type, SDL_SCANCODE_APOSTROPHE, GHOST_kKeyQuote); + GXMAP(type, SDL_SCANCODE_GRAVE, GHOST_kKeyAccentGrave); + GXMAP(type, SDL_SCANCODE_MINUS, GHOST_kKeyMinus); + GXMAP(type, SDL_SCANCODE_EQUALS, GHOST_kKeyEqual); + + GXMAP(type, SDL_SCANCODE_SLASH, GHOST_kKeySlash); + GXMAP(type, SDL_SCANCODE_BACKSLASH, GHOST_kKeyBackslash); + GXMAP(type, SDL_SCANCODE_KP_EQUALS, GHOST_kKeyEqual); + GXMAP(type, SDL_SCANCODE_LEFTBRACKET, GHOST_kKeyLeftBracket); + GXMAP(type, SDL_SCANCODE_RIGHTBRACKET, GHOST_kKeyRightBracket); + GXMAP(type, SDL_SCANCODE_PAUSE, GHOST_kKeyPause); + + GXMAP(type, SDL_SCANCODE_LSHIFT, GHOST_kKeyLeftShift); + GXMAP(type, SDL_SCANCODE_RSHIFT, GHOST_kKeyRightShift); + GXMAP(type, SDL_SCANCODE_LCTRL, GHOST_kKeyLeftControl); + GXMAP(type, SDL_SCANCODE_RCTRL, GHOST_kKeyRightControl); + GXMAP(type, SDL_SCANCODE_LALT, GHOST_kKeyLeftAlt); + GXMAP(type, SDL_SCANCODE_RALT, GHOST_kKeyRightAlt); + GXMAP(type, SDL_SCANCODE_LGUI, GHOST_kKeyOS); + GXMAP(type, SDL_SCANCODE_RGUI, GHOST_kKeyOS); + + GXMAP(type, SDL_SCANCODE_INSERT, GHOST_kKeyInsert); + GXMAP(type, SDL_SCANCODE_DELETE, GHOST_kKeyDelete); + GXMAP(type, SDL_SCANCODE_HOME, GHOST_kKeyHome); + GXMAP(type, SDL_SCANCODE_END, GHOST_kKeyEnd); + GXMAP(type, SDL_SCANCODE_PAGEUP, GHOST_kKeyUpPage); + GXMAP(type, SDL_SCANCODE_PAGEDOWN, GHOST_kKeyDownPage); + + GXMAP(type, SDL_SCANCODE_LEFT, GHOST_kKeyLeftArrow); + GXMAP(type, SDL_SCANCODE_RIGHT, GHOST_kKeyRightArrow); + GXMAP(type, SDL_SCANCODE_UP, GHOST_kKeyUpArrow); + GXMAP(type, SDL_SCANCODE_DOWN, GHOST_kKeyDownArrow); + + GXMAP(type, SDL_SCANCODE_CAPSLOCK, GHOST_kKeyCapsLock); + GXMAP(type, SDL_SCANCODE_SCROLLLOCK, GHOST_kKeyScrollLock); + GXMAP(type, SDL_SCANCODE_NUMLOCKCLEAR, GHOST_kKeyNumLock); + GXMAP(type, SDL_SCANCODE_PRINTSCREEN, GHOST_kKeyPrintScreen); + + /* keypad events */ + + /* note, sdl defines a bunch of kp defines I never saw before like + * SDL_SCANCODE_KP_PERCENT, SDL_SCANCODE_KP_XOR - campbell */ + GXMAP(type, SDL_SCANCODE_KP_0, GHOST_kKeyNumpad0); + GXMAP(type, SDL_SCANCODE_KP_1, GHOST_kKeyNumpad1); + GXMAP(type, SDL_SCANCODE_KP_2, GHOST_kKeyNumpad2); + GXMAP(type, SDL_SCANCODE_KP_3, GHOST_kKeyNumpad3); + GXMAP(type, SDL_SCANCODE_KP_4, GHOST_kKeyNumpad4); + GXMAP(type, SDL_SCANCODE_KP_5, GHOST_kKeyNumpad5); + GXMAP(type, SDL_SCANCODE_KP_6, GHOST_kKeyNumpad6); + GXMAP(type, SDL_SCANCODE_KP_7, GHOST_kKeyNumpad7); + GXMAP(type, SDL_SCANCODE_KP_8, GHOST_kKeyNumpad8); + GXMAP(type, SDL_SCANCODE_KP_9, GHOST_kKeyNumpad9); + GXMAP(type, SDL_SCANCODE_KP_PERIOD, GHOST_kKeyNumpadPeriod); + + GXMAP(type, SDL_SCANCODE_KP_ENTER, GHOST_kKeyNumpadEnter); + GXMAP(type, SDL_SCANCODE_KP_PLUS, GHOST_kKeyNumpadPlus); + GXMAP(type, SDL_SCANCODE_KP_MINUS, GHOST_kKeyNumpadMinus); + GXMAP(type, SDL_SCANCODE_KP_MULTIPLY, GHOST_kKeyNumpadAsterisk); + GXMAP(type, SDL_SCANCODE_KP_DIVIDE, GHOST_kKeyNumpadSlash); + + /* Media keys in some keyboards and laptops with XFree86/Xorg */ + GXMAP(type, SDL_SCANCODE_AUDIOPLAY, GHOST_kKeyMediaPlay); + GXMAP(type, SDL_SCANCODE_AUDIOSTOP, GHOST_kKeyMediaStop); + GXMAP(type, SDL_SCANCODE_AUDIOPREV, GHOST_kKeyMediaFirst); + // GXMAP(type,XF86XK_AudioRewind, GHOST_kKeyMediaFirst); + GXMAP(type, SDL_SCANCODE_AUDIONEXT, GHOST_kKeyMediaLast); + + default: + printf("Unknown\n"); + type = GHOST_kKeyUnknown; + break; } } @@ -256,64 +260,64 @@ convertSDLKey(SDL_Scancode key) void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event) { - GHOST_Event * g_event= NULL; + GHOST_Event *g_event = NULL; - switch(sdl_event->type) { - case SDL_WINDOWEVENT: + switch (sdl_event->type) { + case SDL_WINDOWEVENT: { - SDL_WindowEvent &sdl_sub_evt= sdl_event->window; - GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID)); + SDL_WindowEvent &sdl_sub_evt = sdl_event->window; + GHOST_WindowSDL *window = findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID)); //assert(window != NULL); // can be NULL on close window. switch (sdl_sub_evt.event) { - case SDL_WINDOWEVENT_EXPOSED: - g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window); - break; - case SDL_WINDOWEVENT_RESIZED: - g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window); - break; - case SDL_WINDOWEVENT_MOVED: - g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, window); - break; - case SDL_WINDOWEVENT_FOCUS_GAINED: - g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window); - break; - case SDL_WINDOWEVENT_FOCUS_LOST: - g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window); - break; - case SDL_WINDOWEVENT_CLOSE: - g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window); - break; + case SDL_WINDOWEVENT_EXPOSED: + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window); + break; + case SDL_WINDOWEVENT_RESIZED: + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window); + break; + case SDL_WINDOWEVENT_MOVED: + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, window); + break; + case SDL_WINDOWEVENT_FOCUS_GAINED: + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window); + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window); + break; + case SDL_WINDOWEVENT_CLOSE: + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window); + break; } } - break; - case SDL_QUIT: - g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL); - break; + break; + case SDL_QUIT: + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL); + break; - case SDL_MOUSEMOTION: + case SDL_MOUSEMOTION: { - SDL_MouseMotionEvent &sdl_sub_evt= sdl_event->motion; - SDL_Window *sdl_win= SDL_GetWindowFromID(sdl_sub_evt.windowID); - GHOST_WindowSDL *window= findGhostWindow(sdl_win); + SDL_MouseMotionEvent &sdl_sub_evt = sdl_event->motion; + SDL_Window *sdl_win = SDL_GetWindowFromID(sdl_sub_evt.windowID); + GHOST_WindowSDL *window = findGhostWindow(sdl_win); assert(window != NULL); int x_win, y_win; SDL_GetWindowPosition(sdl_win, &x_win, &y_win); - GHOST_TInt32 x_root= sdl_sub_evt.x + x_win; - GHOST_TInt32 y_root= sdl_sub_evt.y + y_win; + GHOST_TInt32 x_root = sdl_sub_evt.x + x_win; + GHOST_TInt32 y_root = sdl_sub_evt.y + y_win; #if 0 - if(window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal) + if (window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal) { - GHOST_TInt32 x_new= x_root; - GHOST_TInt32 y_new= y_root; + GHOST_TInt32 x_new = x_root; + GHOST_TInt32 y_new = y_root; GHOST_TInt32 x_accum, y_accum; GHOST_Rect bounds; /* fallback to window bounds */ - if(window->getCursorGrabBounds(bounds)==GHOST_kFailure) + if (window->getCursorGrabBounds(bounds) == GHOST_kFailure) window->getClientBounds(bounds); /* could also clamp to screen bounds @@ -322,14 +326,15 @@ GHOST_SystemSDL::processEvent(SDL_Event *sdl_event) window->getCursorGrabAccum(x_accum, y_accum); // cant use setCursorPosition because the mouse may have no focus! - if(x_new != x_root || y_new != y_root) { - if (1 ) { //xme.time > m_last_warp) { + if (x_new != x_root || y_new != y_root) { + if (1) { //xme.time > m_last_warp) { /* when wrapping we don't need to add an event because the * setCursorPosition call will cause a new event after */ SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win); /* wrap */ window->setCursorGrabAccum(x_accum + (x_root - x_new), y_accum + (y_root - y_new)); // m_last_warp= lastEventTime(xme.time); - } else { + } + else { // setCursorPosition(x_new, y_new); /* wrap but don't accumulate */ SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win); } @@ -343,117 +348,117 @@ GHOST_SystemSDL::processEvent(SDL_Event *sdl_event) else #endif { - g_event= new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x_root, y_root); + g_event = new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x_root, y_root); } break; } - case SDL_MOUSEBUTTONUP: - case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + case SDL_MOUSEBUTTONDOWN: { - SDL_MouseButtonEvent &sdl_sub_evt= sdl_event->button; - GHOST_TButtonMask gbmask= GHOST_kButtonMaskLeft; - GHOST_TEventType type= (sdl_sub_evt.state==SDL_PRESSED) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp; + SDL_MouseButtonEvent &sdl_sub_evt = sdl_event->button; + GHOST_TButtonMask gbmask = GHOST_kButtonMaskLeft; + GHOST_TEventType type = (sdl_sub_evt.state == SDL_PRESSED) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp; - GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID)); + GHOST_WindowSDL *window = findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID)); assert(window != NULL); /* process rest of normal mouse buttons */ - if(sdl_sub_evt.button == SDL_BUTTON_LEFT) - gbmask= GHOST_kButtonMaskLeft; - else if(sdl_sub_evt.button == SDL_BUTTON_MIDDLE) - gbmask= GHOST_kButtonMaskMiddle; - else if(sdl_sub_evt.button == SDL_BUTTON_RIGHT) - gbmask= GHOST_kButtonMaskRight; + if (sdl_sub_evt.button == SDL_BUTTON_LEFT) + gbmask = GHOST_kButtonMaskLeft; + else if (sdl_sub_evt.button == SDL_BUTTON_MIDDLE) + gbmask = GHOST_kButtonMaskMiddle; + else if (sdl_sub_evt.button == SDL_BUTTON_RIGHT) + gbmask = GHOST_kButtonMaskRight; /* these buttons are untested! */ - else if(sdl_sub_evt.button == SDL_BUTTON_X1) - gbmask= GHOST_kButtonMaskButton4; - else if(sdl_sub_evt.button == SDL_BUTTON_X2) - gbmask= GHOST_kButtonMaskButton5; + else if (sdl_sub_evt.button == SDL_BUTTON_X1) + gbmask = GHOST_kButtonMaskButton4; + else if (sdl_sub_evt.button == SDL_BUTTON_X2) + gbmask = GHOST_kButtonMaskButton5; else break; - g_event= new GHOST_EventButton(getMilliSeconds(), type, window, gbmask); + g_event = new GHOST_EventButton(getMilliSeconds(), type, window, gbmask); break; } - case SDL_MOUSEWHEEL: + case SDL_MOUSEWHEEL: { - SDL_MouseWheelEvent &sdl_sub_evt= sdl_event->wheel; - GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID)); + SDL_MouseWheelEvent &sdl_sub_evt = sdl_event->wheel; + GHOST_WindowSDL *window = findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID)); assert(window != NULL); - g_event= new GHOST_EventWheel(getMilliSeconds(), window, sdl_sub_evt.y); + g_event = new GHOST_EventWheel(getMilliSeconds(), window, sdl_sub_evt.y); } - break; - case SDL_KEYDOWN: - case SDL_KEYUP: + break; + case SDL_KEYDOWN: + case SDL_KEYUP: { - SDL_KeyboardEvent &sdl_sub_evt= sdl_event->key; - SDL_Keycode sym= sdl_sub_evt.keysym.sym; - GHOST_TEventType type= (sdl_sub_evt.state == SDL_PRESSED) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp; + SDL_KeyboardEvent &sdl_sub_evt = sdl_event->key; + SDL_Keycode sym = sdl_sub_evt.keysym.sym; + GHOST_TEventType type = (sdl_sub_evt.state == SDL_PRESSED) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp; - GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID)); + GHOST_WindowSDL *window = findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID)); assert(window != NULL); - GHOST_TKey gkey= convertSDLKey(sdl_sub_evt.keysym.scancode); + GHOST_TKey gkey = convertSDLKey(sdl_sub_evt.keysym.scancode); /* note, the sdl_sub_evt.keysym.sym is truncated, for unicode support ghost has to be modified */ /* printf("%d\n", sym); */ - if(sym > 127) { - switch(sym) { - case SDLK_KP_DIVIDE: sym= '/'; break; - case SDLK_KP_MULTIPLY: sym= '*'; break; - case SDLK_KP_MINUS: sym= '-'; break; - case SDLK_KP_PLUS: sym= '+'; break; - case SDLK_KP_1: sym= '1'; break; - case SDLK_KP_2: sym= '2'; break; - case SDLK_KP_3: sym= '3'; break; - case SDLK_KP_4: sym= '4'; break; - case SDLK_KP_5: sym= '5'; break; - case SDLK_KP_6: sym= '6'; break; - case SDLK_KP_7: sym= '7'; break; - case SDLK_KP_8: sym= '8'; break; - case SDLK_KP_9: sym= '9'; break; - case SDLK_KP_0: sym= '0'; break; - case SDLK_KP_PERIOD: sym= '.'; break; - default: sym= 0; break; + if (sym > 127) { + switch (sym) { + case SDLK_KP_DIVIDE: sym = '/'; break; + case SDLK_KP_MULTIPLY: sym = '*'; break; + case SDLK_KP_MINUS: sym = '-'; break; + case SDLK_KP_PLUS: sym = '+'; break; + case SDLK_KP_1: sym = '1'; break; + case SDLK_KP_2: sym = '2'; break; + case SDLK_KP_3: sym = '3'; break; + case SDLK_KP_4: sym = '4'; break; + case SDLK_KP_5: sym = '5'; break; + case SDLK_KP_6: sym = '6'; break; + case SDLK_KP_7: sym = '7'; break; + case SDLK_KP_8: sym = '8'; break; + case SDLK_KP_9: sym = '9'; break; + case SDLK_KP_0: sym = '0'; break; + case SDLK_KP_PERIOD: sym = '.'; break; + default: sym = 0; break; } } else { - if(sdl_sub_evt.keysym.mod & (KMOD_LSHIFT|KMOD_RSHIFT)) { + if (sdl_sub_evt.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) { /* lame US keyboard assumptions */ - if(sym >= 'a' && sym <= ('a' + 32)) { + if (sym >= 'a' && sym <= ('a' + 32)) { sym -= 32; } else { - switch(sym) { - case '`': sym= '~'; break; - case '1': sym= '!'; break; - case '2': sym= '@'; break; - case '3': sym= '#'; break; - case '4': sym= '$'; break; - case '5': sym= '%'; break; - case '6': sym= '^'; break; - case '7': sym= '&'; break; - case '8': sym= '*'; break; - case '9': sym= '('; break; - case '0': sym= ')'; break; - case '-': sym= '_'; break; - case '=': sym= '+'; break; - case '[': sym= '{'; break; - case ']': sym= '}'; break; - case '\\': sym= '|'; break; - case ';': sym= ':'; break; - case '\'': sym= '"'; break; - case ',': sym= '<'; break; - case '.': sym= '>'; break; - case '/': sym= '?'; break; + switch (sym) { + case '`': sym = '~'; break; + case '1': sym = '!'; break; + case '2': sym = '@'; break; + case '3': sym = '#'; break; + case '4': sym = '$'; break; + case '5': sym = '%'; break; + case '6': sym = '^'; break; + case '7': sym = '&'; break; + case '8': sym = '*'; break; + case '9': sym = '('; break; + case '0': sym = ')'; break; + case '-': sym = '_'; break; + case '=': sym = '+'; break; + case '[': sym = '{'; break; + case ']': sym = '}'; break; + case '\\': sym = '|'; break; + case ';': sym = ':'; break; + case '\'': sym = '"'; break; + case ',': sym = '<'; break; + case '.': sym = '>'; break; + case '/': sym = '?'; break; default: break; } } } } - g_event= new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sym, NULL); + g_event = new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sym, NULL); } - break; + break; } if (g_event) { @@ -466,13 +471,13 @@ GHOST_SystemSDL::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const { int x_win, y_win; - SDL_Window *win= SDL_GetMouseFocus(); + SDL_Window *win = SDL_GetMouseFocus(); SDL_GetWindowPosition(win, &x_win, &y_win); int xi, yi; SDL_GetMouseState(&xi, &yi); - x= xi + x_win; - y= yi + x_win; + x = xi + x_win; + y = yi + x_win; return GHOST_kSuccess; } @@ -482,7 +487,7 @@ GHOST_SystemSDL::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) { int x_win, y_win; - SDL_Window *win= SDL_GetMouseFocus(); + SDL_Window *win = SDL_GetMouseFocus(); SDL_GetWindowPosition(win, &x_win, &y_win); SDL_WarpMouseInWindow(win, x - x_win, y - y_win); @@ -492,24 +497,24 @@ GHOST_SystemSDL::setCursorPosition(GHOST_TInt32 x, bool GHOST_SystemSDL::generateWindowExposeEvents() { - std::vector<GHOST_WindowSDL *>::iterator w_start= m_dirty_windows.begin(); - std::vector<GHOST_WindowSDL *>::const_iterator w_end= m_dirty_windows.end(); - bool anyProcessed= false; - - for (;w_start != w_end; ++w_start) { - GHOST_Event * g_event= new - GHOST_Event( - getMilliSeconds(), - GHOST_kEventWindowUpdate, - *w_start - ); + std::vector<GHOST_WindowSDL *>::iterator w_start = m_dirty_windows.begin(); + std::vector<GHOST_WindowSDL *>::const_iterator w_end = m_dirty_windows.end(); + bool anyProcessed = false; + + for (; w_start != w_end; ++w_start) { + GHOST_Event *g_event = new + GHOST_Event( + getMilliSeconds(), + GHOST_kEventWindowUpdate, + *w_start + ); (*w_start)->validate(); if (g_event) { printf("Expose events pushed\n"); pushEvent(g_event); - anyProcessed= true; + anyProcessed = true; } } @@ -524,21 +529,22 @@ GHOST_SystemSDL::processEvents(bool waitForEvent) // Get all the current events -- translate them into // ghost events and call base class pushEvent() method. - bool anyProcessed= false; + bool anyProcessed = false; do { - GHOST_TimerManager* timerMgr= getTimerManager(); + GHOST_TimerManager *timerMgr = getTimerManager(); if (waitForEvent && m_dirty_windows.empty() && !SDL_HasEvents(SDL_FIRSTEVENT, SDL_LASTEVENT)) { - GHOST_TUns64 next= timerMgr->nextFireTime(); + GHOST_TUns64 next = timerMgr->nextFireTime(); - if (next==GHOST_kFireTimeNever) { + if (next == GHOST_kFireTimeNever) { SDL_WaitEventTimeout(NULL, -1); //SleepTillEvent(m_display, -1); - } else { - GHOST_TInt64 maxSleep= next - getMilliSeconds(); + } + else { + GHOST_TInt64 maxSleep = next - getMilliSeconds(); - if(maxSleep >= 0) { + if (maxSleep >= 0) { SDL_WaitEventTimeout(NULL, next - getMilliSeconds()); // SleepTillEvent(m_display, next - getMilliSeconds()); // X11 } @@ -546,17 +552,17 @@ GHOST_SystemSDL::processEvents(bool waitForEvent) } if (timerMgr->fireTimers(getMilliSeconds())) { - anyProcessed= true; + anyProcessed = true; } SDL_Event sdl_event; while (SDL_PollEvent(&sdl_event)) { processEvent(&sdl_event); - anyProcessed= true; + anyProcessed = true; } if (generateWindowExposeEvents()) { - anyProcessed= true; + anyProcessed = true; } } while (waitForEvent && !anyProcessed); @@ -574,13 +580,13 @@ GHOST_SystemSDL::findGhostWindow(SDL_Window *sdl_win) // We should always check the window manager's list of windows // and only process events on these windows. - std::vector<GHOST_IWindow *> & win_vec= m_windowManager->getWindows(); + std::vector<GHOST_IWindow *> & win_vec = m_windowManager->getWindows(); - std::vector<GHOST_IWindow *>::iterator win_it= win_vec.begin(); - std::vector<GHOST_IWindow *>::const_iterator win_end= win_vec.end(); + std::vector<GHOST_IWindow *>::iterator win_it = win_vec.begin(); + std::vector<GHOST_IWindow *>::const_iterator win_end = win_vec.end(); for (; win_it != win_end; ++win_it) { - GHOST_WindowSDL * window= static_cast<GHOST_WindowSDL *>(*win_it); + GHOST_WindowSDL *window = static_cast<GHOST_WindowSDL *>(*win_it); if (window->getSDLWindow() == sdl_win) { return window; } @@ -600,7 +606,7 @@ GHOST_SystemSDL::addDirtyWindow(GHOST_WindowSDL *bad_wind) GHOST_TSuccess GHOST_SystemSDL::getButtons(GHOST_Buttons& buttons) const { - Uint8 state= SDL_GetMouseState(NULL, NULL); + Uint8 state = SDL_GetMouseState(NULL, NULL); buttons.set(GHOST_kButtonMaskLeft, (state & SDL_BUTTON_LMASK) != 0); buttons.set(GHOST_kButtonMaskMiddle, (state & SDL_BUTTON_MMASK) != 0); buttons.set(GHOST_kButtonMaskRight, (state & SDL_BUTTON_RMASK) != 0); diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 9f2728a581f..7a65c741532 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -115,16 +115,16 @@ #endif // VK_GR_LESS #ifndef VK_MEDIA_NEXT_TRACK -#define VK_MEDIA_NEXT_TRACK 0xB0 +#define VK_MEDIA_NEXT_TRACK 0xB0 #endif // VK_MEDIA_NEXT_TRACK #ifndef VK_MEDIA_PREV_TRACK -#define VK_MEDIA_PREV_TRACK 0xB1 +#define VK_MEDIA_PREV_TRACK 0xB1 #endif // VK_MEDIA_PREV_TRACK #ifndef VK_MEDIA_STOP -#define VK_MEDIA_STOP 0xB2 +#define VK_MEDIA_STOP 0xB2 #endif // VK_MEDIA_STOP #ifndef VK_MEDIA_PLAY_PAUSE -#define VK_MEDIA_PLAY_PAUSE 0xB3 +#define VK_MEDIA_PLAY_PAUSE 0xB3 #endif // VK_MEDIA_PLAY_PAUSE static void initRawInput() @@ -150,7 +150,7 @@ static void initRawInput() #endif if (RegisterRawInputDevices(devices, DEVICE_COUNT, sizeof(RAWINPUTDEVICE))) - ; // yay! + ; // yay! else printf("could not register for RawInput: %d\n", (int)GetLastError()); @@ -158,9 +158,9 @@ static void initRawInput() } GHOST_SystemWin32::GHOST_SystemWin32() -: m_hasPerformanceCounter(false), m_freq(0), m_start(0) + : m_hasPerformanceCounter(false), m_freq(0), m_start(0) { - m_displayManager = new GHOST_DisplayManagerWin32 (); + m_displayManager = new GHOST_DisplayManagerWin32(); GHOST_ASSERT(m_displayManager, "GHOST_SystemWin32::GHOST_SystemWin32(): m_displayManager==0\n"); m_displayManager->initialize(); @@ -195,12 +195,12 @@ GHOST_TUns64 GHOST_SystemWin32::getMilliSeconds() const // Retrieve current count __int64 count = 0; - ::QueryPerformanceCounter((LARGE_INTEGER*)&count); + ::QueryPerformanceCounter((LARGE_INTEGER *)&count); // Calculate the time passed since system initialization. - __int64 delta = 1000*(count-m_start); + __int64 delta = 1000 * (count - m_start); - GHOST_TUns64 t = (GHOST_TUns64)(delta/m_freq); + GHOST_TUns64 t = (GHOST_TUns64)(delta / m_freq); return t; } @@ -217,37 +217,37 @@ GHOST_TUns8 GHOST_SystemWin32::getNumDisplays() const void GHOST_SystemWin32::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const { width = ::GetSystemMetrics(SM_CXSCREEN); - height= ::GetSystemMetrics(SM_CYSCREEN); + height = ::GetSystemMetrics(SM_CYSCREEN); } -GHOST_IWindow* GHOST_SystemWin32::createWindow( - const STR_String& title, - GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, - GHOST_TWindowState state, GHOST_TDrawingContextType type, - bool stereoVisual, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow ) +GHOST_IWindow *GHOST_SystemWin32::createWindow( + const STR_String& title, + GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, + GHOST_TWindowState state, GHOST_TDrawingContextType type, + bool stereoVisual, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow) { - GHOST_Window* window = 0; - window = new GHOST_WindowWin32 (this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples, parentWindow); + GHOST_Window *window = 0; + window = new GHOST_WindowWin32(this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples, parentWindow); if (window) { if (window->getValid()) { // Store the pointer to the window // if (state != GHOST_kWindowStateFullScreen) { - m_windowManager->addWindow(window); - m_windowManager->setActiveWindow(window); + m_windowManager->addWindow(window); + m_windowManager->setActiveWindow(window); // } } else { // Invalid parent window hwnd - if (((GHOST_WindowWin32*)window)->getNextWindow() == NULL) { + if (((GHOST_WindowWin32 *)window)->getNextWindow() == NULL) { delete window; window = 0; return window; } // An invalid window could be one that was used to test for AA - window = ((GHOST_WindowWin32*)window)->getNextWindow(); + window = ((GHOST_WindowWin32 *)window)->getNextWindow(); // If another window is found, let the wm know about that one, but not the old one if (window->getValid()) { @@ -270,7 +270,7 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent) bool anyProcessed = false; do { - GHOST_TimerManager* timerMgr = getTimerManager(); + GHOST_TimerManager *timerMgr = getTimerManager(); if (waitForEvent && !::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) { #if 1 @@ -281,7 +281,8 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent) if (next == GHOST_kFireTimeNever) { ::WaitMessage(); - } else if(maxSleep >= 0.0) { + } + else if (maxSleep >= 0.0) { ::SetTimer(NULL, 0, maxSleep, NULL); ::WaitMessage(); ::KillTimer(NULL, 0); @@ -307,7 +308,7 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent) GHOST_TSuccess GHOST_SystemWin32::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const { POINT point; - if(::GetCursorPos(&point)){ + if (::GetCursorPos(&point)) { x = point.x; y = point.y; return GHOST_kSuccess; @@ -343,7 +344,7 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) cons bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0; bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0; - if(lwindown || rwindown) + if (lwindown || rwindown) keys.set(GHOST_kModifierKeyOS, true); else keys.set(GHOST_kModifierKeyOS, false); @@ -376,20 +377,20 @@ GHOST_TSuccess GHOST_SystemWin32::init() /* Disable scaling on high DPI displays on Vista */ HMODULE - user32 = ::LoadLibraryA("user32.dll"); + user32 = ::LoadLibraryA("user32.dll"); typedef BOOL (WINAPI * LPFNSETPROCESSDPIAWARE)(); LPFNSETPROCESSDPIAWARE SetProcessDPIAware = - (LPFNSETPROCESSDPIAWARE)GetProcAddress(user32, "SetProcessDPIAware"); + (LPFNSETPROCESSDPIAWARE)GetProcAddress(user32, "SetProcessDPIAware"); if (SetProcessDPIAware) SetProcessDPIAware(); FreeLibrary(user32); initRawInput(); // Determine whether this system has a high frequency performance counter. */ - m_hasPerformanceCounter = ::QueryPerformanceFrequency((LARGE_INTEGER*)&m_freq) == TRUE; + m_hasPerformanceCounter = ::QueryPerformanceFrequency((LARGE_INTEGER *)&m_freq) == TRUE; if (m_hasPerformanceCounter) { GHOST_PRINT("GHOST_SystemWin32::init: High Frequency Performance Timer available\n") - ::QueryPerformanceCounter((LARGE_INTEGER*)&m_start); + ::QueryPerformanceCounter((LARGE_INTEGER *)&m_start); } else { GHOST_PRINT("GHOST_SystemWin32::init: High Frequency Performance Timer not available\n") @@ -397,20 +398,20 @@ GHOST_TSuccess GHOST_SystemWin32::init() if (success) { WNDCLASSW wc; - wc.style= CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc= s_wndProc; - wc.cbClsExtra= 0; - wc.cbWndExtra= 0; - wc.hInstance= ::GetModuleHandle(0); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = s_wndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = ::GetModuleHandle(0); wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON"); if (!wc.hIcon) { ::LoadIcon(NULL, IDI_APPLICATION); } wc.hCursor = ::LoadCursor(0, IDC_ARROW); - wc.hbrBackground= (HBRUSH)::GetStockObject(BLACK_BRUSH); + wc.hbrBackground = (HBRUSH) ::GetStockObject(BLACK_BRUSH); wc.lpszMenuName = 0; - wc.lpszClassName= L"GHOST_WindowClass"; + wc.lpszClassName = L"GHOST_WindowClass"; // Use RegisterClassEx for setting small icon if (::RegisterClassW(&wc) == 0) { @@ -427,12 +428,12 @@ GHOST_TSuccess GHOST_SystemWin32::exit() return GHOST_System::exit(); } -GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw, int * keyDown, char * vk) +GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw, int *keyDown, char *vk) { GHOST_TKey key = GHOST_kKeyUnknown; - if(!keyDown) + if (!keyDown) return GHOST_kKeyUnknown; @@ -446,66 +447,65 @@ GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw unsigned int msg = raw.data.keyboard.Message; *keyDown = !(raw.data.keyboard.Flags & RI_KEY_BREAK) && msg != WM_KEYUP && msg != WM_SYSKEYUP; - key = this->convertKey(window, raw.data.keyboard.VKey, raw.data.keyboard.MakeCode, (raw.data.keyboard.Flags&(RI_KEY_E1|RI_KEY_E0))); + key = this->convertKey(window, raw.data.keyboard.VKey, raw.data.keyboard.MakeCode, (raw.data.keyboard.Flags & (RI_KEY_E1 | RI_KEY_E0))); // extra handling of modifier keys: don't send repeats out from GHOST - if(key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt) + if (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt) { bool changed = false; GHOST_TModifierKeyMask modifier; - switch(key) { + switch (key) { case GHOST_kKeyLeftShift: - { - changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != (bool)*keyDown); - modifier = GHOST_kModifierKeyLeftShift; - } - break; + { + changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != (bool)*keyDown); + modifier = GHOST_kModifierKeyLeftShift; + } + break; case GHOST_kKeyRightShift: - { - changed = (modifiers.get(GHOST_kModifierKeyRightShift) != (bool)*keyDown); - modifier = GHOST_kModifierKeyRightShift; - } - break; + { + changed = (modifiers.get(GHOST_kModifierKeyRightShift) != (bool)*keyDown); + modifier = GHOST_kModifierKeyRightShift; + } + break; case GHOST_kKeyLeftControl: - { - changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != (bool)*keyDown); - modifier = GHOST_kModifierKeyLeftControl; - } - break; + { + changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != (bool)*keyDown); + modifier = GHOST_kModifierKeyLeftControl; + } + break; case GHOST_kKeyRightControl: - { - changed = (modifiers.get(GHOST_kModifierKeyRightControl) != (bool)*keyDown); - modifier = GHOST_kModifierKeyRightControl; - } - break; + { + changed = (modifiers.get(GHOST_kModifierKeyRightControl) != (bool)*keyDown); + modifier = GHOST_kModifierKeyRightControl; + } + break; case GHOST_kKeyLeftAlt: - { - changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != (bool)*keyDown); - modifier = GHOST_kModifierKeyLeftAlt; - } - break; + { + changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != (bool)*keyDown); + modifier = GHOST_kModifierKeyLeftAlt; + } + break; case GHOST_kKeyRightAlt: - { - changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != (bool)*keyDown); - modifier = GHOST_kModifierKeyRightAlt; - } - break; + { + changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != (bool)*keyDown); + modifier = GHOST_kModifierKeyRightAlt; + } + break; default: break; } - if(changed) + if (changed) { modifiers.set(modifier, (bool)*keyDown); system->storeModifierKeys(modifiers); } - else - { + else { key = GHOST_kKeyUnknown; } } - if(vk) *vk = raw.data.keyboard.VKey; + if (vk) *vk = raw.data.keyboard.VKey; return key; } @@ -515,9 +515,9 @@ GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw GHOST_TKey GHOST_SystemWin32::processSpecialKey(GHOST_IWindow *window, short vKey, short scanCode) const { GHOST_TKey key = GHOST_kKeyUnknown; - switch(PRIMARYLANGID(m_langId)) { + switch (PRIMARYLANGID(m_langId)) { case LANG_FRENCH: - if(vKey==VK_OEM_8) key = GHOST_kKeyF13; // oem key; used purely for shortcuts . + if (vKey == VK_OEM_8) key = GHOST_kKeyF13; // oem key; used purely for shortcuts . break; } @@ -541,111 +541,111 @@ GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, short vKey, shor } else { switch (vKey) { - case VK_RETURN: - key = (extend)?GHOST_kKeyNumpadEnter : GHOST_kKeyEnter; break; + case VK_RETURN: + key = (extend) ? GHOST_kKeyNumpadEnter : GHOST_kKeyEnter; break; - case VK_BACK: key = GHOST_kKeyBackSpace; break; - case VK_TAB: key = GHOST_kKeyTab; break; - case VK_ESCAPE: key = GHOST_kKeyEsc; break; - case VK_SPACE: key = GHOST_kKeySpace; break; - - case VK_INSERT: - case VK_NUMPAD0: - key = (extend) ? GHOST_kKeyInsert : GHOST_kKeyNumpad0; break; - case VK_END: - case VK_NUMPAD1: - key = (extend) ? GHOST_kKeyEnd : GHOST_kKeyNumpad1; break; - case VK_DOWN: - case VK_NUMPAD2: - key = (extend) ? GHOST_kKeyDownArrow : GHOST_kKeyNumpad2; break; - case VK_NEXT: - case VK_NUMPAD3: - key = (extend) ? GHOST_kKeyDownPage : GHOST_kKeyNumpad3; break; - case VK_LEFT: - case VK_NUMPAD4: - key = (extend) ? GHOST_kKeyLeftArrow : GHOST_kKeyNumpad4; break; - case VK_CLEAR: - case VK_NUMPAD5: - key = (extend) ? GHOST_kKeyUnknown: GHOST_kKeyNumpad5; break; - case VK_RIGHT: - case VK_NUMPAD6: - key = (extend) ? GHOST_kKeyRightArrow : GHOST_kKeyNumpad6; break; - case VK_HOME: - case VK_NUMPAD7: - key = (extend) ? GHOST_kKeyHome : GHOST_kKeyNumpad7; break; - case VK_UP: - case VK_NUMPAD8: - key = (extend) ? GHOST_kKeyUpArrow : GHOST_kKeyNumpad8; break; - case VK_PRIOR: - case VK_NUMPAD9: - key = (extend) ? GHOST_kKeyUpPage : GHOST_kKeyNumpad9; break; - case VK_DECIMAL: - case VK_DELETE: - key = (extend) ? GHOST_kKeyDelete : GHOST_kKeyNumpadPeriod; break; - - case VK_SNAPSHOT: key = GHOST_kKeyPrintScreen; break; - case VK_PAUSE: key = GHOST_kKeyPause; break; - case VK_MULTIPLY: key = GHOST_kKeyNumpadAsterisk; break; - case VK_SUBTRACT: key = GHOST_kKeyNumpadMinus; break; - case VK_DIVIDE: key = GHOST_kKeyNumpadSlash; break; - case VK_ADD: key = GHOST_kKeyNumpadPlus; break; - - case VK_SEMICOLON: key = GHOST_kKeySemicolon; break; - case VK_EQUALS: key = GHOST_kKeyEqual; break; - case VK_COMMA: key = GHOST_kKeyComma; break; - case VK_MINUS: key = GHOST_kKeyMinus; break; - case VK_PERIOD: key = GHOST_kKeyPeriod; break; - case VK_SLASH: key = GHOST_kKeySlash; break; - case VK_BACK_QUOTE: key = GHOST_kKeyAccentGrave; break; - case VK_OPEN_BRACKET: key = GHOST_kKeyLeftBracket; break; - case VK_BACK_SLASH: key = GHOST_kKeyBackslash; break; - case VK_CLOSE_BRACKET: key = GHOST_kKeyRightBracket; break; - case VK_QUOTE: key = GHOST_kKeyQuote; break; - case VK_GR_LESS: key = GHOST_kKeyGrLess; break; - - case VK_SHIFT: - key = (scanCode == 0x36)? GHOST_kKeyRightShift : GHOST_kKeyLeftShift; - break; - case VK_CONTROL: - key = (extend)? GHOST_kKeyRightControl : GHOST_kKeyLeftControl; - break; - case VK_MENU: - key = (extend)? GHOST_kKeyRightAlt : GHOST_kKeyLeftAlt; - break; - case VK_LWIN: - case VK_RWIN: - key = GHOST_kKeyOS; - break; - case VK_NUMLOCK: key = GHOST_kKeyNumLock; break; - case VK_SCROLL: key = GHOST_kKeyScrollLock; break; - case VK_CAPITAL: key = GHOST_kKeyCapsLock; break; - case VK_OEM_8: - key = ((GHOST_SystemWin32*)getSystem())->processSpecialKey(window, vKey, scanCode); - break; - case VK_MEDIA_PLAY_PAUSE: key = GHOST_kKeyMediaPlay; break; - case VK_MEDIA_STOP: key = GHOST_kKeyMediaStop; break; - case VK_MEDIA_PREV_TRACK: key = GHOST_kKeyMediaFirst; break; - case VK_MEDIA_NEXT_TRACK: key = GHOST_kKeyMediaLast; break; - default: - key = GHOST_kKeyUnknown; - break; + case VK_BACK: key = GHOST_kKeyBackSpace; break; + case VK_TAB: key = GHOST_kKeyTab; break; + case VK_ESCAPE: key = GHOST_kKeyEsc; break; + case VK_SPACE: key = GHOST_kKeySpace; break; + + case VK_INSERT: + case VK_NUMPAD0: + key = (extend) ? GHOST_kKeyInsert : GHOST_kKeyNumpad0; break; + case VK_END: + case VK_NUMPAD1: + key = (extend) ? GHOST_kKeyEnd : GHOST_kKeyNumpad1; break; + case VK_DOWN: + case VK_NUMPAD2: + key = (extend) ? GHOST_kKeyDownArrow : GHOST_kKeyNumpad2; break; + case VK_NEXT: + case VK_NUMPAD3: + key = (extend) ? GHOST_kKeyDownPage : GHOST_kKeyNumpad3; break; + case VK_LEFT: + case VK_NUMPAD4: + key = (extend) ? GHOST_kKeyLeftArrow : GHOST_kKeyNumpad4; break; + case VK_CLEAR: + case VK_NUMPAD5: + key = (extend) ? GHOST_kKeyUnknown : GHOST_kKeyNumpad5; break; + case VK_RIGHT: + case VK_NUMPAD6: + key = (extend) ? GHOST_kKeyRightArrow : GHOST_kKeyNumpad6; break; + case VK_HOME: + case VK_NUMPAD7: + key = (extend) ? GHOST_kKeyHome : GHOST_kKeyNumpad7; break; + case VK_UP: + case VK_NUMPAD8: + key = (extend) ? GHOST_kKeyUpArrow : GHOST_kKeyNumpad8; break; + case VK_PRIOR: + case VK_NUMPAD9: + key = (extend) ? GHOST_kKeyUpPage : GHOST_kKeyNumpad9; break; + case VK_DECIMAL: + case VK_DELETE: + key = (extend) ? GHOST_kKeyDelete : GHOST_kKeyNumpadPeriod; break; + + case VK_SNAPSHOT: key = GHOST_kKeyPrintScreen; break; + case VK_PAUSE: key = GHOST_kKeyPause; break; + case VK_MULTIPLY: key = GHOST_kKeyNumpadAsterisk; break; + case VK_SUBTRACT: key = GHOST_kKeyNumpadMinus; break; + case VK_DIVIDE: key = GHOST_kKeyNumpadSlash; break; + case VK_ADD: key = GHOST_kKeyNumpadPlus; break; + + case VK_SEMICOLON: key = GHOST_kKeySemicolon; break; + case VK_EQUALS: key = GHOST_kKeyEqual; break; + case VK_COMMA: key = GHOST_kKeyComma; break; + case VK_MINUS: key = GHOST_kKeyMinus; break; + case VK_PERIOD: key = GHOST_kKeyPeriod; break; + case VK_SLASH: key = GHOST_kKeySlash; break; + case VK_BACK_QUOTE: key = GHOST_kKeyAccentGrave; break; + case VK_OPEN_BRACKET: key = GHOST_kKeyLeftBracket; break; + case VK_BACK_SLASH: key = GHOST_kKeyBackslash; break; + case VK_CLOSE_BRACKET: key = GHOST_kKeyRightBracket; break; + case VK_QUOTE: key = GHOST_kKeyQuote; break; + case VK_GR_LESS: key = GHOST_kKeyGrLess; break; + + case VK_SHIFT: + key = (scanCode == 0x36) ? GHOST_kKeyRightShift : GHOST_kKeyLeftShift; + break; + case VK_CONTROL: + key = (extend) ? GHOST_kKeyRightControl : GHOST_kKeyLeftControl; + break; + case VK_MENU: + key = (extend) ? GHOST_kKeyRightAlt : GHOST_kKeyLeftAlt; + break; + case VK_LWIN: + case VK_RWIN: + key = GHOST_kKeyOS; + break; + case VK_NUMLOCK: key = GHOST_kKeyNumLock; break; + case VK_SCROLL: key = GHOST_kKeyScrollLock; break; + case VK_CAPITAL: key = GHOST_kKeyCapsLock; break; + case VK_OEM_8: + key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(window, vKey, scanCode); + break; + case VK_MEDIA_PLAY_PAUSE: key = GHOST_kKeyMediaPlay; break; + case VK_MEDIA_STOP: key = GHOST_kKeyMediaStop; break; + case VK_MEDIA_PREV_TRACK: key = GHOST_kKeyMediaFirst; break; + case VK_MEDIA_NEXT_TRACK: key = GHOST_kKeyMediaLast; break; + default: + key = GHOST_kKeyUnknown; + break; } } return key; } -GHOST_EventButton* GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask) +GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask) { - return new GHOST_EventButton (getSystem()->getMilliSeconds(), type, window, mask); + return new GHOST_EventButton(getSystem()->getMilliSeconds(), type, window, mask); } -GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow) +GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow) { GHOST_TInt32 x_screen, y_screen; - GHOST_SystemWin32 * system = ((GHOST_SystemWin32 * ) getSystem()); - GHOST_WindowWin32 * window = ( GHOST_WindowWin32 * ) Iwindow; + GHOST_SystemWin32 *system = ((GHOST_SystemWin32 * ) getSystem()); + GHOST_WindowWin32 *window = ( GHOST_WindowWin32 * ) Iwindow; system->getCursorPosition(x_screen, y_screen); @@ -653,13 +653,13 @@ GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, bool is_tablet = false; if (is_tablet == false && window->getCursorGrabModeIsWarp()) { - GHOST_TInt32 x_new= x_screen; - GHOST_TInt32 y_new= y_screen; + GHOST_TInt32 x_new = x_screen; + GHOST_TInt32 y_new = y_screen; GHOST_TInt32 x_accum, y_accum; GHOST_Rect bounds; /* fallback to window bounds */ - if(window->getCursorGrabBounds(bounds)==GHOST_kFailure){ + if (window->getCursorGrabBounds(bounds) == GHOST_kFailure) { window->getClientBounds(bounds); } @@ -669,86 +669,87 @@ GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, bounds.wrapPoint(x_new, y_new, 2); /* offset of one incase blender is at screen bounds */ window->getCursorGrabAccum(x_accum, y_accum); - if(x_new != x_screen|| y_new != y_screen) { + if (x_new != x_screen || y_new != y_screen) { /* when wrapping we don't need to add an event because the * setCursorPosition call will cause a new event after */ system->setCursorPosition(x_new, y_new); /* wrap */ window->setCursorGrabAccum(x_accum + (x_screen - x_new), y_accum + (y_screen - y_new)); - }else{ + } + else { return new GHOST_EventCursor(system->getMilliSeconds(), - GHOST_kEventCursorMove, - window, - x_screen + x_accum, - y_screen + y_accum - ); + GHOST_kEventCursorMove, + window, + x_screen + x_accum, + y_screen + y_accum + ); } } else { return new GHOST_EventCursor(system->getMilliSeconds(), - GHOST_kEventCursorMove, - window, - x_screen, - y_screen - ); + GHOST_kEventCursorMove, + window, + x_screen, + y_screen + ); } return NULL; } -GHOST_EventWheel* GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) +GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) { // short fwKeys = LOWORD(wParam); // key flags - int zDelta = (short) HIWORD(wParam); // wheel rotation + int zDelta = (short) HIWORD(wParam); // wheel rotation // zDelta /= WHEEL_DELTA; // temporary fix below: microsoft now has added more precision, making the above division not work - if (zDelta <= 0 ) zDelta= -1; else zDelta= 1; + if (zDelta <= 0) zDelta = -1; else zDelta = 1; // short xPos = (short) LOWORD(lParam); // horizontal position of pointer // short yPos = (short) HIWORD(lParam); // vertical position of pointer - return new GHOST_EventWheel (getSystem()->getMilliSeconds(), window, zDelta); + return new GHOST_EventWheel(getSystem()->getMilliSeconds(), window, zDelta); } -GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw) +GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw) { - int keyDown=0; + int keyDown = 0; char vk; - GHOST_SystemWin32 * system = (GHOST_SystemWin32 *)getSystem(); + GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem(); GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk); - GHOST_EventKey* event; + GHOST_EventKey *event; if (key != GHOST_kKeyUnknown) { char utf8_char[6] = {0}; char ascii = 0; - wchar_t utf16[3]={0}; - BYTE state[256] ={0}; + wchar_t utf16[3] = {0}; + BYTE state[256] = {0}; int r; GetKeyboardState((PBYTE)state); - if(r = ToUnicodeEx(vk, 0, state, utf16, 2, 0, system->m_keylayout)) { - if((r>0 && r<3)){ - utf16[r]=0; - conv_utf_16_to_8(utf16,utf8_char,6); + if (r = ToUnicodeEx(vk, 0, state, utf16, 2, 0, system->m_keylayout)) { + if ((r > 0 && r < 3)) { + utf16[r] = 0; + conv_utf_16_to_8(utf16, utf8_char, 6); } - else if (r==-1) { + else if (r == -1) { utf8_char[0] = '\0'; } } - if(!keyDown) { + if (!keyDown) { utf8_char[0] = '\0'; - ascii='\0'; + ascii = '\0'; } else { - ascii = utf8_char[0]& 0x80?'?' : utf8_char[0]; + ascii = utf8_char[0] & 0x80 ? '?' : utf8_char[0]; } - if(0x80&state[VK_MENU]) utf8_char[0]='\0'; + if (0x80 & state[VK_MENU]) utf8_char[0] = '\0'; - event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii, utf8_char); + event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, key, ascii, utf8_char); #ifdef GHOST_DEBUG std::cout << ascii << std::endl; @@ -761,9 +762,9 @@ GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINP } -GHOST_Event* GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_IWindow* window) +GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_IWindow *window) { - GHOST_System* system = (GHOST_System*)getSystem(); + GHOST_System *system = (GHOST_System *)getSystem(); if (type == GHOST_kEventWindowActivate) { system->getWindowManager()->setActiveWindow(window); @@ -773,23 +774,23 @@ GHOST_Event* GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_ } GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(GHOST_TEventType eventType, - GHOST_TDragnDropTypes draggedObjectType, - GHOST_IWindow* window, - int mouseX, int mouseY, - void* data) + GHOST_TDragnDropTypes draggedObjectType, + GHOST_IWindow *window, + int mouseX, int mouseY, + void *data) { - GHOST_SystemWin32* system = ((GHOST_SystemWin32*)getSystem()); + GHOST_SystemWin32 *system = ((GHOST_SystemWin32 *)getSystem()); return system->pushEvent(new GHOST_EventDragnDrop(system->getMilliSeconds(), - eventType, - draggedObjectType, - window,mouseX,mouseY,data) - ); + eventType, + draggedObjectType, + window, mouseX, mouseY, data) + ); } -void GHOST_SystemWin32::processMinMaxInfo(MINMAXINFO * minmax) +void GHOST_SystemWin32::processMinMaxInfo(MINMAXINFO *minmax) { - minmax->ptMinTrackSize.x=320; - minmax->ptMinTrackSize.y=240; + minmax->ptMinTrackSize.x = 320; + minmax->ptMinTrackSize.y = 240; } #ifdef WITH_INPUT_NDOF @@ -821,7 +822,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw) // using Microsoft compiler & header files // they invented the RawInput API, so this version is (probably) correct. // MinGW64 also works fine with this - BYTE const* data = raw.data.hid.bRawData; + BYTE const *data = raw.data.hid.bRawData; // struct RAWHID { // DWORD dwSizeHid; // DWORD dwCount; @@ -830,7 +831,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw) #else // MinGW's definition (below) doesn't agree, so we need a slight // workaround until it's fixed - BYTE const* data = &raw.data.hid.bRawData; + BYTE const *data = &raw.data.hid.bRawData; // struct RAWHID { // DWORD dwSizeHid; // DWORD dwCount; @@ -843,7 +844,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw) { case 1: // translation { - short* axis = (short*)(data + 1); + short *axis = (short *)(data + 1); // massage into blender view coords (same goes for rotation) short t[3] = {axis[0], -axis[2], axis[1]}; m_ndofManager->updateTranslation(t, now); @@ -860,7 +861,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw) } case 2: // rotation { - short* axis = (short*)(data + 1); + short *axis = (short *)(data + 1); short r[3] = {-axis[0], axis[2], -axis[1]}; m_ndofManager->updateRotation(r, now); break; @@ -879,15 +880,15 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw) LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - GHOST_Event* event = 0; + GHOST_Event *event = 0; bool eventHandled = false; LRESULT lResult = 0; - GHOST_SystemWin32* system = ((GHOST_SystemWin32*)getSystem()); + GHOST_SystemWin32 *system = ((GHOST_SystemWin32 *)getSystem()); GHOST_ASSERT(system, "GHOST_SystemWin32::s_wndProc(): system not initialized") if (hwnd) { - GHOST_WindowWin32* window = (GHOST_WindowWin32*)::GetWindowLong(hwnd, GWL_USERDATA); + GHOST_WindowWin32 *window = (GHOST_WindowWin32 *)::GetWindowLong(hwnd, GWL_USERDATA); if (window) { switch (msg) { // we need to check if new key layout has AltGr @@ -906,29 +907,29 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, } //else wParam == RIM_INPUT RAWINPUT raw; - RAWINPUT* raw_ptr = &raw; + RAWINPUT *raw_ptr = &raw; UINT rawSize = sizeof(RAWINPUT); GetRawInputData((HRAWINPUT)lParam, RID_INPUT, raw_ptr, &rawSize, sizeof(RAWINPUTHEADER)); switch (raw.header.dwType) { - case RIM_TYPEKEYBOARD: - event = processKeyEvent(window, raw); - if (!event) { - GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ") - GHOST_PRINT(msg) - GHOST_PRINT(" key ignored\n") - } - break; + case RIM_TYPEKEYBOARD: + event = processKeyEvent(window, raw); + if (!event) { + GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ") + GHOST_PRINT(msg) + GHOST_PRINT(" key ignored\n") + } + break; #ifdef WITH_INPUT_NDOF - case RIM_TYPEHID: - if (system->processNDOF(raw)) - eventHandled = true; - break; + case RIM_TYPEHID: + if (system->processNDOF(raw)) + eventHandled = true; + break; #endif } - break; + break; } //////////////////////////////////////////////////////////////////////// // Keyboard events, ignored @@ -937,12 +938,12 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: - /* These functions were replaced by WM_INPUT*/ + /* These functions were replaced by WM_INPUT*/ case WM_CHAR: - /* The WM_CHAR message is posted to the window with the keyboard focus when - * a WM_KEYDOWN message is translated by the TranslateMessage function. WM_CHAR - * contains the character code of the key that was pressed. - */ + /* The WM_CHAR message is posted to the window with the keyboard focus when + * a WM_KEYDOWN message is translated by the TranslateMessage function. WM_CHAR + * contains the character code of the key that was pressed. + */ case WM_DEADCHAR: /* The WM_DEADCHAR message is posted to the window with the keyboard focus when a * WM_KEYUP message is translated by the TranslateMessage function. WM_DEADCHAR @@ -954,11 +955,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, */ break; case WM_SYSDEADCHAR: - /* The WM_SYSDEADCHAR message is sent to the window with the keyboard focus when - * a WM_SYSKEYDOWN message is translated by the TranslateMessage function. - * WM_SYSDEADCHAR specifies the character code of a system dead key - that is, - * a dead key that is pressed while holding down the alt key. - */ + /* The WM_SYSDEADCHAR message is sent to the window with the keyboard focus when + * a WM_SYSKEYDOWN message is translated by the TranslateMessage function. + * WM_SYSDEADCHAR specifies the character code of a system dead key - that is, + * a dead key that is pressed while holding down the alt key. + */ case WM_SYSCHAR: /* The WM_SYSCHAR message is sent to the window with the keyboard focus when * a WM_SYSCHAR message is translated by the TranslateMessage function. @@ -972,17 +973,17 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, * maximize, minimize or close the window are triggered. Also it is sent when ALT * button is press for menu. To prevent this we must return preventing DefWindowProc. */ - if(wParam==SC_KEYMENU) return 0; + if (wParam == SC_KEYMENU) return 0; break; //////////////////////////////////////////////////////////////////////// // Tablet events, processed //////////////////////////////////////////////////////////////////////// case WT_PACKET: - ((GHOST_WindowWin32*)window)->processWin32TabletEvent(wParam, lParam); + ((GHOST_WindowWin32 *)window)->processWin32TabletEvent(wParam, lParam); break; case WT_CSRCHANGE: case WT_PROXIMITY: - ((GHOST_WindowWin32*)window)->processWin32TabletInitEvent(); + ((GHOST_WindowWin32 *)window)->processWin32TabletInitEvent(); break; //////////////////////////////////////////////////////////////////////// // Mouse events, processed @@ -1001,9 +1002,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, break; case WM_XBUTTONDOWN: window->registerMouseClickEvent(0); - if ((short) HIWORD(wParam) == XBUTTON1){ + if ((short) HIWORD(wParam) == XBUTTON1) { event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskButton4); - }else if((short) HIWORD(wParam) == XBUTTON2){ + } + else if ((short) HIWORD(wParam) == XBUTTON2) { event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskButton5); } break; @@ -1021,9 +1023,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, break; case WM_XBUTTONUP: window->registerMouseClickEvent(1); - if ((short) HIWORD(wParam) == XBUTTON1){ + if ((short) HIWORD(wParam) == XBUTTON1) { event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskButton4); - }else if((short) HIWORD(wParam) == XBUTTON2){ + } + else if ((short) HIWORD(wParam) == XBUTTON2) { event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskButton5); } break; @@ -1063,10 +1066,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, // Mouse events, ignored //////////////////////////////////////////////////////////////////////// case WM_NCMOUSEMOVE: - /* The WM_NCMOUSEMOVE message is posted to a window when the cursor is moved - * within the nonclient area of the window. This message is posted to the window - * that contains the cursor. If a window has captured the mouse, this message is not posted. - */ + /* The WM_NCMOUSEMOVE message is posted to a window when the cursor is moved + * within the nonclient area of the window. This message is posted to the window + * that contains the cursor. If a window has captured the mouse, this message is not posted. + */ case WM_NCHITTEST: /* The WM_NCHITTEST message is sent to a window when the cursor moves, or * when a mouse button is pressed or released. If the mouse is not captured, @@ -1089,16 +1092,16 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, * procedure of the top-level window being activated. If the windows use different input queues, * the message is sent asynchronously, so the window is activated immediately. */ - { + { GHOST_ModifierKeys modifiers; modifiers.clear(); system->storeModifierKeys(modifiers); event = processWindowEvent(LOWORD(wParam) ? GHOST_kEventWindowActivate : GHOST_kEventWindowDeactivate, window); /* WARNING: Let DefWindowProc handle WM_ACTIVATE, otherwise WM_MOUSEWHEEL - will not be dispatched to OUR active window if we minimize one of OUR windows. */ + will not be dispatched to OUR active window if we minimize one of OUR windows. */ lResult = ::DefWindowProc(hwnd, msg, wParam, lParam); break; - } + } case WM_PAINT: /* An application sends the WM_PAINT message when the system or another application * makes a request to paint a portion of an application's window. The message is sent @@ -1131,10 +1134,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, window->lostMouseCapture(); break; case WM_MOVING: - /* The WM_MOVING message is sent to a window that the user is moving. By processing - * this message, an application can monitor the size and position of the drag rectangle - * and, if needed, change its size or position. - */ + /* The WM_MOVING message is sent to a window that the user is moving. By processing + * this message, an application can monitor the size and position of the drag rectangle + * and, if needed, change its size or position. + */ case WM_MOVE: /* The WM_SIZE and WM_MOVE messages are not sent if an application handles the * WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient @@ -1147,32 +1150,32 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, // Window events, ignored //////////////////////////////////////////////////////////////////////// case WM_WINDOWPOSCHANGED: - /* The WM_WINDOWPOSCHANGED message is sent to a window whose size, position, or place - * in the Z order has changed as a result of a call to the SetWindowPos function or - * another window-management function. - * The WM_SIZE and WM_MOVE messages are not sent if an application handles the - * WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient - * to perform any move or size change processing during the WM_WINDOWPOSCHANGED - * message without calling DefWindowProc. - */ + /* The WM_WINDOWPOSCHANGED message is sent to a window whose size, position, or place + * in the Z order has changed as a result of a call to the SetWindowPos function or + * another window-management function. + * The WM_SIZE and WM_MOVE messages are not sent if an application handles the + * WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient + * to perform any move or size change processing during the WM_WINDOWPOSCHANGED + * message without calling DefWindowProc. + */ case WM_ERASEBKGND: - /* An application sends the WM_ERASEBKGND message when the window background must be - * erased (for example, when a window is resized). The message is sent to prepare an - * invalidated portion of a window for painting. - */ + /* An application sends the WM_ERASEBKGND message when the window background must be + * erased (for example, when a window is resized). The message is sent to prepare an + * invalidated portion of a window for painting. + */ case WM_NCPAINT: - /* An application sends the WM_NCPAINT message to a window when its frame must be painted. */ + /* An application sends the WM_NCPAINT message to a window when its frame must be painted. */ case WM_NCACTIVATE: - /* The WM_NCACTIVATE message is sent to a window when its nonclient area needs to be changed - * to indicate an active or inactive state. - */ + /* The WM_NCACTIVATE message is sent to a window when its nonclient area needs to be changed + * to indicate an active or inactive state. + */ case WM_DESTROY: - /* The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window - * procedure of the window being destroyed after the window is removed from the screen. - * This message is sent first to the window being destroyed and then to the child windows - * (if any) as they are destroyed. During the processing of the message, it can be assumed - * that all child windows still exist. - */ + /* The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window + * procedure of the window being destroyed after the window is removed from the screen. + * This message is sent first to the window being destroyed and then to the child windows + * (if any) as they are destroyed. During the processing of the message, it can be assumed + * that all child windows still exist. + */ case WM_NCDESTROY: /* The WM_NCDESTROY message informs a window that its nonclient area is being destroyed. The * DestroyWindow function sends the WM_NCDESTROY message to the window following the WM_DESTROY @@ -1182,17 +1185,17 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_KILLFOCUS: /* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus. * We want to prevent this if a window is still active and it loses focus to nowhere*/ - if(!wParam && hwnd==GetActiveWindow()) + if (!wParam && hwnd == GetActiveWindow()) SetFocus(hwnd); case WM_SHOWWINDOW: - /* The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown. */ + /* The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown. */ case WM_WINDOWPOSCHANGING: - /* The WM_WINDOWPOSCHANGING message is sent to a window whose size, position, or place in - * the Z order is about to change as a result of a call to the SetWindowPos function or - * another window-management function. - */ + /* The WM_WINDOWPOSCHANGING message is sent to a window whose size, position, or place in + * the Z order is about to change as a result of a call to the SetWindowPos function or + * another window-management function. + */ case WM_SETFOCUS: - /* The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus. */ + /* The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus. */ case WM_ENTERSIZEMOVE: /* The WM_ENTERSIZEMOVE message is sent one time to a window after it enters the moving * or sizing modal loop. The window enters the moving or sizing modal loop when the user @@ -1202,19 +1205,19 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, * DefWindowProc returns. */ break; - //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// // Other events //////////////////////////////////////////////////////////////////////// case WM_GETTEXT: - /* An application sends a WM_GETTEXT message to copy the text that - * corresponds to a window into a buffer provided by the caller. - */ + /* An application sends a WM_GETTEXT message to copy the text that + * corresponds to a window into a buffer provided by the caller. + */ case WM_ACTIVATEAPP: - /* The WM_ACTIVATEAPP message is sent when a window belonging to a - * different application than the active window is about to be activated. - * The message is sent to the application whose window is being activated - * and to the application whose window is being deactivated. - */ + /* The WM_ACTIVATEAPP message is sent when a window belonging to a + * different application than the active window is about to be activated. + * The message is sent to the application whose window is being activated + * and to the application whose window is being deactivated. + */ case WM_TIMER: /* The WIN32 docs say: * The WM_TIMER message is posted to the installing thread's message queue @@ -1237,7 +1240,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, WM_NCCALCSIZE 0x83 WM_CREATE 0x01 We let DefWindowProc do the work. - */ + */ } } else { @@ -1256,66 +1259,68 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, return lResult; } -GHOST_TUns8* GHOST_SystemWin32::getClipboard(bool selection) const +GHOST_TUns8 *GHOST_SystemWin32::getClipboard(bool selection) const { char *temp_buff; - if ( IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL) ) { + if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL) ) { wchar_t *buffer; - HANDLE hData = GetClipboardData( CF_UNICODETEXT ); + HANDLE hData = GetClipboardData(CF_UNICODETEXT); if (hData == NULL) { CloseClipboard(); return NULL; } - buffer = (wchar_t*)GlobalLock( hData ); + buffer = (wchar_t *)GlobalLock(hData); if (!buffer) { CloseClipboard(); return NULL; } - temp_buff = alloc_utf_8_from_16(buffer,0); + temp_buff = alloc_utf_8_from_16(buffer, 0); /* Buffer mustn't be accessed after CloseClipboard it would like accessing free-d memory */ - GlobalUnlock( hData ); + GlobalUnlock(hData); CloseClipboard(); - return (GHOST_TUns8*)temp_buff; - } else if ( IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL) ) { + return (GHOST_TUns8 *)temp_buff; + } + else if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL) ) { char *buffer; size_t len = 0; - HANDLE hData = GetClipboardData( CF_TEXT ); + HANDLE hData = GetClipboardData(CF_TEXT); if (hData == NULL) { CloseClipboard(); return NULL; } - buffer = (char*)GlobalLock( hData ); + buffer = (char *)GlobalLock(hData); if (!buffer) { CloseClipboard(); return NULL; } len = strlen(buffer); - temp_buff = (char*) malloc(len+1); + temp_buff = (char *) malloc(len + 1); strncpy(temp_buff, buffer, len); temp_buff[len] = '\0'; /* Buffer mustn't be accessed after CloseClipboard it would like accessing free-d memory */ - GlobalUnlock( hData ); + GlobalUnlock(hData); CloseClipboard(); - return (GHOST_TUns8*)temp_buff; - } else { + return (GHOST_TUns8 *)temp_buff; + } + else { return NULL; } } void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const { - if(selection) {return;} // for copying the selection, used on X11 + if (selection) {return; } // for copying the selection, used on X11 - if(OpenClipboard(NULL)) { + if (OpenClipboard(NULL)) { HLOCAL clipbuffer; wchar_t *data; @@ -1323,65 +1328,66 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const size_t len = count_utf_16_from_8(buffer); EmptyClipboard(); - clipbuffer = LocalAlloc(LMEM_FIXED,sizeof(wchar_t) * len); - data = (wchar_t*)GlobalLock(clipbuffer); + clipbuffer = LocalAlloc(LMEM_FIXED, sizeof(wchar_t) * len); + data = (wchar_t *)GlobalLock(clipbuffer); conv_utf_8_to_16(buffer, data, len); LocalUnlock(clipbuffer); - SetClipboardData(CF_UNICODETEXT,clipbuffer); + SetClipboardData(CF_UNICODETEXT, clipbuffer); } CloseClipboard(); - } else { + } + else { return; } } int GHOST_SystemWin32::toggleConsole(int action) { - switch(action) + switch (action) { case 3: //hide if no console - { - DWORD sp = GetCurrentProcessId(); - HANDLE ptree = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - PROCESSENTRY32 e = {0}; e.dwSize = sizeof(PROCESSENTRY32); - - if( Process32First(ptree, &e)) { - do { //Searches for Blender's PROCESSENTRY32 + { + DWORD sp = GetCurrentProcessId(); + HANDLE ptree = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + PROCESSENTRY32 e = {0}; e.dwSize = sizeof(PROCESSENTRY32); + + if (Process32First(ptree, &e)) { + do { //Searches for Blender's PROCESSENTRY32 + if (e.th32ProcessID == sp) { + sp = e.th32ParentProcessID; + Process32First(ptree, &e); + do { //Got parent id, searches for its PROCESSENTRY32 if (e.th32ProcessID == sp) { - sp = e.th32ParentProcessID; - Process32First(ptree, &e); - do { //Got parent id, searches for its PROCESSENTRY32 - if (e.th32ProcessID == sp) { - if(strcmp("explorer.exe",e.szExeFile)==0) - { //If explorer, hide cmd - ShowWindow(GetConsoleWindow(),SW_HIDE); - m_consoleStatus = 0; - } - break; - } - - } while( Process32Next(ptree, &e)); + if (strcmp("explorer.exe", e.szExeFile) == 0) + { //If explorer, hide cmd + ShowWindow(GetConsoleWindow(), SW_HIDE); + m_consoleStatus = 0; + } break; } - } while( Process32Next(ptree, &e)); - } - CloseHandle(ptree); - break; + } while (Process32Next(ptree, &e)); + break; + } + } while (Process32Next(ptree, &e)); } + + CloseHandle(ptree); + break; + } case 0: //hide - ShowWindow(GetConsoleWindow(),SW_HIDE); + ShowWindow(GetConsoleWindow(), SW_HIDE); m_consoleStatus = 0; break; case 1: //show - ShowWindow(GetConsoleWindow(),SW_SHOW); + ShowWindow(GetConsoleWindow(), SW_SHOW); m_consoleStatus = 1; break; case 2: //toggle - ShowWindow(GetConsoleWindow(),m_consoleStatus?SW_HIDE:SW_SHOW); - m_consoleStatus=!m_consoleStatus; + ShowWindow(GetConsoleWindow(), m_consoleStatus ? SW_HIDE : SW_SHOW); + m_consoleStatus = !m_consoleStatus; break; }; @@ -1390,8 +1396,8 @@ int GHOST_SystemWin32::toggleConsole(int action) return m_consoleStatus; } -int GHOST_SystemWin32::confirmQuit(GHOST_IWindow * window) const +int GHOST_SystemWin32::confirmQuit(GHOST_IWindow *window) const { - return (MessageBox(window ? ((GHOST_WindowWin32*)window)->getHWND() : 0, "Some changes have not been saved.\nDo you really want to quit ?", - "Exit Blender", MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST) == IDOK); + return (MessageBox(window ? ((GHOST_WindowWin32 *)window)->getHWND() : 0, "Some changes have not been saved.\nDo you really want to quit ?", + "Exit Blender", MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST) == IDOK); } diff --git a/intern/ghost/intern/GHOST_TimerManager.cpp b/intern/ghost/intern/GHOST_TimerManager.cpp index 19cfe61a260..4780a4a0d44 100644 --- a/intern/ghost/intern/GHOST_TimerManager.cpp +++ b/intern/ghost/intern/GHOST_TimerManager.cpp @@ -61,14 +61,14 @@ GHOST_TUns32 GHOST_TimerManager::getNumTimers() } -bool GHOST_TimerManager::getTimerFound(GHOST_TimerTask* timer) +bool GHOST_TimerManager::getTimerFound(GHOST_TimerTask *timer) { TTimerVector::const_iterator iter = std::find(m_timers.begin(), m_timers.end(), timer); return iter != m_timers.end(); } -GHOST_TSuccess GHOST_TimerManager::addTimer(GHOST_TimerTask* timer) +GHOST_TSuccess GHOST_TimerManager::addTimer(GHOST_TimerTask *timer) { GHOST_TSuccess success; if (!getTimerFound(timer)) { @@ -83,7 +83,7 @@ GHOST_TSuccess GHOST_TimerManager::addTimer(GHOST_TimerTask* timer) } -GHOST_TSuccess GHOST_TimerManager::removeTimer(GHOST_TimerTask* timer) +GHOST_TSuccess GHOST_TimerManager::removeTimer(GHOST_TimerTask *timer) { GHOST_TSuccess success; TTimerVector::iterator iter = std::find(m_timers.begin(), m_timers.end(), timer); @@ -108,7 +108,7 @@ GHOST_TUns64 GHOST_TimerManager::nextFireTime() for (iter = m_timers.begin(); iter != m_timers.end(); iter++) { GHOST_TUns64 next = (*iter)->getNext(); - if (next<smallest) + if (next < smallest) smallest = next; } @@ -129,7 +129,7 @@ bool GHOST_TimerManager::fireTimers(GHOST_TUns64 time) } -bool GHOST_TimerManager::fireTimer(GHOST_TUns64 time, GHOST_TimerTask* task) +bool GHOST_TimerManager::fireTimer(GHOST_TUns64 time, GHOST_TimerTask *task) { GHOST_TUns64 next = task->getNext(); @@ -148,7 +148,8 @@ bool GHOST_TimerManager::fireTimer(GHOST_TUns64 time, GHOST_TimerTask* task) task->setNext(next); return true; - } else { + } + else { return false; } } diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp index b560b04b5df..c3244d1594d 100644 --- a/intern/ghost/intern/GHOST_Window.cpp +++ b/intern/ghost/intern/GHOST_Window.cpp @@ -40,12 +40,12 @@ GHOST_Window::GHOST_Window( - GHOST_TUns32 width, GHOST_TUns32 height, - GHOST_TWindowState state, - GHOST_TDrawingContextType type, - const bool stereoVisual, - const GHOST_TUns16 numOfAASamples) -: + GHOST_TUns32 width, GHOST_TUns32 height, + GHOST_TWindowState state, + GHOST_TDrawingContextType type, + const bool stereoVisual, + const GHOST_TUns16 numOfAASamples) + : m_drawingContextType(type), m_cursorVisible(true), m_cursorGrab(GHOST_kGrabDisable), @@ -58,14 +58,14 @@ GHOST_Window::GHOST_Window( m_progressBarVisible = false; - m_cursorGrabAccumPos[0] = 0; - m_cursorGrabAccumPos[1] = 0; - - m_fullScreen = state == GHOST_kWindowStateFullScreen; - if (m_fullScreen) { - m_fullScreenWidth = width; - m_fullScreenHeight = height; - } + m_cursorGrabAccumPos[0] = 0; + m_cursorGrabAccumPos[1] = 0; + + m_fullScreen = state == GHOST_kWindowStateFullScreen; + if (m_fullScreen) { + m_fullScreenWidth = width; + m_fullScreenHeight = height; + } } @@ -73,7 +73,7 @@ GHOST_Window::~GHOST_Window() { } -void* GHOST_Window::getOSWindow() const +void *GHOST_Window::getOSWindow() const { return NULL; } @@ -107,16 +107,17 @@ GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible) GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_Rect *bounds) { - if(m_cursorGrab == mode) + if (m_cursorGrab == mode) return GHOST_kSuccess; if (setWindowCursorGrab(mode)) { - if(mode==GHOST_kGrabDisable) - m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; + if (mode == GHOST_kGrabDisable) + m_cursorGrabBounds.m_l = m_cursorGrabBounds.m_r = -1; else if (bounds) { - m_cursorGrabBounds= *bounds; - } else { /* if bounds not defined, use window */ + m_cursorGrabBounds = *bounds; + } + else { /* if bounds not defined, use window */ getClientBounds(m_cursorGrabBounds); } m_cursorGrab = mode; @@ -129,8 +130,8 @@ GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_Rec GHOST_TSuccess GHOST_Window::getCursorGrabBounds(GHOST_Rect& bounds) { - bounds= m_cursorGrabBounds; - return (bounds.m_l==-1 && bounds.m_r==-1) ? GHOST_kFailure : GHOST_kSuccess; + bounds = m_cursorGrabBounds; + return (bounds.m_l == -1 && bounds.m_r == -1) ? GHOST_kFailure : GHOST_kSuccess; } GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape) @@ -148,14 +149,14 @@ GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHO int hotX, int hotY) { return setCustomCursorShape((GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, - 16, 16, hotX, hotY, 0, 1 ); + 16, 16, hotX, hotY, 0, 1); } GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color) { - if (setWindowCustomCursorShape(bitmap, mask, sizex, sizey,hotX, hotY, fg_color, bg_color)) { + if (setWindowCustomCursorShape(bitmap, mask, sizex, sizey, hotX, hotY, fg_color, bg_color)) { m_cursorShape = GHOST_kStandardCursorCustom; return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp index ab7325fcef8..16e3cb49652 100644 --- a/intern/ghost/intern/GHOST_WindowCarbon.cpp +++ b/intern/ghost/intern/GHOST_WindowCarbon.cpp @@ -46,31 +46,31 @@ const GHOST_TInt32 GHOST_WindowCarbon::s_sizeRectSize = 16; #endif //GHOST_DRAW_CARBON_GUTTER static const GLint sPreferredFormatWindow[10] = { -AGL_RGBA, -AGL_DOUBLEBUFFER, -AGL_ACCELERATED, -AGL_DEPTH_SIZE, 32, -AGL_NONE, + AGL_RGBA, + AGL_DOUBLEBUFFER, + AGL_ACCELERATED, + AGL_DEPTH_SIZE, 32, + AGL_NONE, }; static const GLint sPreferredFormatFullScreen[11] = { -AGL_RGBA, -AGL_DOUBLEBUFFER, -AGL_ACCELERATED, -AGL_FULLSCREEN, -AGL_DEPTH_SIZE, 32, -AGL_NONE, + AGL_RGBA, + AGL_DOUBLEBUFFER, + AGL_ACCELERATED, + AGL_FULLSCREEN, + AGL_DEPTH_SIZE, 32, + AGL_NONE, }; -WindowRef ugly_hack=NULL; +WindowRef ugly_hack = NULL; -const EventTypeSpec kWEvents[] = { +const EventTypeSpec kWEvents[] = { { kEventClassWindow, kEventWindowZoom }, /* for new zoom behaviour */ }; -static OSStatus myWEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData) +static OSStatus myWEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData) { WindowRef mywindow; GHOST_WindowCarbon *ghost_window; @@ -78,7 +78,7 @@ static OSStatus myWEventHandlerProc(EventHandlerCallRef handler, EventRef event, int theState; if (::GetEventKind(event) == kEventWindowZoom) { - err = ::GetEventParameter (event,kEventParamDirectObject,typeWindowRef,NULL,sizeof(mywindow),NULL, &mywindow); + err = ::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(mywindow), NULL, &mywindow); ghost_window = (GHOST_WindowCarbon *) GetWRefCon(mywindow); theState = ghost_window->getMac_windowState(); if (theState == 1) @@ -91,16 +91,16 @@ static OSStatus myWEventHandlerProc(EventHandlerCallRef handler, EventRef event, } GHOST_WindowCarbon::GHOST_WindowCarbon( - 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, - const GHOST_TUns16 numOfAASamples -) : + 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, + const GHOST_TUns16 numOfAASamples + ) : GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone), m_windowRef(0), m_grafPtr(0), @@ -108,84 +108,87 @@ GHOST_WindowCarbon::GHOST_WindowCarbon( m_customCursor(0), m_fullScreenDirty(false) { - Str255 title255; + Str255 title255; OSStatus err; //fprintf(stderr," main screen top %i left %i height %i width %i\n", top, left, height, width); - if (state >= GHOST_kWindowState8Normal ) { - if(state == GHOST_kWindowState8Normal) state= GHOST_kWindowStateNormal; - else if(state == GHOST_kWindowState8Maximized) state= GHOST_kWindowStateMaximized; - else if(state == GHOST_kWindowState8Minimized) state= GHOST_kWindowStateMinimized; - else if(state == GHOST_kWindowState8FullScreen) state= GHOST_kWindowStateFullScreen; + if (state >= GHOST_kWindowState8Normal) { + if (state == GHOST_kWindowState8Normal) state = GHOST_kWindowStateNormal; + else if (state == GHOST_kWindowState8Maximized) state = GHOST_kWindowStateMaximized; + else if (state == GHOST_kWindowState8Minimized) state = GHOST_kWindowStateMinimized; + else if (state == GHOST_kWindowState8FullScreen) state = GHOST_kWindowStateFullScreen; // state = state - 8; this was the simple version of above code, doesnt work in gcc 4.0 setMac_windowState(1); - } else + } + else setMac_windowState(0); if (state != GHOST_kWindowStateFullScreen) { - Rect bnds = { top, left, top+height, left+width }; - // Boolean visible = (state == GHOST_kWindowStateNormal) || (state == GHOST_kWindowStateMaximized); /*unused*/ - gen2mac(title, title255); - - err = ::CreateNewWindow( kDocumentWindowClass, - kWindowStandardDocumentAttributes+kWindowLiveResizeAttribute, - &bnds, - &m_windowRef); - - if ( err != noErr) { - fprintf(stderr," error creating window %i \n",(int)err); - } else { + Rect bnds = { top, left, top + height, left + width }; + // Boolean visible = (state == GHOST_kWindowStateNormal) || (state == GHOST_kWindowStateMaximized); /*unused*/ + gen2mac(title, title255); + + err = ::CreateNewWindow(kDocumentWindowClass, + kWindowStandardDocumentAttributes + kWindowLiveResizeAttribute, + &bnds, + &m_windowRef); - ::SetWRefCon(m_windowRef,(SInt32)this); + if (err != noErr) { + fprintf(stderr, " error creating window %i \n", (int)err); + } + else { + + ::SetWRefCon(m_windowRef, (SInt32) this); setTitle(title); - err = InstallWindowEventHandler (m_windowRef, myWEventHandlerProc, GetEventTypeCount(kWEvents), kWEvents,NULL,NULL); - if ( err != noErr) { - fprintf(stderr," error creating handler %i \n",(int)err); - } else { + err = InstallWindowEventHandler(m_windowRef, myWEventHandlerProc, GetEventTypeCount(kWEvents), kWEvents, NULL, NULL); + if (err != noErr) { + fprintf(stderr, " error creating handler %i \n", (int)err); + } + else { // ::TransitionWindow (m_windowRef,kWindowZoomTransitionEffect,kWindowShowTransitionAction,NULL); ::ShowWindow(m_windowRef); - ::MoveWindow (m_windowRef, left, top,true); + ::MoveWindow(m_windowRef, left, top, true); } } - if (m_windowRef) { - m_grafPtr = ::GetWindowPort(m_windowRef); - setDrawingContextType(type); - updateDrawingContext(); - activateDrawingContext(); - } - if(ugly_hack==NULL) { - ugly_hack= m_windowRef; + if (m_windowRef) { + m_grafPtr = ::GetWindowPort(m_windowRef); + setDrawingContextType(type); + updateDrawingContext(); + activateDrawingContext(); + } + if (ugly_hack == NULL) { + ugly_hack = m_windowRef; // when started from commandline, window remains in the back... also for play anim ProcessSerialNumber psn; GetCurrentProcess(&psn); SetFrontProcess(&psn); } - } - else { - /* - Rect bnds = { top, left, top+height, left+width }; - gen2mac("", title255); - m_windowRef = ::NewCWindow( - nil, // Storage - &bnds, // Bounding rectangle of the window - title255, // Title of the window - 0, // Window initially visible - plainDBox, // procID - (WindowRef)-1L, // Put window before all other windows - 0, // Window has minimize box - (SInt32)this); // Store a pointer to the class in the refCon - */ - //GHOST_PRINT("GHOST_WindowCarbon::GHOST_WindowCarbon(): creating full-screen OpenGL context\n"); - setDrawingContextType(GHOST_kDrawingContextTypeOpenGL);;installDrawingContext(GHOST_kDrawingContextTypeOpenGL); - updateDrawingContext(); - activateDrawingContext(); - - m_tablet.Active = GHOST_kTabletModeNone; - } + } + else { +#if 0 + Rect bnds = { top, left, top + height, left + width }; + gen2mac("", title255); + m_windowRef = ::NewCWindow( + nil, // Storage + &bnds, // Bounding rectangle of the window + title255, // Title of the window + 0, // Window initially visible + plainDBox, // procID + (WindowRef) - 1L, // Put window before all other windows + 0, // Window has minimize box + (SInt32) this); // Store a pointer to the class in the refCon +#endif + //GHOST_PRINT("GHOST_WindowCarbon::GHOST_WindowCarbon(): creating full-screen OpenGL context\n"); + setDrawingContextType(GHOST_kDrawingContextTypeOpenGL);; installDrawingContext(GHOST_kDrawingContextTypeOpenGL); + updateDrawingContext(); + activateDrawingContext(); + + m_tablet.Active = GHOST_kTabletModeNone; + } } @@ -193,44 +196,44 @@ GHOST_WindowCarbon::~GHOST_WindowCarbon() { if (m_customCursor) delete m_customCursor; - if(ugly_hack==m_windowRef) ugly_hack= NULL; + if (ugly_hack == m_windowRef) ugly_hack = NULL; // printf("GHOST_WindowCarbon::~GHOST_WindowCarbon(): removing drawing context\n"); - if(ugly_hack==NULL) setDrawingContextType(GHOST_kDrawingContextTypeNone); - if (m_windowRef) { - ::DisposeWindow(m_windowRef); + if (ugly_hack == NULL) setDrawingContextType(GHOST_kDrawingContextTypeNone); + if (m_windowRef) { + ::DisposeWindow(m_windowRef); m_windowRef = 0; } } bool GHOST_WindowCarbon::getValid() const { - bool valid; - if (!m_fullScreen) { - valid = (m_windowRef != 0) && (m_grafPtr != 0) && ::IsValidWindowPtr(m_windowRef); - } - else { - valid = true; - } - return valid; + bool valid; + if (!m_fullScreen) { + valid = (m_windowRef != 0) && (m_grafPtr != 0) && ::IsValidWindowPtr(m_windowRef); + } + else { + valid = true; + } + return valid; } void GHOST_WindowCarbon::setTitle(const STR_String& title) { - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setTitle(): window invalid") - Str255 title255; - gen2mac(title, title255); + GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setTitle(): window invalid") + Str255 title255; + gen2mac(title, title255); ::SetWTitle(m_windowRef, title255); } void GHOST_WindowCarbon::getTitle(STR_String& title) const { - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getTitle(): window invalid") - Str255 title255; - ::GetWTitle(m_windowRef, title255); - mac2gen(title255, title); + GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getTitle(): window invalid") + Str255 title255; + ::GetWTitle(m_windowRef, title255); + mac2gen(title255, title); } @@ -265,8 +268,7 @@ void GHOST_WindowCarbon::getClientBounds(GHOST_Rect& bounds) const { bounds.m_b -= s_sizeRectSize; } - else - { + else { bounds.m_t = bounds.m_b; } #endif //GHOST_DRAW_CARBON_GUTTER @@ -291,8 +293,8 @@ GHOST_TSuccess GHOST_WindowCarbon::setClientHeight(GHOST_TUns32 height) GHOST_Rect cBnds, wBnds; getClientBounds(cBnds); #ifdef GHOST_DRAW_CARBON_GUTTER - if (((GHOST_TUns32)cBnds.getHeight()) != height+s_sizeRectSize) { - ::SizeWindow(m_windowRef, cBnds.getWidth(), height+s_sizeRectSize, true); + if (((GHOST_TUns32)cBnds.getHeight()) != height + s_sizeRectSize) { + ::SizeWindow(m_windowRef, cBnds.getWidth(), height + s_sizeRectSize, true); } #else //GHOST_DRAW_CARBON_GUTTER if (((GHOST_TUns32)cBnds.getHeight()) != height) { @@ -310,8 +312,9 @@ GHOST_TSuccess GHOST_WindowCarbon::setClientSize(GHOST_TUns32 width, GHOST_TUns3 getClientBounds(cBnds); #ifdef GHOST_DRAW_CARBON_GUTTER if ((((GHOST_TUns32)cBnds.getWidth()) != width) || - (((GHOST_TUns32)cBnds.getHeight()) != height+s_sizeRectSize)) { - ::SizeWindow(m_windowRef, width, height+s_sizeRectSize, true); + (((GHOST_TUns32)cBnds.getHeight()) != height + s_sizeRectSize)) + { + ::SizeWindow(m_windowRef, width, height + s_sizeRectSize, true); } #else //GHOST_DRAW_CARBON_GUTTER if ((((GHOST_TUns32)cBnds.getWidth()) != width) || @@ -346,11 +349,11 @@ void GHOST_WindowCarbon::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOS Point point; point.h = inX; point.v = inY; - GrafPtr oldPort; - ::GetPort(&oldPort); - ::SetPort(m_grafPtr); + GrafPtr oldPort; + ::GetPort(&oldPort); + ::SetPort(m_grafPtr); ::GlobalToLocal(&point); - ::SetPort(oldPort); + ::SetPort(oldPort); outX = point.h; outY = point.v; } @@ -362,11 +365,11 @@ void GHOST_WindowCarbon::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOS Point point; point.h = inX; point.v = inY; - GrafPtr oldPort; - ::GetPort(&oldPort); - ::SetPort(m_grafPtr); + GrafPtr oldPort; + ::GetPort(&oldPort); + ::SetPort(m_grafPtr); ::LocalToGlobal(&point); - ::SetPort(oldPort); + ::SetPort(oldPort); outX = point.h; outY = point.v; } @@ -375,38 +378,38 @@ void GHOST_WindowCarbon::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOS GHOST_TSuccess GHOST_WindowCarbon::setState(GHOST_TWindowState state) { GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setState(): window invalid") - switch (state) { - case GHOST_kWindowStateMinimized: - ::HideWindow(m_windowRef); - break; - case GHOST_kWindowStateModified: - SetWindowModified(m_windowRef, 1); - break; - case GHOST_kWindowStateUnModified: - SetWindowModified(m_windowRef, 0); - break; - case GHOST_kWindowStateMaximized: - case GHOST_kWindowStateNormal: - default: - ::ShowWindow(m_windowRef); - break; - } - return GHOST_kSuccess; + switch (state) { + case GHOST_kWindowStateMinimized: + ::HideWindow(m_windowRef); + break; + case GHOST_kWindowStateModified: + SetWindowModified(m_windowRef, 1); + break; + case GHOST_kWindowStateUnModified: + SetWindowModified(m_windowRef, 0); + break; + case GHOST_kWindowStateMaximized: + case GHOST_kWindowStateNormal: + default: + ::ShowWindow(m_windowRef); + break; + } + return GHOST_kSuccess; } GHOST_TSuccess GHOST_WindowCarbon::setOrder(GHOST_TWindowOrder order) { GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setOrder(): window invalid") - if (order == GHOST_kWindowOrderTop) { - //::BringToFront(m_windowRef); is wrong, front window should be active for input too + if (order == GHOST_kWindowOrderTop) { + //::BringToFront(m_windowRef); is wrong, front window should be active for input too ::SelectWindow(m_windowRef); - } - else { + } + else { /* doesnt work if you do this with a mouseclick */ - ::SendBehind(m_windowRef, nil); - } - return GHOST_kSuccess; + ::SendBehind(m_windowRef, nil); + } + return GHOST_kSuccess; } /*#define WAIT_FOR_VSYNC 1*/ @@ -418,20 +421,20 @@ GHOST_TSuccess GHOST_WindowCarbon::swapBuffers() { #ifdef WAIT_FOR_VSYNC /* wait for vsync, to avoid tearing artifacts */ -long VBL = 1; -CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL); + long VBL = 1; + CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL); #endif - GHOST_TSuccess succeeded = GHOST_kSuccess; - if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) { - if (m_aglCtx) { - ::aglSwapBuffers(m_aglCtx); - } - else { - succeeded = GHOST_kFailure; - } - } - return succeeded; + GHOST_TSuccess succeeded = GHOST_kSuccess; + if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) { + if (m_aglCtx) { + ::aglSwapBuffers(m_aglCtx); + } + else { + succeeded = GHOST_kFailure; + } + } + return succeeded; } GHOST_TSuccess GHOST_WindowCarbon::updateDrawingContext() @@ -462,9 +465,9 @@ GHOST_TSuccess GHOST_WindowCarbon::activateDrawingContext() GLint b[4] = { bnds.m_l, - bnds.m_t+s_sizeRectSize, - bnds.m_r-bnds.m_l, - bnds.m_b-bnds.m_t + bnds.m_t + s_sizeRectSize, + bnds.m_r - bnds.m_l, + bnds.m_b - bnds.m_t }; GLboolean result = ::aglSetInteger(m_aglCtx, AGL_BUFFER_RECT, b); #endif //GHOST_DRAW_CARBON_GUTTER @@ -482,38 +485,38 @@ GHOST_TSuccess GHOST_WindowCarbon::installDrawingContext(GHOST_TDrawingContextTy GHOST_TSuccess success = GHOST_kFailure; switch (type) { case GHOST_kDrawingContextTypeOpenGL: - { + { if (!getValid()) break; - - AGLPixelFormat pixelFormat; - if (!m_fullScreen) { - pixelFormat = ::aglChoosePixelFormat(0, 0, sPreferredFormatWindow); - m_aglCtx = ::aglCreateContext(pixelFormat, s_firstaglCtx); - if (!m_aglCtx) break; + + AGLPixelFormat pixelFormat; + if (!m_fullScreen) { + pixelFormat = ::aglChoosePixelFormat(0, 0, sPreferredFormatWindow); + m_aglCtx = ::aglCreateContext(pixelFormat, s_firstaglCtx); + if (!m_aglCtx) break; if (!s_firstaglCtx) s_firstaglCtx = m_aglCtx; - success = ::aglSetDrawable(m_aglCtx, m_grafPtr) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure; - } - else { - //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL\n"); -GDHandle device=::GetMainDevice();pixelFormat=::aglChoosePixelFormat(&device,1,sPreferredFormatFullScreen); - m_aglCtx = ::aglCreateContext(pixelFormat, 0); - if (!m_aglCtx) break; + success = ::aglSetDrawable(m_aglCtx, m_grafPtr) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL\n"); + GDHandle device = ::GetMainDevice(); pixelFormat = ::aglChoosePixelFormat(&device, 1, sPreferredFormatFullScreen); + m_aglCtx = ::aglCreateContext(pixelFormat, 0); + if (!m_aglCtx) break; if (!s_firstaglCtx) s_firstaglCtx = m_aglCtx; - //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): created OpenGL context\n"); - //::CGGetActiveDisplayList(0, NULL, &m_numDisplays) - success = ::aglSetFullScreen(m_aglCtx, m_fullScreenWidth, m_fullScreenHeight, 75, 0) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure; - /* - if (success == GHOST_kSuccess) { - GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL succeeded\n"); - } - else { - GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL failed\n"); - } - */ - } - ::aglDestroyPixelFormat(pixelFormat); + //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): created OpenGL context\n"); + //::CGGetActiveDisplayList(0, NULL, &m_numDisplays) + success = ::aglSetFullScreen(m_aglCtx, m_fullScreenWidth, m_fullScreenHeight, 75, 0) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure; +#if 0 + if (success == GHOST_kSuccess) { + GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL succeeded\n"); + } + else { + GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL failed\n"); + } +#endif } - break; + ::aglDestroyPixelFormat(pixelFormat); + } + break; case GHOST_kDrawingContextTypeNone: success = GHOST_kSuccess; @@ -532,9 +535,9 @@ GHOST_TSuccess GHOST_WindowCarbon::removeDrawingContext() switch (m_drawingContextType) { case GHOST_kDrawingContextTypeOpenGL: if (m_aglCtx) { - aglSetCurrentContext(NULL); - aglSetDrawable(m_aglCtx, NULL); - //aglDestroyContext(m_aglCtx); + aglSetCurrentContext(NULL); + aglSetDrawable(m_aglCtx, NULL); + //aglDestroyContext(m_aglCtx); if (s_firstaglCtx == m_aglCtx) s_firstaglCtx = NULL; success = ::aglDestroyContext(m_aglCtx) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure; m_aglCtx = 0; @@ -553,22 +556,22 @@ GHOST_TSuccess GHOST_WindowCarbon::removeDrawingContext() GHOST_TSuccess GHOST_WindowCarbon::invalidate() { GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::invalidate(): window invalid") - if (!m_fullScreen) { - Rect rect; - ::GetPortBounds(m_grafPtr, &rect); - ::InvalWindowRect(m_windowRef, &rect); - } - else { - //EventRef event; - //OSStatus status = ::CreateEvent(NULL, kEventClassWindow, kEventWindowUpdate, 0, 0, &event); - //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): created event " << status << " \n"); - //status = ::SetEventParameter(event, kEventParamDirectObject, typeWindowRef, sizeof(WindowRef), this); - //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): set event parameter " << status << " \n"); - //status = ::PostEventToQueue(::GetMainEventQueue(), event, kEventPriorityStandard); - //status = ::SendEventToEventTarget(event, ::GetApplicationEventTarget()); - //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): added event to queue " << status << " \n"); - m_fullScreenDirty = true; - } + if (!m_fullScreen) { + Rect rect; + ::GetPortBounds(m_grafPtr, &rect); + ::InvalWindowRect(m_windowRef, &rect); + } + else { + //EventRef event; + //OSStatus status = ::CreateEvent(NULL, kEventClassWindow, kEventWindowUpdate, 0, 0, &event); + //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): created event " << status << " \n"); + //status = ::SetEventParameter(event, kEventParamDirectObject, typeWindowRef, sizeof(WindowRef), this); + //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): set event parameter " << status << " \n"); + //status = ::PostEventToQueue(::GetMainEventQueue(), event, kEventPriorityStandard); + //status = ::SendEventToEventTarget(event, ::GetApplicationEventTarget()); + //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): added event to queue " << status << " \n"); + m_fullScreenDirty = true; + } return GHOST_kSuccess; } @@ -578,7 +581,7 @@ void GHOST_WindowCarbon::gen2mac(const STR_String& in, Str255 out) const STR_String tempStr = in; int num = tempStr.Length(); if (num > 255) num = 255; - ::memcpy(out+1, tempStr.Ptr(), num); + ::memcpy(out + 1, tempStr.Ptr(), num); out[0] = num; } @@ -586,7 +589,7 @@ void GHOST_WindowCarbon::gen2mac(const STR_String& in, Str255 out) const void GHOST_WindowCarbon::mac2gen(const Str255 in, STR_String& out) const { char tmp[256]; - ::memcpy(tmp, in+1, in[0]); + ::memcpy(tmp, in + 1, in[0]); tmp[in[0]] = '\0'; out = tmp; } @@ -607,35 +610,36 @@ void GHOST_WindowCarbon::loadCursor(bool visible, GHOST_TStandardCursor cursor) } if (cursor == GHOST_kStandardCursorCustom && m_customCursor) { - ::SetCursor( m_customCursor ); - } else { + ::SetCursor(m_customCursor); + } + else { int carbon_cursor; -#define GCMAP(ghostCursor, carbonCursor) case ghostCursor: carbon_cursor = carbonCursor; break +#define GCMAP(ghostCursor, carbonCursor) case ghostCursor: carbon_cursor = carbonCursor; break switch (cursor) { - default: - GCMAP( GHOST_kStandardCursorDefault, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorRightArrow, kThemeAliasArrowCursor); - GCMAP( GHOST_kStandardCursorLeftArrow, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorInfo, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorDestroy, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorHelp, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorCycle, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorSpray, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorWait, kThemeWatchCursor); - GCMAP( GHOST_kStandardCursorText, kThemeIBeamCursor); - GCMAP( GHOST_kStandardCursorCrosshair, kThemeCrossCursor); - GCMAP( GHOST_kStandardCursorUpDown, kThemeClosedHandCursor); - GCMAP( GHOST_kStandardCursorLeftRight, kThemeClosedHandCursor); - GCMAP( GHOST_kStandardCursorTopSide, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorBottomSide, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorLeftSide, kThemeResizeLeftCursor); - GCMAP( GHOST_kStandardCursorRightSide, kThemeResizeRightCursor); - GCMAP( GHOST_kStandardCursorTopLeftCorner, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorTopRightCorner, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorBottomRightCorner, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorBottomLeftCorner, kThemeArrowCursor); - GCMAP( GHOST_kStandardCursorCopy, kThemeCopyArrowCursor); + default: + GCMAP(GHOST_kStandardCursorDefault, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorRightArrow, kThemeAliasArrowCursor); + GCMAP(GHOST_kStandardCursorLeftArrow, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorInfo, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorDestroy, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorHelp, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorCycle, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorSpray, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorWait, kThemeWatchCursor); + GCMAP(GHOST_kStandardCursorText, kThemeIBeamCursor); + GCMAP(GHOST_kStandardCursorCrosshair, kThemeCrossCursor); + GCMAP(GHOST_kStandardCursorUpDown, kThemeClosedHandCursor); + GCMAP(GHOST_kStandardCursorLeftRight, kThemeClosedHandCursor); + GCMAP(GHOST_kStandardCursorTopSide, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorBottomSide, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorLeftSide, kThemeResizeLeftCursor); + GCMAP(GHOST_kStandardCursorRightSide, kThemeResizeRightCursor); + GCMAP(GHOST_kStandardCursorTopLeftCorner, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorTopRightCorner, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorBottomRightCorner, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorBottomLeftCorner, kThemeArrowCursor); + GCMAP(GHOST_kStandardCursorCopy, kThemeCopyArrowCursor); }; #undef GCMAP @@ -646,7 +650,7 @@ void GHOST_WindowCarbon::loadCursor(bool visible, GHOST_TStandardCursor cursor) bool GHOST_WindowCarbon::getFullScreenDirty() { - return m_fullScreen && m_fullScreenDirty; + return m_fullScreen && m_fullScreenDirty; } @@ -677,9 +681,9 @@ GHOST_TSuccess GHOST_WindowCarbon::setWindowCursorShape(GHOST_TStandardCursor sh /** Reverse the bits in a GHOST_TUns8 */ static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch) { - ch= ((ch>>1)&0x55) | ((ch<<1)&0xAA); - ch= ((ch>>2)&0x33) | ((ch<<2)&0xCC); - ch= ((ch>>4)&0x0F) | ((ch<<4)&0xF0); + ch = ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA); + ch = ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC); + ch = ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0); return ch; } #endif @@ -688,15 +692,15 @@ static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch) /** Reverse the bits in a GHOST_TUns16 */ static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt) { - shrt= ((shrt>>1)&0x5555) | ((shrt<<1)&0xAAAA); - shrt= ((shrt>>2)&0x3333) | ((shrt<<2)&0xCCCC); - shrt= ((shrt>>4)&0x0F0F) | ((shrt<<4)&0xF0F0); - shrt= ((shrt>>8)&0x00FF) | ((shrt<<8)&0xFF00); + shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA); + shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC); + shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0); + shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00); return shrt; } GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, - int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color) + int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color) { int y; @@ -708,13 +712,13 @@ GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 *bitma m_customCursor = new Cursor; if (!m_customCursor) return GHOST_kFailure; - for (y=0; y<16; y++) { + for (y = 0; y < 16; y++) { #if !defined(__LITTLE_ENDIAN__) - m_customCursor->data[y] = uns16ReverseBits((bitmap[2*y]<<0) | (bitmap[2*y+1]<<8)); - m_customCursor->mask[y] = uns16ReverseBits((mask[2*y]<<0) | (mask[2*y+1]<<8)); + m_customCursor->data[y] = uns16ReverseBits((bitmap[2 * y] << 0) | (bitmap[2 * y + 1] << 8)); + m_customCursor->mask[y] = uns16ReverseBits((mask[2 * y] << 0) | (mask[2 * y + 1] << 8)); #else - m_customCursor->data[y] = uns16ReverseBits((bitmap[2*y+1]<<0) | (bitmap[2*y]<<8)); - m_customCursor->mask[y] = uns16ReverseBits((mask[2*y+1]<<0) | (mask[2*y]<<8)); + m_customCursor->data[y] = uns16ReverseBits((bitmap[2 * y + 1] << 0) | (bitmap[2 * y] << 8)); + m_customCursor->mask[y] = uns16ReverseBits((mask[2 * y + 1] << 0) | (mask[2 * y] << 8)); #endif } @@ -730,9 +734,9 @@ GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 *bitma } GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], - GHOST_TUns8 mask[16][2], int hotX, int hotY) + GHOST_TUns8 mask[16][2], int hotX, int hotY) { - return setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*) mask, 16, 16, hotX, hotY, 0, 1); + return setWindowCustomCursorShape((GHOST_TUns8 *)bitmap, (GHOST_TUns8 *) mask, 16, 16, hotX, hotY, 0, 1); } diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index fbb474cb20a..b7d14873e7b 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -1441,7 +1441,7 @@ static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt) } GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, - int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color) + int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color) { int y,nbUns16; NSPoint hotSpotPoint; @@ -1509,7 +1509,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 *bitmap } GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], - GHOST_TUns8 mask[16][2], int hotX, int hotY) + GHOST_TUns8 mask[16][2], int hotX, int hotY) { return setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*) mask, 16, 16, hotX, hotY, 0, 1); } diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp index cf236283b0f..a6211b42fe6 100644 --- a/intern/ghost/intern/GHOST_WindowManager.cpp +++ b/intern/ghost/intern/GHOST_WindowManager.cpp @@ -57,7 +57,7 @@ GHOST_WindowManager::~GHOST_WindowManager() } -GHOST_TSuccess GHOST_WindowManager::addWindow(GHOST_IWindow* window) +GHOST_TSuccess GHOST_WindowManager::addWindow(GHOST_IWindow *window) { GHOST_TSuccess success = GHOST_kFailure; if (window) { @@ -71,7 +71,7 @@ GHOST_TSuccess GHOST_WindowManager::addWindow(GHOST_IWindow* window) } -GHOST_TSuccess GHOST_WindowManager::removeWindow(const GHOST_IWindow* window) +GHOST_TSuccess GHOST_WindowManager::removeWindow(const GHOST_IWindow *window) { GHOST_TSuccess success = GHOST_kFailure; if (window) { @@ -79,7 +79,7 @@ GHOST_TSuccess GHOST_WindowManager::removeWindow(const GHOST_IWindow* window) endFullScreen(); } else { - std::vector<GHOST_IWindow*>::iterator result = find(m_windows.begin(), m_windows.end(), window); + std::vector<GHOST_IWindow *>::iterator result = find(m_windows.begin(), m_windows.end(), window); if (result != m_windows.end()) { setWindowInactive(window); m_windows.erase(result); @@ -91,19 +91,19 @@ GHOST_TSuccess GHOST_WindowManager::removeWindow(const GHOST_IWindow* window) } -bool GHOST_WindowManager::getWindowFound(const GHOST_IWindow* window) const +bool GHOST_WindowManager::getWindowFound(const GHOST_IWindow *window) const { bool found = false; if (window) { - if (getFullScreen() && (window == m_fullScreenWindow)) { - found = true; - } - else { - std::vector<GHOST_IWindow*>::const_iterator result = find(m_windows.begin(), m_windows.end(), window); - if (result != m_windows.end()) { - found = true; - } - } + if (getFullScreen() && (window == m_fullScreenWindow)) { + found = true; + } + else { + std::vector<GHOST_IWindow *>::const_iterator result = find(m_windows.begin(), m_windows.end(), window); + if (result != m_windows.end()) { + found = true; + } + } } return found; } @@ -115,13 +115,13 @@ bool GHOST_WindowManager::getFullScreen(void) const } -GHOST_IWindow* GHOST_WindowManager::getFullScreenWindow(void) const +GHOST_IWindow *GHOST_WindowManager::getFullScreenWindow(void) const { - return m_fullScreenWindow; + return m_fullScreenWindow; } -GHOST_TSuccess GHOST_WindowManager::beginFullScreen(GHOST_IWindow* window, +GHOST_TSuccess GHOST_WindowManager::beginFullScreen(GHOST_IWindow *window, bool stereoVisual) { GHOST_TSuccess success = GHOST_kFailure; @@ -151,13 +151,13 @@ GHOST_TSuccess GHOST_WindowManager::endFullScreen(void) setActiveWindow(m_activeWindowBeforeFullScreen); } } - success = GHOST_kSuccess; + success = GHOST_kSuccess; } return success; } -GHOST_TSuccess GHOST_WindowManager::setActiveWindow(GHOST_IWindow* window) +GHOST_TSuccess GHOST_WindowManager::setActiveWindow(GHOST_IWindow *window) { GHOST_TSuccess success = GHOST_kSuccess; if (window != m_activeWindow) { @@ -172,13 +172,13 @@ GHOST_TSuccess GHOST_WindowManager::setActiveWindow(GHOST_IWindow* window) } -GHOST_IWindow* GHOST_WindowManager::getActiveWindow(void) const +GHOST_IWindow *GHOST_WindowManager::getActiveWindow(void) const { return m_activeWindow; } -void GHOST_WindowManager::setWindowInactive(const GHOST_IWindow* window) +void GHOST_WindowManager::setWindowInactive(const GHOST_IWindow *window) { if (window == m_activeWindow) { m_activeWindow = 0; @@ -192,9 +192,9 @@ std::vector<GHOST_IWindow *> &GHOST_WindowManager::getWindows() } -GHOST_IWindow* GHOST_WindowManager::getWindowAssociatedWithOSWindow(void* osWindow) +GHOST_IWindow *GHOST_WindowManager::getWindowAssociatedWithOSWindow(void *osWindow) { - std::vector<GHOST_IWindow*>::iterator iter; + std::vector<GHOST_IWindow *>::iterator iter; for (iter = m_windows.begin(); iter != m_windows.end(); iter++) { if ((*iter)->getOSWindow() == osWindow) @@ -207,7 +207,7 @@ GHOST_IWindow* GHOST_WindowManager::getWindowAssociatedWithOSWindow(void* osWind bool GHOST_WindowManager::getAnyModifiedState() { bool isAnyModified = false; - std::vector<GHOST_IWindow*>::iterator iter; + std::vector<GHOST_IWindow *>::iterator iter; for (iter = m_windows.begin(); iter != m_windows.end(); iter++) { if ((*iter)->getModifiedState()) diff --git a/intern/ghost/intern/GHOST_WindowSDL.cpp b/intern/ghost/intern/GHOST_WindowSDL.cpp index b8cbf9b474d..369fc4ace14 100644 --- a/intern/ghost/intern/GHOST_WindowSDL.cpp +++ b/intern/ghost/intern/GHOST_WindowSDL.cpp @@ -28,7 +28,7 @@ #include "SDL_mouse.h" #include <assert.h> -static SDL_GLContext s_firstContext= NULL; +static SDL_GLContext s_firstContext = NULL; GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system, const STR_String& title, @@ -42,18 +42,18 @@ GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system, const bool stereoVisual, const GHOST_TUns16 numOfAASamples ) - : - GHOST_Window(width,height,state,type,stereoVisual,numOfAASamples), - m_system (system), - m_invalid_window(false), - m_sdl_custom_cursor(NULL) + : + GHOST_Window(width, height, state, type, stereoVisual, numOfAASamples), + m_system(system), + m_invalid_window(false), + m_sdl_custom_cursor(NULL) { - m_sdl_win= SDL_CreateWindow(title, - left, - top, - width, - height, - SDL_WINDOW_RESIZABLE|SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN); + m_sdl_win = SDL_CreateWindow(title, + left, + top, + width, + height, + SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); @@ -64,7 +64,7 @@ GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system, SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); - m_sdl_glcontext= SDL_GL_CreateContext(m_sdl_win); + m_sdl_glcontext = SDL_GL_CreateContext(m_sdl_win); //fprintf(stderr, "Ignoring Xlib error: error code %d request code %d\n", // theEvent->error_code, theEvent->request_code); @@ -74,7 +74,7 @@ GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system, GHOST_WindowSDL::~GHOST_WindowSDL() { - if(m_sdl_custom_cursor) { + if (m_sdl_custom_cursor) { SDL_FreeCursor(m_sdl_custom_cursor); } @@ -92,29 +92,29 @@ GHOST_WindowSDL::installDrawingContext(GHOST_TDrawingContextType type) // only support openGL for now. GHOST_TSuccess success; switch (type) { - case GHOST_kDrawingContextTypeOpenGL: - m_sdl_glcontext= SDL_GL_CreateContext(m_sdl_win); + case GHOST_kDrawingContextTypeOpenGL: + m_sdl_glcontext = SDL_GL_CreateContext(m_sdl_win); - if (m_sdl_glcontext != NULL) { - if (!s_firstContext) { - s_firstContext= m_sdl_glcontext; - } + if (m_sdl_glcontext != NULL) { + if (!s_firstContext) { + s_firstContext = m_sdl_glcontext; + } - success= (SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext) < 0) ? - GHOST_kFailure : GHOST_kSuccess; - } - else { - success= GHOST_kFailure; - } + success = (SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext) < 0) ? + GHOST_kFailure : GHOST_kSuccess; + } + else { + success = GHOST_kFailure; + } - break; + break; - case GHOST_kDrawingContextTypeNone: - success= GHOST_kSuccess; - break; + case GHOST_kDrawingContextTypeNone: + success = GHOST_kSuccess; + break; - default: - success= GHOST_kFailure; + default: + success = GHOST_kFailure; } return success; } @@ -138,7 +138,7 @@ GHOST_WindowSDL::invalidate(void) if (m_invalid_window == false) { m_system->addDirtyWindow(this); - m_invalid_window= true; + m_invalid_window = true; } return GHOST_kSuccess; @@ -161,8 +161,8 @@ GHOST_WindowSDL::swapBuffers() GHOST_TSuccess GHOST_WindowSDL::activateDrawingContext() { - if (m_sdl_glcontext !=NULL) { - int status=SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext); + if (m_sdl_glcontext != NULL) { + int status = SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext); (void)status; return GHOST_kSuccess; } @@ -177,10 +177,10 @@ GHOST_WindowSDL::removeDrawingContext() if (m_sdl_glcontext != NULL) { SDL_GL_DeleteContext(m_sdl_glcontext); - success= GHOST_kSuccess; + success = GHOST_kSuccess; } else { - success= GHOST_kFailure; + success = GHOST_kFailure; } return success; } @@ -189,23 +189,23 @@ GHOST_WindowSDL::removeDrawingContext() GHOST_TSuccess GHOST_WindowSDL::setState(GHOST_TWindowState state) { - switch(state) { - case GHOST_kWindowStateNormal: - SDL_SetWindowFullscreen(m_sdl_win, SDL_FALSE); - SDL_RestoreWindow(m_sdl_win); - break; - case GHOST_kWindowStateMaximized: - SDL_SetWindowFullscreen(m_sdl_win, SDL_FALSE); - SDL_MaximizeWindow(m_sdl_win); - break; - case GHOST_kWindowStateMinimized: - SDL_MinimizeWindow(m_sdl_win); - break; - case GHOST_kWindowStateFullScreen: - SDL_SetWindowFullscreen(m_sdl_win, SDL_TRUE); - break; - default: - break; + switch (state) { + case GHOST_kWindowStateNormal: + SDL_SetWindowFullscreen(m_sdl_win, SDL_FALSE); + SDL_RestoreWindow(m_sdl_win); + break; + case GHOST_kWindowStateMaximized: + SDL_SetWindowFullscreen(m_sdl_win, SDL_FALSE); + SDL_MaximizeWindow(m_sdl_win); + break; + case GHOST_kWindowStateMinimized: + SDL_MinimizeWindow(m_sdl_win); + break; + case GHOST_kWindowStateFullScreen: + SDL_SetWindowFullscreen(m_sdl_win, SDL_TRUE); + break; + default: + break; } return GHOST_kSuccess; @@ -215,11 +215,11 @@ GHOST_WindowSDL::setState(GHOST_TWindowState state) GHOST_TWindowState GHOST_WindowSDL::getState() const { - Uint32 flags= SDL_GetWindowFlags(m_sdl_win); + Uint32 flags = SDL_GetWindowFlags(m_sdl_win); - if(flags & SDL_WINDOW_FULLSCREEN) return GHOST_kWindowStateFullScreen; - else if(flags & SDL_WINDOW_MAXIMIZED) return GHOST_kWindowStateMaximized; - else if(flags & SDL_WINDOW_MINIMIZED) return GHOST_kWindowStateMinimized; + if (flags & SDL_WINDOW_FULLSCREEN) return GHOST_kWindowStateFullScreen; + else if (flags & SDL_WINDOW_MAXIMIZED) return GHOST_kWindowStateMaximized; + else if (flags & SDL_WINDOW_MINIMIZED) return GHOST_kWindowStateMinimized; return GHOST_kWindowStateNormal; } @@ -234,7 +234,7 @@ GHOST_WindowSDL::setTitle(const STR_String& title) void GHOST_WindowSDL::getTitle(STR_String& title) const { - title= SDL_GetWindowTitle(m_sdl_win); + title = SDL_GetWindowTitle(m_sdl_win); } @@ -252,10 +252,10 @@ GHOST_WindowSDL::getClientBounds(GHOST_Rect& bounds) const SDL_GetWindowSize(m_sdl_win, &w, &h); SDL_GetWindowPosition(m_sdl_win, &x, &y); - bounds.m_l= x; - bounds.m_r= x + w; - bounds.m_t= y; - bounds.m_b= y + h; + bounds.m_l = x; + bounds.m_r = x + w; + bounds.m_t = y; + bounds.m_b = y + h; } GHOST_TSuccess @@ -278,14 +278,14 @@ GHOST_WindowSDL::setClientHeight(GHOST_TUns32 height) GHOST_TSuccess GHOST_WindowSDL::setClientSize(GHOST_TUns32 width, - GHOST_TUns32 height) + GHOST_TUns32 height) { SDL_SetWindowSize(m_sdl_win, width, height); return GHOST_kSuccess; } void -GHOST_WindowSDL::screenToClient( GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY ) const +GHOST_WindowSDL::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const { /* XXXSDL_WEAK_ABS_COORDS */ int x_win, y_win; @@ -295,7 +295,7 @@ GHOST_WindowSDL::screenToClient( GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt3 outY = inY - y_win; } void -GHOST_WindowSDL::clientToScreen( GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY ) const +GHOST_WindowSDL::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const { /* XXXSDL_WEAK_ABS_COORDS */ int x_win, y_win; @@ -306,148 +306,148 @@ GHOST_WindowSDL::clientToScreen( GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt3 } /* mouse cursor */ -static unsigned char sdl_std_cursor_mask_xterm[]= {0xef,0x01,0xff,0x01,0xff,0x01,0x7c,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x7c,0x00,0xff,0x01,0xff,0x01,0xef,0x01,}; -static unsigned char sdl_std_cursor_xterm[]= {0x00,0x77,0x00,0x1c,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x1c,0x00,0x77,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_xterm[] = {0xef, 0x01, 0xff, 0x01, 0xff, 0x01, 0x7c, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xff, 0x01, 0xff, 0x01, 0xef, 0x01, }; +static unsigned char sdl_std_cursor_xterm[] = {0x00, 0x77, 0x00, 0x1c, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x1c, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_xterm 9 #define sdl_std_cursor_HEIGHT_xterm 16 #define sdl_std_cursor_HOT_X_xterm -3 #define sdl_std_cursor_HOT_Y_xterm -7 -static unsigned char sdl_std_cursor_mask_watch[]= {0xfc,0x0f,0xfc,0x0f,0xfc,0x0f,0xfe,0x1f,0xff,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfe,0x1f,0xfc,0x0f,0xfc,0x0f,0xfc,0x0f,}; -static unsigned char sdl_std_cursor_watch[]= {0xf8,0x07,0xf8,0x07,0xf8,0x07,0xfc,0x0f,0x86,0x18,0x83,0x30,0x81,0xe0,0xc1,0xe1,0xc1,0xe1,0x21,0xe0,0x13,0x30,0x06,0x18,0xfc,0x0f,0xf8,0x07,0xf8,0x07,0xf8,0x07,}; +static unsigned char sdl_std_cursor_mask_watch[] = {0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfe, 0x1f, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x1f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, }; +static unsigned char sdl_std_cursor_watch[] = {0xf8, 0x07, 0xf8, 0x07, 0xf8, 0x07, 0xfc, 0x0f, 0x86, 0x18, 0x83, 0x30, 0x81, 0xe0, 0xc1, 0xe1, 0xc1, 0xe1, 0x21, 0xe0, 0x13, 0x30, 0x06, 0x18, 0xfc, 0x0f, 0xf8, 0x07, 0xf8, 0x07, 0xf8, 0x07, }; #define sdl_std_cursor_WIDTH_watch 16 #define sdl_std_cursor_HEIGHT_watch 16 #define sdl_std_cursor_HOT_X_watch -15 #define sdl_std_cursor_HOT_Y_watch -7 -static unsigned char sdl_std_cursor_mask_umbrella[]= {0xe8,0x76,0xfb,0xdf,0xfd,0x3f,0xfe,0xff,0xff,0x3f,0xff,0xff,0xcf,0x79,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x07,0xc0,0x07,0xc0,0x07,0xc0,0x07,0x80,0x03,}; -static unsigned char sdl_std_cursor_umbrella[]= {0x88,0x04,0x20,0x0a,0xc9,0x32,0xf2,0x09,0x4c,0x06,0x43,0x18,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x01,0x40,0x01,0x80,0x00,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_umbrella[] = {0xe8, 0x76, 0xfb, 0xdf, 0xfd, 0x3f, 0xfe, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xcf, 0x79, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0x80, 0x03, }; +static unsigned char sdl_std_cursor_umbrella[] = {0x88, 0x04, 0x20, 0x0a, 0xc9, 0x32, 0xf2, 0x09, 0x4c, 0x06, 0x43, 0x18, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x01, 0x40, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_umbrella 16 #define sdl_std_cursor_HEIGHT_umbrella 16 #define sdl_std_cursor_HOT_X_umbrella -7 #define sdl_std_cursor_HOT_Y_umbrella -12 -static unsigned char sdl_std_cursor_mask_top_side[]= {0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xc0,0x01,0xe0,0x03,0xf0,0x07,0xf8,0x0f,0xdc,0x1d,0xcc,0x19,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,}; -static unsigned char sdl_std_cursor_top_side[]= {0xff,0x1f,0xff,0x1f,0x00,0x00,0x40,0x00,0xe0,0x00,0x50,0x01,0x48,0x02,0x44,0x04,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_top_side[] = {0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xdc, 0x1d, 0xcc, 0x19, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, }; +static unsigned char sdl_std_cursor_top_side[] = {0xff, 0x1f, 0xff, 0x1f, 0x00, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x50, 0x01, 0x48, 0x02, 0x44, 0x04, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_top_side 15 #define sdl_std_cursor_HEIGHT_top_side 16 #define sdl_std_cursor_HOT_X_top_side -6 #define sdl_std_cursor_HOT_Y_top_side -14 -static unsigned char sdl_std_cursor_mask_top_right_corner[]= {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf0,0xfc,0xf7,0xfc,0xf7,0xfc,0xf7,0xc0,0xf7,0xe0,0xf7,0x70,0xf7,0x38,0xf7,0x1c,0xf7,0x0c,0xf7,0x00,0xf0,0x00,0xf0,}; -static unsigned char sdl_std_cursor_top_right_corner[]= {0xff,0x3f,0xff,0x3f,0x00,0x30,0x00,0x30,0x00,0x30,0xfc,0x31,0x80,0x31,0x40,0x31,0x20,0x31,0x10,0x31,0x08,0x31,0x04,0x31,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_top_right_corner[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xfc, 0xf7, 0xfc, 0xf7, 0xfc, 0xf7, 0xc0, 0xf7, 0xe0, 0xf7, 0x70, 0xf7, 0x38, 0xf7, 0x1c, 0xf7, 0x0c, 0xf7, 0x00, 0xf0, 0x00, 0xf0, }; +static unsigned char sdl_std_cursor_top_right_corner[] = {0xff, 0x3f, 0xff, 0x3f, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0xfc, 0x31, 0x80, 0x31, 0x40, 0x31, 0x20, 0x31, 0x10, 0x31, 0x08, 0x31, 0x04, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_top_right_corner 16 #define sdl_std_cursor_HEIGHT_top_right_corner 16 #define sdl_std_cursor_HOT_X_top_right_corner -13 #define sdl_std_cursor_HOT_Y_top_right_corner -14 -static unsigned char sdl_std_cursor_mask_top_left_corner[]= {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0xef,0x3f,0xef,0x3f,0xef,0x3f,0xef,0x03,0xef,0x07,0xef,0x0e,0xef,0x1c,0xef,0x38,0xef,0x30,0x0f,0x00,0x0f,0x00,}; -static unsigned char sdl_std_cursor_top_left_corner[]= {0xff,0x3f,0xff,0x3f,0x03,0x00,0x03,0x00,0x03,0x00,0xe3,0x0f,0x63,0x00,0xa3,0x00,0x23,0x01,0x23,0x02,0x23,0x04,0x23,0x08,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_top_left_corner[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xef, 0x3f, 0xef, 0x3f, 0xef, 0x3f, 0xef, 0x03, 0xef, 0x07, 0xef, 0x0e, 0xef, 0x1c, 0xef, 0x38, 0xef, 0x30, 0x0f, 0x00, 0x0f, 0x00, }; +static unsigned char sdl_std_cursor_top_left_corner[] = {0xff, 0x3f, 0xff, 0x3f, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0xe3, 0x0f, 0x63, 0x00, 0xa3, 0x00, 0x23, 0x01, 0x23, 0x02, 0x23, 0x04, 0x23, 0x08, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_top_left_corner 16 #define sdl_std_cursor_HEIGHT_top_left_corner 16 #define sdl_std_cursor_HOT_X_top_left_corner 0 #define sdl_std_cursor_HOT_Y_top_left_corner -14 -static unsigned char sdl_std_cursor_mask_spraycan[]= {0x00,0x0c,0x18,0x0d,0x7c,0x0d,0x7c,0x0d,0x7e,0x0d,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,}; -static unsigned char sdl_std_cursor_spraycan[]= {0x00,0x06,0x80,0x00,0x2c,0x06,0x9e,0x00,0x16,0x06,0x3f,0x00,0x21,0x00,0x27,0x00,0x25,0x00,0x27,0x00,0x25,0x00,0x27,0x00,0x27,0x00,0x21,0x00,0x21,0x00,0x3f,0x00,}; +static unsigned char sdl_std_cursor_mask_spraycan[] = {0x00, 0x0c, 0x18, 0x0d, 0x7c, 0x0d, 0x7c, 0x0d, 0x7e, 0x0d, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, }; +static unsigned char sdl_std_cursor_spraycan[] = {0x00, 0x06, 0x80, 0x00, 0x2c, 0x06, 0x9e, 0x00, 0x16, 0x06, 0x3f, 0x00, 0x21, 0x00, 0x27, 0x00, 0x25, 0x00, 0x27, 0x00, 0x25, 0x00, 0x27, 0x00, 0x27, 0x00, 0x21, 0x00, 0x21, 0x00, 0x3f, 0x00, }; #define sdl_std_cursor_WIDTH_spraycan 12 #define sdl_std_cursor_HEIGHT_spraycan 16 #define sdl_std_cursor_HOT_X_spraycan -9 #define sdl_std_cursor_HOT_Y_spraycan -14 -static unsigned char sdl_std_cursor_mask_sb_v_double_arrow[]= {0x38,0x00,0x7c,0x00,0xfe,0x00,0xff,0x01,0xff,0x01,0x7c,0x00,0x7c,0x00,0x7c,0x00,0x7c,0x00,0x7c,0x00,0xff,0x01,0xff,0x01,0xfe,0x00,0x7c,0x00,0x38,0x00,}; -static unsigned char sdl_std_cursor_sb_v_double_arrow[]= {0x10,0x00,0x38,0x00,0x7c,0x00,0xfe,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0xfe,0x00,0x7c,0x00,0x38,0x00,0x10,0x00,}; +static unsigned char sdl_std_cursor_mask_sb_v_double_arrow[] = {0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00, 0xff, 0x01, 0xff, 0x01, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0xff, 0x01, 0xff, 0x01, 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, }; +static unsigned char sdl_std_cursor_sb_v_double_arrow[] = {0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, }; #define sdl_std_cursor_WIDTH_sb_v_double_arrow 9 #define sdl_std_cursor_HEIGHT_sb_v_double_arrow 15 #define sdl_std_cursor_HOT_X_sb_v_double_arrow -3 #define sdl_std_cursor_HOT_Y_sb_v_double_arrow -8 -static unsigned char sdl_std_cursor_mask_sb_h_double_arrow[]= {0x18,0x0c,0x1c,0x1c,0xfe,0x3f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xfe,0x3f,0x1c,0x1c,0x18,0x0c,}; -static unsigned char sdl_std_cursor_sb_h_double_arrow[]= {0x00,0x00,0x08,0x08,0x0c,0x18,0xfe,0x3f,0x0f,0x78,0xfe,0x3f,0x0c,0x18,0x08,0x08,0x00,0x00}; +static unsigned char sdl_std_cursor_mask_sb_h_double_arrow[] = {0x18, 0x0c, 0x1c, 0x1c, 0xfe, 0x3f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xfe, 0x3f, 0x1c, 0x1c, 0x18, 0x0c, }; +static unsigned char sdl_std_cursor_sb_h_double_arrow[] = {0x00, 0x00, 0x08, 0x08, 0x0c, 0x18, 0xfe, 0x3f, 0x0f, 0x78, 0xfe, 0x3f, 0x0c, 0x18, 0x08, 0x08, 0x00, 0x00}; #define sdl_std_cursor_WIDTH_sb_h_double_arrow 15 #define sdl_std_cursor_HEIGHT_sb_h_double_arrow 9 #define sdl_std_cursor_HOT_X_sb_h_double_arrow -7 #define sdl_std_cursor_HOT_Y_sb_h_double_arrow -4 -static unsigned char sdl_std_cursor_mask_right_side[]= {0x00,0xf0,0x00,0xf0,0xc0,0xf0,0xc0,0xf1,0x80,0xf3,0x00,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf7,0x80,0xf3,0xc0,0xf1,0xc0,0xf0,0x00,0xf0,0x00,0xf0,}; -static unsigned char sdl_std_cursor_right_side[]= {0x00,0x30,0x00,0x30,0x40,0x30,0x80,0x30,0x00,0x31,0x00,0x32,0xff,0x37,0x00,0x32,0x00,0x31,0x80,0x30,0x40,0x30,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_right_side[] = {0x00, 0xf0, 0x00, 0xf0, 0xc0, 0xf0, 0xc0, 0xf1, 0x80, 0xf3, 0x00, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf7, 0x80, 0xf3, 0xc0, 0xf1, 0xc0, 0xf0, 0x00, 0xf0, 0x00, 0xf0, }; +static unsigned char sdl_std_cursor_right_side[] = {0x00, 0x30, 0x00, 0x30, 0x40, 0x30, 0x80, 0x30, 0x00, 0x31, 0x00, 0x32, 0xff, 0x37, 0x00, 0x32, 0x00, 0x31, 0x80, 0x30, 0x40, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_right_side 16 #define sdl_std_cursor_HEIGHT_right_side 15 #define sdl_std_cursor_HOT_X_right_side -13 #define sdl_std_cursor_HOT_Y_right_side -7 -static unsigned char sdl_std_cursor_mask_right_ptr[]= {0x00,0x03,0x80,0x03,0xc0,0x03,0xe0,0x03,0xf0,0x03,0xf8,0x03,0xfc,0x03,0xfe,0x03,0xff,0x03,0xff,0x03,0xf8,0x03,0xbc,0x03,0x3c,0x03,0x1e,0x00,0x1e,0x00,0x0c,0x00,}; -static unsigned char sdl_std_cursor_right_ptr[]= {0x00,0x80,0x00,0xc0,0x00,0xe0,0x00,0xf0,0x00,0xf8,0x00,0xfc,0x00,0xfe,0x00,0xff,0x00,0xf8,0x00,0xd8,0x00,0x8c,0x00,0x0c,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_right_ptr[] = {0x00, 0x03, 0x80, 0x03, 0xc0, 0x03, 0xe0, 0x03, 0xf0, 0x03, 0xf8, 0x03, 0xfc, 0x03, 0xfe, 0x03, 0xff, 0x03, 0xff, 0x03, 0xf8, 0x03, 0xbc, 0x03, 0x3c, 0x03, 0x1e, 0x00, 0x1e, 0x00, 0x0c, 0x00, }; +static unsigned char sdl_std_cursor_right_ptr[] = {0x00, 0x80, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xf0, 0x00, 0xf8, 0x00, 0xfc, 0x00, 0xfe, 0x00, 0xff, 0x00, 0xf8, 0x00, 0xd8, 0x00, 0x8c, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_right_ptr 10 #define sdl_std_cursor_HEIGHT_right_ptr 16 #define sdl_std_cursor_HOT_X_right_ptr -7 #define sdl_std_cursor_HOT_Y_right_ptr -14 -static unsigned char sdl_std_cursor_mask_question_arrow[]= {0xf8,0x00,0xfc,0x01,0xfe,0x03,0xff,0x07,0x8f,0x07,0x9f,0x07,0xde,0x07,0xfc,0x03,0xf8,0x01,0xf8,0x00,0xf8,0x00,0xfc,0x01,0xfe,0x03,0xfc,0x01,0xf8,0x00,0x70,0x00,}; -static unsigned char sdl_std_cursor_question_arrow[]= {0x7c,0x00,0xfe,0x00,0xc7,0x01,0x83,0x01,0x87,0x01,0xc6,0x01,0xe0,0x00,0x78,0x00,0x38,0x00,0x28,0x00,0x28,0x00,0xee,0x00,0x6c,0x00,0x38,0x00,0x10,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_question_arrow[] = {0xf8, 0x00, 0xfc, 0x01, 0xfe, 0x03, 0xff, 0x07, 0x8f, 0x07, 0x9f, 0x07, 0xde, 0x07, 0xfc, 0x03, 0xf8, 0x01, 0xf8, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0xfe, 0x03, 0xfc, 0x01, 0xf8, 0x00, 0x70, 0x00, }; +static unsigned char sdl_std_cursor_question_arrow[] = {0x7c, 0x00, 0xfe, 0x00, 0xc7, 0x01, 0x83, 0x01, 0x87, 0x01, 0xc6, 0x01, 0xe0, 0x00, 0x78, 0x00, 0x38, 0x00, 0x28, 0x00, 0x28, 0x00, 0xee, 0x00, 0x6c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_question_arrow 11 #define sdl_std_cursor_HEIGHT_question_arrow 16 #define sdl_std_cursor_HOT_X_question_arrow -4 #define sdl_std_cursor_HOT_Y_question_arrow -8 -static unsigned char sdl_std_cursor_mask_pirate[]= {0xf0,0x03,0xf8,0x07,0xfc,0x0f,0xfe,0x1f,0xfe,0x1f,0xfc,0x0f,0xf8,0x07,0xf1,0x83,0xf1,0xe3,0xf3,0xf3,0xef,0x39,0x1e,0x1e,0xe0,0x01,0xfe,0xc7,0xff,0xff,0x0f,0x7c,}; -static unsigned char sdl_std_cursor_pirate[]= {0xe0,0x01,0xf0,0x03,0xf8,0x07,0xcc,0x0c,0xcc,0x0c,0xf8,0x07,0xf0,0x03,0xe0,0x01,0xe1,0x21,0xe1,0x61,0xc2,0x10,0x1c,0x0e,0xe0,0x01,0xf8,0x47,0x0f,0x7c,0x01,0x20,}; +static unsigned char sdl_std_cursor_mask_pirate[] = {0xf0, 0x03, 0xf8, 0x07, 0xfc, 0x0f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfc, 0x0f, 0xf8, 0x07, 0xf1, 0x83, 0xf1, 0xe3, 0xf3, 0xf3, 0xef, 0x39, 0x1e, 0x1e, 0xe0, 0x01, 0xfe, 0xc7, 0xff, 0xff, 0x0f, 0x7c, }; +static unsigned char sdl_std_cursor_pirate[] = {0xe0, 0x01, 0xf0, 0x03, 0xf8, 0x07, 0xcc, 0x0c, 0xcc, 0x0c, 0xf8, 0x07, 0xf0, 0x03, 0xe0, 0x01, 0xe1, 0x21, 0xe1, 0x61, 0xc2, 0x10, 0x1c, 0x0e, 0xe0, 0x01, 0xf8, 0x47, 0x0f, 0x7c, 0x01, 0x20, }; #define sdl_std_cursor_WIDTH_pirate 16 #define sdl_std_cursor_HEIGHT_pirate 16 #define sdl_std_cursor_HOT_X_pirate -7 #define sdl_std_cursor_HOT_Y_pirate -4 -static unsigned char sdl_std_cursor_mask_left_side[]= {0x0f,0x00,0x0f,0x00,0x0f,0x03,0x8f,0x03,0xcf,0x01,0xef,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x00,0xcf,0x01,0x8f,0x03,0x0f,0x03,0x0f,0x00,0x0f,0x00,}; -static unsigned char sdl_std_cursor_left_side[]= {0x03,0x00,0x03,0x00,0x83,0x00,0x43,0x00,0x23,0x00,0x13,0x00,0xfb,0x3f,0x13,0x00,0x23,0x00,0x43,0x00,0x83,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_left_side[] = {0x0f, 0x00, 0x0f, 0x00, 0x0f, 0x03, 0x8f, 0x03, 0xcf, 0x01, 0xef, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0x00, 0xcf, 0x01, 0x8f, 0x03, 0x0f, 0x03, 0x0f, 0x00, 0x0f, 0x00, }; +static unsigned char sdl_std_cursor_left_side[] = {0x03, 0x00, 0x03, 0x00, 0x83, 0x00, 0x43, 0x00, 0x23, 0x00, 0x13, 0x00, 0xfb, 0x3f, 0x13, 0x00, 0x23, 0x00, 0x43, 0x00, 0x83, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_left_side 16 #define sdl_std_cursor_HEIGHT_left_side 15 #define sdl_std_cursor_HOT_X_left_side 0 #define sdl_std_cursor_HOT_Y_left_side -7 -static unsigned char sdl_std_cursor_mask_left_ptr[]= {0x03,0x00,0x07,0x00,0x0f,0x00,0x1f,0x00,0x3f,0x00,0x7f,0x00,0xff,0x00,0xff,0x01,0xff,0x03,0xff,0x03,0x7f,0x00,0xf7,0x00,0xf3,0x00,0xe0,0x01,0xe0,0x01,0xc0,0x00,}; -static unsigned char sdl_std_cursor_left_ptr[]= {0x00,0x00,0x02,0x00,0x06,0x00,0x0e,0x00,0x1e,0x00,0x3e,0x00,0x7e,0x00,0xfe,0x00,0xfe,0x00,0x3e,0x00,0x36,0x00,0x62,0x00,0x60,0x00,0xc0,0x00,0xc0,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_left_ptr[] = {0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3f, 0x00, 0x7f, 0x00, 0xff, 0x00, 0xff, 0x01, 0xff, 0x03, 0xff, 0x03, 0x7f, 0x00, 0xf7, 0x00, 0xf3, 0x00, 0xe0, 0x01, 0xe0, 0x01, 0xc0, 0x00, }; +static unsigned char sdl_std_cursor_left_ptr[] = {0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x3e, 0x00, 0x7e, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0x3e, 0x00, 0x36, 0x00, 0x62, 0x00, 0x60, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_left_ptr 10 #define sdl_std_cursor_HEIGHT_left_ptr 16 #define sdl_std_cursor_HOT_X_left_ptr -8 #define sdl_std_cursor_HOT_Y_left_ptr -14 -static unsigned char sdl_std_cursor_mask_exchange[]= {0xe3,0x07,0xf7,0x0f,0xff,0x1f,0xff,0x3f,0x3f,0x38,0xff,0x30,0xff,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x0c,0xfe,0x1c,0xfc,0xfc,0xff,0xf8,0xff,0xf0,0xef,0xe0,0xc7,}; -static unsigned char sdl_std_cursor_exchange[]= {0xf1,0x03,0xfb,0x07,0x1f,0x0c,0x09,0x08,0x19,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x26,0x04,0x24,0x0c,0x3e,0xf8,0x37,0xf0,0x23,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_exchange[] = {0xe3, 0x07, 0xf7, 0x0f, 0xff, 0x1f, 0xff, 0x3f, 0x3f, 0x38, 0xff, 0x30, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x0c, 0xfe, 0x1c, 0xfc, 0xfc, 0xff, 0xf8, 0xff, 0xf0, 0xef, 0xe0, 0xc7, }; +static unsigned char sdl_std_cursor_exchange[] = {0xf1, 0x03, 0xfb, 0x07, 0x1f, 0x0c, 0x09, 0x08, 0x19, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x26, 0x04, 0x24, 0x0c, 0x3e, 0xf8, 0x37, 0xf0, 0x23, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_exchange 16 #define sdl_std_cursor_HEIGHT_exchange 16 #define sdl_std_cursor_HOT_X_exchange -6 #define sdl_std_cursor_HOT_Y_exchange -8 -static unsigned char sdl_std_cursor_mask_crosshair[]= {0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,}; -static unsigned char sdl_std_cursor_crosshair[]= {0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x7f,0xff,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_crosshair[] = {0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, }; +static unsigned char sdl_std_cursor_crosshair[] = {0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x7f, 0xff, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_crosshair 16 #define sdl_std_cursor_HEIGHT_crosshair 16 #define sdl_std_cursor_HOT_X_crosshair -7 #define sdl_std_cursor_HOT_Y_crosshair -8 -static unsigned char sdl_std_cursor_mask_bottom_side[]= {0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xcc,0x19,0xdc,0x1d,0xf8,0x0f,0xf0,0x07,0xe0,0x03,0xc0,0x01,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,}; -static unsigned char sdl_std_cursor_bottom_side[]= {0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x44,0x04,0x48,0x02,0x50,0x01,0xe0,0x00,0x40,0x00,0x00,0x00,0xff,0x1f,0xff,0x1f,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_bottom_side[] = {0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xcc, 0x19, 0xdc, 0x1d, 0xf8, 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, }; +static unsigned char sdl_std_cursor_bottom_side[] = {0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x44, 0x04, 0x48, 0x02, 0x50, 0x01, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0xff, 0x1f, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_bottom_side 15 #define sdl_std_cursor_HEIGHT_bottom_side 16 #define sdl_std_cursor_HOT_X_bottom_side -6 #define sdl_std_cursor_HOT_Y_bottom_side -1 -static unsigned char sdl_std_cursor_mask_bottom_right_corner[]= {0x00,0xf0,0x00,0xf0,0x0c,0xf7,0x1c,0xf7,0x38,0xf7,0x70,0xf7,0xe0,0xf7,0xc0,0xf7,0xfc,0xf7,0xfc,0xf7,0xfc,0xf7,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,}; -static unsigned char sdl_std_cursor_bottom_right_corner[]= {0x00,0x30,0x00,0x30,0x04,0x31,0x08,0x31,0x10,0x31,0x20,0x31,0x40,0x31,0x80,0x31,0xfc,0x31,0x00,0x30,0x00,0x30,0x00,0x30,0xff,0x3f,0xff,0x3f,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_bottom_right_corner[] = {0x00, 0xf0, 0x00, 0xf0, 0x0c, 0xf7, 0x1c, 0xf7, 0x38, 0xf7, 0x70, 0xf7, 0xe0, 0xf7, 0xc0, 0xf7, 0xfc, 0xf7, 0xfc, 0xf7, 0xfc, 0xf7, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; +static unsigned char sdl_std_cursor_bottom_right_corner[] = {0x00, 0x30, 0x00, 0x30, 0x04, 0x31, 0x08, 0x31, 0x10, 0x31, 0x20, 0x31, 0x40, 0x31, 0x80, 0x31, 0xfc, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0xff, 0x3f, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_bottom_right_corner 16 #define sdl_std_cursor_HEIGHT_bottom_right_corner 16 #define sdl_std_cursor_HOT_X_bottom_right_corner -13 #define sdl_std_cursor_HOT_Y_bottom_right_corner -1 -static unsigned char sdl_std_cursor_mask_bottom_left_corner[]= {0x0f,0x00,0x0f,0x00,0xef,0x30,0xef,0x38,0xef,0x1c,0xef,0x0e,0xef,0x07,0xef,0x03,0xef,0x3f,0xef,0x3f,0xef,0x3f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,}; -static unsigned char sdl_std_cursor_bottom_left_corner[]= {0x03,0x00,0x03,0x00,0x23,0x08,0x23,0x04,0x23,0x02,0x23,0x01,0xa3,0x00,0x63,0x00,0xe3,0x0f,0x03,0x00,0x03,0x00,0x03,0x00,0xff,0x3f,0xff,0x3f,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_bottom_left_corner[] = {0x0f, 0x00, 0x0f, 0x00, 0xef, 0x30, 0xef, 0x38, 0xef, 0x1c, 0xef, 0x0e, 0xef, 0x07, 0xef, 0x03, 0xef, 0x3f, 0xef, 0x3f, 0xef, 0x3f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; +static unsigned char sdl_std_cursor_bottom_left_corner[] = {0x03, 0x00, 0x03, 0x00, 0x23, 0x08, 0x23, 0x04, 0x23, 0x02, 0x23, 0x01, 0xa3, 0x00, 0x63, 0x00, 0xe3, 0x0f, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0xff, 0x3f, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_bottom_left_corner 16 #define sdl_std_cursor_HEIGHT_bottom_left_corner 16 #define sdl_std_cursor_HOT_X_bottom_left_corner 0 #define sdl_std_cursor_HOT_Y_bottom_left_corner -1 -static unsigned char sdl_std_cursor_mask_arrow[]= {0x00,0xe0,0x00,0xf8,0x00,0xfe,0x80,0x7f,0xe0,0x7f,0xf8,0x3f,0xfc,0x3f,0xfc,0x1f,0xe0,0x1f,0xf0,0x0f,0xf8,0x0f,0x7c,0x07,0x3e,0x07,0x1f,0x02,0x0e,0x00,0x04,0x00,}; -static unsigned char sdl_std_cursor_arrow[]= {0x00,0x30,0x00,0x3c,0x00,0x1f,0xc0,0x1f,0xf0,0x0f,0xfc,0x0f,0xc0,0x07,0xe0,0x07,0x70,0x03,0x38,0x03,0x1c,0x01,0x0e,0x01,0x07,0x00,0x02,0x00,0x00,0x00,0x00,0x00,}; +static unsigned char sdl_std_cursor_mask_arrow[] = {0x00, 0xe0, 0x00, 0xf8, 0x00, 0xfe, 0x80, 0x7f, 0xe0, 0x7f, 0xf8, 0x3f, 0xfc, 0x3f, 0xfc, 0x1f, 0xe0, 0x1f, 0xf0, 0x0f, 0xf8, 0x0f, 0x7c, 0x07, 0x3e, 0x07, 0x1f, 0x02, 0x0e, 0x00, 0x04, 0x00, }; +static unsigned char sdl_std_cursor_arrow[] = {0x00, 0x30, 0x00, 0x3c, 0x00, 0x1f, 0xc0, 0x1f, 0xf0, 0x0f, 0xfc, 0x0f, 0xc0, 0x07, 0xe0, 0x07, 0x70, 0x03, 0x38, 0x03, 0x1c, 0x01, 0x0e, 0x01, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, }; #define sdl_std_cursor_WIDTH_arrow 16 #define sdl_std_cursor_HEIGHT_arrow 16 #define sdl_std_cursor_HOT_X_arrow -13 @@ -455,7 +455,7 @@ static unsigned char sdl_std_cursor_arrow[]= {0x00,0x30,0x00,0x3c,0x00,0x1f,0xc0 /* end cursor data */ -static SDL_Cursor *sdl_std_cursor_array[(int)GHOST_kStandardCursorNumCursors]= {0}; +static SDL_Cursor *sdl_std_cursor_array[(int)GHOST_kStandardCursorNumCursors] = {0}; /* utility function mostly a copy of SDL_CreateCursor but allows us to change * color and supports blenders flipped bits */ @@ -467,54 +467,54 @@ sdl_ghost_CreateCursor(const Uint8 *data, int hot_x, int hot_y) { - SDL_Surface *surface; - SDL_Cursor *cursor; - int x, y; - Uint32 *pixel; - Uint8 datab= 0, maskb= 0; - const Uint32 black= 0xFF000000; - const Uint32 white= 0xFFFFFFFF; - const Uint32 transparent= 0x00000000; - - /* Make sure the width is a multiple of 8 */ - w= ((w + 7) & ~7); - - /* Create the surface from a bitmap */ - surface= SDL_CreateRGBSurface(0, w, h, 32, - 0x00FF0000, - 0x0000FF00, - 0x000000FF, - 0xFF000000); - if (!surface) { - return NULL; - } - for (y= 0; y < h; ++y) { - pixel= (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch); - for (x= 0; x < w; ++x) { - if ((x % 8) == 0) { - datab= *data++; - maskb= *mask++; + SDL_Surface *surface; + SDL_Cursor *cursor; + int x, y; + Uint32 *pixel; + Uint8 datab = 0, maskb = 0; + const Uint32 black = 0xFF000000; + const Uint32 white = 0xFFFFFFFF; + const Uint32 transparent = 0x00000000; + + /* Make sure the width is a multiple of 8 */ + w = ((w + 7) & ~7); + + /* Create the surface from a bitmap */ + surface = SDL_CreateRGBSurface(0, w, h, 32, + 0x00FF0000, + 0x0000FF00, + 0x000000FF, + 0xFF000000); + if (!surface) { + return NULL; + } + for (y = 0; y < h; ++y) { + pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch); + for (x = 0; x < w; ++x) { + if ((x % 8) == 0) { + datab = *data++; + maskb = *mask++; /* reverse bit order */ - datab= (datab * 0x0202020202ULL & 0x010884422010ULL) % 1023; - maskb= (maskb * 0x0202020202ULL & 0x010884422010ULL) % 1023; - } - if (maskb & 0x80) { - *pixel++= (datab & 0x80) ? white : black; - } + datab = (datab * 0x0202020202ULL & 0x010884422010ULL) % 1023; + maskb = (maskb * 0x0202020202ULL & 0x010884422010ULL) % 1023; + } + if (maskb & 0x80) { + *pixel++ = (datab & 0x80) ? white : black; + } else { - *pixel++= (datab & 0x80) ? white : transparent; - } - datab <<= 1; - maskb <<= 1; - } - } + *pixel++ = (datab & 0x80) ? white : transparent; + } + datab <<= 1; + maskb <<= 1; + } + } - cursor= SDL_CreateColorCursor(surface, hot_x, hot_y); + cursor = SDL_CreateColorCursor(surface, hot_x, hot_y); - SDL_FreeSurface(surface); + SDL_FreeSurface(surface); - return cursor; + return cursor; } /* TODO, this is currently never freed but it wont leak either. */ @@ -522,16 +522,16 @@ static void sdl_cursor_init(void) { #define DEF_CURSOR(name, ind) \ - assert(\ - (\ - sdl_std_cursor_array[(int)ind]= \ - sdl_ghost_CreateCursor(sdl_std_cursor_##name, \ - sdl_std_cursor_mask_##name, \ - sdl_std_cursor_WIDTH_##name, \ - sdl_std_cursor_HEIGHT_##name, \ - (sdl_std_cursor_WIDTH_##name + (sdl_std_cursor_HOT_X_##name)) - 1, \ - (sdl_std_cursor_HEIGHT_##name + (sdl_std_cursor_HOT_Y_##name)) - 1) \ - ) != NULL) \ + assert( \ + ( \ + sdl_std_cursor_array[(int)ind] = \ + sdl_ghost_CreateCursor(sdl_std_cursor_##name, \ + sdl_std_cursor_mask_##name, \ + sdl_std_cursor_WIDTH_##name, \ + sdl_std_cursor_HEIGHT_##name, \ + (sdl_std_cursor_WIDTH_##name + (sdl_std_cursor_HOT_X_##name)) - 1, \ + (sdl_std_cursor_HEIGHT_##name + (sdl_std_cursor_HOT_Y_##name)) - 1) \ + ) != NULL) \ DEF_CURSOR(left_ptr, GHOST_kStandardCursorDefault); @@ -554,8 +554,8 @@ static void sdl_cursor_init(void) DEF_CURSOR(top_left_corner, GHOST_kStandardCursorTopLeftCorner); DEF_CURSOR(top_right_corner, GHOST_kStandardCursorTopRightCorner); DEF_CURSOR(bottom_right_corner, GHOST_kStandardCursorBottomRightCorner); - DEF_CURSOR(bottom_left_corner , GHOST_kStandardCursorBottomLeftCorner); - DEF_CURSOR(arrow , GHOST_kStandardCursorCopy); + DEF_CURSOR(bottom_left_corner, GHOST_kStandardCursorBottomLeftCorner); + DEF_CURSOR(arrow, GHOST_kStandardCursorCopy); //DEF_CURSOR(arrow, GHOST_kStandardCursorCustom); DEF_CURSOR(arrow, GHOST_kStandardCursorPencil); @@ -575,7 +575,7 @@ GHOST_WindowSDL::setWindowCursorGrab(GHOST_TGrabCursorMode mode) GHOST_TSuccess GHOST_WindowSDL::setWindowCursorShape(GHOST_TStandardCursor shape) { - if(sdl_std_cursor_array[0] == NULL) { + if (sdl_std_cursor_array[0] == NULL) { sdl_cursor_init(); } @@ -605,14 +605,14 @@ GHOST_WindowSDL::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, int hotX, int hotY, int fg_color, int bg_color) { - if(m_sdl_custom_cursor) { + if (m_sdl_custom_cursor) { SDL_FreeCursor(m_sdl_custom_cursor); } - m_sdl_custom_cursor= sdl_ghost_CreateCursor((const Uint8 *)bitmap, - (const Uint8 *)mask, - sizex, sizex, - hotX, hotY); + m_sdl_custom_cursor = sdl_ghost_CreateCursor((const Uint8 *)bitmap, + (const Uint8 *)mask, + sizex, sizex, + hotX, hotY); SDL_SetCursor(m_sdl_custom_cursor); return GHOST_kSuccess; diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 3715da12cd6..81eefdfdc9c 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -55,8 +55,8 @@ #endif // Some more multisample defines -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 // win64 doesn't define GWL_USERDATA #ifdef WIN32 @@ -66,7 +66,7 @@ #endif #endif -wchar_t* GHOST_WindowWin32::s_windowClassName = L"GHOST_WindowClass"; +wchar_t *GHOST_WindowWin32::s_windowClassName = L"GHOST_WindowClass"; const int GHOST_WindowWin32::s_maxTitleLength = 128; HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL; HDC GHOST_WindowWin32::s_firstHDC = NULL; @@ -88,7 +88,7 @@ static PIXELFORMATDESCRIPTOR sPreferredFormat = { 1, /* version */ PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | - PFD_SWAP_COPY | /* support swap copy */ + PFD_SWAP_COPY | /* support swap copy */ PFD_DOUBLEBUFFER, /* support double-buffering */ PFD_TYPE_RGBA, /* color type */ 32, /* prefered color depth */ @@ -113,7 +113,7 @@ static PIXELFORMATDESCRIPTOR sPreferredFormat = { static int is_crappy_intel_card(void) { int crappy = 0; - const char *vendor = (const char*)glGetString(GL_VENDOR); + const char *vendor = (const char *)glGetString(GL_VENDOR); if (strstr(vendor, "Intel")) crappy = 1; @@ -122,22 +122,22 @@ static int is_crappy_intel_card(void) } GHOST_WindowWin32::GHOST_WindowWin32( - GHOST_SystemWin32 * system, - 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, - const GHOST_TUns16 numOfAASamples, - GHOST_TEmbedderWindowID parentwindowhwnd, - GHOST_TSuccess msEnabled, - int msPixelFormat) -: + GHOST_SystemWin32 *system, + 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, + const GHOST_TUns16 numOfAASamples, + GHOST_TEmbedderWindowID parentwindowhwnd, + GHOST_TSuccess msEnabled, + int msPixelFormat) + : GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone, - stereoVisual,numOfAASamples), + stereoVisual, numOfAASamples), m_system(system), m_hDC(0), m_hGlRc(0), @@ -170,15 +170,16 @@ GHOST_WindowWin32::GHOST_WindowWin32( versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - if(!GetVersionEx((OSVERSIONINFO *)&versionInfo)) { + if (!GetVersionEx((OSVERSIONINFO *)&versionInfo)) { versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if(GetVersionEx((OSVERSIONINFO*)&versionInfo)) { - if((versionInfo.dwMajorVersion==6 && versionInfo.dwMinorVersion>=1) || versionInfo.dwMajorVersion >= 7) { + if (GetVersionEx((OSVERSIONINFO *)&versionInfo)) { + if ((versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion >= 1) || versionInfo.dwMajorVersion >= 7) { hasMinVersionForTaskbar = true; } } - } else { - if((versionInfo.dwMajorVersion==6 && versionInfo.dwMinorVersion>=1) || versionInfo.dwMajorVersion >= 7) { + } + else { + if ((versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion >= 1) || versionInfo.dwMajorVersion >= 7) { hasMinVersionForTaskbar = true; } } @@ -188,41 +189,41 @@ GHOST_WindowWin32::GHOST_WindowWin32( MONITORINFO monitor; GHOST_TUns32 tw, th; - width += GetSystemMetrics(SM_CXSIZEFRAME)*2; - height += GetSystemMetrics(SM_CYSIZEFRAME)*2 + GetSystemMetrics(SM_CYCAPTION); + width += GetSystemMetrics(SM_CXSIZEFRAME) * 2; + height += GetSystemMetrics(SM_CYSIZEFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION); rect.left = left; rect.right = left + width; rect.top = top; rect.bottom = top + height; - monitor.cbSize=sizeof(monitor); - monitor.dwFlags=0; + monitor.cbSize = sizeof(monitor); + monitor.dwFlags = 0; // take taskbar into account - GetMonitorInfo(MonitorFromRect(&rect,MONITOR_DEFAULTTONEAREST),&monitor); + GetMonitorInfo(MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST), &monitor); th = monitor.rcWork.bottom - monitor.rcWork.top; tw = monitor.rcWork.right - monitor.rcWork.left; - if(tw < width) + if (tw < width) { width = tw; left = monitor.rcWork.left; } - else if(monitor.rcWork.right < left + (int)width) + else if (monitor.rcWork.right < left + (int)width) left = monitor.rcWork.right - width; - else if(left < monitor.rcWork.left) + else if (left < monitor.rcWork.left) left = monitor.rcWork.left; - if(th < height) + if (th < height) { height = th; top = monitor.rcWork.top; } - else if(monitor.rcWork.bottom < top + (int)height) + else if (monitor.rcWork.bottom < top + (int)height) top = monitor.rcWork.bottom - height; - else if(top < monitor.rcWork.top) + else if (top < monitor.rcWork.top) top = monitor.rcWork.top; int wintype = WS_OVERLAPPEDWINDOW; @@ -236,35 +237,35 @@ GHOST_WindowWin32::GHOST_WindowWin32( height = rect.bottom - rect.top; } - wchar_t * title_16 = alloc_utf16_from_8((char*)(const char*)title,0); + wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0); m_hWnd = ::CreateWindowW( - s_windowClassName, // pointer to registered class name - title_16, // pointer to window name - wintype, // window style - left, // horizontal position of window - top, // vertical position of window - width, // window width - height, // window height - (HWND) m_parentWindowHwnd, // handle to parent or owner window - 0, // handle to menu or child-window identifier - ::GetModuleHandle(0), // handle to application instance - 0); // pointer to window-creation data + s_windowClassName, // pointer to registered class name + title_16, // pointer to window name + wintype, // window style + left, // horizontal position of window + top, // vertical position of window + width, // window width + height, // window height + (HWND) m_parentWindowHwnd, // handle to parent or owner window + 0, // handle to menu or child-window identifier + ::GetModuleHandle(0), // handle to application instance + 0); // pointer to window-creation data free(title_16); } else { - wchar_t * title_16 = alloc_utf16_from_8((char*)(const char*)title,0); + wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0); m_hWnd = ::CreateWindowW( - s_windowClassName, // pointer to registered class name - title_16, // pointer to window name - WS_POPUP | WS_MAXIMIZE, // window style - left, // horizontal position of window - top, // vertical position of window - width, // window width - height, // window height - HWND_DESKTOP, // handle to parent or owner window - 0, // handle to menu or child-window identifier - ::GetModuleHandle(0), // handle to application instance - 0); // pointer to window-creation data + s_windowClassName, // pointer to registered class name + title_16, // pointer to window name + WS_POPUP | WS_MAXIMIZE, // window style + left, // horizontal position of window + top, // vertical position of window + width, // window width + height, // window height + HWND_DESKTOP, // handle to parent or owner window + 0, // handle to menu or child-window identifier + ::GetModuleHandle(0), // handle to application instance + 0); // pointer to window-creation data free(title_16); } if (m_hWnd) { @@ -272,12 +273,12 @@ GHOST_WindowWin32::GHOST_WindowWin32( // Note that OleInitialize(0) has to be called prior to this. Done in GHOST_SystemWin32. m_dropTarget = new GHOST_DropTargetWin32(this, m_system); // Store a pointer to this class in the window structure - ::SetWindowLongPtr(m_hWnd, GWL_USERDATA, (LONG_PTR)this); + ::SetWindowLongPtr(m_hWnd, GWL_USERDATA, (LONG_PTR) this); // Store the device context m_hDC = ::GetDC(m_hWnd); - if(!s_firstHDC) { + if (!s_firstHDC) { s_firstHDC = m_hDC; } @@ -304,8 +305,7 @@ GHOST_WindowWin32::GHOST_WindowWin32( // Force an initial paint of the window ::UpdateWindow(m_hWnd); } - else - { + else { //invalidate the window m_hWnd = 0; } @@ -313,8 +313,8 @@ GHOST_WindowWin32::GHOST_WindowWin32( if (parentwindowhwnd != 0) { RAWINPUTDEVICE device = {0}; - device.usUsagePage = 0x01; /* usUsagePage & usUsage for keyboard*/ - device.usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */ + device.usUsagePage = 0x01; /* usUsagePage & usUsage for keyboard*/ + device.usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */ device.dwFlags |= RIDEV_INPUTSINK; // makes WM_INPUT is visible for ghost when has parent window device.hwndTarget = m_hWnd; RegisterRawInputDevices(&device, 1, sizeof(device)); @@ -322,8 +322,8 @@ GHOST_WindowWin32::GHOST_WindowWin32( m_wintab = ::LoadLibrary("Wintab32.dll"); if (m_wintab) { - GHOST_WIN32_WTInfo fpWTInfo = ( GHOST_WIN32_WTInfo ) ::GetProcAddress( m_wintab, "WTInfoA" ); - GHOST_WIN32_WTOpen fpWTOpen = ( GHOST_WIN32_WTOpen ) ::GetProcAddress( m_wintab, "WTOpenA" ); + GHOST_WIN32_WTInfo fpWTInfo = (GHOST_WIN32_WTInfo) ::GetProcAddress(m_wintab, "WTInfoA"); + GHOST_WIN32_WTOpen fpWTOpen = (GHOST_WIN32_WTOpen) ::GetProcAddress(m_wintab, "WTOpenA"); // let's see if we can initialize tablet here /* check if WinTab available. */ @@ -335,7 +335,7 @@ GHOST_WindowWin32::GHOST_WindowWin32( // Open a Wintab context // Get default context information - fpWTInfo( WTI_DEFCONTEXT, 0, &lc ); + fpWTInfo(WTI_DEFCONTEXT, 0, &lc); // Open the context lc.lcPktData = PACKETDATA; @@ -343,18 +343,18 @@ GHOST_WindowWin32::GHOST_WindowWin32( lc.lcOptions |= CXO_MESSAGES | CXO_SYSTEM; /* Set the entire tablet as active */ - fpWTInfo(WTI_DEVICES,DVC_X,&TabletX); - fpWTInfo(WTI_DEVICES,DVC_Y,&TabletY); + fpWTInfo(WTI_DEVICES, DVC_X, &TabletX); + fpWTInfo(WTI_DEVICES, DVC_Y, &TabletY); /* get the max pressure, to divide into a float */ - BOOL pressureSupport = fpWTInfo (WTI_DEVICES, DVC_NPRESSURE, &Pressure); + BOOL pressureSupport = fpWTInfo(WTI_DEVICES, DVC_NPRESSURE, &Pressure); if (pressureSupport) m_maxPressure = Pressure.axMax; else m_maxPressure = 0; /* get the max tilt axes, to divide into floats */ - BOOL tiltSupport = fpWTInfo (WTI_DEVICES, DVC_ORIENTATION, &Orientation); + BOOL tiltSupport = fpWTInfo(WTI_DEVICES, DVC_ORIENTATION, &Orientation); if (tiltSupport) { /* does the tablet support azimuth ([0]) and altitude ([1]) */ if (Orientation[0].axResolution && Orientation[1].axResolution) { @@ -368,7 +368,7 @@ GHOST_WindowWin32::GHOST_WindowWin32( } if (fpWTOpen) { - m_tablet = fpWTOpen( m_hWnd, &lc, TRUE ); + m_tablet = fpWTOpen(m_hWnd, &lc, TRUE); if (m_tablet) { m_tabletData = new GHOST_TabletData(); m_tabletData->Active = GHOST_kTabletModeNone; @@ -377,29 +377,29 @@ GHOST_WindowWin32::GHOST_WindowWin32( } } - if(hasMinVersionForTaskbar) - CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList ,(LPVOID*)&m_Bar); + if (hasMinVersionForTaskbar) + CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (LPVOID *)&m_Bar); else - m_Bar=NULL; + m_Bar = NULL; } GHOST_WindowWin32::~GHOST_WindowWin32() { - if(m_Bar) + if (m_Bar) { m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS); m_Bar->Release(); }; if (m_wintab) { - GHOST_WIN32_WTClose fpWTClose = ( GHOST_WIN32_WTClose ) ::GetProcAddress( m_wintab, "WTClose" ); + GHOST_WIN32_WTClose fpWTClose = (GHOST_WIN32_WTClose) ::GetProcAddress(m_wintab, "WTClose"); if (fpWTClose) { if (m_tablet) fpWTClose(m_tablet); if (m_tabletData) delete m_tabletData; - m_tabletData = NULL; + m_tabletData = NULL; } } if (m_customCursor) { @@ -439,17 +439,17 @@ HWND GHOST_WindowWin32::getHWND() const void GHOST_WindowWin32::setTitle(const STR_String& title) { - wchar_t * title_16 = alloc_utf16_from_8((char*)(const char*)title, 0); - ::SetWindowTextW(m_hWnd, (wchar_t*)title_16); + wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0); + ::SetWindowTextW(m_hWnd, (wchar_t *)title_16); free(title_16); } void GHOST_WindowWin32::getTitle(STR_String& title) const { - char buf[s_maxTitleLength];/*CHANGE + never used yet*/ + char buf[s_maxTitleLength]; /*CHANGE + never used yet*/ ::GetWindowText(m_hWnd, buf, s_maxTitleLength); - STR_String temp (buf); + STR_String temp(buf); title = buf; } @@ -468,30 +468,33 @@ void GHOST_WindowWin32::getWindowBounds(GHOST_Rect& bounds) const void GHOST_WindowWin32::getClientBounds(GHOST_Rect& bounds) const { RECT rect; - GHOST_TWindowState state= this->getState(); + GHOST_TWindowState state = this->getState(); LONG_PTR result = ::GetWindowLongPtr(m_hWnd, GWL_STYLE); int sm_cysizeframe = GetSystemMetrics(SM_CYSIZEFRAME); ::GetWindowRect(m_hWnd, &rect); - if((result & (WS_POPUP | WS_MAXIMIZE)) != (WS_POPUP | WS_MAXIMIZE)) { - if(state==GHOST_kWindowStateMaximized) { + if ((result & (WS_POPUP | WS_MAXIMIZE)) != (WS_POPUP | WS_MAXIMIZE)) { + if (state == GHOST_kWindowStateMaximized) { // in maximized state we don't have borders on the window - bounds.m_b = rect.bottom-GetSystemMetrics(SM_CYCAPTION)- sm_cysizeframe*2; + bounds.m_b = rect.bottom - GetSystemMetrics(SM_CYCAPTION) - sm_cysizeframe * 2; bounds.m_l = rect.left + sm_cysizeframe; bounds.m_r = rect.right - sm_cysizeframe; bounds.m_t = rect.top; - } else if (state == GHOST_kWindowStateEmbedded) { + } + else if (state == GHOST_kWindowStateEmbedded) { bounds.m_b = rect.bottom; bounds.m_l = rect.left; bounds.m_r = rect.right; bounds.m_t = rect.top; - } else { - bounds.m_b = rect.bottom-GetSystemMetrics(SM_CYCAPTION)-sm_cysizeframe*2; + } + else { + bounds.m_b = rect.bottom - GetSystemMetrics(SM_CYCAPTION) - sm_cysizeframe * 2; bounds.m_l = rect.left; - bounds.m_r = rect.right-sm_cysizeframe*2; + bounds.m_r = rect.right - sm_cysizeframe * 2; bounds.m_t = rect.top; } - } else { + } + else { bounds.m_b = rect.bottom; bounds.m_l = rect.left; bounds.m_r = rect.right; @@ -510,7 +513,7 @@ GHOST_TSuccess GHOST_WindowWin32::setClientWidth(GHOST_TUns32 width) int cx = wBnds.getWidth() + width - cBnds.getWidth(); int cy = wBnds.getHeight(); success = ::SetWindowPos(m_hWnd, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ? - GHOST_kSuccess : GHOST_kFailure; + GHOST_kSuccess : GHOST_kFailure; } else { success = GHOST_kSuccess; @@ -529,7 +532,7 @@ GHOST_TSuccess GHOST_WindowWin32::setClientHeight(GHOST_TUns32 height) int cx = wBnds.getWidth(); int cy = wBnds.getHeight() + height - cBnds.getHeight(); success = ::SetWindowPos(m_hWnd, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ? - GHOST_kSuccess : GHOST_kFailure; + GHOST_kSuccess : GHOST_kFailure; } else { success = GHOST_kSuccess; @@ -548,7 +551,7 @@ GHOST_TSuccess GHOST_WindowWin32::setClientSize(GHOST_TUns32 width, GHOST_TUns32 int cx = wBnds.getWidth() + width - cBnds.getWidth(); int cy = wBnds.getHeight() + height - cBnds.getHeight(); success = ::SetWindowPos(m_hWnd, HWND_TOP, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER) ? - GHOST_kSuccess : GHOST_kFailure; + GHOST_kSuccess : GHOST_kFailure; } else { success = GHOST_kSuccess; @@ -574,7 +577,7 @@ GHOST_TWindowState GHOST_WindowWin32::getState() const } else if (::IsZoomed(m_hWnd)) { LONG_PTR result = ::GetWindowLongPtr(m_hWnd, GWL_STYLE); - if((result & (WS_POPUP | WS_MAXIMIZE)) != (WS_POPUP | WS_MAXIMIZE)) + if ((result & (WS_POPUP | WS_MAXIMIZE)) != (WS_POPUP | WS_MAXIMIZE)) state = GHOST_kWindowStateMaximized; else state = GHOST_kWindowStateFullScreen; @@ -614,29 +617,29 @@ GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state) if (state == GHOST_kWindowStateNormal) state = m_normal_state; switch (state) { - case GHOST_kWindowStateMinimized: - wp.showCmd = SW_SHOWMINIMIZED; - break; - case GHOST_kWindowStateMaximized: - wp.showCmd = SW_SHOWMAXIMIZED; - SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); - break; - case GHOST_kWindowStateFullScreen: - if (curstate != state && curstate != GHOST_kWindowStateMinimized) - m_normal_state = curstate; - wp.showCmd = SW_SHOWMAXIMIZED; - wp.ptMaxPosition.x = 0; - wp.ptMaxPosition.y = 0; - SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_POPUP | WS_MAXIMIZE); - break; - case GHOST_kWindowStateEmbedded: - SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_CHILD); - break; - case GHOST_kWindowStateNormal: - default: - wp.showCmd = SW_SHOWNORMAL; - SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); - break; + case GHOST_kWindowStateMinimized: + wp.showCmd = SW_SHOWMINIMIZED; + break; + case GHOST_kWindowStateMaximized: + wp.showCmd = SW_SHOWMAXIMIZED; + SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); + break; + case GHOST_kWindowStateFullScreen: + if (curstate != state && curstate != GHOST_kWindowStateMinimized) + m_normal_state = curstate; + wp.showCmd = SW_SHOWMAXIMIZED; + wp.ptMaxPosition.x = 0; + wp.ptMaxPosition.y = 0; + SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_POPUP | WS_MAXIMIZE); + break; + case GHOST_kWindowStateEmbedded: + SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_CHILD); + break; + case GHOST_kWindowStateNormal: + default: + wp.showCmd = SW_SHOWNORMAL; + SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); + break; } SetWindowPos(m_hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); /*Clears window cache for SetWindowLongPtr */ return ::SetWindowPlacement(m_hWnd, &wp) == TRUE ? GHOST_kSuccess : GHOST_kFailure; @@ -737,7 +740,7 @@ GHOST_TSuccess GHOST_WindowWin32::initMultisample(PIXELFORMATDESCRIPTOR pfd) iAttributes[17] -= 1; success = GHOST_kFailure; } - if (m_multisampleEnabled == GHOST_kSuccess) { + if (m_multisampleEnabled == GHOST_kSuccess) { return GHOST_kSuccess; } GHOST_PRINT("no available pixel format\n"); @@ -748,43 +751,47 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp { GHOST_TSuccess success; switch (type) { - case GHOST_kDrawingContextTypeOpenGL: - { - // If this window has multisample enabled, use the supplied format - if (m_multisampleEnabled) + case GHOST_kDrawingContextTypeOpenGL: { - if (SetPixelFormat(m_hDC, m_msPixelFormat, &sPreferredFormat)==FALSE) + // If this window has multisample enabled, use the supplied format + if (m_multisampleEnabled) { - success = GHOST_kFailure; - break; - } + if (SetPixelFormat(m_hDC, m_msPixelFormat, &sPreferredFormat) == FALSE) + { + success = GHOST_kFailure; + break; + } - // Create the context - m_hGlRc = ::wglCreateContext(m_hDC); - if (m_hGlRc) { - if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) { - if (s_firsthGLRc) { - if (is_crappy_intel_card()) { - if (::wglMakeCurrent(NULL, NULL) == TRUE) { - ::wglDeleteContext(m_hGlRc); - m_hGlRc = s_firsthGLRc; + // Create the context + m_hGlRc = ::wglCreateContext(m_hDC); + if (m_hGlRc) { + if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) { + if (s_firsthGLRc) { + if (is_crappy_intel_card()) { + if (::wglMakeCurrent(NULL, NULL) == TRUE) { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = s_firsthGLRc; + } + else { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = NULL; + } } else { - ::wglDeleteContext(m_hGlRc); - m_hGlRc = NULL; + ::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS); + ::wglShareLists(s_firsthGLRc, m_hGlRc); } } else { - ::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS); - ::wglShareLists(s_firsthGLRc, m_hGlRc); + s_firsthGLRc = m_hGlRc; } - } - else { - s_firsthGLRc = m_hGlRc; - } - if (m_hGlRc) { - success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + if (m_hGlRc) { + success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + success = GHOST_kFailure; + } } else { success = GHOST_kFailure; @@ -793,59 +800,58 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp else { success = GHOST_kFailure; } - } - else { - success = GHOST_kFailure; - } - if (success == GHOST_kFailure) { - printf("Failed to get a context....\n"); + if (success == GHOST_kFailure) { + printf("Failed to get a context....\n"); + } } - } - else - { - if(m_stereoVisual) - sPreferredFormat.dwFlags |= PFD_STEREO; + else { + if (m_stereoVisual) + sPreferredFormat.dwFlags |= PFD_STEREO; - // Attempt to match device context pixel format to the preferred format - int iPixelFormat = EnumPixelFormats(m_hDC); - if (iPixelFormat == 0) { - success = GHOST_kFailure; - break; - } - if (::SetPixelFormat(m_hDC, iPixelFormat, &sPreferredFormat) == FALSE) { - success = GHOST_kFailure; - break; - } - // For debugging only: retrieve the pixel format chosen - PIXELFORMATDESCRIPTOR preferredFormat; - ::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat); - - // Create the context - m_hGlRc = ::wglCreateContext(m_hDC); - if (m_hGlRc) { - if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) { - if (s_firsthGLRc) { - if (is_crappy_intel_card()) { - if (::wglMakeCurrent(NULL, NULL) == TRUE) { - ::wglDeleteContext(m_hGlRc); - m_hGlRc = s_firsthGLRc; + // Attempt to match device context pixel format to the preferred format + int iPixelFormat = EnumPixelFormats(m_hDC); + if (iPixelFormat == 0) { + success = GHOST_kFailure; + break; + } + if (::SetPixelFormat(m_hDC, iPixelFormat, &sPreferredFormat) == FALSE) { + success = GHOST_kFailure; + break; + } + // For debugging only: retrieve the pixel format chosen + PIXELFORMATDESCRIPTOR preferredFormat; + ::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat); + + // Create the context + m_hGlRc = ::wglCreateContext(m_hDC); + if (m_hGlRc) { + if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) { + if (s_firsthGLRc) { + if (is_crappy_intel_card()) { + if (::wglMakeCurrent(NULL, NULL) == TRUE) { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = s_firsthGLRc; + } + else { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = NULL; + } } else { - ::wglDeleteContext(m_hGlRc); - m_hGlRc = NULL; + ::wglShareLists(s_firsthGLRc, m_hGlRc); } } else { - ::wglShareLists(s_firsthGLRc, m_hGlRc); + s_firsthGLRc = m_hGlRc; } - } - else { - s_firsthGLRc = m_hGlRc; - } - if (m_hGlRc) { - success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + if (m_hGlRc) { + success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + success = GHOST_kFailure; + } } else { success = GHOST_kFailure; @@ -854,66 +860,63 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp else { success = GHOST_kFailure; } - } - else { - success = GHOST_kFailure; - } - - if (success == GHOST_kFailure) { - printf("Failed to get a context....\n"); - } - // Attempt to enable multisample - if (m_multisample && WGL_ARB_multisample && !m_multisampleEnabled) - { - success = initMultisample(preferredFormat); + if (success == GHOST_kFailure) { + printf("Failed to get a context....\n"); + } - if (success) + // Attempt to enable multisample + if (m_multisample && WGL_ARB_multisample && !m_multisampleEnabled) { - - // Make sure we don't screw up the context - if (m_hGlRc == s_firsthGLRc) - s_firsthGLRc = NULL; - m_drawingContextType = GHOST_kDrawingContextTypeOpenGL; - removeDrawingContext(); - - // Create a new window - GHOST_TWindowState new_state = getState(); - - m_nextWindow = new GHOST_WindowWin32((GHOST_SystemWin32*)GHOST_ISystem::getSystem(), - m_title, - m_left, - m_top, - m_width, - m_height, - new_state, - type, - m_stereo, - m_multisample, - m_parentWindowHwnd, - m_multisampleEnabled, - m_msPixelFormat); - - // Return failure so we can trash this window. - success = GHOST_kFailure; - break; - } else { - m_multisampleEnabled = GHOST_kSuccess; - printf("Multisample failed to initialized\n"); - success = GHOST_kSuccess; + success = initMultisample(preferredFormat); + + if (success) + { + + // Make sure we don't screw up the context + if (m_hGlRc == s_firsthGLRc) + s_firsthGLRc = NULL; + m_drawingContextType = GHOST_kDrawingContextTypeOpenGL; + removeDrawingContext(); + + // Create a new window + GHOST_TWindowState new_state = getState(); + + m_nextWindow = new GHOST_WindowWin32((GHOST_SystemWin32 *)GHOST_ISystem::getSystem(), + m_title, + m_left, + m_top, + m_width, + m_height, + new_state, + type, + m_stereo, + m_multisample, + m_parentWindowHwnd, + m_multisampleEnabled, + m_msPixelFormat); + + // Return failure so we can trash this window. + success = GHOST_kFailure; + break; + } + else { + m_multisampleEnabled = GHOST_kSuccess; + printf("Multisample failed to initialized\n"); + success = GHOST_kSuccess; + } } } - } } break; - case GHOST_kDrawingContextTypeNone: - success = GHOST_kSuccess; - break; + case GHOST_kDrawingContextTypeNone: + success = GHOST_kSuccess; + break; - default: - success = GHOST_kFailure; + default: + success = GHOST_kFailure; } return success; } @@ -922,55 +925,54 @@ GHOST_TSuccess GHOST_WindowWin32::removeDrawingContext() { GHOST_TSuccess success; switch (m_drawingContextType) { - case GHOST_kDrawingContextTypeOpenGL: - // we shouldn't remove the drawing context if it's the first OpenGL context - // If we do, we get corrupted drawing. See #19997 - if (m_hGlRc && m_hGlRc!=s_firsthGLRc) { - success = ::wglDeleteContext(m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; - m_hGlRc = 0; - } - else { + case GHOST_kDrawingContextTypeOpenGL: + // we shouldn't remove the drawing context if it's the first OpenGL context + // If we do, we get corrupted drawing. See #19997 + if (m_hGlRc && m_hGlRc != s_firsthGLRc) { + success = ::wglDeleteContext(m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + m_hGlRc = 0; + } + else { + success = GHOST_kFailure; + } + break; + case GHOST_kDrawingContextTypeNone: + success = GHOST_kSuccess; + break; + default: success = GHOST_kFailure; - } - break; - case GHOST_kDrawingContextTypeNone: - success = GHOST_kSuccess; - break; - default: - success = GHOST_kFailure; } return success; } void GHOST_WindowWin32::lostMouseCapture() { - if(m_hasMouseCaptured) - { m_hasGrabMouse = false; - m_nPressedButtons = 0; - m_hasMouseCaptured = false; - }; + if (m_hasMouseCaptured) + { m_hasGrabMouse = false; + m_nPressedButtons = 0; + m_hasMouseCaptured = false; }; } void GHOST_WindowWin32::registerMouseClickEvent(int press) { - switch(press) + switch (press) { - case 0: m_nPressedButtons++; break; - case 1: if(m_nPressedButtons) m_nPressedButtons--; break; - case 2: m_hasGrabMouse=true; break; - case 3: m_hasGrabMouse=false; break; + case 0: m_nPressedButtons++; break; + case 1: if (m_nPressedButtons) m_nPressedButtons--; break; + case 2: m_hasGrabMouse = true; break; + case 3: m_hasGrabMouse = false; break; } - if(!m_nPressedButtons && !m_hasGrabMouse && m_hasMouseCaptured) + if (!m_nPressedButtons && !m_hasGrabMouse && m_hasMouseCaptured) { - ::ReleaseCapture(); - m_hasMouseCaptured = false; + ::ReleaseCapture(); + m_hasMouseCaptured = false; } - else if((m_nPressedButtons || m_hasGrabMouse) && !m_hasMouseCaptured) + else if ((m_nPressedButtons || m_hasGrabMouse) && !m_hasMouseCaptured) { - ::SetCapture(m_hWnd); - m_hasMouseCaptured = true; + ::SetCapture(m_hWnd); + m_hasMouseCaptured = true; } } @@ -979,43 +981,44 @@ void GHOST_WindowWin32::registerMouseClickEvent(int press) void GHOST_WindowWin32::loadCursor(bool visible, GHOST_TStandardCursor cursor) const { if (!visible) { - while (::ShowCursor(FALSE) >= 0); + while (::ShowCursor(FALSE) >= 0) ; } else { - while (::ShowCursor(TRUE) < 0); + while (::ShowCursor(TRUE) < 0) ; } if (cursor == GHOST_kStandardCursorCustom && m_customCursor) { - ::SetCursor( m_customCursor ); - } else { + ::SetCursor(m_customCursor); + } + else { // Convert GHOST cursor to Windows OEM cursor bool success = true; LPCSTR id; switch (cursor) { - case GHOST_kStandardCursorDefault: id = IDC_ARROW; break; - case GHOST_kStandardCursorRightArrow: id = IDC_ARROW; break; - case GHOST_kStandardCursorLeftArrow: id = IDC_ARROW; break; - case GHOST_kStandardCursorInfo: id = IDC_SIZEALL; break; // Four-pointed arrow pointing north, south, east, and west - case GHOST_kStandardCursorDestroy: id = IDC_NO; break; // Slashed circle - case GHOST_kStandardCursorHelp: id = IDC_HELP; break; // Arrow and question mark - case GHOST_kStandardCursorCycle: id = IDC_NO; break; // Slashed circle - case GHOST_kStandardCursorSpray: id = IDC_SIZEALL; break; // Four-pointed arrow pointing north, south, east, and west - case GHOST_kStandardCursorWait: id = IDC_WAIT; break; // Hourglass - case GHOST_kStandardCursorText: id = IDC_IBEAM; break; // I-beam - case GHOST_kStandardCursorCrosshair: id = IDC_CROSS; break; // Crosshair - case GHOST_kStandardCursorUpDown: id = IDC_SIZENS; break; // Double-pointed arrow pointing north and south - case GHOST_kStandardCursorLeftRight: id = IDC_SIZEWE; break; // Double-pointed arrow pointing west and east - case GHOST_kStandardCursorTopSide: id = IDC_UPARROW; break; // Vertical arrow - case GHOST_kStandardCursorBottomSide: id = IDC_SIZENS; break; - case GHOST_kStandardCursorLeftSide: id = IDC_SIZEWE; break; - case GHOST_kStandardCursorTopLeftCorner: id = IDC_SIZENWSE; break; - case GHOST_kStandardCursorTopRightCorner: id = IDC_SIZENESW; break; - case GHOST_kStandardCursorBottomRightCorner: id = IDC_SIZENWSE; break; - case GHOST_kStandardCursorBottomLeftCorner: id = IDC_SIZENESW; break; - case GHOST_kStandardCursorPencil: id = IDC_ARROW; break; - case GHOST_kStandardCursorCopy: id = IDC_ARROW; break; + case GHOST_kStandardCursorDefault: id = IDC_ARROW; break; + case GHOST_kStandardCursorRightArrow: id = IDC_ARROW; break; + case GHOST_kStandardCursorLeftArrow: id = IDC_ARROW; break; + case GHOST_kStandardCursorInfo: id = IDC_SIZEALL; break; // Four-pointed arrow pointing north, south, east, and west + case GHOST_kStandardCursorDestroy: id = IDC_NO; break; // Slashed circle + case GHOST_kStandardCursorHelp: id = IDC_HELP; break; // Arrow and question mark + case GHOST_kStandardCursorCycle: id = IDC_NO; break; // Slashed circle + case GHOST_kStandardCursorSpray: id = IDC_SIZEALL; break; // Four-pointed arrow pointing north, south, east, and west + case GHOST_kStandardCursorWait: id = IDC_WAIT; break; // Hourglass + case GHOST_kStandardCursorText: id = IDC_IBEAM; break; // I-beam + case GHOST_kStandardCursorCrosshair: id = IDC_CROSS; break; // Crosshair + case GHOST_kStandardCursorUpDown: id = IDC_SIZENS; break; // Double-pointed arrow pointing north and south + case GHOST_kStandardCursorLeftRight: id = IDC_SIZEWE; break; // Double-pointed arrow pointing west and east + case GHOST_kStandardCursorTopSide: id = IDC_UPARROW; break; // Vertical arrow + case GHOST_kStandardCursorBottomSide: id = IDC_SIZENS; break; + case GHOST_kStandardCursorLeftSide: id = IDC_SIZEWE; break; + case GHOST_kStandardCursorTopLeftCorner: id = IDC_SIZENWSE; break; + case GHOST_kStandardCursorTopRightCorner: id = IDC_SIZENESW; break; + case GHOST_kStandardCursorBottomRightCorner: id = IDC_SIZENWSE; break; + case GHOST_kStandardCursorBottomLeftCorner: id = IDC_SIZENESW; break; + case GHOST_kStandardCursorPencil: id = IDC_ARROW; break; + case GHOST_kStandardCursorCopy: id = IDC_ARROW; break; default: - success = false; + success = false; } if (success) { @@ -1035,22 +1038,22 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCursorVisibility(bool visible) GHOST_TSuccess GHOST_WindowWin32::setWindowCursorGrab(GHOST_TGrabCursorMode mode) { - if(mode != GHOST_kGrabDisable) { - if(mode != GHOST_kGrabNormal) { + if (mode != GHOST_kGrabDisable) { + if (mode != GHOST_kGrabNormal) { m_system->getCursorPosition(m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]); setCursorGrabAccum(0, 0); - if(mode == GHOST_kGrabHide) + if (mode == GHOST_kGrabHide) setWindowCursorVisibility(false); } registerMouseClickEvent(2); } else { - if (m_cursorGrab==GHOST_kGrabHide) { + if (m_cursorGrab == GHOST_kGrabHide) { m_system->setCursorPosition(m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]); setWindowCursorVisibility(true); } - if(m_cursorGrab != GHOST_kGrabNormal) { + if (m_cursorGrab != GHOST_kGrabNormal) { /* use to generate a mouse move event, otherwise the last event * blender gets can be outside the screen causing menus not to show * properly unless the user moves the mouse */ @@ -1061,7 +1064,7 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCursorGrab(GHOST_TGrabCursorMode mode /* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */ setCursorGrabAccum(0, 0); - m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; /* disable */ + m_cursorGrabBounds.m_l = m_cursorGrabBounds.m_r = -1; /* disable */ registerMouseClickEvent(3); } @@ -1085,20 +1088,20 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCursorShape(GHOST_TStandardCursor cur void GHOST_WindowWin32::processWin32TabletInitEvent() { if (m_wintab) { - GHOST_WIN32_WTInfo fpWTInfo = ( GHOST_WIN32_WTInfo ) ::GetProcAddress( m_wintab, "WTInfoA" ); + GHOST_WIN32_WTInfo fpWTInfo = (GHOST_WIN32_WTInfo) ::GetProcAddress(m_wintab, "WTInfoA"); // let's see if we can initialize tablet here /* check if WinTab available. */ if (fpWTInfo) { AXIS Pressure, Orientation[3]; /* The maximum tablet size */ - BOOL pressureSupport = fpWTInfo (WTI_DEVICES, DVC_NPRESSURE, &Pressure); + BOOL pressureSupport = fpWTInfo(WTI_DEVICES, DVC_NPRESSURE, &Pressure); if (pressureSupport) m_maxPressure = Pressure.axMax; else m_maxPressure = 0; - BOOL tiltSupport = fpWTInfo (WTI_DEVICES, DVC_ORIENTATION, &Orientation); + BOOL tiltSupport = fpWTInfo(WTI_DEVICES, DVC_ORIENTATION, &Orientation); if (tiltSupport) { /* does the tablet support azimuth ([0]) and altitude ([1]) */ if (Orientation[0].axResolution && Orientation[1].axResolution) { @@ -1119,7 +1122,7 @@ void GHOST_WindowWin32::processWin32TabletEvent(WPARAM wParam, LPARAM lParam) { PACKET pkt; if (m_wintab) { - GHOST_WIN32_WTPacket fpWTPacket = ( GHOST_WIN32_WTPacket ) ::GetProcAddress( m_wintab, "WTPacket" ); + GHOST_WIN32_WTPacket fpWTPacket = (GHOST_WIN32_WTPacket) ::GetProcAddress(m_wintab, "WTPacket"); if (fpWTPacket) { if (fpWTPacket((HCTX)lParam, wParam, &pkt)) { if (m_tabletData) { @@ -1139,43 +1142,45 @@ void GHOST_WindowWin32::processWin32TabletEvent(WPARAM wParam, LPARAM lParam) } if (m_maxPressure > 0) { m_tabletData->Pressure = (float)pkt.pkNormalPressure / (float)m_maxPressure; - } else { + } + else { m_tabletData->Pressure = 1.0f; } if ((m_maxAzimuth > 0) && (m_maxAltitude > 0)) { ORIENTATION ort = pkt.pkOrientation; float vecLen; - float altRad, azmRad; /* in radians */ + float altRad, azmRad; /* in radians */ /* - from the wintab spec: - orAzimuth Specifies the clockwise rotation of the - cursor about the z axis through a full circular range. - - orAltitude Specifies the angle with the x-y plane - through a signed, semicircular range. Positive values - specify an angle upward toward the positive z axis; - negative values specify an angle downward toward the negative z axis. - - wintab.h defines .orAltitude as a UINT but documents .orAltitude - as positive for upward angles and negative for downward angles. - WACOM uses negative altitude values to show that the pen is inverted; - therefore we cast .orAltitude as an (int) and then use the absolute value. - */ + * from the wintab spec: + * orAzimuth Specifies the clockwise rotation of the + * cursor about the z axis through a full circular range. + * + * orAltitude Specifies the angle with the x-y plane + * through a signed, semicircular range. Positive values + * specify an angle upward toward the positive z axis; + * negative values specify an angle downward toward the negative z axis. + * + * wintab.h defines .orAltitude as a UINT but documents .orAltitude + * as positive for upward angles and negative for downward angles. + * WACOM uses negative altitude values to show that the pen is inverted; + * therefore we cast .orAltitude as an (int) and then use the absolute value. + */ /* convert raw fixed point data to radians */ - altRad = (float)((fabs((float)ort.orAltitude)/(float)m_maxAltitude) * M_PI/2.0); - azmRad = (float)(((float)ort.orAzimuth/(float)m_maxAzimuth) * M_PI*2.0); + altRad = (float)((fabs((float)ort.orAltitude) / (float)m_maxAltitude) * M_PI / 2.0); + azmRad = (float)(((float)ort.orAzimuth / (float)m_maxAzimuth) * M_PI * 2.0); /* find length of the stylus' projected vector on the XY plane */ vecLen = cos(altRad); /* from there calculate X and Y components based on azimuth */ m_tabletData->Xtilt = sin(azmRad) * vecLen; - m_tabletData->Ytilt = (float)(sin(M_PI/2.0 - azmRad) * vecLen); + m_tabletData->Ytilt = (float)(sin(M_PI / 2.0 - azmRad) * vecLen); - } else { + } + else { m_tabletData->Xtilt = 0.0f; m_tabletData->Ytilt = 0.0f; } @@ -1188,40 +1193,40 @@ void GHOST_WindowWin32::processWin32TabletEvent(WPARAM wParam, LPARAM lParam) /** Reverse the bits in a GHOST_TUns8 */ static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch) { - ch= ((ch>>1)&0x55) | ((ch<<1)&0xAA); - ch= ((ch>>2)&0x33) | ((ch<<2)&0xCC); - ch= ((ch>>4)&0x0F) | ((ch<<4)&0xF0); + ch = ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA); + ch = ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC); + ch = ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0); return ch; } /** Reverse the bits in a GHOST_TUns16 */ static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt) { - shrt= ((shrt>>1)&0x5555) | ((shrt<<1)&0xAAAA); - shrt= ((shrt>>2)&0x3333) | ((shrt<<2)&0xCCCC); - shrt= ((shrt>>4)&0x0F0F) | ((shrt<<4)&0xF0F0); - shrt= ((shrt>>8)&0x00FF) | ((shrt<<8)&0xFF00); + shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA); + shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC); + shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0); + shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00); return shrt; } GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY) { - return setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*)mask, + return setWindowCustomCursorShape((GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 16, 16, hotX, hotY, 0, 1); } GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, - GHOST_TUns8 *mask, int sizeX, int sizeY, int hotX, int hotY, - int fg_color, int bg_color) + GHOST_TUns8 *mask, int sizeX, int sizeY, int hotX, int hotY, + int fg_color, int bg_color) { GHOST_TUns32 andData[32]; GHOST_TUns32 xorData[32]; GHOST_TUns32 fullBitRow, fullMaskRow; int x, y, cols; - cols=sizeX/8; /* Num of whole bytes per row (width of bm/mask) */ - if (sizeX%8) cols++; + cols = sizeX / 8; /* Num of whole bytes per row (width of bm/mask) */ + if (sizeX % 8) cols++; if (m_customCursor) { DestroyCursor(m_customCursor); @@ -1231,17 +1236,17 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap memset(&andData, 0xFF, sizeof(andData)); memset(&xorData, 0, sizeof(xorData)); - for (y=0; y<sizeY; y++) { - fullBitRow=0; - fullMaskRow=0; - for (x=cols-1; x>=0; x--){ - fullBitRow<<=8; - fullMaskRow<<=8; - fullBitRow |= uns8ReverseBits(bitmap[cols*y + x]); - fullMaskRow |= uns8ReverseBits( mask[cols*y + x]); + for (y = 0; y < sizeY; y++) { + fullBitRow = 0; + fullMaskRow = 0; + for (x = cols - 1; x >= 0; x--) { + fullBitRow <<= 8; + fullMaskRow <<= 8; + fullBitRow |= uns8ReverseBits(bitmap[cols * y + x]); + fullMaskRow |= uns8ReverseBits(mask[cols * y + x]); } - xorData[y]= fullBitRow & fullMaskRow; - andData[y]= ~fullMaskRow; + xorData[y] = fullBitRow & fullMaskRow; + andData[y] = ~fullMaskRow; } m_customCursor = ::CreateCursor(::GetModuleHandle(0), hotX, hotY, 32, 32, andData, xorData); @@ -1260,7 +1265,7 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap GHOST_TSuccess GHOST_WindowWin32::setProgressBar(float progress) { /*SetProgressValue sets state to TBPF_NORMAL automaticly*/ - if(m_Bar && S_OK == m_Bar->SetProgressValue(m_hWnd,10000*progress,10000)) + if (m_Bar && S_OK == m_Bar->SetProgressValue(m_hWnd, 10000 * progress, 10000)) return GHOST_kSuccess; return GHOST_kFailure; @@ -1268,14 +1273,14 @@ GHOST_TSuccess GHOST_WindowWin32::setProgressBar(float progress) GHOST_TSuccess GHOST_WindowWin32::endProgressBar() { - if(m_Bar && S_OK == m_Bar->SetProgressState(m_hWnd,TBPF_NOPROGRESS)) + if (m_Bar && S_OK == m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS)) return GHOST_kSuccess; return GHOST_kFailure; } /* Ron Fosner's code for weighting pixel formats and forcing software. - See http://www.opengl.org/resources/faq/technical/weight.cpp */ + See http://www.opengl.org/resources/faq/technical/weight.cpp */ static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd) { @@ -1285,12 +1290,14 @@ static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd) /* cull unusable pixel formats */ /* if no formats can be found, can we determine why it was rejected? */ - if( !(pfd.dwFlags & PFD_SUPPORT_OPENGL) || - !(pfd.dwFlags & PFD_DRAW_TO_WINDOW) || - !(pfd.dwFlags & PFD_DOUBLEBUFFER) || /* Blender _needs_ this */ - ( pfd.cDepthBits <= 8 ) || - !(pfd.iPixelType == PFD_TYPE_RGBA)) + if (!(pfd.dwFlags & PFD_SUPPORT_OPENGL) || + !(pfd.dwFlags & PFD_DRAW_TO_WINDOW) || + !(pfd.dwFlags & PFD_DOUBLEBUFFER) || /* Blender _needs_ this */ + (pfd.cDepthBits <= 8) || + !(pfd.iPixelType == PFD_TYPE_RGBA)) + { return 0; + } weight = 1; /* it's usable */ @@ -1301,10 +1308,10 @@ static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd) weight += pfd.cColorBits - 8; /* want swap copy capability -- it matters a lot */ - if(pfd.dwFlags & PFD_SWAP_COPY) weight += 16; + if (pfd.dwFlags & PFD_SWAP_COPY) weight += 16; /* but if it's a generic (not accelerated) view, it's really bad */ - if(pfd.dwFlags & PFD_GENERIC_FORMAT) weight /= 10; + if (pfd.dwFlags & PFD_GENERIC_FORMAT) weight /= 10; return weight; } @@ -1318,27 +1325,27 @@ static int EnumPixelFormats(HDC hdc) PIXELFORMATDESCRIPTOR pfd; /* we need a device context to do anything */ - if(!hdc) return 0; + if (!hdc) return 0; iPixelFormat = 1; /* careful! PFD numbers are 1 based, not zero based */ /* obtain detailed information about - the device context's first pixel format */ - n = 1+::DescribePixelFormat(hdc, iPixelFormat, - sizeof(PIXELFORMATDESCRIPTOR), &pfd); + * the device context's first pixel format */ + n = 1 + ::DescribePixelFormat(hdc, iPixelFormat, + sizeof(PIXELFORMATDESCRIPTOR), &pfd); /* choose a pixel format using the useless Windows function in case - we come up empty handed */ - iPixelFormat = ::ChoosePixelFormat( hdc, &sPreferredFormat ); + we come up empty handed */ + iPixelFormat = ::ChoosePixelFormat(hdc, &sPreferredFormat); - if(!iPixelFormat) return 0; /* couldn't find one to use */ + if (!iPixelFormat) return 0; /* couldn't find one to use */ - for(i=1; i<=n; i++) { /* not the idiom, but it's right */ - ::DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd ); + for (i = 1; i <= n; i++) { /* not the idiom, but it's right */ + ::DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); w = WeightPixelFormat(pfd); // be strict on stereo - if (!((sPreferredFormat.dwFlags ^ pfd.dwFlags) & PFD_STEREO)) { - if(w > weight) { + if (!((sPreferredFormat.dwFlags ^ pfd.dwFlags) & PFD_STEREO)) { + if (w > weight) { weight = w; iPixelFormat = i; } @@ -1346,10 +1353,10 @@ static int EnumPixelFormats(HDC hdc) } if (weight == 0) { // we could find the correct stereo setting, just find any suitable format - for(i=1; i<=n; i++) { /* not the idiom, but it's right */ - ::DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd ); + for (i = 1; i <= n; i++) { /* not the idiom, but it's right */ + ::DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); w = WeightPixelFormat(pfd); - if(w > weight) { + if (w > weight) { weight = w; iPixelFormat = i; } diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 12990064621..1f4111c8cf3 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -271,11 +271,11 @@ GHOST_WindowX11( // Specify which events we are interested in hearing. xattributes.event_mask = - ExposureMask | StructureNotifyMask | - KeyPressMask | KeyReleaseMask | - EnterWindowMask | LeaveWindowMask | - ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | FocusChangeMask | PropertyChangeMask; + ExposureMask | StructureNotifyMask | + KeyPressMask | KeyReleaseMask | + EnterWindowMask | LeaveWindowMask | + ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | FocusChangeMask | PropertyChangeMask; // create the window! @@ -833,12 +833,12 @@ clientToScreen( Window temp; XTranslateCoordinates( - m_display, - m_window, - RootWindow(m_display, m_visual->screen), - inX, inY, - &ax, &ay, - &temp); + m_display, + m_window, + RootWindow(m_display, m_visual->screen), + inX, inY, + &ax, &ay, + &temp); outX = ax; outY = ay; } diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp index 1822f3539bd..2e8a9e88fd1 100644 --- a/intern/ghost/test/gears/GHOST_Test.cpp +++ b/intern/ghost/test/gears/GHOST_Test.cpp @@ -46,7 +46,7 @@ #include <GL/gl.h> #else // WIN32 - // __APPLE__ is defined + // __APPLE__ is defined #include <AGL/gl.h> #endif // WIN32 #else // defined(WIN32) || defined(__APPLE__) @@ -66,20 +66,20 @@ static bool nVidiaWindows; // very dirty but hey, it's for testing only -static void gearsTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time); +static void gearsTimerProc(GHOST_ITimerTask *task, GHOST_TUns64 time); -static class Application* fApp; -static GLfloat view_rotx=20.0, view_roty=30.0, view_rotz=0.0; +static class Application * fApp; +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; static GLfloat fAngle = 0.0; -static GHOST_ISystem* fSystem = 0; +static GHOST_ISystem *fSystem = 0; void StereoProjection(float left, float right, float bottom, float top, float nearplane, float farplane, - float zero_plane, float dist, - float eye); + float zero_plane, float dist, + float eye); -static void testTimerProc(GHOST_ITimerTask* /*task*/, GHOST_TUns64 time) +static void testTimerProc(GHOST_ITimerTask * /*task*/, GHOST_TUns64 time) { std::cout << "timer1, time=" << (int)time << "\n"; } @@ -93,35 +93,35 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL GLfloat u, v, len; r0 = inner_radius; - r1 = outer_radius - tooth_depth/2.0; - r2 = outer_radius + tooth_depth/2.0; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; const double pi = 3.14159264; - da = 2.0*pi / teeth / 4.0; + da = 2.0 * pi / teeth / 4.0; glShadeModel(GL_FLAT); glNormal3f(0.0, 0.0, 1.0); /* draw front face */ glBegin(GL_QUAD_STRIP); - for (i=0;i<=teeth;i++) { - angle = i * 2.0*pi / teeth; - glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5); - glVertex3f(r1*cos(angle), r1*sin(angle), width*0.5); - glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5); - glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * pi / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); } glEnd(); /* draw front sides of teeth */ glBegin(GL_QUADS); - da = 2.0*pi / teeth / 4.0; - for (i=0;i<teeth;i++) { - angle = i * 2.0*pi / teeth; - glVertex3f(r1*cos(angle), r1*sin(angle), width*0.5); - glVertex3f(r2*cos(angle+da), r2*sin(angle+da), width*0.5); - glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5); - glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5); + da = 2.0 * pi / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * pi / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); } glEnd(); @@ -129,64 +129,64 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL /* draw back face */ glBegin(GL_QUAD_STRIP); - for (i=0;i<=teeth;i++) { - angle = i * 2.0*pi / teeth; - glVertex3f(r1*cos(angle), r1*sin(angle), -width*0.5); - glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5); - glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5); - glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * pi / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); } glEnd(); /* draw back sides of teeth */ glBegin(GL_QUADS); - da = 2.0*pi / teeth / 4.0; - for (i=0;i<teeth;i++) { - angle = i * 2.0*pi / teeth; - glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5); - glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), -width*0.5); - glVertex3f(r2*cos(angle+da), r2*sin(angle+da), -width*0.5); - glVertex3f(r1*cos(angle), r1*sin(angle), -width*0.5); + da = 2.0 * pi / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * pi / teeth; + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); } glEnd(); /* draw outward faces of teeth */ glBegin(GL_QUAD_STRIP); - for (i=0;i<teeth;i++) { - angle = i * 2.0*pi / teeth; - glVertex3f(r1*cos(angle), r1*sin(angle), width*0.5); - glVertex3f(r1*cos(angle), r1*sin(angle), -width*0.5); - u = r2*cos(angle+da) - r1*cos(angle); - v = r2*sin(angle+da) - r1*sin(angle); - len = sqrt(u*u + v*v); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * pi / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 *cos(angle); + v = r2 * sin(angle + da) - r1 *sin(angle); + len = sqrt(u * u + v * v); u /= len; v /= len; glNormal3f(v, -u, 0.0); - glVertex3f(r2*cos(angle+da), r2*sin(angle+da), width*0.5); - glVertex3f(r2*cos(angle+da), r2*sin(angle+da), -width*0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); glNormal3f(cos(angle), sin(angle), 0.0); - glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5); - glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), -width*0.5); - u = r1*cos(angle+3*da) - r2*cos(angle+2*da); - v = r1*sin(angle+3*da) - r2*sin(angle+2*da); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 *cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 *sin(angle + 2 * da); glNormal3f(v, -u, 0.0); - glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5); - glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); glNormal3f(cos(angle), sin(angle), 0.0); - } - glVertex3f(r1*cos(0.0), r1*sin(0.0), width*0.5); - glVertex3f(r1*cos(0.0), r1*sin(0.0), -width*0.5); + } + glVertex3f(r1 * cos(0.0), r1 * sin(0.0), width * 0.5); + glVertex3f(r1 * cos(0.0), r1 * sin(0.0), -width * 0.5); glEnd(); glShadeModel(GL_SMOOTH); /* draw inside radius cylinder */ glBegin(GL_QUAD_STRIP); - for (i=0;i<=teeth;i++) { - angle = i * 2.0*pi / teeth; + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * pi / teeth; glNormal3f(-cos(angle), -sin(angle), 0.0); - glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5); - glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); } glEnd(); } @@ -208,20 +208,20 @@ static void drawGearGL(int id) switch (id) { - case 1: - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ared); - gearGL(1.0f, 4.0f, 1.0f, 20, 0.7f); - break; - case 2: - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, agreen); - gearGL(0.5f, 2.0f, 2.0f, 10, 0.7f); - break; - case 3: - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ablue); - gearGL(1.3f, 2.0f, 0.5f, 10, 0.7f); - break; - default: - break; + case 1: + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ared); + gearGL(1.0f, 4.0f, 1.0f, 20, 0.7f); + break; + case 2: + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, agreen); + gearGL(0.5f, 2.0f, 2.0f, 10, 0.7f); + break; + case 3: + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ablue); + gearGL(1.3f, 2.0f, 0.5f, 10, 0.7f); + break; + default: + break; } glEnable(GL_NORMALIZE); } @@ -229,9 +229,9 @@ static void drawGearGL(int id) void RenderCamera() { - glRotatef(view_rotx, 1.0, 0.0, 0.0); - glRotatef(view_roty, 0.0, 1.0, 0.0); - glRotatef(view_rotz, 0.0, 0.0, 1.0); + glRotatef(view_rotx, 1.0, 0.0, 0.0); + glRotatef(view_roty, 0.0, 1.0, 0.0); + glRotatef(view_rotz, 0.0, 0.0, 1.0); } @@ -258,7 +258,7 @@ void RenderScene() } -static void View(GHOST_IWindow* window, bool stereo, int eye = 0) +static void View(GHOST_IWindow *window, bool stereo, int eye = 0) { window->activateDrawingContext(); GHOST_Rect bnds; @@ -270,18 +270,17 @@ static void View(GHOST_IWindow* window, bool stereo, int eye = 0) window->getClientBounds(bnds); // viewport - if(stereo) + if (stereo) { - if(nVidiaWindows) + if (nVidiaWindows) { // handled by nVidia driver so act as normal (explicitly put here since // it -is- stereo) glViewport(0, 0, bnds.getWidth(), bnds.getHeight()); } - else - { // generic cross platform above-below stereo + else { // generic cross platform above-below stereo noOfScanlines = (bnds.getHeight() - verticalBlankingInterval) / 2; - switch(eye) + switch (eye) { case LEFT_EYE: // upper half of window @@ -294,8 +293,7 @@ static void View(GHOST_IWindow* window, bool stereo, int eye = 0) } } } - else - { + else { noOfScanlines = bnds.getHeight(); lowerScanline = 0; } @@ -310,11 +308,11 @@ static void View(GHOST_IWindow* window, bool stereo, int eye = 0) nearplane = 5.0; farplane = 60.0; - if(stereo) + if (stereo) { zeroPlane = 0.0; distance = 14.5; - switch(eye) + switch (eye) { case LEFT_EYE: StereoProjection(left, right, bottom, top, nearplane, farplane, zeroPlane, distance, -eyeSeparation / 2.0); @@ -324,8 +322,7 @@ static void View(GHOST_IWindow* window, bool stereo, int eye = 0) break; } } - else - { + else { // left = -w; // right = w; // bottom = -h; @@ -339,7 +336,7 @@ static void View(GHOST_IWindow* window, bool stereo, int eye = 0) } - glClearColor(.2f,0.0f,0.0f,0.0f); + glClearColor(.2f, 0.0f, 0.0f, 0.0f); } @@ -347,31 +344,31 @@ void StereoProjection(float left, float right, float bottom, float top, float ne float zero_plane, float dist, float eye) /* Perform the perspective projection for one eye's subfield. -The projection is in the direction of the negative z axis. + The projection is in the direction of the negative z axis. --6.0, 6.0, -4.8, 4.8, -left, right, bottom, top = the coordinate range, in the plane of zero -parallax setting, which will be displayed on the screen. The -ratio between (right-left) and (top-bottom) should equal the aspect -ratio of the display. + -6.0, 6.0, -4.8, 4.8, + left, right, bottom, top = the coordinate range, in the plane of zero + parallax setting, which will be displayed on the screen. The + ratio between (right-left) and (top-bottom) should equal the aspect + ratio of the display. -6.0, -6.0, -near, far = the z-coordinate values of the clipping planes. + 6.0, -6.0, + near, far = the z-coordinate values of the clipping planes. -0.0, -zero_plane = the z-coordinate of the plane of zero parallax setting. + 0.0, + zero_plane = the z-coordinate of the plane of zero parallax setting. -14.5, -dist = the distance from the center of projection to the plane -of zero parallax. + 14.5, + dist = the distance from the center of projection to the plane + of zero parallax. --0.31 -eye = half the eye separation; positive for the right eye subfield, -negative for the left eye subfield. -*/ + -0.31 + eye = half the eye separation; positive for the right eye subfield, + negative for the left eye subfield. + */ { float xmid, ymid, clip_near, clip_far, topw, bottomw, leftw, rightw, - dx, dy, n_over_d; + dx, dy, n_over_d; dx = right - left; dy = top - bottom; @@ -387,7 +384,7 @@ negative for the left eye subfield. topw = n_over_d * dy / 2.0; bottomw = -topw; rightw = n_over_d * (dx / 2.0 - eye); - leftw = n_over_d *(-dx / 2.0 - eye); + leftw = n_over_d * (-dx / 2.0 - eye); /* Need to be in projection mode for this. */ glLoadIdentity(); @@ -400,15 +397,15 @@ negative for the left eye subfield. class Application : public GHOST_IEventConsumer { public: - Application(GHOST_ISystem* system); + Application(GHOST_ISystem *system); ~Application(void); - virtual bool processEvent(GHOST_IEvent* event); + virtual bool processEvent(GHOST_IEvent *event); - GHOST_ISystem* m_system; - GHOST_IWindow* m_mainWindow; - GHOST_IWindow* m_secondaryWindow; - GHOST_IWindow* m_fullScreenWindow; - GHOST_ITimerTask* m_gearsTimer, *m_testTimer; + GHOST_ISystem *m_system; + GHOST_IWindow *m_mainWindow; + GHOST_IWindow *m_secondaryWindow; + GHOST_IWindow *m_fullScreenWindow; + GHOST_ITimerTask *m_gearsTimer, *m_testTimer; GHOST_TStandardCursor m_cursor; bool m_exitRequested; @@ -416,34 +413,34 @@ public: }; -Application::Application(GHOST_ISystem* system) +Application::Application(GHOST_ISystem *system) : m_system(system), m_mainWindow(0), m_secondaryWindow(0), m_fullScreenWindow(0), - m_gearsTimer(0), m_testTimer(0), m_cursor(GHOST_kStandardCursorFirstCursor), - m_exitRequested(false), stereo(false) + m_gearsTimer(0), m_testTimer(0), m_cursor(GHOST_kStandardCursorFirstCursor), + m_exitRequested(false), stereo(false) { fApp = this; // Create the main window - STR_String title1 ("gears - main window"); + STR_String title1("gears - main window"); m_mainWindow = system->createWindow(title1, 10, 64, 320, 200, GHOST_kWindowStateNormal, - GHOST_kDrawingContextTypeOpenGL, false, false); + GHOST_kDrawingContextTypeOpenGL, false, false); - if (!m_mainWindow) { + if (!m_mainWindow) { std::cout << "could not create main window\n"; exit(-1); - } + } // Create a secondary window - STR_String title2 ("gears - secondary window"); + STR_String title2("gears - secondary window"); m_secondaryWindow = system->createWindow(title2, 340, 64, 320, 200, GHOST_kWindowStateNormal, - GHOST_kDrawingContextTypeOpenGL, false, false); + GHOST_kDrawingContextTypeOpenGL, false, false); if (!m_secondaryWindow) { cout << "could not create secondary window\n"; exit(-1); } // Install a timer to have the gears running - m_gearsTimer = system->installTimer(0 /*delay*/, 20/*interval*/, gearsTimerProc, m_mainWindow); + m_gearsTimer = system->installTimer(0 /*delay*/, 20 /*interval*/, gearsTimerProc, m_mainWindow); } @@ -459,183 +456,183 @@ Application::~Application(void) } -bool Application::processEvent(GHOST_IEvent* event) +bool Application::processEvent(GHOST_IEvent *event) { - GHOST_IWindow* window = event->getWindow(); + GHOST_IWindow *window = event->getWindow(); bool handled = true; switch (event->getType()) { /* case GHOST_kEventUnknown: - break; - case GHOST_kEventCursorButton: - std::cout << "GHOST_kEventCursorButton"; break; - case GHOST_kEventCursorMove: - std::cout << "GHOST_kEventCursorMove"; break; -*/ - case GHOST_kEventWheel: - { - GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*) event->getData(); - if (wheelData->z > 0) - { - view_rotz += 5.f; - } - else - { - view_rotz -= 5.f; - } - } - break; - - case GHOST_kEventKeyUp: - break; - - case GHOST_kEventKeyDown: + break; + case GHOST_kEventCursorButton: + std::cout << "GHOST_kEventCursorButton"; break; + case GHOST_kEventCursorMove: + std::cout << "GHOST_kEventCursorMove"; break; + */ + case GHOST_kEventWheel: { - GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*) event->getData(); - switch (keyData->key) { - case GHOST_kKeyC: - { - int cursor = m_cursor; - cursor++; - if (cursor >= GHOST_kStandardCursorNumCursors) { - cursor = GHOST_kStandardCursorFirstCursor; - } - m_cursor = (GHOST_TStandardCursor)cursor; - window->setCursorShape(m_cursor); - } - break; - - case GHOST_kKeyE: + GHOST_TEventWheelData *wheelData = (GHOST_TEventWheelData *) event->getData(); + if (wheelData->z > 0) { - int x = 200, y= 200; - m_system->setCursorPosition(x,y); - break; - } - - case GHOST_kKeyF: - if (!m_system->getFullScreen()) { - // Begin fullscreen mode - GHOST_DisplaySetting setting; - - setting.bpp = 16; - setting.frequency = 50; - setting.xPixels = 640; - setting.yPixels = 480; - m_system->beginFullScreen(setting, &m_fullScreenWindow, false /* stereo flag */); + view_rotz += 5.f; } else { - m_system->endFullScreen(); - m_fullScreenWindow = 0; + view_rotz -= 5.f; } - break; + } + break; - case GHOST_kKeyH: - window->setCursorVisibility(!window->getCursorVisibility()); + case GHOST_kEventKeyUp: break; - case GHOST_kKeyM: - { - bool down = false; - m_system->getModifierKeyState(GHOST_kModifierKeyLeftShift,down); - if (down) { - std::cout << "left shift down\n"; - } - m_system->getModifierKeyState(GHOST_kModifierKeyRightShift,down); - if (down) { - std::cout << "right shift down\n"; } - m_system->getModifierKeyState(GHOST_kModifierKeyLeftAlt,down); - if (down) { - std::cout << "left Alt down\n"; - } - m_system->getModifierKeyState(GHOST_kModifierKeyRightAlt,down); - if (down) { - std::cout << "right Alt down\n"; + case GHOST_kEventKeyDown: + { + GHOST_TEventKeyData *keyData = (GHOST_TEventKeyData *) event->getData(); + switch (keyData->key) { + case GHOST_kKeyC: + { + int cursor = m_cursor; + cursor++; + if (cursor >= GHOST_kStandardCursorNumCursors) { + cursor = GHOST_kStandardCursorFirstCursor; + } + m_cursor = (GHOST_TStandardCursor)cursor; + window->setCursorShape(m_cursor); } - m_system->getModifierKeyState(GHOST_kModifierKeyLeftControl,down); - if (down) { - std::cout << "left control down\n"; + break; + + case GHOST_kKeyE: + { + int x = 200, y = 200; + m_system->setCursorPosition(x, y); + break; } - m_system->getModifierKeyState(GHOST_kModifierKeyRightControl,down); - if (down) { - std::cout << "right control down\n"; + + case GHOST_kKeyF: + if (!m_system->getFullScreen()) { + // Begin fullscreen mode + GHOST_DisplaySetting setting; + + setting.bpp = 16; + setting.frequency = 50; + setting.xPixels = 640; + setting.yPixels = 480; + m_system->beginFullScreen(setting, &m_fullScreenWindow, false /* stereo flag */); + } + else { + m_system->endFullScreen(); + m_fullScreenWindow = 0; + } + break; + + case GHOST_kKeyH: + window->setCursorVisibility(!window->getCursorVisibility()); + break; + + case GHOST_kKeyM: + { + bool down = false; + m_system->getModifierKeyState(GHOST_kModifierKeyLeftShift, down); + if (down) { + std::cout << "left shift down\n"; + } + m_system->getModifierKeyState(GHOST_kModifierKeyRightShift, down); + if (down) { + std::cout << "right shift down\n"; + } + m_system->getModifierKeyState(GHOST_kModifierKeyLeftAlt, down); + if (down) { + std::cout << "left Alt down\n"; + } + m_system->getModifierKeyState(GHOST_kModifierKeyRightAlt, down); + if (down) { + std::cout << "right Alt down\n"; + } + m_system->getModifierKeyState(GHOST_kModifierKeyLeftControl, down); + if (down) { + std::cout << "left control down\n"; + } + m_system->getModifierKeyState(GHOST_kModifierKeyRightControl, down); + if (down) { + std::cout << "right control down\n"; + } } - } - break; + break; - case GHOST_kKeyQ: - if (m_system->getFullScreen()) - { - m_system->endFullScreen(); - m_fullScreenWindow = 0; - } - m_exitRequested = true; - break; + case GHOST_kKeyQ: + if (m_system->getFullScreen()) + { + m_system->endFullScreen(); + m_fullScreenWindow = 0; + } + m_exitRequested = true; + break; - case GHOST_kKeyS: // toggle mono and stereo - if(stereo) - stereo = false; - else - stereo = true; - break; + case GHOST_kKeyS: // toggle mono and stereo + if (stereo) + stereo = false; + else + stereo = true; + break; - case GHOST_kKeyT: - if (!m_testTimer) { - m_testTimer = m_system->installTimer(0, 1000, testTimerProc); - } + case GHOST_kKeyT: + if (!m_testTimer) { + m_testTimer = m_system->installTimer(0, 1000, testTimerProc); + } - else { - m_system->removeTimer(m_testTimer); - m_testTimer = 0; - } + else { + m_system->removeTimer(m_testTimer); + m_testTimer = 0; + } - break; + break; - case GHOST_kKeyW: - if (m_mainWindow) - { - STR_String title; - m_mainWindow->getTitle(title); - title += "-"; - m_mainWindow->setTitle(title); + case GHOST_kKeyW: + if (m_mainWindow) + { + STR_String title; + m_mainWindow->getTitle(title); + title += "-"; + m_mainWindow->setTitle(title); - } - break; + } + break; - default: - break; - } + default: + break; + } } break; - case GHOST_kEventWindowClose: + case GHOST_kEventWindowClose: { - GHOST_IWindow* window2 = event->getWindow(); - if (window2 == m_mainWindow) { - m_exitRequested = true; - } - else { - m_system->disposeWindow(window2); - } + GHOST_IWindow *window2 = event->getWindow(); + if (window2 == m_mainWindow) { + m_exitRequested = true; + } + else { + m_system->disposeWindow(window2); + } } break; - case GHOST_kEventWindowActivate: - handled = false; - break; + case GHOST_kEventWindowActivate: + handled = false; + break; - case GHOST_kEventWindowDeactivate: - handled = false; - break; + case GHOST_kEventWindowDeactivate: + handled = false; + break; - case GHOST_kEventWindowUpdate: + case GHOST_kEventWindowUpdate: { - GHOST_IWindow* window2 = event->getWindow(); - if(!m_system->validWindow(window2)) + GHOST_IWindow *window2 = event->getWindow(); + if (!m_system->validWindow(window2)) break; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - if(stereo) + if (stereo) { View(window2, stereo, LEFT_EYE); glPushMatrix(); @@ -649,8 +646,7 @@ bool Application::processEvent(GHOST_IEvent* event) RenderScene(); glPopMatrix(); } - else - { + else { View(window2, stereo); glPushMatrix(); RenderCamera(); @@ -661,15 +657,15 @@ bool Application::processEvent(GHOST_IEvent* event) } break; - default: - handled = false; - break; + default: + handled = false; + break; } return handled; } -int main(int /*argc*/, char** /*argv*/) +int main(int /*argc*/, char ** /*argv*/) { nVidiaWindows = false; // nVidiaWindows = true; @@ -678,7 +674,7 @@ int main(int /*argc*/, char** /*argv*/) /* Set a couple of settings in the registry for the nVidia detonator driver. * So this is very specific... */ - if(nVidiaWindows) + if (nVidiaWindows) { LONG lresult; HKEY hkey = 0; @@ -691,19 +687,19 @@ int main(int /*argc*/, char** /*argv*/) lresult = regkey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable", KEY_ALL_ACCESS); - if(lresult == ERROR_SUCCESS) + if (lresult == ERROR_SUCCESS) printf("Succesfully opened key\n"); #if 0 lresult = regkey.QueryValue(&keyValue, "StereoEnable"); - if(lresult == ERROR_SUCCESS) + if (lresult == ERROR_SUCCESS) printf("Succesfully queried key\n"); #endif lresult = regkey.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable", - "1"); - if(lresult == ERROR_SUCCESS) + "1"); + if (lresult == ERROR_SUCCESS) printf("Succesfully set value for key\n"); regkey.Close(); - if(lresult == ERROR_SUCCESS) + if (lresult == ERROR_SUCCESS) printf("Succesfully closed key\n"); // regkey.Write("2"); } @@ -715,14 +711,14 @@ int main(int /*argc*/, char** /*argv*/) if (fSystem) { // Create an application object - Application app (fSystem); + Application app(fSystem); // Add the application as event consumer fSystem->addEventConsumer(&app); // Enter main loop while (!app.m_exitRequested) { - //printf("main: loop\n"); + //printf("main: loop\n"); fSystem->processEvents(true); fSystem->dispatchEvents(); } @@ -735,11 +731,11 @@ int main(int /*argc*/, char** /*argv*/) } -static void gearsTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 /*time*/) +static void gearsTimerProc(GHOST_ITimerTask *task, GHOST_TUns64 /*time*/) { - fAngle += 2.0; - view_roty += 1.0; - GHOST_IWindow* window = (GHOST_IWindow*)task->getUserData(); + fAngle += 2.0; + view_roty += 1.0; + GHOST_IWindow *window = (GHOST_IWindow *)task->getUserData(); if (fApp->m_fullScreenWindow) { // Running full screen fApp->m_fullScreenWindow->invalidate(); |