| 1 | //
|
|---|
| 2 | // Issue405AppDelegate.m
|
|---|
| 3 | // issue405
|
|---|
| 4 | //
|
|---|
| 5 | // Created by Gary Palter on 9/4/09.
|
|---|
| 6 | // Copyright 2009 Clozure Associates. All rights reserved.
|
|---|
| 7 | //
|
|---|
| 8 |
|
|---|
| 9 | #import "Issue492AppDelegate.h"
|
|---|
| 10 | #import "Issue492WindowDelegate.h"
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | @implementation Issue492AppDelegate
|
|---|
| 14 |
|
|---|
| 15 | -(void) applicationDidFinishLaunching:(NSNotification *)aNotification {
|
|---|
| 16 |
|
|---|
| 17 | //#ifdef WINDOWS
|
|---|
| 18 | // OBJCEnableMsgTracing();
|
|---|
| 19 | //#endif
|
|---|
| 20 |
|
|---|
| 21 | NSTextStorage *textStorage;
|
|---|
| 22 | NSLayoutManager *layoutManager;
|
|---|
| 23 | NSTextContainer *textContainer;
|
|---|
| 24 | NSTextView *textView;
|
|---|
| 25 |
|
|---|
| 26 | NSRect windowRect = (NSRect){{0,0},{340,180}};
|
|---|
| 27 |
|
|---|
| 28 | window = [[[NSWindow alloc] initWithContentRect:windowRect
|
|---|
| 29 | styleMask:(NSTitledWindowMask |
|
|---|
| 30 | NSClosableWindowMask |
|
|---|
| 31 | NSMiniaturizableWindowMask |
|
|---|
| 32 | NSResizableWindowMask)
|
|---|
| 33 | backing:NSBackingStoreBuffered
|
|---|
| 34 | defer:YES]
|
|---|
| 35 | retain];
|
|---|
| 36 |
|
|---|
| 37 | Issue492WindowDelegate *delegate = [[Issue492WindowDelegate alloc] init];
|
|---|
| 38 | delegate.window = window;
|
|---|
| 39 | [window setDelegate:delegate];
|
|---|
| 40 |
|
|---|
| 41 | NSRect screenFrame = [[NSScreen mainScreen] frame];
|
|---|
| 42 | [window setFrameTopLeftPoint:(NSPoint){100,screenFrame.size.height-100}];
|
|---|
| 43 |
|
|---|
| 44 | textStorage = [[NSTextStorage alloc] initWithString:@"This is a test."];
|
|---|
| 45 | [textStorage setFont:[NSFont fontWithName:@"Courier New" size:12.0]];
|
|---|
| 46 | layoutManager = [[NSLayoutManager alloc] init];
|
|---|
| 47 | textContainer = [[NSTextContainer alloc] initWithContainerSize:windowRect.size];
|
|---|
| 48 |
|
|---|
| 49 | [textStorage addLayoutManager:layoutManager];
|
|---|
| 50 | [layoutManager release];
|
|---|
| 51 |
|
|---|
| 52 | [layoutManager addTextContainer:textContainer];
|
|---|
| 53 | [textContainer release];
|
|---|
| 54 |
|
|---|
| 55 | textView = [[NSTextView alloc] initWithFrame:windowRect textContainer:textContainer];
|
|---|
| 56 |
|
|---|
| 57 | [window setTitle:@"Test Window"];
|
|---|
| 58 | [window setContentView:textView];
|
|---|
| 59 | [textView release];
|
|---|
| 60 | [window performSelectorOnMainThread: @selector(makeKeyAndOrderFront:)
|
|---|
| 61 | withObject:nil
|
|---|
| 62 | waitUntilDone:NO];
|
|---|
| 63 |
|
|---|
| 64 | //#ifdef WINDOWS
|
|---|
| 65 | // OBJCDisableMsgTracing();
|
|---|
| 66 | //#endif
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | @end
|
|---|