summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2017-06-01 22:57:09 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2017-06-01 22:57:09 (GMT)
commitc08ef5f984fe785b6e13df204046b455489f8810 (patch)
treef7dad140cc5f11c9c4ae6aa0b490e22d0b37f8ee
parent08a86bfa0e5d961f255f8e64ddcdb6f179db485d (diff)
downloadnetsurf-c08ef5f984fe785b6e13df204046b455489f8810.tar.gz
netsurf-c08ef5f984fe785b6e13df204046b455489f8810.tar.bz2
make windows frontend use corewindow API for local history window
-rw-r--r--frontends/windows/Makefile2
-rw-r--r--frontends/windows/corewindow.c68
-rw-r--r--frontends/windows/drawable.c7
-rw-r--r--frontends/windows/local_history.c259
-rw-r--r--frontends/windows/local_history.h45
-rw-r--r--frontends/windows/localhistory.c448
-rw-r--r--frontends/windows/localhistory.h46
-rw-r--r--frontends/windows/main.c3
-rw-r--r--frontends/windows/window.c15
9 files changed, 380 insertions, 513 deletions
diff --git a/frontends/windows/Makefile b/frontends/windows/Makefile
index 1b93e4c..bd34b46 100644
--- a/frontends/windows/Makefile
+++ b/frontends/windows/Makefile
@@ -50,7 +50,7 @@ S_RESOURCES := windows_resource.o
# sources purely for the windows build
S_FRONTEND := main.c window.c gui.c drawable.c plot.c findfile.c \
font.c bitmap.c about.c prefs.c download.c filetype.c file.c \
- localhistory.c schedule.c windbg.c pointers.c \
+ local_history.c schedule.c windbg.c pointers.c \
corewindow.c hotlist.c cookies.c global_history.c ssl_cert.c
# This is the final source build list
diff --git a/frontends/windows/corewindow.c b/frontends/windows/corewindow.c
index a121219..adf1c65 100644
--- a/frontends/windows/corewindow.c
+++ b/frontends/windows/corewindow.c
@@ -211,7 +211,7 @@ nsw32_corewindow_vscroll(struct nsw32_corewindow *nsw32_cw,
NULL,
NULL,
NULL,
- SW_INVALIDATE);
+ SW_ERASE | SW_INVALIDATE);
/**
* /todo win32 corewindow vertical scrolling needs us to
@@ -221,6 +221,69 @@ nsw32_corewindow_vscroll(struct nsw32_corewindow *nsw32_cw,
return 0;
}
+
+static LRESULT
+nsw32_corewindow_hscroll(struct nsw32_corewindow *nsw32_cw,
+ HWND hwnd,
+ WPARAM wparam)
+{
+ SCROLLINFO si; /* current scroll information */
+ SCROLLINFO usi; /* updated scroll infomation for scrollwindowex */
+
+ LOG("VSCROLL");
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo(hwnd, SB_HORZ, &si);
+ usi = si;
+
+ switch (LOWORD(wparam)) {
+ case SB_LINELEFT:
+ usi.nPos -= 30;
+ break;
+
+ case SB_LINERIGHT:
+ usi.nPos += 30;
+ break;
+
+ case SB_PAGELEFT:
+ usi.nPos -= si.nPage;
+ break;
+
+ case SB_PAGERIGHT:
+ usi.nPos += si.nPage;
+ break;
+
+ case SB_THUMBTRACK:
+ usi.nPos = si.nTrackPos;
+ break;
+
+ default:
+ break;
+ }
+
+ if (usi.nPos < si.nMin) {
+ usi.nPos = si.nMin;
+ }
+ if (usi.nPos > si.nMax) {
+ usi.nPos = si.nMax;
+ }
+
+ SetScrollInfo(hwnd, SB_HORZ, &usi, TRUE);
+
+ ScrollWindowEx(hwnd,
+ si.nPos - usi.nPos,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ SW_ERASE | SW_INVALIDATE);
+
+ return 0;
+}
+
+
static LRESULT
nsw32_corewindow_mousedown(struct nsw32_corewindow *nsw32_cw,
int x, int y,
@@ -275,6 +338,9 @@ nsw32_window_corewindow_event_callback(HWND hwnd,
case WM_VSCROLL:
return nsw32_corewindow_vscroll(nsw32_cw, hwnd, wparam);
+ case WM_HSCROLL:
+ return nsw32_corewindow_hscroll(nsw32_cw, hwnd, wparam);
+
case WM_LBUTTONDOWN:
return nsw32_corewindow_mousedown(nsw32_cw,
GET_X_LPARAM(lparam),
diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c
index 4540b12..28a76cf 100644
--- a/frontends/windows/drawable.c
+++ b/frontends/windows/drawable.c
@@ -38,7 +38,7 @@
#include "windows/windbg.h"
#include "windows/plot.h"
#include "windows/window.h"
-#include "windows/localhistory.h"
+#include "windows/local_history.h"
#include "windows/drawable.h"
static const char windowclassname_drawable[] = "nswsdrawablewindow";
@@ -415,7 +415,7 @@ nsws_drawable_mousedown(struct gui_window *gw,
if ((gw == NULL) ||
(gw->mouse == NULL) ||
(gw->bw == NULL)) {
- nsws_localhistory_close(gw);
+ nsw32_local_history_hide();
return 0;
}
@@ -532,9 +532,8 @@ nsws_window_drawable_event_callback(HWND hwnd,
GET_Y_LPARAM(lparam),
BROWSER_MOUSE_PRESS_1);
SetFocus(hwnd);
- nsws_localhistory_close(gw);
+ nsw32_local_history_hide();
return 0;
- break;
case WM_RBUTTONDOWN:
nsws_drawable_mousedown(gw,
diff --git a/frontends/windows/local_history.c b/frontends/windows/local_history.c
new file mode 100644
index 0000000..f447423
--- a/dev/null
+++ b/frontends/windows/local_history.c
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2017 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Implementation of win32 local history interface.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <windows.h>
+
+#include "utils/log.h"
+#include "utils/nsoption.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
+#include "desktop/local_history.h"
+
+#include "windows/plot.h"
+#include "windows/corewindow.h"
+#include "windows/local_history.h"
+
+
+struct nsw32_local_history_window {
+ struct nsw32_corewindow core;
+
+ struct local_history_session *session;
+};
+
+static struct nsw32_local_history_window *local_history_window = NULL;
+
+/**
+ * callback for keypress on local_history window
+ *
+ * \param nsw32_cw The nsw32 core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+nsw32_local_history_key(struct nsw32_corewindow *nsw32_cw, uint32_t nskey)
+{
+ struct nsw32_local_history_window *lhw;
+
+ lhw = (struct nsw32_local_history_window *)nsw32_cw;
+
+ if (local_history_keypress(lhw->session,nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
+
+/**
+ * callback for mouse action on local_history 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
+ */
+static nserror
+nsw32_local_history_mouse(struct nsw32_corewindow *nsw32_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ struct nsw32_local_history_window *lhw;
+
+ lhw = (struct nsw32_local_history_window *)nsw32_cw;
+
+ local_history_mouse_action(lhw->session, mouse_state, x, y);
+
+ return NSERROR_OK;
+}
+
+/**
+ * callback on draw event for local_history window
+ *
+ * \param nsw32_cw The nsw32 core window structure.
+ * \param scrollx The horizontal scroll offset.
+ * \param scrolly The vertical scroll offset.
+ * \param r The rectangle of the window that needs updating.
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+nsw32_local_history_draw(struct nsw32_corewindow *nsw32_cw,
+ int scrollx,
+ int scrolly,
+ struct rect *r)
+{
+ struct nsw32_local_history_window *lhw;
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &win_plotters
+ };
+
+ lhw = (struct nsw32_local_history_window *)nsw32_cw;
+
+ local_history_redraw(lhw->session,
+ r->x0 - scrollx,
+ r->y0 - scrolly,
+ r,
+ &ctx);
+
+ return NSERROR_OK;
+}
+
+
+static nserror
+nsw32_local_history_close(struct nsw32_corewindow *nsw32_cw)
+{
+ ShowWindow(nsw32_cw->hWnd, SW_HIDE);
+
+ return NSERROR_OK;
+}
+
+/**
+ * Creates the window for the local_history tree.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+static nserror
+nsw32_local_history_init(HINSTANCE hInstance,
+ struct browser_window *bw,
+ struct nsw32_local_history_window **win_out)
+{
+ struct nsw32_local_history_window *ncwin;
+ nserror res;
+
+ if ((*win_out) != NULL) {
+ res = local_history_set((*win_out)->session, bw);
+ return res;
+ }
+
+ ncwin = malloc(sizeof(struct nsw32_local_history_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ ncwin->core.title = "NetSurf Local History";
+ ncwin->core.draw = nsw32_local_history_draw;
+ ncwin->core.key = nsw32_local_history_key;
+ ncwin->core.mouse = nsw32_local_history_mouse;
+ ncwin->core.close = nsw32_local_history_close;
+
+ res = nsw32_corewindow_init(hInstance, NULL, &ncwin->core);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ res = local_history_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin,
+ bw,
+ &ncwin->session);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ /* memoise window so it can be represented when necessary
+ * instead of recreating every time.
+ */
+ *win_out = ncwin;
+
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in windows/local_history.h */
+nserror
+nsw32_local_history_present(HWND hWndParent, struct browser_window *bw)
+{
+ nserror res;
+ HINSTANCE hInstance;
+ RECT parentr;
+ int width, height;
+ int margin = 50;
+
+ hInstance = (HINSTANCE)GetWindowLongPtr(hWndParent, GWLP_HINSTANCE);
+
+ res = nsw32_local_history_init(hInstance, bw, &local_history_window);
+ if (res == NSERROR_OK) {
+ GetWindowRect(hWndParent, &parentr);
+
+ /* resize history widget ensureing the drawing area is
+ * no larger than parent window
+ */
+ res = local_history_get_size(local_history_window->session,
+ &width,
+ &height);
+ width += margin;
+ height += margin;
+ if ((parentr.right - parentr.left - margin) < width) {
+ width = parentr.right - parentr.left - margin;
+ }
+ if ((parentr.bottom - parentr.top - margin) < height) {
+ height = parentr.bottom - parentr.top - margin;
+ }
+ SetWindowPos(local_history_window->core.hWnd,
+ HWND_TOP,
+ parentr.left + (margin/2),
+ parentr.top + (margin/2),
+ width,
+ height,
+ SWP_SHOWWINDOW);
+ }
+ return res;
+}
+
+
+/* exported interface documented in windows/local_history.h */
+nserror nsw32_local_history_hide(void)
+{
+ nserror res = NSERROR_OK;
+
+ if (local_history_window != NULL) {
+ ShowWindow(local_history_window->core.hWnd, SW_HIDE);
+
+ res = local_history_set(local_history_window->session, NULL);
+ }
+
+ return res;
+}
+
+/* exported interface documented in windows/local_history.h */
+nserror nsw32_local_history_finalise(void)
+{
+ nserror res;
+
+ if (local_history_window == NULL) {
+ return NSERROR_OK;
+ }
+
+ res = local_history_fini(local_history_window->session);
+ if (res == NSERROR_OK) {
+ res = nsw32_corewindow_fini(&local_history_window->core);
+ DestroyWindow(local_history_window->core.hWnd);
+ free(local_history_window);
+ local_history_window = NULL;
+ }
+
+ return res;
+}
diff --git a/frontends/windows/local_history.h b/frontends/windows/local_history.h
new file mode 100644
index 0000000..a6e2180
--- a/dev/null
+++ b/frontends/windows/local_history.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Interface to win32 local history manager using nsw32 core window
+ */
+
+#ifndef NETSURF_WINDOWS_LOCAL_HISTORY_H
+#define NETSURF_WINDOWS_LOCAL_HISTORY_H
+
+/**
+ * make the local history window visible.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror nsw32_local_history_present(HWND hWndParent, struct browser_window *bw);
+
+/**
+ * hide the local history window.
+ */
+nserror nsw32_local_history_hide(void);
+
+/**
+ * Destroys the local history window and performs any other necessary cleanup
+ * actions.
+ */
+nserror nsw32_local_history_finalise(void);
+
+#endif
diff --git a/frontends/windows/localhistory.c b/frontends/windows/localhistory.c
deleted file mode 100644
index e145cf7..0000000
--- a/frontends/windows/localhistory.c
+++ b/dev/null
@@ -1,448 +0,0 @@
-/*
- * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * \file
- * win32 local history viewer implementation.
- */
-
-#include "utils/config.h"
-
-#include <windows.h>
-#include <windowsx.h>
-#include <commctrl.h>
-
-#include "desktop/browser_history.h"
-#include "netsurf/plotters.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-
-#include "windows/window.h"
-#include "windows/localhistory.h"
-#include "windows/gui.h"
-#include "windows/plot.h"
-#include "windows/resourceid.h"
-#include "windows/windbg.h"
-
-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 */
- int height; /**< the height of the memory history */
- int guiwidth; /**< the width of the history window */
- int guiheight; /**< the height of the history window */
- int vscroll; /**< the vertical scroll location */
- int hscroll; /**< the horizontal scroll location */
-};
-
-
-/**
- * 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)) {
- return;
- }
-
- browser_window_history_size(gw->bw, &(l->width), &(l->height));
-
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL;
- si.nMin = 0;
- si.nMax = l->height;
- si.nPage = l->guiheight;
- si.nPos = 0;
- SetScrollInfo(l->hwnd, SB_VERT, &si, TRUE);
-
- si.nMax = l->width;
- si.nPage = l->guiwidth;
- SetScrollInfo(l->hwnd, SB_HORZ, &si, TRUE);
- if (l->guiheight >= l->height) {
- l->vscroll = 0;
- }
- 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)
-{
- HDC tmp_hdc;
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &win_plotters
- };
-
- LOG("gui window %p", gw);
-
- l->vscroll = 0;
- l->hscroll = 0;
-
- if (gw->bw != NULL) {
- /* set global HDC for the plotters */
- tmp_hdc = plot_hdc;
- plot_hdc = GetDC(l->hwnd);
-
- browser_window_history_redraw(gw->bw, &ctx);
-
- ReleaseDC(l->hwnd, plot_hdc);
-
- plot_hdc = tmp_hdc;
- }
-
- nsws_localhistory_scroll_check(l, gw);
-}
-
-
-/* exported interface documented in windows/localhistory.h */
-void nsws_localhistory_close(struct gui_window *gw)
-{
- struct nsws_localhistory *lh = gui_window_localhistory(gw);
- if (lh != NULL) {
- CloseWindow(lh->hwnd);
- }
-}
-
-
-/**
- * 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;
-
- LOG_WIN_MSG(hwnd, msg, wparam, lparam);
-
- gw = nsws_get_gui_window(hwnd);
- if (gw == NULL) {
- LOG("Unable to find gui window structure for hwnd %p", hwnd);
- return DefWindowProc(hwnd, msg, wparam, lparam);
- }
-
- switch(msg) {
-
- case WM_CREATE:
- nsws_localhistory_scroll_check(gw->localhistory, gw);
- break;
-
- case WM_SIZE:
- gw->localhistory->guiheight = HIWORD(lparam);
- gw->localhistory->guiwidth = LOWORD(lparam);
- nsws_localhistory_scroll_check(gw->localhistory, gw);
- break;
-
- case WM_LBUTTONUP:
- if (gw->bw == NULL)
- break;
-
- x = GET_X_LPARAM(lparam);
- y = GET_Y_LPARAM(lparam);
-
- if (browser_window_history_click(gw->bw,
- gw->localhistory->hscroll + x,
- gw->localhistory->vscroll + y,
- false)) {
- DestroyWindow(hwnd);
- }
-
- break;
-
- case WM_MOUSEMOVE:
- x = GET_X_LPARAM(lparam);
- y = GET_Y_LPARAM(lparam);
- return DefWindowProc(hwnd, msg, wparam, lparam);
- break;
-
-
- case WM_VSCROLL:
- {
- SCROLLINFO si;
- int mem;
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL;
- GetScrollInfo(hwnd, SB_VERT, &si);
- mem = si.nPos;
- switch (LOWORD(wparam)) {
- case SB_TOP:
- si.nPos = si.nMin;
- break;
- case SB_BOTTOM:
- si.nPos = si.nMax;
- break;
- case SB_LINEUP:
- si.nPos -= 30;
- break;
- case SB_LINEDOWN:
- si.nPos += 30;
- break;
- case SB_PAGEUP:
- si.nPos -= gw->localhistory->guiheight;
- break;
- case SB_PAGEDOWN:
- si.nPos += gw->localhistory->guiheight;
- break;
- case SB_THUMBTRACK:
- si.nPos = si.nTrackPos;
- break;
- default:
- break;
- }
- si.nPos = min(si.nPos, gw->localhistory->height);
- si.nPos = min(si.nPos, 0);
- si.fMask = SIF_POS;
- SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
- GetScrollInfo(hwnd, SB_VERT, &si);
- if (si.nPos != mem) {
- gw->localhistory->vscroll += si.nPos - mem;
- ScrollWindowEx(hwnd, 0, -(si.nPos - mem), NULL, NULL, NULL, NULL, SW_ERASE | SW_INVALIDATE);
- }
- break;
- }
-
- case WM_HSCROLL:
- {
- SCROLLINFO si;
- int mem;
-
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL;
- GetScrollInfo(hwnd, SB_HORZ, &si);
- mem = si.nPos;
-
- switch (LOWORD(wparam)) {
- case SB_LINELEFT:
- si.nPos -= 30;
- break;
- case SB_LINERIGHT:
- si.nPos += 30;
- break;
- case SB_PAGELEFT:
- si.nPos -= gw->localhistory->guiwidth;
- break;
- case SB_PAGERIGHT:
- si.nPos += gw->localhistory->guiwidth;
- break;
- case SB_THUMBTRACK:
- si.nPos = si.nTrackPos;
- break;
- default:
- break;
- }
- si.nPos = min(si.nPos, gw->localhistory->width);
- si.nPos = max(si.nPos, 0);
- si.fMask = SIF_POS;
- SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
- GetScrollInfo(hwnd, SB_HORZ, &si);
- if (si.nPos != mem) {
- gw->localhistory->hscroll += si.nPos - mem;
- ScrollWindowEx(hwnd, -(si.nPos - mem), 0, NULL, NULL, NULL, NULL, SW_ERASE | SW_INVALIDATE);
- }
- break;
- }
-
- case WM_PAINT: {
- PAINTSTRUCT ps;
- HDC hdc, tmp_hdc;
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &win_plotters
- };
-
- hdc = BeginPaint(hwnd, &ps);
- if (gw->bw != NULL) {
- /* set global HDC for the plotters */
- tmp_hdc = plot_hdc;
- 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);
-
- plot_hdc = tmp_hdc;
-
- }
- EndPaint(hwnd, &ps);
-
- break;
- }
-
- case WM_CLOSE:
- DestroyWindow(hwnd);
- return 1;
-
- case WM_DESTROY:
- free(gw->localhistory);
- gw->localhistory = NULL;
- break;
-
- default:
- return DefWindowProc(hwnd, msg, wparam, lparam);
-
- }
- return 0;
-}
-
-
-/* exported method documented in windows/localhistory.h */
-struct nsws_localhistory *nsws_window_create_localhistory(struct gui_window *gw)
-{
- struct nsws_localhistory *localhistory;
- INITCOMMONCONTROLSEX icc;
- int margin = 50;
- RECT r;
-
- LOG("gui window %p", gw);
-
- /* if we already have a window, just update and re-show it */
- if (gw->localhistory != NULL) {
- nsws_localhistory_up(gw->localhistory, gw);
- UpdateWindow(gw->localhistory->hwnd);
- ShowWindow(gw->localhistory->hwnd, SW_SHOWNORMAL);
- return gw->localhistory;
- }
-
- localhistory = calloc(1, sizeof(struct nsws_localhistory));
-
- if (localhistory == NULL) {
- return NULL;
- }
- gw->localhistory = localhistory;
-
- localhistory->width = 0;
- localhistory->height = 0;
-
- if (gw->bw != NULL) {
- browser_window_history_size(gw->bw,
- &(localhistory->width),
- &(localhistory->height));
- }
-
- GetWindowRect(gw->main, &r);
- 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->guiheight = min(r.bottom - r.top - margin,
- localhistory->height + margin);
-
- icc.dwSize = sizeof(icc);
- icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
-#if WINVER > 0x0501
- icc.dwICC |= ICC_STANDARD_CLASSES;
-#endif
- InitCommonControlsEx(&icc);
-
- LOG("creating local history window for hInstance %p", hinst);
- localhistory->hwnd = CreateWindow(windowclassname_localhistory,
- "NetSurf History",
- WS_THICKFRAME |
- WS_HSCROLL |
- WS_VSCROLL |
- WS_CLIPCHILDREN |
- WS_CLIPSIBLINGS |
- WS_SYSMENU |
- CS_DBLCLKS,
- r.left + margin/2,
- r.top + margin/2,
- localhistory->guiwidth,
- localhistory->guiheight,
- NULL,
- NULL,
- hinst,
- NULL);
-
- /* set the gui window associated with this browser */
- SetProp(localhistory->hwnd, TEXT("GuiWnd"), (HANDLE)gw);
-
- LOG("gui_window %p width %d height %d hwnd %p",
- gw, localhistory->guiwidth, localhistory->guiheight,
- localhistory->hwnd);
-
- nsws_localhistory_up(localhistory, gw);
- UpdateWindow(localhistory->hwnd);
- ShowWindow(localhistory->hwnd, SW_SHOWNORMAL);
-
- return localhistory;
-}
-
-
-/* exported method documented in windows/localhistory.h */
-nserror
-nsws_create_localhistory_class(HINSTANCE hinstance)
-{
- nserror ret = NSERROR_OK;
- WNDCLASSEX w;
-
- /* localhistory window */
- w.cbSize = sizeof(WNDCLASSEX);
- w.style = 0;
- w.lpfnWndProc = nsws_localhistory_event_callback;
- w.cbClsExtra = 0;
- w.cbWndExtra = 0;
- w.hInstance = hinstance;
- w.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDR_NETSURF_ICON));
- w.hCursor = LoadCursor(NULL, IDC_ARROW);
- w.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- w.lpszMenuName = NULL;
- w.lpszClassName = windowclassname_localhistory;
- w.hIconSm = LoadIcon(hinstance, MAKEINTRESOURCE(IDR_NETSURF_ICON));
-
- if (RegisterClassEx(&w) == 0) {
- win_perror("DrawableClass");
- ret = NSERROR_INIT_FAILED;
- }
-
- return ret;
-}
diff --git a/frontends/windows/localhistory.h b/frontends/windows/localhistory.h
deleted file mode 100644
index eed417f..0000000
--- a/frontends/windows/localhistory.h
+++ b/dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
-*
-* This file is part of NetSurf, http://www.netsurf-browser.org/
-*
-* NetSurf is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; version 2 of the License.
-*
-* NetSurf is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef NETSURF_WINDOWS_LOCALHISTORY_H
-#define NETSURF_WINDOWS_LOCALHISTORY_H
-
-struct nsws_localhistory;
-
-/**
- * Close win32 localhistory window.
- *
- * \param gw The win32 gui window to close local history for.
- */
-void nsws_localhistory_close(struct gui_window *gw);
-
-/**
- * creates localhistory window
- *
- * \param gw The win32 gui window to create a local history for.
- */
-struct nsws_localhistory *nsws_window_create_localhistory(struct gui_window *gw);
-
-/**
- * Create the win32 window class
- *
- * \param hinstance The application instance to create the window class under
- * \return NSERROR_OK on success else error code.
- */
-nserror nsws_create_localhistory_class(HINSTANCE hinstance);
-
-#endif
diff --git a/frontends/windows/main.c b/frontends/windows/main.c
index ec2b20f..d019f10 100644
--- a/frontends/windows/main.c
+++ b/frontends/windows/main.c
@@ -46,7 +46,7 @@
#include "windows/corewindow.h"
#include "windows/ssl_cert.h"
#include "windows/download.h"
-#include "windows/localhistory.h"
+#include "windows/local_history.h"
#include "windows/window.h"
#include "windows/schedule.h"
#include "windows/font.h"
@@ -376,7 +376,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
ret = nsws_create_main_class(hInstance);
ret = nsws_create_drawable_class(hInstance);
- ret = nsws_create_localhistory_class(hInstance);
ret = nsw32_create_corewindow_class(hInstance);
ret = nsws_create_cert_verify_class(hInstance);
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 6ba61c5..976974c 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -49,7 +49,7 @@
#include "windows/drawable.h"
#include "windows/font.h"
#include "windows/prefs.h"
-#include "windows/localhistory.h"
+#include "windows/local_history.h"
#include "windows/hotlist.h"
#include "windows/cookies.h"
#include "windows/global_history.h"
@@ -879,6 +879,7 @@ static void nsws_window_update_forward_back(struct gui_window *w)
MAKELONG((back ? TBSTATE_ENABLED :
TBSTATE_INDETERMINATE), 0));
}
+ nsw32_local_history_hide();
}
@@ -1148,7 +1149,7 @@ nsws_window_command(HWND hwnd,
break;
case IDM_NAV_LOCALHISTORY:
- gw->localhistory = nsws_window_create_localhistory(gw);
+ nsw32_local_history_present(gw->main, gw->bw);
break;
case IDM_NAV_GLOBALHISTORY:
@@ -1436,6 +1437,7 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
case WM_NCDESTROY:
RemoveProp(hwnd, TEXT("GuiWnd"));
+ nsw32_local_history_hide();
browser_window_destroy(gw->bw);
if (--open_windows <= 0) {
win32_set_quit(true);
@@ -1948,12 +1950,3 @@ HWND gui_window_main_window(struct gui_window *w)
return NULL;
return w->main;
}
-
-
-/* exported interface documented in windows/window.h */
-struct nsws_localhistory *gui_window_localhistory(struct gui_window *w)
-{
- if (w == NULL)
- return NULL;
- return w->localhistory;
-}