File: windows.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 (192 lines) | stat: -rw-r--r-- 5,242 bytes parent folder | download | duplicates (4)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* 
   windows.m

   Multiple windows

   Copyright (C) 1997 Free Software Foundation, Inc.

   Author:  Scott Christley <scottc@net-community.com>
   Date: March 1997
   
   This file is part of the GNUstep GUI X/RAW Backend.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ 

#import <Foundation/NSAutoreleasePool.h>
#import <AppKit/AppKit.h>
#include "TestView.h"

@interface windowsController : NSObject
{
  id textField;
  id textField1;
}

@end

@implementation windowsController
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
  NSWindow *w0, *w1, *w2;
  NSRect wf0 = {{250, 400}, {500, 500}};
  NSRect wf1 = {{500, 100}, {500, 500}};
  NSRect wf2 = {{50, 50}, {300, 500}};
  TestView *v;
  NSView *v1, *v2;
  NSButton *mpush, *ponpoff, *toggle, *swtch, *radio, *mchange, *onoff;
  NSRect bf0 = {{5, 5}, {200, 50}};
  NSRect bf1 = {{5, 65}, {90, 45}};
  NSRect bf2 = {{5, 115}, {90, 26}};
  NSRect bf3 = {{5, 170}, {200, 26}};
  NSRect bf4 = {{5, 225}, {200, 26}};
  NSRect bf5 = {{5, 280}, {200, 50}};
  NSRect bf6 = {{5, 335}, {200, 50}};
  NSSlider *s0;
  NSRect sf0 = {{25, 325}, {100, 50}};

  NSTextField *t0, *t1, *t2, *t3;
  NSRect tf0 = {{25, 25}, {200, 50}};
  NSRect tf1 = {{25, 100}, {200, 50}};
  NSRect tf2 = {{25, 175}, {200, 50}};
  NSRect tf3 = {{25, 250}, {200, 50}};

  //
  // Windows
  //
  w0 = [[NSWindow alloc] init];
  [w0 setTitle:@"Graphics Testing"];

  v = [[TestView alloc] init];
  [w0 setContentView: v];
  [w0 setFrame:wf0 display:YES];

  w1 = [[NSWindow alloc] init];
  [w1 setTitle: @"Second Window"];
  v1 = [w1 contentView];

  mpush = [[NSButton alloc] initWithFrame: bf0];
  [mpush setTitle: @"MomentaryPush"];

  ponpoff = [[NSButton alloc] initWithFrame: bf1];
  [ponpoff setButtonType:NSToggleButton];
  [ponpoff setTitle: @"Toggle"];
  [ponpoff setAlternateTitle: @"Alternate"];
  [ponpoff setImage:[NSImage imageNamed:@"common_SwitchOff"]];
  [ponpoff setAlternateImage:[NSImage imageNamed:@"common_SwitchOn"]];
  [ponpoff setImagePosition:NSImageAbove];
  [ponpoff setAlignment:NSCenterTextAlignment];

  toggle = [[NSButton alloc] initWithFrame: bf2];
  [toggle setButtonType: NSToggleButton];
  [toggle setTitle: @"Toggle"];

  swtch = [[NSButton alloc] initWithFrame: bf3];
  [swtch setButtonType: NSSwitchButton];
  [swtch setBordered: NO];
  [swtch setTitle: @"Switch"];
  [swtch setAlternateTitle: @"Alternate"];

  radio = [[NSButton alloc] initWithFrame: bf4];
  [radio setButtonType: NSRadioButton];
  [radio setBordered: NO];
  [radio setTitle: @"Radio"];
  [radio setAlternateTitle: @"Alternate"];

  mchange = [[NSButton alloc] initWithFrame: bf5];
  [mchange setButtonType: NSMomentaryChangeButton];
  [mchange setTitle: @"MomentaryChange"];
  [mchange setAlternateTitle: @"Alternate"];

  onoff = [[NSButton alloc] initWithFrame: bf6];
  [onoff setButtonType: NSOnOffButton];
  [onoff setTitle: @"OnOff"];

  [v1 addSubview: mpush];
  [v1 addSubview: ponpoff];
  [v1 addSubview: toggle];
  [v1 addSubview: swtch];
  [v1 addSubview: radio];
  [v1 addSubview: mchange];
  [v1 addSubview: onoff];

  [w1 setFrame: wf1 display: YES];

  w2 = [[NSWindow alloc] init];
  [w2 setTitle: @"Third Window"];
  v2 = [w2 contentView];

  t0 = [[NSTextField alloc] initWithFrame: tf0];
  t1 = [[NSTextField alloc] initWithFrame: tf1];
  [t1 setAlignment: NSRightTextAlignment];
  t2 = [[NSTextField alloc] initWithFrame: tf2];
  [t2 setAlignment: NSCenterTextAlignment];
  t3 = [[NSTextField alloc] initWithFrame: tf3];
  [t3 setBordered: NO];
  [t3 setTextColor: [NSColor redColor]];
  [t0 setNextText: t3];
  [t1 setNextText: t0];
  [t2 setNextText: t1];
  [t3 setNextText: t2];
  [v2 addSubview: t0];
  [v2 addSubview: t1];
  [v2 addSubview: t2];
  [v2 addSubview: t3];

  s0 = [[NSSlider alloc] initWithFrame: sf0];
  [v2 addSubview: s0];

  [w2 setFrame: wf2 display: YES];

  {
    NSMenu	*menu = [NSMenu new];

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

  [w0 orderFrontRegardless];
  [w1 orderFrontRegardless];
  [w2 orderFrontRegardless];

}
@end


//
// my main for the test app
//
int
main(int argc, char **argv, char** env)
{
  id pool = [NSAutoreleasePool new];
  NSApplication *theApp;

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

  theApp = [NSApplication sharedApplication];
  [theApp setDelegate: [windowsController new]];
  [theApp run];

  [pool release];

  return 0;
}