NetSurf
Functions | Variables
corewindow.c File Reference

win32 generic core window implementation. More...

#include <assert.h>
#include <string.h>
#include <math.h>
#include <windows.h>
#include <windowsx.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utf8.h"
#include "netsurf/types.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
#include "windows/windbg.h"
#include "windows/corewindow.h"
#include "windows/plot.h"
Include dependency graph for corewindow.c:

Go to the source code of this file.

Functions

static void update_scrollbars (struct nsw32_corewindow *nsw32_cw)
 update the scrollbar visibility and size More...
 
static LRESULT nsw32_corewindow_paint (struct nsw32_corewindow *nsw32_cw, HWND hwnd)
 Handle paint messages. More...
 
static LRESULT nsw32_corewindow_vscroll (struct nsw32_corewindow *nsw32_cw, HWND hwnd, WPARAM wparam)
 
static LRESULT nsw32_corewindow_hscroll (struct nsw32_corewindow *nsw32_cw, HWND hwnd, WPARAM wparam)
 
static LRESULT nsw32_corewindow_mousedown (struct nsw32_corewindow *nsw32_cw, HWND hwnd, int x, int y, browser_mouse_state button)
 
static LRESULT nsw32_corewindow_mouseup (struct nsw32_corewindow *nsw32_cw, HWND hwnd, int x, int y, browser_mouse_state button)
 
static LRESULT nsw32_corewindow_close (struct nsw32_corewindow *nsw32_cw)
 
