Setup scrollview

This commit is contained in:
anthony 2020-12-02 19:48:59 +00:00
parent 074bb11459
commit ca34bcb07f
6 changed files with 33 additions and 1 deletions

View File

@ -21,4 +21,9 @@ struct browser_window;
-(void)setBrowserScroll: (NSPoint)scroll;
-(void)invalidateBrowser;
-(void)invalidateBrowser: (NSRect)rect;
-(void)updateBrowserExtent;
-(void)removeCaret;
-(void)newContent;
-(void)startThrobber;
-(void)stopThrobber;
@end

View File

@ -45,7 +45,24 @@
-(void)invalidateBrowser: (NSRect)rect {
[plotView setNeedsDisplayInRect: rect];
}
-(void)updateBrowserExtent {
int width, height;
browser_window_get_extents(browser, false, &width, &height);
NSLog(@"set frame to size: %d, %d", width, height);
[plotView setFrame: NSMakeRect(0, 0, width, height)];
}
-(void)removeCaret {
}
-(void)newContent {
}
-(void)startThrobber {
}
-(void)stopThrobber {
}
-(BOOL)control: (NSControl*)control textShouldEndEditing: (NSText*)fieldEditor {
NSLog(@"textShouldEndEditing");

View File

@ -276,7 +276,7 @@ static const struct plotter_table gnustep_plotters = {
*/
-(void)drawRect: (NSRect)rect {
NSLog(@"Drawing plotview");
NSSize newSize = [self frame].size;
NSSize newSize = [[self superview] frame].size;
BOOL sizeChanged = newSize.width != lastSize.width ||
newSize.height != lastSize.height;
if (!reallyDraw && sizeChanged) {

View File

@ -101,6 +101,11 @@ static nserror cocoa_font_split(const plot_font_style_t *style,
if (layout == nil) return NSERROR_BAD_PARAMETER;
NSUInteger glyphIndex = cocoa_glyph_for_location( layout, x );
if (glyphIndex >= length) {
*char_offset = length;
*actual_x = cocoa_layout_width( layout );
return NSERROR_OK;
}
NSUInteger chars = [layout characterIndexForGlyphAtIndex: glyphIndex];
if (chars >= [cocoa_text_storage length]) {

View File

@ -70,18 +70,23 @@ static nserror gnustep_window_event(struct gui_window *gw, enum gui_window_event
switch (event) {
case GW_EVENT_UPDATE_EXTENT:
NSLog(@"GW_EVENT_UPDATE_EXTENT");
[(id)gw updateBrowserExtent];
break;
case GW_EVENT_REMOVE_CARET:
NSLog(@"GW_EVENT_REMOVE_CARET");
[(id)gw removeCaret];
break;
case GW_EVENT_NEW_CONTENT:
NSLog(@"GW_EVENT_NEW_CONTENT");
[(id)gw newContent];
break;
case GW_EVENT_START_THROBBER:
NSLog(@"GW_EVENT_START_THROBBER");
[(id)gw startThrobber];
break;
case GW_EVENT_STOP_THROBBER:
NSLog(@"GW_EVENT_STOP_THROBBER");
[(id)gw stopThrobber];
break;
default:
NSLog(@"Unknown window event.");