home *** CD-ROM | disk | FTP | other *** search
/ Superpower (Alt) / SUPERPOWER.iso / q / source / inspecto.m < prev    next >
Encoding:
Text File  |  1996-08-08  |  2.9 KB  |  129 lines

  1.  
  2. #import "qedefs.h"
  3.  
  4. // Add .h-files here for new inspectors
  5. #import    "Things.h"
  6. #import    "TexturePalette.h"
  7. #import    "Preferences.h"
  8.  
  9. id        inspcontrol_i;
  10.  
  11. @implementation InspectorControl
  12.  
  13. - awakeFromNib
  14. {
  15.     inspcontrol_i = self;
  16.         
  17.     currentInspectorType = -1;
  18.  
  19.     contentList = [[List alloc] init];
  20.     windowList = [[List alloc] init];
  21.     itemList = [[List alloc] init];
  22.  
  23.     // ADD NEW INSPECTORS HERE...
  24.  
  25.     [windowList addObject:win_project_i];
  26.     [contentList addObject:[win_project_i contentView]];
  27.     [itemProject_i setKeyEquivalent:'1'];
  28.     [itemList addObject:itemProject_i];
  29.  
  30.     [windowList addObject:win_textures_i];
  31.     [contentList addObject:[win_textures_i contentView]];
  32.     [itemTextures_i setKeyEquivalent:'2'];
  33.     [itemList addObject:itemTextures_i];
  34.  
  35.     [windowList addObject:win_things_i];
  36.     [contentList addObject:[win_things_i contentView]];
  37.     [itemThings_i setKeyEquivalent:'3'];
  38.     [itemList addObject:itemThings_i];
  39.     
  40.     [windowList addObject:win_prefs_i];
  41.     [contentList addObject:[win_prefs_i contentView]];
  42.     [itemPrefs_i setKeyEquivalent:'4'];
  43.     [itemList addObject:itemPrefs_i];
  44.  
  45.     [windowList addObject:win_settings_i];
  46.     [contentList addObject:[win_settings_i contentView]];
  47.     [itemSettings_i setKeyEquivalent:'5'];
  48.     [itemList addObject:itemSettings_i];
  49.  
  50.     [windowList addObject:win_output_i];
  51.     [contentList addObject:[win_output_i contentView]];
  52.     [itemOutput_i setKeyEquivalent:'6'];
  53.     [itemList addObject:itemOutput_i];
  54.  
  55.     [windowList addObject:win_help_i];
  56.     [contentList addObject:[win_help_i contentView]];
  57.     [itemHelp_i setKeyEquivalent:'7'];
  58.     [itemList addObject:itemHelp_i];
  59.  
  60.     // Setup inspector window with project subview first
  61.  
  62.     [inspectorView_i setAutoresizeSubviews:YES];
  63.  
  64.     inspectorSubview_i = [contentList objectAt:i_project];
  65.     [inspectorView_i addSubview:inspectorSubview_i];
  66.  
  67.     currentInspectorType = -1;
  68.     [self changeInspectorTo:i_project];
  69.  
  70.     return self;
  71. }
  72.  
  73.  
  74. //
  75. //    Sent by the PopUpList in the Inspector
  76. //    Each cell in the PopUpList must have the correct tag
  77. //
  78. - changeInspector:sender
  79. {
  80.     id    cell;
  81.  
  82.     cell = [sender selectedCell];
  83.     [self changeInspectorTo:[cell tag]];
  84.     return self;
  85. }
  86.  
  87. //
  88. //    Change to specific Inspector
  89. //
  90. - changeInspectorTo:(insp_e)which
  91. {
  92.     id        newView;
  93.     NXRect    r;
  94.     id        cell;
  95.     NXRect    f;
  96.     
  97.     if (which == currentInspectorType)
  98.         return self;
  99.     
  100.     currentInspectorType = which;
  101.     newView = [contentList objectAt:which];
  102.     
  103.     cell = [itemList objectAt:which];    // set PopUpButton title
  104.     [popUpButton_i setTitle:[cell title]];
  105.     
  106.     [inspectorView_i replaceSubview:inspectorSubview_i with:newView];
  107.     [inspectorView_i getFrame:&r];
  108.     inspectorSubview_i = newView;
  109.     [inspectorSubview_i setAutosizing:NX_WIDTHSIZABLE | NX_HEIGHTSIZABLE];
  110.     [inspectorSubview_i sizeTo:r.size.width - 4 :r.size.height - 4];
  111.     
  112.     [inspectorSubview_i lockFocus];
  113.     [inspectorSubview_i getBounds:&f];
  114.     PSsetgray(NX_LTGRAY);
  115.     NXRectFill(&f);
  116.     [inspectorSubview_i unlockFocus];
  117.     [inspectorView_i display];
  118.     
  119.     return self;
  120. }
  121.  
  122. - (insp_e)getCurrentInspector
  123. {
  124.     return currentInspectorType;
  125. }
  126.  
  127.  
  128. @end
  129.