InspectorControl.m 2.9 KB

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