53 int i, z = GET_WHEEL_DELTA_WPARAM(wparam) / WHEEL_DELTA;
54 int key = LOWORD(wparam);
56 unsigned int newmessage = WM_VSCROLL;
58 if (key == MK_SHIFT) {
59 command = (z > 0) ? SB_LINERIGHT : SB_LINELEFT;
60 newmessage = WM_HSCROLL;
63 command = (z > 0) ? SB_LINEUP : SB_LINEDOWN;
66 z = (z < 0) ? -1 * z : z;
68 for (i = 0; i < z; i++) {
69 SendMessage(hwnd, newmessage, MAKELONG(command, 0), 0);
91 si.cbSize =
sizeof(si);
93 GetScrollInfo(hwnd, SB_VERT, &si);
96 switch (LOWORD(wparam)) {
122 si.nPos = si.nTrackPos;
130 if ((gw->
bw != NULL) &&
136 si.nPos =
max(si.nPos, 0);
137 SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
138 GetScrollInfo(hwnd, SB_VERT, &si);
139 if (si.nPos != mem) {
165 si.cbSize =
sizeof(si);
167 GetScrollInfo(hwnd, SB_HORZ, &si);
170 switch (LOWORD(wparam)) {
180 si.nPos -= gw->
width;
184 si.nPos += gw->
width;
188 si.nPos = si.nTrackPos;
197 if ((gw->
bw != NULL) &&
202 si.nPos =
max(si.nPos, 0);
203 SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
204 GetScrollInfo(hwnd, SB_HORZ, &si);
205 if (si.nPos != mem) {
234 if (wparam == UNICODE_NOCHAR) {
258 const uint32_t utf16_hi_surrogate_start = 0xD800;
259 const uint32_t utf16_lo_surrogate_start = 0xDC00;
260 const uint32_t utf16_surrogate_end = 0xDFFF;
262 static uint32_t highSurrogate = 0;
264 if ((nskey >= utf16_hi_surrogate_start) &&
265 (nskey < utf16_lo_surrogate_start) ) {
266 highSurrogate = nskey;
268 if ((nskey >= utf16_lo_surrogate_start) &&
269 (nskey <= utf16_surrogate_end)) {
270 uint32_t lowSurrogate = nskey;
271 nskey = (highSurrogate - utf16_hi_surrogate_start) << 10;
272 nskey |= ( lowSurrogate - utf16_lo_surrogate_start );
290 bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
296 SendMessage(hwnd, WM_HSCROLL,
297 MAKELONG(SB_LINELEFT, 0), 0);
303 SendMessage(hwnd, WM_HSCROLL,
304 MAKELONG(SB_LINERIGHT, 0), 0);
310 SendMessage(hwnd, WM_VSCROLL,
311 MAKELONG(SB_LINEUP, 0), 0);
317 SendMessage(hwnd, WM_VSCROLL,
318 MAKELONG(SB_LINEDOWN, 0), 0);
324 SendMessage(hwnd, WM_HSCROLL,
325 MAKELONG(SB_PAGELEFT, 0), 0);
331 SendMessage(hwnd, WM_HSCROLL,
332 MAKELONG(SB_PAGERIGHT, 0), 0);
340 SendMessage(hwnd, WM_VSCROLL, MAKELONG(SB_PAGEDOWN, 0), 0);
344 SendMessage(hwnd, WM_VSCROLL, MAKELONG(SB_PAGEUP, 0), 0);
367 .background_images =
true,
371 BeginPaint(hwnd, &ps);
376 clip.x0 = ps.rcPaint.left;
377 clip.y0 = ps.rcPaint.top;
378 clip.x1 = ps.rcPaint.right;
379 clip.y1 = ps.rcPaint.bottom;
408 bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
409 bool ctrl = ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000);
410 bool alt = ((GetKeyState(VK_MENU) & 0x8000) == 0x8000);
413 (gw->
mouse == NULL) ||
433 "mouse click bw %p, state 0x%x, x %d, y %d",
464 (gw->
mouse == NULL) ||
471 if ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000)
473 if ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000)
475 if ((GetKeyState(VK_MENU) & 0x8000) == 0x8000)
481 NSLOG(netsurf, INFO,
"mouse click bw %p, state %x, x %d, y %d",
502 bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
503 bool ctrl = ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000);
504 bool alt = ((GetKeyState(VK_MENU) & 0x8000) == 0x8000);
506 if ((gw == NULL) || (gw->
mouse == NULL) || (gw->
bw == NULL))
519 NSLOG(netsurf, INFO,
"Drag start state 0x%x",
557static LRESULT CALLBACK
570 "Unable to find gui window structure for hwnd %p", hwnd);
571 return DefWindowProc(hwnd, msg, wparam, lparam);
578 GET_X_LPARAM(lparam),
579 GET_Y_LPARAM(lparam));
583 GET_X_LPARAM(lparam),
584 GET_Y_LPARAM(lparam),
592 GET_X_LPARAM(lparam),
593 GET_Y_LPARAM(lparam),
600 GET_X_LPARAM(lparam),
601 GET_Y_LPARAM(lparam),
607 GET_X_LPARAM(lparam),
608 GET_Y_LPARAM(lparam),
666 return DefWindowProc(hwnd, msg, wparam, lparam);
679 hwnd = CreateWindowExW(0,
682 WS_VISIBLE | WS_CHILD,
692 NSLOG(netsurf, INFO,
"Window creation failed");
697 SetProp(hwnd, TEXT(
"GuiWnd"), (HANDLE)gw);
712 w.cbSize =
sizeof(WNDCLASSEX);
717 w.hInstance = hinstance;
720 w.hbrBackground = (HBRUSH)(COLOR_MENU + 1);
721 w.lpszMenuName = NULL;
725 if (RegisterClassExW(&w) == 0) {
Browser window creation and manipulation interface.
nserror browser_window_schedule_reformat(struct browser_window *bw)
Reformat the browser window contents in a safe context.
bool browser_window_redraw(struct browser_window *bw, int x, int y, const struct rect *clip, const struct redraw_context *ctx)
Redraw an area of a window.
void browser_window_mouse_click(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse clicks in a browser window.
nserror browser_window_get_extents(struct browser_window *bw, bool scaled, int *width, int *height)
Get a browser window's content extents.
void browser_window_mouse_track(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle non-click mouse action in a browser window.
static LRESULT nsws_drawable_unichar(struct gui_window *gw, HWND hwnd, WPARAM wparam)
Handle unicode character messages.
static LRESULT CALLBACK nsws_window_drawable_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Called when activity occours within the drawable window.
static LRESULT nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam)
Handle vertical scroll messages.
static const wchar_t * windowclassname_drawable
nserror nsws_create_drawable_class(HINSTANCE hinstance)
Create the drawable window class.
static LRESULT nsws_drawable_resize(struct gui_window *gw)
Handle resize events.
static LRESULT nsws_drawable_paint(struct gui_window *gw, HWND hwnd)
Handle paint messages.
static LRESULT nsws_drawable_mousedown(struct gui_window *gw, int x, int y, browser_mouse_state button)
Handle mouse button down messages.
static LRESULT nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam)
Handle horizontal scroll messages.
HWND nsws_window_create_drawable(HINSTANCE hinstance, HWND hparent, struct gui_window *gw)
Create a drawable window.
static LRESULT nsws_drawable_char(struct gui_window *gw, HWND hwnd, WPARAM wparam)
Handle character messages.
static LRESULT nsws_drawable_wheel(struct gui_window *gw, HWND hwnd, WPARAM wparam)
Handle wheel scroll messages.
static LRESULT nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
Handle mouse movement messages.
static LRESULT nsws_drawable_mouseup(struct gui_window *gw, int x, int y, browser_mouse_state press, browser_mouse_state click)
Handle mouse button up messages.
static LRESULT nsws_drawable_keydown(struct gui_window *gw, HWND hwnd, WPARAM wparam)
Handle keydown messages.
nserror
Enumeration of error codes.
@ NSERROR_INIT_FAILED
Initialisation failed.
nserror nsw32_local_history_hide(void)
hide the local history window.
Interface to win32 local history manager using nsw32 core window.
browser_mouse_state
Mouse state: 1 is primary mouse button.
@ BROWSER_MOUSE_PRESS_1
primary button pressed
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
@ BROWSER_MOUSE_PRESS_2
auxillary button pressed
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
@ BROWSER_MOUSE_MOD_2
2nd modifier key pressed (eg.
@ BROWSER_MOUSE_MOD_3
3rd modifier key pressed (eg.
@ BROWSER_MOUSE_MOD_1
1st modifier key pressed (eg.
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
@ BROWSER_MOUSE_HOLDING_2
during button 2 drag
@ BROWSER_MOUSE_HOLDING_1
during button 1 drag
@ BROWSER_MOUSE_DRAG_ON
a drag operation was started and a mouse button is still pressed
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Target independent plotting interface.
Interface to key press operations.
bool browser_window_key_press(struct browser_window *bw, uint32_t key)
Handle key presses in a browser window.
#define NSLOG(catname, level, logmsg, args...)
first entry in window list
int height
height of drawing area
int requestscrolly
scolling requested.
int scrollx
current scroll location
struct gui_window::@32 mouse
int scrolly
current scroll location
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
bool interactive
Redraw to show interactive features.
void win_perror(const char *lpszFunction)
#define LOG_WIN_MSG(h, m, w, l)
log windows message
const struct plotter_table win_plotters
win32 API plot operation table
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
struct gui_window * nsws_get_gui_window(HWND hwnd)
Obtain gui window structure from window handle.
nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect)
Set the scroll position of a win32 browser window.