home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c016 / 3.ddi / COMMEX.PAK / TERMAPP.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-08  |  4.2 KB  |  154 lines

  1. //----------------------------------------------------------------------------
  2. // Borland Visual Solutions Pack
  3. // (C) Copyright 1993 by Borland International
  4. //----------------------------------------------------------------------------
  5. #include <owl\owlpch.h>
  6. #include <owl\applicat.h>
  7. #include <owl\decframe.h>
  8. #include <owl\statusba.h>
  9. #include <owl\controlb.h>
  10. #include <owl\buttonga.h>
  11. #include <owl\opensave.h>
  12. #include <stdio.h>
  13. #include <dir.h>
  14. #include "termchld.h"            // The terminal as a child window
  15. #include "termapp.rh"            // Definition of all resources.
  16.  
  17. class SaxTermApp : public TApplication {
  18.   public:
  19.     SaxTermApp();
  20.    ~SaxTermApp();
  21.  
  22.   protected:
  23.     void InitMainWindow();
  24.     void SetupToolBar(TDecoratedFrame* frame);
  25.  
  26.     void CmFileNew();
  27.     void CmFileOpen();
  28.     void CmHelpAbout();
  29.  
  30.   private:
  31.     void OpenFile(const char* fileName);
  32.  
  33.   DECLARE_RESPONSE_TABLE(SaxTermApp);
  34. };
  35.  
  36. //
  37. // Build a response table for all messages/commands handled
  38. // by SaxTermApp derived from TApplication.
  39. //
  40. DEFINE_RESPONSE_TABLE1(SaxTermApp, TApplication)
  41.   EV_COMMAND(CM_MDIFILENEW, CmFileNew),
  42.   EV_COMMAND(CM_MDIFILEOPEN, CmFileOpen),
  43.   EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
  44. END_RESPONSE_TABLE;
  45.  
  46.  
  47. //////////////////////////////////////////////////////////
  48. // SaxTermApp
  49. // =====
  50. //
  51. SaxTermApp::SaxTermApp () : TApplication("Sax Terminal")
  52. {
  53. }
  54.  
  55. SaxTermApp::~SaxTermApp ()
  56. {
  57. }
  58.  
  59. void SaxTermApp::SetupToolBar(TDecoratedFrame* frame)
  60. {
  61.   //
  62.   // Create default toolbar New and associate toolbar buttons with commands.
  63.   //
  64.   TControlBar* cb = new TControlBar(frame);
  65.   cb->Insert(*new TButtonGadget(CM_MDIFILENEW, CM_MDIFILENEW));
  66.   cb->Insert(*new TButtonGadget(CM_MDIFILEOPEN, CM_MDIFILEOPEN));
  67.   cb->Insert(*new TButtonGadget(CM_FILESAVE, CM_FILESAVE));
  68.   cb->Insert(*new TSeparatorGadget(6));
  69.   cb->Insert(*new TButtonGadget(CM_FILEUPLOAD, CM_FILEUPLOAD));
  70.   cb->Insert(*new TButtonGadget(CM_FILEDOWNLOAD, CM_FILEDOWNLOAD));
  71.   frame->Insert(*cb, TDecoratedFrame::Top);
  72. }
  73.  
  74. //////////////////////////////////////////////////////////
  75. // SaxTermApp
  76. // =====
  77. // Application intialization.
  78. //
  79. void SaxTermApp::InitMainWindow()
  80. {
  81.   TDecoratedFrame* frame = new TDecoratedFrame(0, GetName(), new SaxTermChild(0, 0));
  82.   nCmdShow = (nCmdShow != SW_SHOWMINNOACTIVE) ? SW_SHOWNORMAL : nCmdShow;
  83.  
  84.   // Assign ICON w/ this application.
  85.   //
  86.   frame->SetIcon(this, IDI_SAXAPPLICATION);
  87.  
  88.   // Menu associated with window and accelerator table associated with table.
  89.   //
  90.   frame->AssignMenu(IDM_MENU);
  91.   frame->Attr.AccelTable = IDA_EDITFILE;
  92.  
  93.   SetupToolBar(frame);
  94.  
  95.   TStatusBar* sb = new TStatusBar(frame, TGadget::Recessed, TStatusBar::CapsLock | TStatusBar::NumLock);
  96.   frame->Insert(*sb, TDecoratedFrame::Bottom);
  97.  
  98.   MainWindow = frame;
  99.  
  100.   // Windows 3-D controls.
  101.   //
  102.   EnableCtl3d(TRUE);
  103. }
  104.  
  105. void SaxTermApp::OpenFile(const char* fileName)
  106. {
  107.   // Create a new sax term client
  108.   //
  109.   delete GetMainWindow()->SetClientWindow(new SaxTermChild(GetMainWindow(), fileName));
  110. }
  111.  
  112. //////////////////////////////////////////////////////////
  113. // Menu File New command
  114. void SaxTermApp::CmFileNew()
  115. {
  116.   OpenFile(0);
  117. }
  118.  
  119. //////////////////////////////////////////////////////////
  120. // Menu File Open command
  121. void SaxTermApp::CmFileOpen()
  122. {
  123.   //
  124.   // Display standard Open dialog box to select a file name.
  125.   //
  126.   TOpenSaveDialog::TData  fileData;
  127.  
  128.   fileData.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT;
  129.   fileData.SetFilter("Comm Session Files (*.ses)|*.ses|All Files (*.*)|*.*|");
  130.   fileData.DefExt = "SES";
  131.   *fileData.FileName = 0;
  132.   if (TFileOpenDialog(GetMainWindow(), fileData).Execute() == IDOK)
  133.     OpenFile(fileData.FileName);
  134. }
  135.  
  136. //////////////////////////////////////////////////////////
  137. // Menu Help About SaxTerm.exe command
  138. void SaxTermApp::CmHelpAbout ()
  139. {
  140.   TDialog(GetMainWindow(),IDD_ABOUT).Execute();    // Show the modal dialog.
  141. }
  142.  
  143. //////////////////////////////////////////////////////////
  144.  
  145. int OwlMain (int /*argc*/, char* /*argv*/ [])
  146. {
  147.   TBIVbxLibrary vbxLib;     // constructing this loads & inits the library
  148.   //
  149.   // Application characteristics and function.
  150.   //
  151.   return SaxTermApp().Run();
  152. }
  153.  
  154.