File: NSPanelTest.m

package info (click to toggle)
gnustep-examples 1%3A1.2.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,952 kB
  • ctags: 270
  • sloc: objc: 14,381; makefile: 65
file content (848 lines) | stat: -rw-r--r-- 25,630 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
/*****************************************************************************
FILE:               NSPanelTest.m
LANGUAGE:           Objective-C
SYSTEM:             GNUstep
USER-INTERFACE:     None
DESCRIPTION

    This application is a test bed for the NSPanel functions.

AUTHORS
    <PJB> Pascal J. Bourguignon <pjb@imaginet.fr>
MODIFICATIONS
    2000-03-05 <PJB> Creation.
BUGS
LEGAL
    Written by:  Pascal J. Bourguignon <pjb@imaginet.fr>

    Copyright (C) 2000 Free Software Foundation, Inc.

    This  library is  free software;  you can  redistribute  it and/or
    modify it under the terms of the GNU Lesser 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
    Lesser General Public License for more details.

    You should have  received a copy of the  GNU Lesser General Public
    License  along  with this  library;  if  not,  write to  the  Free
    Software  Foundation, Inc.,  59 Temple  Place, Suite  330, Boston,
    MA 02111-1307 USA
*****************************************************************************/
#import "NSPanelTest.h"
#include <stdlib.h>


////////////////////////////////////////////////////////////////////////

@interface PanelConstructor:NSObject
{
}

// This is an abstract class. Please use the subclasses.

    -(NSString*)panelName;

    -(id)getPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat;

    -(int)runPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat;

    -(int)runLocalizedPanelFromTable:(NSString*)table
                           withTitle:(NSString*)title
                              format:(NSString*)format
                       defaultButton:(NSString*)desfaux
                     alternateButton:(NSString*)alternate
                         otherButton:(NSString*)other
                       andWithObject:(id)forFormat;

@end //PanelConstructor;

////////////////////////////////////////////////////////////////////////


@implementation PanelConstructor

-(NSString*)panelName
{
  [self subclassResponsibility:_cmd];
  return nil;
}


-(id)getPanelTitled:(NSString*)title
	 withFormat:(NSString*)format
      defaultButton:(NSString*)desfaux
    alternateButton:(NSString*)alternate
	otherButton:(NSString*)other
      andWithObject:(id)forFormat
{
  [self subclassResponsibility:_cmd];
  return nil;
}//getPanelTitled:...;


-(int)runPanelTitled:(NSString*)title
	  withFormat:(NSString*)format
       defaultButton:(NSString*)desfaux
     alternateButton:(NSString*)alternate
	 otherButton:(NSString*)other
       andWithObject:(id)forFormat;
{
  [self subclassResponsibility:_cmd];
  return 0;
}//runPanelTitled:...;


-(int)runLocalizedPanelFromTable:(NSString*)table
		       withTitle:(NSString*)title
			  format:(NSString*)format
		   defaultButton:(NSString*)desfaux
		 alternateButton:(NSString*)alternate
		     otherButton:(NSString*)other
		   andWithObject:(id)forFormat
{
  [self subclassResponsibility:_cmd];
  return 0;
}//runLocalizedPanelTitled:...;


@end //PanelConstructor;

////////////////////////////////////////////////////////////////////////

@interface AlertPanelConstructor:PanelConstructor
{
}

/*
  RETURN:     the singleton instance of this class.
*/
+(id)instance;

// overwrites all the methods of its superclass.

@end //AlertPanelConstructor;

////////////////////////////////////////////////////////////////////////

@implementation AlertPanelConstructor

