home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / DCLAP 4j / DApp / MailHelp.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-17  |  2.6 KB  |  137 lines  |  [TEXT/R*ch]

  1. // MailHelp.cp
  2. // d.g.gilbert -- simple email dialog to fixed help address
  3. // Jan 1994
  4.  
  5.  
  6. #include <DClap.h>
  7. #include <DNet.h>
  8.  
  9.  
  10.     // customize these strings for your local settings
  11. Local char* kDefaultMailhost= "mailhost.some.university.edu";
  12. Local char* kHelpAddress  = "help@some.university.edu";
  13. Local char* kHelpMenuItem = "Mail to help desk...";
  14. Local    char* aboutMailHelp =
  15.     "Send mail to your department/school/company\n"
  16.     "help desk for answers to your questions.";
  17.  
  18.  
  19. class DMailHelp : public DApplication
  20. {
  21. public:
  22.     enum internetMenu {
  23.         kMailSetup = 1001, kBugMail, kSendMail
  24.         };
  25.         
  26.     void IMailHelp(void);     
  27.     void DoAboutBox();
  28.     virtual void SetUpMenus(void);    // override
  29.     virtual    Boolean IsMyAction(DTaskMaster* action); //override
  30.     virtual Boolean IsInternetMenu(DTaskMaster* action); 
  31.     virtual    void UpdateMenus(void); // override
  32. };
  33.  
  34.  
  35.     // here we go -- the Nlm_Main() program (called from main() in ncbimain.c)
  36. extern "C" short Main(void)
  37. {
  38.   DMailHelp* app = new DMailHelp();
  39.   app->IMailHelp();
  40.   app->Run();
  41.   delete app; 
  42.   return 0;
  43. }
  44.  
  45.  
  46.  
  47.  
  48. void DMailHelp::IMailHelp(void)
  49. {
  50.     IApplication();
  51.     gMailhost= StrDup(kDefaultMailhost);
  52. }     
  53.  
  54. void DMailHelp::DoAboutBox()
  55. {
  56.     DAboutBoxWindow* about = new DAboutBoxWindow(aboutMailHelp); // make instance & it handles rest
  57. }
  58.  
  59. void DMailHelp::SetUpMenus(void)
  60. {
  61.     DApplication::SetUpMenus();
  62.  
  63.     DMenu* iMenu = NewMenu(cMail, "Mail");
  64.     iMenu->AddItem( kMailSetup, "Mail setup...");
  65.     iMenu->AddItem( kBugMail, kHelpMenuItem);
  66.     iMenu->AddItem( kSendMail, "Send mail...");
  67.     iMenu->suicide(1);
  68.  
  69. }
  70.  
  71.  
  72. class    DBugMailDialog : public DSendMailDialog
  73. {
  74. public:
  75.     DBugMailDialog(long id, DTaskMaster* itsSuperior) :
  76.         DSendMailDialog(id, itsSuperior, -5, -5, -50, -20, "Mail for Help")
  77.         {}
  78.     
  79.     virtual DView* InstallTo(DView* super, char* toStr)  //override
  80.     {
  81.         return DSendMailDialog::InstallTo(super, kHelpAddress);
  82.     }
  83. };
  84.  
  85.  
  86.  
  87.  
  88. Boolean DMailHelp::IsInternetMenu(DTaskMaster* action) 
  89. {
  90.     DWindow* win;
  91.  
  92.     switch(action->Id()) {
  93.  
  94.         case    kMailSetup:
  95.             {
  96.             win= new DMailSetupDialog(0, this, -10, -10, -20, -20, "Mail Setup");
  97.             win->Open();
  98.             return true;
  99.             }
  100.         case  kBugMail:
  101.             {
  102.             win= new DBugMailDialog( 0, this);
  103.             win->Open();
  104.             return true;
  105.             }
  106.         case     kSendMail: 
  107.             {
  108.             win= new DSendMailDialog(0, this, -10, -10, -20, -20, "Send Mail");
  109.             win->Open();
  110.             return true;
  111.             }
  112.             
  113.         default:    return false;
  114.         }
  115. }
  116.  
  117.  
  118. Boolean DMailHelp::IsMyAction(DTaskMaster* action) 
  119. {
  120.     DWindow* win;
  121.     
  122.     if (action->fSuperior && action->fSuperior->Id() == cMail)
  123.         return IsInternetMenu(action);
  124.         
  125.     switch(action->Id()) {
  126.         default: 
  127.             return DApplication::IsMyAction(action);
  128.         }
  129. }
  130.  
  131.  
  132.  
  133. void DMailHelp::UpdateMenus(void)
  134. {
  135.     DApplication::UpdateMenus();
  136. }
  137.