From 0ad6a06b880fa094724e13103a03fbdaae6dd397 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Mon, 8 Feb 2010 19:04:28 +0000 Subject: [Author: thomasvl] Add basic support for NSTabView and a unittest to validate simple behaviors. R=dmaclach DELTA=1069 (1066 added, 0 deleted, 3 changed) --- AppKit/GTMUILocalizerAndLayoutTweaker.m | 12 +- AppKit/GTMUILocalizerAndLayoutTweakerTest.h | 6 +- AppKit/GTMUILocalizerAndLayoutTweakerTest.m | 44 +- AppKit/GTMUILocalizerAndLayoutTweakerTest6.xib | 976 +++++++++++++++++++++ ...GTMUILocalizerAndLayoutTweakerTest6-tab0-0.tiff | Bin 0 -> 13638 bytes ...GTMUILocalizerAndLayoutTweakerTest6-tab0-1.tiff | Bin 0 -> 12784 bytes ...GTMUILocalizerAndLayoutTweakerTest6-tab0-2.tiff | Bin 0 -> 12840 bytes ...GTMUILocalizerAndLayoutTweakerTest6-tab1-0.tiff | Bin 0 -> 16052 bytes ...GTMUILocalizerAndLayoutTweakerTest6-tab1-1.tiff | Bin 0 -> 15668 bytes ...GTMUILocalizerAndLayoutTweakerTest6-tab1-2.tiff | Bin 0 -> 15962 bytes 10 files changed, 1035 insertions(+), 3 deletions(-) create mode 100644 AppKit/GTMUILocalizerAndLayoutTweakerTest6.xib create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-0.tiff create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-1.tiff create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-2.tiff create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-0.tiff create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-1.tiff create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-2.tiff (limited to 'AppKit') diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m index a2f94ab..94bb637 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweaker.m +++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m @@ -123,9 +123,19 @@ static BOOL IsRightAnchored(NSView *view); } - (void)tweakView:(NSView *)view { - // If its a alignment box, let it do its thing, otherwise, go find boxes + // If it's a alignment box, let it do its thing... if ([view isKindOfClass:[GTMWidthBasedTweaker class]]) { [(GTMWidthBasedTweaker *)view tweakLayoutWithOffset:NSZeroPoint]; + // Do our best to support TabViews. If the tabs need to resize, you are + // probably better off manually running them through a tweaker and then fixing + // up the parent view (and other tabs) to look right. + } else if ([view isKindOfClass:[NSTabView class]]) { + NSArray *tabViewItems = [(NSTabView *)view tabViewItems]; + NSTabViewItem *item = nil; + GTM_FOREACH_OBJECT(item, tabViewItems) { + [self tweakView:[item view]]; + } + // Generically look for subviews... } else { NSArray *subviews = [view subviews]; NSView *subview = nil; diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest.h b/AppKit/GTMUILocalizerAndLayoutTweakerTest.h index 9853007..6d841f6 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweakerTest.h +++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest.h @@ -19,7 +19,11 @@ #import #import "GTMUILocalizer.h" -@interface GTMUILocalizerAndLayoutTweakerTestWindowController : NSWindowController +@interface GTMUILocalizerAndLayoutTweakerTestWindowController : NSWindowController { + @private + IBOutlet NSTabView *tabView_; +} +- (NSTabView *)tabView; @end diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m index 5d2375f..fed8359 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m +++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m @@ -129,7 +129,7 @@ static NSUInteger gTestPass = 0; } } -- (void)testWrapStartTitleForWidth { +- (void)testWrappingForWidth { NSString *kTestStrings[] = { @"The fox jumps the dog.", @"The quick brown fox jumps over the lazy dog.", @@ -174,9 +174,51 @@ static NSUInteger gTestPass = 0; } } +- (void)testTabViewLocalization { + // Test with nib 6 + for (gTestPass = 0; gTestPass < 3; ++gTestPass) { + GTMUILocalizerAndLayoutTweakerTestWindowController *controller = + [[GTMUILocalizerAndLayoutTweakerTestWindowController alloc] + initWithWindowNibName:@"GTMUILocalizerAndLayoutTweakerTest6"]; + NSWindow *window = [controller window]; + STAssertNotNil(window, @"Pass %zu", gTestPass); + NSTabView *tabView = [controller tabView]; + for (NSInteger tabIndex = 0; tabIndex < [tabView numberOfTabViewItems]; + ++tabIndex) { + [tabView selectTabViewItemAtIndex:tabIndex]; + NSString *imageName = + [NSString stringWithFormat: + @"GTMUILocalizerAndLayoutTweakerTest6-tab%ld-%ld", + (long)tabIndex, (long)gTestPass]; + GTMAssertObjectImageEqualToImageNamed(window, imageName, + @"Pass %zu", gTestPass); + } + [controller release]; + } + // Test with nib 2 + for (gTestPass = 0; gTestPass < 3; ++gTestPass) { + GTMUILocalizerAndLayoutTweakerTestWindowController *controller = + [[GTMUILocalizerAndLayoutTweakerTestWindowController alloc] + initWithWindowNibName:@"GTMUILocalizerAndLayoutTweakerTest2"]; + NSWindow *window = [controller window]; + STAssertNotNil(window, @"Pass %zu", gTestPass); + NSString *imageName = + [NSString stringWithFormat:@"GTMUILocalizerAndLayoutTweakerTest2-%ld", + (long)gTestPass]; + GTMAssertObjectImageEqualToImageNamed(window, imageName, + @"Pass %zu", gTestPass); + [controller release]; + } +} + @end @implementation GTMUILocalizerAndLayoutTweakerTestWindowController + +- (NSTabView *)tabView { + return tabView_; +} + @end @implementation GTMUILocalizerAndLayoutTweakerTestLocalizer diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest6.xib b/AppKit/GTMUILocalizerAndLayoutTweakerTest6.xib new file mode 100644 index 0000000..6326164 --- /dev/null +++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest6.xib @@ -0,0 +1,976 @@ + + + + 1050 + 9L30 + 680 + 949.54 + 353.00 + + YES + + + + YES + com.apple.InterfaceBuilderKit + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + YES + + + + YES + + GTMUILocalizerAndLayoutTweakerTestWindowController + + + FirstResponder + + + NSApplication + + + 15 + 2 + {{71, 48}, {532, 250}} + 536870912 + Window + NSWindow + + {3.40282e+38, 3.40282e+38} + + + 256 + + YES + + + 18 + {{13, 10}, {506, 234}} + + + YES + + 1 + + + 256 + + YES + + + 266 + + YES + + + 256 + + YES + + + 266 + {{3, 45}, {311, 22}} + + YES + + -1804468671 + 272630784 + + + LucidaGrande + 1.300000e+01 + 1044 + + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + 3 + MAA + + + + + + + 266 + {{3, 13}, {311, 22}} + + YES + + -1804468671 + 272630784 + + + + YES + + + + + + + 266 + {{3, 77}, {311, 22}} + + YES + + -1804468671 + 272630784 + + + + YES + + + + + + {337, 109} + + + + {{155, 52}, {337, 109}} + + {0, 0} + + 67239424 + 0 + Box + + LucidaGrande + 1.100000e+01 + 3100 + + + + 3 + MCAwLjgwMDAwMDAxAA + + + + 0 + 0 + 0 + NO + + + + 268 + + YES + + + 268 + {{17, 84}, {139, 17}} + + YES + + 68288064 + 272630784 + ab:10:2 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2OQA + + + + 6 + System + controlTextColor + + + + + + + 268 + {{17, 20}, {139, 17}} + + YES + + 68288064 + 272630784 + l:12:3 + + + + + + + + + 268 + {{17, 52}, {139, 17}} + + YES + + 68288064 + 272630784 + W:10:4 + + + + + + + + {{-3, 47}, {153, 121}} + + GTMWidthBasedTweaker + + + {{10, 33}, {486, 188}} + + + Tab1 + + + + + 2 + + + 256 + + YES + + + 268 + + YES + + + 268 + {{14, 8}, {96, 32}} + + YES + + 67239424 + 134217728 + no:1:2 + + + -2038284033 + 129 + + + 200 + 25 + + + + + 268 + {{14, 72}, {96, 32}} + + YES + + 67239424 + 134217728 + foo :4:1 + + + -2038284033 + 129 + + + 200 + 25 + + + + + 268 + {{14, 40}, {111, 32}} + + YES + + 67239424 + 134217728 + foobar :2:1 + + + -2038284033 + 129 + + + 200 + 25 + + + + {{17, 76}, {135, 109}} + + GTMWidthBasedTweaker + + + {{10, 33}, {486, 188}} + + Tab2 + + + + + + + 0 + YES + YES + + YES + + + + + {532, 250} + + + {{0, 0}, {1920, 1178}} + {3.40282e+38, 3.40282e+38} + + + GTMUILocalizerAndLayoutTweaker + + + GTMUILocalizerAndLayoutTweakerTestLocalizer + + + + + YES + + + uiObject_ + + + + 84 + + + + viewToSlideAndResize_ + + + + 116 + + + + localizer_ + + + + 118 + + + + window + + + + 119 + + + + tabView_ + + + + 132 + + + + + YES + + 0 + + YES + + + + + + -2 + + + RmlsZSdzIE93bmVyA + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + 2 + + + YES + + + + + + 35 + + + + + 117 + + + + + 120 + + + YES + + + + + + + 121 + + + YES + + + + + + 122 + + + YES + + + + + + 123 + + + YES + + + + + + 124 + + + YES + + + + + + + 34 + + + YES + + + + + + + + 11 + + + YES + + + + + + 15 + + + YES + + + + + + 13 + + + YES + + + + + + 14 + + + + + 16 + + + + + 12 + + + + + 115 + + + YES + + + + + + + + 7 + + + YES + + + + + + 9 + + + YES + + + + + + 5 + + + YES + + + + + + 6 + + + + + 10 + + + + + 8 + + + + + 125 + + + YES + + + + + + + + 126 + + + YES + + + + + + 127 + + + YES + + + + + + 128 + + + YES + + + + + + 129 + + + + + 130 + + + + + 131 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 10.IBPluginDependency + 11.IBPluginDependency + 117.IBPluginDependency + 12.IBPluginDependency + 120.IBPluginDependency + 121.IBPluginDependency + 122.IBPluginDependency + 123.IBPluginDependency + 124.IBPluginDependency + 126.IBPluginDependency + 127.IBPluginDependency + 128.IBPluginDependency + 129.IBPluginDependency + 13.IBPluginDependency + 130.IBPluginDependency + 131.IBPluginDependency + 14.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency + 2.IBPluginDependency + 35.IBPluginDependency + 5.IBPluginDependency + 6.IBPluginDependency + 7.IBPluginDependency + 8.IBPluginDependency + 9.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilderKit + com.apple.InterfaceBuilderKit + {{636, 906}, {532, 250}} + com.apple.InterfaceBuilder.CocoaPlugin + {{636, 906}, {532, 250}} + + {196, 240} + {{202, 428}, {480, 270}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + YES + + + YES + + + + + YES + + YES + + + YES + + + + 132 + + + + YES + + GTMUILocalizer + NSObject + + YES + + YES + otherObjectToLocalize_ + owner_ + yetAnotherObjectToLocalize_ + + + YES + id + id + id + + + + IBProjectSource + AppKit/GTMUILocalizer.h + + + + GTMUILocalizerAndLayoutTweaker + NSObject + + YES + + YES + localizerOwner_ + localizer_ + uiObject_ + + + YES + id + GTMUILocalizer + id + + + + IBProjectSource + AppKit/GTMUILocalizerAndLayoutTweaker.h + + + + GTMUILocalizerAndLayoutTweakerTestLocalizer + GTMUILocalizer + + IBProjectSource + AppKit/GTMUILocalizerAndLayoutTweakerTest.h + + + + GTMUILocalizerAndLayoutTweakerTestWindowController + NSWindowController + + tabView_ + NSTabView + + + + + GTMWidthBasedTweaker + NSView + + YES + + YES + viewToResize_ + viewToSlideAndResize_ + viewToSlide_ + + + YES + id + NSView + NSView + + + + + + NSApplication + + IBProjectSource + UnitTesting/GTMAppKit+UnitTesting.h + + + + NSButton + + + + NSCell + + + + NSControl + + + + NSMenu + + + + NSObject + + IBProjectSource + AppKit/GTMCarbonEvent.h + + + + NSObject + + IBProjectSource + AppKit/GTMDelegatingTableColumn.h + + + + NSObject + + IBProjectSource + Foundation/GTMHTTPServer.h + + + + NSObject + + IBProjectSource + Foundation/GTMNSAppleEventDescriptor+Foundation.h + + + + NSObject + + IBProjectSource + Foundation/GTMNSObject+KeyValueObserving.h + + + + NSObject + + IBProjectSource + UnitTesting/GTMCALayer+UnitTesting.h + + + + NSObject + + IBProjectSource + UnitTesting/GTMNSObject+BindingUnitTesting.h + + + + NSObject + + IBProjectSource + UnitTesting/GTMNSObject+UnitTesting.h + + + + NSTabView + + + + NSTabViewItem + + + + NSTextField + + + + NSView + + IBProjectSource + AppKit/GTMTheme.h + + + + NSView + + + + NSWindow + + + + NSWindow + + + + + 0 + ../GTM.xcodeproj + 3 + + diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-0.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-0.tiff new file mode 100644 index 0000000..0b6ced5 Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-0.tiff differ diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-1.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-1.tiff new file mode 100644 index 0000000..2ba6f64 Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-1.tiff differ diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-2.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-2.tiff new file mode 100644 index 0000000..e405f7f Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab0-2.tiff differ diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-0.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-0.tiff new file mode 100644 index 0000000..0653128 Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-0.tiff differ diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-1.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-1.tiff new file mode 100644 index 0000000..37054ee Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-1.tiff differ diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-2.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-2.tiff new file mode 100644 index 0000000..5940ef2 Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest6-tab1-2.tiff differ -- cgit v1.2.3