+(id)instance
    {
        static id instance=nil;
        if(instance==nil){
            instance=[[self alloc]init];
        }
        return(instance);
    }//instance;


    -(NSString*)panelName
    {
        return(@"Alert Panel");
    }//panelName;


    -(id)getPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat
    {
        return(NSGetAlertPanel(title,format,desfaux,alternate,other,forFormat));
    }//getPanelTitled:...;


    -(int)runPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat;
    {
        return(NSRunAlertPanel(title,format,desfaux,alternate,other,forFormat));
    }//runPanelTitled:...;


    -(int)runLocalizedPanelFromTable:(NSString*)table
                           withTitle:(NSString*)title
                              format:(NSString*)format
                       defaultButton:(NSString*)desfaux
                     alternateButton:(NSString*)alternate
                         otherButton:(NSString*)other
                       andWithObject:(id)forFormat;
    {
#ifndef	STRICT_MACOS_X
        return(NSRunLocalizedAlertPanel(table,title,format,desfaux,alternate,
                                        other,forFormat));
#else
        return(NSRunAlertPanel(@"Unavailable Function",
                               @"The function NSRunLocalizedAlertPanel is not"
                               @"available on STRICT_MACOS_X hosts.\n"
                               @"%@",
                               @"OK",nil,nil,
                               @"Please use GNUstep instead of MacOSX to "
                               @"profit of all the advantages of a good "
                               @"OpenStep implementation."));
#endif
    }//runLocalizedPanelTitled:...;


@end //AlertPanelConstructor;

////////////////////////////////////////////////////////////////////////

@interface CriticalPanelConstructor:PanelConstructor
{
}

    +(id)instance;
        /*
            RETURN:     the singleton instance of this class.
        */

// overwrites all the methods of its superclass.

@end //CriticalPanelConstructor;

////////////////////////////////////////////////////////////////////////

@implementation CriticalPanelConstructor

    +(id)instance
    {
        static id instance=nil;
        if(instance==nil){
            instance=[[self alloc]init];
        }
        return(instance);
    }//instance;


    -(NSString*)panelName
    {
        return(@"Critical Panel");
    }//panelName;


    -(id)getPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat
    {
#ifndef	STRICT_OPENSTEP
        return(NSGetCriticalAlertPanel(title,format,desfaux,alternate,
                                       other,forFormat));
#else
        return(NSGetAlertPanel(@"Unavailable Function"
                               @"The function NSGetCriticalAlertPanel is not"
                               @"available on STRICT_OPENSTEP hosts.\n"
                               @"%@",
                               @"OK",nil,nil,
                               @"Please use GNUstep instead of MacOSX to "
                               @"profit of all the advantages of a true and "
                               @"untarnished OpenStep implementation."));
#endif
    }//getPanelTitled:...;


    -(int)runPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat;
    {
#ifndef	STRICT_OPENSTEP
        return(NSRunCriticalAlertPanel(title,format,desfaux,alternate,
                                       other,forFormat));
#else
        return(NSRunAlertPanel(@"Unavailable Function"
                               @"The function NSRunCriticalAlertPanel is not"
                               @"available on STRICT_OPENSTEP hosts.\n"
                               @"%@",
                               @"OK",nil,nil,
                               @"Please use GNUstep instead of MacOSX to "
                               @"profit of all the advantages of a true and "
                               @"untarnished OpenStep implementation."));
#endif
    }//getPanelTitled:...;


    -(int)runLocalizedPanelFromTable:(NSString*)table
                           withTitle:(NSString*)title
                              format:(NSString*)format
                       defaultButton:(NSString*)desfaux
                     alternateButton:(NSString*)alternate
                         otherButton:(NSString*)other
                       andWithObject:(id)forFormat;
    {
        // Not available for critical panels.
      return 0;
    }//runLocalizedPanelTitled:...;


@end //CriticalPanelConstructor;

////////////////////////////////////////////////////////////////////////


@interface InformationalPanelConstructor:PanelConstructor
{
}

    +(id)instance;
        /*
            RETURN:     the singleton instance of this class.
        */

// overwrites all the methods of its superclass.

@end //InformationalPanelConstructor;

