Permalink
Browse files

Merge pull request #68 from bww/master

Various scroll view improvements
  • Loading branch information...
2 parents a302717 + f2643b1 commit 65addb39e159c1f9f5ce58f040affce5119bbc64 @atebits atebits committed Sep 27, 2011
@@ -19,7 +19,11 @@
@interface ExampleAppDelegate : NSObject <NSApplicationDelegate>
{
- NSWindow *window;
+ NSWindow * tableViewWindow;
+ NSWindow * scrollViewWindow;
}
+-(IBAction)showTableViewExampleWindow:(id)sender;
+-(IBAction)showScrollViewExampleWindow:(id)sender;
+
@end
@@ -16,38 +16,67 @@
#import "ExampleAppDelegate.h"
#import "ExampleView.h"
+#import "ExampleScrollView.h"
@implementation ExampleAppDelegate
- (void)dealloc
{
- [window release];
+ [tableViewWindow release];
+ [scrollViewWindow release];
[super dealloc];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
CGRect b = CGRectMake(0, 0, 500, 450);
- window = [[NSWindow alloc] initWithContentRect:b
- styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask
- backing:NSBackingStoreBuffered
- defer:NO];
- [window setMinSize:NSMakeSize(300, 250)];
- [window center];
+ /** Table View */
+ tableViewWindow = [[NSWindow alloc] initWithContentRect:b styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO];
+ [tableViewWindow setReleasedWhenClosed:FALSE];
+ [tableViewWindow setMinSize:NSMakeSize(300, 250)];
+ [tableViewWindow center];
+
+ /* TUINSView is the bridge between the standard AppKit NSView-based heirarchy and the TUIView-based heirarchy */
+ TUINSView *tuiTableViewContainer = [[TUINSView alloc] initWithFrame:b];
+ [tableViewWindow setContentView:tuiTableViewContainer];
+ [tuiTableViewContainer release];
+
+ ExampleView *tableExample = [[ExampleView alloc] initWithFrame:b];
+ tuiTableViewContainer.rootView = tableExample;
+ [tableExample release];
+
+ /** Scroll View */
+ scrollViewWindow = [[NSWindow alloc] initWithContentRect:b styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:YES];
+ [scrollViewWindow setReleasedWhenClosed:FALSE];
+ [scrollViewWindow setMinSize:NSMakeSize(300, 250)];
+ [scrollViewWindow setFrameTopLeftPoint:[tableViewWindow cascadeTopLeftFromPoint:CGPointMake(tableViewWindow.frame.origin.x, tableViewWindow.frame.origin.y + tableViewWindow.frame.size.height)]];
+
+ /* TUINSView is the bridge between the standard AppKit NSView-based heirarchy and the TUIView-based heirarchy */
+ TUINSView *tuiScrollViewContainer = [[TUINSView alloc] initWithFrame:b];
+ [scrollViewWindow setContentView:tuiScrollViewContainer];
+ [tuiScrollViewContainer release];
+
+ ExampleScrollView *scrollExample = [[ExampleScrollView alloc] initWithFrame:b];
+ tuiScrollViewContainer.rootView = scrollExample;
+ [scrollExample release];
+
+ [self showTableViewExampleWindow:nil];
+
+}
+
+/**
+ * @brief Show the table view example
+ */
+-(IBAction)showTableViewExampleWindow:(id)sender {
+ [tableViewWindow makeKeyAndOrderFront:sender];
+}
- /*
- TUINSView is the bridge between the standard AppKit NSView-based heirarchy and the TUIView-based heirarchy
- */
- TUINSView *tuiContainer = [[TUINSView alloc] initWithFrame:b];
- [window setContentView:tuiContainer];
- [tuiContainer release];
-
- ExampleView *example = [[ExampleView alloc] initWithFrame:b];
- tuiContainer.rootView = example;
- [example release];
-
- [window makeKeyAndOrderFront:nil];
+/**
+ * @brief Show the scroll view example
+ */
+-(IBAction)showScrollViewExampleWindow:(id)sender {
+ [scrollViewWindow makeKeyAndOrderFront:sender];
}
@end
@@ -0,0 +1,25 @@
+/*
+ Copyright 2011 Twitter, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this work except in compliance with the License.
+ You may obtain a copy of the License in the LICENSE file, or 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 "TUIKit.h"
+#import "ExampleTabBar.h"
+
+@interface ExampleScrollView : TUIView
+{
+ TUIScrollView * _scrollView;
+}
+
+@end
@@ -0,0 +1,46 @@
+/*
+ Copyright 2011 Twitter, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this work except in compliance with the License.
+ You may obtain a copy of the License in the LICENSE file, or 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 "ExampleScrollView.h"
+
+@implementation ExampleScrollView
+
+- (id)initWithFrame:(CGRect)frame
+{
+ if((self = [super initWithFrame:frame])) {
+ self.backgroundColor = [TUIColor colorWithWhite:0.9 alpha:1.0];
+
+ _scrollView = [[TUIScrollView alloc] initWithFrame:self.bounds];
+ _scrollView.autoresizingMask = TUIViewAutoresizingFlexibleSize;
+ _scrollView.scrollIndicatorStyle = TUIScrollViewIndicatorStyleDark;
+ [self addSubview:_scrollView];
+
+ TUIImageView *imageView = [[TUIImageView alloc] initWithImage:[TUIImage imageNamed:@"large-image.jpeg"]];
+ [_scrollView addSubview:imageView];
+ [_scrollView setContentSize:imageView.frame.size];
+ [imageView release];
+
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [_scrollView release];
+ [super dealloc];
+}
+
+@end
Oops, something went wrong.

0 comments on commit 65addb3

Please sign in to comment.