r9958 tlsa - in /trunk/art/fonts/netsurf/tools: ./ convert.c
by netsurf@semichrome.net
Author: tlsa
Date: Sat Feb 6 16:37:27 2010
New Revision: 9958
URL: http://source.netsurf-browser.org?rev=9958&view=rev
Log:
Basic tool to convert the plain text font data to something useful for nsfb.
Added:
trunk/art/fonts/netsurf/tools/
trunk/art/fonts/netsurf/tools/convert.c
Added: trunk/art/fonts/netsurf/tools/convert.c
URL: http://source.netsurf-browser.org/trunk/art/fonts/netsurf/tools/convert.c...
==============================================================================
--- trunk/art/fonts/netsurf/tools/convert.c (added)
+++ trunk/art/fonts/netsurf/tools/convert.c Sat Feb 6 16:37:27 2010
@@ -1,0 +1,392 @@
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+enum font_style {
+ REGULAR = 0,
+ ITALIC = 1,
+ BOLD = 2,
+ ITALIC_BOLD = 3
+};
+
+struct glyph_offset {
+ int code;
+ long offset;
+};
+
+const int HEADER_MAX = 10000;
+
+int cp1252[256] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFD, 0x017D, 0xFFFD,
+ 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0xFFFD, 0x017E, 0x0178,
+ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF};
+
+
+// Convert a hex digit to a number. e.g. 'A' --> 10
+int get_hex_digit_value(char c)
+{
+ if (c >= '0' && c <= '9')
+ return (c - '0');
+ else if (c >= 'A' && c <= 'F')
+ return (10 + c - 'A');
+ else {
+ printf("Bad hex value\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
+
+// Convert Unicode codepoint to an int. e.g. "000F" --> 15
+int unicode_to_int(char* text)
+{
+ int result = 0;
+ int i;
+
+ for (i = 0; i < 4; i++)
+ result += get_hex_digit_value(text[i]) * pow(16, 3 - i);
+
+ return result;
+}
+
+
+// Numercical comparison function for qsort() and bsearch()
+int compare(const void *a, const void *b)
+{
+ return (*(int *)a - ((struct glyph_offset*)b)->code);
+}
+
+
+// Scan glyphs file for faults and populate table of glyph offsets
+bool prescan_glyphs(FILE *glyphs_file, struct glyph_offset **offsets, int *n)
+{
+ int count, c;
+ char code[5];
+ code[4] = '\0';
+ char p = '\0';
+ int previous = -1;
+
+ // Count glyphs in file
+ *n = 0;
+ c = fgetc(glyphs_file);
+ while (c != EOF) {
+ if (c == '+' && p == 'U') {
+ *n = *n + 1;
+ }
+ p = c;
+ c = fgetc(glyphs_file);
+ }
+
+ // Allocate space for offset table
+ *offsets = (struct glyph_offset*)
+ malloc(*n * sizeof(struct glyph_offset));
+ if (*offsets == NULL) {
+ printf("Couldn't allocate offsets memory.\n");
+ return false;
+ }
+
+ // Check glyphs in the file are in the correct order, and record
+ // offset to each glyph section
+ rewind(glyphs_file);
+ count = 0;
+ p = '\0';
+ c = fgetc(glyphs_file);
+ while (c != EOF) {
+ if (c == '+' && p == 'U') {
+ // Record offset to glyph entry
+ (*offsets)[count].offset = ftell(glyphs_file);
+ fread(code, 1, 4, glyphs_file);
+ if (previous >= unicode_to_int(code)) {
+ printf("Wrong order at: %s\n", code);
+ return false;
+ }
+ // Record which glyph it is
+ (*offsets)[count].code = unicode_to_int(code);
+ previous = unicode_to_int(code);
+ count++;
+ }
+ p = c;
+ c = fgetc(glyphs_file);
+ }
+
+ rewind(glyphs_file);
+
+ return true;
+}
+
+
+// Get a particular glyph from the glyphs file. Return true unless problem
+// encountered
+bool get_glyph(FILE *glyphs_file, char glyph_data[16][8], int n, int codepoint,
+ struct glyph_offset *offsets, enum font_style style)
+{
+ enum font_style output_style;
+ char code[5];
+ char buffer[16 * 45];
+ code[4] = '\0';
+ int c, i;
+ int x, y;
+ struct glyph_offset *glyph;
+ int count, position, start_pos;
+
+ bool italic = true;
+ bool bold = true;
+ bool italic_bold = true;
+
+ glyph = (struct glyph_offset*)bsearch(&codepoint, offsets, n,
+ sizeof(struct glyph_offset), compare);
+
+ if (glyph == NULL) {
+ // This codepoint isn't available in the glyph file.
+ return false;
+ }
+
+ // Move to the required glyph section in glyphs file
+ fseek(glyphs_file, glyph->offset, SEEK_SET);
+
+ // Check we're at the right place
+ fread(code, 1, 4, glyphs_file);
+ if (unicode_to_int(code) != glyph->code) {
+ printf("Error finding glyph %.4X, missmatches %s\n"
+ "Probably broken offset table.\n",
+ glyph->code, code);
+ exit(EXIT_FAILURE);
+ }
+
+ // Pass over rest of line
+ c = fgetc(glyphs_file);
+ while (c != EOF) {
+ if (c == '\n')
+ break;
+ c = fgetc(glyphs_file);
+ }
+
+ // Pass over separator line
+ fread(buffer, 1, 54, glyphs_file);
+ if (strncmp("- - - - - - - - - - - - - - - - - - - - - - - - - - -\n",
+ buffer, 54) != 0) {
+ printf("Glyph file formatting error around glyph U+%.4X\n",
+ glyph->code);
+ exit(EXIT_FAILURE);
+ }
+
+ // Read glyph data
+ fread(buffer, 1, 16 * 45, glyphs_file);
+
+ // Check glyph data formatting is valid and find which styles are
+ // present
+ count = 0;
+ while (buffer[count] != '\n') {
+ count++;
+ }
+ if (count != 11 && count != 22 && count != 33 && count != 44) {
+ printf("Glyph data formatting problem at glyph U+%.4X, "
+ "line 0\n"
+ "Possibly trailing whitespace.\n",
+ glyph->code);
+ exit(EXIT_FAILURE);
+ }
+
+ position = count;
+ for (i = 1; i < 16; i++) {
+ if (buffer[position] != '\n') {
+ printf("Glyph data formatting problem at glyph U+%.4X, "
+ "line %i\n"
+ "Possibly trailing whitespace.\n",
+ glyph->code, i);
+ exit(EXIT_FAILURE);
+ }
+ position += count + 1;
+ }
+ // TODO handle italic_bold available but not italic or bold
+ if (count < 44)
+ italic_bold = false;
+ if (count < 33)
+ bold = false;
+ if (count < 22)
+ italic = false;
+
+ // Set output_style depending on required style and style availability
+ switch (style) {
+ case REGULAR:
+ output_style = REGULAR;
+ break;
+ case ITALIC:
+ if (italic) {
+ output_style = ITALIC;
+ } else {
+ output_style = REGULAR;
+ printf("U+%.4X - Subst. regular for italic\n",
+ glyph->code);
+ }
+ break;
+ case BOLD:
+ if (bold) {
+ output_style = BOLD;
+ } else {
+ output_style = REGULAR;
+ printf("U+%.4X - Subst. regular for bold\n",
+ glyph->code);
+ }
+ break;
+ case ITALIC_BOLD:
+
+ if (italic_bold) {
+ output_style = ITALIC_BOLD;
+ } else if (italic) {
+ output_style = ITALIC;
+ printf("U+%.4X - Subst. italic for italic bold\n",
+ glyph->code);
+ } else {
+ output_style = REGULAR;
+ printf("U+%.4X - Subst. regular for italic bold\n",
+ glyph->code);
+ }
+ break;
+ default:
+ printf("Insane font style requested\n");
+ exit(EXIT_FAILURE);
+ }
+
+ // Populate output glyph data array with glyph
+ start_pos = 3 + output_style * (8 + 3);
+ for (y = 0; y < 16; y++) {
+ position = start_pos + (y * (count + 1));
+ for (x = 0; x < 8; x++) {
+ glyph_data[y][x] = buffer[position + x];
+ }
+ }
+
+ rewind(glyphs_file);
+ return true;
+}
+
+
+int main(int argc, char** argv)
+{
+ FILE *glyphs_file;
+ FILE *r_file, *i_file, *b_file, *ib_file;
+ char glyph_data[16][8];
+ struct glyph_offset *offsets;
+ int n, x, y, i;
+ int c, p = '\0';
+ char buffer[HEADER_MAX];
+
+ // Open glyph data file
+ if ((glyphs_file = fopen("BitmapFont", "r")) == NULL)
+ return EXIT_FAILURE;
+
+ // Scan glyphs file for problems and create table of pointers
+ // to each glyph's section in file
+ if (!prescan_glyphs(glyphs_file, &offsets, &n))
+ return EXIT_FAILURE;
+
+ /* Uncomment to print all available glyphs in the chosen style as text
+ // Go through the entire unicode range and print the glyph, if available
+ for (i = 0x0000; i <= 0xFFFF; i++) {
+ if (get_glyph(glyphs_file, glyph_data, n, i, offsets,
+ REGULAR)) {
+ printf("U+%.4X\n", i);
+ // Print glyph
+ for (y = 0; y < 16; y++) {
+ printf(" ");
+ for (x = 0; x < 8; x++) {
+ printf("%c", glyph_data[y][x]);
+ }
+ printf("\n");
+ }
+ printf("\n");
+ }
+ }
+ */
+
+ // Export CP1252 glyphs for framebuffer NetSurf
+ if ((r_file = fopen("r", "w")) == NULL)
+ return EXIT_FAILURE;
+
+ rewind(glyphs_file);
+ fread(buffer, 1, HEADER_MAX, glyphs_file);
+ i = 0;
+ while (i < HEADER_MAX - 1 && (buffer[i] != '\n' ||
+ (buffer[i+1] == '*' && buffer[i] == '\n'))) {
+ i++;
+ }
+ buffer[i + 1] = '\0';
+ fprintf(r_file, "/*\n%s */\n\n", buffer);
+
+ fprintf(r_file, "/* Don't edit this file, it was generated from the "
+ "plain text source data. */\n\n");
+
+ fprintf(r_file, "#include \"desktop/plotters.h\"\n"
+ "#include \"utils/utf8.h\"\n\n"
+ "#include \"framebuffer/font_internal.h\"\n\n"
+ "#define FONTDATAMAX 4096\n\n"
+ "static const uint32_t "
+ "fontdata_regular[FONTDATAMAX] = {\n");
+
+ for (i = 0; i < 256; i++) {
+ if (!get_glyph(glyphs_file, glyph_data, n, cp1252[i], offsets,
+ REGULAR)) {
+ printf("Glyph U+%.4x\n", cp1252[i]);
+ return EXIT_FAILURE;
+ }
+ fprintf(r_file, "\t");
+ for (y = 0; y < 16; y++) {
+ c = 0;
+ for (x = 0; x < 8; x++) {
+ if (glyph_data[y][x] == '#') {
+ c += 1 << (7 - x);
+ }
+ }
+ if (y == 7)
+ fprintf(r_file, "0x%.2X,\n\t", c);
+ else
+ fprintf(r_file, "0x%.2X, ", c);
+ }
+ fprintf(r_file, "\n");
+ }
+
+ fprintf(r_file, "};\n\n"
+ "const struct fb_font_desc font_regular = {\n"
+ "\t.name = \"NetSurf Regular\",\n"
+ "\t.width = 8,\n"
+ "\t.height = 16,\n"
+ "\t.encoding = \"CP1252\",\n"
+ "\t.data = fontdata_regular,\n"
+ "};", buffer);
+
+ free(offsets);
+ fclose(glyphs_file);
+ fclose(r_file);
+
+ return EXIT_SUCCESS;
+}
12 years, 12 months
r9955 vince - in /trunk/netsurf/windows: gui.c res/resource.rc resourceid.h
by netsurf@semichrome.net
Author: vince
Date: Thu Feb 4 17:15:50 2010
New Revision: 9955
URL: http://source.netsurf-browser.org?rev=9955&view=rev
Log:
Fix high colour bitmap loading on toolbar
Modified:
trunk/netsurf/windows/gui.c
trunk/netsurf/windows/res/resource.rc
trunk/netsurf/windows/resourceid.h
Modified: trunk/netsurf/windows/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/gui.c?rev=9955&r1...
==============================================================================
--- trunk/netsurf/windows/gui.c (original)
+++ trunk/netsurf/windows/gui.c Thu Feb 4 17:15:50 2010
@@ -248,8 +248,8 @@
/**
* callback for url bar events
*/
-LRESULT CALLBACK nsws_window_url_callback(HWND hwnd, UINT msg, WPARAM wparam,
- LPARAM lparam)
+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);
@@ -547,14 +547,26 @@
w->throbber = hwnd;
}
+static HIMAGELIST
+nsws_set_imagelist(HWND hwnd, UINT msg, int resid, int bsize, int bcnt)
+{
+ HIMAGELIST hImageList;
+ HBITMAP hScrBM;
+
+ hImageList = ImageList_Create(bsize, bsize, ILC_COLOR24 |ILC_MASK, 0, bcnt);
+ hScrBM = LoadImage(hinstance, MAKEINTRESOURCE(resid),
+ IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
+ ImageList_AddMasked(hImageList, hScrBM, 0xcccccc);
+ DeleteObject(hScrBM);
+
+ SendMessage(hwnd, msg, (WPARAM)0, (LPARAM)hImageList);
+ return hImageList;
+}
static HWND
nsws_window_toolbar_create(struct gui_window *gw, HWND hWndParent)
{
HWND hWndToolbar;
- HIMAGELIST hImageList;
- HIMAGELIST hDisabledImageList;
- HIMAGELIST hHotImageList;
/* Toolbar buttons */
TBBUTTON tbButtons[] = {
{0, NSWS_ID_NAV_BACK, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
@@ -578,16 +590,13 @@
gw->toolbuttonc = sizeof(tbButtons) / sizeof(TBBUTTON);
/* Create the standard image list and assign to toolbar. */
- hImageList = ImageList_LoadImage(hinstance, MAKEINTRESOURCE(NSWS_ID_TOOLBAR_BITMAP), gw->toolbuttonsize, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
- SendMessage(hWndToolbar, TB_SETIMAGELIST, (WPARAM)0, (LPARAM)hImageList);
+ nsws_set_imagelist(hWndToolbar, TB_SETIMAGELIST, NSWS_ID_TOOLBAR_BITMAP, gw->toolbuttonsize, gw->toolbuttonc);
/* Create the disabled image list and assign to toolbar. */
- hDisabledImageList = ImageList_LoadImage(hinstance, MAKEINTRESOURCE(NSWS_ID_TOOLBAR_GREY_BITMAP), gw->toolbuttonsize, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
- SendMessage(hWndToolbar, TB_SETDISABLEDIMAGELIST, (WPARAM)1, (LPARAM)hDisabledImageList);
+ nsws_set_imagelist(hWndToolbar, TB_SETDISABLEDIMAGELIST, NSWS_ID_TOOLBAR_GREY_BITMAP, gw->toolbuttonsize, gw->toolbuttonc);
/* Create the hot image list and assign to toolbar. */
- hHotImageList = ImageList_LoadImage(hinstance, MAKEINTRESOURCE(NSWS_ID_TOOLBAR_HIGHL_BITMAP), gw->toolbuttonsize, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
- SendMessage(hWndToolbar, TB_SETHOTIMAGELIST, (WPARAM)2, (LPARAM)hHotImageList);
+ nsws_set_imagelist(hWndToolbar, TB_SETHOTIMAGELIST, NSWS_ID_TOOLBAR_HOT_BITMAP, gw->toolbuttonsize, gw->toolbuttonc);
/* Add buttons. */
SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
@@ -1524,7 +1533,7 @@
w.hInstance = hinstance;
w.hIcon = LoadIcon(NULL, IDI_APPLICATION); /* -> NetSurf */
w.hCursor = LoadCursor(NULL, IDC_ARROW);
- w.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ w.hbrBackground = (HBRUSH)(COLOR_MENU + 1);
w.lpszMenuName = NULL;
w.lpszClassName = windowclassname_main;
w.hIconSm = LoadIcon(NULL, IDI_APPLICATION); /* -> NetSurf */
@@ -1562,7 +1571,8 @@
gw->rclick = LoadMenu(hinstance, MAKEINTRESOURCE(NSWS_ID_CTXMENU));
LOG(("creating window for hInstance %p", hinstance));
- hwnd = CreateWindow(windowclassname_main,
+ hwnd = CreateWindowEx(0,
+ windowclassname_main,
"NetSurf Browser",
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CS_DBLCLKS,
Modified: trunk/netsurf/windows/res/resource.rc
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/resource.rc?r...
==============================================================================
--- trunk/netsurf/windows/res/resource.rc (original)
+++ trunk/netsurf/windows/res/resource.rc Thu Feb 4 17:15:50 2010
@@ -18,7 +18,7 @@
NSWS_ID_TOOLBAR_GREY_BITMAP BITMAP "toolbarg.bmp"
-NSWS_ID_TOOLBAR_HIGHL_BITMAP BITMAP "toolbarh.bmp"
+NSWS_ID_TOOLBAR_HOT_BITMAP BITMAP "toolbarh.bmp"
Modified: trunk/netsurf/windows/resourceid.h
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/resourceid.h?rev=...
==============================================================================
--- trunk/netsurf/windows/resourceid.h (original)
+++ trunk/netsurf/windows/resourceid.h Thu Feb 4 17:15:50 2010
@@ -27,7 +27,7 @@
#define NSWS_ID_CTXMENU 103
#define NSWS_ID_TOOLBAR_BITMAP 107
#define NSWS_ID_TOOLBAR_GREY_BITMAP 108
-#define NSWS_ID_TOOLBAR_HIGHL_BITMAP 109
+#define NSWS_ID_TOOLBAR_HOT_BITMAP 109
#define NSWS_ID_ABOUT_DIALOG 11111
#define NSWS_ID_ABOUT_CONTENT 11112
#define NSWS_ID_PREFS_DIALOG 11113
13 years
r9954 vince - in /trunk/netsurf/windows: font.c gui.c res/back.bmp res/forward.bmp res/home.bmp res/reload.bmp res/resource.rc res/stop.bmp res/toolbar.bmp res/toolbarg.bmp res/toolbarh.bmp resourceid.h
by netsurf@semichrome.net
Author: vince
Date: Thu Feb 4 15:05:44 2010
New Revision: 9954
URL: http://source.netsurf-browser.org?rev=9954&view=rev
Log:
Cleanup toolbar usage
Fix font sizing
Added:
trunk/netsurf/windows/res/toolbar.bmp (with props)
trunk/netsurf/windows/res/toolbarg.bmp (with props)
trunk/netsurf/windows/res/toolbarh.bmp (with props)
Removed:
trunk/netsurf/windows/res/back.bmp
trunk/netsurf/windows/res/forward.bmp
trunk/netsurf/windows/res/home.bmp
trunk/netsurf/windows/res/reload.bmp
trunk/netsurf/windows/res/stop.bmp
Modified:
trunk/netsurf/windows/font.c
trunk/netsurf/windows/gui.c
trunk/netsurf/windows/res/resource.rc
trunk/netsurf/windows/resourceid.h
Modified: trunk/netsurf/windows/font.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/font.c?rev=9954&r...
==============================================================================
--- trunk/netsurf/windows/font.c (original)
+++ trunk/netsurf/windows/font.c Thu Feb 4 15:05:44 2010
@@ -31,9 +31,6 @@
#include "windows/gui.h"
#include "windows/plot.h"
-#define NSWS_FONT_SCALE_HEIGHT 1.3
-#define NSWS_FONT_SCALE_WIDTH 0.45
-
utf8_convert_ret utf8_to_font_encoding(const struct font_desc* font,
const char *string,
size_t len,
@@ -76,28 +73,32 @@
family = FF_SWISS | DEFAULT_PITCH;
break;
}
-
- HFONT font = CreateFont((int)((((float)style->size) *
- NSWS_FONT_SCALE_HEIGHT * nsws_plot_get_scale())
- / FONT_SIZE_SCALE), /* height */
- (int)((((float)style->size) *
- NSWS_FONT_SCALE_WIDTH * nsws_plot_get_scale())
- / FONT_SIZE_SCALE), /* width */
- 0, /* escapement*/
- 0, /* orientation */
- style->weight,
- (style->flags & FONTF_ITALIC) ? TRUE : FALSE,
- FALSE, /* underline */
- FALSE, /* strike */
- DEFAULT_CHARSET, /* for locale */
- OUT_DEFAULT_PRECIS, /* general 'best match' */
- CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY,
- family,
- face /* name of font face */
- );
+
+ int nHeight = -10;
+
+ HDC hdc = GetDC(current_hwnd);
+ nHeight = -MulDiv(style->size, GetDeviceCaps(hdc, LOGPIXELSY), 72 * FONT_SIZE_SCALE);
+ ReleaseDC(current_hwnd, hdc);
+
+ HFONT font = CreateFont(
+ nHeight, /* height */
+ 0, /* width */
+ 0, /* escapement*/
+ 0, /* orientation */
+ style->weight,
+ (style->flags & FONTF_ITALIC) ? TRUE : FALSE,
+ FALSE, /* underline */
+ FALSE, /* strike */
+ DEFAULT_CHARSET, /* for locale */
+ OUT_DEFAULT_PRECIS, /* general 'best match' */
+ CLIP_DEFAULT_PRECIS,
+ DEFAULT_QUALITY,
+ family,
+ face /* name of font face */
+ );
if (face != NULL)
free(face);
+
if (font == NULL) {
if (style->family == PLOT_FONT_FAMILY_MONOSPACE)
font = (HFONT) GetStockObject(ANSI_FIXED_FONT);
Modified: trunk/netsurf/windows/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/gui.c?rev=9954&r1...
==============================================================================
--- trunk/netsurf/windows/gui.c (original)
+++ trunk/netsurf/windows/gui.c Thu Feb 4 15:05:44 2010
@@ -67,7 +67,7 @@
struct gui_window *window_list = NULL;
FARPROC urlproc;
-FARPROC toolproc;
+WNDPROC toolproc;
static char default_page[] = "http://www.netsurf-browser.org/welcome/";
static HICON hIcon, hIconS;
@@ -76,7 +76,6 @@
static const char windowclassname_main[] = "nswsmainwindow";
static const char windowclassname_drawable[] = "nswsdrawablewindow";
-#define NTOOLBUTTONS 5
#define NSWS_THROBBER_WIDTH 24
#define NSWS_URL_ENTER (WM_USER)
@@ -99,12 +98,10 @@
struct nsws_localhistory *localhistory; /**< handle to local history window */
int width; /**< width of window */
int height; /**< height of drawing area */
- int urlbarwidth; /**< width of url bar */
- int ntoolbuttons; /**< number of toolbar buttons */
- int toolbuttondimension; /**< width, height of buttons */
+
+ int toolbuttonc; /**< number of toolbar buttons */
+ int toolbuttonsize; /**< width, height of buttons */
bool throbbing; /**< whether currently throbbing */
- TBBUTTON buttons[NTOOLBUTTONS + 1]; /* 1 = url bar */
- HBITMAP hbmp[NTOOLBUTTONS]; /**< tool button images */
struct browser_mouse *mouse; /**< mouse state */
@@ -267,66 +264,71 @@
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)
+{
+ struct gui_window *gw;
+ HWND phwnd;
+
+ gw = GetProp(hwnd, TEXT("GuiWnd"));
+
+ if (gw == NULL) {
+ /* try the parent window instead */
+ phwnd = GetParent(hwnd);
+ gw = GetProp(phwnd, TEXT("GuiWnd"));
+ }
+
+ if (gw == NULL) {
+ /* unable to fetch from property, try seraching the
+ * gui window list
+ */
+ gw = window_list;
+ while (gw != NULL) {
+ if ((gw->main == hwnd) || (gw->toolbar == hwnd)) {
+ break;
+ }
+ gw = gw->next;
+ }
+ }
+
+ return gw;
+}
+
/**
* callback for toolbar events
*/
-LRESULT CALLBACK nsws_window_toolbar_callback(HWND hwnd, UINT msg,
- WPARAM wparam, LPARAM lparam)
-{
- int x,y;
- bool match = false;
- struct gui_window *w = window_list;
- while (w != NULL) {
- if (w->toolbar == hwnd) {
- match = true;
- break;
- }
- w = w->next;
- }
-
- if (match == false) { /* during initial window creation */
- w = window_list;
- while (w != NULL) {
- if (w->toolbar == NULL) {
- w->toolbar = hwnd;
- break;
- }
- w = w->next;
- }
- }
+LRESULT CALLBACK
+nsws_window_toolbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ struct gui_window *gw;
+ int urlx, urly, urlwidth, urlheight;
switch (msg) {
- case WM_LBUTTONUP:
- case WM_LBUTTONDOWN:
- case WM_MOUSEMOVE:
- x = GET_X_LPARAM(lparam);
- y = GET_Y_LPARAM(lparam);
- if ((w != NULL) &&
- (x > w->ntoolbuttons * w->toolbuttondimension)) {
- if (msg == WM_LBUTTONDOWN)
- SetFocus(w->urlbar);
-
- return CallWindowProc((WNDPROC)
- nsws_window_url_callback,
- w->urlbar, msg, wparam,
- MAKELONG(x - w->ntoolbuttons *
- w->toolbuttondimension, y));
- }
- break;
case WM_SIZE:
+ gw = nsws_get_gui_window(hwnd);
+ urlbar_dimensions(hwnd, gw->toolbuttonsize, gw->toolbuttonc, &urlx, &urly, &urlwidth, &urlheight);
/* resize url */
- if (w->urlbar != NULL) {
- w->urlbarwidth = LOWORD(lparam) - w->ntoolbuttons * w->toolbuttondimension - 8 - NSWS_THROBBER_WIDTH;
- MoveWindow(w->urlbar,
- w->toolbuttondimension * w->ntoolbuttons + 2,
- 8,
- w->urlbarwidth - 8,
- w->toolbuttondimension - 12,
- true);
+ if (gw->urlbar != NULL) {
+ MoveWindow(gw->urlbar, urlx, urly, urlwidth, urlheight, true);
}
/* move throbber */
- if (w->throbber != NULL) {
- MoveWindow(w->throbber,
+ if (gw->throbber != NULL) {
+ MoveWindow(gw->throbber,
LOWORD(lparam) - NSWS_THROBBER_WIDTH - 4, 8,
NSWS_THROBBER_WIDTH, NSWS_THROBBER_WIDTH,
true);
@@ -335,7 +337,8 @@
break;
}
- return CallWindowProc((WNDPROC) toolproc, hwnd, msg, wparam, lparam);
+ /* chain to the next handler */
+ return CallWindowProc(toolproc, hwnd, msg, wparam, lparam);
}
/**
@@ -512,26 +515,6 @@
SendMessage(w->main, WM_SETICON, ICON_SMALL, (LPARAM)hIconS);
}
-/**
- * creation of url bar
- */
-static void nsws_window_urlbar_create(struct gui_window *w)
-{
- HWND hwnd = CreateWindow("EDIT",
- "",
- WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_OEMCONVERT,
- w->toolbuttondimension * w->ntoolbuttons + 2,
- 8,
- w->urlbarwidth - 8,
- w->toolbuttondimension - 12,
- w->main,
- (HMENU) NSWS_ID_URLBAR,
- hinstance,
- NULL);
- /*urlproc = (FARPROC) SetWindowLong(hwnd, GWL_WNDPROC, (DWORD)
- nsws_window_url_callback);*/
- w->urlbar = hwnd;
-}
/**
* creation of throbber
@@ -564,80 +547,83 @@
w->throbber = hwnd;
}
-/**
- * creation of toolbar
- */
-static void
-nsws_window_toolbar_create(struct gui_window *w)
-{
- unsigned int listid = 0;
- char imagepath[PATH_MAX];
- /* NB there is currently an immediate window close at
- * netsurf launch in real/virtual - as distinct from
- * emulation - windows whose probable cause is the
- * location of the url bar to the right of the buttons;
- * really the way forward would quite possibly be to
- * implement an active bitmap as the button bar, sensitive
- * to hover / click events; the immediate window close
- * behaviour was observed during development when testing
- * the arrangements of url bar / buttons although much has
- * changed since then */
-
- HWND hwnd = CreateWindow(TOOLBARCLASSNAME,
- NULL,
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_FLAT,
- 0, 0, w->width,
- w->toolbuttondimension + 8, w->main,
- (HMENU) NSWS_ID_TOOLBAR, hinstance, NULL);
- HIMAGELIST hImageList = ImageList_Create(w->toolbuttondimension - 8,
- w->toolbuttondimension - 8,
- 0,
- w->ntoolbuttons,
- 0);
- SendMessage(hwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
-
- ZeroMemory(w->buttons, sizeof(w->buttons));
-
- w->buttons[5].iBitmap = w->urlbarwidth;
- w->buttons[5].fsStyle = TBSTYLE_SEP;
- w->buttons[5].iString = -1;
-/* w->buttons[0].fsState = TBSTATE_ENABLED; */
-
-/* keep bitmaps in cache memory for re-creation of toolbar */
-
-#define MAKE_BUTTON(p, q, r) \
- if (w->hbmp[p] == NULL) { \
- nsws_find_resource(imagepath, #r ".bmp", "windows/res/" \
- #r ".bmp"); \
- LOG(("loading toolbutton image %s", imagepath)); \
- w->hbmp[p] = LoadImage(NULL, imagepath, IMAGE_BITMAP, \
- w->toolbuttondimension - 8, \
- w->toolbuttondimension - 8, LR_SHARED | \
- LR_LOADFROMFILE | LR_LOADTRANSPARENT); \
- } \
- ImageList_Add(hImageList, w->hbmp[p], NULL); \
- w->buttons[p].iBitmap = MAKELONG(p, 0); \
- w->buttons[p].idCommand = NSWS_ID_NAV_##q; \
- w->buttons[p].fsState = TBSTATE_ENABLED; \
- w->buttons[p].fsStyle = TBSTYLE_BUTTON
- MAKE_BUTTON(0, BACK, back);
- MAKE_BUTTON(1, FORWARD, forward);
- MAKE_BUTTON(2, HOME, home);
- MAKE_BUTTON(3, STOP, stop);
- MAKE_BUTTON(4, RELOAD, reload);
-#undef MAKE_BUTTON
- SendMessage(hwnd, TB_SETIMAGELIST, (WPARAM) listid, (LPARAM)
- hImageList);
- SendMessage(hwnd, TB_ADDBUTTONS, w->ntoolbuttons + 1,
- (LPARAM) &(w->buttons));
- w->toolbar = hwnd;
- DeleteObject(hImageList);
- nsws_window_urlbar_create(w);
- nsws_window_throbber_create(w);
- SendMessage(hwnd, WM_SIZE, 0,
- MAKELONG(w->width, w->toolbuttondimension + 12));
- toolproc = (FARPROC) SetWindowLong(hwnd, GWL_WNDPROC, (DWORD)
- nsws_window_toolbar_callback);
+
+static HWND
+nsws_window_toolbar_create(struct gui_window *gw, HWND hWndParent)
+{
+ HWND hWndToolbar;
+ HIMAGELIST hImageList;
+ HIMAGELIST hDisabledImageList;
+ HIMAGELIST hHotImageList;
+ /* Toolbar buttons */
+ TBBUTTON tbButtons[] = {
+ {0, NSWS_ID_NAV_BACK, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+ {1, NSWS_ID_NAV_FORWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+ {2, NSWS_ID_NAV_HOME, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+ {3, NSWS_ID_NAV_RELOAD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+ {4, NSWS_ID_NAV_STOP, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+ };
+
+ /* Create the toolbar child window. */
+ hWndToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, "Toolbar",
+ WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT,
+ 0, 0, 0, 0,
+ hWndParent, NULL, HINST_COMMCTRL, NULL);
+
+ if (!hWndToolbar) {
+ return NULL;
+ }
+
+ /* remember how many buttons are being created */
+ gw->toolbuttonc = sizeof(tbButtons) / sizeof(TBBUTTON);
+
+ /* Create the standard image list and assign to toolbar. */
+ hImageList = ImageList_LoadImage(hinstance, MAKEINTRESOURCE(NSWS_ID_TOOLBAR_BITMAP), gw->toolbuttonsize, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
+ SendMessage(hWndToolbar, TB_SETIMAGELIST, (WPARAM)0, (LPARAM)hImageList);
+
+ /* Create the disabled image list and assign to toolbar. */
+ hDisabledImageList = ImageList_LoadImage(hinstance, MAKEINTRESOURCE(NSWS_ID_TOOLBAR_GREY_BITMAP), gw->toolbuttonsize, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
+ SendMessage(hWndToolbar, TB_SETDISABLEDIMAGELIST, (WPARAM)1, (LPARAM)hDisabledImageList);
+
+ /* Create the hot image list and assign to toolbar. */
+ hHotImageList = ImageList_LoadImage(hinstance, MAKEINTRESOURCE(NSWS_ID_TOOLBAR_HIGHL_BITMAP), gw->toolbuttonsize, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
+ SendMessage(hWndToolbar, TB_SETHOTIMAGELIST, (WPARAM)2, (LPARAM)hHotImageList);
+
+ /* Add buttons. */
+ SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
+ SendMessage(hWndToolbar, TB_ADDBUTTONS, (WPARAM)gw->toolbuttonc, (LPARAM)&tbButtons);
+
+
+ int urlx, urly, urlwidth, urlheight;
+ urlbar_dimensions(hWndToolbar, gw->toolbuttonsize, gw->toolbuttonc, &urlx, &urly, &urlwidth, &urlheight);
+
+ // 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;
}
/**
@@ -654,15 +640,19 @@
static void nsws_window_drawingarea_create(struct gui_window *w)
{
- /* potentially make drawingarea window from frameless window
- + scrollbars here */
+ RECT rtoolbar;
+ RECT rstatusbar;
+
+ GetClientRect(w->toolbar, &rtoolbar);
+ GetClientRect(w->statusbar, &rstatusbar);
+
w->drawingarea = CreateWindow(windowclassname_drawable,
NULL,
WS_VISIBLE|WS_CHILD,
0,
- w->toolbuttondimension + 8,
+ rtoolbar.bottom + 1,
w->width,
- w->height - (w->toolbuttondimension + 8),
+ rstatusbar.top - rtoolbar.bottom,
w->main,
NULL,
hinstance,
@@ -1490,13 +1480,6 @@
nscss_screen_dpi = INTTOFIX(dpi);
ReleaseDC(hwnd, hdc);
- nsws_window_set_accels(w);
- nsws_window_set_ico(w);
- nsws_window_toolbar_create(w);
- nsws_window_statusbar_create(w);
- nsws_window_vscroll_create(w);
- nsws_window_hscroll_create(w);
- nsws_window_drawingarea_create(w);
break;
}
@@ -1600,6 +1583,14 @@
option_window_y, option_window_width,
option_window_height, SWP_SHOWWINDOW);
+ nsws_window_set_accels(gw);
+ nsws_window_set_ico(gw);
+ gw->toolbar = nsws_window_toolbar_create(gw, hwnd);
+ nsws_window_statusbar_create(gw);
+ nsws_window_vscroll_create(gw);
+ nsws_window_hscroll_create(gw);
+ nsws_window_drawingarea_create(gw);
+
ShowWindow(hwnd, SW_SHOWNORMAL);
UpdateWindow(hwnd);
gw->main = hwnd;
@@ -1626,10 +1617,7 @@
w->width = 600;
w->height = 600;
- w->ntoolbuttons = NTOOLBUTTONS;
- w->toolbuttondimension = 32; /* includes padding of 4 every side */
- w->urlbarwidth = w->width - w->toolbuttondimension * w->ntoolbuttons
- - 8 - NSWS_THROBBER_WIDTH;
+ w->toolbuttonsize = 24; /* includes padding of 4 every side */
w->requestscrollx = 0;
w->requestscrolly = 0;
w->localhistory = NULL;
Removed: trunk/netsurf/windows/res/back.bmp
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/back.bmp?rev=...
==============================================================================
Binary file - no diff available.
Removed: trunk/netsurf/windows/res/forward.bmp
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/forward.bmp?r...
==============================================================================
Binary file - no diff available.
Removed: trunk/netsurf/windows/res/home.bmp
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/home.bmp?rev=...
==============================================================================
Binary file - no diff available.
Removed: trunk/netsurf/windows/res/reload.bmp
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/reload.bmp?re...
==============================================================================
Binary file - no diff available.
Modified: trunk/netsurf/windows/res/resource.rc
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/resource.rc?r...
==============================================================================
--- trunk/netsurf/windows/res/resource.rc (original)
+++ trunk/netsurf/windows/res/resource.rc Thu Feb 4 15:05:44 2010
@@ -10,9 +10,21 @@
//
+// Bitmap resources
+//
+NSWS_ID_TOOLBAR_BITMAP BITMAP "toolbar.bmp"
+
+
+NSWS_ID_TOOLBAR_GREY_BITMAP BITMAP "toolbarg.bmp"
+
+
+NSWS_ID_TOOLBAR_HIGHL_BITMAP BITMAP "toolbarh.bmp"
+
+
+
+//
// Menu resources
//
-//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
NSWS_ID_CTXMENU MENU
{
POPUP "Context"
@@ -32,7 +44,6 @@
-//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
NSWS_ID_MAINMENU MENU
{
POPUP "&File"
@@ -118,20 +129,18 @@
//
// Dialog resources
//
-//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
-NSWS_ID_ABOUT_DIALOG DIALOG 0, 0, 400, 400
+NSWS_ID_ABOUT_DIALOG DIALOG 0, 0, 400, 350
STYLE DS_MODALFRAME | DS_SETFONT | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
CAPTION "About NetSurf"
FONT 8, "MS Sans Serif"
{
- DEFPUSHBUTTON "&OK", IDOK, 350, 365, 30, 20
- GROUPBOX "About NetSurf", IDC_STATIC, 10, 10, 380, 380
- CTEXT "content", NSWS_ID_ABOUT_CONTENT, 20, 20, 350, 330, SS_CENTER
-}
-
-
-
-//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+ DEFPUSHBUTTON "&OK", IDOK, 345, 317, 41, 16
+ GROUPBOX "About NetSurf", IDC_STATIC, 10, 10, 380, 328
+ CTEXT "content", NSWS_ID_ABOUT_CONTENT, 20, 20, 361, 292, SS_CENTER
+}
+
+
+
NSWS_ID_DOWNLOAD_DIALOG DIALOG 0, 0, 200, 100
STYLE DS_MODALFRAME | DS_SETFONT | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
CAPTION "download"
@@ -145,7 +154,6 @@
-//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
NSWS_ID_PREFS_DIALOG DIALOG 0, 0, 388, 205
STYLE DS_MODALFRAME | DS_SETFONT | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
CAPTION "Edit preferences"
@@ -213,5 +221,4 @@
//
// Icon resources
//
-//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
ID ICON "NetSurf32.ico"
Removed: trunk/netsurf/windows/res/stop.bmp
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/stop.bmp?rev=...
==============================================================================
Binary file - no diff available.
Added: trunk/netsurf/windows/res/toolbar.bmp
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/toolbar.bmp?r...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/windows/res/toolbar.bmp
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/windows/res/toolbarg.bmp
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/toolbarg.bmp?...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/windows/res/toolbarg.bmp
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/windows/res/toolbarh.bmp
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/res/toolbarh.bmp?...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/windows/res/toolbarh.bmp
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: trunk/netsurf/windows/resourceid.h
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/resourceid.h?rev=...
==============================================================================
--- trunk/netsurf/windows/resourceid.h (original)
+++ trunk/netsurf/windows/resourceid.h Thu Feb 4 15:05:44 2010
@@ -25,6 +25,9 @@
#define NSWS_ID_MAINMENU 101
#define NSWS_ID_CTXMENU 103
+#define NSWS_ID_TOOLBAR_BITMAP 107
+#define NSWS_ID_TOOLBAR_GREY_BITMAP 108
+#define NSWS_ID_TOOLBAR_HIGHL_BITMAP 109
#define NSWS_ID_ABOUT_DIALOG 11111
#define NSWS_ID_ABOUT_CONTENT 11112
#define NSWS_ID_PREFS_DIALOG 11113
13 years
r9952 vince - /trunk/netsurf/windows/gui.c
by netsurf@semichrome.net
Author: vince
Date: Tue Feb 2 17:43:09 2010
New Revision: 9952
URL: http://source.netsurf-browser.org?rev=9952&view=rev
Log:
Make window resizeing not delete all child windows and recreate them a resize is sufficient
Modified:
trunk/netsurf/windows/gui.c
Modified: trunk/netsurf/windows/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/gui.c?rev=9952&r1...
==============================================================================
--- trunk/netsurf/windows/gui.c (original)
+++ trunk/netsurf/windows/gui.c Tue Feb 2 17:43:09 2010
@@ -182,29 +182,18 @@
w = w->next;
continue;
}
-// current_hwnd = w->main;
+
current_hwnd = w->drawingarea;
-// PostMessage(w->toolbar, WM_PAINT, 0, 0);
-// PostMessage(w->urlbar, WM_PAINT, 0, 0);
w->scrolly += w->requestscrolly;
w->scrollx += w->requestscrollx;
w->scrolly = MAX(w->scrolly, 0);
- w->scrolly = MIN(w->scrolly, c->height * w->bw->scale
- - w->height);
+ w->scrolly = MIN(w->scrolly, c->height * w->bw->scale - w->height);
w->scrollx = MAX(w->scrollx, 0);
- w->scrollx = MIN(w->scrollx, c->width * w->bw->scale
- - w->width);
+ w->scrollx = MIN(w->scrollx, c->width * w->bw->scale - w->width);
/* redraw */
-/* w->redraw.left = MIN(w->redraw.left, w->scrollx);
- w->redraw.top = MIN(w->redraw.top, w->scrolly + w->voffset );
- w->redraw.right = MAX(w->redraw.right, w->scrollx + w->width);
- w->redraw.bottom = MAX(w->redraw.bottom, w->scrolly +
- w->height + w->voffset );
-*/
current_redraw_browser = bw;
nsws_plot_set_scale(bw->scale);
-/* doublebuffering = true; */
hdc = GetDC(w->main);
if (w->bufferbm == NULL) {
w->bufferbm = CreateCompatibleBitmap(hdc, w->width,
@@ -284,6 +273,7 @@
LRESULT CALLBACK nsws_window_toolbar_callback(HWND hwnd, UINT msg,
WPARAM wparam, LPARAM lparam)
{
+ int x,y;
bool match = false;
struct gui_window *w = window_list;
while (w != NULL) {
@@ -305,23 +295,46 @@
}
}
- if ((msg == WM_LBUTTONUP) ||
- (msg == WM_LBUTTONDOWN) ||
- (msg == WM_MOUSEMOVE)) {
- int x,y;
+ switch (msg) {
+ case WM_LBUTTONUP:
+ case WM_LBUTTONDOWN:
+ case WM_MOUSEMOVE:
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if ((w != NULL) &&
+ if ((w != NULL) &&
(x > w->ntoolbuttons * w->toolbuttondimension)) {
if (msg == WM_LBUTTONDOWN)
SetFocus(w->urlbar);
+
return CallWindowProc((WNDPROC)
nsws_window_url_callback,
w->urlbar, msg, wparam,
MAKELONG(x - w->ntoolbuttons *
w->toolbuttondimension, y));
}
- }
+ break;
+ case WM_SIZE:
+ /* resize url */
+ if (w->urlbar != NULL) {
+ w->urlbarwidth = LOWORD(lparam) - w->ntoolbuttons * w->toolbuttondimension - 8 - NSWS_THROBBER_WIDTH;
+ MoveWindow(w->urlbar,
+ w->toolbuttondimension * w->ntoolbuttons + 2,
+ 8,
+ w->urlbarwidth - 8,
+ w->toolbuttondimension - 12,
+ true);
+ }
+ /* move throbber */
+ if (w->throbber != NULL) {
+ MoveWindow(w->throbber,
+ LOWORD(lparam) - NSWS_THROBBER_WIDTH - 4, 8,
+ NSWS_THROBBER_WIDTH, NSWS_THROBBER_WIDTH,
+ true);
+ }
+
+ break;
+ }
+
return CallWindowProc((WNDPROC) toolproc, hwnd, msg, wparam, lparam);
}
@@ -504,16 +517,16 @@
*/
static void nsws_window_urlbar_create(struct gui_window *w)
{
- HWND hwnd = CreateWindow("EDIT",
- "",
+ HWND hwnd = CreateWindow("EDIT",
+ "",
WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_OEMCONVERT,
- w->toolbuttondimension * w->ntoolbuttons + 2,
+ w->toolbuttondimension * w->ntoolbuttons + 2,
8,
- w->urlbarwidth - 8,
+ w->urlbarwidth - 8,
w->toolbuttondimension - 12,
- w->main,
- (HMENU) NSWS_ID_URLBAR,
- hinstance,
+ w->main,
+ (HMENU) NSWS_ID_URLBAR,
+ hinstance,
NULL);
/*urlproc = (FARPROC) SetWindowLong(hwnd, GWL_WNDPROC, (DWORD)
nsws_window_url_callback);*/
@@ -531,9 +544,14 @@
hwnd = CreateWindow(ANIMATE_CLASS,
"",
WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT,
- w->width - NSWS_THROBBER_WIDTH - 4, 8,
- NSWS_THROBBER_WIDTH, NSWS_THROBBER_WIDTH, w->main,
- (HMENU) NSWS_ID_THROBBER, hinstance, NULL);
+ w->width - NSWS_THROBBER_WIDTH - 4,
+ 8,
+ NSWS_THROBBER_WIDTH,
+ NSWS_THROBBER_WIDTH,
+ w->main,
+ (HMENU) NSWS_ID_THROBBER,
+ hinstance,
+ NULL);
nsws_find_resource(avi, "throbber.avi", "windows/res/throbber.avi");
LOG(("setting throbber avi as %s", avi));
@@ -549,7 +567,7 @@
/**
* creation of toolbar
*/
-static void
+static void
nsws_window_toolbar_create(struct gui_window *w)
{
unsigned int listid = 0;
@@ -565,16 +583,16 @@
* the arrangements of url bar / buttons although much has
* changed since then */
- HWND hwnd = CreateWindow(TOOLBARCLASSNAME,
- NULL,
+ HWND hwnd = CreateWindow(TOOLBARCLASSNAME,
+ NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_FLAT,
0, 0, w->width,
w->toolbuttondimension + 8, w->main,
(HMENU) NSWS_ID_TOOLBAR, hinstance, NULL);
HIMAGELIST hImageList = ImageList_Create(w->toolbuttondimension - 8,
- w->toolbuttondimension - 8,
- 0,
- w->ntoolbuttons,
+ w->toolbuttondimension - 8,
+ 0,
+ w->ntoolbuttons,
0);
SendMessage(hwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
@@ -638,15 +656,15 @@
{
/* potentially make drawingarea window from frameless window
+ scrollbars here */
- w->drawingarea = CreateWindow(windowclassname_drawable,
- NULL,
+ w->drawingarea = CreateWindow(windowclassname_drawable,
+ NULL,
WS_VISIBLE|WS_CHILD,
- 0,
- w->toolbuttondimension + 8,
- w->width,
+ 0,
+ w->toolbuttondimension + 8,
+ w->width,
w->height - (w->toolbuttondimension + 8),
- w->main,
- NULL,
+ w->main,
+ NULL,
hinstance,
NULL);
if (w->drawingarea == NULL)
@@ -679,8 +697,8 @@
bool ctrl = ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000);
bool alt = ((GetKeyState(VK_MENU) & 0x8000) == 0x8000);
- if ((gw == NULL) ||
- (gw->mouse == NULL) ||
+ if ((gw == NULL) ||
+ (gw->mouse == NULL) ||
(gw->bw == NULL))
return 0;
@@ -716,8 +734,8 @@
static LRESULT nsws_drawable_mousedown(struct gui_window *gw, int x, int y, browser_mouse_state button)
{
- if ((gw == NULL) ||
- (gw->mouse == NULL) ||
+ if ((gw == NULL) ||
+ (gw->mouse == NULL) ||
(gw->bw == NULL)) {
nsws_localhistory_close(gw);
return 0;
@@ -741,19 +759,19 @@
return 0;
}
-static LRESULT
-nsws_drawable_mouseup(struct gui_window *gw,
- int x,
- int y,
- browser_mouse_state press,
+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) ||
+ if ((gw == NULL) ||
+ (gw->mouse == NULL) ||
(gw->bw == NULL))
return 0;
@@ -771,12 +789,12 @@
gw->mouse->state &= ~BROWSER_MOUSE_MOD_3;
if ((gw->mouse->state & click) != 0)
- browser_window_mouse_click(gw->bw,
+ 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,
+ browser_window_mouse_drag_end(gw->bw,
0,
(x + gw->scrollx) / gw->bw->scale,
(y + gw->scrolly) / gw->bw->scale);
@@ -805,6 +823,90 @@
plot.clip(0, 0, gw->width, gw->height); /* vrs - very suspect */
}
+static void nsws_drawable_key(struct gui_window *gw, HWND hwnd, WPARAM wparam)
+{
+ if (GetFocus() != hwnd)
+ return;
+
+ 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);
+
+}
+
+
/* Called when activity occours within the drawable window. */
LRESULT CALLBACK nsws_window_drawable_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
@@ -822,32 +924,32 @@
switch(msg) {
- case WM_MOUSEMOVE:
+ case WM_MOUSEMOVE:
nsws_drawable_mousemove(gw,
- GET_X_LPARAM(lparam),
+ GET_X_LPARAM(lparam),
GET_Y_LPARAM(lparam));
break;
- case WM_LBUTTONDOWN:
+ case WM_LBUTTONDOWN:
nsws_drawable_mousedown(gw,
- GET_X_LPARAM(lparam),
+ GET_X_LPARAM(lparam),
GET_Y_LPARAM(lparam),
BROWSER_MOUSE_PRESS_1);
SetFocus(hwnd);
nsws_localhistory_close(gw);
break;
- case WM_RBUTTONDOWN:
+ case WM_RBUTTONDOWN:
nsws_drawable_mousedown(gw,
- GET_X_LPARAM(lparam),
+ GET_X_LPARAM(lparam),
GET_Y_LPARAM(lparam),
BROWSER_MOUSE_PRESS_2);
SetFocus(hwnd);
break;
- case WM_LBUTTONUP:
+ case WM_LBUTTONUP:
nsws_drawable_mouseup(gw,
- GET_X_LPARAM(lparam),
+ GET_X_LPARAM(lparam),
GET_Y_LPARAM(lparam),
BROWSER_MOUSE_PRESS_1,
BROWSER_MOUSE_CLICK_1);
@@ -855,7 +957,7 @@
case WM_RBUTTONUP:
nsws_drawable_mouseup(gw,
- GET_X_LPARAM(lparam),
+ GET_X_LPARAM(lparam),
GET_Y_LPARAM(lparam),
BROWSER_MOUSE_PRESS_2,
BROWSER_MOUSE_CLICK_2);
@@ -865,75 +967,9 @@
nsws_drawable_paint(gw, hwnd);
break;
- case WM_KEYDOWN: {
- if (GetFocus() != hwnd)
- break;
- 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);
- break;
- }
-
+ case WM_KEYDOWN:
+ nsws_drawable_key(gw, hwnd, wparam);
+ break;
default:
break;
}
@@ -941,35 +977,58 @@
return DefWindowProc(hwnd, msg, wparam, lparam);
}
-static void
-nsws_window_resize(struct gui_window *w,
- HWND hwnd,
- WPARAM wparam,
+static void
+nsws_window_resize(struct gui_window *w,
+ HWND hwnd,
+ WPARAM wparam,
LPARAM lparam)
{
- if ((w->toolbar == NULL) || (w->urlbar == NULL) ||
+ if ((w->toolbar == NULL) ||
+ (w->urlbar == NULL) ||
(w->statusbar == NULL))
return;
+
int x, y;
RECT rmain, rstatus, rtool;
GetClientRect(hwnd, &rmain);
GetClientRect(w->toolbar, &rtool);
GetWindowRect(w->statusbar, &rstatus);
gui_window_get_scroll(w, &x, &y);
- w->height = HIWORD(lparam) -
- (rtool.bottom - rtool.top) -
+ w->height = HIWORD(lparam) -
+ (rtool.bottom - rtool.top) -
(rstatus.bottom - rstatus.top);
w->width = LOWORD(lparam);
if (w->drawingarea != NULL) {
- MoveWindow(w->drawingarea, 0 ,rtool.bottom, w->width, w->height, true);
+ MoveWindow(w->drawingarea,
+ 0,
+ rtool.bottom,
+ w->width,
+ w->height,
+ true);
}
if (w->statusbar != NULL) {
- MoveWindow(w->statusbar, 0 ,rtool.bottom + w->height, w->width, (rstatus.bottom - rstatus.top+1) , true);
- }
-
-
+ MoveWindow(w->statusbar,
+ 0,
+ rtool.bottom + w->height,
+ w->width,
+ (rstatus.bottom - rstatus.top + 1),
+ true);
+ }
+
+ nsws_window_update_forward_back(w);
+
+ if (w->toolbar != NULL) {
+ MoveWindow(w->toolbar,
+ 0,
+ 0,
+ w->width,
+ (rtool.bottom - rtool.top),
+ true);
+ }
+
+ /* update double buffering context */
HDC hdc = GetDC(hwnd);
if (w->bufferdc == NULL)
w->bufferdc = CreateCompatibleDC(hdc);
@@ -979,31 +1038,13 @@
SelectObject(w->bufferdc, w->bufferbm);
}
ReleaseDC(hwnd, hdc);
- w->urlbarwidth = w->width - w->ntoolbuttons *
- w->toolbuttondimension - 8 -
- NSWS_THROBBER_WIDTH;
+
+ /* update browser window to new dimensions */
if (w->bw != NULL) {
-
browser_window_reformat(w->bw, w->width, w->height);
redraw();
}
gui_window_set_scroll(w, x, y);
-
- /* re-create toolbar to adjust width of url bar holder */
- DestroyWindow(w->toolbar);
- DestroyWindow(w->throbber);
- /* memorize url */
- int len = SendMessage(w->urlbar, WM_GETTEXTLENGTH, 0, 0);
- char temp[len + 1];
- SendMessage(w->urlbar, WM_GETTEXT, (WPARAM) (len + 1),
- (LPARAM) temp);
- DestroyWindow(w->urlbar);
- nsws_window_toolbar_create(w);
- SendMessage(w->urlbar, WM_SETTEXT, 0, (LPARAM) temp);
-/* SendMessage(w->toolbar, TB_AUTOSIZE, 0, 0);
- */
-// SendMessage(w->statusbar, WM_SIZE, 0, MAKELONG(w->width, 0));
- nsws_window_update_forward_back(w);
if (w->toolbar != NULL)
SendMessage(w->toolbar, TB_SETSTATE,
@@ -2118,7 +2159,7 @@
/**
* clear window caret
*/
-void
+void
gui_window_remove_caret(struct gui_window *w)
{
if (w == NULL)
@@ -2126,31 +2167,31 @@
HideCaret(w->drawingarea);
}
-void
+void
gui_window_set_icon(struct gui_window *g, struct content *icon)
{
}
-void
+void
gui_window_set_search_ico(struct content *ico)
{
}
-bool
-save_complete_gui_save(const char *path,
+bool
+save_complete_gui_save(const char *path,
const char *filename,
- size_t len,
- const char *sourcedata,
+ size_t len,
+ const char *sourcedata,
content_type type)
{
return false;
}
-int
-save_complete_htmlSaveFileFormat(const char *path,
+int
+save_complete_htmlSaveFileFormat(const char *path,
const char *filename,
- xmlDocPtr cur,
- const char *encoding,
+ xmlDocPtr cur,
+ const char *encoding,
int format)
{
return 0;
@@ -2417,7 +2458,7 @@
void gui_stdout(void)
{
- /* mwindows compile flag normally invalidates stdout unless
+ /* mwindows compile flag normally invalidates stdout unless
already redirected */
if (_get_osfhandle(fileno(stdout)) == -1) {
AllocConsole();
13 years
r9951 tlsa - /trunk/netsurfweb/about/thanks.en
by netsurf@semichrome.net
Author: tlsa
Date: Tue Feb 2 14:31:33 2010
New Revision: 9951
URL: http://source.netsurf-browser.org?rev=9951&view=rev
Log:
Update GSoC 2009 bits.
Modified:
trunk/netsurfweb/about/thanks.en
Modified: trunk/netsurfweb/about/thanks.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/about/thanks.en?rev=99...
==============================================================================
--- trunk/netsurfweb/about/thanks.en (original)
+++ trunk/netsurfweb/about/thanks.en Tue Feb 2 14:31:33 2010
@@ -76,13 +76,18 @@
<p>Our students completed our new HTML5 parser, vastly overhauled the GTK front end, implemented PDF export, added print functionality to the GTK version and split bits of NetSurf out into separate libraries, for ease of maintenance and use by other projects. In addition to all this, taking part in Google Summer of Code also raised NetSurf's profile in the wider open source community.</p>
-<h3>GSoC 2009</h3>
-
-<p>In the second year we participated, our students worked on several areas of the project. Much work was done on our new Document Object Model library. A set of core widgets like scrollbars and text inputs was created. Much previously RISC OS specific functionality was moved from the RISC OS front end to the multi-platform core. These include treeviews, global history, cookie management, and page text search. The GTK front end was much improved with interfaces for the new core functionality and other features like a search bar and favicons.</p>
-
<ul>
<li><a href="http://code.google.com/soc/2008/">Google Summer of Code 2008</a></li>
<li><a href="http://code.google.com/soc/2008/netsurf/about.html">GSoC 2008 - NetSurf organisation listing</a></li>
+</ul>
+
+<h3>GSoC 2009</h3>
+
+<p>In the second year our students worked on several areas of the project. Much work was done on our new Document Object Model library. A set of core widgets like scrollbars and text inputs was created. Much previously RISC OS specific functionality was moved from the RISC OS front end to the multi-platform core. These include treeviews, global history, cookie management, and page text search. The GTK front end was much improved with interfaces for the new core functionality and other features like a search bar and favicons.</p>
+
+<ul>
+<li><a href="http://socghop.appspot.com/">Google Summer of Code</a></li>
+<li><a href="http://socghop.appspot.com/gsoc/org/home/google/gsoc2009/netsurf">GSoC 2009 - NetSurf organisation listing</a></li>
</ul>
<h2><img class="thankslogo" src="/webimages/logoppf.png" alt="">Pepperfish</h2>
13 years
r9950 vince - in /trunk/netsurf/windows: gui.c localhistory.c plot.c
by netsurf@semichrome.net
Author: vince
Date: Mon Feb 1 17:59:40 2010
New Revision: 9950
URL: http://source.netsurf-browser.org?rev=9950&view=rev
Log:
remove all references to defunct vertical offset from plotters
Modified:
trunk/netsurf/windows/gui.c
trunk/netsurf/windows/localhistory.c
trunk/netsurf/windows/plot.c
Modified: trunk/netsurf/windows/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/gui.c?rev=9950&r1...
==============================================================================
--- trunk/netsurf/windows/gui.c (original)
+++ trunk/netsurf/windows/gui.c Mon Feb 1 17:59:40 2010
@@ -1722,13 +1722,6 @@
return &(w->clip);
}
-int gui_window_voffset(struct gui_window *w)
-{
- if (w == NULL)
- return 0;
- return 0;
-}
-
int gui_window_width(struct gui_window *w)
{
if (w == NULL)
Modified: trunk/netsurf/windows/localhistory.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/localhistory.c?re...
==============================================================================
--- trunk/netsurf/windows/localhistory.c (original)
+++ trunk/netsurf/windows/localhistory.c Mon Feb 1 17:59:40 2010
@@ -158,15 +158,13 @@
break;
case WM_MOVE: {
RECT r, rmain;
- int voffset;
if (w != NULL) {
current_gui = w;
current_hwnd = gui_window_main_window(w);
- voffset = gui_window_voffset(w);
GetWindowRect(hwnd, &r);
GetWindowRect(current_hwnd, &rmain);
gui_window_redraw(w,
- MIN(r.top - rmain.top - voffset, 0),
+ MIN(r.top - rmain.top , 0),
MIN(r.left - rmain.left, 0),
gui_window_height(w) -
MIN(rmain.bottom - r.bottom, 0),
Modified: trunk/netsurf/windows/plot.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/plot.c?rev=9950&r...
==============================================================================
--- trunk/netsurf/windows/plot.c (original)
+++ trunk/netsurf/windows/plot.c Mon Feb 1 17:59:40 2010
@@ -57,9 +57,6 @@
static bool clip(int x0, int y0, int x1, int y1)
{
- int voffset = (thumbnail ? 0 : gui_window_voffset(current_gui));
- y0 += voffset;
- y1 += voffset;
#if NSWS_PLOT_DEBUG
LOG(("clip %d,%d to %d,%d thumbnail %d", x0, y0, x1, y1, thumbnail));
@@ -68,10 +65,10 @@
if (clip == NULL)
clip = &localhistory_clip;
x0 = MAX(x0, 0);
- y0 = MAX(y0, voffset);
+ y0 = MAX(y0, 0);
if (!((current_gui == NULL) || (thumbnail))) {
x1 = MIN(x1, gui_window_width(current_gui));
- y1 = MIN(y1, gui_window_height(current_gui) + voffset);
+ y1 = MIN(y1, gui_window_height(current_gui));
}
clip->left = x0;
clip->top = y0 ;
@@ -83,8 +80,6 @@
static bool line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- y0 += (thumbnail ? 0 : gui_window_voffset(current_gui));
- y1 += (thumbnail ? 0 : gui_window_voffset(current_gui));
#if NSWS_PLOT_DEBUG
LOG(("ligne from %d,%d to %d,%d thumbnail %d", x0, y0, x1, y1,
thumbnail));
@@ -159,8 +154,6 @@
y1 = MIN(y1, gui_window_height(current_gui));
}
- y0 += (thumbnail ? 0 : gui_window_voffset(current_gui));
- y1 += (thumbnail ? 0 : gui_window_voffset(current_gui));
#if NSWS_PLOT_DEBUG
LOG(("rectangle from %d,%d to %d,%d thumbnail %d", x0, y0, x1, y1,
thumbnail));
@@ -306,9 +299,7 @@
SetPolyFillMode(hdc, WINDING);
for (i = 0; i < n; i++) {
points[i].x = (long) p[2 * i];
- points[i].y = (long) (p[2 * i + 1]
- + (thumbnail ? 0 :
- gui_window_voffset(current_gui)));
+ points[i].y = (long) p[2 * i + 1];
#if NSWS_PLOT_DEBUG
printf ("%ld,%ld ", points[i].x, points[i].y);
@@ -370,7 +361,6 @@
fontbak = (HFONT) SelectObject(hdc, font);
GetTextExtentPoint(hdc, text, length, &s);
- y += (thumbnail ? 0 : gui_window_voffset(current_gui));
r.left = x;
r.top = y - (3 * s.cy) / 4;
r.right = x + s.cx;
@@ -407,7 +397,6 @@
static bool disc(int x, int y, int radius, const plot_style_t *style)
{
- y += (thumbnail ? 0 : gui_window_voffset(current_gui));
#if NSWS_PLOT_DEBUG
LOG(("disc at %d,%d radius %d thumbnail %d", x, y, radius, thumbnail));
#endif
@@ -492,7 +481,6 @@
static bool arc(int x, int y, int radius, int angle1, int angle2,
const plot_style_t *style)
{
- y += (thumbnail ? 0 : gui_window_voffset(current_gui));
#if NSWS_PLOT_DEBUG
LOG(("arc centre %d,%d radius %d from %d to %d", x, y, radius,
angle1, angle2));
@@ -613,8 +601,6 @@
#endif
if (bitmap == NULL)
return false;
- int voffset = (thumbnail ? 0 : gui_window_voffset(current_gui));
- y += voffset;
HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd);
if (hdc == NULL) {
return false;
13 years
r9949 vince - /trunk/netsurf/windows/gui.c
by netsurf@semichrome.net
Author: vince
Date: Mon Feb 1 17:48:00 2010
New Revision: 9949
URL: http://source.netsurf-browser.org?rev=9949&view=rev
Log:
Substantial cleanup
perform drawing in child window
eliminate random vertical offsets
Modified:
trunk/netsurf/windows/gui.c
Modified: trunk/netsurf/windows/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/windows/gui.c?rev=9949&r1...
==============================================================================
--- trunk/netsurf/windows/gui.c (original)
+++ trunk/netsurf/windows/gui.c Mon Feb 1 17:48:00 2010
@@ -72,6 +72,9 @@
static char default_page[] = "http://www.netsurf-browser.org/welcome/";
static HICON hIcon, hIconS;
static int open_windows = 0;
+
+static const char windowclassname_main[] = "nswsmainwindow";
+static const char windowclassname_drawable[] = "nswsdrawablewindow";
#define NTOOLBUTTONS 5
#define NSWS_THROBBER_WIDTH 24
@@ -99,7 +102,6 @@
int urlbarwidth; /**< width of url bar */
int ntoolbuttons; /**< number of toolbar buttons */
int toolbuttondimension; /**< width, height of buttons */
- int voffset; /**< height of toolbar */
bool throbbing; /**< whether currently throbbing */
TBBUTTON buttons[NTOOLBUTTONS + 1]; /* 1 = url bar */
HBITMAP hbmp[NTOOLBUTTONS]; /**< tool button images */
@@ -142,6 +144,7 @@
LRESULT CALLBACK nsws_window_url_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);
HINSTANCE hinstance;
@@ -179,9 +182,10 @@
w = w->next;
continue;
}
- current_hwnd = w->main;
- PostMessage(w->toolbar, WM_PAINT, 0, 0);
- PostMessage(w->urlbar, WM_PAINT, 0, 0);
+// current_hwnd = w->main;
+ current_hwnd = w->drawingarea;
+// PostMessage(w->toolbar, WM_PAINT, 0, 0);
+// PostMessage(w->urlbar, WM_PAINT, 0, 0);
w->scrolly += w->requestscrolly;
w->scrollx += w->requestscrollx;
w->scrolly = MAX(w->scrolly, 0);
@@ -204,7 +208,7 @@
hdc = GetDC(w->main);
if (w->bufferbm == NULL) {
w->bufferbm = CreateCompatibleBitmap(hdc, w->width,
- w->height + w->voffset);
+ w->height );
SelectObject(w->bufferdc, w->bufferbm);
}
@@ -224,8 +228,8 @@
bw->scale, 0xFFFFFF);
if (doublebuffering)
/* blit buffer to screen */
- BitBlt(hdc, 0, w->voffset, w->width, w->height,
- w->bufferdc, 0, w->voffset,
+ BitBlt(hdc, 0, 0, w->width, w->height,
+ w->bufferdc, 0, 0,
SRCCOPY);
ReleaseDC(w->main, hdc);
doublebuffering = false;
@@ -308,8 +312,7 @@
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
if ((w != NULL) &&
- (x > w->ntoolbuttons * w->toolbuttondimension)
- && (y < w->voffset)) {
+ (x > w->ntoolbuttons * w->toolbuttondimension)) {
if (msg == WM_LBUTTONDOWN)
SetFocus(w->urlbar);
return CallWindowProc((WNDPROC)
@@ -504,8 +507,8 @@
HWND hwnd = CreateWindow("EDIT",
"",
WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_OEMCONVERT,
- w->toolbuttondimension * w->ntoolbuttons + 4,
- 10,
+ w->toolbuttondimension * w->ntoolbuttons + 2,
+ 8,
w->urlbarwidth - 8,
w->toolbuttondimension - 12,
w->main,
@@ -562,13 +565,17 @@
* the arrangements of url bar / buttons although much has
* changed since then */
- HWND hwnd = CreateWindow(TOOLBARCLASSNAME, NULL, WS_CHILD |
- WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS,
+ HWND hwnd = CreateWindow(TOOLBARCLASSNAME,
+ NULL,
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_FLAT,
0, 0, w->width,
- w->toolbuttondimension + 12, w->main,
+ w->toolbuttondimension + 8, w->main,
(HMENU) NSWS_ID_TOOLBAR, hinstance, NULL);
HIMAGELIST hImageList = ImageList_Create(w->toolbuttondimension - 8,
- w->toolbuttondimension - 8, 0, w->ntoolbuttons, 0);
+ w->toolbuttondimension - 8,
+ 0,
+ w->ntoolbuttons,
+ 0);
SendMessage(hwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
ZeroMemory(w->buttons, sizeof(w->buttons));
@@ -631,6 +638,19 @@
{
/* potentially make drawingarea window from frameless window
+ scrollbars here */
+ w->drawingarea = CreateWindow(windowclassname_drawable,
+ NULL,
+ WS_VISIBLE|WS_CHILD,
+ 0,
+ w->toolbuttondimension + 8,
+ w->width,
+ w->height - (w->toolbuttondimension + 8),
+ w->main,
+ NULL,
+ hinstance,
+ NULL);
+ if (w->drawingarea == NULL)
+ die("arse");
}
/**
@@ -653,43 +673,198 @@
NULL);
}
-/**
- * callback for window events generally
- */
-LRESULT CALLBACK nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam,
- LPARAM lparam)
-{
- bool match = false;
- bool historyactive = false;
- struct gui_window *w = window_list;
- while (w != NULL) {
- if (w->main == hwnd) {
- match = true;
- break;
- }
- w = w->next;
- }
- if (!match) { /* during initial window creation */
- w = window_list;
- while (w != NULL) {
- if (w->main == NULL) {
- w->main = hwnd;
- break;
- }
- w = w->next;
- }
- }
- if ((match) && (current_gui == NULL)) {
- /* local history window is active */
- if ((msg == WM_LBUTTONDOWN) || (msg == WM_PAINT))
- historyactive = true;
- else if ((msg == WM_NCHITTEST) || (msg == WM_SETCURSOR))
- return DefWindowProc(hwnd, msg, wparam, lparam);
- else
- return 0;
- }
- current_gui = w;
+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;
+
+ 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 + gw->scrollx) / gw->bw->scale,
+ (y + gw->scrolly) / gw->bw->scale);
+
+ return 0;
+}
+
+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;
+
+ browser_window_mouse_click(gw->bw, gw->mouse->state,
+ (x + gw->scrollx) / gw->bw->scale ,
+ (y + gw->scrolly) / gw->bw->scale);
+
+ return 0;
+}
+
+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;
+
+
+ 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)
+ 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;
+}
+
+static void nsws_drawable_paint(struct gui_window *gw, HWND hwnd)
+{
+ PAINTSTRUCT ps;
+
+ BeginPaint(hwnd, &ps);
+ gw->redraw.left = ps.rcPaint.left;
+ gw->redraw.top = ps.rcPaint.top;
+ gw->redraw.right = ps.rcPaint.right;
+ gw->redraw.bottom = ps.rcPaint.bottom;
+
+ /* set globals for the plotters */
+ current_hwnd = gw->drawingarea;
+ current_gui = gw;
+
+ redraw();
+ EndPaint(hwnd, &ps);
+
+ plot.clip(0, 0, gw->width, gw->height); /* vrs - very suspect */
+}
+
+/* Called when activity occours within the drawable window. */
+LRESULT CALLBACK nsws_window_drawable_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ struct gui_window *gw = window_list;
+
+ while (gw != NULL) {
+ if (gw->drawingarea == hwnd) {
+ break;
+ }
+ gw = gw->next;
+ }
+
+ if (gw == NULL)
+ return DefWindowProc(hwnd, msg, wparam, lparam);
+
switch(msg) {
+
+ case WM_MOUSEMOVE:
+ nsws_drawable_mousemove(gw,
+ GET_X_LPARAM(lparam),
+ GET_Y_LPARAM(lparam));
+ break;
+
+ 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);
+ break;
+
+ case WM_RBUTTONDOWN:
+ nsws_drawable_mousedown(gw,
+ GET_X_LPARAM(lparam),
+ GET_Y_LPARAM(lparam),
+ BROWSER_MOUSE_PRESS_2);
+ SetFocus(hwnd);
+ break;
+
+ case WM_LBUTTONUP:
+ nsws_drawable_mouseup(gw,
+ GET_X_LPARAM(lparam),
+ GET_Y_LPARAM(lparam),
+ BROWSER_MOUSE_PRESS_1,
+ BROWSER_MOUSE_CLICK_1);
+ break;
+
+ case WM_RBUTTONUP:
+ nsws_drawable_mouseup(gw,
+ GET_X_LPARAM(lparam),
+ GET_Y_LPARAM(lparam),
+ BROWSER_MOUSE_PRESS_2,
+ BROWSER_MOUSE_CLICK_2);
+ break;
+
+ case WM_PAINT:
+ nsws_drawable_paint(gw, hwnd);
+ break;
+
case WM_KEYDOWN: {
if (GetFocus() != hwnd)
break;
@@ -754,192 +929,136 @@
(((!capslock) && (!shift)) ||
((capslock) && (shift))))
i += 'a' - 'A';
- if (w != NULL)
- browser_window_key_press(w->bw, i);
- break;
- }
- case WM_MOUSEMOVE: {
- int x,y;
- bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
- bool ctrl = ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000);
- bool alt = ((GetKeyState(VK_MENU) & 0x8000) == 0x8000);
- x = GET_X_LPARAM(lparam);
- y = GET_Y_LPARAM(lparam);
- if ((w == NULL) || (w->mouse == NULL) || (w->bw == NULL)
- || (y < w->voffset))
+ if (gw != NULL)
+ browser_window_key_press(gw->bw, i);
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return DefWindowProc(hwnd, msg, wparam, lparam);
+}
+
+static void
+nsws_window_resize(struct gui_window *w,
+ HWND hwnd,
+ WPARAM wparam,
+ LPARAM lparam)
+{
+ if ((w->toolbar == NULL) || (w->urlbar == NULL) ||
+ (w->statusbar == NULL))
+ return;
+ int x, y;
+ RECT rmain, rstatus, rtool;
+ GetClientRect(hwnd, &rmain);
+ GetClientRect(w->toolbar, &rtool);
+ GetWindowRect(w->statusbar, &rstatus);
+ gui_window_get_scroll(w, &x, &y);
+ w->height = HIWORD(lparam) -
+ (rtool.bottom - rtool.top) -
+ (rstatus.bottom - rstatus.top);
+ w->width = LOWORD(lparam);
+
+ if (w->drawingarea != NULL) {
+ MoveWindow(w->drawingarea, 0 ,rtool.bottom, w->width, w->height, true);
+ }
+
+ if (w->statusbar != NULL) {
+ MoveWindow(w->statusbar, 0 ,rtool.bottom + w->height, w->width, (rstatus.bottom - rstatus.top+1) , true);
+ }
+
+
+ HDC hdc = GetDC(hwnd);
+ if (w->bufferdc == NULL)
+ w->bufferdc = CreateCompatibleDC(hdc);
+ if (w->bufferbm != NULL) {
+ DeleteObject(w->bufferbm);
+ w->bufferbm = CreateCompatibleBitmap(hdc, w->width, w->height);
+ SelectObject(w->bufferdc, w->bufferbm);
+ }
+ ReleaseDC(hwnd, hdc);
+ w->urlbarwidth = w->width - w->ntoolbuttons *
+ w->toolbuttondimension - 8 -
+ NSWS_THROBBER_WIDTH;
+ if (w->bw != NULL) {
+
+ browser_window_reformat(w->bw, w->width, w->height);
+ redraw();
+ }
+ gui_window_set_scroll(w, x, y);
+
+ /* re-create toolbar to adjust width of url bar holder */
+ DestroyWindow(w->toolbar);
+ DestroyWindow(w->throbber);
+ /* memorize url */
+ int len = SendMessage(w->urlbar, WM_GETTEXTLENGTH, 0, 0);
+ char temp[len + 1];
+ SendMessage(w->urlbar, WM_GETTEXT, (WPARAM) (len + 1),
+ (LPARAM) temp);
+ DestroyWindow(w->urlbar);
+ nsws_window_toolbar_create(w);
+ SendMessage(w->urlbar, WM_SETTEXT, 0, (LPARAM) temp);
+/* SendMessage(w->toolbar, TB_AUTOSIZE, 0, 0);
+ */
+// SendMessage(w->statusbar, WM_SIZE, 0, MAKELONG(w->width, 0));
+ nsws_window_update_forward_back(w);
+
+ if (w->toolbar != NULL)
+ SendMessage(w->toolbar, TB_SETSTATE,
+ (WPARAM) NSWS_ID_NAV_STOP,
+ MAKELONG(TBSTATE_INDETERMINATE, 0));
+
+}
+
+/**
+ * callback for window events generally
+ */
+LRESULT CALLBACK nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam,
+ LPARAM lparam)
+{
+ bool match = false;
+ bool historyactive = false;
+ struct gui_window *w = window_list;
+ while (w != NULL) {
+ if (w->main == hwnd) {
+ match = true;
+ break;
+ }
+ w = w->next;
+ }
+ if (!match) { /* during initial window creation */
+ w = window_list;
+ while (w != NULL) {
+ if (w->main == NULL) {
+ w->main = hwnd;
+ break;
+ }
+ w = w->next;
+ }
+ }
+ if ((match) && (current_gui == NULL)) {
+ /* local history window is active */
+ if ((msg == WM_LBUTTONDOWN) || (msg == WM_PAINT))
+ historyactive = true;
+ else if ((msg == WM_NCHITTEST) || (msg == WM_SETCURSOR))
return DefWindowProc(hwnd, msg, wparam, lparam);
-
- if ((w->mouse->state & BROWSER_MOUSE_PRESS_1) != 0) {
- browser_window_mouse_click(w->bw, BROWSER_MOUSE_DRAG_1,
- w->mouse->pressed_x,
- w->mouse->pressed_y);
- w->mouse->state &= ~BROWSER_MOUSE_PRESS_1;
- w->mouse->state |= BROWSER_MOUSE_HOLDING_1 |
- BROWSER_MOUSE_DRAG_ON;
- }
- else if ((w->mouse->state & BROWSER_MOUSE_PRESS_2) != 0) {
- browser_window_mouse_click(w->bw, BROWSER_MOUSE_DRAG_2,
- w->mouse->pressed_x,
- w->mouse->pressed_y);
- w->mouse->state &= ~BROWSER_MOUSE_PRESS_2;
- w->mouse->state |= BROWSER_MOUSE_HOLDING_2 |
- BROWSER_MOUSE_DRAG_ON;
- }
- if (((w->mouse->state & BROWSER_MOUSE_MOD_1) != 0) && !shift)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_1;
- if (((w->mouse->state & BROWSER_MOUSE_MOD_2) != 0) && !ctrl)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_2;
- if (((w->mouse->state & BROWSER_MOUSE_MOD_3) != 0) && !alt)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_3;
-
- browser_window_mouse_track(w->bw, w->mouse->state,
- (x + w->scrollx) / w->bw->scale,
- (y - w->voffset + w->scrolly) / w->bw->scale);
- return DefWindowProc(hwnd, msg, wparam, lparam);
- break;
- }
- case WM_LBUTTONDOWN: {
- int x,y;
- x = GET_X_LPARAM(lparam);
- y = GET_Y_LPARAM(lparam);
- if ((w == NULL) || (w->mouse == NULL) || (w->bw == NULL)
- || (y < w->voffset)) {
- nsws_localhistory_close(w);
- return DefWindowProc(hwnd, msg, wparam, lparam);
- }
- w->mouse->state = BROWSER_MOUSE_PRESS_1;
- if ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000)
- w->mouse->state |= BROWSER_MOUSE_MOD_1;
- if ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000)
- w->mouse->state |= BROWSER_MOUSE_MOD_2;
- if ((GetKeyState(VK_MENU) & 0x8000) == 0x8000)
- w->mouse->state |= BROWSER_MOUSE_MOD_3;
- w->mouse->pressed_x = (x + w->scrollx) / w->bw->scale;
- w->mouse->pressed_y = (y - w->voffset + w->scrolly)
- / w->bw->scale;
-
- SetFocus(hwnd);
- browser_window_mouse_click(w->bw, w->mouse->state,
- (x + w->scrollx) / w->bw->scale ,
- (y - w->voffset + w->scrolly) /
- w->bw->scale);
- nsws_localhistory_close(w);
- return DefWindowProc(hwnd, msg, wparam, lparam);
- break;
- }
- case WM_RBUTTONDOWN: {
- int x,y;
- x = GET_X_LPARAM(lparam);
- y = GET_Y_LPARAM(lparam);
- if ((w == NULL) || (w->mouse == NULL) || (w->bw == NULL) ||
- (y < w->voffset))
- return DefWindowProc(hwnd, msg, wparam, lparam);
-
- w->mouse->state = BROWSER_MOUSE_PRESS_2;
- if ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000)
- w->mouse->state |= BROWSER_MOUSE_MOD_1;
- if ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000)
- w->mouse->state |= BROWSER_MOUSE_MOD_2;
- if ((GetKeyState(VK_MENU) & 0x8000) == 0x8000)
- w->mouse->state |= BROWSER_MOUSE_MOD_3;
- w->mouse->pressed_x = (x + w->scrollx) / w->bw->scale;
- w->mouse->pressed_y = (y - w->voffset + w->scrolly)
- / w->bw->scale;
- SetFocus(hwnd);
- browser_window_mouse_click(w->bw, w->mouse->state,
- (x + w->scrollx) / w->bw->scale ,
- (y - w->voffset + w->scrolly) /
- w->bw->scale);
- return DefWindowProc(hwnd, msg, wparam, lparam);
- break;
- }
- case WM_LBUTTONUP: {
- int x,y;
- x = GET_X_LPARAM(lparam);
- y = GET_Y_LPARAM(lparam);
- if ((w == NULL) || (w->mouse == NULL) || (w->bw == NULL)
- || (y < w->voffset))
- return DefWindowProc(hwnd, msg, wparam, lparam);
-
- bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
- bool ctrl = ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000);
- bool alt = ((GetKeyState(VK_MENU) & 0x8000) == 0x8000);
-
- if ((w->mouse->state & BROWSER_MOUSE_PRESS_1) != 0) {
- w->mouse->state &= ~BROWSER_MOUSE_PRESS_1;
- w->mouse->state |= BROWSER_MOUSE_CLICK_1;
- }
-
- if (((w->mouse->state & BROWSER_MOUSE_MOD_1) != 0) && !shift)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_1;
- if (((w->mouse->state & BROWSER_MOUSE_MOD_2) != 0) && !ctrl)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_2;
- if (((w->mouse->state & BROWSER_MOUSE_MOD_3) != 0) && !alt)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_3;
-
- if ((w->mouse->state & BROWSER_MOUSE_CLICK_1) != 0)
- browser_window_mouse_click(w->bw, w->mouse->state,
- (x + w->scrollx) / w->bw->scale,
- (y - w->voffset + w->scrolly) /
- w->bw->scale);
else
- browser_window_mouse_drag_end(w->bw, 0,
- (x + w->scrollx) / w->bw->scale,
- (y - w->voffset + w->scrolly) /
- w->bw->scale);
-
- w->mouse->state = 0;
- return DefWindowProc(hwnd, msg, wparam, lparam);
- break;
- }
- case WM_RBUTTONUP: {
- int x,y;
- x = GET_X_LPARAM(lparam);
- y = GET_Y_LPARAM(lparam);
- if ((w == NULL) || (w->mouse == NULL) || (w->bw == NULL) ||
- (y < w->voffset))
- return DefWindowProc(hwnd, msg, wparam, lparam);
- bool shift = ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000);
- bool ctrl = ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000);
- bool alt = ((GetKeyState(VK_MENU) & 0x8000) == 0x8000);
-
- if ((w->mouse->state & BROWSER_MOUSE_PRESS_2) != 0) {
- w->mouse->state &= ~BROWSER_MOUSE_PRESS_2;
- w->mouse->state |= BROWSER_MOUSE_CLICK_2;
- }
-
- if (((w->mouse->state & BROWSER_MOUSE_MOD_1) != 0) && !shift)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_1;
- if (((w->mouse->state & BROWSER_MOUSE_MOD_2) != 0) && !ctrl)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_2;
- if (((w->mouse->state & BROWSER_MOUSE_MOD_3) != 0) && !alt)
- w->mouse->state &= ~BROWSER_MOUSE_MOD_3;
-
- if ((w->mouse->state & BROWSER_MOUSE_CLICK_2) != 0)
- browser_window_mouse_click(w->bw, w->mouse->state,
- (x + w->scrollx) / w->bw->scale,
- (y - w->voffset + w->scrolly) /
- w->bw->scale);
- else
- browser_window_mouse_drag_end(w->bw, 0,
- (x + w->scrollx) / w->bw->scale,
- (y - w->voffset + w->scrolly) /
- w->bw->scale);
-
- w->mouse->state = 0;
- return DefWindowProc(hwnd, msg, wparam, lparam);
- break;
- }
+ return 0;
+ }
+ current_gui = w;
+ switch(msg) {
+
case WM_LBUTTONDBLCLK: {
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if ((w != NULL) && (w->bw != NULL) && (y > w->voffset))
+ if ((w != NULL) && (w->bw != NULL) )
browser_window_mouse_click(w->bw,
BROWSER_MOUSE_DOUBLE_CLICK,
(x + w->scrollx) / w->bw->scale,
- (y - w->voffset + w->scrolly) /
- w->bw->scale);
+ (y + w->scrolly) / w->bw->scale);
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
}
@@ -1331,163 +1450,44 @@
nsws_window_set_ico(w);
nsws_window_toolbar_create(w);
nsws_window_statusbar_create(w);
- nsws_window_drawingarea_create(w);
nsws_window_vscroll_create(w);
nsws_window_hscroll_create(w);
- break;
- }
+ nsws_window_drawingarea_create(w);
+ break;
+ }
+
case WM_PAINT:
{
- if ((w->toolbar == NULL) || (w->urlbar == NULL) ||
- (w->statusbar == NULL) || (w->vscroll == NULL)
- || (w->hscroll == NULL))
- break;
- HWND focuswnd = GetFocus();
- SetFocus(w->urlbar);
- SetFocus(focuswnd);
- current_hwnd = hwnd;
- current_gui = w;
- PAINTSTRUCT ps;
- BeginPaint(hwnd, &ps);
-/* printf("repaint dc %p erase %d from %ld,%ld to %ld,%ld\n",
- ps.hdc, (int)ps.fErase, ps.rcPaint.left,
- ps.rcPaint.top, ps.rcPaint.right,
- ps.rcPaint.bottom);
-*/ PostMessage(w->toolbar, WM_PAINT, 0, 0);
- PostMessage(w->urlbar, WM_PAINT, 0, 0);
- PostMessage(w->statusbar, WM_PAINT, 0, 0);
- PostMessage(w->main, WM_NCPAINT, 0, 0);
-/* PostMessage(w->vscroll, WM_PAINT, 0, 0);
- PostMessage(w->hscroll, WM_PAINT, 0, 0);
-*/
- RECT r, rstatus, rtool;
- GetClientRect(hwnd, &r);
- GetWindowRect(w->toolbar, &rtool);
- GetWindowRect(w->statusbar, &rstatus);
-
- w->voffset = rtool.bottom - rtool.top - 1;
- /* 1 seems necessary */
-
- w->height = r.bottom - w->voffset - (rstatus.bottom -
- rstatus.top) + 1;
-
- w->width = r.right + 1;
-
- w->redraw.left = MAX(ps.rcPaint.left, 0);
- w->redraw.top = MAX(ps.rcPaint.top - w->voffset, 0);
- w->redraw.right = MIN(ps.rcPaint.right, w->width);
- w->redraw.bottom = MIN(ps.rcPaint.bottom, w->height);
- redraw();
- EndPaint(hwnd, &ps);
- plot.clip(0, 0, w->width, w->height);
DWORD ret = DefWindowProc(hwnd, msg, wparam, lparam);
if (historyactive)
current_gui = NULL;
return ret;
- break;
- }
- case WM_NCPAINT:
- PostMessage(w->toolbar, WM_PAINT, 0, 0);
- PostMessage(w->urlbar, WM_PAINT, 0, 0);
+ }
+
+ case WM_SIZE:
+ nsws_window_resize(w, hwnd, wparam, lparam);
return DefWindowProc(hwnd, msg, wparam, lparam);
- break;
- case WM_MOVE:
- DefWindowProc(hwnd, msg, wparam, lparam);
- gui_window_redraw_window(w);
- break;
- case WM_SIZE:
- {
- if ((w->toolbar == NULL) || (w->urlbar == NULL) ||
- (w->statusbar == NULL))
- break;
- int x, y;
- RECT rmain, rstatus, rtool;
- GetClientRect(hwnd, &rmain);
- GetClientRect(w->toolbar, &rtool);
- GetWindowRect(w->statusbar, &rstatus);
- gui_window_get_scroll(w, &x, &y);
- w->voffset = rtool.bottom - rtool.top;
- w->height = HIWORD(lparam) - w->voffset - (rstatus.bottom -
- rstatus.top);
- w->width = LOWORD(lparam);
- HDC hdc = GetDC(hwnd);
- if (w->bufferdc == NULL)
- w->bufferdc = CreateCompatibleDC(hdc);
- if (w->bufferbm != NULL) {
- DeleteObject(w->bufferbm);
- w->bufferbm = CreateCompatibleBitmap(hdc, w->width,
- w->height + w->voffset);
- SelectObject(w->bufferdc, w->bufferbm);
- }
- ReleaseDC(hwnd, hdc);
- w->urlbarwidth = w->width - w->ntoolbuttons *
- w->toolbuttondimension - 8 -
- NSWS_THROBBER_WIDTH;
- if (w->bw != NULL) {
- browser_window_reformat(
- w->bw, w->width, w->height);
- redraw();
- }
- gui_window_set_scroll(w, x, y);
-
- /* re-create toolbar to adjust width of url bar holder */
- DestroyWindow(w->toolbar);
- DestroyWindow(w->throbber);
- /* memorize url */
- int len = SendMessage(w->urlbar, WM_GETTEXTLENGTH, 0, 0);
- char temp[len + 1];
- SendMessage(w->urlbar, WM_GETTEXT, (WPARAM) (len + 1),
- (LPARAM) temp);
- DestroyWindow(w->urlbar);
- nsws_window_toolbar_create(w);
- SendMessage(w->urlbar, WM_SETTEXT, 0, (LPARAM) temp);
-/* SendMessage(w->toolbar, TB_AUTOSIZE, 0, 0);
- */
- SendMessage(w->statusbar, WM_SIZE, 0, MAKELONG(w->width, 0));
- nsws_window_update_forward_back(w);
-
- if (w->toolbar != NULL)
- SendMessage(w->toolbar, TB_SETSTATE,
- (WPARAM) NSWS_ID_NAV_STOP,
- MAKELONG(TBSTATE_INDETERMINATE, 0));
-
- return DefWindowProc(hwnd, msg, wparam, lparam);
- break;
- }
+
case WM_CLOSE:
if (--open_windows == 0) {
netsurf_quit = true;
}
DestroyWindow(hwnd);
break;
+
case WM_DESTROY:
PostQuitMessage(0);
break;
+
default:
return DefWindowProc(hwnd, msg, wparam, lparam);
}
return 0;
}
-/**
- * creation of a new window
- */
-static void nsws_window_create(struct gui_window *gw)
-{
- if (gw == NULL)
- return;
- LOG(("nsws_window_create %p", gw));
- const char windowclassname[] = "nsws_window";
+
+static void create_local_windows_classes(void) {
WNDCLASSEX w;
- HWND hwnd;
- INITCOMMONCONTROLSEX icc;
-
- icc.dwSize = sizeof(icc);
- icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
-#if WINVER > 0x0501
- icc.dwICC |= ICC_STANDARD_CLASSES;
-#endif
- InitCommonControlsEx(&icc);
w.cbSize = sizeof(WNDCLASSEX);
w.style = 0;
@@ -1499,15 +1499,43 @@
w.hCursor = LoadCursor(NULL, IDC_ARROW);
w.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
w.lpszMenuName = NULL;
- w.lpszClassName = windowclassname;
+ w.lpszClassName = windowclassname_main;
w.hIconSm = LoadIcon(NULL, IDI_APPLICATION); /* -> NetSurf */
RegisterClassEx(&w);
+ w.lpfnWndProc = nsws_window_drawable_event_callback;
+ w.hIcon = NULL;
+ w.lpszMenuName = NULL;
+ w.lpszClassName = windowclassname_drawable;
+ w.hIconSm = NULL;
+
+ RegisterClassEx(&w);
+
+}
+
+/**
+ * creation of a new window
+ */
+static void nsws_window_create(struct gui_window *gw)
+{
+ if (gw == NULL)
+ return;
+ LOG(("nsws_window_create %p", gw));
+ HWND hwnd;
+ INITCOMMONCONTROLSEX icc;
+
+ icc.dwSize = sizeof(icc);
+ icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
+#if WINVER > 0x0501
+ icc.dwICC |= ICC_STANDARD_CLASSES;
+#endif
+ InitCommonControlsEx(&icc);
+
gw->mainmenu = LoadMenu(hinstance, MAKEINTRESOURCE(NSWS_ID_MAINMENU));
gw->rclick = LoadMenu(hinstance, MAKEINTRESOURCE(NSWS_ID_CTXMENU));
LOG(("creating window for hInstance %p", hinstance));
- hwnd = CreateWindow(windowclassname,
+ hwnd = CreateWindow(windowclassname_main,
"NetSurf Browser",
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CS_DBLCLKS,
@@ -1698,7 +1726,7 @@
{
if (w == NULL)
return 0;
- return w->voffset;
+ return 0;
}
int gui_window_width(struct gui_window *w)
@@ -1885,25 +1913,25 @@
/* Set caret position */
GetCaretPos(&p);
- HideCaret(w->main);
+ HideCaret(w->drawingarea);
SetCaretPos(p.x - w->requestscrollx, p.y - w->requestscrolly);
- ShowCaret(w->main);
+ ShowCaret(w->drawingarea);
RECT r, redraw;
- r.top = w->voffset - 1;
- r.bottom = w->voffset + w->height + 1;
+ r.top = 0;
+ r.bottom = w->height + 1;
r.left = 0;
r.right = w->width + 1;
- ScrollWindowEx(w->main, - w->requestscrollx, - w->requestscrolly, &r,
+ ScrollWindowEx(w->drawingarea, - w->requestscrollx, - w->requestscrolly, &r,
NULL, NULL, &redraw, SW_INVALIDATE);
gui_window_redraw(w, redraw.left + (w->requestscrollx + w->scrollx)
/ w->bw->scale - 1,
redraw.top + (w->requestscrolly + w->scrolly)
- / w->bw->scale - w->voffset - 1,
+ / w->bw->scale - 1,
redraw.right + (w->requestscrollx + w->scrollx)
/ w->bw->scale + 1,
redraw.bottom + (w->requestscrolly + w->scrolly)
- / w->bw->scale - w->voffset + 1);
+ / w->bw->scale + 1);
}
void gui_window_scroll_visible(struct gui_window *w, int x0, int y0,
@@ -2088,10 +2116,10 @@
{
if (w == NULL)
return;
- CreateCaret(w->main, (HBITMAP)NULL, 1, height * w->bw->scale);
+ CreateCaret(w->drawingarea, (HBITMAP)NULL, 1, height * w->bw->scale);
SetCaretPos(x * w->bw->scale - w->scrollx,
- y * w->bw->scale + w->voffset - w->scrolly);
- ShowCaret(w->main);
+ y * w->bw->scale - w->scrolly);
+ ShowCaret(w->drawingarea);
}
/**
@@ -2102,7 +2130,7 @@
{
if (w == NULL)
return;
- HideCaret(w->main);
+ HideCaret(w->drawingarea);
}
void
@@ -2367,6 +2395,9 @@
quirks_stylesheet_url = path_to_url(buf);
LOG(("Using '%s' as quirks stylesheet url", quirks_stylesheet_url ));
+
+ create_local_windows_classes();
+
option_target_blank = false;
}
13 years