home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / OTL-MC7.DMS / in.adf / classsource.lha / ClassSource / Workbench / Workbench.c < prev   
Encoding:
C/C++ Source or Header  |  1995-02-12  |  3.1 KB  |  192 lines

  1. #include <classes/Workbench/Workbench.h>
  2.  
  3. #include <pragma/wb_lib.h>
  4.  
  5. WBArgC::WBArgC(struct WBArg *arg, WBArgC *def)
  6.     : NodeC(),
  7.       DiskObjectNewC(arg ? arg->wa_Name : NULL, arg ? arg->wa_Lock : NULL)
  8. {
  9.     argument = arg;
  10.     default_arg = def;
  11. }
  12.  
  13. WBArgC::~WBArgC()
  14. {
  15. }
  16.  
  17. STRPTR WBArgC::name()
  18. {
  19.     if (argument)
  20.         return argument->wa_Name;
  21.     return NULL;
  22. }
  23.  
  24. BPTR WBArgC::lock()
  25. {
  26.     if (argument)
  27.         return argument->wa_Lock;
  28.     return NULL;
  29. }
  30.  
  31. // ******************************************************************
  32.  
  33. WBArgListC::WBArgListC(LONG argNum, struct WBArg *args, WBArgC *def)
  34.     : ListC()
  35. {
  36.     WBArgC *x;
  37.     while ((argNum--) > 0)
  38.     {
  39.         if (x = new WBArgC(args,def))
  40.             addTail(*x);
  41.         args++;
  42.     };
  43. }
  44.  
  45. WBArgListC::~WBArgListC()
  46. {
  47.     WBArgC *x;
  48.     while (x = remTail())
  49.     {
  50.         delete x;
  51.     };
  52. }
  53.  
  54. // *****************************************************************
  55.  
  56. WBStartupC::WBStartupC(struct WBStartup &msg)
  57.     : wbtool(msg.sm_ArgList),
  58.       projekts(msg.sm_NumArgs-1,msg.sm_ArgList+1,&wbtool)
  59. {
  60. }
  61.  
  62. WBStartupC::~WBStartupC()
  63. {
  64. }
  65.  
  66. // *************************************************************
  67.  
  68. AppEventHandlerC::AppEventHandlerC(UWORD apptype)
  69. {
  70.     aType = apptype;
  71. }
  72.  
  73. BOOL AppEventHandlerC::handle(MessageC &msg)
  74. {
  75.     return _handle((AppMessageC &) msg);
  76. }
  77.  
  78. BOOL AppEventHandlerC::forMe(MessageC &msg)
  79. {
  80.     return _forMe((AppMessageC &) msg);
  81. }
  82.  
  83. BOOL AppEventHandlerC::_handle(AppMessageC &msg)
  84. {
  85.     return FALSE;
  86. }
  87.  
  88. BOOL AppEventHandlerC::_forMe(AppMessageC &msg)
  89. {
  90.     return aType == msg.am_Type;
  91. }
  92.  
  93. // *************************************************************
  94.  
  95. AppWindowC::AppWindowC(AppPortC &p, WindowC &w, ULONG id, Tag tag1type, ...)
  96.     : aPort(&p),
  97.       aWindow(&w),
  98.       aID(id),
  99.       inittags((struct TagItem *) tag1type),
  100.       aWin(NULL)
  101. {
  102. }
  103.  
  104. AppWindowC::AppWindowC(AppPortC &p, WindowC &w, ULONG id, struct TagItem *tags)
  105.     : aPort(&p),
  106.       aWindow(&w),
  107.       aID(id),
  108.       inittags(tags),
  109.       aWin(NULL)
  110. {
  111. }
  112.  
  113. AppWindowC::AppWindowC(const AppWindowC &s)
  114.     : inittags(s.inittags)
  115. {
  116.     aPort = s.aPort;
  117.     aWindow = s.aWindow;
  118.     aID = s.aID;
  119.     aWin = NULL;
  120. }
  121.  
  122. AppWindowC::~AppWindowC()
  123. {
  124.     detach();
  125. }
  126.  
  127. AppWindowC &AppWindowC::operator= (const AppWindowC &s)
  128. {
  129.     if (this != &s)
  130.     {
  131.         detach();
  132.         aPort = s.aPort;
  133.         aWindow = s.aWindow;
  134.         aID = s.aID;
  135.         aWin = NULL;
  136.     };
  137.     return *this;
  138. }
  139.  
  140. BOOL AppWindowC::attach(Tag tag1type, ...)
  141. {
  142.     return attach((struct TagItem *) tag1type);
  143. }
  144.  
  145. BOOL AppWindowC::attach(struct TagItem *tags)
  146. {
  147.     if (aWin)
  148.         return TRUE;
  149.     if (aWindow->window() && aPort->port())
  150.     {
  151.         TagItemC t = inittags;
  152.         t.append(tags);
  153.         if (aWin = AddAppWindowA(aID,(ULONG) this,aWindow->window(),
  154.                 aPort->port(),t.tags()))
  155.             return TRUE;
  156.     };
  157.     return FALSE;
  158. }
  159.  
  160. VOID AppWindowC::detach()
  161. {
  162.     if (aWin)
  163.     {
  164.         RemoveAppWindow(aWin);
  165.         aWin = NULL;
  166.     }
  167. }
  168.  
  169. // *************************************************************
  170.  
  171. AppWindowHandlerC::AppWindowHandlerC(AppWindowC &w)
  172.     : AppEventHandlerC(AMTYPE_APPWINDOW),
  173.       aWindow(&w)
  174. {
  175.     aWindow->port()->add(*this);
  176. }
  177.  
  178. BOOL AppWindowHandlerC::_handle(AppMessageC &msg)
  179. {
  180.     drop(msg);
  181.     return FALSE;
  182. }
  183.  
  184. BOOL AppWindowHandlerC::_forMe(AppMessageC &msg)
  185. {
  186.     return (appType() == msg.am_Type) &&
  187.         (aWindow == (AppWindowC *) msg.am_UserData);
  188. }
  189.  
  190. // *************************************************************
  191.  
  192.