////////////////////////////////////////////////////////////////////////

@implementation InformationalPanelConstructor

    +(id)instance
    {
        static id instance=nil;
        if(instance==nil){
            instance=[[self alloc]init];
        }
        return(instance);
    }//instance;


    -(NSString*)panelName
    {
        return(@"Informational Panel");
    }//panelName;


    -(id)getPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat
    {
#ifndef	STRICT_OPENSTEP
        return(NSGetInformationalAlertPanel(title,format,desfaux,alternate,
                                       other,forFormat));
#else
        return(NSGetAlertPanel(@"Unavailable Function"
                               @"The function NSGetInformationalAlertPanel is "
                               @"not available on STRICT_OPENSTEP hosts.\n"
                               @"%@",
                               @"OK",nil,nil,
                               @"Please use GNUstep instead of MacOSX to "
                               @"profit of all the advantages of a true and "
                               @"untarnished OpenStep implementation."));
#endif
    }//getPanelTitled:...;


    -(int)runPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat;
    {
#ifndef	STRICT_OPENSTEP
        return(NSRunInformationalAlertPanel(title,format,desfaux,alternate,
                                       other,forFormat));
#else
        return(NSRunAlertPanel(@"Unavailable Function"
                               @"The function NSRunInformationalAlertPanel is "
                               @"not available on STRICT_OPENSTEP hosts.\n"
                               @"%@",
                               @"OK",nil,nil,
                               @"Please use GNUstep instead of MacOSX to "
                               @"profit of all the advantages of a true and "
                               @"untarnished OpenStep implementation."));
#endif
    }//getPanelTitled:...;


    -(int)runLocalizedPanelFromTable:(NSString*)table
                           withTitle:(NSString*)title
                              format:(NSString*)format
                       defaultButton:(NSString*)desfaux
                     alternateButton:(NSString*)alternate
                         otherButton:(NSString*)other
                       andWithObject:(id)forFormat;
    {
        // Not available for informational panels.
      return 0;
    }//runLocalizedPanelTitled:...;


@end //InformationalPanelConstructor;

////////////////////////////////////////////////////////////////////////

@interface RandomPanelConstructor:PanelConstructor
{
}

// This is an abstract class. Please use the subclasses.

    -(id)getPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat;

    -(int)runPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat;

    -(int)runLocalizedPanelFromTable:(NSString*)table
                           withTitle:(NSString*)title
                              format:(NSString*)format
                       defaultButton:(NSString*)desfaux
                     alternateButton:(NSString*)alternate
                         otherButton:(NSString*)other
                       andWithObject:(id)forFormat;

@end //RandomPanelConstructor;

////////////////////////////////////////////////////////////////////////


@implementation RandomPanelConstructor

    static PanelConstructor* choice[3];

    +(void)initialize
    {
        choice[0]=[[AlertPanelConstructor instance]retain];
        choice[1]=[[CriticalPanelConstructor instance]retain];
        choice[2]=[[InformationalPanelConstructor instance]retain];
    }//initialize;


    +(id)instance
    {
        static id instance=nil;
        if(instance==nil){
            instance=[[self alloc]init];
        }
        return(instance);
    }//instance;


    -(int)random
    {
        return(rand()%3);
    }//random;


    -(NSString*)panelName
    {
        return(@"Either Alert, Critical or Informational");
    }//panelName;


    -(id)getPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat
    {
        return([choice[[self random]] getPanelTitled:title
                      withFormat:format
                      defaultButton:desfaux
                      alternateButton:alternate
                      otherButton:other
                      andWithObject:forFormat]);
    }//getPanelTitled:...;


    -(int)runPanelTitled:(NSString*)title
             withFormat:(NSString*)format
          defaultButton:(NSString*)desfaux
        alternateButton:(NSString*)alternate
            otherButton:(NSString*)other
          andWithObject:(id)forFormat;
    {
        return([choice[[self random]] runPanelTitled:title
                      withFormat:format
                      defaultButton:desfaux
                      alternateButton:alternate
                      otherButton:other
                      andWithObject:forFormat]);
    }//runPanelTitled:...;


    -(int)runLocalizedPanelFromTable:(NSString*)table
                           withTitle:(NSString*)title
                              format:(NSString*)format
                       defaultButton:(NSString*)desfaux
                     alternateButton:(NSString*)alternate
                         otherButton:(NSString*)other
                       andWithObject:(id)forFormat
    {
        return([choice[[self random]] runLocalizedPanelFromTable:table
                      withTitle:title
                      format:format
                      defaultButton:desfaux
                      alternateButton:alternate
                      otherButton:other
                      andWithObject:forFormat]);
    }//runLocalizedPanelTitled:...;

