X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=OSX%2FXScreenSaverConfigSheet.m;fp=OSX%2FXScreenSaverConfigSheet.m;h=6dceacf7010a921894f7509ccccbebc649880eaa;hp=1e58dc26666a6aafcd20acd6d1a4f31853cdf7c3;hb=d5186197bc394e10a4402f7f6d23fbb14103bc50;hpb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e diff --git a/OSX/XScreenSaverConfigSheet.m b/OSX/XScreenSaverConfigSheet.m index 1e58dc26..6dceacf7 100644 --- a/OSX/XScreenSaverConfigSheet.m +++ b/OSX/XScreenSaverConfigSheet.m @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2006-2013 Jamie Zawinski +/* xscreensaver, Copyright (c) 2006-2014 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -228,10 +228,13 @@ typedef enum { SimpleXMLCommentKind, webView = [[UIWebView alloc] init]; webView.delegate = self; webView.dataDetectorTypes = UIDataDetectorTypeNone; - self. autoresizingMask = (UIViewAutoresizingFlexibleWidth | - UIViewAutoresizingFlexibleHeight); - webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | - UIViewAutoresizingFlexibleHeight); + self. autoresizingMask = UIViewAutoresizingNone; // we do it manually + webView.autoresizingMask = UIViewAutoresizingNone; + webView.scrollView.scrollEnabled = NO; + webView.scrollView.bounces = NO; + webView.opaque = NO; + [webView setBackgroundColor:[UIColor clearColor]]; + [self addSubview: webView]; [self setHTML: h]; return self; @@ -270,6 +273,7 @@ typedef enum { SimpleXMLCommentKind, " font-family: \"%@\";" " font-size: %.4fpx;" // Must be "px", not "pt"! " line-height: %.4fpx;" // And no spaces before it. + " -webkit-text-size-adjust: none;" "}" "\n//-->\n" "" @@ -282,6 +286,7 @@ typedef enum { SimpleXMLCommentKind, [font pointSize], [font lineHeight], h]; + [webView stopLoading]; [webView loadHTMLString:h2 baseURL:[NSURL URLWithString:@""]]; } @@ -290,6 +295,8 @@ static char *anchorize (const char *url); - (void) setText: (NSString *)t { + t = [t stringByTrimmingCharactersInSet:[NSCharacterSet + whitespaceCharacterSet]]; t = [t stringByReplacingOccurrencesOfString:@"&" withString:@"&"]; t = [t stringByReplacingOccurrencesOfString:@"<" withString:@"<"]; t = [t stringByReplacingOccurrencesOfString:@">" withString:@">"]; @@ -313,6 +320,12 @@ static char *anchorize (const char *url); } h = [NSString stringWithFormat: @"%@ %@", h, s]; } + + h = [h stringByReplacingOccurrencesOfString:@"

" withString:@"

"]; + h = [h stringByReplacingOccurrencesOfString:@"

" withString:@"

"]; + h = [h stringByTrimmingCharactersInSet:[NSCharacterSet + whitespaceAndNewlineCharacterSet]]; + [self setHTML: h]; } @@ -336,8 +349,6 @@ static char *anchorize (const char *url); r.origin.x = 0; r.origin.y = 0; [webView setFrame: r]; - [self setHTML: html]; - [webView reload]; } @@ -345,6 +356,7 @@ static char *anchorize (const char *url); { NSString *result = @""; + // Add newlines. str = [str stringByReplacingOccurrencesOfString:@"

" withString:@"

" options:NSCaseInsensitiveSearch @@ -354,12 +366,25 @@ static char *anchorize (const char *url); options:NSCaseInsensitiveSearch range:NSMakeRange(0, [str length])]; + // Remove HREFs. for (NSString *s in [str componentsSeparatedByString: @"<"]) { NSRange r = [s rangeOfString:@">"]; if (r.length > 0) s = [s substringFromIndex: r.location + r.length]; result = [result stringByAppendingString: s]; } + + // Compress internal horizontal whitespace. + str = result; + result = @""; + for (NSString *s in [str componentsSeparatedByCharactersInSet: + [NSCharacterSet whitespaceCharacterSet]]) { + if ([result length] == 0) + result = s; + else if ([s length] > 0) + result = [NSString stringWithFormat: @"%@ %@", result, s]; + } + return result; } @@ -370,8 +395,15 @@ static char *anchorize (const char *url); /* It would be sensible to just ask the UIWebView how tall the page is, instead of hoping that NSString and UIWebView measure fonts and do - wrapping in exactly the same way, but I can't make that work. - Maybe because it loads async? + wrapping in exactly the same way, but since UIWebView is asynchronous, + we'd have to wait for the document to load first, e.g.: + + - Start the document loading; + - return a default height to use for the UITableViewCell; + - wait for the webViewDidFinishLoad delegate method to fire; + - then force the UITableView to reload, to pick up the new height. + + But I couldn't make that work. */ # if 0 r.size.height = [[webView @@ -385,11 +417,6 @@ static char *anchorize (const char *url); s = [text sizeWithFont: font constrainedToSize: s lineBreakMode:NSLineBreakByWordWrapping]; - - // GAAAH. Add one more line, or the UIWebView is still scrollable! - // The text is sized right, but it lets you scroll it up anyway. - s.height += [font pointSize]; - r.size.height = s.height; # endif @@ -1329,6 +1356,8 @@ hreffify (NSText *nstext) [self placeChild:lab on:parent]; # else // USE_IPHONE [lab setTextAlignment: NSTextAlignmentRight]; + // Sometimes rotation screws up truncation. + [lab setLineBreakMode:NSLineBreakByClipping]; [self placeChild:lab on:parent right:(label ? YES : NO)]; # endif // USE_IPHONE @@ -1363,6 +1392,10 @@ hreffify (NSText *nstext) // Make right label be same height as slider. rect.size.height = [slider frame].size.height; [lab setFrame:rect]; +# ifdef USE_IPHONE + // Sometimes rotation screws up truncation. + [lab setLineBreakMode:NSLineBreakByClipping]; +# endif [self placeChild:lab on:parent right:YES]; [lab release]; } @@ -1677,7 +1710,7 @@ set_menu_item_object (NSMenuItem *item, NSObject *obj) // Store the items for this picker in the picker_values array. // This is so fucking stupid. - int menu_number = [pref_keys count] - 1; + unsigned long menu_number = [pref_keys count] - 1; if (! picker_values) picker_values = [[NSMutableArray arrayWithCapacity:menu_number] retain]; while ([picker_values count] <= menu_number) @@ -2488,7 +2521,25 @@ last_child (NSView *parent) # else // USE_IPHONE - // Controls is an array of arrays of the controls, divided into sections. + /* Controls is an array of arrays of the controls, divided into sections. + Each hgroup / vgroup gets a nested array, too, e.g.: + + [ [ [