home *** CD-ROM | disk | FTP | other *** search
/ Dream 41 / Amiga_Dream_41.iso / Amiga / Programmation / c / gcc / objam02.lha / objam / objtriton / TRApplication.m < prev    next >
Encoding:
Text File  |  1995-04-16  |  2.4 KB  |  154 lines

  1. /*
  2. ** ObjectiveAmiga: Implementation of class TRApplication
  3. ** See GNU:lib/libobjam/ReadMe for details
  4. */
  5.  
  6.  
  7. #import <objtriton/TRApplication.h>
  8.  
  9. #include <exec/types.h>
  10. #include <inline/triton.h>
  11.  
  12.  
  13. @implementation TRApplication
  14.  
  15. // Create and delete instances
  16.  
  17. - initTriton:(unsigned int)trVer
  18. {
  19.   if(![super init]) return nil;
  20.   if(!TR_OpenTriton(trVer,TRCA_Name,[OAApp appName])) return [self free];
  21.   if(!(windowList=[FlatList new])) return [self free];
  22.   return self;
  23. }
  24.  
  25. - init
  26. {
  27.   return [self initTriton:0];
  28. }
  29.  
  30. - free
  31. {
  32.   if(windowList) [[windowList freeObjects] free];
  33.   TR_CloseTriton();
  34.   return [super free];
  35. }
  36.  
  37. // Run the application
  38.  
  39. - runFromAppKit
  40. {
  41.   return [OAApp add:self];
  42. }
  43.  
  44. - quit
  45. {
  46.   return [OAApp remove:self];
  47. }
  48.  
  49. // Protocol <ExecSignalProcessing>
  50.  
  51. - execSignals:(ULONG)sigMask
  52. {
  53.   struct TR_Message *trMsg;
  54.   int i;
  55.   id window;
  56.   BOOL dispatched=NO;
  57.  
  58.   while(trMsg=TR_GetMsg(__Triton_Support_App))
  59.   {
  60.     for(i=0;(!dispatched) && (i<[windowList count]);i++)
  61.     {
  62.       if([(window=[windowList objectAt:i]) project]==trMsg->trm_Project)
  63.       {
  64.     [window tritonMessage:trMsg];
  65.     dispatched=YES;
  66.       }
  67.     }
  68.     TR_ReplyMsg(trMsg);
  69.   }
  70.   return self;
  71. }
  72.  
  73. - (ULONG)execSignals
  74. {
  75.   return __Triton_Support_App->tra_BitMask;
  76. }
  77.  
  78. // Add and remove windows
  79.  
  80. - add:window
  81. {
  82.   if(![windowList addObject:window]) return nil;
  83.   return self;
  84. }
  85.  
  86. - addModal:window
  87. {
  88.   int i;
  89.   id win;
  90.  
  91.   if(![windowList addObject:window]) return nil;
  92.  
  93.   for(i=0;i<[windowList count];i++)
  94.   {
  95.     win=[windowList objectAt:i];
  96.     if([win modalLevel]==modalLevel) [win lock];
  97.   }
  98.   modalLevel++;
  99.  
  100.   return self;
  101. }
  102.  
  103. - remove:window
  104. {
  105.   int i;
  106.   id win;
  107.   unsigned int newModalLevel=0, winModalLevel;
  108.  
  109.   [windowList removeObject:window];
  110.  
  111.   for(i=0;i<[windowList count];i++)
  112.   {
  113.     winModalLevel=[[windowList objectAt:i] modalLevel];
  114.     newModalLevel=max(winModalLevel,newModalLevel);
  115.   }
  116.   if(newModalLevel<modalLevel)
  117.   {
  118.     for(i=0;i<[windowList count];i++)
  119.     {
  120.       win=[windowList objectAt:i];
  121.       if([win modalLevel]==newModalLevel) [win unlock];
  122.     }
  123.     modalLevel=newModalLevel;
  124.   }
  125.  
  126.   return self;
  127. }
  128.  
  129. // Provide information to the windows
  130.  
  131. - (unsigned int)modalLevel
  132. {
  133.   return modalLevel;
  134. }
  135.  
  136. // Lock and unlock windows
  137.  
  138. - lockWindows
  139. {
  140.   [windowList makeObjectsPerform:@selector(lock)];
  141.   return self;
  142. }
  143.  
  144. - unlockWindows
  145. {
  146.   [windowList makeObjectsPerform:@selector(unlock)];
  147.   return self;
  148. }
  149.  
  150. @end
  151.  
  152.  
  153. TRApplication *TRApp;
  154.