@end //RandomPanelConstructor;

////////////////////////////////////////////////////////////////////////

@implementation NSPanelTest


-(id)init
{
  self=[super init];
  if(self!=nil){
    constructor=[AlertPanelConstructor instance];
  }
  return(self);
}//init;


-(void)dealloc
{
  [super dealloc];
}//dealloc;


-(void)applicationWillFinishLaunching:(NSNotification*)notification
{
  [NSApp setMainMenu:[self makeMenu]];
}//applicationDidFinishLaunching:;


// tests:

-testHighMessagePanel:sender
{
  NSMutableString* message=[NSMutableString stringWithFormat:
					      @"Let's see how many lines can be shown on this screen...\n"];
  int i;
  int result;

  for(i=0;i<100;i++){
    [message appendFormat:@"Line %d\n",i];
  }
  result=[constructor runPanelTitled:@"Testing Height"
		      withFormat:message
		      defaultButton:@"Yes"
		      alternateButton:@"No"
		      otherButton:@"May be"
		      andWithObject:nil];
  NSLog(@"Testing Height NSRunAlertPanel returned %d\n",result);
  return(self);
}//testHighMessagePanel:;


-testLargeMessagePanel:sender
{
  NSMutableString* message=[NSMutableString stringWithFormat:
					      @"A long line: "];
  int i;
  int result;

  message=[NSMutableString stringWithFormat:@"Hello"];
  for(i=0;i<100;i++){
    [message appendFormat:@", number %d",i];
  }
  result=[constructor runPanelTitled:@"Testing Width"
		      withFormat:message
		      defaultButton:@"Yes"
		      alternateButton:@"No"
		      otherButton:@"May be"
		      andWithObject:nil];
  NSLog(@"Testing Width  NSRunAlertPanel returned %d\n",result);
  return(self);
}//testLargeMessagePanel:;


-testSmallPanel:sender
{
  int result;
  result=[constructor runPanelTitled:@"Testing Small"
		      withFormat:@"Small?"
		      defaultButton:@"Yes"
		      alternateButton:@"No"
		      otherButton:@"May be"
		      andWithObject:nil];
  NSLog(@"Testing Small  NSRunAlertPanel returned %d\n",result);
  return self;
}//testSmalPanel:;


-testLargeTitlePanel:sender
{
  int result;
  result=[constructor runPanelTitled:@"Testing with a very, very, very long title, that should go well over one screen width, even on very, very, very large screens, and this is just to see what would happen in such a case."
		      withFormat:@"Large enough?"
		      defaultButton:@"Yes"
		      alternateButton:@"No"
		      otherButton:@"May be"
		      andWithObject:nil];
  NSLog(@"Testing Large Title  NSRunAlertPanel returned %d\n",result);
  return self;
}//testLargeTitlePanel:;



