summaryrefslogtreecommitdiff
path: root/frontends/windows/pointers.c
blob: b796a30ec8e9211b490d35763e27084a25071fc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
 *
 * This file is part of NetSurf, http://www.netsurf-browser.org/
 *
 * NetSurf is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * NetSurf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <windows.h>

#include "utils/errors.h"
#include "utils/nsurl.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/corestrings.h"
#include "utils/url.h"
#include "utils/file.h"
#include "netsurf/browser_window.h"
#include "netsurf/clipboard.h"

#include "windows/schedule.h"
#include "windows/window.h"
#include "windows/filetype.h"
#include "windows/pointers.h"

struct nsws_pointers {
	HCURSOR hand;
	HCURSOR ibeam;
	HCURSOR cross;
	HCURSOR sizeall;
	HCURSOR sizewe;
	HCURSOR sizens;
	HCURSOR sizenesw;
	HCURSOR sizenwse;
	HCURSOR wait;
	HCURSOR appstarting;
	HCURSOR no;
	HCURSOR help;
	HCURSOR arrow;
};

/** pre loaded pointer cursors */
static struct nsws_pointers nsws_pointer;

/* exported interface documented in windows/pointers.h */
void nsws_window_init_pointers(HINSTANCE hinstance)
{
	nsws_pointer.hand = LoadCursor(NULL, IDC_HAND);
	nsws_pointer.ibeam = LoadCursor(NULL, IDC_IBEAM);
	nsws_pointer.cross = LoadCursor(NULL, IDC_CROSS);
	nsws_pointer.sizeall = LoadCursor(NULL, IDC_SIZEALL);
	nsws_pointer.sizewe = LoadCursor(NULL, IDC_SIZEWE);
	nsws_pointer.sizens = LoadCursor(NULL, IDC_SIZENS);
	nsws_pointer.sizenesw = LoadCursor(NULL, IDC_SIZENESW);
	nsws_pointer.sizenwse = LoadCursor(NULL, IDC_SIZENWSE);
	nsws_pointer.wait = LoadCursor(NULL, IDC_WAIT);
	nsws_pointer.appstarting = LoadCursor(NULL, IDC_APPSTARTING);
	nsws_pointer.no = LoadCursor(NULL, IDC_NO);
	nsws_pointer.help = LoadCursor(NULL, IDC_HELP);
	nsws_pointer.arrow = LoadCursor(NULL, IDC_ARROW);
}

/* exported interface documented in windows/pointers.h */
HCURSOR nsws_get_pointer(gui_pointer_shape shape)
{
	switch (shape) {
	case GUI_POINTER_POINT: /* link */
	case GUI_POINTER_MENU:
		return nsws_pointer.hand;

	case GUI_POINTER_CARET: /* input */
		return nsws_pointer.ibeam;

	case GUI_POINTER_CROSS:
		return nsws_pointer.cross;

	case GUI_POINTER_MOVE:
		return nsws_pointer.sizeall;

	case GUI_POINTER_RIGHT:
	case GUI_POINTER_LEFT:
		return nsws_pointer.sizewe;

	case GUI_POINTER_UP:
	case GUI_POINTER_DOWN:
		return nsws_pointer.sizens;

	case GUI_POINTER_RU:
	case GUI_POINTER_LD:
		return nsws_pointer.sizenesw;

	case GUI_POINTER_RD:
	case GUI_POINTER_LU:
		return nsws_pointer.sizenwse;

	case GUI_POINTER_WAIT:
		return nsws_pointer.wait;

	case GUI_POINTER_PROGRESS:
		return nsws_pointer.appstarting;

	case GUI_POINTER_NO_DROP:
	case GUI_POINTER_NOT_ALLOWED:
		return nsws_pointer.no;

	case GUI_POINTER_HELP:
		return nsws_pointer.help;

	default:
		break;
	}

	return nsws_pointer.arrow;
}