aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMUILocalizerAndLayoutTweaker.h
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-08-06 17:00:44 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-08-06 17:00:44 +0000
commit1aac50492d94c282511a6484760405b314d1f1f0 (patch)
tree33a3b3e20f874a77bdff3f0238a5f6d393e562c0 /AppKit/GTMUILocalizerAndLayoutTweaker.h
parenteff8351b590bcf190b175e2add2ab87c8e7204ec (diff)
[Author: thomasvl]
Move the nib finding code in GTMUILocalizer to a class methods so it can be called without an instance. Add GTMUILocalizerAndLayoutTweaker getting UI localized and then running through it to auto size UI items that have been marked and also support limited tweaks on other objects based on a group of tweaks. Provide a class method for this sizeToFit fixup of individual objects. Unittests for the new class. R=dmaclach,stuartmorgan DELTA=3161 (3157 added, 0 deleted, 4 changed)
Diffstat (limited to 'AppKit/GTMUILocalizerAndLayoutTweaker.h')
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.h b/AppKit/GTMUILocalizerAndLayoutTweaker.h
new file mode 100644
index 0000000..2d6e0a4
--- /dev/null
+++ b/AppKit/GTMUILocalizerAndLayoutTweaker.h
@@ -0,0 +1,78 @@
+//
+// GTMUILocalizerAndLayoutTweaker.h
+//
+// Copyright 2009 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@class GTMUILocalizer;
+
+// This object will run a GTMUILocalizer on the given object, and then run
+// through the object's view heirarchy triggering any Tweakers to do their work.
+// (This "double duty" is needed so the work can be done in order during
+// awakeFromNib, if it was two objects, the order couldn't be guaranteed.)
+@interface GTMUILocalizerAndLayoutTweaker : NSObject {
+ @private
+ IBOutlet id uiObject_; // The window or view to process on awakeFromNib
+ IBOutlet GTMUILocalizer *localizer_; // If nil, one will be created
+ IBOutlet id localizerOwner_; // Set if you want the default GTMUILocalizer
+}
+- (void)applyLocalizer:(GTMUILocalizer *)localizer
+ tweakingUI:(id)uiObject;
+
+// 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.
+// Returns the amount the view changed in size.
++ (NSSize)sizeToFitView:(NSView *)view;
+@end
+
+// This is a Tweaker that will call sizeToFit on everything within it (that
+// supports it).
+//
+// If the items were all left aligned, they will stay as such and the box will
+// resize based on the largest change of any item within it. If they aren't
+// left aligned, they are assumed to be in a row, and it will slide everything
+// along as it lays them out to make sure they end up still spaced out and will
+// resize itself by the total change to the row.
+//
+// This Tweaker makes no attempt to deal with changes in an object height.
+//
+// This Tweaker makes no attempt to deal with its parent's width.
+@interface GTMWidthBasedTweaker : NSView {
+ @private
+ // This outlet is the view that should move by the same amount as this box
+ // grows and change its size by the inverse. i.e.-if a box of NSTextFields,
+ // they will stay next to the box of labels and resize so the two boxes
+ // continue to use the same total space.
+ IBOutlet NSView *viewToSlideAndResize_;
+ // This outlet is just like viewToSlideAndResize_ except the view is only
+ // slid (ie-its width is not adjusted). i.e.-lets something move along next
+ // to this box.
+ IBOutlet NSView *viewToSlide_;
+ // This outlet is just like viewToSlideAndResize_ except the view is only
+ // resized (ie-its position is not adjusted). i.e.-lets something above/below
+ // this box stay the same width. You can set this to be the window, in
+ // which case it is resized, but you need to make sure everything is setup
+ // to handle that, and using two Tweakers pointed at the window isn't likely
+ // to give the results you want.
+ IBOutlet id viewToResize_;
+
+ CGFloat widthChange_;
+}
+// Return the amount we changed our width by on last tweak.
+- (CGFloat)changedWidth;
+@end