home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / Palettes / NibInfoPalette2B / NibInfoMethods / NibInfoMethods.m < prev    next >
Encoding:
Text File  |  1994-02-10  |  2.7 KB  |  117 lines

  1. // Robert Nicholson, Thu Feb 10 14:42:00 GMT 1994
  2. // Copyright, 1994. All rights reserved.
  3.  
  4. #import "NibInfoMethods.h"
  5. #import <string.h>
  6.  
  7. @implementation Object(NibInfoMethods)
  8.  
  9. // report header
  10. - NIBINFOReportHeader:(const char *)pathname toStream:(NXStream *)s
  11. {
  12.     NXPrintf(s,"Header for nib %s\n",pathname);
  13.     return self;
  14. }
  15.  
  16. // report trailer
  17. - NIBINFOReportTrailer:(const char *)pathname toStream:(NXStream *)s
  18. {
  19.     NXPrintf(s,"Trailer for nib %s\n",pathname);
  20.     return self;
  21. }
  22.  
  23. // header line for master object
  24. - NIBINFOheaderForObject:anObject toStream:(NXStream *)s
  25. {
  26.     NXPrintf(s,"%s",[[anObject class] name]);
  27.     if ([anObject respondsTo:@selector(NIBINFOinfoToStream:)]) {
  28.         [anObject NIBINFOinfoToStream:s];
  29.     }
  30.     NXPrintf(s,"\n");
  31.     return self;
  32. }
  33.  
  34. // detail information for source of connection.
  35. - NIBINFOdetailForSourceToStream:(NXStream *)s
  36. {
  37.     const char *sourceClassName;
  38.     
  39.     sourceClassName = [[self class] name];
  40.     NXPrintf(s,"\t%s",sourceClassName ? sourceClassName : "NULL");
  41.     return self;
  42. }
  43.  
  44. // detail information for desintation of connection.
  45. - NIBINFOdetailForDestToStream:(NXStream *)s
  46. {
  47.     const char *destClassName;
  48.     
  49.     destClassName = [[self class] name];
  50.     NXPrintf(s,"->%s",destClassName ? destClassName : "NULL");
  51.     return self;
  52. }
  53.  
  54. // selector/outlet for connection
  55. - NIBINFOselector:(const char *)selector toStream:(NXStream *)s
  56. {
  57.     char *slash=NULL;
  58.  
  59.     NXPrintf(s," ");
  60.     slash = rindex(selector,'/');
  61.     if (slash) {
  62.         NXPrintf(s,"[%s]",slash+1);
  63.     } else {
  64.         NXPrintf(s,"[%s]",selector);
  65.     }
  66.     NXPrintf(s,"\n");
  67.     return self;
  68. }
  69.  
  70. #import <dbkit/DBModule.h>
  71.  
  72. // destintation information
  73. - NIBINFOinfoToStream:(NXStream *)s
  74. {
  75.     const char *info=NULL;
  76.     // Unfortunately we are unable to use dynamic binding on 
  77.     // IB's Template classes.  eg. WindowTemplate, DBModuleTemplate
  78.     // MenuTemplate. "Template" classes are substitutes for real classes during
  79.     // edit mode. They are all Object subclasses.
  80.  
  81.     if (!strcmp([[self class] name],"DBModuleTemplate")) {
  82.         char name[MAXPATHLEN+1];
  83.         const char *database;
  84.         const char *entity;
  85.  
  86.         database = (const char *)[[(DBModule *)self database] name];
  87.         entity =(const char *)[[(DBModule *)self entity] name];
  88.         sprintf(name,"%s->%s",database,entity);
  89.         info = name;
  90.     } else {
  91.         if ([self respondsTo:@selector(title)]) {
  92.             info=(const char *)[self perform:@selector(title)];
  93.         }
  94.     }
  95.     if (info && *info) {
  96.         NXPrintf(s,"(\"%s\") ",info);
  97.     } else {
  98.         NXPrintf(s,"(\"N/A\") ");
  99.     }
  100.     return self;
  101. }
  102.  
  103. @end
  104.  
  105. // customized for View subclasses in order to print frame information.
  106.  
  107. @implementation View(NibInfoMethods)
  108.  
  109. - NIBINFOinfoToStream:(NXStream *)s
  110. {
  111.     [super NIBINFOinfoToStream:s];
  112.     NXPrintf(s,"(%f %f %f %f)",NX_X(&frame),NX_Y(&frame),NX_WIDTH(&frame),NX_HEIGHT(&frame));
  113.     return self;
  114. }
  115.     
  116. @end
  117.