#include "CocoaMouseCursor.hxx"
#endif
+#ifdef SG_WINDOWS
+#include "WindowsMouseCursor.hxx"
+#endif
+
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Viewer/renderer.hxx>
osgViewer::GraphicsWindow::MouseCursor translateCursor(Cursor aCursor)
{
switch (aCursor) {
+ case CURSOR_ARROW: return osgViewer::GraphicsWindow::RightArrowCursor;
case CURSOR_HAND: return osgViewer::GraphicsWindow::HandCursor;
case CURSOR_CROSSHAIR: return osgViewer::GraphicsWindow::CrosshairCursor;
case CURSOR_IBEAM: return osgViewer::GraphicsWindow::TextCursor;
case CURSOR_LEFT_RIGHT: return osgViewer::GraphicsWindow::LeftRightCursor;
- default: return osgViewer::GraphicsWindow::InheritCursor;
+ default:
+ return osgViewer::GraphicsWindow::RightArrowCursor;
}
}
static_instance = new CocoaMouseCursor;
}
#endif
-
- // windows
+ #ifdef SG_WINDOWS
+ // set osgViewer cursor inherit, otherwise it will interefere
+ std::vector<osgViewer::GraphicsWindow*> gws;
+ globals->get_renderer()->getViewer()->getWindows(gws);
+ BOOST_FOREACH(osgViewer::GraphicsWindow* gw, gws) {
+ gw->setCursor(osgViewer::GraphicsWindow::InheritCursor);
+ }
+
+ // and create our real implementation
+ static_instance = new WindowsMouseCursor;
+ #endif
// X11
-// WindowsMouseCursor.cxx - mouse cursor using Cocoa APIs
+// WindowsMouseCursor.cxx - mouse cursor using Windows APIs
// Copyright (C) 2013 James Turner <zakalawe@mac.com>
//
{
public:
Cursor activeCursorKey;
-
+ bool hideUntilMove;
+
typedef std::map<Cursor, HCURSOR> CursorMap;
CursorMap cursors;
};
HCURSOR windowsCursorForKey(FGMouseCursor::Cursor aKey)
{
- #if 0
- NSImage* img = nil;
-
- NSString* path = [NSString stringWithCString:globals->get_fg_root().c_str()
- encoding:NSUTF8StringEncoding];
- path = [path stringByAppendingPathComponent:@"gui"];
-
switch (aKey) {
- case FGMouseCursor::CURSOR_HAND: return [NSCursor pointingHandCursor];
- case FGMouseCursor::CURSOR_CROSSHAIR: return [NSCursor crosshairCursor];
- case FGMouseCursor::CURSOR_IBEAM: return [NSCursor IBeamCursor];
+ case FGMouseCursor::CURSOR_HAND: return LoadCursor(NULL, IDC_HAND);
+ case FGMouseCursor::CURSOR_CROSSHAIR: return LoadCursor(NULL, IDC_CROSS);
+ case FGMouseCursor::CURSOR_IBEAM: return LoadCursor(NULL, IDC_IBEAM);
+ case FGMouseCursor::CURSOR_LEFT_RIGHT: return LoadCursor( NULL, IDC_SIZEWE );
- // FIXME - use a proper left-right cursor here.
- case FGMouseCursor::CURSOR_LEFT_RIGHT: return [NSCursor resizeLeftRightCursor];
-
+#if 0
case FGMouseCursor::CURSOR_SPIN_CW:
path = [path stringByAppendingPathComponent:@"cursor-spin-cw.png"];
img = [[NSImage alloc] initWithContentsOfFile:path];
path = [path stringByAppendingPathComponent:@"cursor-spin-cw.png"];
img = [[NSImage alloc] initWithContentsOfFile:path];
return [[NSCursor alloc] initWithImage:img hotSpot:NSMakePoint(16,16)];
-
- default: return [NSCursor arrowCursor];
+#endif
+ default: return LoadCursor(NULL, IDC_ARROW);
}
-#endif
}
WindowsMouseCursor::WindowsMouseCursor() :
d(new WindowsMouseCursorPrivate)
{
-
+ d->hideUntilMove = false;
+ d->activeCursorKey = CURSOR_ARROW;
}
WindowsMouseCursor::~WindowsMouseCursor()
d->activeCursorKey = aCursor;
if (d->cursors.find(aCursor) == d->cursors.end()) {
- d->cursors[key] = windowsCursorForKey(aCursor);
+ d->cursors[aCursor] = windowsCursorForKey(aCursor);
}
-
- SetCursor(windowsCursorForKey(d->cursors[key]));
+ SetCursor(d->cursors[aCursor]);
}
void WindowsMouseCursor::setCursorVisible(bool aVis)
{
d->hideUntilMove = false; // cancel this
-
- if (aVis) {
- ShowCursor();
- } else {
-
- HideCursor();
- }
+ ShowCursor(aVis);
}
void WindowsMouseCursor::hideCursorUntilMouseMove()
}
d->hideUntilMove = true;
- HideCursor();
+ ShowCursor(false);
}
void WindowsMouseCursor::mouseMoved()
{
if (d->hideUntilMove) {
d->hideUntilMove = false;
- ShowCursor();
+ ShowCursor(true);
}
}