File: gstextnetwork.m

package info (click to toggle)
gnustep-examples 1%3A1.4.0%2Bgit20210703-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,164 kB
  • sloc: objc: 17,202; makefile: 56
file content (101 lines) | stat: -rw-r--r-- 2,868 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#import <Foundation/NSAutoreleasePool.h>
#import <AppKit/AppKit.h>
#import <AppKit/NSTextStorage.h>

@interface buttonsController : NSObject
{
  NSWindow *win;
  NSTextView *theTextView;
  NSScrollView *theScrollView;
}

@end

@implementation buttonsController
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
  NSRect wf = {{100, 100}, {400, 400}};
  NSRect f = {{10, 10}, {380, 200}};
  NSPopUpButton *pushb;
  NSView *aView;
  unsigned int style = NSTitledWindowMask | NSClosableWindowMask
		      | NSMiniaturizableWindowMask | NSResizableWindowMask;

  win = [[NSWindow alloc] initWithContentRect:wf
				    styleMask:style
				      backing:NSBackingStoreRetained
					defer:NO];

  theScrollView = [[NSScrollView alloc] initWithFrame:[[win contentView] frame]];

  [theScrollView setBorderType:NSNoBorder];
  [theScrollView setHasVerticalScroller:YES];
  [theScrollView setHasHorizontalScroller:NO];
  [theScrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];

  theTextView = [[NSTextView alloc]
initWithFrame:NSMakeRect(0,0,[theScrollView contentSize].width,
1e7)];
  [theTextView setMinSize:NSMakeSize(0.0, [theScrollView
contentSize].height)];
  [theTextView setMaxSize:NSMakeSize(1e7, 1e7)];
  [theTextView setVerticallyResizable:YES];
  [theTextView setHorizontallyResizable:NO];
  [theTextView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
  [theTextView setBackgroundColor:[NSColor whiteColor]];

  [[theTextView textContainer]
    setContainerSize:NSMakeSize([theScrollView contentSize].width, 1e7)];
//  [[theTextView textContainer] setWidthTracksTextView:YES];

  [theTextView setString:[NSString stringWithContentsOfFile:@"Readme.txt"]];

  [theScrollView setDocumentView:theTextView];
  [win setContentView:theScrollView];
  [win makeKeyAndOrderFront:nil];
  [win makeFirstResponder:theTextView];
  [win display];
}

@end

int
main(int argc, char **argv, char** env)
{
  id pool = [NSAutoreleasePool new];
  NSApplication *theApp;
  NSAttributedString *attributedString;
  NSString *funString = @"SomethingNothing";
  NSScanner *scanner;
  unsigned int sL;

#if LIB_FOUNDATION_LIBRARY
  [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
#endif

  theApp = [NSApplication sharedApplication];
  scanner = [[NSScanner alloc] initWithString:funString];
  [scanner scanUpToString:[NSText newlineString] intoString:NULL];
  sL = [scanner scanLocation];

  NSLog(@"%d", sL + 2);

  attributedString = [[NSAttributedString alloc] initWithString:@"Hey!"];
  NSLog(@"%@", [attributedString string]);

  [theApp setDelegate: [buttonsController new]];
  {
    NSMenu	*menu = [NSMenu new];

    [menu addItemWithTitle: @"Quit"
		    action: @selector(terminate:)
	     keyEquivalent: @"q"];
    [NSApp setMainMenu: menu];
  }

  [theApp run];

  [pool release];

  return 0;
}