home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / INTERNET / WWW / LYNX / SOURCE / SRC0_8A.ZIP / DOSLYNX / SRC / TDOSLYN7.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-11  |  5.7 KB  |  220 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TDosLynx : public TApplication
  4. //    Include File:    TDosLynx.h
  5. //    Purpose:    Implement our application object.
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-09-93    created
  9. //        02-09-94    Split all members into seperate files to
  10. //                enhance overlay support.
  11. #define Uses_TDeskTop
  12. #define Uses_TVMemMgr
  13. #define Uses_MsgBox
  14. #include"tdoslynx.h"
  15. #include"globals.h"
  16. #include<stdlib.h>
  17.  
  18. extern "C"    {
  19. #include"..\wattcp\include\tcp.h"
  20. #include"image.h"
  21. };
  22.  
  23. void TDosLynx::handleEvent(TEvent& TE_Event)    {
  24. //    Purpose:    Determine the implications of an event
  25. //    Arguments:    TE_Event    What happened for call to function
  26. //    Return Value:   void
  27. //    Remarks/Portability/Dependencies/Restrictions:
  28. //    Revision History:
  29. //        12-13-93    created
  30. //        03-31-94    Modified to better handle an ownerClose
  31. //                request.  Didn't work.
  32. //        04-05-94    Video switching mode code added.  Moved into
  33. //                a separate function.
  34. //        08-09-94    Added code to not depend upon the presence
  35. //                of TC.
  36.  
  37.     //    If the following is not null, a window is requesting that
  38.     //    it be close.  Will do so now to avoid a particular problem
  39.     //    of returning to an object that no longer exists.
  40.     if(TVp_ToBeRemoved != NULL)    {
  41.         deskTop->remove(TVp_ToBeRemoved);
  42.         destroy(TVp_ToBeRemoved);
  43.         TVp_ToBeRemoved = NULL;
  44.     }
  45.  
  46.     //    If the following is not null, then there is an image that
  47.     //    we must view.  Will do so now.  This is a staggered event.
  48.     if(cp_ToBeViewed != NULL)    {
  49.         if(usi_graphicsmode != (image_modes)image_modes_total)    {
  50.             //    Suspend DosLynx and view the image.
  51.             suspend();
  52.             ::image_viewer(cp_ToBeViewed, (image_modes)
  53.                 usi_graphicsmode);
  54.             resume();
  55.             redraw();
  56.         }
  57.         delete(cp_ToBeViewed);
  58.         cp_ToBeViewed = NULL;
  59.     }
  60.  
  61.     if(TE_Event.what & evMessage)    {
  62.         switch(TE_Event.message.command)    {
  63.         case cmOpenURL:
  64.             //    Open a URL
  65.             OpenURL();
  66.             clearEvent(TE_Event);
  67.             break;
  68.         case cmUnHideMessage:
  69.             //    Show the message window.
  70.             if(::B_noInfo != TRUE)    {
  71.                 ::TC->show();
  72.                 ::TC->makeFirst();
  73.             }
  74.             clearEvent(TE_Event);
  75.             break;
  76.         case cmTile:
  77.             //    Tile all windows on desktop.
  78.             ::TC->hide();
  79.             deskTop->tile(deskTop->getExtent());
  80.             clearEvent(TE_Event);
  81.             break;
  82.         case cmCascade:
  83.             //    Cascade all windows on desktop.
  84.             ::TC->hide();
  85.             deskTop->cascade(deskTop->getExtent());
  86.             clearEvent(TE_Event);
  87.             break;
  88.         case cmDosShell:
  89.             //    Provide a dos shell.
  90.             suspend();
  91.             system("cls");
  92.             system("echo Type EXIT to return to DOSLYNX.");
  93.             system(getenv("COMSPEC") == NULL ? "command.com" :
  94.                 getenv("COMSPEC"));
  95.             resume();
  96.             clearEvent(TE_Event);
  97.             redraw();
  98.             break;
  99. #ifndef RELEASE
  100.         case cmTraceWWW:    {
  101.             //    Turn on WWW tracing.
  102.             extern int WWW_TraceFlag;
  103.             WWW_TraceFlag++;
  104.             WWW_TraceFlag %= 2;
  105.             clearEvent(TE_Event);
  106.             doslynxmessage("WWW tracing turned " << (WWW_TraceFlag
  107.                 == 1 ? "on" : "off") << '.');
  108.             break;
  109.         }
  110.         case cmTraceWATTCP:    {
  111.             //    Turn on Wattcp debugging.
  112.             static int i_twattcp = 0;
  113.             i_twattcp++;
  114.             i_twattcp %= 2;
  115.             tcp_set_debug_state(i_twattcp);
  116.             clearEvent(TE_Event);
  117.             doslynxmessage("WATTCP tracing turned " << (i_twattcp
  118.                 == 1 ? "on" : "off") << '.');
  119.             break;
  120.         }
  121.         case cmTraceDOSLYNX:    {
  122.             //    Turn on doslynx debugging.
  123.             c_trace++;
  124.             c_trace %= 2;
  125.             clearEvent(TE_Event);
  126.             doslynxmessage("DOSLYNX tracing turned " << (c_trace
  127.                 == 1 ? "on" : "off") << '.');
  128.             break;
  129.         }
  130. #endif // RELEASE
  131.         case cmOpenLocal:
  132.             //    Open a local file
  133.             OpenLocal();
  134.             clearEvent(TE_Event);
  135.             break;
  136.         case cmOwnerClose:
  137.             //    Destroy the requesting view.
  138.             //    Assume deskTop owns the view.
  139.             //    Here's the kludge, set a variable that will
  140.             //    close this for us the next time the function
  141.             //    is called so that we will avoid returning to
  142.             //    an object that no longer exists.
  143.             TVp_ToBeRemoved = (TView *)(TE_Event.message.infoPtr);
  144.             clearEvent(TE_Event);
  145.             break;
  146.         case cmQuit:    {
  147.             //    The application is about to exit.
  148.             //    Broadcast to all open views in the desktop
  149.             //    to close.
  150.             //    Don't clear this event.  The base class will
  151.             //    have to do its wrap up also.
  152.             TEvent TE_close;
  153.             TE_close.what = evBroadcast;
  154.             TE_close.message.command = cmClose;
  155.             deskTop->handleEvent(TE_close);
  156.             break;
  157.         }
  158.         case cmVideoMode:    {
  159.             //    Change the video mode from what we are to
  160.             //    the other....
  161.             switchVideo();
  162.             clearEvent(TE_Event);
  163.             break;
  164.         }
  165.         case cmMailDeveloper:    {
  166.             mailDeveloper();
  167.             clearEvent(TE_Event);
  168.             break;
  169.         }
  170.         case cmImage:    {
  171.             //    There is an image that we will view.
  172.             cp_ToBeViewed = (char *)TE_Event.message.infoPtr;
  173.             clearEvent(TE_Event);
  174.             break;
  175.         }
  176.         case cmHomePage:    {
  177.             //    Load up the home page.
  178.             if(cp_Home != NULL)    {
  179.                 OpenURL(cp_Home);
  180.             }
  181.             else    {
  182.                 doslynxmessage("home not specified in the"
  183.                     "configuration file.");
  184.             }
  185.             clearEvent(TE_Event);
  186.             break;
  187.         }
  188.         case cmHotList:    {
  189.             //    Load up the HotList.
  190.             if(cp_HotList != NULL)    {
  191.                 OpenLocal(cp_HotList);
  192.             }
  193.             else    {
  194.                 doslynxmessage("hotlistfile not specified in "
  195.                     "the configuration file.");
  196.             }
  197.             clearEvent(TE_Event);
  198.             break;
  199.         }
  200.         case cmAboutDosLynx:    {
  201.             auto TRect TR_about = deskTop->getExtent();
  202.             TR_about.grow(-3, -1 * TR_about.b.y / 2);
  203.             TR_about.grow(0, 6);
  204.  
  205.             messageBoxRect(TR_about, "\nDosLynx\nVersion 0.8 "
  206.                 "Alpha\nCopyright (c) 1994 by The "
  207.                 "University of Kansas, All Rights Reserved\n"
  208.                 "Developer:  Garrett Arch Blythe",
  209.                 mfInformation | mfOKButton);
  210.             break;
  211.         }
  212.         default:
  213.             //    Event not handled here.
  214.             break;
  215.         }
  216.     }
  217.  
  218.     //    Have our base handle the event also.
  219.     TApplication::handleEvent(TE_Event);
  220. }