1 /* Example for use of GNU gettext.
2 Copyright (C) 2003 Free Software Foundation, Inc.
3 This file is in the public domain.
5 Source code of the Hello class. */
9 #include <GNUstepGUI/GSHbox.h>
10 #include <GNUstepGUI/GSVbox.h>
16 if ((self = [super init]))
27 - (void)makeKeyAndOrderFront
29 if (![window isVisible])
31 [window makeKeyAndOrderFront:self];
41 @implementation Hello (UIBuilder)
49 label1 = [NSTextField new];
50 [label1 setStringValue: _(@"Hello, world!")];
51 [label1 setAlignment: NSLeftTextAlignment];
52 [label1 setBordered: NO];
53 [label1 setEditable: NO];
54 [label1 setBezeled: NO];
55 [label1 setDrawsBackground: NO];
58 label2 = [NSTextField new];
59 [label2 setStringValue: [NSString stringWithFormat: _(@"This program is running as process number %d."), [[NSProcessInfo processInfo] processIdentifier]]];
60 [label2 setAlignment: NSLeftTextAlignment];
61 [label2 setBordered: NO];
62 [label2 setEditable: NO];
63 [label2 setBezeled: NO];
64 [label2 setDrawsBackground: NO];
67 okButton = [NSButton new];
68 [okButton setTitle: @"OK"];
69 [okButton setTarget: self];
70 [okButton setAction: @selector(done)];
71 [okButton setFrameSize: NSMakeSize(60,22)];
72 [okButton setAutoresizingMask: 7];
74 buttonbar = [GSHbox new];
75 [buttonbar setAutoresizingMask: NSViewMinXMargin];
76 [buttonbar addView: okButton];
77 AUTORELEASE (okButton);
80 // GSVbox is flawed: We have to add the controls bottom-up, and mark the
81 // last one (= the topmost one) as non-resizable in Y direction, so that the
82 // Y space becomes equally distributed _between_ (not above) the subviews.
83 [cview addView: buttonbar];
84 AUTORELEASE (buttonbar);
85 [cview addView: label2];
87 [cview addView: label1 enablingYResizing: NO];
90 window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0,0, [cview frame].size.width, [cview frame].size.height)
91 styleMask: (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask)
92 backing: NSBackingStoreBuffered
94 [window setDelegate: self];
95 [window setTitle: @"Hello example"];
96 [window setReleasedWhenClosed: NO];
97 [window setContentView: cview];