-testGettingPanel:sender
{
  int result;
  NSPanel* panel;
  panel=[constructor getPanelTitled:@"Getting a panel"
		     withFormat:@"This panel was built with \n"
		     @"NSGetAlertPanel."
		     defaultButton:@"Yes"
		     alternateButton:@"No"
		     otherButton:@"May be"
		     andWithObject:nil];
  if(panel!=nil){
    result=[[NSApplication sharedApplication]runModalForWindow:panel];
    NSLog(@"Testing NSGetAlertPanel, runModalForWindow returned %d\n",result);
    if([panel isVisible]){
      [panel close];
    }
    NSReleaseAlertPanel(panel);
  }
  return self;
}//testGettingPanel:;


-testLocalizedPanel:sender
{
  int result;
  result=[constructor runLocalizedPanelFromTable:@"Test"
		      withTitle:@"Testing Localized"
		      format:@"This message should be read in French."
		      defaultButton:@"Yes"
		      alternateButton:@"No"
		      otherButton:@"May be"
		      andWithObject:nil];
  NSLog(@"Testing NSRunLocalizedAlertPanel returned %d\n",result);
  return self;
}//testLocalizedPanel:;


-testMultilineBtnPanel:sender
{
  int result;
  result=[constructor runPanelTitled:@"Testing With Multiline Buttons"
		      withFormat:@"Two lines of message\n"
		      @"and four lines of button."
		      defaultButton:@"Yes!\nOui !\nJa !\n Si !"
		      alternateButton:@"No"
		      otherButton:@"May be"
		      andWithObject:nil];
  NSLog(@"Testing multiline buttons NSRunAlertPanel returned %d\n",
	result);
  return self;
}//testMultilineBtnPanel:;


-testTitleLessPanel:sender
{
  int result;
  result=[constructor runPanelTitled:nil
		      withFormat:@"This panel should be titleless,\n"
		      @"or not, depending on its kind:"
		      @"%@."
		      defaultButton:@"Yes"
		      alternateButton:@"No"
		      otherButton:@"May be"
		      andWithObject:[constructor panelName]];
  NSLog(@"Testing titleless NSRunAlertPanel returned %d\n",result);
  return self;
}//testTitleLessPanel;



-testMissingBtnRunPanel:sender
{
  int buttons;
  for(buttons=0;buttons<8;buttons++){
    int result=[constructor runPanelTitled:@"Testing NSRunModalPanel With Missing Buttons"
			    withFormat:@"When no button is available,\n"
			    @"you should be able to close the\n"
			    @"panel with the escape key.\n"
			    @"(%@/7)"
			    defaultButton:((buttons&1)?@"Yes":nil)
			    alternateButton:((buttons&2)?@"No":nil)
			    otherButton:((buttons&4)?@"May Be":nil)
			    andWithObject:[NSNumber numberWithInt:buttons]];
    NSLog(@"Testing buttons (%d/7) NSRunAlertPanel returned %d\n",buttons,result);
  }
  return self;
}//testMissingButtonRunPanel:;


-testMissingBtnGetPanel:sender
{
  int buttons;
  for(buttons=0;buttons<8;buttons++){
    NSPanel* panel=[constructor 
		     getPanelTitled:@"Testing NSGetModalPanel With Missing Buttons"
		     withFormat:@"When no button is available,\n"
		     @"you should be able to close the\n"
		     @"panel with the escape key.\n"
		     @"(%@/7)"
		     defaultButton:((buttons&1)?@"Yes":nil)
		     alternateButton:((buttons&2)?@"No":nil)
		     otherButton:((buttons&4)?@"May Be":nil)
                     andWithObject:[NSNumber numberWithInt:buttons]];
    if(panel!=nil){
      int  result=[[NSApplication sharedApplication]
		    runModalForWindow:panel];
      NSLog(@"Testing buttons (%d/7) NSGetAlertPanel, runModalForWindow returned %d\n",buttons,result);
      if([panel isVisible]){
	[panel close];
      }
      NSReleaseAlertPanel(panel);
    }
  }
  return self;
}//testMissingBtnGetPanel:;


