FlightGear next
WindowsMouseCursor.cxx
Go to the documentation of this file.
1// WindowsMouseCursor.cxx - mouse cursor using Windows APIs
2
3// Copyright (C) 2013 James Turner <zakalawe@mac.com>
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License as
7// published by the Free Software Foundation; either version 2 of the
8// License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18//
19
20#ifdef HAVE_CONFIG_H
21 #include "config.h"
22#endif
23
25
26#include "windows.h"
27
28#include <map>
29
30#include <Main/globals.hxx>
31
41
43{
44 switch (aKey) {
45 case FGMouseCursor::CURSOR_HAND: return LoadCursor(NULL, IDC_HAND);
46 case FGMouseCursor::CURSOR_CROSSHAIR: return LoadCursor(NULL, IDC_CROSS);
47 case FGMouseCursor::CURSOR_IBEAM: return LoadCursor(NULL, IDC_IBEAM);
48 case FGMouseCursor::CURSOR_LEFT_RIGHT: return LoadCursor( NULL, IDC_SIZEWE );
49
50#if 0
52 path = [path stringByAppendingPathComponent:@"cursor-spin-cw.png"];
53 img = [[NSImage alloc] initWithContentsOfFile:path];
54 return [[NSCursor alloc] initWithImage:img hotSpot:NSMakePoint(16,16)];
55
57 path = [path stringByAppendingPathComponent:@"cursor-spin-cw.png"];
58 img = [[NSImage alloc] initWithContentsOfFile:path];
59 return [[NSCursor alloc] initWithImage:img hotSpot:NSMakePoint(16,16)];
60#endif
61 default: return LoadCursor(NULL, IDC_ARROW);
62 }
63
64}
65
68{
69 d->hideUntilMove = false;
70 d->activeCursorKey = CURSOR_ARROW;
71}
72
78
79
81{
82 if (aCursor == d->activeCursorKey) {
83 return;
84 }
85
86 d->activeCursorKey = aCursor;
87 if (d->cursors.find(aCursor) == d->cursors.end()) {
88 d->cursors[aCursor] = windowsCursorForKey(aCursor);
89 }
90
91 SetCursor(d->cursors[aCursor]);
92}
93
95{
96 d->hideUntilMove = false; // cancel this
97 ShowCursor(aVis);
98}
99
101{
102 if (d->hideUntilMove) {
103 return;
104 }
105
106 d->hideUntilMove = true;
107 ShowCursor(false);
108}
109
111{
112 if (d->hideUntilMove) {
113 d->hideUntilMove = false;
114 ShowCursor(true);
115 }
116}
HCURSOR windowsCursorForKey(FGMouseCursor::Cursor aKey)
@ CURSOR_HAND
the browser 'link' cursor
@ CURSOR_IBEAM
for editing text
virtual void hideCursorUntilMouseMove()
virtual void setCursorVisible(bool aVis)
virtual void setCursor(Cursor aCursor)