Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/67b22a811128f5a0635430151a73442d1f100735
...commit
http://git.netsurf-browser.org/netsurf.git/commit/67b22a811128f5a0635430151a73442d1f100735
...tree
http://git.netsurf-browser.org/netsurf.git/tree/67b22a811128f5a0635430151a73442d1f100735
The branch, master has been updated
via 67b22a811128f5a0635430151a73442d1f100735 (commit)
from 9d0943b8e561dd2e5449cd9d53d8b5c2f439442d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=67b22a811128f5a0635430151a73442d1f100735
commit 67b22a811128f5a0635430151a73442d1f100735
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
cleanup windows frontend documentation comments and spelling
diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c
index cb94291..0bd1bae 100644
--- a/frontends/windows/drawable.c
+++ b/frontends/windows/drawable.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 implementation of drawable window showing browser context
+ */
+
#include <stdbool.h>
#include <stdint.h>
@@ -38,6 +43,7 @@
static const char windowclassname_drawable[] = "nswsdrawablewindow";
+
/**
* Handle wheel scroll messages.
*/
@@ -66,6 +72,7 @@ nsws_drawable_wheel(struct gui_window *gw, HWND hwnd, WPARAM
wparam)
return 0;
}
+
/**
* Handle vertical scroll messages.
*/
@@ -121,8 +128,8 @@ nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd,
WPARAM wparam)
si.fMask = SIF_POS;
if ((gw->bw != NULL) &&
- (browser_window_get_extents(gw->bw, true,
- &width, &height) == NSERROR_OK)) {
+ (browser_window_get_extents(gw->bw, true,
+ &width, &height) == NSERROR_OK)) {
si.nPos = min(si.nPos, height - gw->height);
}
@@ -131,7 +138,7 @@ nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd,
WPARAM wparam)
GetScrollInfo(hwnd, SB_VERT, &si);
if (si.nPos != mem) {
win32_window_set_scroll(gw, gw->scrollx, gw->scrolly +
- gw->requestscrolly + si.nPos - mem);
+ gw->requestscrolly + si.nPos - mem);
}
return 0;
@@ -186,8 +193,8 @@ nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd,
WPARAM wparam)
si.fMask = SIF_POS;
if ((gw->bw != NULL) &&
- (browser_window_get_extents(gw->bw, true,
- &width, &height) == NSERROR_OK)) {
+ (browser_window_get_extents(gw->bw, true,
+ &width, &height) == NSERROR_OK)) {
si.nPos = min(si.nPos, width - gw->width);
}
si.nPos = max(si.nPos, 0);
@@ -195,13 +202,14 @@ nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd,
WPARAM wparam)
GetScrollInfo(hwnd, SB_HORZ, &si);
if (si.nPos != mem) {
win32_window_set_scroll(gw,
- gw->scrollx + gw->requestscrollx + si.nPos -
mem,
- gw->scrolly);
+ gw->scrollx + gw->requestscrollx +
si.nPos - mem,
+ gw->scrolly);
}
return 0;
}
+
/**
* Handle resize events.
*/
@@ -212,6 +220,7 @@ nsws_drawable_resize(struct gui_window *gw)
return 0;
}
+
/**
* Handle key press messages.
*/
@@ -289,7 +298,7 @@ nsws_drawable_key(struct gui_window *gw, HWND hwnd, WPARAM
wparam)
break;
}
- if ((i >= 'A') &&
+ if ((i >= 'A') &&
(i <= 'Z') &&
(((!capslock) && (!shift)) || ((capslock) && (shift)))) {
i += 'a' - 'A';
@@ -371,7 +380,10 @@ nsws_drawable_mouseup(struct gui_window *gw,
gw->mouse->state &= ~BROWSER_MOUSE_MOD_3;
if ((gw->mouse->state & click) != 0) {
- LOG("mouse click bw %p, state 0x%x, x %f, y %f", gw->bw,
gw->mouse->state, (x + gw->scrollx) / gw->scale, (y + gw->scrolly) / gw->scale);
+ LOG("mouse click bw %p, state 0x%x, x %f, y %f",
+ gw->bw, gw->mouse->state,
+ (x + gw->scrollx) / gw->scale,
+ (y + gw->scrolly) / gw->scale);
browser_window_mouse_click(gw->bw,
gw->mouse->state,
@@ -415,7 +427,10 @@ nsws_drawable_mousedown(struct gui_window *gw,
gw->mouse->pressed_x = (x + gw->scrollx) / gw->scale;
gw->mouse->pressed_y = (y + gw->scrolly) / gw->scale;
- LOG("mouse click bw %p, state %x, x %f, y %f", gw->bw,
gw->mouse->state, (x + gw->scrollx) / gw->scale, (y + gw->scrolly) / gw->scale);
+ LOG("mouse click bw %p, state %x, x %f, y %f",
+ gw->bw, gw->mouse->state,
+ (x + gw->scrollx) / gw->scale,
+ (y + gw->scrolly) / gw->scale);
browser_window_mouse_click(gw->bw, gw->mouse->state,
(x + gw->scrollx) / gw->scale,
@@ -424,6 +439,7 @@ nsws_drawable_mousedown(struct gui_window *gw,
return 0;
}
+
/**
* Handle mouse movement messages.
*/
@@ -480,6 +496,7 @@ nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
return 0;
}
+
/**
* Called when activity occours within the drawable window.
*/
@@ -564,12 +581,13 @@ nsws_window_drawable_event_callback(HWND hwnd,
return DefWindowProc(hwnd, msg, wparam, lparam);
}
+
/**
* Create a drawable window.
*/
HWND
-nsws_window_create_drawable(HINSTANCE hinstance,
- HWND hparent,
+nsws_window_create_drawable(HINSTANCE hinstance,
+ HWND hparent,
struct gui_window *gw)
{
HWND hwnd;
@@ -594,6 +612,7 @@ nsws_window_create_drawable(HINSTANCE hinstance,
return hwnd;
}
+
/**
* Create the drawable window class.
*/
diff --git a/frontends/windows/filetype.c b/frontends/windows/filetype.c
index ed07dd5..4e7f2f4 100644
--- a/frontends/windows/filetype.c
+++ b/frontends/windows/filetype.c
@@ -16,6 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file Fetch operation implementation for win32
+ */
+
#include <stdlib.h>
#include <string.h>
@@ -26,7 +30,10 @@
#include "windows/filetype.h"
/**
- * filetype -- determine the MIME type of a local file
+ * determine the MIME type of a local file.
+ *
+ * \param unix_path The unix style path to the file.
+ * \return The mime type of the file.
*/
static const char *fetch_filetype(const char *unix_path)
{
@@ -52,6 +59,7 @@ static const char *fetch_filetype(const char *unix_path)
return "text/html";
}
+/** win32 fetch operation table */
static struct gui_fetch_table fetch_table = {
.filetype = fetch_filetype,
};
diff --git a/frontends/windows/font.c b/frontends/windows/font.c
index f50ba6e..3407ec4 100644
--- a/frontends/windows/font.c
+++ b/frontends/windows/font.c
@@ -19,7 +19,7 @@
/**
* \file
- * Windows font handling implementation.
+ * Windows font handling and character encoding implementation.
*/
#include "utils/config.h"
@@ -38,36 +38,57 @@
HWND font_hwnd;
-nserror utf8_to_font_encoding(const struct font_desc* font,
- const char *string,
- size_t len,
- char **result)
+/* exported interface documented in windows/font.h */
+nserror
+utf8_to_font_encoding(const struct font_desc* font,
+ const char *string,
+ size_t len,
+ char **result)
{
return utf8_to_enc(string, font->encoding, len, result);
}
-static nserror utf8_to_local_encoding(const char *string,
- size_t len,
- char **result)
+
+/**
+ * Convert a string to UCS2 from UTF8
+ *
+ * \param[in] string source string
+ * \param[in] len source string length
+ * \param[out] result The UCS2 string
+ */
+static nserror
+utf8_to_local_encoding(const char *string, size_t len, char **result)
{
return utf8_to_enc(string, "UCS-2", len, result);
}
-static nserror utf8_from_local_encoding(const char *string, size_t len,
- char **result)
+
+/**
+ * Convert a string to UTF8 from local encoding
+ *
+ * \param[in] string source string
+ * \param[in] len source string length
+ * \param[out] result The UTF8 string
+ */
+static nserror
+utf8_from_local_encoding(const char *string, size_t len, char **result)
{
assert(string && result);
- if (len == 0)
+ if (len == 0) {
len = strlen(string);
+ }
*result = strndup(string, len);
- if (!(*result))
+ if (!(*result)) {
return NSERROR_NOMEM;
+ }
return NSERROR_OK;
}
+
+/* exported interface documented in windows/font.h */
HFONT get_font(const plot_font_style_t *style)
{
char *face = NULL;
@@ -122,16 +143,18 @@ HFONT get_font(const plot_font_style_t *style)
free(face);
if (font == NULL) {
- if (style->family == PLOT_FONT_FAMILY_MONOSPACE)
+ if (style->family == PLOT_FONT_FAMILY_MONOSPACE) {
font = (HFONT) GetStockObject(ANSI_FIXED_FONT);
- else
+ } else {
font = (HFONT) GetStockObject(ANSI_VAR_FONT);
+ }
}
if (font == NULL)
font = (HFONT) GetStockObject(SYSTEM_FONT);
return font;
}
+
/**
* Measure the width of a string.
*
@@ -139,13 +162,13 @@ HFONT get_font(const plot_font_style_t *style)
* \param[in] string UTF-8 string to measure
* \param[in] length length of string, in bytes
* \param[out] width updated to width of string[0..length)
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
win32_font_width(const plot_font_style_t *style,
- const char *string,
- size_t length,
- int *width)
+ const char *string,
+ size_t length,
+ int *width)
{
HDC hdc;
HFONT font;
@@ -184,15 +207,15 @@ win32_font_width(const plot_font_style_t *style,
* \param x x coordinate to search for
* \param char_offset updated to offset in string of actual_x, [0..length]
* \param actual_x updated to x coordinate of character closest to x
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
win32_font_position(const plot_font_style_t *style,
- const char *string,
- size_t length,
- int x,
- size_t *char_offset,
- int *actual_x)
+ const char *string,
+ size_t length,
+ int x,
+ size_t *char_offset,
+ int *actual_x)
{
HDC hdc;
HFONT font;
@@ -211,8 +234,8 @@ win32_font_position(const plot_font_style_t *style,
if ((GetTextExtentExPointA(hdc, string, length, x, &offset,
NULL,&s) != 0) &&
(GetTextExtentPoint32A(hdc, string, offset, &s) != 0)) {
- *char_offset = (size_t)offset;
- *actual_x = s.cx;
+ *char_offset = (size_t)offset;
+ *actual_x = s.cx;
} else {
ret = NSERROR_UNKNOWN;
}
@@ -235,7 +258,7 @@ win32_font_position(const plot_font_style_t *style,
* \param x width available
* \param char_offset updated to offset in string of actual_x, [0..length]
* \param actual_x updated to x coordinate of character closest to x
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*
* On exit, [char_offset == 0 ||
* string[char_offset] == ' ' ||
@@ -243,16 +266,21 @@ win32_font_position(const plot_font_style_t *style,
*/
static nserror
win32_font_split(const plot_font_style_t *style,
- const char *string,
- size_t length,
- int x,
- size_t *char_offset,
- int *actual_x)
+ const char *string,
+ size_t length,
+ int x,
+ size_t *char_offset,
+ int *actual_x)
{
int c_off;
nserror ret = NSERROR_UNKNOWN;
- if (win32_font_position(style, string, length, x, char_offset,
actual_x)) {
+ if (win32_font_position(style,
+ string,
+ length,
+ x,
+ char_offset,
+ actual_x)) {
c_off = *char_offset;
if (*char_offset == length) {
ret = NSERROR_OK;
@@ -271,7 +299,10 @@ win32_font_split(const plot_font_style_t *style,
}
}
- success = win32_font_width(style, string, *char_offset,
actual_x);
+ success = win32_font_width(style,
+ string,
+ *char_offset,
+ actual_x);
if (success) {
ret = NSERROR_OK;
}
@@ -279,13 +310,14 @@ win32_font_split(const plot_font_style_t *style,
}
/*
- LOG("ret %d Split %u chars at %ipx: Split at char %i (%ipx) - %.*s",
- ret, length, x, *char_offset, *actual_x, *char_offset, string);
+ LOG("ret %d Split %u chars at %ipx: Split at char %i (%ipx) - %.*s",
+ ret, length, x, *char_offset, *actual_x, *char_offset, string);
*/
return ret;
}
+/** win32 font operations table */
static struct gui_layout_table layout_table = {
.width = win32_font_width,
.position = win32_font_position,
@@ -294,7 +326,7 @@ static struct gui_layout_table layout_table = {
struct gui_layout_table *win32_layout_table = &layout_table;
-
+/** win32 utf8 encoding operations table */
static struct gui_utf8_table utf8_table = {
.utf8_to_local = utf8_to_local_encoding,
.local_to_utf8 = utf8_from_local_encoding,
diff --git a/frontends/windows/font.h b/frontends/windows/font.h
index a1077e0..ec2c262 100644
--- a/frontends/windows/font.h
+++ b/frontends/windows/font.h
@@ -38,10 +38,15 @@ struct font_desc {
struct gui_layout_table *win32_layout_table;
struct gui_utf8_table *win32_utf8_table;
-extern nserror utf8_to_font_encoding(const struct font_desc* font,
- const char *string,
- size_t len,
- char **result);
+/**
+ * convert from utf-8 to win32 font encoding.
+ *
+ * \param[in] font font descriptor
+ * \param[in] string source utf-8 string
+ * \param[in] len The length of the utf-8 data
+ * \param[out] result The reencoded string.
+ */
+extern nserror utf8_to_font_encoding(const struct font_desc* font, const char
*string, size_t len, char **result);
/**
* generate a win32 font handle from a generic font style
diff --git a/frontends/windows/global_history.c
b/frontends/windows/global_history.c
index 0ef0963..4e90a77 100644
--- a/frontends/windows/global_history.c
+++ b/frontends/windows/global_history.c
@@ -18,7 +18,7 @@
/**
* \file
- * Implementation of win32 cookie manager.
+ * Implementation of win32 global history interface.
*/
#include <stdint.h>
diff --git a/frontends/windows/gui.c b/frontends/windows/gui.c
index f5808de..602dcd4 100644
--- a/frontends/windows/gui.c
+++ b/frontends/windows/gui.c
@@ -17,6 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 gui implementation.
+ */
+
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -47,6 +52,7 @@ HINSTANCE hinst;
static bool win32_quit = false;
+/* exported interface documented in gui.h */
void win32_set_quit(bool q)
{
win32_quit = q;
@@ -98,7 +104,7 @@ void win32_run(void)
nserror win32_warning(const char *warning, const char *detail)
{
size_t len = 1 + ((warning != NULL) ? strlen(messages_get(warning)) :
- 0) + ((detail != 0) ? strlen(detail) : 0);
+ 0) + ((detail != 0) ? strlen(detail) : 0);
char message[len];
snprintf(message, len, messages_get(warning), detail);
MessageBox(NULL, message, "Warning", MB_ICONWARNING);
@@ -110,8 +116,8 @@ nserror win32_warning(const char *warning, const char
*detail)
/**
* Core asks front end for clipboard contents.
*
- * \param buffer UTF-8 text, allocated by front end, ownership yeilded to
core
- * \param length Byte length of UTF-8 text in buffer
+ * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
+ * \param length Byte length of UTF-8 text in buffer
*/
static void gui_get_clipboard(char **buffer, size_t *length)
{
@@ -137,7 +143,7 @@ static void gui_get_clipboard(char **buffer, size_t *length)
* \param n_styles Number of text run styles in array
*/
static void gui_set_clipboard(const char *buffer, size_t length,
- nsclipboard_styles styles[], int n_styles)
+ nsclipboard_styles styles[], int n_styles)
{
/* TODO: Implement this */
HANDLE hnew;
@@ -169,5 +175,3 @@ static struct gui_clipboard_table clipboard_table = {
};
struct gui_clipboard_table *win32_clipboard_table = &clipboard_table;
-
-
diff --git a/frontends/windows/localhistory.c b/frontends/windows/localhistory.c
index ae3b7f5..8921b2b 100644
--- a/frontends/windows/localhistory.c
+++ b/frontends/windows/localhistory.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 local history viewer implementation.
+ */
+
#include "utils/config.h"
#include <windows.h>
@@ -36,6 +41,7 @@
static const char windowclassname_localhistory[] = "nswslocalhistorywindow";
+/** local history context */
struct nsws_localhistory {
HWND hwnd; /**< the window handle */
int width; /**< the width of the memory history */
@@ -47,14 +53,21 @@ struct nsws_localhistory {
};
+/**
+ * set the scrollbar sizes and offset
+ *
+ * \param l localhistory context.
+ * \param gw win32 gui window
+ */
static void
nsws_localhistory_scroll_check(struct nsws_localhistory *l,
struct gui_window *gw)
{
SCROLLINFO si;
- if ((gw->bw == NULL) || (l->hwnd == NULL))
+ if ((gw->bw == NULL) || (l->hwnd == NULL)) {
return;
+ }
browser_window_history_size(gw->bw, &(l->width), &(l->height));
@@ -69,14 +82,22 @@ nsws_localhistory_scroll_check(struct nsws_localhistory *l,
si.nMax = l->width;
si.nPage = l->guiwidth;
SetScrollInfo(l->hwnd, SB_HORZ, &si, TRUE);
- if (l->guiheight >= l->height)
+ if (l->guiheight >= l->height) {
l->vscroll = 0;
- if (l->guiwidth >= l->width)
+ }
+ if (l->guiwidth >= l->width) {
l->hscroll = 0;
+ }
SendMessage(l->hwnd, WM_PAINT, 0, 0);
}
+/**
+ * redraw local history window
+ *
+ * \param l localhistory context.
+ * \param gw win32 gui window
+ */
static void
nsws_localhistory_up(struct nsws_localhistory *l, struct gui_window *gw)
{
@@ -108,17 +129,34 @@ nsws_localhistory_up(struct nsws_localhistory *l, struct
gui_window *gw)
}
+/**
+ * close local history window
+ *
+ * \param gw the gui window to close history for
+ */
void nsws_localhistory_close(struct gui_window *w)
{
struct nsws_localhistory *l = gui_window_localhistory(w);
- if (l != NULL)
+ if (l != NULL) {
CloseWindow(l->hwnd);
+ }
}
-static LRESULT CALLBACK
-nsws_localhistory_event_callback(HWND hwnd, UINT msg,
- WPARAM wparam, LPARAM lparam)
+/**
+ * handler for win32 messges on local history window
+ *
+ * \param hwnd The win32 handle of the appearance dialog
+ * \param msg The message code
+ * \param wparam The message w parameter
+ * \param lparam The message l parameter
+ * \return result appropriate for message
+ */
+static LRESULT CALLBACK
+nsws_localhistory_event_callback(HWND hwnd,
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lparam)
{
int x,y;
struct gui_window *gw;
@@ -143,7 +181,7 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
nsws_localhistory_scroll_check(gw->localhistory, gw);
break;
- case WM_LBUTTONUP:
+ case WM_LBUTTONUP:
if (gw->bw == NULL)
break;
@@ -151,20 +189,20 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
y = GET_Y_LPARAM(lparam);
if (browser_window_history_click(gw->bw,
- gw->localhistory->hscroll + x,
- gw->localhistory->vscroll + y,
- false)) {
+ gw->localhistory->hscroll + x,
+ gw->localhistory->vscroll + y,
+ false)) {
DestroyWindow(hwnd);
}
-
+
break;
- case WM_MOUSEMOVE:
+ case WM_MOUSEMOVE:
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
-
+
case WM_VSCROLL:
{
@@ -268,12 +306,12 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
plot_hdc = hdc;
browser_window_history_redraw_rectangle(gw->bw,
- gw->localhistory->hscroll + ps.rcPaint.left,
- gw->localhistory->vscroll + ps.rcPaint.top,
- gw->localhistory->hscroll + (ps.rcPaint.right
- ps.rcPaint.left),
- gw->localhistory->vscroll + (ps.rcPaint.bottom
- ps.rcPaint.top),
- ps.rcPaint.left,
- ps.rcPaint.top, &ctx);
+ gw->localhistory->hscroll + ps.rcPaint.left,
+ gw->localhistory->vscroll + ps.rcPaint.top,
+ gw->localhistory->hscroll + (ps.rcPaint.right -
ps.rcPaint.left),
+ gw->localhistory->vscroll + (ps.rcPaint.bottom
- ps.rcPaint.top),
+ ps.rcPaint.left,
+ ps.rcPaint.top, &ctx);
plot_hdc = tmp_hdc;
@@ -284,7 +322,7 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
}
case WM_CLOSE:
- DestroyWindow(hwnd);
+ DestroyWindow(hwnd);
return 1;
case WM_DESTROY:
@@ -316,7 +354,7 @@ struct nsws_localhistory
*nsws_window_create_localhistory(struct gui_window *gw)
UpdateWindow(gw->localhistory->hwnd);
ShowWindow(gw->localhistory->hwnd, SW_SHOWNORMAL);
return gw->localhistory;
- }
+ }
localhistory = calloc(1, sizeof(struct nsws_localhistory));
@@ -329,19 +367,19 @@ struct nsws_localhistory
*nsws_window_create_localhistory(struct gui_window *gw)
localhistory->height = 0;
if (gw->bw != NULL) {
- browser_window_history_size(gw->bw,
- &(localhistory->width),
- &(localhistory->height));
+ browser_window_history_size(gw->bw,
+ &(localhistory->width),
+ &(localhistory->height));
}
GetWindowRect(gw->main, &r);
- SetWindowPos(gw->main, HWND_NOTOPMOST, 0, 0, 0, 0,
+ SetWindowPos(gw->main, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE);
localhistory->guiwidth = min(r.right - r.left - margin,
- localhistory->width + margin);
+ localhistory->width + margin);
localhistory->guiheight = min(r.bottom - r.top - margin,
- localhistory->height + margin);
+ localhistory->height + margin);
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
@@ -386,7 +424,8 @@ struct nsws_localhistory
*nsws_window_create_localhistory(struct gui_window *gw)
/* exported method documented in windows/localhistory.h */
nserror
-nsws_create_localhistory_class(HINSTANCE hinstance) {
+nsws_create_localhistory_class(HINSTANCE hinstance)
+{
nserror ret = NSERROR_OK;
WNDCLASSEX w;
diff --git a/frontends/windows/plot.c b/frontends/windows/plot.c
index b733dfd..1bd0ba4 100644
--- a/frontends/windows/plot.c
+++ b/frontends/windows/plot.c
@@ -17,6 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 plotter implementation.
+ */
+
#include "utils/config.h"
#include <sys/types.h>
#include <stdint.h>
@@ -48,7 +53,8 @@
HDC plot_hdc;
-static RECT plot_clip; /* currently set clipping rectangle */
+/** currently set clipping rectangle */
+static RECT plot_clip;
/**
@@ -111,6 +117,14 @@ plot_block(COLORREF col, int x, int y, int width, int
height)
* plot an alpha blended bitmap
*
* blunt force truma way of achiving alpha blended plotting
+ *
+ * \param hdc drawing cotext
+ * \param bitmap bitmap to render
+ * \param x x coordinate to plot at
+ * \param y y coordinate to plot at
+ * \param width The width to plot the bitmap into
+ * \param height The height to plot the bitmap into
+ * \return NSERROR_OK on success else appropriate error code.
*/
static nserror
plot_alpha_bitmap(HDC hdc,
@@ -145,8 +159,11 @@ plot_alpha_bitmap(HDC hdc,
BITMAPINFO *bmi;
HBITMAP MemBMh;
- PLOT_LOG("%p bitmap %d,%d width %d height %d", bitmap, x, y, width,
height);
- PLOT_LOG("clipped %ld,%ld to %ld,%ld",plot_clip.left, plot_clip.top,
plot_clip.right, plot_clip.bottom);
+ PLOT_LOG("%p bitmap %d,%d width %d height %d",
+ bitmap, x, y, width, height);
+ PLOT_LOG("clipped %ld,%ld to %ld,%ld",
+ plot_clip.left, plot_clip.top,
+ plot_clip.right, plot_clip.bottom);
Memhdc = CreateCompatibleDC(hdc);
if (Memhdc == NULL) {
@@ -156,7 +173,7 @@ plot_alpha_bitmap(HDC hdc,
if ((bitmap->width != width) ||
(bitmap->height != height)) {
PLOT_LOG("scaling from %d,%d to %d,%d",
- bitmap->width, bitmap->height, width, height);
+ bitmap->width, bitmap->height, width, height);
bitmap = bitmap_scale(bitmap, width, height);
if (bitmap == NULL) {
return NSERROR_INVALID;
@@ -256,6 +273,14 @@ plot_alpha_bitmap(HDC hdc,
/**
+ * Internal bitmap plotting
+ *
+ * \param bitmap The bitmap to plot
+ * \param x x coordinate to plot at
+ * \param y y coordinate to plot at
+ * \param width The width to plot the bitmap into
+ * \param height The height to plot the bitmap into
+ * \return NSERROR_OK on success else appropriate error code.
*/
static nserror
plot_bitmap(struct bitmap *bitmap, int x, int y, int width, int height)
@@ -331,8 +356,6 @@ plot_bitmap(struct bitmap *bitmap, int x, int y, int width,
int height)
}
-
-
/**
* \brief Sets a clip rectangle for subsequent plot operations.
*
@@ -377,7 +400,7 @@ arc(const struct redraw_context *ctx,
int radius, int angle1, int angle2)
{
PLOT_LOG("arc centre %d,%d radius %d from %d to %d", x, y, radius,
- angle1, angle2);
+ angle1, angle2);
/* ensure the plot HDC is set */
if (plot_hdc == NULL) {
@@ -564,8 +587,8 @@ disc(const struct redraw_context *ctx,
*/
static nserror
line(const struct redraw_context *ctx,
- const plot_style_t *style,
- const struct rect *line)
+ const plot_style_t *style,
+ const struct rect *line)
{
PLOT_LOG("from %d,%d to %d,%d", x0, y0, x1, y1);
@@ -582,10 +605,10 @@ line(const struct redraw_context *ctx,
COLORREF col = (DWORD)(style->stroke_colour & 0x00FFFFFF);
/* windows 0x00bbggrr */
- DWORD penstyle = PS_GEOMETRIC | ((style->stroke_type ==
- PLOT_OP_TYPE_DOT) ? PS_DOT :
- (style->stroke_type ==
PLOT_OP_TYPE_DASH) ? PS_DASH:
- 0);
+ DWORD penstyle = PS_GEOMETRIC |
+ ((style->stroke_type == PLOT_OP_TYPE_DOT) ? PS_DOT :
+ (style->stroke_type == PLOT_OP_TYPE_DASH) ? PS_DASH:
+ 0);
LOGBRUSH lb = {BS_SOLID, col, 0};
HPEN pen = ExtCreatePen(penstyle, style->stroke_width, &lb, 0, NULL);
if (pen == NULL) {
@@ -630,8 +653,8 @@ line(const struct redraw_context *ctx,
*/
static nserror
rectangle(const struct redraw_context *ctx,
- const plot_style_t *style,
- const struct rect *rect)
+ const plot_style_t *style,
+ const struct rect *rect)
{
PLOT_LOG("rectangle from %d,%d to %d,%d",
rect->x0, rect->y0, rect->x1, rect->y1);
@@ -713,9 +736,9 @@ rectangle(const struct redraw_context *ctx,
*/
static nserror
polygon(const struct redraw_context *ctx,
- const plot_style_t *style,
- const int *p,
- unsigned int n)
+ const plot_style_t *style,
+ const int *p,
+ unsigned int n)
{
PLOT_LOG("polygon %d points", n);
@@ -802,11 +825,11 @@ polygon(const struct redraw_context *ctx,
*/
static nserror
path(const struct redraw_context *ctx,
- const plot_style_t *pstyle,
- const float *p,
- unsigned int n,
- float width,
- const float transform[6])
+ const plot_style_t *pstyle,
+ const float *p,
+ unsigned int n,
+ float width,
+ const float transform[6])
{
PLOT_LOG("path unimplemented");
return NSERROR_OK;
@@ -839,12 +862,12 @@ path(const struct redraw_context *ctx,
*/
static nserror
bitmap(const struct redraw_context *ctx,
- struct bitmap *bitmap,
- int x, int y,
- int width,
- int height,
- colour bg,
- bitmap_flags_t flags)
+ struct bitmap *bitmap,
+ int x, int y,
+ int width,
+ int height,
+ colour bg,
+ bitmap_flags_t flags)
{
int xf,yf;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
@@ -875,7 +898,11 @@ bitmap(const struct redraw_context *ctx,
if ((*(bitmap->pixdata + 3) & 0xff) == 0) {
return NSERROR_OK;
}
- return plot_block((*(COLORREF *)bitmap->pixdata) &
0xffffff, x, y, x + width, y + height);
+ return plot_block((*(COLORREF *)bitmap->pixdata) &
0xffffff,
+ x,
+ y,
+ x + width,
+ y + height);
} else {
return plot_bitmap(bitmap, x, y, width, height);
@@ -896,7 +923,8 @@ bitmap(const struct redraw_context *ctx,
/* Optimise tiled plots of bitmaps scaled to 1x1 by replacing with
* a flat fill of the area. Can only be done when image is fully
- * opaque. */
+ * opaque.
+ */
if ((width == 1) && (height == 1)) {
if (bitmap->opaque) {
/** TODO: Currently using top left pixel. Maybe centre
@@ -909,8 +937,10 @@ bitmap(const struct redraw_context *ctx,
}
}
- PLOT_LOG("Tiled plotting %d,%d by %d,%d",x,y,width,height);
- PLOT_LOG("clipped %ld,%ld to %ld,%ld",plot_clip.left, plot_clip.top,
plot_clip.right, plot_clip.bottom);
+ PLOT_LOG("Tiled plotting %d,%d by %d,%d", x, y, width, height);
+ PLOT_LOG("clipped %ld,%ld to %ld,%ld",
+ plot_clip.left, plot_clip.top,
+ plot_clip.right, plot_clip.bottom);
/* get left most tile position */
if (repeat_x) {
@@ -922,7 +952,8 @@ bitmap(const struct redraw_context *ctx,
for (; y > plot_clip.top; y -= height);
}
- PLOT_LOG("repeat from %d,%d to %ld,%ld", x, y, plot_clip.right,
plot_clip.bottom);
+ PLOT_LOG("repeat from %d,%d to %ld,%ld",
+ x, y, plot_clip.right, plot_clip.bottom);
/* tile down and across to extents */
for (xf = x; xf < plot_clip.right; xf += width) {
@@ -952,11 +983,11 @@ bitmap(const struct redraw_context *ctx,
*/
static nserror
text(const struct redraw_context *ctx,
- const struct plot_font_style *fstyle,
- int x,
- int y,
- const char *text,
- size_t length)
+ const struct plot_font_style *fstyle,
+ int x,
+ int y,
+ const char *text,
+ size_t length)
{
PLOT_LOG("words %s at %d,%d", text, x, y);
diff --git a/frontends/windows/prefs.c b/frontends/windows/prefs.c
index 03414ee..f84ee1c 100644
--- a/frontends/windows/prefs.c
+++ b/frontends/windows/prefs.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 preferences dialog implementation.
+ */
+
#include "utils/config.h"
#include <windows.h>
@@ -31,9 +36,19 @@
#include "windows/resourceid.h"
#include "windows/windbg.h"
+/** Preferences dialog width */
#define NSWS_PREFS_WINDOW_WIDTH 600
+/** Preferences dialog height */
#define NSWS_PREFS_WINDOW_HEIGHT 400
+
+/**
+ * Prepare preferences dialog font tab
+ *
+ * \param fontfamily The font family
+ * \param parent The parent window win32 handle
+ * \return The selected font or NULL on error
+ */
static CHOOSEFONT *nsws_prefs_font_prepare(int fontfamily, HWND parent)
{
CHOOSEFONT *cf = malloc(sizeof(CHOOSEFONT));
@@ -81,6 +96,15 @@ static CHOOSEFONT *nsws_prefs_font_prepare(int fontfamily,
HWND parent)
return cf;
}
+
+/**
+ * Update value in spinner control when it is changed
+ *
+ * \param sub The window handle of the spinner control
+ * \param change The amount the control changed by
+ * \param minval The minimum allowed value of the control
+ * \param maxval The maximum allowed value of the control
+ */
static void change_spinner(HWND sub, double change, double minval, double
maxval)
{
char *temp, number[6];
@@ -90,8 +114,9 @@ static void change_spinner(HWND sub, double change, double
minval, double maxval
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
temp = malloc(len + 1);
- if (temp == NULL)
+ if (temp == NULL) {
return;
+ }
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM) temp);
@@ -101,17 +126,29 @@ static void change_spinner(HWND sub, double change,
double minval, double maxval
value = max(value, minval);
value = min(value, maxval);
- if ((change == 1.0) || (change == -1.0))
+ if ((change == 1.0) || (change == -1.0)) {
snprintf(number, 6, "%.0f", value);
- else
+ } else {
snprintf(number, 6, "%.1f", value);
+ }
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
}
+/**
+ * Handle messages to the appearance preference dialog
+ *
+ * \param hwnd The win32 handle of the appearance dialog
+ * \param msg The message code
+ * \param wparam The message w parameter
+ * \param lParam The message l parameter
+ * \return result appropriate for message
+ */
static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd,
- UINT msg, WPARAM wparam, LPARAM lParam)
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lParam)
{
int len;
char *temp, number[6];
@@ -192,7 +229,7 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND
hwnd,
/* animation */
sub = GetDlgItem(hwnd, IDC_PREFS_NOANIMATION);
SendMessage(sub, BM_SETCHECK,
(WPARAM)((nsoption_bool(animate_images))
- ? BST_UNCHECKED : BST_CHECKED), 0);
+ ? BST_UNCHECKED :
BST_CHECKED), 0);
if (nsoption_int(minimum_gif_delay) != 0) {
sub = GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY);
@@ -222,13 +259,13 @@ static BOOL CALLBACK
options_appearance_dialog_handler(HWND hwnd,
if (temp != NULL) {
SendMessage(sub, WM_GETTEXT, (WPARAM)
(len + 1), (LPARAM) temp);
- nsoption_set_int(font_min_size,
+ nsoption_set_int(font_min_size,
(int)(10 * strtod(temp,
NULL)));
free(temp);
}
/* animation */
- nsoption_set_bool(animate_images,
+ nsoption_set_bool(animate_images,
(IsDlgButtonChecked(hwnd,
IDC_PREFS_NOANIMATION) == BST_CHECKED) ? true : false);
@@ -259,7 +296,7 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND
hwnd,
case IDC_PREFS_ANIMATIONDELAY_SPIN:
change_spinner(GetDlgItem(hwnd,
IDC_PREFS_ANIMATIONDELAY), 0.1 * ud->iDelta, 0.1, 100.0);
return TRUE;
-
+
}
}
break;
@@ -276,8 +313,8 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND
hwnd,
SendMessage(sub, CB_GETCURSEL, 0, 0) -
1);
nsoption_set_bool(http_proxy,
(nsoption_int(http_proxy_auth) !=
-1));
- nsoption_set_int(http_proxy_auth,
- nsoption_int(http_proxy_auth) +
+ nsoption_set_int(http_proxy_auth,
+ nsoption_int(http_proxy_auth) +
(nsoption_bool(http_proxy)) ? 0 : 1);
break;
@@ -288,7 +325,7 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND
hwnd,
}
if (ChooseFont(cf) == TRUE) {
- nsoption_set_charp(font_sans,
+ nsoption_set_charp(font_sans,
strdup(cf->lpLogFont->lfFaceName));
}
@@ -390,12 +427,12 @@ static BOOL CALLBACK
options_appearance_dialog_handler(HWND hwnd,
break;
}
- case IDC_PREFS_FONTDEF:
+ case IDC_PREFS_FONTDEF:
sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF);
nsoption_set_int(font_default,
SendMessage(sub, CB_GETCURSEL, 0, 0) +
1);
break;
-
+
}
break;
@@ -403,8 +440,20 @@ static BOOL CALLBACK
options_appearance_dialog_handler(HWND hwnd,
return FALSE;
}
+
+/**
+ * Handle messages to the connections preference dialog
+ *
+ * \param hwnd The win32 handle of the connections dialog
+ * \param msg The message code
+ * \param wparam The message w parameter
+ * \param lParam The message l parameter
+ * \return result appropriate for message
+ */
static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd,
- UINT msg, WPARAM wparam, LPARAM lParam)
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lParam)
{
int len;
char *temp, number[6];
@@ -562,8 +611,20 @@ static BOOL CALLBACK
options_connections_dialog_handler(HWND hwnd,
return FALSE;
}
+
+/**
+ * Handle messages to the general preference dialog
+ *
+ * \param hwnd The win32 handle of the general dialog
+ * \param msg The message code
+ * \param wparam The message w parameter
+ * \param lParam The message l parameter
+ * \return result appropriate for message
+ */
static BOOL CALLBACK options_general_dialog_handler(HWND hwnd,
- UINT msg, WPARAM wparam, LPARAM lParam)
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lParam)
{
HWND sub;
@@ -577,21 +638,21 @@ static BOOL CALLBACK options_general_dialog_handler(HWND
hwnd,
/* Display images */
sub = GetDlgItem(hwnd, IDC_PREFS_IMAGES);
- SendMessage(sub, BM_SETCHECK,
- (WPARAM) ((nsoption_bool(suppress_images)) ?
- BST_CHECKED : BST_UNCHECKED), 0);
+ SendMessage(sub, BM_SETCHECK,
+ (WPARAM) ((nsoption_bool(suppress_images)) ?
+ BST_CHECKED : BST_UNCHECKED), 0);
/* advert blocking */
sub = GetDlgItem(hwnd, IDC_PREFS_ADVERTS);
- SendMessage(sub, BM_SETCHECK,
- (WPARAM) ((nsoption_bool(block_advertisements)) ?
- BST_CHECKED : BST_UNCHECKED), 0);
+ SendMessage(sub, BM_SETCHECK,
+ (WPARAM) ((nsoption_bool(block_advertisements)) ?
+ BST_CHECKED : BST_UNCHECKED), 0);
/* Referrer sending */
sub = GetDlgItem(hwnd, IDC_PREFS_REFERER);
- SendMessage(sub, BM_SETCHECK,
+ SendMessage(sub, BM_SETCHECK,
(WPARAM)((nsoption_bool(send_referer)) ?
- BST_CHECKED : BST_UNCHECKED), 0);
+ BST_CHECKED : BST_UNCHECKED), 0);
break;
case WM_NOTIFY:
@@ -602,8 +663,8 @@ static BOOL CALLBACK options_general_dialog_handler(HWND
hwnd,
if (sub != NULL) {
int text_length;
char *text;
- text_length = SendMessage(sub,
- WM_GETTEXTLENGTH, 0, 0);
+ text_length = SendMessage(sub,
+ WM_GETTEXTLENGTH, 0,
0);
text = malloc(text_length + 1);
if (text != NULL) {
SendMessage(sub, WM_GETTEXT,
@@ -616,19 +677,20 @@ static BOOL CALLBACK options_general_dialog_handler(HWND
hwnd,
nsoption_set_bool(suppress_images,
(IsDlgButtonChecked(hwnd,
IDC_PREFS_IMAGES) == BST_CHECKED) ? true : false);
- nsoption_set_bool(block_advertisements,
(IsDlgButtonChecked(hwnd,
-
IDC_PREFS_ADVERTS) == BST_CHECKED) ? true : false);
+ nsoption_set_bool(block_advertisements,
+ (IsDlgButtonChecked(hwnd,
IDC_PREFS_ADVERTS) == BST_CHECKED) ? true : false);
- nsoption_set_bool(send_referer,
(IsDlgButtonChecked(hwnd,
-
IDC_PREFS_REFERER) == BST_CHECKED) ? true : false);
+ nsoption_set_bool(send_referer,
+ (IsDlgButtonChecked(hwnd,
IDC_PREFS_REFERER) == BST_CHECKED) ? true : false);
break;
-
+
}
}
return FALSE;
}
+
/* exported interface documented in windows/prefs.h */
nserror nsws_prefs_save(void)
{
@@ -644,6 +706,7 @@ nserror nsws_prefs_save(void)
return res;
}
+
/* exported interface documented in windows/prefs.h */
void nsws_prefs_dialog_init(HINSTANCE hinst, HWND parent)
{
diff --git a/frontends/windows/ssl_cert.c b/frontends/windows/ssl_cert.c
index 72d1d3b..efbdf45 100644
--- a/frontends/windows/ssl_cert.c
+++ b/frontends/windows/ssl_cert.c
@@ -41,13 +41,18 @@
/* spacing and sizes for dialog elements from
*
https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486(v=vs.85).aspx#sizingandspacing
*/
+/** dialog margin */
#define DLG_MRGN 11
+/** warning icon height */
#define WRN_ICO_H 32
+/** comand button width */
#define CMD_BTN_W 75
+/** command button height */
#define CMD_BTN_H 23
static const char windowclassname_sslcert[] = "nswssslcertwindow";
+/** win32 ssl certificate view context */
struct nsw32_sslcert_window {
struct nsw32_corewindow core;
@@ -65,15 +70,15 @@ struct nsw32_sslcert_window {
/** warning text handle */
HWND hTxt;
-
};
+
/**
- * callback for keypress on hotlist window
+ * callback for keypress on ssl certificate window
*
* \param nsw32_cw The nsw32 core window structure.
* \param nskey The netsurf key code
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
nsw32_sslcert_viewer_key(struct nsw32_corewindow *nsw32_cw, uint32_t nskey)
@@ -89,19 +94,20 @@ nsw32_sslcert_viewer_key(struct nsw32_corewindow *nsw32_cw,
uint32_t nskey)
return NSERROR_NOT_IMPLEMENTED;
}
+
/**
- * callback for mouse action on hotlist window
+ * callback for mouse action on ssl certificate window
*
* \param nsw32_cw The nsw32 core window structure.
* \param mouse_state netsurf mouse state on event
* \param x location of event
* \param y location of event
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
nsw32_sslcert_viewer_mouse(struct nsw32_corewindow *nsw32_cw,
- browser_mouse_state mouse_state,
- int x, int y)
+ browser_mouse_state mouse_state,
+ int x, int y)
{
struct nsw32_sslcert_window *crtvrfy_win;
@@ -113,12 +119,13 @@ nsw32_sslcert_viewer_mouse(struct nsw32_corewindow
*nsw32_cw,
return NSERROR_OK;
}
+
/**
- * callback on draw event for hotlist window
+ * callback on draw event for ssl certificate window
*
* \param nsw32_cw The nsw32 core window structure.
* \param r The rectangle of the window that needs updating.
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
nsw32_sslcert_viewer_draw(struct nsw32_corewindow *nsw32_cw,
@@ -144,6 +151,12 @@ nsw32_sslcert_viewer_draw(struct nsw32_corewindow
*nsw32_cw,
}
+/**
+ * callback on close event for ssl certificate window
+ *
+ * \param nsw32_cw The nsw32 core window structure.
+ * \return NSERROR_OK on success otherwise appropriate error code
+ */
static nserror
nsw32_sslcert_viewer_close(struct nsw32_corewindow *nsw32_cw)
{
@@ -155,10 +168,10 @@ nsw32_sslcert_viewer_close(struct nsw32_corewindow
*nsw32_cw)
/* exported interface documented in nsw32/ssl_cert.h */
nserror nsw32_cert_verify(struct nsurl *url,
- const struct ssl_cert_info *certs,
- unsigned long num,
- nserror (*cb)(bool proceed, void *pw),
- void *cbpw)
+ const struct ssl_cert_info *certs,
+ unsigned long num,
+ nserror (*cb)(bool proceed, void *pw),
+ void *cbpw)
{
struct nsw32_sslcert_window *ncwin;
nserror res;
@@ -260,17 +273,17 @@ nserror nsw32_cert_verify(struct nsurl *url,
NULL,
NULL);
ncwin->hTxt = CreateWindowEx(0,
- "STATIC",
- "NetSurf failed to verify the authenticity of an SSL
certificate. Verify the certificate details",
- WS_VISIBLE | WS_CHILD | SS_LEFT,
- DLG_MRGN + WRN_ICO_H + DLG_MRGN,
- DLG_MRGN + 5,
- 400,
- WRN_ICO_H - 5,
- ncwin->hWnd,
- NULL,
- NULL,
- NULL);
+ "STATIC",
+ "NetSurf failed to verify the authenticity
of an SSL certificate. Verify the certificate details",
+ WS_VISIBLE | WS_CHILD | SS_LEFT,
+ DLG_MRGN + WRN_ICO_H + DLG_MRGN,
+ DLG_MRGN + 5,
+ 400,
+ WRN_ICO_H - 5,
+ ncwin->hWnd,
+ NULL,
+ NULL,
+ NULL);
SendMessage(ncwin->hTxt, WM_SETFONT, (WPARAM)hfDefault,
MAKELPARAM(FALSE,0));
SetProp(ncwin->hWnd, TEXT("CertWnd"), (HANDLE)ncwin);
@@ -280,8 +293,12 @@ nserror nsw32_cert_verify(struct nsurl *url,
return NSERROR_OK;
}
+
/**
* position and size ssl cert window widgets.
+ *
+ * \param hwnd The win32 handle of the window
+ * \param certwin The certificate viewer context
*/
static void
nsw32_window_ssl_cert_size(HWND hwnd, struct nsw32_sslcert_window *certwin)
@@ -318,6 +335,13 @@ nsw32_window_ssl_cert_size(HWND hwnd, struct
nsw32_sslcert_window *certwin)
TRUE);
}
+
+/**
+ * Destroy a certificate viewing window
+ *
+ * \param certwin The certificate viewer context
+ * \return NSERROR_OK on success otherwise appropriate error code
+ */
static nserror nsw32_crtvrfy_destroy(struct nsw32_sslcert_window *crtwin)
{
nserror res;
@@ -331,22 +355,23 @@ static nserror nsw32_crtvrfy_destroy(struct
nsw32_sslcert_window *crtwin)
return res;
}
+
/**
- * handle command message on main browser window
+ * handle command message on certificate viewing window
*
* \param hwnd The win32 window handle
* \param gw win32 gui window
- * \param notification_code notifiction code
+ * \param notification_code notification code
* \param identifier notification identifier
* \param ctrl_window The win32 control window handle
- * \return apropriate response for command
+ * \return appropriate response for command
*/
static LRESULT
nsw32_window_ssl_cert_command(HWND hwnd,
- struct nsw32_sslcert_window *crtwin,
- int notification_code,
- int identifier,
- HWND ctrl_window)
+ struct nsw32_sslcert_window *crtwin,
+ int notification_code,
+ int identifier,
+ HWND ctrl_window)
{
LOG("notification_code %x identifier %x ctrl_window %p",
notification_code, identifier, ctrl_window);
@@ -368,6 +393,7 @@ nsw32_window_ssl_cert_command(HWND hwnd,
return 0; /* control message handled */
}
+
/**
* callback for SSL certificate window win32 events
*
@@ -378,9 +404,9 @@ nsw32_window_ssl_cert_command(HWND hwnd,
*/
static LRESULT CALLBACK
nsw32_window_ssl_cert_event_callback(HWND hwnd,
- UINT msg,
- WPARAM wparam,
- LPARAM lparam)
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lparam)
{
struct nsw32_sslcert_window *crtwin;
crtwin = GetProp(hwnd, TEXT("CertWnd"));
@@ -410,6 +436,7 @@ nsw32_window_ssl_cert_event_callback(HWND hwnd,
return DefWindowProc(hwnd, msg, wparam, lparam);
}
+
/* exported interface documented in nsw32/ssl_cert.h */
nserror nsws_create_cert_verify_class(HINSTANCE hInstance)
{
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 94dc7c1..74b84e3 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -75,7 +75,7 @@ static int open_windows = 0;
* Obtain the DPI of the display.
*
* \param hwnd A win32 window handle to get the DPI for
- * \return The DPI of the device teh window is displayed on.
+ * \return The DPI of the device the window is displayed on.
*/
static int get_window_dpi(HWND hwnd)
{
@@ -99,7 +99,7 @@ static int get_window_dpi(HWND hwnd)
*
* \param gw gui window context.
*/
-static void nsws_window_set_accels(struct gui_window *w)
+static void nsws_window_set_accels(struct gui_window *gw)
{
int i, nitems = 13;
ACCEL accels[nitems];
@@ -137,7 +137,7 @@ static void nsws_window_set_accels(struct gui_window *w)
accels[12].fVirt = FVIRTKEY;
accels[12].cmd = IDM_VIEW_FULLSCREEN;
- w->acceltable = CreateAcceleratorTable(accels, nitems);
+ gw->acceltable = CreateAcceleratorTable(accels, nitems);
}
@@ -223,9 +223,9 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct
gui_window *gw)
*/
static LRESULT
nsws_window_toolbar_command(struct gui_window *gw,
- int notification_code,
- int identifier,
- HWND ctrl_window)
+ int notification_code,
+ int identifier,
+ HWND ctrl_window)
{
LOG("notification_code %d identifier %d ctrl_window %p",
notification_code, identifier, ctrl_window);
@@ -446,7 +446,7 @@ nsws_window_urlbar_callback(HWND hwnd, UINT msg, WPARAM
wparam, LPARAM lparam)
/**
* create a urlbar and message handler
*
- * Create an Edit control for enerting urls
+ * Create an Edit control for entering urls
*
* \param hInstance The application instance handle.
* \param hWndParent The containing window.
@@ -491,8 +491,8 @@ nsws_window_urlbar_create(HINSTANCE hInstance,
/* subclass the message handler */
urlproc = (WNDPROC)SetWindowLongPtr(hwnd,
- GWLP_WNDPROC,
- (LONG_PTR)nsws_window_urlbar_callback);
+ GWLP_WNDPROC,
+
(LONG_PTR)nsws_window_urlbar_callback);
/* save the real handler */
SetProp(hwnd, TEXT("OrigMsgProc"), (HANDLE)urlproc);
@@ -654,8 +654,8 @@ nsws_window_create_toolbar(HINSTANCE hInstance,
/* subclass the message handler */
toolproc = (WNDPROC)SetWindowLongPtr(hWndToolbar,
- GWLP_WNDPROC,
- (LONG_PTR)nsws_window_toolbar_callback);
+ GWLP_WNDPROC,
+
(LONG_PTR)nsws_window_toolbar_callback);
/* save the real handler */
SetProp(hWndToolbar, TEXT("OrigMsgProc"), (HANDLE)toolproc);
@@ -754,7 +754,7 @@ nsws_window_create_statusbar(HINSTANCE hInstance,
static void nsws_update_edit(struct gui_window *w)
{
browser_editor_flags editor_flags = (w->bw == NULL) ?
- BW_EDITOR_NONE : browser_window_get_editor_flags(w->bw);
+ BW_EDITOR_NONE : browser_window_get_editor_flags(w->bw);
bool paste, copy, del;
bool sel = (editor_flags & BW_EDITOR_CAN_COPY);
@@ -810,7 +810,7 @@ static void nsws_update_edit(struct gui_window *w)
* \param gw win32 frontends graphical window.
* \param hwnd The win32 window handle
* \param int x The x coordinate of the event.
- * \param y the y cooordiante of the event.
+ * \param y the y coordinate of the event.
*/
static bool
nsws_ctx_menu(struct gui_window *w, HWND hwnd, int x, int y)
@@ -963,10 +963,10 @@ static nserror win32_open_new_window(struct gui_window
*gw)
*
* \param hwnd The win32 window handle
* \param gw win32 gui window
- * \param notification_code notifiction code
+ * \param notification_code notification code
* \param identifier notification identifier
* \param ctrl_window The win32 control window handle
- * \return apropriate response for command
+ * \return appropriate response for command
*/
static LRESULT
nsws_window_command(HWND hwnd,
@@ -1286,9 +1286,9 @@ nsws_window_command(HWND hwnd,
/**
* Get the scroll position of a win32 browser window.
*
- * \param g gui_window
- * \param sx receives x ordinate of point at top-left of window
- * \param sy receives y ordinate of point at top-left of window
+ * \param gw gui_window
+ * \param sx receives x ordinate of point at top-left of window
+ * \param sy receives y ordinate of point at top-left of window
* \return true iff successful
*/
static bool win32_window_get_scroll(struct gui_window *gw, int *sx, int *sy)
@@ -1311,7 +1311,7 @@ static bool win32_window_get_scroll(struct gui_window
*gw, int *sx, int *sy)
* \param hwnd The win32 window handle
* \param wparam The w win32 parameter
* \param lparam The l win32 parameter
- * \return apropriate response for resize
+ * \return appropriate response for resize
*/
static LRESULT
nsws_window_resize(struct gui_window *gw,
@@ -1603,24 +1603,29 @@ static void win32_window_reformat(struct gui_window *gw)
*/
static void win32_window_set_title(struct gui_window *w, const char *title)
{
- if (w == NULL)
+ char *fulltitle;
+
+ if (w == NULL) {
return;
+ }
+
LOG("%p, title %s", w, title);
- char *fulltitle = malloc(strlen(title) +
- SLEN(" - NetSurf") + 1);
+ fulltitle = malloc(strlen(title) + SLEN(" - NetSurf") + 1);
if (fulltitle == NULL) {
win32_warning("NoMemory", 0);
return;
}
+
strcpy(fulltitle, title);
strcat(fulltitle, " - NetSurf");
+
SendMessage(w->main, WM_SETTEXT, 0, (LPARAM)fulltitle);
free(fulltitle);
}
/**
- * Set the navigation url is a win32 browser window.
+ * Set the navigation url in a win32 browser window.
*
* \param gw window to update.
* \param url The url to use as icon.
@@ -1797,7 +1802,7 @@ struct gui_window *nsws_get_gui_window(HWND hwnd)
struct gui_window *gw = NULL;
HWND phwnd = hwnd;
- /* scan the window hierachy for gui window */
+ /* scan the window hierarchy for gui window */
while (phwnd != NULL) {
gw = GetProp(phwnd, TEXT("GuiWnd"));
if (gw != NULL)
@@ -1866,7 +1871,7 @@ void win32_window_set_scroll(struct gui_window *w, int
sx, int sy)
/*LOG("scroll sx,sy:%d,%d x,y:%d,%d
w.h:%d,%d",sx,sy,w->scrollx,w->scrolly, width,height);*/
- /* The resulting gui window scroll must remain withn the
+ /* The resulting gui window scroll must remain within the
* windows bounding box.
*/
if (sx < 0) {
-----------------------------------------------------------------------
Summary of changes:
frontends/windows/drawable.c | 43 +++++++++----
frontends/windows/filetype.c | 10 ++-
frontends/windows/font.c | 106 ++++++++++++++++++++-----------
frontends/windows/font.h | 13 ++--
frontends/windows/global_history.c | 2 +-
frontends/windows/gui.c | 16 +++--
frontends/windows/localhistory.c | 97 +++++++++++++++++++---------
frontends/windows/plot.c | 109 ++++++++++++++++++++------------
frontends/windows/prefs.c | 123 +++++++++++++++++++++++++++---------
frontends/windows/ssl_cert.c | 95 ++++++++++++++++++----------
frontends/windows/window.c | 55 ++++++++--------
11 files changed, 451 insertions(+), 218 deletions(-)
diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c
index cb94291..0bd1bae 100644
--- a/frontends/windows/drawable.c
+++ b/frontends/windows/drawable.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 implementation of drawable window showing browser context
+ */
+
#include <stdbool.h>
#include <stdint.h>
@@ -38,6 +43,7 @@
static const char windowclassname_drawable[] = "nswsdrawablewindow";
+
/**
* Handle wheel scroll messages.
*/
@@ -66,6 +72,7 @@ nsws_drawable_wheel(struct gui_window *gw, HWND hwnd, WPARAM
wparam)
return 0;
}
+
/**
* Handle vertical scroll messages.
*/
@@ -121,8 +128,8 @@ nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd,
WPARAM wparam)
si.fMask = SIF_POS;
if ((gw->bw != NULL) &&
- (browser_window_get_extents(gw->bw, true,
- &width, &height) == NSERROR_OK)) {
+ (browser_window_get_extents(gw->bw, true,
+ &width, &height) == NSERROR_OK)) {
si.nPos = min(si.nPos, height - gw->height);
}
@@ -131,7 +138,7 @@ nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd,
WPARAM wparam)
GetScrollInfo(hwnd, SB_VERT, &si);
if (si.nPos != mem) {
win32_window_set_scroll(gw, gw->scrollx, gw->scrolly +
- gw->requestscrolly + si.nPos - mem);
+ gw->requestscrolly + si.nPos - mem);
}
return 0;
@@ -186,8 +193,8 @@ nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd,
WPARAM wparam)
si.fMask = SIF_POS;
if ((gw->bw != NULL) &&
- (browser_window_get_extents(gw->bw, true,
- &width, &height) == NSERROR_OK)) {
+ (browser_window_get_extents(gw->bw, true,
+ &width, &height) == NSERROR_OK)) {
si.nPos = min(si.nPos, width - gw->width);
}
si.nPos = max(si.nPos, 0);
@@ -195,13 +202,14 @@ nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd,
WPARAM wparam)
GetScrollInfo(hwnd, SB_HORZ, &si);
if (si.nPos != mem) {
win32_window_set_scroll(gw,
- gw->scrollx + gw->requestscrollx + si.nPos -
mem,
- gw->scrolly);
+ gw->scrollx + gw->requestscrollx +
si.nPos - mem,
+ gw->scrolly);
}
return 0;
}
+
/**
* Handle resize events.
*/
@@ -212,6 +220,7 @@ nsws_drawable_resize(struct gui_window *gw)
return 0;
}
+
/**
* Handle key press messages.
*/
@@ -289,7 +298,7 @@ nsws_drawable_key(struct gui_window *gw, HWND hwnd, WPARAM
wparam)
break;
}
- if ((i >= 'A') &&
+ if ((i >= 'A') &&
(i <= 'Z') &&
(((!capslock) && (!shift)) || ((capslock) && (shift)))) {
i += 'a' - 'A';
@@ -371,7 +380,10 @@ nsws_drawable_mouseup(struct gui_window *gw,
gw->mouse->state &= ~BROWSER_MOUSE_MOD_3;
if ((gw->mouse->state & click) != 0) {
- LOG("mouse click bw %p, state 0x%x, x %f, y %f", gw->bw,
gw->mouse->state, (x + gw->scrollx) / gw->scale, (y + gw->scrolly) / gw->scale);
+ LOG("mouse click bw %p, state 0x%x, x %f, y %f",
+ gw->bw, gw->mouse->state,
+ (x + gw->scrollx) / gw->scale,
+ (y + gw->scrolly) / gw->scale);
browser_window_mouse_click(gw->bw,
gw->mouse->state,
@@ -415,7 +427,10 @@ nsws_drawable_mousedown(struct gui_window *gw,
gw->mouse->pressed_x = (x + gw->scrollx) / gw->scale;
gw->mouse->pressed_y = (y + gw->scrolly) / gw->scale;
- LOG("mouse click bw %p, state %x, x %f, y %f", gw->bw,
gw->mouse->state, (x + gw->scrollx) / gw->scale, (y + gw->scrolly) / gw->scale);
+ LOG("mouse click bw %p, state %x, x %f, y %f",
+ gw->bw, gw->mouse->state,
+ (x + gw->scrollx) / gw->scale,
+ (y + gw->scrolly) / gw->scale);
browser_window_mouse_click(gw->bw, gw->mouse->state,
(x + gw->scrollx) / gw->scale,
@@ -424,6 +439,7 @@ nsws_drawable_mousedown(struct gui_window *gw,
return 0;
}
+
/**
* Handle mouse movement messages.
*/
@@ -480,6 +496,7 @@ nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
return 0;
}
+
/**
* Called when activity occours within the drawable window.
*/
@@ -564,12 +581,13 @@ nsws_window_drawable_event_callback(HWND hwnd,
return DefWindowProc(hwnd, msg, wparam, lparam);
}
+
/**
* Create a drawable window.
*/
HWND
-nsws_window_create_drawable(HINSTANCE hinstance,
- HWND hparent,
+nsws_window_create_drawable(HINSTANCE hinstance,
+ HWND hparent,
struct gui_window *gw)
{
HWND hwnd;
@@ -594,6 +612,7 @@ nsws_window_create_drawable(HINSTANCE hinstance,
return hwnd;
}
+
/**
* Create the drawable window class.
*/
diff --git a/frontends/windows/filetype.c b/frontends/windows/filetype.c
index ed07dd5..4e7f2f4 100644
--- a/frontends/windows/filetype.c
+++ b/frontends/windows/filetype.c
@@ -16,6 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file Fetch operation implementation for win32
+ */
+
#include <stdlib.h>
#include <string.h>
@@ -26,7 +30,10 @@
#include "windows/filetype.h"
/**
- * filetype -- determine the MIME type of a local file
+ * determine the MIME type of a local file.
+ *
+ * \param unix_path The unix style path to the file.
+ * \return The mime type of the file.
*/
static const char *fetch_filetype(const char *unix_path)
{
@@ -52,6 +59,7 @@ static const char *fetch_filetype(const char *unix_path)
return "text/html";
}
+/** win32 fetch operation table */
static struct gui_fetch_table fetch_table = {
.filetype = fetch_filetype,
};
diff --git a/frontends/windows/font.c b/frontends/windows/font.c
index f50ba6e..3407ec4 100644
--- a/frontends/windows/font.c
+++ b/frontends/windows/font.c
@@ -19,7 +19,7 @@
/**
* \file
- * Windows font handling implementation.
+ * Windows font handling and character encoding implementation.
*/
#include "utils/config.h"
@@ -38,36 +38,57 @@
HWND font_hwnd;
-nserror utf8_to_font_encoding(const struct font_desc* font,
- const char *string,
- size_t len,
- char **result)
+/* exported interface documented in windows/font.h */
+nserror
+utf8_to_font_encoding(const struct font_desc* font,
+ const char *string,
+ size_t len,
+ char **result)
{
return utf8_to_enc(string, font->encoding, len, result);
}
-static nserror utf8_to_local_encoding(const char *string,
- size_t len,
- char **result)
+
+/**
+ * Convert a string to UCS2 from UTF8
+ *
+ * \param[in] string source string
+ * \param[in] len source string length
+ * \param[out] result The UCS2 string
+ */
+static nserror
+utf8_to_local_encoding(const char *string, size_t len, char **result)
{
return utf8_to_enc(string, "UCS-2", len, result);
}
-static nserror utf8_from_local_encoding(const char *string, size_t len,
- char **result)
+
+/**
+ * Convert a string to UTF8 from local encoding
+ *
+ * \param[in] string source string
+ * \param[in] len source string length
+ * \param[out] result The UTF8 string
+ */
+static nserror
+utf8_from_local_encoding(const char *string, size_t len, char **result)
{
assert(string && result);
- if (len == 0)
+ if (len == 0) {
len = strlen(string);
+ }
*result = strndup(string, len);
- if (!(*result))
+ if (!(*result)) {
return NSERROR_NOMEM;
+ }
return NSERROR_OK;
}
+
+/* exported interface documented in windows/font.h */
HFONT get_font(const plot_font_style_t *style)
{
char *face = NULL;
@@ -122,16 +143,18 @@ HFONT get_font(const plot_font_style_t *style)
free(face);
if (font == NULL) {
- if (style->family == PLOT_FONT_FAMILY_MONOSPACE)
+ if (style->family == PLOT_FONT_FAMILY_MONOSPACE) {
font = (HFONT) GetStockObject(ANSI_FIXED_FONT);
- else
+ } else {
font = (HFONT) GetStockObject(ANSI_VAR_FONT);
+ }
}
if (font == NULL)
font = (HFONT) GetStockObject(SYSTEM_FONT);
return font;
}
+
/**
* Measure the width of a string.
*
@@ -139,13 +162,13 @@ HFONT get_font(const plot_font_style_t *style)
* \param[in] string UTF-8 string to measure
* \param[in] length length of string, in bytes
* \param[out] width updated to width of string[0..length)
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
win32_font_width(const plot_font_style_t *style,
- const char *string,
- size_t length,
- int *width)
+ const char *string,
+ size_t length,
+ int *width)
{
HDC hdc;
HFONT font;
@@ -184,15 +207,15 @@ win32_font_width(const plot_font_style_t *style,
* \param x x coordinate to search for
* \param char_offset updated to offset in string of actual_x, [0..length]
* \param actual_x updated to x coordinate of character closest to x
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
win32_font_position(const plot_font_style_t *style,
- const char *string,
- size_t length,
- int x,
- size_t *char_offset,
- int *actual_x)
+ const char *string,
+ size_t length,
+ int x,
+ size_t *char_offset,
+ int *actual_x)
{
HDC hdc;
HFONT font;
@@ -211,8 +234,8 @@ win32_font_position(const plot_font_style_t *style,
if ((GetTextExtentExPointA(hdc, string, length, x, &offset,
NULL,&s) != 0) &&
(GetTextExtentPoint32A(hdc, string, offset, &s) != 0)) {
- *char_offset = (size_t)offset;
- *actual_x = s.cx;
+ *char_offset = (size_t)offset;
+ *actual_x = s.cx;
} else {
ret = NSERROR_UNKNOWN;
}
@@ -235,7 +258,7 @@ win32_font_position(const plot_font_style_t *style,
* \param x width available
* \param char_offset updated to offset in string of actual_x, [0..length]
* \param actual_x updated to x coordinate of character closest to x
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*
* On exit, [char_offset == 0 ||
* string[char_offset] == ' ' ||
@@ -243,16 +266,21 @@ win32_font_position(const plot_font_style_t *style,
*/
static nserror
win32_font_split(const plot_font_style_t *style,
- const char *string,
- size_t length,
- int x,
- size_t *char_offset,
- int *actual_x)
+ const char *string,
+ size_t length,
+ int x,
+ size_t *char_offset,
+ int *actual_x)
{
int c_off;
nserror ret = NSERROR_UNKNOWN;
- if (win32_font_position(style, string, length, x, char_offset,
actual_x)) {
+ if (win32_font_position(style,
+ string,
+ length,
+ x,
+ char_offset,
+ actual_x)) {
c_off = *char_offset;
if (*char_offset == length) {
ret = NSERROR_OK;
@@ -271,7 +299,10 @@ win32_font_split(const plot_font_style_t *style,
}
}
- success = win32_font_width(style, string, *char_offset,
actual_x);
+ success = win32_font_width(style,
+ string,
+ *char_offset,
+ actual_x);
if (success) {
ret = NSERROR_OK;
}
@@ -279,13 +310,14 @@ win32_font_split(const plot_font_style_t *style,
}
/*
- LOG("ret %d Split %u chars at %ipx: Split at char %i (%ipx) - %.*s",
- ret, length, x, *char_offset, *actual_x, *char_offset, string);
+ LOG("ret %d Split %u chars at %ipx: Split at char %i (%ipx) - %.*s",
+ ret, length, x, *char_offset, *actual_x, *char_offset, string);
*/
return ret;
}
+/** win32 font operations table */
static struct gui_layout_table layout_table = {
.width = win32_font_width,
.position = win32_font_position,
@@ -294,7 +326,7 @@ static struct gui_layout_table layout_table = {
struct gui_layout_table *win32_layout_table = &layout_table;
-
+/** win32 utf8 encoding operations table */
static struct gui_utf8_table utf8_table = {
.utf8_to_local = utf8_to_local_encoding,
.local_to_utf8 = utf8_from_local_encoding,
diff --git a/frontends/windows/font.h b/frontends/windows/font.h
index a1077e0..ec2c262 100644
--- a/frontends/windows/font.h
+++ b/frontends/windows/font.h
@@ -38,10 +38,15 @@ struct font_desc {
struct gui_layout_table *win32_layout_table;
struct gui_utf8_table *win32_utf8_table;
-extern nserror utf8_to_font_encoding(const struct font_desc* font,
- const char *string,
- size_t len,
- char **result);
+/**
+ * convert from utf-8 to win32 font encoding.
+ *
+ * \param[in] font font descriptor
+ * \param[in] string source utf-8 string
+ * \param[in] len The length of the utf-8 data
+ * \param[out] result The reencoded string.
+ */
+extern nserror utf8_to_font_encoding(const struct font_desc* font, const char
*string, size_t len, char **result);
/**
* generate a win32 font handle from a generic font style
diff --git a/frontends/windows/global_history.c
b/frontends/windows/global_history.c
index 0ef0963..4e90a77 100644
--- a/frontends/windows/global_history.c
+++ b/frontends/windows/global_history.c
@@ -18,7 +18,7 @@
/**
* \file
- * Implementation of win32 cookie manager.
+ * Implementation of win32 global history interface.
*/
#include <stdint.h>
diff --git a/frontends/windows/gui.c b/frontends/windows/gui.c
index f5808de..602dcd4 100644
--- a/frontends/windows/gui.c
+++ b/frontends/windows/gui.c
@@ -17,6 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 gui implementation.
+ */
+
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -47,6 +52,7 @@ HINSTANCE hinst;
static bool win32_quit = false;
+/* exported interface documented in gui.h */
void win32_set_quit(bool q)
{
win32_quit = q;
@@ -98,7 +104,7 @@ void win32_run(void)
nserror win32_warning(const char *warning, const char *detail)
{
size_t len = 1 + ((warning != NULL) ? strlen(messages_get(warning)) :
- 0) + ((detail != 0) ? strlen(detail) : 0);
+ 0) + ((detail != 0) ? strlen(detail) : 0);
char message[len];
snprintf(message, len, messages_get(warning), detail);
MessageBox(NULL, message, "Warning", MB_ICONWARNING);
@@ -110,8 +116,8 @@ nserror win32_warning(const char *warning, const char
*detail)
/**
* Core asks front end for clipboard contents.
*
- * \param buffer UTF-8 text, allocated by front end, ownership yeilded to
core
- * \param length Byte length of UTF-8 text in buffer
+ * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
+ * \param length Byte length of UTF-8 text in buffer
*/
static void gui_get_clipboard(char **buffer, size_t *length)
{
@@ -137,7 +143,7 @@ static void gui_get_clipboard(char **buffer, size_t *length)
* \param n_styles Number of text run styles in array
*/
static void gui_set_clipboard(const char *buffer, size_t length,
- nsclipboard_styles styles[], int n_styles)
+ nsclipboard_styles styles[], int n_styles)
{
/* TODO: Implement this */
HANDLE hnew;
@@ -169,5 +175,3 @@ static struct gui_clipboard_table clipboard_table = {
};
struct gui_clipboard_table *win32_clipboard_table = &clipboard_table;
-
-
diff --git a/frontends/windows/localhistory.c b/frontends/windows/localhistory.c
index ae3b7f5..8921b2b 100644
--- a/frontends/windows/localhistory.c
+++ b/frontends/windows/localhistory.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 local history viewer implementation.
+ */
+
#include "utils/config.h"
#include <windows.h>
@@ -36,6 +41,7 @@
static const char windowclassname_localhistory[] = "nswslocalhistorywindow";
+/** local history context */
struct nsws_localhistory {
HWND hwnd; /**< the window handle */
int width; /**< the width of the memory history */
@@ -47,14 +53,21 @@ struct nsws_localhistory {
};
+/**
+ * set the scrollbar sizes and offset
+ *
+ * \param l localhistory context.
+ * \param gw win32 gui window
+ */
static void
nsws_localhistory_scroll_check(struct nsws_localhistory *l,
struct gui_window *gw)
{
SCROLLINFO si;
- if ((gw->bw == NULL) || (l->hwnd == NULL))
+ if ((gw->bw == NULL) || (l->hwnd == NULL)) {
return;
+ }
browser_window_history_size(gw->bw, &(l->width), &(l->height));
@@ -69,14 +82,22 @@ nsws_localhistory_scroll_check(struct nsws_localhistory *l,
si.nMax = l->width;
si.nPage = l->guiwidth;
SetScrollInfo(l->hwnd, SB_HORZ, &si, TRUE);
- if (l->guiheight >= l->height)
+ if (l->guiheight >= l->height) {
l->vscroll = 0;
- if (l->guiwidth >= l->width)
+ }
+ if (l->guiwidth >= l->width) {
l->hscroll = 0;
+ }
SendMessage(l->hwnd, WM_PAINT, 0, 0);
}
+/**
+ * redraw local history window
+ *
+ * \param l localhistory context.
+ * \param gw win32 gui window
+ */
static void
nsws_localhistory_up(struct nsws_localhistory *l, struct gui_window *gw)
{
@@ -108,17 +129,34 @@ nsws_localhistory_up(struct nsws_localhistory *l, struct
gui_window *gw)
}
+/**
+ * close local history window
+ *
+ * \param gw the gui window to close history for
+ */
void nsws_localhistory_close(struct gui_window *w)
{
struct nsws_localhistory *l = gui_window_localhistory(w);
- if (l != NULL)
+ if (l != NULL) {
CloseWindow(l->hwnd);
+ }
}
-static LRESULT CALLBACK
-nsws_localhistory_event_callback(HWND hwnd, UINT msg,
- WPARAM wparam, LPARAM lparam)
+/**
+ * handler for win32 messges on local history window
+ *
+ * \param hwnd The win32 handle of the appearance dialog
+ * \param msg The message code
+ * \param wparam The message w parameter
+ * \param lparam The message l parameter
+ * \return result appropriate for message
+ */
+static LRESULT CALLBACK
+nsws_localhistory_event_callback(HWND hwnd,
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lparam)
{
int x,y;
struct gui_window *gw;
@@ -143,7 +181,7 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
nsws_localhistory_scroll_check(gw->localhistory, gw);
break;
- case WM_LBUTTONUP:
+ case WM_LBUTTONUP:
if (gw->bw == NULL)
break;
@@ -151,20 +189,20 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
y = GET_Y_LPARAM(lparam);
if (browser_window_history_click(gw->bw,
- gw->localhistory->hscroll + x,
- gw->localhistory->vscroll + y,
- false)) {
+ gw->localhistory->hscroll + x,
+ gw->localhistory->vscroll + y,
+ false)) {
DestroyWindow(hwnd);
}
-
+
break;
- case WM_MOUSEMOVE:
+ case WM_MOUSEMOVE:
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
-
+
case WM_VSCROLL:
{
@@ -268,12 +306,12 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
plot_hdc = hdc;
browser_window_history_redraw_rectangle(gw->bw,
- gw->localhistory->hscroll + ps.rcPaint.left,
- gw->localhistory->vscroll + ps.rcPaint.top,
- gw->localhistory->hscroll + (ps.rcPaint.right
- ps.rcPaint.left),
- gw->localhistory->vscroll + (ps.rcPaint.bottom
- ps.rcPaint.top),
- ps.rcPaint.left,
- ps.rcPaint.top, &ctx);
+ gw->localhistory->hscroll + ps.rcPaint.left,
+ gw->localhistory->vscroll + ps.rcPaint.top,
+ gw->localhistory->hscroll + (ps.rcPaint.right -
ps.rcPaint.left),
+ gw->localhistory->vscroll + (ps.rcPaint.bottom
- ps.rcPaint.top),
+ ps.rcPaint.left,
+ ps.rcPaint.top, &ctx);
plot_hdc = tmp_hdc;
@@ -284,7 +322,7 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
}
case WM_CLOSE:
- DestroyWindow(hwnd);
+ DestroyWindow(hwnd);
return 1;
case WM_DESTROY:
@@ -316,7 +354,7 @@ struct nsws_localhistory
*nsws_window_create_localhistory(struct gui_window *gw)
UpdateWindow(gw->localhistory->hwnd);
ShowWindow(gw->localhistory->hwnd, SW_SHOWNORMAL);
return gw->localhistory;
- }
+ }
localhistory = calloc(1, sizeof(struct nsws_localhistory));
@@ -329,19 +367,19 @@ struct nsws_localhistory
*nsws_window_create_localhistory(struct gui_window *gw)
localhistory->height = 0;
if (gw->bw != NULL) {
- browser_window_history_size(gw->bw,
- &(localhistory->width),
- &(localhistory->height));
+ browser_window_history_size(gw->bw,
+ &(localhistory->width),
+ &(localhistory->height));
}
GetWindowRect(gw->main, &r);
- SetWindowPos(gw->main, HWND_NOTOPMOST, 0, 0, 0, 0,
+ SetWindowPos(gw->main, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE);
localhistory->guiwidth = min(r.right - r.left - margin,
- localhistory->width + margin);
+ localhistory->width + margin);
localhistory->guiheight = min(r.bottom - r.top - margin,
- localhistory->height + margin);
+ localhistory->height + margin);
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
@@ -386,7 +424,8 @@ struct nsws_localhistory
*nsws_window_create_localhistory(struct gui_window *gw)
/* exported method documented in windows/localhistory.h */
nserror
-nsws_create_localhistory_class(HINSTANCE hinstance) {
+nsws_create_localhistory_class(HINSTANCE hinstance)
+{
nserror ret = NSERROR_OK;
WNDCLASSEX w;
diff --git a/frontends/windows/plot.c b/frontends/windows/plot.c
index b733dfd..1bd0ba4 100644
--- a/frontends/windows/plot.c
+++ b/frontends/windows/plot.c
@@ -17,6 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 plotter implementation.
+ */
+
#include "utils/config.h"
#include <sys/types.h>
#include <stdint.h>
@@ -48,7 +53,8 @@
HDC plot_hdc;
-static RECT plot_clip; /* currently set clipping rectangle */
+/** currently set clipping rectangle */
+static RECT plot_clip;
/**
@@ -111,6 +117,14 @@ plot_block(COLORREF col, int x, int y, int width, int
height)
* plot an alpha blended bitmap
*
* blunt force truma way of achiving alpha blended plotting
+ *
+ * \param hdc drawing cotext
+ * \param bitmap bitmap to render
+ * \param x x coordinate to plot at
+ * \param y y coordinate to plot at
+ * \param width The width to plot the bitmap into
+ * \param height The height to plot the bitmap into
+ * \return NSERROR_OK on success else appropriate error code.
*/
static nserror
plot_alpha_bitmap(HDC hdc,
@@ -145,8 +159,11 @@ plot_alpha_bitmap(HDC hdc,
BITMAPINFO *bmi;
HBITMAP MemBMh;
- PLOT_LOG("%p bitmap %d,%d width %d height %d", bitmap, x, y, width,
height);
- PLOT_LOG("clipped %ld,%ld to %ld,%ld",plot_clip.left, plot_clip.top,
plot_clip.right, plot_clip.bottom);
+ PLOT_LOG("%p bitmap %d,%d width %d height %d",
+ bitmap, x, y, width, height);
+ PLOT_LOG("clipped %ld,%ld to %ld,%ld",
+ plot_clip.left, plot_clip.top,
+ plot_clip.right, plot_clip.bottom);
Memhdc = CreateCompatibleDC(hdc);
if (Memhdc == NULL) {
@@ -156,7 +173,7 @@ plot_alpha_bitmap(HDC hdc,
if ((bitmap->width != width) ||
(bitmap->height != height)) {
PLOT_LOG("scaling from %d,%d to %d,%d",
- bitmap->width, bitmap->height, width, height);
+ bitmap->width, bitmap->height, width, height);
bitmap = bitmap_scale(bitmap, width, height);
if (bitmap == NULL) {
return NSERROR_INVALID;
@@ -256,6 +273,14 @@ plot_alpha_bitmap(HDC hdc,
/**
+ * Internal bitmap plotting
+ *
+ * \param bitmap The bitmap to plot
+ * \param x x coordinate to plot at
+ * \param y y coordinate to plot at
+ * \param width The width to plot the bitmap into
+ * \param height The height to plot the bitmap into
+ * \return NSERROR_OK on success else appropriate error code.
*/
static nserror
plot_bitmap(struct bitmap *bitmap, int x, int y, int width, int height)
@@ -331,8 +356,6 @@ plot_bitmap(struct bitmap *bitmap, int x, int y, int width,
int height)
}
-
-
/**
* \brief Sets a clip rectangle for subsequent plot operations.
*
@@ -377,7 +400,7 @@ arc(const struct redraw_context *ctx,
int radius, int angle1, int angle2)
{
PLOT_LOG("arc centre %d,%d radius %d from %d to %d", x, y, radius,
- angle1, angle2);
+ angle1, angle2);
/* ensure the plot HDC is set */
if (plot_hdc == NULL) {
@@ -564,8 +587,8 @@ disc(const struct redraw_context *ctx,
*/
static nserror
line(const struct redraw_context *ctx,
- const plot_style_t *style,
- const struct rect *line)
+ const plot_style_t *style,
+ const struct rect *line)
{
PLOT_LOG("from %d,%d to %d,%d", x0, y0, x1, y1);
@@ -582,10 +605,10 @@ line(const struct redraw_context *ctx,
COLORREF col = (DWORD)(style->stroke_colour & 0x00FFFFFF);
/* windows 0x00bbggrr */
- DWORD penstyle = PS_GEOMETRIC | ((style->stroke_type ==
- PLOT_OP_TYPE_DOT) ? PS_DOT :
- (style->stroke_type ==
PLOT_OP_TYPE_DASH) ? PS_DASH:
- 0);
+ DWORD penstyle = PS_GEOMETRIC |
+ ((style->stroke_type == PLOT_OP_TYPE_DOT) ? PS_DOT :
+ (style->stroke_type == PLOT_OP_TYPE_DASH) ? PS_DASH:
+ 0);
LOGBRUSH lb = {BS_SOLID, col, 0};
HPEN pen = ExtCreatePen(penstyle, style->stroke_width, &lb, 0, NULL);
if (pen == NULL) {
@@ -630,8 +653,8 @@ line(const struct redraw_context *ctx,
*/
static nserror
rectangle(const struct redraw_context *ctx,
- const plot_style_t *style,
- const struct rect *rect)
+ const plot_style_t *style,
+ const struct rect *rect)
{
PLOT_LOG("rectangle from %d,%d to %d,%d",
rect->x0, rect->y0, rect->x1, rect->y1);
@@ -713,9 +736,9 @@ rectangle(const struct redraw_context *ctx,
*/
static nserror
polygon(const struct redraw_context *ctx,
- const plot_style_t *style,
- const int *p,
- unsigned int n)
+ const plot_style_t *style,
+ const int *p,
+ unsigned int n)
{
PLOT_LOG("polygon %d points", n);
@@ -802,11 +825,11 @@ polygon(const struct redraw_context *ctx,
*/
static nserror
path(const struct redraw_context *ctx,
- const plot_style_t *pstyle,
- const float *p,
- unsigned int n,
- float width,
- const float transform[6])
+ const plot_style_t *pstyle,
+ const float *p,
+ unsigned int n,
+ float width,
+ const float transform[6])
{
PLOT_LOG("path unimplemented");
return NSERROR_OK;
@@ -839,12 +862,12 @@ path(const struct redraw_context *ctx,
*/
static nserror
bitmap(const struct redraw_context *ctx,
- struct bitmap *bitmap,
- int x, int y,
- int width,
- int height,
- colour bg,
- bitmap_flags_t flags)
+ struct bitmap *bitmap,
+ int x, int y,
+ int width,
+ int height,
+ colour bg,
+ bitmap_flags_t flags)
{
int xf,yf;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
@@ -875,7 +898,11 @@ bitmap(const struct redraw_context *ctx,
if ((*(bitmap->pixdata + 3) & 0xff) == 0) {
return NSERROR_OK;
}
- return plot_block((*(COLORREF *)bitmap->pixdata) &
0xffffff, x, y, x + width, y + height);
+ return plot_block((*(COLORREF *)bitmap->pixdata) &
0xffffff,
+ x,
+ y,
+ x + width,
+ y + height);
} else {
return plot_bitmap(bitmap, x, y, width, height);
@@ -896,7 +923,8 @@ bitmap(const struct redraw_context *ctx,
/* Optimise tiled plots of bitmaps scaled to 1x1 by replacing with
* a flat fill of the area. Can only be done when image is fully
- * opaque. */
+ * opaque.
+ */
if ((width == 1) && (height == 1)) {
if (bitmap->opaque) {
/** TODO: Currently using top left pixel. Maybe centre
@@ -909,8 +937,10 @@ bitmap(const struct redraw_context *ctx,
}
}
- PLOT_LOG("Tiled plotting %d,%d by %d,%d",x,y,width,height);
- PLOT_LOG("clipped %ld,%ld to %ld,%ld",plot_clip.left, plot_clip.top,
plot_clip.right, plot_clip.bottom);
+ PLOT_LOG("Tiled plotting %d,%d by %d,%d", x, y, width, height);
+ PLOT_LOG("clipped %ld,%ld to %ld,%ld",
+ plot_clip.left, plot_clip.top,
+ plot_clip.right, plot_clip.bottom);
/* get left most tile position */
if (repeat_x) {
@@ -922,7 +952,8 @@ bitmap(const struct redraw_context *ctx,
for (; y > plot_clip.top; y -= height);
}
- PLOT_LOG("repeat from %d,%d to %ld,%ld", x, y, plot_clip.right,
plot_clip.bottom);
+ PLOT_LOG("repeat from %d,%d to %ld,%ld",
+ x, y, plot_clip.right, plot_clip.bottom);
/* tile down and across to extents */
for (xf = x; xf < plot_clip.right; xf += width) {
@@ -952,11 +983,11 @@ bitmap(const struct redraw_context *ctx,
*/
static nserror
text(const struct redraw_context *ctx,
- const struct plot_font_style *fstyle,
- int x,
- int y,
- const char *text,
- size_t length)
+ const struct plot_font_style *fstyle,
+ int x,
+ int y,
+ const char *text,
+ size_t length)
{
PLOT_LOG("words %s at %d,%d", text, x, y);
diff --git a/frontends/windows/prefs.c b/frontends/windows/prefs.c
index 03414ee..f84ee1c 100644
--- a/frontends/windows/prefs.c
+++ b/frontends/windows/prefs.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * win32 preferences dialog implementation.
+ */
+
#include "utils/config.h"
#include <windows.h>
@@ -31,9 +36,19 @@
#include "windows/resourceid.h"
#include "windows/windbg.h"
+/** Preferences dialog width */
#define NSWS_PREFS_WINDOW_WIDTH 600
+/** Preferences dialog height */
#define NSWS_PREFS_WINDOW_HEIGHT 400
+
+/**
+ * Prepare preferences dialog font tab
+ *
+ * \param fontfamily The font family
+ * \param parent The parent window win32 handle
+ * \return The selected font or NULL on error
+ */
static CHOOSEFONT *nsws_prefs_font_prepare(int fontfamily, HWND parent)
{
CHOOSEFONT *cf = malloc(sizeof(CHOOSEFONT));
@@ -81,6 +96,15 @@ static CHOOSEFONT *nsws_prefs_font_prepare(int fontfamily,
HWND parent)
return cf;
}
+
+/**
+ * Update value in spinner control when it is changed
+ *
+ * \param sub The window handle of the spinner control
+ * \param change The amount the control changed by
+ * \param minval The minimum allowed value of the control
+ * \param maxval The maximum allowed value of the control
+ */
static void change_spinner(HWND sub, double change, double minval, double
maxval)
{
char *temp, number[6];
@@ -90,8 +114,9 @@ static void change_spinner(HWND sub, double change, double
minval, double maxval
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
temp = malloc(len + 1);
- if (temp == NULL)
+ if (temp == NULL) {
return;
+ }
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM) temp);
@@ -101,17 +126,29 @@ static void change_spinner(HWND sub, double change,
double minval, double maxval
value = max(value, minval);
value = min(value, maxval);
- if ((change == 1.0) || (change == -1.0))
+ if ((change == 1.0) || (change == -1.0)) {
snprintf(number, 6, "%.0f", value);
- else
+ } else {
snprintf(number, 6, "%.1f", value);
+ }
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
}
+/**
+ * Handle messages to the appearance preference dialog
+ *
+ * \param hwnd The win32 handle of the appearance dialog
+ * \param msg The message code
+ * \param wparam The message w parameter
+ * \param lParam The message l parameter
+ * \return result appropriate for message
+ */
static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd,
- UINT msg, WPARAM wparam, LPARAM lParam)
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lParam)
{
int len;
char *temp, number[6];
@@ -192,7 +229,7 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND
hwnd,
/* animation */
sub = GetDlgItem(hwnd, IDC_PREFS_NOANIMATION);
SendMessage(sub, BM_SETCHECK,
(WPARAM)((nsoption_bool(animate_images))
- ? BST_UNCHECKED : BST_CHECKED), 0);
+ ? BST_UNCHECKED :
BST_CHECKED), 0);
if (nsoption_int(minimum_gif_delay) != 0) {
sub = GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY);
@@ -222,13 +259,13 @@ static BOOL CALLBACK
options_appearance_dialog_handler(HWND hwnd,
if (temp != NULL) {
SendMessage(sub, WM_GETTEXT, (WPARAM)
(len + 1), (LPARAM) temp);
- nsoption_set_int(font_min_size,
+ nsoption_set_int(font_min_size,
(int)(10 * strtod(temp,
NULL)));
free(temp);
}
/* animation */
- nsoption_set_bool(animate_images,
+ nsoption_set_bool(animate_images,
(IsDlgButtonChecked(hwnd,
IDC_PREFS_NOANIMATION) == BST_CHECKED) ? true : false);
@@ -259,7 +296,7 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND
hwnd,
case IDC_PREFS_ANIMATIONDELAY_SPIN:
change_spinner(GetDlgItem(hwnd,
IDC_PREFS_ANIMATIONDELAY), 0.1 * ud->iDelta, 0.1, 100.0);
return TRUE;
-
+
}
}
break;
@@ -276,8 +313,8 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND
hwnd,
SendMessage(sub, CB_GETCURSEL, 0, 0) -
1);
nsoption_set_bool(http_proxy,
(nsoption_int(http_proxy_auth) !=
-1));
- nsoption_set_int(http_proxy_auth,
- nsoption_int(http_proxy_auth) +
+ nsoption_set_int(http_proxy_auth,
+ nsoption_int(http_proxy_auth) +
(nsoption_bool(http_proxy)) ? 0 : 1);
break;
@@ -288,7 +325,7 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND
hwnd,
}
if (ChooseFont(cf) == TRUE) {
- nsoption_set_charp(font_sans,
+ nsoption_set_charp(font_sans,
strdup(cf->lpLogFont->lfFaceName));
}
@@ -390,12 +427,12 @@ static BOOL CALLBACK
options_appearance_dialog_handler(HWND hwnd,
break;
}
- case IDC_PREFS_FONTDEF:
+ case IDC_PREFS_FONTDEF:
sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF);
nsoption_set_int(font_default,
SendMessage(sub, CB_GETCURSEL, 0, 0) +
1);
break;
-
+
}
break;
@@ -403,8 +440,20 @@ static BOOL CALLBACK
options_appearance_dialog_handler(HWND hwnd,
return FALSE;
}
+
+/**
+ * Handle messages to the connections preference dialog
+ *
+ * \param hwnd The win32 handle of the connections dialog
+ * \param msg The message code
+ * \param wparam The message w parameter
+ * \param lParam The message l parameter
+ * \return result appropriate for message
+ */
static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd,
- UINT msg, WPARAM wparam, LPARAM lParam)
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lParam)
{
int len;
char *temp, number[6];
@@ -562,8 +611,20 @@ static BOOL CALLBACK
options_connections_dialog_handler(HWND hwnd,
return FALSE;
}
+
+/**
+ * Handle messages to the general preference dialog
+ *
+ * \param hwnd The win32 handle of the general dialog
+ * \param msg The message code
+ * \param wparam The message w parameter
+ * \param lParam The message l parameter
+ * \return result appropriate for message
+ */
static BOOL CALLBACK options_general_dialog_handler(HWND hwnd,
- UINT msg, WPARAM wparam, LPARAM lParam)
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lParam)
{
HWND sub;
@@ -577,21 +638,21 @@ static BOOL CALLBACK options_general_dialog_handler(HWND
hwnd,
/* Display images */
sub = GetDlgItem(hwnd, IDC_PREFS_IMAGES);
- SendMessage(sub, BM_SETCHECK,
- (WPARAM) ((nsoption_bool(suppress_images)) ?
- BST_CHECKED : BST_UNCHECKED), 0);
+ SendMessage(sub, BM_SETCHECK,
+ (WPARAM) ((nsoption_bool(suppress_images)) ?
+ BST_CHECKED : BST_UNCHECKED), 0);
/* advert blocking */
sub = GetDlgItem(hwnd, IDC_PREFS_ADVERTS);
- SendMessage(sub, BM_SETCHECK,
- (WPARAM) ((nsoption_bool(block_advertisements)) ?
- BST_CHECKED : BST_UNCHECKED), 0);
+ SendMessage(sub, BM_SETCHECK,
+ (WPARAM) ((nsoption_bool(block_advertisements)) ?
+ BST_CHECKED : BST_UNCHECKED), 0);
/* Referrer sending */
sub = GetDlgItem(hwnd, IDC_PREFS_REFERER);
- SendMessage(sub, BM_SETCHECK,
+ SendMessage(sub, BM_SETCHECK,
(WPARAM)((nsoption_bool(send_referer)) ?
- BST_CHECKED : BST_UNCHECKED), 0);
+ BST_CHECKED : BST_UNCHECKED), 0);
break;
case WM_NOTIFY:
@@ -602,8 +663,8 @@ static BOOL CALLBACK options_general_dialog_handler(HWND
hwnd,
if (sub != NULL) {
int text_length;
char *text;
- text_length = SendMessage(sub,
- WM_GETTEXTLENGTH, 0, 0);
+ text_length = SendMessage(sub,
+ WM_GETTEXTLENGTH, 0,
0);
text = malloc(text_length + 1);
if (text != NULL) {
SendMessage(sub, WM_GETTEXT,
@@ -616,19 +677,20 @@ static BOOL CALLBACK options_general_dialog_handler(HWND
hwnd,
nsoption_set_bool(suppress_images,
(IsDlgButtonChecked(hwnd,
IDC_PREFS_IMAGES) == BST_CHECKED) ? true : false);
- nsoption_set_bool(block_advertisements,
(IsDlgButtonChecked(hwnd,
-
IDC_PREFS_ADVERTS) == BST_CHECKED) ? true : false);
+ nsoption_set_bool(block_advertisements,
+ (IsDlgButtonChecked(hwnd,
IDC_PREFS_ADVERTS) == BST_CHECKED) ? true : false);
- nsoption_set_bool(send_referer,
(IsDlgButtonChecked(hwnd,
-
IDC_PREFS_REFERER) == BST_CHECKED) ? true : false);
+ nsoption_set_bool(send_referer,
+ (IsDlgButtonChecked(hwnd,
IDC_PREFS_REFERER) == BST_CHECKED) ? true : false);
break;
-
+
}
}
return FALSE;
}
+
/* exported interface documented in windows/prefs.h */
nserror nsws_prefs_save(void)
{
@@ -644,6 +706,7 @@ nserror nsws_prefs_save(void)
return res;
}
+
/* exported interface documented in windows/prefs.h */
void nsws_prefs_dialog_init(HINSTANCE hinst, HWND parent)
{
diff --git a/frontends/windows/ssl_cert.c b/frontends/windows/ssl_cert.c
index 72d1d3b..efbdf45 100644
--- a/frontends/windows/ssl_cert.c
+++ b/frontends/windows/ssl_cert.c
@@ -41,13 +41,18 @@
/* spacing and sizes for dialog elements from
*
https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486(v=vs.85).aspx#sizingandspacing
*/
+/** dialog margin */
#define DLG_MRGN 11
+/** warning icon height */
#define WRN_ICO_H 32
+/** comand button width */
#define CMD_BTN_W 75
+/** command button height */
#define CMD_BTN_H 23
static const char windowclassname_sslcert[] = "nswssslcertwindow";
+/** win32 ssl certificate view context */
struct nsw32_sslcert_window {
struct nsw32_corewindow core;
@@ -65,15 +70,15 @@ struct nsw32_sslcert_window {
/** warning text handle */
HWND hTxt;
-
};
+
/**
- * callback for keypress on hotlist window
+ * callback for keypress on ssl certificate window
*
* \param nsw32_cw The nsw32 core window structure.
* \param nskey The netsurf key code
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
nsw32_sslcert_viewer_key(struct nsw32_corewindow *nsw32_cw, uint32_t nskey)
@@ -89,19 +94,20 @@ nsw32_sslcert_viewer_key(struct nsw32_corewindow *nsw32_cw,
uint32_t nskey)
return NSERROR_NOT_IMPLEMENTED;
}
+
/**
- * callback for mouse action on hotlist window
+ * callback for mouse action on ssl certificate window
*
* \param nsw32_cw The nsw32 core window structure.
* \param mouse_state netsurf mouse state on event
* \param x location of event
* \param y location of event
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
nsw32_sslcert_viewer_mouse(struct nsw32_corewindow *nsw32_cw,
- browser_mouse_state mouse_state,
- int x, int y)
+ browser_mouse_state mouse_state,
+ int x, int y)
{
struct nsw32_sslcert_window *crtvrfy_win;
@@ -113,12 +119,13 @@ nsw32_sslcert_viewer_mouse(struct nsw32_corewindow
*nsw32_cw,
return NSERROR_OK;
}
+
/**
- * callback on draw event for hotlist window
+ * callback on draw event for ssl certificate window
*
* \param nsw32_cw The nsw32 core window structure.
* \param r The rectangle of the window that needs updating.
- * \return NSERROR_OK on success otherwise apropriate error code
+ * \return NSERROR_OK on success otherwise appropriate error code
*/
static nserror
nsw32_sslcert_viewer_draw(struct nsw32_corewindow *nsw32_cw,
@@ -144,6 +151,12 @@ nsw32_sslcert_viewer_draw(struct nsw32_corewindow
*nsw32_cw,
}
+/**
+ * callback on close event for ssl certificate window
+ *
+ * \param nsw32_cw The nsw32 core window structure.
+ * \return NSERROR_OK on success otherwise appropriate error code
+ */
static nserror
nsw32_sslcert_viewer_close(struct nsw32_corewindow *nsw32_cw)
{
@@ -155,10 +168,10 @@ nsw32_sslcert_viewer_close(struct nsw32_corewindow
*nsw32_cw)
/* exported interface documented in nsw32/ssl_cert.h */
nserror nsw32_cert_verify(struct nsurl *url,
- const struct ssl_cert_info *certs,
- unsigned long num,
- nserror (*cb)(bool proceed, void *pw),
- void *cbpw)
+ const struct ssl_cert_info *certs,
+ unsigned long num,
+ nserror (*cb)(bool proceed, void *pw),
+ void *cbpw)
{
struct nsw32_sslcert_window *ncwin;
nserror res;
@@ -260,17 +273,17 @@ nserror nsw32_cert_verify(struct nsurl *url,
NULL,
NULL);
ncwin->hTxt = CreateWindowEx(0,
- "STATIC",
- "NetSurf failed to verify the authenticity of an SSL
certificate. Verify the certificate details",
- WS_VISIBLE | WS_CHILD | SS_LEFT,
- DLG_MRGN + WRN_ICO_H + DLG_MRGN,
- DLG_MRGN + 5,
- 400,
- WRN_ICO_H - 5,
- ncwin->hWnd,
- NULL,
- NULL,
- NULL);
+ "STATIC",
+ "NetSurf failed to verify the authenticity
of an SSL certificate. Verify the certificate details",
+ WS_VISIBLE | WS_CHILD | SS_LEFT,
+ DLG_MRGN + WRN_ICO_H + DLG_MRGN,
+ DLG_MRGN + 5,
+ 400,
+ WRN_ICO_H - 5,
+ ncwin->hWnd,
+ NULL,
+ NULL,
+ NULL);
SendMessage(ncwin->hTxt, WM_SETFONT, (WPARAM)hfDefault,
MAKELPARAM(FALSE,0));
SetProp(ncwin->hWnd, TEXT("CertWnd"), (HANDLE)ncwin);
@@ -280,8 +293,12 @@ nserror nsw32_cert_verify(struct nsurl *url,
return NSERROR_OK;
}
+
/**
* position and size ssl cert window widgets.
+ *
+ * \param hwnd The win32 handle of the window
+ * \param certwin The certificate viewer context
*/
static void
nsw32_window_ssl_cert_size(HWND hwnd, struct nsw32_sslcert_window *certwin)
@@ -318,6 +335,13 @@ nsw32_window_ssl_cert_size(HWND hwnd, struct
nsw32_sslcert_window *certwin)
TRUE);
}
+
+/**
+ * Destroy a certificate viewing window
+ *
+ * \param certwin The certificate viewer context
+ * \return NSERROR_OK on success otherwise appropriate error code
+ */
static nserror nsw32_crtvrfy_destroy(struct nsw32_sslcert_window *crtwin)
{
nserror res;
@@ -331,22 +355,23 @@ static nserror nsw32_crtvrfy_destroy(struct
nsw32_sslcert_window *crtwin)
return res;
}
+
/**
- * handle command message on main browser window
+ * handle command message on certificate viewing window
*
* \param hwnd The win32 window handle
* \param gw win32 gui window
- * \param notification_code notifiction code
+ * \param notification_code notification code
* \param identifier notification identifier
* \param ctrl_window The win32 control window handle
- * \return apropriate response for command
+ * \return appropriate response for command
*/
static LRESULT
nsw32_window_ssl_cert_command(HWND hwnd,
- struct nsw32_sslcert_window *crtwin,
- int notification_code,
- int identifier,
- HWND ctrl_window)
+ struct nsw32_sslcert_window *crtwin,
+ int notification_code,
+ int identifier,
+ HWND ctrl_window)
{
LOG("notification_code %x identifier %x ctrl_window %p",
notification_code, identifier, ctrl_window);
@@ -368,6 +393,7 @@ nsw32_window_ssl_cert_command(HWND hwnd,
return 0; /* control message handled */
}
+
/**
* callback for SSL certificate window win32 events
*
@@ -378,9 +404,9 @@ nsw32_window_ssl_cert_command(HWND hwnd,
*/
static LRESULT CALLBACK
nsw32_window_ssl_cert_event_callback(HWND hwnd,
- UINT msg,
- WPARAM wparam,
- LPARAM lparam)
+ UINT msg,
+ WPARAM wparam,
+ LPARAM lparam)
{
struct nsw32_sslcert_window *crtwin;
crtwin = GetProp(hwnd, TEXT("CertWnd"));
@@ -410,6 +436,7 @@ nsw32_window_ssl_cert_event_callback(HWND hwnd,
return DefWindowProc(hwnd, msg, wparam, lparam);
}
+
/* exported interface documented in nsw32/ssl_cert.h */
nserror nsws_create_cert_verify_class(HINSTANCE hInstance)
{
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 94dc7c1..74b84e3 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -75,7 +75,7 @@ static int open_windows = 0;
* Obtain the DPI of the display.
*
* \param hwnd A win32 window handle to get the DPI for
- * \return The DPI of the device teh window is displayed on.
+ * \return The DPI of the device the window is displayed on.
*/
static int get_window_dpi(HWND hwnd)
{
@@ -99,7 +99,7 @@ static int get_window_dpi(HWND hwnd)
*
* \param gw gui window context.
*/
-static void nsws_window_set_accels(struct gui_window *w)
+static void nsws_window_set_accels(struct gui_window *gw)
{
int i, nitems = 13;
ACCEL accels[nitems];
@@ -137,7 +137,7 @@ static void nsws_window_set_accels(struct gui_window *w)
accels[12].fVirt = FVIRTKEY;
accels[12].cmd = IDM_VIEW_FULLSCREEN;
- w->acceltable = CreateAcceleratorTable(accels, nitems);
+ gw->acceltable = CreateAcceleratorTable(accels, nitems);
}
@@ -223,9 +223,9 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct
gui_window *gw)
*/
static LRESULT
nsws_window_toolbar_command(struct gui_window *gw,
- int notification_code,
- int identifier,
- HWND ctrl_window)
+ int notification_code,
+ int identifier,
+ HWND ctrl_window)
{
LOG("notification_code %d identifier %d ctrl_window %p",
notification_code, identifier, ctrl_window);
@@ -446,7 +446,7 @@ nsws_window_urlbar_callback(HWND hwnd, UINT msg, WPARAM
wparam, LPARAM lparam)
/**
* create a urlbar and message handler
*
- * Create an Edit control for enerting urls
+ * Create an Edit control for entering urls
*
* \param hInstance The application instance handle.
* \param hWndParent The containing window.
@@ -491,8 +491,8 @@ nsws_window_urlbar_create(HINSTANCE hInstance,
/* subclass the message handler */
urlproc = (WNDPROC)SetWindowLongPtr(hwnd,
- GWLP_WNDPROC,
- (LONG_PTR)nsws_window_urlbar_callback);
+ GWLP_WNDPROC,
+
(LONG_PTR)nsws_window_urlbar_callback);
/* save the real handler */
SetProp(hwnd, TEXT("OrigMsgProc"), (HANDLE)urlproc);
@@ -654,8 +654,8 @@ nsws_window_create_toolbar(HINSTANCE hInstance,
/* subclass the message handler */
toolproc = (WNDPROC)SetWindowLongPtr(hWndToolbar,
- GWLP_WNDPROC,
- (LONG_PTR)nsws_window_toolbar_callback);
+ GWLP_WNDPROC,
+
(LONG_PTR)nsws_window_toolbar_callback);
/* save the real handler */
SetProp(hWndToolbar, TEXT("OrigMsgProc"), (HANDLE)toolproc);
@@ -754,7 +754,7 @@ nsws_window_create_statusbar(HINSTANCE hInstance,
static void nsws_update_edit(struct gui_window *w)
{
browser_editor_flags editor_flags = (w->bw == NULL) ?
- BW_EDITOR_NONE : browser_window_get_editor_flags(w->bw);
+ BW_EDITOR_NONE : browser_window_get_editor_flags(w->bw);
bool paste, copy, del;
bool sel = (editor_flags & BW_EDITOR_CAN_COPY);
@@ -810,7 +810,7 @@ static void nsws_update_edit(struct gui_window *w)
* \param gw win32 frontends graphical window.
* \param hwnd The win32 window handle
* \param int x The x coordinate of the event.
- * \param y the y cooordiante of the event.
+ * \param y the y coordinate of the event.
*/
static bool
nsws_ctx_menu(struct gui_window *w, HWND hwnd, int x, int y)
@@ -963,10 +963,10 @@ static nserror win32_open_new_window(struct gui_window
*gw)
*
* \param hwnd The win32 window handle
* \param gw win32 gui window
- * \param notification_code notifiction code
+ * \param notification_code notification code
* \param identifier notification identifier
* \param ctrl_window The win32 control window handle
- * \return apropriate response for command
+ * \return appropriate response for command
*/
static LRESULT
nsws_window_command(HWND hwnd,
@@ -1286,9 +1286,9 @@ nsws_window_command(HWND hwnd,
/**
* Get the scroll position of a win32 browser window.
*
- * \param g gui_window
- * \param sx receives x ordinate of point at top-left of window
- * \param sy receives y ordinate of point at top-left of window
+ * \param gw gui_window
+ * \param sx receives x ordinate of point at top-left of window
+ * \param sy receives y ordinate of point at top-left of window
* \return true iff successful
*/
static bool win32_window_get_scroll(struct gui_window *gw, int *sx, int *sy)
@@ -1311,7 +1311,7 @@ static bool win32_window_get_scroll(struct gui_window
*gw, int *sx, int *sy)
* \param hwnd The win32 window handle
* \param wparam The w win32 parameter
* \param lparam The l win32 parameter
- * \return apropriate response for resize
+ * \return appropriate response for resize
*/
static LRESULT
nsws_window_resize(struct gui_window *gw,
@@ -1603,24 +1603,29 @@ static void win32_window_reformat(struct gui_window *gw)
*/
static void win32_window_set_title(struct gui_window *w, const char *title)
{
- if (w == NULL)
+ char *fulltitle;
+
+ if (w == NULL) {
return;
+ }
+
LOG("%p, title %s", w, title);
- char *fulltitle = malloc(strlen(title) +
- SLEN(" - NetSurf") + 1);
+ fulltitle = malloc(strlen(title) + SLEN(" - NetSurf") + 1);
if (fulltitle == NULL) {
win32_warning("NoMemory", 0);
return;
}
+
strcpy(fulltitle, title);
strcat(fulltitle, " - NetSurf");
+
SendMessage(w->main, WM_SETTEXT, 0, (LPARAM)fulltitle);
free(fulltitle);
}
/**
- * Set the navigation url is a win32 browser window.
+ * Set the navigation url in a win32 browser window.
*
* \param gw window to update.
* \param url The url to use as icon.
@@ -1797,7 +1802,7 @@ struct gui_window *nsws_get_gui_window(HWND hwnd)
struct gui_window *gw = NULL;
HWND phwnd = hwnd;
- /* scan the window hierachy for gui window */
+ /* scan the window hierarchy for gui window */
while (phwnd != NULL) {
gw = GetProp(phwnd, TEXT("GuiWnd"));
if (gw != NULL)
@@ -1866,7 +1871,7 @@ void win32_window_set_scroll(struct gui_window *w, int
sx, int sy)
/*LOG("scroll sx,sy:%d,%d x,y:%d,%d
w.h:%d,%d",sx,sy,w->scrollx,w->scrolly, width,height);*/
- /* The resulting gui window scroll must remain withn the
+ /* The resulting gui window scroll must remain within the
* windows bounding box.
*/
if (sx < 0) {
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org