Implement SkiaDisplay::setNativeMouseCursor() on Windows

This commit is contained in:
David Capello 2015-05-22 13:44:41 -03:00
parent da3b3de6c1
commit 5eea582365
2 changed files with 64 additions and 1 deletions

View File

@ -116,6 +116,7 @@ EventQueue* SkiaDisplay::getEventQueue()
bool SkiaDisplay::setNativeMouseCursor(NativeCursor cursor)
{
m_window.setNativeMouseCursor(cursor);
return true;
}

View File

@ -15,6 +15,7 @@
#include "gfx/size.h"
#include "she/event.h"
#include "she/keys.h"
#include "she/native_cursor.h"
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x020E
@ -32,6 +33,7 @@ namespace she {
Window() {
registerClass();
m_hwnd = createHwnd(this);
m_hcursor = NULL;
m_hasMouse = false;
m_captureMouse = false;
m_scale = 1;
@ -94,6 +96,58 @@ namespace she {
SetCursorPos(pos.x, pos.y);
}
void setNativeMouseCursor(NativeCursor cursor) {
HCURSOR hcursor = NULL;
switch (cursor) {
case kNoCursor:
// Do nothing, just set to null
break;
case kArrowCursor:
hcursor = LoadCursor(NULL, IDC_ARROW);
break;
case kIBeamCursor:
hcursor = LoadCursor(NULL, IDC_IBEAM);
break;
case kWaitCursor:
hcursor = LoadCursor(NULL, IDC_WAIT);
break;
case kLinkCursor:
hcursor = LoadCursor(NULL, IDC_HAND);
break;
case kHelpCursor:
hcursor = LoadCursor(NULL, IDC_HELP);
break;
case kForbiddenCursor:
hcursor = LoadCursor(NULL, IDC_NO);
break;
case kMoveCursor:
hcursor = LoadCursor(NULL, IDC_SIZEALL);
break;
case kSizeNCursor:
case kSizeNSCursor:
case kSizeSCursor:
hcursor = LoadCursor(NULL, IDC_SIZENS);
break;
case kSizeECursor:
case kSizeWCursor:
case kSizeWECursor:
hcursor = LoadCursor(NULL, IDC_SIZEWE);
break;
case kSizeNWCursor:
case kSizeSECursor:
hcursor = LoadCursor(NULL, IDC_SIZENWSE);
break;
case kSizeNECursor:
case kSizeSWCursor:
hcursor = LoadCursor(NULL, IDC_SIZENESW);
break;
}
SetCursor(hcursor);
m_hcursor = hcursor;
}
void invalidate() {
InvalidateRect(m_hwnd, NULL, FALSE);
}
@ -106,6 +160,13 @@ namespace she {
LRESULT wndProc(UINT msg, WPARAM wparam, LPARAM lparam) {
switch (msg) {
case WM_SETCURSOR:
if (LOWORD(lparam) == HTCLIENT) {
SetCursor(m_hcursor);
return TRUE;
}
break;
case WM_CLOSE: {
Event ev;
ev.setType(Event::CloseDisplay);
@ -400,7 +461,7 @@ namespace she {
wcex.cbWndExtra = 0;
wcex.hInstance = instance;
wcex.hIcon = nullptr;
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hCursor = NULL;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = SHE_WND_CLASS_NAME;
@ -444,6 +505,7 @@ namespace she {
}
mutable HWND m_hwnd;
HCURSOR m_hcursor;
gfx::Size m_clientSize;
gfx::Size m_restoredSize;
int m_scale;