-testAll:sender
{
  [self testHighMessagePanel:sender];
  [self testLargeMessagePanel:sender];
  [self testSmallPanel:sender];
  [self testLargeTitlePanel:sender];
  [self testGettingPanel:sender];
  [self testLocalizedPanel:sender];
  [self testMultilineBtnPanel:sender];
  [self testTitleLessPanel:sender];
  [self testMissingBtnRunPanel:sender];
  [self testMissingBtnGetPanel:sender];
  return(self);
}//testAll:;


// actions:


-showInformations:sender
{
  [[NSApplication sharedApplication] orderFrontStandardInfoPanel: self];
  return(self);
}//showInformations:;


-useAlertPanels:sender
{
  constructor=[AlertPanelConstructor instance];
  return(self);
}//useAlertPanels:;


-useCriticalPanels:sender
{
  constructor=[CriticalPanelConstructor instance];
  return(self);
}//useCriticalPanels:;


-useInformationalPanels:sender
{
  constructor=[InformationalPanelConstructor instance];
  return(self);
}//useInformationalPanels:;


-useRandomPanels:sender
{
  constructor=[RandomPanelConstructor instance];
  return(self);
}//useRandomPanels:;


@end // NSPanelTest;

////////////////////////////////////////////////////////////////////////

@implementation NSPanelTest(Protected)
  
-(NSMenu*)makeMenu
{
  id item;
  NSMenu*     menu;
  NSMenu*     subm;

#define makeitem(menu,tit,sel,key)					\
  item=[menu addItemWithTitle:tit action:@selector(sel)			\
	     keyEquivalent:key]; [item setEnabled:YES]; [item setTarget:self]

  menu=[[NSMenu alloc] initWithTitle:[[self class]description]];
  makeitem(menu,@"Informations",           showInformations:,       @"i");
        
  subm=[[NSMenu alloc] initWithTitle:@"Panel Kind"];
  makeitem(subm,@"Use Alert Panels",        useAlertPanels:,        @"");
  makeitem(subm,@"Use Critical Panels",     useCriticalPanels:,     @"");
  makeitem(subm,@"Use Informational Panels",useInformationalPanels:,@"");
  makeitem(subm,@"Use Random Panels",       useRandomPanels:,       @"");
  makeitem(menu,@"Panel Kind",              submenuAction:,         @"");
  [menu setSubmenu:subm forItem:item];

  subm=[[NSMenu alloc] initWithTitle:@"Tests"];
  makeitem(subm,@"All",                     testAll:,              @"0");
  makeitem(subm,@"High Message",            testHighMessagePanel:, @"1");
  makeitem(subm,@"Large Message",           testLargeMessagePanel:,@"2");
  makeitem(subm,@"Small Message",           testSmallPanel:,       @"3");
  makeitem(subm,@"Large Title",             testLargeTitlePanel:,  @"4");
  makeitem(subm,@"NSGetAlertPanel",         testGettingPanel:,     @"5");
  makeitem(subm,@"NSRunLocalizedAlertPanel",testLocalizedPanel:,   @"6");
  makeitem(subm,@"Multiline Buttons",       testMultilineBtnPanel:,@"7");
  makeitem(subm,@"Without Title",           testTitleLessPanel:,   @"8");
  makeitem(subm,@"Missing Buttons (Run)", testMissingBtnRunPanel:, @"9");
  makeitem(subm,@"Missing Buttons (Get)", testMissingBtnGetPanel:, @"a");
  makeitem(menu,@"Tests",                   submenuAction:,        @"");
  [menu setSubmenu:subm forItem:item];

  makeitem(menu,@"Hide",                     hide:,                 @"h");
  makeitem(menu,@"Quit",                     terminate:,            @"q");

  [menu sizeToFit];
  return(menu);
}//makeMenu;




@end // NSPanelTest(Protected).


/*** NSPanelTest.m                    -- 2000-03-10 13:11:30 -- PJB ***/