home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR41 / DFPP02.ZIP / TEST.CPP < prev    next >
C/C++ Source or Header  |  1993-08-15  |  2KB  |  88 lines

  1. // ------------- test.cpp
  2. #include "dflatpp.h"
  3. #include "fileopen.h"
  4.  
  5. extern MenuBarItem aMenu[];
  6.  
  7. // ------- application definition
  8. class myAppl : public Application {
  9.     String fname;
  10. public:
  11.     myAppl() : Application("Test: " VERSION, aMenu)
  12.         { SetAttribute(SIZEABLE | MOVEABLE); }
  13.     // ----- menu command functions
  14.     void CmNew()    {}
  15.     void CmOpen();
  16.     void CmSave();
  17.     void CmSaveAs();
  18.     void CmInsert() {}
  19.     void CmExit()   { CloseWindow(); }
  20. };
  21.  
  22. #define Ap void (Application::*)()
  23.  
  24. // --------- MenuSelection objects
  25. MenuSelection
  26.     NewCmd      ("~New",           (Ap) &myAppl::CmNew ),
  27.     OpenCmd     ("~Open...",       (Ap) &myAppl::CmOpen ),
  28.     SaveCmd     ("~Save",          (Ap) &myAppl::CmSave ),
  29.     SaveAsCmd   ("Save ~As...",    (Ap) &myAppl::CmSaveAs ),
  30.     ExitCmd     ("E~xit   Alt+F4", (Ap) &myAppl::CmExit, ALT_F4 ),
  31.     InsertCmd   ("~Insert    Ins", (Ap) &myAppl::CmInsert, On, INS ),
  32.     WordWrapCmd ("~Word wrap",     On );
  33.     
  34. // --------- File menu definition
  35. MenuSelection *File[] = {
  36.     &NewCmd,
  37.     &OpenCmd,
  38.     &SaveCmd,
  39.     &SaveAsCmd,
  40.     &SelectionSeparator,
  41.     &ExitCmd,
  42.     0
  43. };
  44.  
  45. MenuSelection *Options[] = {
  46.     &InsertCmd,
  47.     &WordWrapCmd,
  48.     0
  49. };
  50.  
  51. // --------- menu bar definition
  52. MenuBarItem aMenu[] = {
  53.     MenuBarItem( "~File",    File    ),
  54.     MenuBarItem( "~Options", Options ),
  55.     MenuBarItem( 0 )
  56. };
  57.  
  58. main()
  59. {
  60.     myAppl ma;
  61.     ma.Execute();
  62.     return 0;
  63. }
  64.  
  65. void myAppl::CmOpen()
  66. {
  67.     FileOpen fo;
  68.     fo.Execute();
  69.     if (fo.OKExit())    {
  70.         fname = String(fo.FileName());
  71.         // ....
  72.     }
  73. }
  74.  
  75. void myAppl::CmSave()
  76. {
  77. }
  78.  
  79. void myAppl::CmSaveAs()
  80. {
  81.     SaveAs sa;
  82.     sa.Execute();
  83.     if (sa.OKExit())    {
  84.         fname = String(sa.FileName());
  85.         // ....
  86.     }
  87. }
  88.