home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / Source / Resound / PreferencesManager.m < prev    next >
Encoding:
Text File  |  1992-06-13  |  3.6 KB  |  185 lines

  1.  
  2. /* 
  3.  
  4.  
  5. May 18 1992
  6. Feel free to modify this code and the application nib file to create your own preferences.
  7.  
  8. */
  9.  
  10. #import "PreferencesManager.h"
  11. #import "Imports.h"
  12.  
  13. @implementation PreferencesManager
  14.  
  15. - init
  16.  
  17. {
  18.     const NXDefaultsVector TheDefaults =
  19.         {
  20.             {"ContinuousZoom","NO"},
  21.             {"ContinuousUpdateSelection","NO"},
  22.             {"ContinuousUpdateView","NO"},
  23.             {"MinMaxDisplay","YES"},
  24.             
  25.             // etc., then
  26.             
  27.             {NULL,NULL}
  28.         };
  29.     
  30.     [super init];
  31.     NXRegisterDefaults ([NXApp appName], TheDefaults);
  32.     [self PerformPreferences];
  33.     return self;
  34. }
  35.  
  36.  
  37.  
  38. - SavePreferences
  39.  
  40. {
  41.     NXWriteDefault([NXApp appName],    "ContinuousZoom", [ContinuousZoomButton intValue]? "YES":"NO");
  42.     NXWriteDefault([NXApp appName],    "ContinuousUpdateSelection", [ContinuousUpdateSelectionButton intValue]? "YES":"NO");
  43.     NXWriteDefault([NXApp appName],    "ContinuousUpdateView", [ContinuousUpdateViewButton intValue]? "YES":"NO");
  44.     NXWriteDefault([NXApp appName],    "MinMaxDisplay", [MinMaxDisplayButton state]? "YES":"NO");
  45.     [self PerformPreferences];
  46.     return self;
  47. }
  48.  
  49.  
  50.  
  51. - PerformPreferences
  52. {
  53.      // Then read in the defaults and adjust the buttons, etc., on the
  54.     // preferences panel appropriately.
  55.     
  56.                                             NXGetDefaultValue ([NXApp appName],"ContinuousUpdateSelection");
  57.     
  58.     if (!strcmp(NXGetDefaultValue ([NXApp appName],"ContinuousZoom"), "NO"))
  59.         {
  60.         // Continuous Zoom is NO.
  61.         [ContinuousZoomButton setIntValue:0];
  62.         [TheEditController SetContinuousZoom:NO];
  63.         }
  64.     else
  65.         {
  66.         // Continuous Zoom is YES.
  67.         [ContinuousZoomButton setIntValue:1];
  68.         [TheEditController SetContinuousZoom:YES];
  69.         }
  70.         
  71.         
  72.     if (!strcmp(NXGetDefaultValue ([NXApp appName],"ContinuousUpdateSelection"), "NO"))
  73.         {
  74.         // Continuous Selection is No.
  75.         [ContinuousUpdateSelectionButton setIntValue:0];
  76.         }
  77.     else
  78.         {
  79.         // Continuous Selection is Yes.
  80.         [ContinuousUpdateSelectionButton setIntValue:1];
  81.         }
  82.  
  83.  
  84.     if (!strcmp(NXGetDefaultValue ([NXApp appName],"ContinuousUpdateView"), "NO"))
  85.         {
  86.         // Continuous View is No.
  87.         [ContinuousUpdateViewButton setIntValue:0];
  88.         }
  89.     else
  90.         {
  91.         // Continuous View is Yes.
  92.         [ContinuousUpdateViewButton setIntValue:1];
  93.         }        
  94.  
  95.  
  96.     if (!strcmp(NXGetDefaultValue ([NXApp appName],"MinMaxDisplay"), "YES"))
  97.         {
  98.         // MinMax is Yes.
  99.         [MinMaxDisplayButton setIntValue:1];
  100.         [OscilliscopicDisplayButton setIntValue:0];
  101.         }
  102.     else
  103.         {
  104.         // MinMax is No.
  105.         [MinMaxDisplayButton setIntValue:0];
  106.         [OscilliscopicDisplayButton setIntValue:1];
  107.         }        
  108.     
  109.         return self;
  110. }
  111.  
  112. - SoundComingIn                        // A nicer way for the FileManager to get the Preferences to know that the
  113.                                     // user has started working on sounds.  Use this as you like.
  114. {
  115.     [self PerformPreferences];
  116.     return self;
  117. }
  118.  
  119.  
  120.  
  121.  
  122.  
  123. // a preferences return item for FileController
  124.  
  125. - (BOOL) ContinuousSelection
  126. {
  127.     return (BOOL) (strcmp(NXGetDefaultValue ([NXApp appName],"ContinuousUpdateSelection"), "NO"));
  128. }
  129.  
  130.  
  131. // a preferences return item for FileController
  132.  
  133. - (BOOL) ContinuousView
  134. {
  135.     printf ("ContinuousView:  %d", (strcmp(NXGetDefaultValue ([NXApp appName],"ContinuousUpdateView"), "NO")));
  136.     return (BOOL) (strcmp(NXGetDefaultValue ([NXApp appName],"ContinuousUpdateView"), "NO"));
  137. }
  138.  
  139.  
  140.  
  141. // a preferences return item for FileController
  142.  
  143. - (int) MinMaxDisplay
  144. {
  145.     if  (strcmp(NXGetDefaultValue ([NXApp appName],"MinMaxDisplay"), "YES"))
  146.         {
  147.         printf("SKWave\n");
  148.         return  SK_DISPLAY_WAVE;
  149.         }
  150.     else
  151.         {
  152.         printf("MINMAX\n");
  153.         return SK_DISPLAY_MINMAX;
  154.         }
  155. }
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162. - PreferencesOkayed:sender
  163. {
  164.     [self SavePreferences];
  165.     [PreferencesPanel close];
  166.     [NXApp stopModal];
  167.     return self;
  168. }
  169.  
  170.  
  171.  
  172.  
  173. - StartPreferencesPanel:sender
  174. {
  175.     [PreferencesPanel makeKeyAndOrderFront:self];
  176.     [self PerformPreferences];
  177.     [NXApp runModalFor: PreferencesPanel];
  178.     return self;
  179. }
  180.  
  181.  
  182.  
  183.  
  184. @end
  185.