home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Source / MiscMergeKit / _MiscMergeQuery.m < prev    next >
Encoding:
Text File  |  1995-07-08  |  2.3 KB  |  114 lines

  1. //
  2. //    _MiscMergeQuery.m -- GUI controller for obtaining user feedback
  3. //        Written by Don Yacktman Copyright (c) 1995 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //        This notice may not be removed from this source code.
  6. //
  7. //    This object is included in the MiscKit by permission from the author
  8. //    and its use is governed by the MiscKit license, found in the file
  9. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  10. //    for a list of all applicable permissions and restrictions.
  11. //    
  12.  
  13.  
  14. #import "_MiscMergeQuery.h"
  15.  
  16. @implementation _MiscMergeQuery
  17.  
  18. static id _sharedInstance = nil;
  19.  
  20. + new
  21. {
  22.     if (!_sharedInstance) {
  23.         _sharedInstance = [super alloc];
  24.     }
  25.     return [_sharedInstance init];
  26. }
  27.  
  28. + alloc
  29. {
  30.     [self error:"Don't call +alloc for Query objects!"];
  31.     return nil;
  32. }
  33.  
  34. - init
  35. {
  36.     static BOOL initted = NO;
  37.  
  38.     if (!initted) {
  39.         self = [super init];
  40.         initted = YES;
  41.     }
  42.     [self loadNibIfNeeded];
  43.     [self setButtonTitles:[self getLocalStringFor:"OK"]
  44.             and:[self getLocalStringFor:"Continue"]];
  45.     [self setTitle:[self getLocalStringFor:"Merge"]];
  46.     status = MISC_QueryNone;
  47.     return self;
  48. }
  49.  
  50. - showWindow:sender
  51. {
  52.     [super showWindow:sender];
  53.     status = MISC_QueryInProgress;
  54.     [window makeKeyAndOrderFront:self];
  55.     [window makeFirstResponder:dataField];
  56.     [dataField selectText:self];
  57.     [NXApp runModalFor:window];
  58.     return self;
  59. }
  60.  
  61. - acceptQuery:sender        // accept...or not...
  62. {
  63.  
  64.     [window orderOut:self];
  65.     [NXApp stopModal];
  66.     status = MISC_QueryAccepted;
  67.     return self;
  68. }
  69.  
  70. - cancelQuery:sender        // cancel modal loop...
  71. {
  72.     [window orderOut:self];
  73.     [NXApp stopModal];
  74.     status = MISC_QueryCancelled;
  75.     return self;
  76. }
  77.  
  78. - setQuestion:(const char *)aString
  79. {
  80.     [questionField setStringValue:aString];
  81.     status = MISC_QueryNone;
  82.     return self;
  83. }
  84.  
  85. - setTitle:(const char *)aString
  86. {
  87.     [titleField setStringValue:aString];
  88.     return self;
  89. }
  90.  
  91. - setButtonTitles:(const char *)aString and:(const char *)bString
  92. {
  93.     [button1 setTitle:aString];
  94.     [button2 setTitle:bString];
  95.     return self;
  96. }
  97.  
  98. - (const char *)stringValue
  99. {
  100.     return [dataField stringValue];
  101. }
  102.  
  103. - (MiscMergeQueryStatus)status { return status; }
  104.  
  105. - (const char *)getLocalStringFor:(const char *)aString
  106. {
  107.     // ***** we should use the MiscBundle or something to allow
  108.     // these strings to be localized.  Right now they pass through
  109.     // untouched...
  110.     return aString;
  111. }
  112.  
  113. @end
  114.