home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Examples / MiscClassDecoder / MiscClassDecoder.bproj / MiscClassDecoderSetup.m < prev    next >
Encoding:
Text File  |  1994-11-26  |  2.2 KB  |  96 lines

  1. //
  2. // Time-stamp: <94/11/26 17:10:03 stephan>
  3. //
  4. //    MiscClassDecoderSetup.m -- load a MiscClassDecoder window into
  5. //    any application.
  6. //    
  7. //        Written by Stephan Wacker <stephan@rodion.muc.de>
  8. //        Copyright (c) 1994 by Stephan Wacker.
  9. //        Version 1.0  All rights reserved.
  10. //
  11. //        This notice may not be removed from this source code.
  12. //
  13. //    This object is included in the MiscKit by permission from the author
  14. //    and its use is governed by the MiscKit license, found in the file
  15. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  16. //    for a list of all applicable permissions and restrictions.
  17. //
  18.  
  19. #if 0 // Description
  20. #
  21.  
  22. How can you create a window in another person's app?
  23.  
  24. 1) Start the app from gdb and let it run.
  25. 2) When the app has initialized, stop it with Ctrl-C.
  26. 3) Issue these commands:
  27.       print [[[[NXBundle alloc] initForDirectory: "/LocalDeveloper/Examples/MiscKit/MiscClassDecoder.app/MiscClassDecoder.bundle"] classNamed: "MiscClassDecoderSetup"] new]
  28.       continue
  29.  
  30. That sould give you a MiscClassDecoder window. 
  31.  
  32. #
  33. #endif // Description
  34.  
  35.  
  36. #import "MiscClassDecoderSetup.h"
  37.  
  38. #define K_MyBundleName    "MiscClassDecoder"
  39.  
  40.  
  41. @implementation MiscClassDecoderSetup
  42.  
  43.  
  44. - init
  45. // Create one instance of the interface.
  46. {
  47.     char    nibPath[MAXPATHLEN + 1];
  48.     NXBundle    *bundle;
  49.     
  50.     if( ! (bundle = [NXBundle bundleForClass:[self class]]) )
  51.     {
  52.     NXRunAlertPanel( [[self class] name],
  53.              "Cannot find my bundle",
  54.              NULL, NULL, NULL );
  55.     return nil;
  56.     }
  57.     
  58.     // printf( "Bundle for directory %s loaded\n", [bundle directory] );
  59.     
  60.     if ( ! [bundle getPath: nibPath forResource: K_MyBundleName ofType: "nib"] )
  61.     {
  62.     NXRunAlertPanel( [[self class] name],
  63.              "Cannot find interface: " K_MyBundleName ".nib",
  64.              NULL, NULL, NULL );
  65.     return nil;
  66.     }
  67.     
  68.     if( ! [NXApp loadNibFile: nibPath owner: self] )
  69.     {
  70.     NXRunAlertPanel( [[self class] name],
  71.              "Cannot load interface: " K_MyBundleName ".nib",
  72.              NULL, NULL, NULL );
  73.     return nil;
  74.     }
  75.     
  76.     [window makeKeyAndOrderFront: self];
  77.     // [window setFloatingPanel: YES];
  78.     
  79.     return self;
  80. }
  81.  
  82.  
  83. - window
  84. {
  85.     return window;
  86. }
  87.  
  88.  
  89. - decoder
  90. {
  91.     return decoder;
  92. }
  93.  
  94.  
  95. @end    // MiscClassDecoderSetup
  96.