mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 22:41:30 +03:00
split out drawable window handling
extensive cleanups fix localhistory svn path=/trunk/netsurf/; revision=12153
This commit is contained in:
parent
74ffc40e92
commit
2ca6e9a3e6
@ -59,9 +59,10 @@ S_RESOURCES := windows_resource.o
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# S_WINDOWS are sources purely for the windows build
|
||||
S_WINDOWS := about.c bitmap.c download.c filetype.c findfile.c font.c \
|
||||
gui.c localhistory.c login.c misc.c plot.c prefs.c schedule.c \
|
||||
thumbnail.c tree.c windbg.c system_colour.c
|
||||
S_WINDOWS := main.c window.c gui.c drawable.c misc.c plot.c findfile.c \
|
||||
font.c bitmap.c about.c prefs.c download.c filetype.c \
|
||||
localhistory.c login.c schedule.c thumbnail.c tree.c \
|
||||
windbg.c system_colour.c
|
||||
S_WINDOWS := $(addprefix windows/,$(S_WINDOWS))
|
||||
|
||||
SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_WINDOWS) $(S_RESOURCES)
|
||||
|
@ -137,7 +137,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
|
||||
|
||||
bool nsws_download_window_up(struct gui_download_window *w)
|
||||
{
|
||||
w->hwnd = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DLG_DOWNLOAD),
|
||||
w->hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DLG_DOWNLOAD),
|
||||
gui_window_main_window(w->window),
|
||||
nsws_download_event_callback);
|
||||
if (w->hwnd == NULL) {
|
||||
|
621
windows/drawable.c
Normal file
621
windows/drawable.c
Normal file
@ -0,0 +1,621 @@
|
||||
/*
|
||||
* Copyright 2011 Vincent Sanders <vince@simtec.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "utils/errors.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include "windows/windbg.h"
|
||||
#include "windows/plot.h"
|
||||
#include "windows/window.h"
|
||||
#include "windows/localhistory.h"
|
||||
#include "windows/drawable.h"
|
||||
|
||||
static const char windowclassname_drawable[] = "nswsdrawablewindow";
|
||||
|
||||
/**
|
||||
* Handle wheel scroll messages.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_wheel(struct gui_window *gw, HWND hwnd, WPARAM wparam)
|
||||
{
|
||||
int i, z = GET_WHEEL_DELTA_WPARAM(wparam) / WHEEL_DELTA;
|
||||
int key = LOWORD(wparam);
|
||||
DWORD command;
|
||||
unsigned int newmessage = WM_VSCROLL;
|
||||
|
||||
if (key == MK_SHIFT) {
|
||||
command = (z > 0) ? SB_LINERIGHT : SB_LINELEFT;
|
||||
newmessage = WM_HSCROLL;
|
||||
} else {
|
||||
/* add MK_CONTROL -> zoom */
|
||||
command = (z > 0) ? SB_LINEUP : SB_LINEDOWN;
|
||||
}
|
||||
|
||||
z = (z < 0) ? -1 * z : z;
|
||||
|
||||
for (i = 0; i < z; i++) {
|
||||
SendMessage(hwnd, newmessage, MAKELONG(command, 0), 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle vertical scroll messages.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
int mem;
|
||||
|
||||
LOG(("VSCROLL %d", gw->requestscrolly));
|
||||
|
||||
if (gw->requestscrolly != 0)
|
||||
return 0;
|
||||
|
||||
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->height;
|
||||
break;
|
||||
|
||||
case SB_PAGEDOWN:
|
||||
si.nPos += gw->height;
|
||||
break;
|
||||
|
||||
case SB_THUMBTRACK:
|
||||
si.nPos = si.nTrackPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
si.fMask = SIF_POS;
|
||||
if ((gw->bw != NULL) && (gw->bw->current_content != NULL)) {
|
||||
si.nPos = min(si.nPos,
|
||||
content_get_height(gw->bw->current_content) *
|
||||
gw->bw->scale - gw->height);
|
||||
}
|
||||
|
||||
si.nPos = max(si.nPos, 0);
|
||||
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
|
||||
GetScrollInfo(hwnd, SB_VERT, &si);
|
||||
if (si.nPos != mem) {
|
||||
gui_window_set_scroll(gw, gw->scrollx, gw->scrolly +
|
||||
gw->requestscrolly + si.nPos - mem);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle horizontal scroll messages.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
int mem;
|
||||
|
||||
LOG(("HSCROLL %d", gw->requestscrollx));
|
||||
|
||||
if (gw->requestscrollx != 0)
|
||||
return 0;
|
||||
|
||||
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->width;
|
||||
break;
|
||||
|
||||
case SB_PAGERIGHT:
|
||||
si.nPos += gw->width;
|
||||
break;
|
||||
|
||||
case SB_THUMBTRACK:
|
||||
si.nPos = si.nTrackPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
si.fMask = SIF_POS;
|
||||
|
||||
if ((gw->bw != NULL) && (gw->bw->current_content != NULL)) {
|
||||
si.nPos = min(si.nPos,
|
||||
content_get_width(gw->bw->current_content) *
|
||||
gw->bw->scale - gw->width);
|
||||
}
|
||||
si.nPos = max(si.nPos, 0);
|
||||
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
|
||||
GetScrollInfo(hwnd, SB_HORZ, &si);
|
||||
if (si.nPos != mem) {
|
||||
gui_window_set_scroll(gw,
|
||||
gw->scrollx + gw->requestscrollx + si.nPos - mem,
|
||||
gw->scrolly);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle resize events.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_resize(struct gui_window *gw)
|
||||
{
|
||||
browser_window_reformat(gw->bw, gw->width, gw->height);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle key press messages.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_key(struct gui_window *gw, HWND hwnd, WPARAM wparam)
|
||||
{
|
||||
if (GetFocus() != hwnd)
|
||||
return 0 ;
|
||||
|
||||
uint32_t i;
|
||||
bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
|
||||
bool capslock = ((GetKeyState(VK_CAPITAL) & 1) == 1);
|
||||
|
||||
switch(wparam) {
|
||||
case VK_LEFT:
|
||||
i = KEY_LEFT;
|
||||
if (shift)
|
||||
SendMessage(hwnd, WM_HSCROLL,
|
||||
MAKELONG(SB_LINELEFT, 0), 0);
|
||||
break;
|
||||
|
||||
case VK_RIGHT:
|
||||
i = KEY_RIGHT;
|
||||
if (shift)
|
||||
SendMessage(hwnd, WM_HSCROLL,
|
||||
MAKELONG(SB_LINERIGHT, 0), 0);
|
||||
break;
|
||||
|
||||
case VK_UP:
|
||||
i = KEY_UP;
|
||||
if (shift)
|
||||
SendMessage(hwnd, WM_VSCROLL,
|
||||
MAKELONG(SB_LINEUP, 0), 0);
|
||||
break;
|
||||
|
||||
case VK_DOWN:
|
||||
i = KEY_DOWN;
|
||||
if (shift)
|
||||
SendMessage(hwnd, WM_VSCROLL,
|
||||
MAKELONG(SB_LINEDOWN, 0), 0);
|
||||
break;
|
||||
|
||||
case VK_HOME:
|
||||
i = KEY_LINE_START;
|
||||
if (shift)
|
||||
SendMessage(hwnd, WM_HSCROLL,
|
||||
MAKELONG(SB_PAGELEFT, 0), 0);
|
||||
break;
|
||||
|
||||
case VK_END:
|
||||
i = KEY_LINE_END;
|
||||
if (shift)
|
||||
SendMessage(hwnd, WM_HSCROLL,
|
||||
MAKELONG(SB_PAGERIGHT, 0), 0);
|
||||
break;
|
||||
|
||||
case VK_DELETE:
|
||||
i = KEY_DELETE_RIGHT;
|
||||
break;
|
||||
|
||||
case VK_NEXT:
|
||||
i = wparam;
|
||||
SendMessage(hwnd, WM_VSCROLL, MAKELONG(SB_PAGEDOWN, 0),
|
||||
0);
|
||||
break;
|
||||
|
||||
case VK_PRIOR:
|
||||
i = wparam;
|
||||
SendMessage(hwnd, WM_VSCROLL, MAKELONG(SB_PAGEUP, 0),
|
||||
0);
|
||||
break;
|
||||
|
||||
default:
|
||||
i = wparam;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((i >= 'A') &&
|
||||
(i <= 'Z') &&
|
||||
(((!capslock) && (!shift)) || ((capslock) && (shift)))) {
|
||||
i += 'a' - 'A';
|
||||
}
|
||||
|
||||
if (gw != NULL)
|
||||
browser_window_key_press(gw->bw, i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle paint messages.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_paint(struct gui_window *gw, HWND hwnd)
|
||||
{
|
||||
struct rect clip;
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
BeginPaint(hwnd, &ps);
|
||||
|
||||
if (gw != NULL) {
|
||||
plot_hdc = ps.hdc;
|
||||
|
||||
clip.x0 = ps.rcPaint.left;
|
||||
clip.y0 = ps.rcPaint.top;
|
||||
clip.x1 = ps.rcPaint.right;
|
||||
clip.y1 = ps.rcPaint.bottom;
|
||||
|
||||
browser_window_redraw(gw->bw,
|
||||
-gw->scrollx / gw->bw->scale,
|
||||
-gw->scrolly / gw->bw->scale,
|
||||
&clip);
|
||||
}
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle mouse button up messages.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_mouseup(struct gui_window *gw,
|
||||
int x,
|
||||
int y,
|
||||
browser_mouse_state press,
|
||||
browser_mouse_state click)
|
||||
{
|
||||
bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
|
||||
bool ctrl = ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000);
|
||||
bool alt = ((GetKeyState(VK_MENU) & 0x8000) == 0x8000);
|
||||
|
||||
if ((gw == NULL) ||
|
||||
(gw->mouse == NULL) ||
|
||||
(gw->bw == NULL))
|
||||
return 0;
|
||||
|
||||
LOG(("state 0x%x, press 0x%x", gw->mouse->state, press));
|
||||
if ((gw->mouse->state & press) != 0) {
|
||||
gw->mouse->state &= ~press;
|
||||
gw->mouse->state |= click;
|
||||
}
|
||||
|
||||
if (((gw->mouse->state & BROWSER_MOUSE_MOD_1) != 0) && !shift)
|
||||
gw->mouse->state &= ~BROWSER_MOUSE_MOD_1;
|
||||
if (((gw->mouse->state & BROWSER_MOUSE_MOD_2) != 0) && !ctrl)
|
||||
gw->mouse->state &= ~BROWSER_MOUSE_MOD_2;
|
||||
if (((gw->mouse->state & BROWSER_MOUSE_MOD_3) != 0) && !alt)
|
||||
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->bw->scale,
|
||||
(y + gw->scrolly) / gw->bw->scale));
|
||||
|
||||
browser_window_mouse_click(gw->bw,
|
||||
gw->mouse->state,
|
||||
(x + gw->scrollx) / gw->bw->scale,
|
||||
(y + gw->scrolly) / gw->bw->scale);
|
||||
} else {
|
||||
browser_window_mouse_drag_end(gw->bw,
|
||||
0,
|
||||
(x + gw->scrollx) / gw->bw->scale,
|
||||
(y + gw->scrolly) / gw->bw->scale);
|
||||
}
|
||||
|
||||
gw->mouse->state = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle mouse button down messages.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_mousedown(struct gui_window *gw,
|
||||
int x, int y,
|
||||
browser_mouse_state button)
|
||||
{
|
||||
if ((gw == NULL) ||
|
||||
(gw->mouse == NULL) ||
|
||||
(gw->bw == NULL)) {
|
||||
nsws_localhistory_close(gw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
gw->mouse->state = button;
|
||||
if ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000)
|
||||
gw->mouse->state |= BROWSER_MOUSE_MOD_1;
|
||||
if ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000)
|
||||
gw->mouse->state |= BROWSER_MOUSE_MOD_2;
|
||||
if ((GetKeyState(VK_MENU) & 0x8000) == 0x8000)
|
||||
gw->mouse->state |= BROWSER_MOUSE_MOD_3;
|
||||
|
||||
gw->mouse->pressed_x = (x + gw->scrollx) / gw->bw->scale;
|
||||
gw->mouse->pressed_y = (y + gw->scrolly) / gw->bw->scale;
|
||||
|
||||
LOG(("mouse click bw %p, state %x, x %f, y %f", gw->bw,
|
||||
gw->mouse->state,
|
||||
(x + gw->scrollx) / gw->bw->scale,
|
||||
(y + gw->scrolly) / gw->bw->scale));
|
||||
|
||||
browser_window_mouse_click(gw->bw, gw->mouse->state,
|
||||
(x + gw->scrollx) / gw->bw->scale ,
|
||||
(y + gw->scrolly) / gw->bw->scale);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle mouse movement messages.
|
||||
*/
|
||||
static LRESULT
|
||||
nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
|
||||
{
|
||||
bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
|
||||
bool ctrl = ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000);
|
||||
bool alt = ((GetKeyState(VK_MENU) & 0x8000) == 0x8000);
|
||||
|
||||
if ((gw == NULL) || (gw->mouse == NULL) || (gw->bw == NULL))
|
||||
return 0;
|
||||
|
||||
/* scale co-ordinates */
|
||||
x = (x + gw->scrollx) / gw->bw->scale;
|
||||
y = (y + gw->scrolly) / gw->bw->scale;
|
||||
|
||||
/* if mouse button held down and pointer moved more than
|
||||
* minimum distance drag is happening */
|
||||
if (((gw->mouse->state & (BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_PRESS_2)) != 0) &&
|
||||
(abs(x - gw->mouse->pressed_x) >= 5) &&
|
||||
(abs(y - gw->mouse->pressed_y) >= 5)) {
|
||||
|
||||
LOG(("Drag start state 0x%x", gw->mouse->state));
|
||||
|
||||
if ((gw->mouse->state & BROWSER_MOUSE_PRESS_1) != 0) {
|
||||
browser_window_mouse_click(gw->bw, BROWSER_MOUSE_DRAG_1,
|
||||
gw->mouse->pressed_x,
|
||||
gw->mouse->pressed_y);
|
||||
gw->mouse->state &= ~BROWSER_MOUSE_PRESS_1;
|
||||
gw->mouse->state |= BROWSER_MOUSE_HOLDING_1 |
|
||||
BROWSER_MOUSE_DRAG_ON;
|
||||
}
|
||||
else if ((gw->mouse->state & BROWSER_MOUSE_PRESS_2) != 0) {
|
||||
browser_window_mouse_click(gw->bw, BROWSER_MOUSE_DRAG_2,
|
||||
gw->mouse->pressed_x,
|
||||
gw->mouse->pressed_y);
|
||||
gw->mouse->state &= ~BROWSER_MOUSE_PRESS_2;
|
||||
gw->mouse->state |= BROWSER_MOUSE_HOLDING_2 |
|
||||
BROWSER_MOUSE_DRAG_ON;
|
||||
}
|
||||
}
|
||||
|
||||
if (((gw->mouse->state & BROWSER_MOUSE_MOD_1) != 0) && !shift)
|
||||
gw->mouse->state &= ~BROWSER_MOUSE_MOD_1;
|
||||
if (((gw->mouse->state & BROWSER_MOUSE_MOD_2) != 0) && !ctrl)
|
||||
gw->mouse->state &= ~BROWSER_MOUSE_MOD_2;
|
||||
if (((gw->mouse->state & BROWSER_MOUSE_MOD_3) != 0) && !alt)
|
||||
gw->mouse->state &= ~BROWSER_MOUSE_MOD_3;
|
||||
|
||||
|
||||
browser_window_mouse_track(gw->bw, gw->mouse->state, x, y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when activity occours within the drawable window.
|
||||
*/
|
||||
static LRESULT CALLBACK
|
||||
nsws_window_drawable_event_callback(HWND hwnd,
|
||||
UINT msg,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
{
|
||||
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_MOUSEMOVE:
|
||||
return nsws_drawable_mousemove(gw,
|
||||
GET_X_LPARAM(lparam),
|
||||
GET_Y_LPARAM(lparam));
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
nsws_drawable_mousedown(gw,
|
||||
GET_X_LPARAM(lparam),
|
||||
GET_Y_LPARAM(lparam),
|
||||
BROWSER_MOUSE_PRESS_1);
|
||||
SetFocus(hwnd);
|
||||
nsws_localhistory_close(gw);
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
nsws_drawable_mousedown(gw,
|
||||
GET_X_LPARAM(lparam),
|
||||
GET_Y_LPARAM(lparam),
|
||||
BROWSER_MOUSE_PRESS_2);
|
||||
SetFocus(hwnd);
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
return nsws_drawable_mouseup(gw,
|
||||
GET_X_LPARAM(lparam),
|
||||
GET_Y_LPARAM(lparam),
|
||||
BROWSER_MOUSE_PRESS_1,
|
||||
BROWSER_MOUSE_CLICK_1);
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
return nsws_drawable_mouseup(gw,
|
||||
GET_X_LPARAM(lparam),
|
||||
GET_Y_LPARAM(lparam),
|
||||
BROWSER_MOUSE_PRESS_2,
|
||||
BROWSER_MOUSE_CLICK_2);
|
||||
|
||||
case WM_ERASEBKGND: /* ignore as drawable window is redrawn on paint */
|
||||
return 0;
|
||||
|
||||
case WM_PAINT: /* redraw the exposed part of the window */
|
||||
return nsws_drawable_paint(gw, hwnd);
|
||||
|
||||
case WM_KEYDOWN:
|
||||
return nsws_drawable_key(gw, hwnd, wparam);
|
||||
|
||||
case WM_SIZE:
|
||||
return nsws_drawable_resize(gw);
|
||||
|
||||
case WM_HSCROLL:
|
||||
return nsws_drawable_hscroll(gw, hwnd, wparam);
|
||||
|
||||
case WM_VSCROLL:
|
||||
return nsws_drawable_vscroll(gw, hwnd, wparam);
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
return nsws_drawable_wheel(gw, hwnd, wparam);
|
||||
|
||||
}
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a drawable window.
|
||||
*/
|
||||
HWND
|
||||
nsws_window_create_drawable(HINSTANCE hinstance,
|
||||
HWND hparent,
|
||||
struct gui_window *gw)
|
||||
{
|
||||
HWND hwnd;
|
||||
hwnd = CreateWindow(windowclassname_drawable,
|
||||
NULL,
|
||||
WS_VISIBLE | WS_CHILD,
|
||||
0, 0, 0, 0,
|
||||
hparent,
|
||||
NULL,
|
||||
hinstance,
|
||||
NULL);
|
||||
|
||||
if (hwnd == NULL) {
|
||||
win_perror("WindowCreateDrawable");
|
||||
LOG(("Window creation failed"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* set the gui window associated with this toolbar */
|
||||
SetProp(hwnd, TEXT("GuiWnd"), (HANDLE)gw);
|
||||
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the drawable window class.
|
||||
*/
|
||||
nserror
|
||||
nsws_create_drawable_class(HINSTANCE hinstance) {
|
||||
nserror ret = NSERROR_OK;
|
||||
WNDCLASSEX w;
|
||||
|
||||
/* drawable area */
|
||||
w.cbSize = sizeof(WNDCLASSEX);
|
||||
w.style = 0;
|
||||
w.lpfnWndProc = nsws_window_drawable_event_callback;
|
||||
w.cbClsExtra = 0;
|
||||
w.cbWndExtra = 0;
|
||||
w.hInstance = hinstance;
|
||||
w.hIcon = NULL;
|
||||
w.hCursor = NULL;
|
||||
w.hbrBackground = (HBRUSH)(COLOR_MENU + 1);
|
||||
w.lpszMenuName = NULL;
|
||||
w.lpszClassName = windowclassname_drawable;
|
||||
w.hIconSm = NULL;
|
||||
|
||||
if (RegisterClassEx(&w) == 0) {
|
||||
win_perror("DrawableClass");
|
||||
ret = NSERROR_INIT_FAILED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
25
windows/drawable.h
Normal file
25
windows/drawable.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2011 Vincent Sanders <vince@simtec.co.uk>
|
||||
*
|
||||
* 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_DRAWABLE_H_
|
||||
#define _NETSURF_WINDOWS_DRAWABLE_H_
|
||||
|
||||
nserror nsws_create_drawable_class(HINSTANCE hinstance);
|
||||
HWND nsws_window_create_drawable(HINSTANCE hinstance, HWND hparent, struct gui_window *gw);
|
||||
|
||||
#endif /* _NETSURF_WINDOWS_DRAWABLE_H_ */
|
905
windows/gui.c
905
windows/gui.c
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,7 @@
|
||||
#include "desktop/gui.h"
|
||||
#include "windows/localhistory.h"
|
||||
|
||||
extern HINSTANCE hinstance;
|
||||
extern HINSTANCE hInstance;
|
||||
|
||||
/* bounding box */
|
||||
typedef struct bbox_s {
|
||||
@ -50,15 +50,6 @@ struct nsws_pointers {
|
||||
HCURSOR arrow;
|
||||
};
|
||||
|
||||
struct browser_mouse {
|
||||
struct gui_window *gui;
|
||||
struct box *box;
|
||||
|
||||
double pressed_x;
|
||||
double pressed_y;
|
||||
bool waiting;
|
||||
browser_mouse_state state;
|
||||
};
|
||||
|
||||
extern struct gui_window *window_list;
|
||||
extern char *options_file_location;
|
||||
@ -84,8 +75,12 @@ int gui_window_scrollingy(struct gui_window *w);
|
||||
|
||||
struct gui_window *gui_window_iterate(struct gui_window *);
|
||||
struct browser_window *gui_window_browser_window(struct gui_window *);
|
||||
|
||||
struct nsws_pointers *nsws_get_pointers(void);
|
||||
HICON nsws_window_get_ico(bool);
|
||||
|
||||
void nsws_window_init_pointers(HINSTANCE hinstance);
|
||||
|
||||
nserror nsws_create_main_class(HINSTANCE hinstance);
|
||||
|
||||
/**
|
||||
* Cause a browser window to navigate to a url
|
||||
|
@ -26,63 +26,328 @@
|
||||
#include "utils/utils.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"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
static const char windowclassname_localhistory[] = "nswslocalhistorywindow";
|
||||
|
||||
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 */
|
||||
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 */
|
||||
};
|
||||
|
||||
static struct nsws_localhistory localhistory;
|
||||
|
||||
LRESULT CALLBACK nsws_localhistory_event_callback(HWND hwnd, UINT msg,
|
||||
WPARAM wparam, LPARAM lparam);
|
||||
static void nsws_localhistory_scroll_check(struct gui_window *w);
|
||||
static void nsws_localhistory_clear(struct gui_window *w);
|
||||
|
||||
void nsws_localhistory_init(struct gui_window *w)
|
||||
static void nsws_localhistory_scroll_check(struct nsws_localhistory *l, struct gui_window *gw)
|
||||
{
|
||||
LOG(("gui window %p", w));
|
||||
static const char localhistorywindowclassname[] = "nsws_localhistory_window";
|
||||
WNDCLASSEX we;
|
||||
HWND mainhwnd = gui_window_main_window(w);
|
||||
SCROLLINFO si;
|
||||
|
||||
if ((gw->bw == NULL) || (l->hwnd == NULL))
|
||||
return;
|
||||
|
||||
history_size(gw->bw->history, &(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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void nsws_localhistory_up(struct nsws_localhistory *l, struct gui_window *gw)
|
||||
{
|
||||
HDC tmp_hdc;
|
||||
|
||||
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);
|
||||
|
||||
history_redraw(gw->bw->history);
|
||||
|
||||
ReleaseDC(l->hwnd, plot_hdc);
|
||||
|
||||
plot_hdc = tmp_hdc;
|
||||
}
|
||||
|
||||
nsws_localhistory_scroll_check(l, gw);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void history_gui_set_pointer(gui_pointer_shape shape, void *p)
|
||||
{
|
||||
struct nsws_pointers *pointers = nsws_get_pointers();
|
||||
if (pointers == NULL)
|
||||
return;
|
||||
switch(shape) {
|
||||
case GUI_POINTER_POINT:
|
||||
SetCursor(pointers->hand);
|
||||
break;
|
||||
default:
|
||||
SetCursor(pointers->arrow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void nsws_localhistory_close(struct gui_window *w)
|
||||
{
|
||||
struct nsws_localhistory *l = gui_window_localhistory(w);
|
||||
if (l != NULL)
|
||||
CloseWindow(l->hwnd);
|
||||
}
|
||||
|
||||
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 (history_click(gw->bw,
|
||||
gw->bw->history,
|
||||
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);
|
||||
/* if (gw->bw != NULL)
|
||||
history_hover(gw->bw->history, x, y, (void *)hwnd);*/
|
||||
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;
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
if (gw->bw != NULL) {
|
||||
/* set global HDC for the plotters */
|
||||
tmp_hdc = plot_hdc;
|
||||
plot_hdc = hdc;
|
||||
|
||||
history_redraw_rectangle(gw->bw->history,
|
||||
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);
|
||||
|
||||
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;
|
||||
HICON hIcon = nsws_window_get_ico(true);
|
||||
HICON hIconS = nsws_window_get_ico(false);
|
||||
struct browser_window *bw = gui_window_browser_window(w);
|
||||
int margin = 50;
|
||||
RECT r;
|
||||
|
||||
localhistory.width = 0;
|
||||
localhistory.height = 0;
|
||||
|
||||
if ((bw != NULL) && (bw->history != NULL))
|
||||
history_size(bw->history, &(localhistory.width),
|
||||
&(localhistory.height));
|
||||
|
||||
GetWindowRect(mainhwnd, &r);
|
||||
SetWindowPos(mainhwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOSIZE | SWP_NOMOVE);
|
||||
LOG(("gui window %p", gw));
|
||||
|
||||
localhistory.guiwidth = MIN(r.right - r.left - margin,
|
||||
localhistory.width + margin);
|
||||
localhistory.guiheight = MIN(r.bottom - r.top - margin,
|
||||
localhistory.height + margin);
|
||||
/* 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) && (gw->bw->history != NULL)) {
|
||||
history_size(gw->bw->history,
|
||||
&(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;
|
||||
@ -90,313 +355,58 @@ void nsws_localhistory_init(struct gui_window *w)
|
||||
icc.dwICC |= ICC_STANDARD_CLASSES;
|
||||
#endif
|
||||
InitCommonControlsEx(&icc);
|
||||
|
||||
we.cbSize = sizeof(WNDCLASSEX);
|
||||
we.style = 0;
|
||||
we.lpfnWndProc = nsws_localhistory_event_callback;
|
||||
we.cbClsExtra = 0;
|
||||
we.cbWndExtra = 0;
|
||||
we.hInstance = hinstance;
|
||||
we.hIcon = (hIcon == NULL) ?
|
||||
LoadIcon(NULL, IDI_APPLICATION) : hIcon;
|
||||
we.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
we.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
we.lpszMenuName = NULL;
|
||||
we.lpszClassName = localhistorywindowclassname;
|
||||
we.hIconSm = (hIconS == NULL) ?
|
||||
LoadIcon(NULL, IDI_APPLICATION) : hIconS;
|
||||
RegisterClassEx(&we);
|
||||
LOG(("creating local history window for hInstance %p", hinstance));
|
||||
localhistory.hwnd = CreateWindow(localhistorywindowclassname,
|
||||
"NetSurf History",WS_THICKFRAME | WS_HSCROLL |
|
||||
WS_VSCROLL | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
|
||||
CS_DBLCLKS, r.left + margin/2, r.top + margin/2,
|
||||
localhistory.guiwidth, localhistory.guiheight, NULL,
|
||||
NULL, hinstance, NULL);
|
||||
LOG(("gui_window %p width %d height %d hwnd %p", w,
|
||||
localhistory.guiwidth, localhistory.guiheight,
|
||||
localhistory.hwnd));
|
||||
|
||||
ShowWindow(localhistory.hwnd, SW_SHOWNORMAL);
|
||||
UpdateWindow(localhistory.hwnd);
|
||||
gui_window_set_localhistory(w, &localhistory);
|
||||
nsws_localhistory_up(w);
|
||||
|
||||
LOG(("creating local history window for hInstance %p", hInstance));
|
||||
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, hInstance, 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;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK nsws_localhistory_event_callback(HWND hwnd, UINT msg,
|
||||
WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
bool match = false;
|
||||
struct gui_window *w = window_list;
|
||||
struct browser_window *bw = NULL;
|
||||
struct nsws_localhistory *local;
|
||||
while (w != NULL) {
|
||||
local = gui_window_localhistory(w);
|
||||
if ((local != NULL) && (local->hwnd == hwnd)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
w = gui_window_iterate(w);
|
||||
/* 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;
|
||||
}
|
||||
if (match)
|
||||
bw = gui_window_browser_window(w);
|
||||
|
||||
switch(msg) {
|
||||
case WM_CREATE:
|
||||
nsws_localhistory_scroll_check(w);
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
localhistory.guiheight = HIWORD(lparam);
|
||||
localhistory.guiwidth = LOWORD(lparam);
|
||||
nsws_localhistory_scroll_check(w);
|
||||
/* current_hwnd = hwnd;
|
||||
plot.rectangle(0, 0, localhistory.guiwidth,
|
||||
localhistory.guiheight, plot_style_fill_white);
|
||||
*/ break;
|
||||
|
||||
/* case WM_MOVE: {
|
||||
RECT r, rmain;
|
||||
if (w != NULL) {
|
||||
current_hwnd = gui_window_main_window(w);
|
||||
GetWindowRect(hwnd, &r);
|
||||
GetWindowRect(current_hwnd, &rmain);
|
||||
gui_window_redraw(w,
|
||||
MIN(r.top - rmain.top , 0),
|
||||
MIN(r.left - rmain.left, 0),
|
||||
gui_window_height(w) -
|
||||
MIN(rmain.bottom - r.bottom, 0),
|
||||
gui_window_width(w) -
|
||||
MIN(rmain.right - r.right, 0));
|
||||
current_hwnd = hwnd;
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
}
|
||||
*/ case WM_LBUTTONUP: {
|
||||
int x,y;
|
||||
x = GET_X_LPARAM(lparam);
|
||||
y = GET_Y_LPARAM(lparam);
|
||||
if (bw == NULL)
|
||||
break;
|
||||
|
||||
if ((bw != NULL) &&
|
||||
(history_click(bw,
|
||||
bw->history,
|
||||
localhistory.hscroll + x,
|
||||
localhistory.vscroll + y,
|
||||
false))) {
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
}
|
||||
case WM_MOUSEMOVE: {
|
||||
int x,y;
|
||||
x = GET_X_LPARAM(lparam);
|
||||
y = GET_Y_LPARAM(lparam);
|
||||
/* if (bw != NULL)
|
||||
history_hover(bw->history, x, y, (void *)hwnd);*/
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
break;
|
||||
}
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
if ((w == NULL) || (bw == NULL))
|
||||
break;
|
||||
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 -= localhistory.guiheight;
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
si.nPos += localhistory.guiheight;
|
||||
break;
|
||||
case SB_THUMBTRACK:
|
||||
si.nPos = si.nTrackPos;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
si.nPos = MIN(si.nPos, localhistory.height);
|
||||
si.nPos = MAX(si.nPos, 0);
|
||||
si.fMask = SIF_POS;
|
||||
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
|
||||
GetScrollInfo(hwnd, SB_VERT, &si);
|
||||
if (si.nPos != mem) {
|
||||
localhistory.vscroll += si.nPos - mem;
|
||||
ScrollWindowEx(hwnd, 0, -(si.nPos - mem), NULL, NULL, NULL, NULL, SW_ERASE | SW_INVALIDATE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_HSCROLL:
|
||||
{
|
||||
if ((w == NULL) || (bw == NULL))
|
||||
break;
|
||||
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 -= localhistory.guiwidth;
|
||||
break;
|
||||
case SB_PAGERIGHT:
|
||||
si.nPos += localhistory.guiwidth;
|
||||
break;
|
||||
case SB_THUMBTRACK:
|
||||
si.nPos = si.nTrackPos;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
si.nPos = MIN(si.nPos, 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) {
|
||||
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;
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
if (bw != NULL) {
|
||||
/* set global HDC for the plotters */
|
||||
tmp_hdc = plot_hdc;
|
||||
plot_hdc = hdc;
|
||||
|
||||
history_redraw_rectangle(bw->history,
|
||||
localhistory.hscroll + ps.rcPaint.left,
|
||||
localhistory.vscroll + ps.rcPaint.top,
|
||||
localhistory.hscroll + (ps.rcPaint.right - ps.rcPaint.left),
|
||||
localhistory.vscroll + (ps.rcPaint.bottom - ps.rcPaint.top),
|
||||
ps.rcPaint.left,
|
||||
ps.rcPaint.top);
|
||||
|
||||
plot_hdc = tmp_hdc;
|
||||
|
||||
}
|
||||
EndPaint(hwnd, &ps);
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
nsws_localhistory_clear(w);
|
||||
DestroyWindow(hwnd);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
nsws_localhistory_clear(w);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void nsws_localhistory_up(struct gui_window *w)
|
||||
{
|
||||
LOG(("gui window %p", w));
|
||||
HDC hdc = GetDC(NULL);
|
||||
struct browser_window *bw = gui_window_browser_window(w);
|
||||
|
||||
localhistory.vscroll = 0;
|
||||
localhistory.hscroll = 0;
|
||||
|
||||
if (bw != NULL)
|
||||
history_redraw(bw->history);
|
||||
|
||||
nsws_localhistory_scroll_check(w);
|
||||
|
||||
ReleaseDC(localhistory.hwnd, hdc);
|
||||
}
|
||||
|
||||
void nsws_localhistory_scroll_check(struct gui_window *w)
|
||||
{
|
||||
if (w == NULL)
|
||||
return;
|
||||
struct browser_window *bw = gui_window_browser_window(w);
|
||||
if ((bw == NULL) || (localhistory.hwnd == NULL))
|
||||
return;
|
||||
history_size(bw->history, &(localhistory.width), &(localhistory.height));
|
||||
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_ALL;
|
||||
si.nMin = 0;
|
||||
si.nMax = localhistory.height;
|
||||
si.nPage = localhistory.guiheight;
|
||||
si.nPos = 0;
|
||||
SetScrollInfo(localhistory.hwnd, SB_VERT, &si, TRUE);
|
||||
|
||||
si.nMax = localhistory.width;
|
||||
si.nPage = localhistory.guiwidth;
|
||||
SetScrollInfo(localhistory.hwnd, SB_HORZ, &si, TRUE);
|
||||
if (localhistory.guiheight >= localhistory.height)
|
||||
localhistory.vscroll = 0;
|
||||
if (localhistory.guiwidth >= localhistory.width)
|
||||
localhistory.hscroll = 0;
|
||||
SendMessage(localhistory.hwnd, WM_PAINT, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
void history_gui_set_pointer(gui_pointer_shape shape, void *p)
|
||||
{
|
||||
struct nsws_pointers *pointers = nsws_get_pointers();
|
||||
if (pointers == NULL)
|
||||
return;
|
||||
switch(shape) {
|
||||
case GUI_POINTER_POINT:
|
||||
SetCursor(pointers->hand);
|
||||
break;
|
||||
default:
|
||||
SetCursor(pointers->arrow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void nsws_localhistory_close(struct gui_window *w)
|
||||
{
|
||||
struct nsws_localhistory *l = gui_window_localhistory(w);
|
||||
if (l != NULL)
|
||||
DestroyWindow(l->hwnd);
|
||||
}
|
||||
|
||||
void nsws_localhistory_clear(struct gui_window *w)
|
||||
{
|
||||
if (w != NULL)
|
||||
gui_window_set_localhistory(w, NULL);
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,14 @@
|
||||
#ifndef _NETSURF_WINDOWS_LOCALHISTORY_H_
|
||||
#define _NETSURF_WINDOWS_LOCALHISTORY_H_
|
||||
|
||||
#include "desktop/browser.h"
|
||||
|
||||
struct nsws_localhistory;
|
||||
|
||||
void nsws_localhistory_init(struct gui_window *);
|
||||
void nsws_localhistory_up(struct gui_window *);
|
||||
void nsws_localhistory_close(struct gui_window *);
|
||||
void nsws_localhistory_open(struct gui_window *gw);
|
||||
void nsws_localhistory_close(struct gui_window *gw);
|
||||
|
||||
/* creates localhistory window */
|
||||
struct nsws_localhistory * nsws_window_create_localhistory(struct gui_window *gw);
|
||||
|
||||
nserror nsws_create_localhistory_class(HINSTANCE hinstance);
|
||||
|
||||
#endif
|
||||
|
163
windows/main.c
Normal file
163
windows/main.c
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright 2011 Vincent Sanders <vince@simtec.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/options.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/filepath.h"
|
||||
#include "content/fetchers/resource.h"
|
||||
|
||||
#include "windows/findfile.h"
|
||||
#include "windows/drawable.h"
|
||||
#include "windows/gui.h"
|
||||
|
||||
static char **respaths; /** resource search path vector. */
|
||||
|
||||
char *default_stylesheet_url;
|
||||
char *adblock_stylesheet_url;
|
||||
char *quirks_stylesheet_url;
|
||||
|
||||
char *options_file_location;
|
||||
|
||||
char* gui_get_resource_url(const char *filename)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
return path_to_url(filepath_sfind(respaths, buf, filename));
|
||||
}
|
||||
|
||||
void gui_launch_url(const char *url)
|
||||
{
|
||||
}
|
||||
|
||||
void gui_quit(void)
|
||||
{
|
||||
LOG(("gui_quit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures output stdio stream is available
|
||||
*/
|
||||
bool nslog_ensure(FILE *fptr)
|
||||
{
|
||||
/* mwindows compile flag normally invalidates standard io unless
|
||||
* already redirected
|
||||
*/
|
||||
if (_get_osfhandle(fileno(fptr)) == -1) {
|
||||
AllocConsole();
|
||||
freopen("CONOUT$", "w", fptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point from operating system
|
||||
**/
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
||||
{
|
||||
char **argv = NULL;
|
||||
int argc = 0, argctemp = 0;
|
||||
size_t len;
|
||||
LPWSTR *argvw;
|
||||
char *messages;
|
||||
nserror ret;
|
||||
struct browser_window *bw;
|
||||
const char *addr = NETSURF_HOMEPAGE;
|
||||
|
||||
if (SLEN(lpcli) > 0) {
|
||||
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
}
|
||||
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
/* Construct a unix style argc/argv */
|
||||
argv = malloc(sizeof(char *) * argc);
|
||||
while (argctemp < argc) {
|
||||
len = wcstombs(NULL, argvw[argctemp], 0) + 1;
|
||||
if (len > 0) {
|
||||
argv[argctemp] = malloc(len);
|
||||
}
|
||||
|
||||
if (argv[argctemp] != NULL) {
|
||||
wcstombs(argv[argctemp], argvw[argctemp], len);
|
||||
/* alter windows-style forward slash flags to
|
||||
* hyphen flags.
|
||||
*/
|
||||
if (argv[argctemp][0] == '/')
|
||||
argv[argctemp][0] = '-';
|
||||
}
|
||||
argctemp++;
|
||||
}
|
||||
|
||||
respaths = nsws_init_resource("${APPDATA}\\NetSurf:${HOME}\\.netsurf:${NETSURFRES}:${PROGRAMFILES}\\NetSurf\\res:"NETSURF_WINDOWS_RESPATH);
|
||||
|
||||
messages = filepath_find(respaths, "messages");
|
||||
|
||||
options_file_location = filepath_find(respaths, "preferences");
|
||||
|
||||
/* initialise netsurf */
|
||||
netsurf_init(&argc, &argv, options_file_location, messages);
|
||||
|
||||
free(messages);
|
||||
|
||||
/* set up stylesheet urls */
|
||||
default_stylesheet_url = strdup("resource:default.css");
|
||||
LOG(("Using '%s' as Default CSS URL", default_stylesheet_url));
|
||||
|
||||
quirks_stylesheet_url = strdup("resource:quirks.css");
|
||||
LOG(("Using '%s' as quirks CSS URL", quirks_stylesheet_url));
|
||||
|
||||
adblock_stylesheet_url = strdup("resource:adblock.css");
|
||||
LOG(("Using '%s' as AdBlock CSS URL", adblock_stylesheet_url));
|
||||
|
||||
ret = nsws_create_main_class(hInstance);
|
||||
ret = nsws_create_drawable_class(hInstance);
|
||||
ret = nsws_create_localhistory_class(hInstance);
|
||||
|
||||
option_target_blank = false;
|
||||
|
||||
nsws_window_init_pointers(hInstance);
|
||||
|
||||
/* ensure homepage option has a default */
|
||||
if (option_homepage_url == NULL || option_homepage_url[0] == '\0')
|
||||
option_homepage_url = strdup(NETSURF_HOMEPAGE);
|
||||
|
||||
/* If there is a url specified on the command line use it */
|
||||
if (argc > 1)
|
||||
addr = argv[1];
|
||||
else
|
||||
addr = option_homepage_url;
|
||||
|
||||
LOG(("calling browser_window_create"));
|
||||
bw = browser_window_create(addr, 0, 0, true, false);
|
||||
|
||||
netsurf_main_loop();
|
||||
|
||||
netsurf_exit();
|
||||
|
||||
free(options_file_location);
|
||||
|
||||
return 0;
|
||||
}
|
@ -35,27 +35,23 @@
|
||||
#include "windows/gui.h"
|
||||
#include "windows/plot.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* set NSWS_PLOT_DEBUG to 0 for no debugging, 1 for debugging */
|
||||
#define NSWS_PLOT_DEBUG 0
|
||||
/* #define NSWS_PLOT_DEBUG */
|
||||
|
||||
#ifdef NSWS_PLOT_DEBUG
|
||||
#define PLOT_LOG(x) LOG(x)
|
||||
#else
|
||||
#define PLOT_LOG(x)
|
||||
#endif
|
||||
|
||||
HDC plot_hdc;
|
||||
|
||||
|
||||
static RECT plot_clip; /* currently set clipping rectangle */
|
||||
|
||||
static bool clip(const struct rect *clip)
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("clip %d,%d to %d,%d", clip->x0, clip->y0, clip->x1, clip->y1));
|
||||
#endif
|
||||
PLOT_LOG(("clip %d,%d to %d,%d", clip->x0, clip->y0, clip->x1, clip->y1));
|
||||
|
||||
plot_clip.left = clip->x0;
|
||||
plot_clip.top = clip->y0;
|
||||
@ -67,9 +63,7 @@ static bool clip(const struct rect *clip)
|
||||
|
||||
static bool line(int x0, int y0, int x1, int y1, const plot_style_t *style)
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("from %d,%d to %d,%d", x0, y0, x1, y1));
|
||||
#endif
|
||||
PLOT_LOG(("from %d,%d to %d,%d", x0, y0, x1, y1));
|
||||
|
||||
/* ensure the plot HDC is set */
|
||||
if (plot_hdc == NULL) {
|
||||
@ -123,9 +117,7 @@ static bool line(int x0, int y0, int x1, int y1, const plot_style_t *style)
|
||||
|
||||
static bool rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("rectangle from %d,%d to %d,%d", x0, y0, x1, y1));
|
||||
#endif
|
||||
PLOT_LOG(("rectangle from %d,%d to %d,%d", x0, y0, x1, y1));
|
||||
|
||||
/* ensure the plot HDC is set */
|
||||
if (plot_hdc == NULL) {
|
||||
@ -192,9 +184,7 @@ static bool rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
|
||||
|
||||
static bool polygon(const int *p, unsigned int n, const plot_style_t *style)
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("polygon %d points", n));
|
||||
#endif
|
||||
PLOT_LOG(("polygon %d points", n));
|
||||
|
||||
/* ensure the plot HDC is set */
|
||||
if (plot_hdc == NULL) {
|
||||
@ -242,9 +232,7 @@ static bool polygon(const int *p, unsigned int n, const plot_style_t *style)
|
||||
points[i].x = (long) p[2 * i];
|
||||
points[i].y = (long) p[2 * i + 1];
|
||||
|
||||
#if NSWS_PLOT_DEBUG
|
||||
printf ("%ld,%ld ", points[i].x, points[i].y);
|
||||
#endif
|
||||
PLOT_LOG(("%ld,%ld ", points[i].x, points[i].y));
|
||||
}
|
||||
|
||||
SelectClipRgn(plot_hdc, clipregion);
|
||||
@ -260,9 +248,6 @@ static bool polygon(const int *p, unsigned int n, const plot_style_t *style)
|
||||
DeleteObject(pen);
|
||||
DeleteObject(brush);
|
||||
|
||||
#if NSWS_PLOT_DEBUG
|
||||
printf("\n");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -270,9 +255,7 @@ static bool polygon(const int *p, unsigned int n, const plot_style_t *style)
|
||||
static bool text(int x, int y, const char *text, size_t length,
|
||||
const plot_font_style_t *style)
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("words %s at %d,%d", text, x, y));
|
||||
#endif
|
||||
PLOT_LOG(("words %s at %d,%d", text, x, y));
|
||||
|
||||
/* ensure the plot HDC is set */
|
||||
if (plot_hdc == NULL) {
|
||||
@ -330,9 +313,7 @@ static bool text(int x, int y, const char *text, size_t length,
|
||||
|
||||
static bool disc(int x, int y, int radius, const plot_style_t *style)
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("disc at %d,%d radius %d", x, y, radius));
|
||||
#endif
|
||||
PLOT_LOG(("disc at %d,%d radius %d", x, y, radius));
|
||||
|
||||
/* ensure the plot HDC is set */
|
||||
if (plot_hdc == NULL) {
|
||||
@ -401,10 +382,8 @@ static bool disc(int x, int y, int radius, const plot_style_t *style)
|
||||
static bool arc(int x, int y, int radius, int angle1, int angle2,
|
||||
const plot_style_t *style)
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("arc centre %d,%d radius %d from %d to %d", x, y, radius,
|
||||
PLOT_LOG(("arc centre %d,%d radius %d from %d to %d", x, y, radius,
|
||||
angle1, angle2));
|
||||
#endif
|
||||
|
||||
/* ensure the plot HDC is set */
|
||||
if (plot_hdc == NULL) {
|
||||
@ -579,10 +558,8 @@ plot_alpha_bitmap(HDC hdc,
|
||||
BITMAPINFO *bmi;
|
||||
HBITMAP MemBMh;
|
||||
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("%p bitmap %d,%d width %d height %d", bitmap, x, y, width, height));
|
||||
LOG(("clipped %ld,%ld to %ld,%ld",plot_clip.left, plot_clip.top, plot_clip.right, plot_clip.bottom));
|
||||
#endif
|
||||
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) {
|
||||
@ -591,7 +568,7 @@ plot_alpha_bitmap(HDC hdc,
|
||||
|
||||
if ((bitmap->width != width) ||
|
||||
(bitmap->height != height)) {
|
||||
LOG(("scaling from %d,%d to %d,%d",
|
||||
PLOT_LOG(("scaling from %d,%d to %d,%d",
|
||||
bitmap->width, bitmap->height, width, height));
|
||||
bitmap = bitmap_scale(bitmap, width, height);
|
||||
if (bitmap == NULL)
|
||||
@ -751,7 +728,7 @@ plot_bitmap(struct bitmap *bitmap, int x, int y, int width, int height)
|
||||
bltres = plot_alpha_bitmap(plot_hdc, bitmap, x, y, width, height);
|
||||
}
|
||||
|
||||
/* LOG(("bltres = %d", bltres)); */
|
||||
PLOT_LOG(("bltres = %d", bltres));
|
||||
|
||||
DeleteObject(clipregion);
|
||||
|
||||
@ -771,7 +748,7 @@ windows_plot_bitmap(int x, int y,
|
||||
|
||||
/* Bail early if we can */
|
||||
|
||||
LOG(("Plotting %p at %d,%d by %d,%d",bitmap, x,y,width,height));
|
||||
PLOT_LOG(("Plotting %p at %d,%d by %d,%d",bitmap, x,y,width,height));
|
||||
|
||||
if (bitmap == NULL) {
|
||||
LOG(("Passed null bitmap!"));
|
||||
@ -827,10 +804,9 @@ windows_plot_bitmap(int x, int y,
|
||||
plot_clip.bottom);
|
||||
}
|
||||
}
|
||||
/*
|
||||
LOG(("Tiled plotting %d,%d by %d,%d",x,y,width,height));
|
||||
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)
|
||||
@ -840,9 +816,7 @@ windows_plot_bitmap(int x, int y,
|
||||
if (repeat_y)
|
||||
for (; y > plot_clip.top; y -= height);
|
||||
|
||||
/*
|
||||
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) {
|
||||
@ -861,18 +835,14 @@ windows_plot_bitmap(int x, int y,
|
||||
|
||||
static bool flush(void)
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("flush unimplemented"));
|
||||
#endif
|
||||
PLOT_LOG(("flush unimplemented"));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool path(const float *p, unsigned int n, colour fill, float width,
|
||||
colour c, const float transform[6])
|
||||
{
|
||||
#if NSWS_PLOT_DEBUG
|
||||
LOG(("path unimplemented"));
|
||||
#endif
|
||||
PLOT_LOG(("path unimplemented"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "utils/log.h"
|
||||
|
||||
const char *msg_num_to_name(int msg);
|
||||
void win_perror(const char * lpszFunction);
|
||||
void win_perror(const char *lpszFunction);
|
||||
|
||||
#define LOG_WIN_MSG(h, m, w, l) \
|
||||
if (((m) != WM_SETCURSOR) && \
|
||||
|
52
windows/window.c
Normal file
52
windows/window.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2011 Vincent Sanders <vince@simtec.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "windows/window.h"
|
||||
|
||||
/* documented in windows/window.h */
|
||||
struct gui_window *
|
||||
nsws_get_gui_window(HWND hwnd)
|
||||
{
|
||||
struct gui_window *gw = NULL;
|
||||
HWND phwnd = hwnd;
|
||||
|
||||
/* scan the window hierachy for gui window */
|
||||
while (phwnd != NULL) {
|
||||
gw = GetProp(phwnd, TEXT("GuiWnd"));
|
||||
if (gw != NULL)
|
||||
break;
|
||||
phwnd = GetParent(phwnd);
|
||||
}
|
||||
|
||||
if (gw == NULL) {
|
||||
/* try again looking for owner windows instead */
|
||||
phwnd = hwnd;
|
||||
while (phwnd != NULL) {
|
||||
gw = GetProp(phwnd, TEXT("GuiWnd"));
|
||||
if (gw != NULL)
|
||||
break;
|
||||
phwnd = GetWindow(phwnd, GW_OWNER);
|
||||
}
|
||||
}
|
||||
|
||||
return gw;
|
||||
}
|
83
windows/window.h
Normal file
83
windows/window.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2011 Vincent Sanders <vince@simtec.co.uk>
|
||||
*
|
||||
* 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_WINDOW_H_
|
||||
#define _NETSURF_WINDOWS_WINDOW_H_
|
||||
|
||||
#include "desktop/mouse.h"
|
||||
|
||||
struct browser_mouse {
|
||||
struct gui_window *gui;
|
||||
struct box *box;
|
||||
|
||||
double pressed_x;
|
||||
double pressed_y;
|
||||
bool waiting;
|
||||
browser_mouse_state state;
|
||||
};
|
||||
|
||||
struct gui_window {
|
||||
/* The front's private data connected to a browser window */
|
||||
/* currently 1<->1 gui_window<->windows window [non-tabbed] */
|
||||
struct browser_window *bw; /** the browser_window */
|
||||
|
||||
HWND main; /**< handle to the actual window */
|
||||
HWND toolbar; /**< toolbar handle */
|
||||
HWND urlbar; /**< url bar handle */
|
||||
HWND throbber; /** throbber handle */
|
||||
HWND drawingarea; /**< drawing area handle */
|
||||
HWND statusbar; /**< status bar handle */
|
||||
HWND vscroll; /**< vertical scrollbar handle */
|
||||
HWND hscroll; /**< horizontal scrollbar handle */
|
||||
|
||||
HMENU mainmenu; /**< the main menu */
|
||||
HMENU rclick; /**< the right-click menu */
|
||||
struct nsws_localhistory *localhistory; /**< handle to local history window */
|
||||
int width; /**< width of window */
|
||||
int height; /**< height of drawing area */
|
||||
|
||||
int toolbuttonc; /**< number of toolbar buttons */
|
||||
int toolbuttonsize; /**< width, height of buttons */
|
||||
bool throbbing; /**< whether currently throbbing */
|
||||
|
||||
struct browser_mouse *mouse; /**< mouse state */
|
||||
|
||||
HACCEL acceltable; /**< accelerators */
|
||||
|
||||
float scale; /**< scale of content */
|
||||
|
||||
int scrollx; /**< current scroll location */
|
||||
int scrolly; /**< current scroll location */
|
||||
|
||||
RECT *fullscreen; /**< memorize non-fullscreen area */
|
||||
RECT redraw; /**< Area needing redraw. */
|
||||
int requestscrollx, requestscrolly; /**< scolling requested. */
|
||||
struct gui_window *next, *prev; /**< global linked list */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Obtain gui window structure from window handle.
|
||||
*
|
||||
* \param hwnd The window handle.
|
||||
* \return The gui window associated with the window handle.
|
||||
*/
|
||||
struct gui_window *nsws_get_gui_window(HWND hwnd);
|
||||
|
||||
|
||||
#endif /* _NETSURF_WINDOWS_WINDOW_H_ */
|
Loading…
Reference in New Issue
Block a user