Fix windows url bar
Clean up toolbar and urlbar creation and subclassing svn path=/trunk/netsurf/; revision=10891
This commit is contained in:
parent
c052d534e7
commit
07c62407e2
|
@ -12,7 +12,7 @@ S_RENDER := box.c box_construct.c box_normalise.c favicon.c \
|
|||
font.c form.c html.c html_interaction.c html_redraw.c \
|
||||
hubbub_binding.c imagemap.c layout.c list.c table.c textplain.c
|
||||
S_UTILS := base64.c filename.c hashtable.c http.c locale.c messages.c \
|
||||
talloc.c url.c utf8.c utils.c useragent.c findresource.c
|
||||
talloc.c url.c utf8.c utils.c useragent.c findresource.c log.c
|
||||
S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \
|
||||
options.c plot_style.c print.c search.c searchweb.c scroll.c \
|
||||
sslcert.c textarea.c tree.c tree_url_node.c version.c \
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2007 Rob Kendrick <rjek@netsurf-browser.org>
|
||||
* Copyright 2004-2007 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
||||
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
* Copyright 2004 John Tytgat <joty@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/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include "desktop/netsurf.h"
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
static struct timeval start_tv;
|
||||
static char buff[32];
|
||||
|
||||
const char *nslog_gettime(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timeval now_tv;
|
||||
|
||||
if (!timerisset(&start_tv)) {
|
||||
gettimeofday(&start_tv, NULL);
|
||||
}
|
||||
gettimeofday(&now_tv, NULL);
|
||||
|
||||
timeval_subtract(&tv, &now_tv, &start_tv);
|
||||
|
||||
snprintf(buff, sizeof(buff),"(%ld.%ld)", tv.tv_sec, tv.tv_usec);
|
||||
return buff;
|
||||
}
|
11
utils/log.h
11
utils/log.h
|
@ -21,22 +21,13 @@
|
|||
#define _NETSURF_LOG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include "desktop/netsurf.h"
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define LOG(x) ((void) 0)
|
||||
#else
|
||||
|
||||
static inline const char *nslog_gettime(void)
|
||||
{
|
||||
static char buff[32];
|
||||
static struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
snprintf(buff, sizeof(buff),"(%ld.%ld)", tv.tv_sec, tv.tv_usec);
|
||||
return buff;
|
||||
}
|
||||
extern const char *nslog_gettime(void);
|
||||
|
||||
# ifdef __GNUC__
|
||||
# define LOG(x) do { if (verbose_log) (printf("%s " __FILE__ " %s %i: ", nslog_gettime(), __PRETTY_FUNCTION__, __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
||||
|
|
|
@ -283,6 +283,34 @@ unsigned int wallclock(void)
|
|||
return ((tv.tv_sec * 100) + (tv.tv_usec / 10000));
|
||||
}
|
||||
|
||||
/* Subtract the `struct timeval' values X and Y,
|
||||
storing the result in RESULT.
|
||||
Return 1 if the difference is negative, otherwise 0.
|
||||
*/
|
||||
|
||||
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
|
||||
{
|
||||
/* Perform the carry for the later subtraction by updating y. */
|
||||
if (x->tv_usec < y->tv_usec) {
|
||||
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
|
||||
y->tv_usec -= 1000000 * nsec;
|
||||
y->tv_sec += nsec;
|
||||
}
|
||||
if (x->tv_usec - y->tv_usec > 1000000) {
|
||||
int nsec = (x->tv_usec - y->tv_usec) / 1000000;
|
||||
y->tv_usec += 1000000 * nsec;
|
||||
y->tv_sec -= nsec;
|
||||
}
|
||||
|
||||
/* Compute the time remaining to wait.
|
||||
tv_usec is certainly positive. */
|
||||
result->tv_sec = x->tv_sec - y->tv_sec;
|
||||
result->tv_usec = x->tv_usec - y->tv_usec;
|
||||
|
||||
/* Return 1 if result is negative. */
|
||||
return x->tv_sec < y->tv_sec;
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <regex.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -105,6 +106,7 @@ void unicode_transliterate(unsigned int c, char **r);
|
|||
char *human_friendly_bytesize(unsigned long bytesize);
|
||||
const char *rfc1123_date(time_t t);
|
||||
unsigned int wallclock(void);
|
||||
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
|
||||
|
||||
/**
|
||||
* Return a hex digit for the given numerical value.
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "utils/url.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
|
365
windows/gui.c
365
windows/gui.c
|
@ -72,9 +72,6 @@ struct gui_window *search_current_window;
|
|||
struct gui_window *window_list = NULL;
|
||||
HWND font_hwnd;
|
||||
|
||||
FARPROC urlproc;
|
||||
WNDPROC toolproc;
|
||||
|
||||
static char default_page[] = "http://www.netsurf-browser.org/welcome/";
|
||||
static HICON hIcon, hIconS;
|
||||
static int open_windows = 0;
|
||||
|
@ -134,16 +131,7 @@ static struct nsws_pointers nsws_pointer;
|
|||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
NSWS_ID_TOOLBAR = 1111,
|
||||
NSWS_ID_URLBAR,
|
||||
NSWS_ID_THROBBER,
|
||||
NSWS_ID_DRAWINGAREA,
|
||||
NSWS_ID_STATUSBAR,
|
||||
NSWS_ID_LAUNCH_URL,
|
||||
} nsws_constants ;
|
||||
|
||||
LRESULT CALLBACK nsws_window_url_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
LRESULT CALLBACK nsws_window_urlbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
LRESULT CALLBACK nsws_window_toolbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
LRESULT CALLBACK nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
LRESULT CALLBACK nsws_window_drawable_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
|
@ -165,6 +153,7 @@ void gui_poll(bool active)
|
|||
TranslateMessage(&Msg);
|
||||
}
|
||||
*/
|
||||
TranslateMessage(&Msg);
|
||||
DispatchMessage(&Msg);
|
||||
}
|
||||
|
||||
|
@ -172,44 +161,6 @@ void gui_poll(bool active)
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* callback for url bar events
|
||||
*/
|
||||
LRESULT CALLBACK
|
||||
nsws_window_url_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
DWORD i, ii;
|
||||
SendMessage(hwnd, EM_GETSEL, (WPARAM)&i, (LPARAM)&ii);
|
||||
|
||||
if (msg == WM_PAINT) {
|
||||
SendMessage(hwnd, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
|
||||
SendMessage(hwnd, EM_SETSEL, (WPARAM)i, (LPARAM)ii);
|
||||
}
|
||||
return CallWindowProc((WNDPROC) urlproc, hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
/* calculate the dimensions of the url bar relative to the parent toolbar */
|
||||
static void
|
||||
urlbar_dimensions(HWND hWndParent,
|
||||
int toolbuttonsize,
|
||||
int buttonc,
|
||||
int *x,
|
||||
int *y,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
RECT rc;
|
||||
const int cy_edit = 24;
|
||||
|
||||
GetClientRect(hWndParent, &rc);
|
||||
*x = (toolbuttonsize + 2) * (buttonc + 1) + (NSWS_THROBBER_WIDTH>>1);
|
||||
*y = (((rc.bottom - rc.top) + 1) - cy_edit) >> 1;
|
||||
*width = ((rc.right - rc.left) + 1) - *x - (NSWS_THROBBER_WIDTH>>1) - NSWS_THROBBER_WIDTH;
|
||||
*height = cy_edit;
|
||||
}
|
||||
|
||||
/* obtain gui window structure from windows window handle */
|
||||
static struct gui_window *
|
||||
nsws_get_gui_window(HWND hwnd)
|
||||
|
@ -233,6 +184,7 @@ nsws_get_gui_window(HWND hwnd)
|
|||
while (gw != NULL) {
|
||||
if ((gw->main == hwnd) ||
|
||||
(gw->drawingarea == hwnd) ||
|
||||
(gw->urlbar == hwnd) ||
|
||||
(gw->toolbar == hwnd)) {
|
||||
break;
|
||||
}
|
||||
|
@ -243,6 +195,128 @@ nsws_get_gui_window(HWND hwnd)
|
|||
return gw;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* callback for url bar events
|
||||
*/
|
||||
LRESULT CALLBACK
|
||||
nsws_window_urlbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
struct gui_window *gw;
|
||||
WNDPROC urlproc;
|
||||
|
||||
gw = nsws_get_gui_window(hwnd);
|
||||
|
||||
LOG(("%s, hwnd %p, gw %p, wparam %d, lparam %ld",
|
||||
msg_num_to_name(msg), hwnd, gw, wparam, lparam));
|
||||
|
||||
/* override messages */
|
||||
switch (msg) {
|
||||
case WM_CHAR:
|
||||
if (wparam == 13) {
|
||||
SendMessage(gw->main, WM_COMMAND, NSWS_ID_LAUNCH_URL, 0);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/* remove properties if window is being destroyed */
|
||||
if (msg == WM_NCDESTROY) {
|
||||
RemoveProp(hwnd, TEXT("GuiWnd"));
|
||||
urlproc = (WNDPROC)RemoveProp(hwnd, TEXT("OrigMsgProc"));
|
||||
} else {
|
||||
urlproc = (WNDPROC)GetProp(hwnd, TEXT("OrigMsgProc"));
|
||||
}
|
||||
|
||||
if (urlproc == NULL) {
|
||||
/* the original toolbar procedure is not available */
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
/* chain to the next handler */
|
||||
return CallWindowProc(urlproc, hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
/* calculate the dimensions of the url bar relative to the parent toolbar */
|
||||
static void
|
||||
urlbar_dimensions(HWND hWndParent,
|
||||
int toolbuttonsize,
|
||||
int buttonc,
|
||||
int *x,
|
||||
int *y,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
RECT rc;
|
||||
const int cy_edit = 24;
|
||||
|
||||
GetClientRect(hWndParent, &rc);
|
||||
*x = (toolbuttonsize + 2) * (buttonc + 1) + (NSWS_THROBBER_WIDTH>>1);
|
||||
*y = (((rc.bottom - rc.top) + 1) - cy_edit) >> 1;
|
||||
*width = ((rc.right - rc.left) + 1) - *x - (NSWS_THROBBER_WIDTH>>1) - NSWS_THROBBER_WIDTH;
|
||||
*height = cy_edit;
|
||||
}
|
||||
|
||||
|
||||
static LRESULT
|
||||
nsws_window_toolbar_command(struct gui_window *gw,
|
||||
int notification_code,
|
||||
int identifier,
|
||||
HWND ctrl_window)
|
||||
{
|
||||
LOG(("notification_code %d identifier %d ctrl_window %p",
|
||||
notification_code, identifier, ctrl_window));
|
||||
|
||||
switch(identifier) {
|
||||
|
||||
case NSWS_ID_URLBAR:
|
||||
switch (notification_code) {
|
||||
case EN_CHANGE:
|
||||
LOG(("EN_CHANGE"));
|
||||
break;
|
||||
|
||||
case EN_ERRSPACE:
|
||||
LOG(("EN_ERRSPACE"));
|
||||
break;
|
||||
|
||||
case EN_HSCROLL:
|
||||
LOG(("EN_HSCROLL"));
|
||||
break;
|
||||
|
||||
case EN_KILLFOCUS:
|
||||
LOG(("EN_KILLFOCUS"));
|
||||
break;
|
||||
|
||||
case EN_MAXTEXT:
|
||||
LOG(("EN_MAXTEXT"));
|
||||
break;
|
||||
|
||||
case EN_SETFOCUS:
|
||||
LOG(("EN_SETFOCUS"));
|
||||
break;
|
||||
|
||||
case EN_UPDATE:
|
||||
LOG(("EN_UPDATE"));
|
||||
break;
|
||||
|
||||
case EN_VSCROLL:
|
||||
LOG(("EN_VSCROLL"));
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG(("Unknown notification_code"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1; /* unhandled */
|
||||
|
||||
}
|
||||
return 0; /* control message handled */
|
||||
}
|
||||
|
||||
/**
|
||||
* callback for toolbar events
|
||||
*/
|
||||
|
@ -251,9 +325,14 @@ nsws_window_toolbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|||
{
|
||||
struct gui_window *gw;
|
||||
int urlx, urly, urlwidth, urlheight;
|
||||
WNDPROC toolproc;
|
||||
|
||||
if (msg == WM_SIZE) {
|
||||
gw = nsws_get_gui_window(hwnd);
|
||||
gw = nsws_get_gui_window(hwnd);
|
||||
|
||||
LOG(("%s, hwnd %p, gw %p", msg_num_to_name(msg), hwnd, gw));
|
||||
|
||||
switch (msg) {
|
||||
case WM_SIZE:
|
||||
|
||||
urlbar_dimensions(hwnd,
|
||||
gw->toolbuttonsize,
|
||||
|
@ -272,11 +351,33 @@ nsws_window_toolbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|||
NSWS_THROBBER_WIDTH, NSWS_THROBBER_WIDTH,
|
||||
true);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (nsws_window_toolbar_command(gw,
|
||||
HIWORD(wparam),
|
||||
LOWORD(wparam),
|
||||
(HWND)lparam) == 0)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* remove properties if window is being destroyed */
|
||||
if (msg == WM_NCDESTROY) {
|
||||
RemoveProp(hwnd, TEXT("GuiWnd"));
|
||||
toolproc = (WNDPROC)RemoveProp(hwnd, TEXT("OrigMsgProc"));
|
||||
} else {
|
||||
toolproc = (WNDPROC)GetProp(hwnd, TEXT("OrigMsgProc"));
|
||||
}
|
||||
|
||||
if (toolproc == NULL) {
|
||||
/* the original toolbar procedure is not available */
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
/* chain to the next handler */
|
||||
return CallWindowProc(toolproc, hwnd, msg, wparam, lparam);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -459,7 +560,8 @@ static void nsws_window_set_ico(struct gui_window *w)
|
|||
/**
|
||||
* creation of throbber
|
||||
*/
|
||||
static void nsws_window_throbber_create(struct gui_window *w)
|
||||
static HWND
|
||||
nsws_window_throbber_create(struct gui_window *w)
|
||||
{
|
||||
HWND hwnd;
|
||||
char avi[PATH_MAX];
|
||||
|
@ -484,7 +586,7 @@ static void nsws_window_throbber_create(struct gui_window *w)
|
|||
else
|
||||
Animate_Seek(hwnd, 0);
|
||||
ShowWindow(hwnd, SW_SHOWNORMAL);
|
||||
w->throbber = hwnd;
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
static HIMAGELIST
|
||||
|
@ -503,8 +605,59 @@ nsws_set_imagelist(HWND hwnd, UINT msg, int resid, int bsize, int bcnt)
|
|||
return hImageList;
|
||||
}
|
||||
|
||||
/** create a urlbar and message handler
|
||||
*
|
||||
* Create an Edit control for enerting urls
|
||||
*/
|
||||
static HWND
|
||||
nsws_window_toolbar_create(struct gui_window *gw)
|
||||
nsws_window_urlbar_create(struct gui_window *gw, HWND hwndparent)
|
||||
{
|
||||
int urlx, urly, urlwidth, urlheight;
|
||||
HWND hwnd;
|
||||
WNDPROC urlproc;
|
||||
|
||||
urlbar_dimensions(hwndparent,
|
||||
gw->toolbuttonsize,
|
||||
gw->toolbuttonc,
|
||||
&urlx, &urly, &urlwidth, &urlheight);
|
||||
|
||||
/* Create the edit control */
|
||||
hwnd = CreateWindowEx(0L,
|
||||
TEXT("Edit"),
|
||||
NULL,
|
||||
WS_CHILD | WS_BORDER | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
|
||||
urlx,
|
||||
urly,
|
||||
urlwidth,
|
||||
urlheight,
|
||||
hwndparent,
|
||||
(HMENU)NSWS_ID_URLBAR,
|
||||
hinstance,
|
||||
0);
|
||||
|
||||
if (hwnd == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* set the gui window associated with this control */
|
||||
SetProp(hwnd, TEXT("GuiWnd"), (HANDLE)gw);
|
||||
|
||||
/* subclass the message handler */
|
||||
urlproc = (WNDPROC)SetWindowLongPtr(hwnd,
|
||||
GWLP_WNDPROC,
|
||||
(LONG_PTR)nsws_window_urlbar_callback);
|
||||
|
||||
/* save the real handler */
|
||||
SetProp(hwnd, TEXT("OrigMsgProc"), (HANDLE)urlproc);
|
||||
|
||||
LOG(("Created url bar hwnd %p", hwnd));
|
||||
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
/* create a toolbar add controls and message handler */
|
||||
static HWND
|
||||
nsws_window_toolbar_create(struct gui_window *gw, HWND hWndParent)
|
||||
{
|
||||
HWND hWndToolbar;
|
||||
/* Toolbar buttons */
|
||||
|
@ -515,9 +668,9 @@ nsws_window_toolbar_create(struct gui_window *gw)
|
|||
{3, NSWS_ID_NAV_RELOAD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
||||
{4, NSWS_ID_NAV_STOP, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
||||
};
|
||||
HWND hWndParent = gw->main;
|
||||
WNDPROC toolproc;
|
||||
|
||||
/* Create the toolbar child window. */
|
||||
/* Create the toolbar window and subclass its message handler. */
|
||||
hWndToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, "Toolbar",
|
||||
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT,
|
||||
0, 0, 0, 0,
|
||||
|
@ -527,6 +680,19 @@ nsws_window_toolbar_create(struct gui_window *gw)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* set the gui window associated with this toolbar */
|
||||
SetProp(hWndToolbar, TEXT("GuiWnd"), (HANDLE)gw);
|
||||
|
||||
/* subclass the message handler */
|
||||
toolproc = (WNDPROC)SetWindowLongPtr(hWndToolbar,
|
||||
GWLP_WNDPROC,
|
||||
(LONG_PTR)nsws_window_toolbar_callback);
|
||||
|
||||
/* save the real handler */
|
||||
SetProp(hWndToolbar, TEXT("OrigMsgProc"), (HANDLE)toolproc);
|
||||
|
||||
|
||||
|
||||
/* remember how many buttons are being created */
|
||||
gw->toolbuttonc = sizeof(tbButtons) / sizeof(TBBUTTON);
|
||||
|
||||
|
@ -543,36 +709,10 @@ nsws_window_toolbar_create(struct gui_window *gw)
|
|||
SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
|
||||
SendMessage(hWndToolbar, TB_ADDBUTTONS, (WPARAM)gw->toolbuttonc, (LPARAM)&tbButtons);
|
||||
|
||||
gw->urlbar = nsws_window_urlbar_create(gw, hWndToolbar);
|
||||
|
||||
int urlx, urly, urlwidth, urlheight;
|
||||
urlbar_dimensions(hWndToolbar, gw->toolbuttonsize, gw->toolbuttonc, &urlx, &urly, &urlwidth, &urlheight);
|
||||
gw->throbber = nsws_window_throbber_create(gw);
|
||||
|
||||
// Create the edit control child window.
|
||||
gw->urlbar = CreateWindowEx(0L, "Edit", NULL,
|
||||
WS_CHILD | WS_BORDER | WS_VISIBLE | ES_LEFT
|
||||
| ES_AUTOVSCROLL | ES_MULTILINE,
|
||||
urlx,
|
||||
urly,
|
||||
urlwidth,
|
||||
urlheight,
|
||||
hWndToolbar,
|
||||
(HMENU)NSWS_ID_URLBAR,
|
||||
hinstance, 0 );
|
||||
|
||||
if (!gw->urlbar) {
|
||||
DestroyWindow(hWndToolbar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsws_window_throbber_create(gw);
|
||||
|
||||
/* set the gui window associated with this toolbar */
|
||||
SetProp(hWndToolbar, TEXT("GuiWnd"), (HANDLE)gw);
|
||||
|
||||
/* subclass the message handler */
|
||||
toolproc = (WNDPROC)SetWindowLongPtr(hWndToolbar, GWLP_WNDPROC, (LONG_PTR)nsws_window_toolbar_callback);
|
||||
|
||||
/* Return the completed toolbar */
|
||||
return hWndToolbar;
|
||||
}
|
||||
|
||||
|
@ -1119,12 +1259,15 @@ nsws_window_resize(struct gui_window *w,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static LRESULT
|
||||
nsws_window_command(struct gui_window *gw,
|
||||
int notification_code,
|
||||
int identifier,
|
||||
HWND ctrl_window)
|
||||
{
|
||||
LOG(("notification_code %x identifier %x ctrl_window %p",
|
||||
notification_code, identifier, ctrl_window));
|
||||
|
||||
switch(identifier) {
|
||||
|
||||
|
@ -1133,10 +1276,9 @@ nsws_window_command(struct gui_window *gw,
|
|||
struct gui_window *w;
|
||||
w = window_list;
|
||||
while (w != NULL) {
|
||||
browser_window_destroy(w->bw);
|
||||
PostMessage(w->main, WM_CLOSE, 0, 0);
|
||||
w = w->next;
|
||||
}
|
||||
netsurf_quit = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1397,11 +1539,10 @@ nsws_window_command(struct gui_window *gw,
|
|||
break;
|
||||
}
|
||||
|
||||
case NSWS_ID_URLBAR:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
return 1; /* unhandled */
|
||||
|
||||
}
|
||||
return 0; /* control message handled */
|
||||
}
|
||||
|
@ -1412,8 +1553,6 @@ nsws_window_command(struct gui_window *gw,
|
|||
LRESULT CALLBACK
|
||||
nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
bool match = false;
|
||||
bool historyactive = false;
|
||||
struct gui_window *gw;
|
||||
|
||||
gw = nsws_get_gui_window(hwnd);
|
||||
|
@ -1450,27 +1589,28 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|||
case WM_ENTERMENULOOP:
|
||||
nsws_update_edit(w);
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
*/
|
||||
|
||||
case WM_CONTEXTMENU:
|
||||
if (!nsws_ctx_menu(w, hwnd, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)))
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
|
||||
if (nsws_ctx_menu(gw, hwnd, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
*/
|
||||
|
||||
case WM_COMMAND:
|
||||
return nsws_window_command(gw, HIWORD(wparam), LOWORD(wparam), (HWND)lparam);
|
||||
if (nsws_window_command(gw, HIWORD(wparam), LOWORD(wparam), (HWND)lparam) == 0)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
|
||||
case WM_SIZE:
|
||||
return nsws_window_resize(gw, hwnd, wparam, lparam);
|
||||
|
||||
case WM_CLOSE:
|
||||
case WM_NCDESTROY:
|
||||
RemoveProp(hwnd, TEXT("GuiWnd"));
|
||||
browser_window_destroy(gw->bw);
|
||||
if (--open_windows <= 0) {
|
||||
netsurf_quit = true;
|
||||
}
|
||||
browser_window_destroy(gw->bw);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -1627,7 +1767,7 @@ gui_create_browser_window(struct browser_window *bw,
|
|||
switch(bw->browser_window_type) {
|
||||
case BROWSER_WINDOW_NORMAL:
|
||||
gw->main = nsws_window_create(gw);
|
||||
gw->toolbar = nsws_window_toolbar_create(gw);
|
||||
gw->toolbar = nsws_window_toolbar_create(gw, gw->main);
|
||||
gw->statusbar = nsws_window_statusbar_create(gw);
|
||||
gw->drawingarea = CreateWindow(windowclassname_drawable,
|
||||
NULL,
|
||||
|
@ -1841,8 +1981,6 @@ void gui_window_destroy(struct gui_window *w)
|
|||
|
||||
DestroyAcceleratorTable(w->acceltable);
|
||||
|
||||
DestroyWindow(w->main);
|
||||
|
||||
free(w);
|
||||
w = NULL;
|
||||
}
|
||||
|
@ -2388,13 +2526,16 @@ static void gui_init(int argc, char** argv)
|
|||
{
|
||||
char buf[PATH_MAX], sbuf[PATH_MAX];
|
||||
int len;
|
||||
hubbub_error he;
|
||||
struct browser_window *bw;
|
||||
const char *addr = NETSURF_HOMEPAGE;
|
||||
|
||||
LOG(("argc %d, argv %p", argc, argv));
|
||||
|
||||
nsws_find_resource(buf, "Aliases", "./windows/res/Aliases");
|
||||
LOG(("Using '%s' as Aliases file", buf));
|
||||
|
||||
hubbub_error he = hubbub_initialise(buf, ns_realloc, NULL);
|
||||
he = hubbub_initialise(buf, ns_realloc, NULL);
|
||||
LOG(("hubbub init %d", he));
|
||||
if (he != HUBBUB_OK)
|
||||
die("Unable to initialise HTML parsing library.\n");
|
||||
|
@ -2419,13 +2560,6 @@ static void gui_init(int argc, char** argv)
|
|||
|
||||
option_target_blank = false;
|
||||
|
||||
}
|
||||
|
||||
static void gui_init2(int argc, char** argv)
|
||||
{
|
||||
struct browser_window *bw;
|
||||
const char *addr = NETSURF_HOMEPAGE;
|
||||
|
||||
nsws_window_init_pointers();
|
||||
LOG(("argc %d, argv %p", argc, argv));
|
||||
|
||||
|
@ -2439,6 +2573,7 @@ static void gui_init2(int argc, char** argv)
|
|||
|
||||
LOG(("calling browser_window_create"));
|
||||
bw = browser_window_create(addr, 0, 0, true, false);
|
||||
|
||||
}
|
||||
|
||||
void gui_stdout(void)
|
||||
|
@ -2458,7 +2593,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
|||
char **argv = NULL;
|
||||
int argc = 0, argctemp = 0;
|
||||
size_t len;
|
||||
LPWSTR * argvw;
|
||||
LPWSTR *argvw;
|
||||
char options[PATH_MAX];
|
||||
char messages[PATH_MAX];
|
||||
|
||||
|
@ -2500,8 +2635,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
|||
|
||||
gui_init(argc, argv);
|
||||
|
||||
gui_init2(argc, argv);
|
||||
|
||||
netsurf_main_loop();
|
||||
|
||||
netsurf_exit();
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#endif
|
||||
|
||||
/* set NSWS_PLOT_DEBUG to 0 for no debugging, 1 for debugging */
|
||||
#define NSWS_PLOT_DEBUG 1
|
||||
#define NSWS_PLOT_DEBUG 0
|
||||
|
||||
HDC plot_hdc;
|
||||
|
||||
|
|
|
@ -28,6 +28,14 @@
|
|||
#define NSWS_ID_TOOLBAR_BITMAP 107
|
||||
#define NSWS_ID_TOOLBAR_GREY_BITMAP 108
|
||||
#define NSWS_ID_TOOLBAR_HOT_BITMAP 109
|
||||
|
||||
#define NSWS_ID_TOOLBAR 1111
|
||||
#define NSWS_ID_URLBAR 1112
|
||||
#define NSWS_ID_THROBBER 1113
|
||||
#define NSWS_ID_DRAWINGAREA 1114
|
||||
#define NSWS_ID_STATUSBAR 1115
|
||||
#define NSWS_ID_LAUNCH_URL 1116
|
||||
|
||||
#define NSWS_ID_ABOUT_DIALOG 11111
|
||||
#define NSWS_ID_ABOUT_CONTENT 11112
|
||||
#define NSWS_ID_PREFS_DIALOG 11113
|
||||
|
|
Loading…
Reference in New Issue