static LRESULT CALLBACK nsw32_window_corewindow_event_callback (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 callback for core window win32 events More...
 
static nserror nsw32_cw_invalidate_area (struct core_window *cw, const struct rect *rect)
 callback from core to request an invalidation of a window area. More...
 
static nserror nsw32_cw_update_size (struct core_window *cw, int width, int height)
 Callback from the core to update the content area size. More...
 
static nserror nsw32_cw_set_scroll (struct core_window *cw, int x, int y)
 
static nserror nsw32_cw_get_scroll (const struct core_window *cw, int *x, int *y)
 
static nserror nsw32_cw_get_window_dimensions (const struct core_window *cw, int *width, int *height)
 Callback from the core to obtain the window viewport dimensions. More...
 
static nserror nsw32_cw_drag_status (struct core_window *cw, core_window_drag_status ds)
 
nserror nsw32_corewindow_init (HINSTANCE hInstance, HWND hWndParent, struct nsw32_corewindow *nsw32_cw)
 initialise elements of nsw32 core window. More...
 
nserror nsw32_corewindow_fini (struct nsw32_corewindow *nsw32_cw)
 finalise elements of nsw32 core window. More...
 
nserror nsw32_create_corewindow_class (HINSTANCE hInstance)
 

Variables

static const char windowclassname_corewindow [] = "nswscorewindowwindow"
 
struct core_window_table nsw32_cw_cb_table
 
struct core_window_tablewin32_core_window_table = &nsw32_cw_cb_table
 

Detailed Description

win32 generic core window implementation.

Provides interface for core renderers to a win32 api client area.

This module is an object that must be encapsulated. Client users should embed a struct nsw32_corewindow at the beginning of their context for this display surface, fill in relevant data and then call nsw32_corewindow_init()

The win32 core window structure requires the callback for draw, key and mouse operations.

Definition in file corewindow.c.

Function Documentation

◆ nsw32_corewindow_close()

static LRESULT nsw32_corewindow_close ( struct nsw32_corewindow nsw32_cw)
static

Definition at line 328 of file corewindow.c.

References nsw32_corewindow::close.

Referenced by nsw32_window_corewindow_event_callback().

Here is the caller graph for this function:

◆ nsw32_corewindow_fini()

nserror nsw32_corewindow_fini ( struct nsw32_corewindow nsw32_cw)

finalise elements of nsw32 core window.

Parameters
nsw32_cwA nsw32 core window structure to initialise
Returns
NSERROR_OK on successful finalisation otherwise error code.

Definition at line 577 of file corewindow.c.

References NSERROR_OK.

Referenced by nsw32_cookies_finalise(), nsw32_global_history_finalise(), nsw32_hotlist_finalise(), and nsw32_local_history_finalise().

Here is the caller graph for this function:

◆ nsw32_corewindow_hscroll()

static LRESULT nsw32_corewindow_hscroll ( struct nsw32_corewindow nsw32_cw,
HWND  hwnd,
WPARAM  wparam 
)
static

Definition at line 226 of file corewindow.c.

References NSLOG.

Referenced by nsw32_window_corewindow_event_callback().

Here is the caller graph for this function:

◆ nsw32_corewindow_init()

nserror nsw32_corewindow_init ( HINSTANCE  hInstance,
HWND  hWndParent,
struct nsw32_corewindow nsw32_cw 
)

initialise elements of nsw32 core window.

As a pre-requisite the draw, key and mouse callbacks must be defined

Parameters
hInstanceThe instance to create the core window in
hWndParentparent window handle may be NULL for top level window.
nsw32_cwA nsw32 core window structure to initialise
Returns
NSERROR_OK on successful initialisation otherwise error code.

Definition at line 519 of file corewindow.c.

References nsw32_corewindow::content_height, nsw32_corewindow::content_width, CORE_WINDOW_DRAG_NONE, nsw32_corewindow::drag_status, nsw32_corewindow::hWnd, NSERROR_NOMEM, NSERROR_OK, NSLOG, nsw32_corewindow::title, and windowclassname_corewindow.

Referenced by nsw32_cookie_init(), nsw32_global_history_init(), nsw32_hotlist_init(), and nsw32_local_history_init().

Here is the caller graph for this function:

◆ nsw32_corewindow_mousedown()

static LRESULT nsw32_corewindow_mousedown ( struct nsw32_corewindow nsw32_cw,
HWND  hwnd,
int  x,
int  y,
browser_mouse_state  button 
)
static

Definition at line 288 of file corewindow.c.

References nsw32_corewindow::mouse.

Referenced by nsw32_window_corewindow_event_callback().

Here is the caller graph for this function:

◆ nsw32_corewindow_mouseup()

static LRESULT nsw32_corewindow_mouseup ( struct nsw32_corewindow nsw32_cw,
HWND  hwnd,
int  x,
int  y,
browser_mouse_state  button 
)
static

Definition at line 308 of file corewindow.c.

References nsw32_corewindow::mouse.

Referenced by nsw32_window_corewindow_event_callback().

Here is the caller graph for this function:

◆ nsw32_corewindow_paint()

static LRESULT nsw32_corewindow_paint ( struct nsw32_corewindow nsw32_cw,
HWND  hwnd 
)
static

Handle paint messages.

Definition at line 117 of file corewindow.c.

References clip(), nsw32_corewindow::draw, and plot_hdc.

Referenced by nsw32_window_corewindow_event_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsw32_corewindow_vscroll()

static LRESULT nsw32_corewindow_vscroll ( struct nsw32_corewindow nsw32_cw,
HWND  hwnd,
WPARAM  wparam 
)
static

/todo win32 corewindow vertical scrolling needs us to compute scroll values and call scrollwindowex()

Definition at line 151 of file corewindow.c.

References NSLOG.

Referenced by nsw32_window_corewindow_event_callback().

Here is the caller graph for this function:

◆ nsw32_create_corewindow_class()

nserror nsw32_create_corewindow_class ( HINSTANCE  hInstance)

Definition at line 584 of file corewindow.c.

References NSERROR_INIT_FAILED, NSERROR_OK, nsw32_window_corewindow_event_callback(), win_perror(), and windowclassname_corewindow.

Referenced by WinMain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsw32_cw_drag_status()

static nserror nsw32_cw_drag_status ( struct core_window *  cw,
core_window_drag_status  ds 
)
static

Definition at line 498 of file corewindow.c.

References nsw32_corewindow::drag_status, and NSERROR_OK.

◆ nsw32_cw_get_scroll()

static nserror nsw32_cw_get_scroll ( const struct core_window *  cw,
int *  x,
int *  y 
)
static

/todo call getscroll apropriately

Definition at line 469 of file corewindow.c.

References NSERROR_NOT_IMPLEMENTED.

◆ nsw32_cw_get_window_dimensions()

static nserror nsw32_cw_get_window_dimensions ( const struct core_window *  cw,
int *  width,
int *  height 
)
static

Callback from the core to obtain the window viewport dimensions.

Parameters
[in]cwthe core window object
[out]widthto be set to viewport width in px
[out]heightto be set to viewport height in px

Definition at line 484 of file corewindow.c.

References height, nsw32_corewindow::hWnd, NSERROR_OK, and width.

◆ nsw32_cw_invalidate_area()

static nserror nsw32_cw_invalidate_area ( struct core_window *  cw,
const struct rect rect 
)
static

callback from core to request an invalidation of a window area.

The specified area of the window should now be considered out of date. If the area is NULL the entire window must be invalidated.

Parameters
[in]cwThe core window to invalidate.
[in]rectarea to redraw or NULL for the entire window area.
Returns
NSERROR_OK on success or appropriate error code.

Definition at line 411 of file corewindow.c.

References nsw32_corewindow::hWnd, NSERROR_OK, rect::x0, rect::x1, rect::y0, and rect::y1.

◆ nsw32_cw_set_scroll()

static nserror nsw32_cw_set_scroll ( struct core_window *  cw,
int  x,
int  y 
)
static

/todo call setscroll apropriately

Definition at line 461 of file corewindow.c.

References NSERROR_OK.

◆ nsw32_cw_update_size()

static nserror nsw32_cw_update_size ( struct core_window *  cw,
int  width,
int  height 
)
static

Callback from the core to update the content area size.

Definition at line 447 of file corewindow.c.

References nsw32_corewindow::content_height, nsw32_corewindow::content_width, height, NSERROR_OK, NSLOG, update_scrollbars(), and width.

Here is the call graph for this function:

◆ nsw32_window_corewindow_event_callback()

static LRESULT CALLBACK nsw32_window_corewindow_event_callback ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

callback for core window win32 events

Parameters
hwndThe win32 window handle
msgThe win32 message identifier
wparamThe w win32 parameter
lparamThe l win32 parameter

Definition at line 343 of file corewindow.c.

References BROWSER_MOUSE_CLICK_1, BROWSER_MOUSE_CLICK_2, BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, nsw32_corewindow_close(), nsw32_corewindow_hscroll(), nsw32_corewindow_mousedown(), nsw32_corewindow_mouseup(), nsw32_corewindow_paint(), nsw32_corewindow_vscroll(), and update_scrollbars().

Referenced by nsw32_create_corewindow_class().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_scrollbars()

static void update_scrollbars ( struct nsw32_corewindow nsw32_cw)
static

update the scrollbar visibility and size

Definition at line 57 of file corewindow.c.

References nsw32_corewindow::content_height, nsw32_corewindow::content_width, and nsw32_corewindow::hWnd.

Referenced by nsw32_cw_update_size(), and nsw32_window_corewindow_event_callback().

Here is the caller graph for this function:

Variable Documentation

◆ nsw32_cw_cb_table

struct core_window_table nsw32_cw_cb_table
Initial value:
= {
.invalidate = nsw32_cw_invalidate_area,
.set_extent = nsw32_cw_update_size,
.set_scroll = nsw32_cw_set_scroll,
.get_scroll = nsw32_cw_get_scroll,
.get_dimensions = nsw32_cw_get_window_dimensions,
.drag_status = nsw32_cw_drag_status
}
static nserror nsw32_cw_set_scroll(struct core_window *cw, int x, int y)
Definition: corewindow.c:461
static nserror nsw32_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
Definition: corewindow.c:498
static nserror nsw32_cw_get_window_dimensions(const struct core_window *cw, int *width, int *height)
Callback from the core to obtain the window viewport dimensions.
Definition: corewindow.c:484
static nserror nsw32_cw_invalidate_area(struct core_window *cw, const struct rect *rect)
callback from core to request an invalidation of a window area.
Definition: corewindow.c:411
static nserror nsw32_cw_update_size(struct core_window *cw, int width, int height)
Callback from the core to update the content area size.
Definition: corewindow.c:447
static nserror nsw32_cw_get_scroll(const struct core_window *cw, int *x, int *y)
Definition: corewindow.c:469

Definition at line 506 of file corewindow.c.

◆ win32_core_window_table

struct core_window_table* win32_core_window_table = &nsw32_cw_cb_table

Definition at line 515 of file corewindow.c.

Referenced by WinMain().

◆ windowclassname_corewindow

const char windowclassname_corewindow[] = "nswscorewindowwindow"
static

Definition at line 51 of file corewindow.c.

Referenced by nsw32_corewindow_init(), and nsw32_create_corewindow_class().