home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextLibrary / Documentation / NextDev / Examples / Little / little.m < prev    next >
Encoding:
Text File  |  1995-02-01  |  2.2 KB  |  91 lines

  1. /*  little.m
  2.  *
  3.  *  A minimal program designed to show how the basic objects provided
  4.  *  by the Application Kit fit together.  This program doesn't define
  5.  *  any classes of its own and doesn't use Interface Builder to set up
  6.  *  its user interface.
  7.  *
  8.  *  It has one standard window that you can type in, a main menu with
  9.  *  just the three basic commands, and an empty information panel that
  10.  *  contains no information.  Nevertheless, all three windows behave
  11.  *  exactly as they would in a more elaborate application.
  12.  */
  13.  
  14.  
  15. #import <appkit/appkit.h>
  16.  
  17. void setUp(void)
  18. {
  19.     id     myWindow, myPanel, myMenu, windowText;
  20.     NXRect     aRect;
  21.  
  22.  
  23.     /*** Step 1:  Set up a Window ***/
  24.     NXSetRect(&aRect, 100.0, 350.0, 300.0, 300.0);
  25.     myWindow = [[Window alloc] initContent:&aRect
  26.                     style:NX_TITLEDSTYLE
  27.                     backing:NX_BUFFERED
  28.                     buttonMask:NX_MINIATURIZEBUTTONMASK
  29.                     defer:NO];
  30.     [myWindow setTitle:"A Little Demonstration"];
  31.  
  32.     NXSetRect(&aRect, 0.0, 0.0, 300.0, 300.0);
  33.     windowText = [[Text alloc] initFrame:&aRect
  34.                     text:""
  35.                     alignment:NX_LEFTALIGNED];
  36.     [windowText setOpaque:YES];
  37.     [[myWindow contentView] addSubview:windowText];
  38.  
  39.  
  40.     /*** Step 2:  Set up a Panel ***/
  41.     NXSetRect(&aRect, 100.0, 700.0, 300.0, 40.0);
  42.     myPanel = [[Panel alloc] initContent:&aRect
  43.                     style:NX_TITLEDSTYLE
  44.                     backing:NX_BUFFERED
  45.                     buttonMask:NX_CLOSEBUTTONMASK
  46.                     defer:YES];
  47.     [myPanel setTitle:"About Little"];
  48.     [myPanel removeFromEventMask:(NX_KEYDOWNMASK | NX_KEYUPMASK)];
  49.  
  50.  
  51.     /*** Step 3:  Set up a Menu ***/
  52.     myMenu = [[Menu alloc] initTitle:"Little"];
  53.     [[myMenu addItem:"Info..."
  54.             action:@selector(orderFront:)
  55.             keyEquivalent:'\0']
  56.             setTarget:myPanel];
  57.     [myMenu addItem:"Hide"
  58.             action:@selector(hide:)
  59.             keyEquivalent:'h'];
  60.     [myMenu addItem:"Quit"
  61.             action:@selector(terminate:)
  62.             keyEquivalent:'q'];
  63.     [myMenu sizeToFit];
  64.     [NXApp setMainMenu:myMenu];
  65.  
  66.  
  67.     /*** Step 4:  Display all windows that aren't deferred ***/
  68.     [myWindow display];
  69.  
  70.  
  71.     /*** Step 5:  Move the principal window on-screen ***/
  72.     [myWindow orderFront:nil];
  73.  
  74.  
  75.     /*** Step 6:  Make it the key window ***/
  76.     [myWindow makeKeyWindow];
  77.  
  78.  
  79.     /*** Step 7:  Show a selection in the key window ***/
  80.     [windowText selectAll:nil];
  81. }
  82.  
  83.  
  84. main()
  85. {
  86.     [Application new];
  87.     setUp();
  88.     [NXApp run];
  89.     [NXApp free];
  90. }
  91.