aboutsummaryrefslogtreecommitdiff
path: root/AppKit
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-10-30 18:35:16 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-10-30 18:35:16 +0000
commite1c938bc73510d64b908408bf404eb10a419001e (patch)
tree0001b2d01f045c33f33fff7051fceddcc00971a4 /AppKit
parente1cbd4dc301f0f7e0a0fd7616a958bfaeb615b67 (diff)
[Author: thomasvl]
Add a helper for doing view resizing without resizing subviews. Fix the fixed width call to not change the width. Update the unittest to make sure the fixed width call doesn't change the width. R=stuartmorgan,dmaclach DELTA=41 (30 added, 0 deleted, 11 changed)
Diffstat (limited to 'AppKit')
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.h12
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.m20
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweakerTest.m3
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib4
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiffbin9234 -> 8652 bytes
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiffbin15754 -> 9252 bytes
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiffbin16292 -> 15768 bytes
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiffbin19996 -> 16290 bytes
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-4.tiffbin0 -> 20016 bytes
9 files changed, 32 insertions, 7 deletions
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.h b/AppKit/GTMUILocalizerAndLayoutTweaker.h
index abcb758..3c5c864 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweaker.h
+++ b/AppKit/GTMUILocalizerAndLayoutTweaker.h
@@ -42,7 +42,7 @@
// This checks to see if |view| implements @selector(sizeToFit) and calls it.
// It then checks the class of |view| and does some fixup for known issues
-// where sizeToFit doesn't product a view that meets UI guidelines.
+// where sizeToFit doesn't produce a view that meets UI guidelines.
// Returns the amount the view changed in size.
+ (NSSize)sizeToFitView:(NSView *)view;
@@ -60,13 +60,15 @@
+ (void)wrapButtonTitleForWidth:(NSButton *)button;
+ (void)wrapRadioGroupForWidth:(NSMatrix *)radioGroup;
-// Resizes |window| by |delta| without letting the subviews of |window| get
+// Resizes |window| or |view| by |delta| without letting the subviews get
// resized. Useful when you've done manual tweaking by things like
-// +sizeToFitFixedWidthTextField. The window's origin is not adjusted. Passes
-// |NO| to for -setFrame:display:'s |displayViews| flag on the assumptions
-// the caller is doing all the invals/updates needed.
+// +sizeToFitFixedWidthTextField. The origin is not adjusted. For windows,
+// passes |NO| to for -setFrame:display:'s |displayViews| flag on the
+// assumptions the caller is doing all the invals/updates needed.
+ (void)resizeWindowWithoutAutoResizingSubViews:(NSWindow*)window
delta:(NSSize)delta;
++ (void)resizeViewWithoutAutoResizingSubViews:(NSView*)view
+ delta:(NSSize)delta;
@end
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m
index dca167a..382871c 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweaker.m
+++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m
@@ -223,6 +223,7 @@ static BOOL IsRightAnchored(NSView *view);
NSRect initialFrame = [textField frame];
NSRect sizeRect = NSMakeRect(0, 0, NSWidth(initialFrame), CGFLOAT_MAX);
NSSize newSize = [[textField cell] cellSizeForBounds:sizeRect];
+ newSize.width = NSWidth(initialFrame);
[textField setFrameSize:newSize];
return newSize.height - NSHeight(initialFrame);
}
@@ -278,6 +279,25 @@ static BOOL IsRightAnchored(NSView *view);
}
}
++ (void)resizeViewWithoutAutoResizingSubViews:(NSView*)view
+ delta:(NSSize)delta {
+ // Clear autosizesSubviews (saving the state).
+ BOOL autoresizesSubviews = [view autoresizesSubviews];
+ if (autoresizesSubviews) {
+ [view setAutoresizesSubviews:NO];
+ }
+
+ NSRect rect = [view frame];
+ rect.size.width += delta.width;
+ rect.size.height += delta.height;
+ [view setFrame:rect];
+
+ // Restore autosizesSubviews.
+ if (autoresizesSubviews) {
+ [view setAutoresizesSubviews:YES];
+ }
+}
+
@end
@implementation GTMWidthBasedTweaker
diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
index 51dd9ff..5d2375f 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
+++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
@@ -63,7 +63,10 @@ static NSUInteger gTestPass = 0;
// In the xib, the one field is over sized, the other is undersized, this
// way we make sure the code handles both condions as there was a bahavior
// change between the 10.4 and 10.5 SDKs.
+ // The right field is also right aligned to make sure the width of the text
+ // field stays constant.
NSString *kTestStrings[] = {
+ @"The fox jumps the dog.",
@"The quick brown fox jumps over the lazy dog.",
@"The quick brown fox jumps over the lazy dog. The quick brown fox jumps "
@"over the lazy dog. The quick brown fox jumps over the lazy dog. "
diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib b/AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib
index d0e3e21..36a6fc5 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib
+++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="1"/>
+ <integer value="2"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -93,7 +93,7 @@
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="847317034">
<int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">272891904</int>
+ <int key="NSCellFlags2">71565312</int>
<string key="NSContents">Multiline Label</string>
<reference key="NSSupport" ref="554297525"/>
<reference key="NSControlView" ref="958773035"/>
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiff
index 6ea28e6..30c2a89 100644
--- a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiff
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiff
Binary files differ
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiff
index fb0826c..d949898 100644
--- a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiff
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiff
Binary files differ
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiff
index a9640a0..2d51e31 100644
--- a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiff
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiff
Binary files differ
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiff
index 7f2f0a9..eb7b8fa 100644
--- a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiff
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiff
Binary files differ
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-4.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-4.tiff
new file mode 100644
index 0000000..041b683
--- /dev/null
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-4.tiff
Binary files differ