diff --git a/.gitignore b/.gitignore index 054455b32..b964e4034 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ nsfb nsmonkey nsdebug Makefile.config +NetSurf.core NetSurf.exe netsurf-installer.exe NetSurf.app diff --git a/frontends/gnustep/BrowserWindowController.h b/frontends/gnustep/BrowserWindowController.h index 7de71d5e8..1acd9ee3b 100644 --- a/frontends/gnustep/BrowserWindowController.h +++ b/frontends/gnustep/BrowserWindowController.h @@ -15,4 +15,9 @@ struct browser_window; -(id)initWithBrowser: (struct browser_window*)aBrowser; -(id)back: (id)sender; -(id)forward: (id)sender; + +// Browser control +-(NSSize)getBrowserSize; +-(void)invalidateBrowser; +-(void)invalidateBrowser: (NSRect)rect; @end diff --git a/frontends/gnustep/BrowserWindowController.m b/frontends/gnustep/BrowserWindowController.m index 8cacc5da4..ecccd985d 100644 --- a/frontends/gnustep/BrowserWindowController.m +++ b/frontends/gnustep/BrowserWindowController.m @@ -41,4 +41,14 @@ NSLog(@"Browser forward"); } +-(NSSize)getBrowserSize { + return [plotView frame].size; +} +-(void)invalidateBrowser { + [plotView setNeedsDisplay: YES]; +} +-(void)invalidateBrowser: (NSRect)rect { + [plotView setNeedsDisplayInRect: rect]; +} + @end diff --git a/frontends/gnustep/PlotView.m b/frontends/gnustep/PlotView.m index f9ed6c28e..6103fd261 100644 --- a/frontends/gnustep/PlotView.m +++ b/frontends/gnustep/PlotView.m @@ -1,6 +1,21 @@ -/** -* Large chunks from the cocoa port -*/ +/* + * Copyright 2011 Sven Weidauer + * Copyright 2020 Anthony Cohn-Richardby + * + * 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 . + */ #import #import "PlotView.h" @@ -78,7 +93,8 @@ void cocoa_plot_render_path(NSBezierPath *path, const plot_style_t *pstyle) static nserror plot_clip(const struct redraw_context *ctx, const struct rect *clip) { NSLog(@"plot_clip"); - [NSBezierPath clipRect: NSMakeRect(clip->x0, clip->y0, clip->x1, clip->y1)]; + cocoa_plot_clip_rect = NSMakeRect(clip->x0, clip->y0, clip->x1, clip->y1); + //[NSBezierPath clipRect: ]; return NSERROR_OK; } @@ -101,7 +117,8 @@ static nserror plot_rectangle(const struct redraw_context *ctx, const plot_style NSLog(@"plot_rectangle"); NSRect nsrect = NSMakeRect(rectangle->x0, rectangle->y0, rectangle->x1, rectangle->y1); - //cocoa_plot_render_path(path, pstyle); + NSBezierPath *path = [NSBezierPath bezierPathWithRect: nsrect]; + cocoa_plot_render_path(path, pstyle); return NSERROR_OK; } diff --git a/frontends/gnustep/tables/layout.m b/frontends/gnustep/tables/layout.m index 151bedb1f..128582def 100644 --- a/frontends/gnustep/tables/layout.m +++ b/frontends/gnustep/tables/layout.m @@ -1,17 +1,25 @@ #import +#import #import "netsurf/netsurf.h" #import "netsurf/layout.h" + /********************/ /****** Layout ******/ /********************/ // Put the measured width of the string into width static nserror gnustep_layout_width(const struct plot_font_style *fstyle, const char *string, size_t length, int *width) { - *width = 0; - NSLog(@"gnustep_layout_width"); + NSLog(@"gnustep_layout_width of %s, len %d", string, length); + if (string == NULL || length == 0) { + *width = 0; + return NSERROR_OK; + } + // TODO: = impl properly. + *width = 5 * length; + return NSERROR_OK; } // Put the character offset and actual x coordinate of the character for which the x diff --git a/frontends/gnustep/tables/window.m b/frontends/gnustep/tables/window.m index 8f6b18055..07b1bde02 100644 --- a/frontends/gnustep/tables/window.m +++ b/frontends/gnustep/tables/window.m @@ -3,6 +3,7 @@ #import "BrowserWindowController.h" #import "netsurf/netsurf.h" #import "netsurf/window.h" +#import "netsurf/types.h" /********************/ /****** Window ******/ @@ -29,6 +30,12 @@ static void gnustep_window_destroy(struct gui_window *gw) { // Trigger a redraw of the specified area, or the entire window if null static nserror gnustep_window_invalidate(struct gui_window *gw, const struct rect *rect) { NSLog(@"gnustep_window_invalidate"); + if (rect == NULL) { + [(id)gw invalidateBrowser]; + } else { + [(id)gw invalidateBrowser: NSMakeRect(rect->x0, rect->y0, + rect->x1, rect->y1)]; + } return NSERROR_OK; } @@ -46,7 +53,10 @@ static nserror gnustep_window_set_scroll(struct gui_window *gw, const struct rec // Put the dimensions of the specified window into width, height static nserror gnustep_window_get_dimensions(struct gui_window *gw, int *width, int *height) { - NSLog(@"gnustep_window_get_dimensions"); + NSSize size = [(id)gw getBrowserSize]; + *width = size.width; + *height = size.height; + NSLog(@"gnustep_window_get_dimensions (%d, %d)", *width, *height); return NSERROR_OK; }