home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / vrac / toolti.zip / TEST.CPP < prev    next >
C/C++ Source or Header  |  1994-11-22  |  5KB  |  208 lines

  1. /*  Project tooltest
  2.  
  3.     Copyright ⌐ 1994. All Rights Reserved.
  4.  
  5.     SUBSYSTEM:    tooltest.exe Application
  6.     FILE:         test.cpp
  7.     AUTHOR:       Steve Saxon
  8.  
  9.  
  10.     OVERVIEW
  11.     ========
  12.     Source file for implementation of TooltipApp (TApplication).
  13. */
  14.  
  15.  
  16. #include <owl\owlpch.h>
  17. #pragma hdrstop
  18.  
  19. #include <owl\textgadg.h>
  20.  
  21. #include "test.h"
  22. #include "about.h"              // Definition of about dialog.
  23.  
  24. //{{TooltipApp Implementation}}
  25.  
  26.  
  27. //
  28. // Build a response table for all messages/commands handled
  29. // by the application.
  30. //
  31. DEFINE_RESPONSE_TABLE1(TooltipApp, TApplication)
  32. //{{TooltipAppRSP_TBL_BEGIN}}
  33.     EV_COMMAND(CM_FILENEW, CmFileNew),
  34.     EV_COMMAND(CM_FILEOPEN, CmFileOpen),
  35.     EV_COMMAND(CM_FILECLOSE, CmFileClose),
  36.     EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
  37. //{{TooltipAppRSP_TBL_END}}
  38. END_RESPONSE_TABLE;
  39.  
  40.  
  41. //
  42. // FrameWindow must be derived to override Paint for Preview and Print.
  43. //
  44. class SDIDecFrame : public TDecoratedFrame {
  45. public:
  46.     SDIDecFrame (TWindow *parent, const char far *title, TWindow *clientWnd, BOOL trackMenuSelection = FALSE, TModule *module = 0) :
  47.             TDecoratedFrame(parent, title, clientWnd, trackMenuSelection, module)
  48.       {  }
  49.     ~SDIDecFrame ()
  50.       {  }
  51. };
  52.  
  53.  
  54. //////////////////////////////////////////////////////////
  55. // TooltipApp
  56. // =====
  57. //
  58. TooltipApp::TooltipApp ()
  59.     :     TApplication("Tooltip Application"),
  60.         tooltip (Tip::SquareBorder | Tip::Shadow)
  61. {
  62.  
  63.     // Common file file flags and filters for Open/Save As dialogs.  Filename and directory are
  64.     // computed in the member functions CmFileOpen, and CmFileSaveAs.
  65.     FileData.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
  66.     FileData.SetFilter("All Files (*.*)|*.*|");
  67.  
  68.     // INSERT>> Your constructor code here.
  69.  
  70. }
  71.  
  72.  
  73. TooltipApp::~TooltipApp ()
  74. {
  75.     // INSERT>> Your destructor code here.
  76.  
  77. }
  78.  
  79. //////////////////////////////////////////////////////////
  80. // TooltipApp
  81. // =====
  82. // Application intialization.
  83. //
  84. void TooltipApp::InitMainWindow ()
  85. {
  86.     Client = new TEditFile(0, 0, 0);
  87.     SDIDecFrame *frame = new SDIDecFrame(0, GetName(), Client, TRUE);
  88.  
  89.     nCmdShow = nCmdShow != SW_SHOWMINIMIZED ? SW_SHOWNORMAL : nCmdShow;
  90.  
  91.     //
  92.     // Assign ICON w/ this application.
  93.     //
  94.     frame->SetIcon(this, IDI_SDIAPPLICATION);
  95.  
  96.     //
  97.     // Menu associated with window and accelerator table associated with table.
  98.     //
  99.     frame->AssignMenu(SDI_MENU);
  100.     
  101.     //
  102.     // Associate with the accelerator table.
  103.     //
  104.     frame->Attr.AccelTable = SDI_MENU;
  105.  
  106.     //
  107.     // Create default toolbar New and associate toolbar buttons with commands.
  108.     //
  109.     TTipControlBar* cb = new TTipControlBar(tooltip, frame);
  110.     cb->Insert(*new TButtonGadget(CM_FILENEW, CM_FILENEW));
  111.     cb->Insert(*new TButtonGadget(CM_FILEOPEN, CM_FILEOPEN));
  112.     cb->Insert(*new TButtonGadget(CM_FILESAVE, CM_FILESAVE));
  113.     cb->Insert(*new TSeparatorGadget(6));
  114.     cb->Insert(*new TButtonGadget(CM_EDITUNDO, CM_EDITUNDO));
  115.     cb->Insert(*new TButtonGadget(CM_EDITCUT, CM_EDITCUT));
  116.     cb->Insert(*new TButtonGadget(CM_EDITCOPY, CM_EDITCOPY));
  117.     cb->Insert(*new TButtonGadget(CM_EDITPASTE, CM_EDITPASTE));
  118.     cb->Insert(*new TSeparatorGadget(6));
  119.     cb->Insert(*new TButtonGadget(CM_EDITFIND, CM_EDITFIND));
  120.     cb->Insert(*new TButtonGadget(CM_EDITFINDNEXT, CM_EDITFINDNEXT));
  121.  
  122.     frame->Insert(*cb, TDecoratedFrame::Top);
  123.  
  124.     //
  125.     // Create default status bar.
  126.     //
  127.     TStatusBar *sb = new TTipStatusBar(tooltip, frame, TGadget::Recessed,
  128.                                     TStatusBar::CapsLock        |
  129.                                     TStatusBar::NumLock         |
  130.                                     TStatusBar::ScrollLock      |
  131.                                     TStatusBar::Overtype);
  132.     frame->Insert(*sb, TDecoratedFrame::Bottom);
  133.  
  134.     MainWindow = frame;
  135.  
  136. //    cb->SetDocking (FALSE);
  137. }
  138.  
  139.  
  140. //////////////////////////////////////////////////////////
  141. // TooltipApp
  142. // ===========
  143. // Menu File New command
  144. void TooltipApp::CmFileNew ()
  145. {
  146.     Client->NewFile();
  147. }
  148.  
  149.  
  150. //////////////////////////////////////////////////////////
  151. // TooltipApp
  152. // ===========
  153. // Menu File Open command
  154. void TooltipApp::CmFileOpen ()
  155. {
  156.     //
  157.     // Display standard Open dialog box to select a file name.
  158.     //
  159.     *FileData.FileName = 0;
  160.     if (Client->CanClose())
  161.         if (TFileOpenDialog(MainWindow, FileData).Execute() == IDOK)
  162.             OpenFile();
  163. }
  164.  
  165.  
  166. void TooltipApp::OpenFile (const char *fileName)
  167. {
  168.     if (fileName)
  169.         lstrcpy(FileData.FileName, fileName);
  170.  
  171.     Client->ReplaceWith(FileData.FileName);
  172. }
  173.  
  174.  
  175. //////////////////////////////////////////////////////////
  176. // TooltipApp
  177. // =====
  178. // Menu File Close command
  179. void TooltipApp::CmFileClose ()
  180. {
  181.      if (Client->CanClose())
  182.              Client->DeleteSubText(0, UINT(-1));
  183. }
  184.  
  185.  
  186. //////////////////////////////////////////////////////////
  187. // TooltipApp
  188. // ===========
  189. // Menu Help About tooltest.exe command
  190. void TooltipApp::CmHelpAbout ()
  191. {
  192.     //
  193.     // Show the modal dialog.
  194.     //
  195.     TooltipAboutDlg(MainWindow).Execute();
  196. }
  197.  
  198.  
  199. int OwlMain (int , char* [])
  200. {
  201.     TooltipApp     App;
  202.     int             result;
  203.  
  204.     result = App.Run();
  205.  
  206.     return result;
  207. }
  208.