X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2FXScreenSaverConfigSheet.m;h=b529daddcaa31e2cdd4523039785441883f5a687;hb=50be9bb40dc60130c99ffa568e6677779904ff70;hp=06804c70429b915d84eb34dcbe30ad90fde0889c;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/OSX/XScreenSaverConfigSheet.m b/OSX/XScreenSaverConfigSheet.m index 06804c70..b529dadd 100644 --- a/OSX/XScreenSaverConfigSheet.m +++ b/OSX/XScreenSaverConfigSheet.m @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2006-2008 Jamie Zawinski +/* xscreensaver, Copyright (c) 2006-2009 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 @@ -483,7 +483,7 @@ do_file_selector (NSTextField *txt, BOOL dirs_p) types:nil]; if (result == NSOKButton) { NSArray *files = [panel filenames]; - NSString *file = ([files count] > 0 ? [files objectAtIndex:0] : @""); + file = ([files count] > 0 ? [files objectAtIndex:0] : @""); file = [file stringByAbbreviatingWithTildeInPath]; [txt setStringValue:file]; @@ -837,6 +837,11 @@ make_option_menu (NSUserDefaultsController *prefs, rect.origin.x = rect.origin.y = 0; rect.size.width = 10; rect.size.height = 10; + + // #### "Build and Analyze" says that all of our widgets leak, because it + // seems to not realize that place_child -> addSubview retains them. + // Not sure what to do to make these warnings go away. + NSPopUpButton *popup = [[NSPopUpButton alloc] initWithFrame:rect pullsDown:NO]; @@ -1047,6 +1052,7 @@ static char * anchorize (const char *url) { const char *wiki = "http://en.wikipedia.org/wiki/"; + const char *math = "http://mathworld.wolfram.com/"; if (!strncmp (wiki, url, strlen(wiki))) { char *anchor = (char *) malloc (strlen(url) * 3 + 10); strcpy (anchor, "Wikipedia: \""); @@ -1076,6 +1082,29 @@ anchorize (const char *url) *out = 0; return anchor; + } else if (!strncmp (math, url, strlen(math))) { + char *anchor = (char *) malloc (strlen(url) * 3 + 10); + strcpy (anchor, "MathWorld: \""); + const char *start = url + strlen(wiki); + const char *in = start; + char *out = anchor + strlen(anchor); + while (*in) { + if (*in == '_') { + *out++ = ' '; + } else if (in != start && *in >= 'A' && *in <= 'Z') { + *out++ = ' '; + *out++ = *in; + } else if (!strncmp (in, ".htm", 4)) { + break; + } else { + *out++ = *in; + } + in++; + } + *out++ = '"'; + *out = 0; + return anchor; + } else { return strdup (url); } @@ -1302,7 +1331,7 @@ make_text_controls (NSUserDefaultsController *prefs, make_text_field (prefs, opts, rgroup, node2, YES); [node2 release]; - rect = [last_child(rgroup) frame]; +// rect = [last_child(rgroup) frame]; /* // trying to make the text fields be enabled only when the checkbox is on.. control = last_child (rgroup); @@ -1323,7 +1352,7 @@ make_text_controls (NSUserDefaultsController *prefs, make_file_selector (prefs, opts, rgroup, node2, NO, YES); [node2 release]; - rect = [last_child(rgroup) frame]; +// rect = [last_child(rgroup) frame]; // node2 = [[NSXMLElement alloc] initWithName:@"string"]; @@ -1335,7 +1364,7 @@ make_text_controls (NSUserDefaultsController *prefs, make_text_field (prefs, opts, rgroup, node2, YES); [node2 release]; - rect = [last_child(rgroup) frame]; +// rect = [last_child(rgroup) frame]; layout_group (rgroup, NO); @@ -1545,8 +1574,7 @@ fix_contentview_size (NSView *parent) NSRect f; NSArray *kids = [parent subviews]; int nkids = [kids count]; - NSView *text; // the NSText at the bottom of the window - NSView *last; // the last child before the NSText + NSView *text = 0; // the NSText at the bottom of the window double maxx = 0, miny = 0; int i; @@ -1562,7 +1590,6 @@ fix_contentview_size (NSView *parent) f = [kid frame]; if (f.origin.x + f.size.width > maxx) maxx = f.origin.x + f.size.width; if (f.origin.y - f.size.height < miny) miny = f.origin.y; - last = kid; // NSLog(@"start: %3.0f x %3.0f @ %3.0f %3.0f %3.0f %@", // f.size.width, f.size.height, f.origin.x, f.origin.y, // f.origin.y + f.size.height, [kid class]); @@ -1573,6 +1600,7 @@ fix_contentview_size (NSView *parent) /* Now that we know the width of the window, set the width of the NSText to that, so that it can decide what its height needs to be. */ + if (! text) abort(); f = [text frame]; // NSLog(@"text old: %3.0f x %3.0f @ %3.0f %3.0f %3.0f %@", // f.size.width, f.size.height, f.origin.x, f.origin.y, @@ -1606,6 +1634,10 @@ fix_contentview_size (NSView *parent) f = [text frame]; float dh = f.size.height - oh; f.origin.y += dh; + + // #### This is needed in OSX 10.5, but is wrong in OSX 10.6. WTF?? + // If we do this in 10.6, the text field moves down, off the window. + // So instead we repair it at the end, at the "WTF2" comment. [text setFrame:f]; // Also adjust the parent height by the change in height of the text field. @@ -1619,10 +1651,10 @@ fix_contentview_size (NSView *parent) /* Set the contentView to the size of the children. */ f = [parent frame]; - float yoff = f.size.height; +// float yoff = f.size.height; f.size.width = maxx + LEFT_MARGIN; f.size.height = -(miny - LEFT_MARGIN*2); - yoff = f.size.height - yoff; +// yoff = f.size.height - yoff; [parent setFrame:f]; // NSLog(@"max: %3.0f x %3.0f @ %3.0f %3.0f", @@ -1643,6 +1675,25 @@ fix_contentview_size (NSView *parent) // f.origin.y + f.size.height, [kid class]); } +/* +Bad: + parent: 420 x 541 @ 0 0 + text: 380 x 100 @ 20 22 miny=-501 + +Good: + parent: 420 x 541 @ 0 0 + text: 380 x 100 @ 20 50 miny=-501 +*/ + + // #### WTF2: See "WTF" above. If the text field is off the screen, + // move it up. We need this on 10.6 but not on 10.5. Auugh. + // + f = [text frame]; + if (f.origin.y < 50) { // magic numbers, yay + f.origin.y = 50; + [text setFrame:f]; + } + /* Set the kids to track the top left corner of the window when resized. Set the NSText to track the bottom right corner as well. */ @@ -1850,13 +1901,6 @@ traverse_tree (NSUserDefaultsController *prefs, options:(NSXMLNodePreserveWhitespace | NSXMLNodePreserveCDATA) error:&err]; -/* clean up? - if (!xmlDoc) { - xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:furl - options:NSXMLDocumentTidyXML - error:&err]; - } -*/ if (!xmlDoc || err) { if (err) NSAssert2 (0, @"XML Error: %@: %@", @@ -1865,6 +1909,7 @@ traverse_tree (NSUserDefaultsController *prefs, } traverse_tree (prefs, self, opts, [xmlDoc rootElement]); + [xmlDoc release]; return self; }