home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / vista_1 / Examples_!SaveEx_h_SaveEx < prev    next >
Encoding:
Text File  |  1996-01-25  |  3.9 KB  |  112 lines

  1. // **************************************************************************
  2. //                     Copyright 1996 David Allison
  3. //
  4. //             VV    VV    IIIIII     SSSSS     TTTTTT       AA
  5. //             VV    VV      II      SS           TT       AA  AA
  6. //             VV    VV      II        SSSS       TT      AA    AA
  7. //              VV  VV       II           SS      TT      AAAAAAAA
  8. //                VV       IIIIII     SSSS        TT      AA    AA
  9. //
  10. //                    MULTI-THREADED C++ WIMP CLASS LIBRARY
  11. //                                for RISC OS
  12. // **************************************************************************
  13. //
  14. //             P U B L I C    D O M A I N    L I C E N C E
  15. //             -------------------------------------------
  16. //
  17. //     This library is copyright. You may not sell the library for
  18. //     profit, but you may sell products which use it providing
  19. //     those products are presented as executable code and are not
  20. //     libraries themselves.  The library is supplied without any
  21. //     warranty and the copyright owner cannot be held responsible for
  22. //     damage resulting from failure of any part of this library.
  23. //
  24. //          See the User Manual for details of the licence.
  25. //
  26. // *************************************************************************
  27.  
  28.  
  29. //
  30. // Example of a SaveBox
  31. //
  32.  
  33. #ifndef __saveex_h
  34. #define __saveex_h
  35.  
  36. #include "Vista:vista.h"
  37. #include <stdio.h>
  38.  
  39. class MainWindow ;             // declaration
  40.  
  41. //
  42. // This class saves things in the MainWindow.  it is a DataSave protocol class
  43. // and is therefore a Channel.  It receives messages from the wimp appropriate
  44. // to the Channel
  45. //
  46.  
  47.  
  48. class Saver: public DataSave
  49.    {
  50.    public:
  51.       Saver(Task *task, MainWindow *window) ;              // constructor
  52.       ~Saver() ;                                           // destructor
  53.       void receive (int action, int task, int my_ref, int your_ref, int data_length, void *data) ;   // receive a message
  54.       void save(int window, int icon, int x, int y, char *leaf) ;     // save to a window and icon
  55.       void save (char *path) ;                                        // save given the whole path
  56.       char *path() { return previous_path ; }                         // access func for path
  57.    private:
  58.       MainWindow *window ;                                            // the window to save
  59.       char previous_path[256] ;                                       // previous path saved to
  60.    } ;
  61.  
  62.  
  63.  
  64. //
  65. // The MainWindow class.  This class is the window opened by clicking on the
  66. // icon bar icon.  It has a menu with only one item (Save).  The class
  67. // simply displays a piece of text in an outline font.
  68. //
  69.  
  70.  
  71. class MainWindow : public Window
  72.    {
  73.    public:
  74.       MainWindow (Task *t) ;                 // constructor
  75.       ~MainWindow() ;                        // destructor
  76.       void menu(MenuItem items[]) ;          // menu click function
  77.       void save(FILE *fp) ;                  // save function
  78.    private:
  79.        enum menu_items
  80.           {
  81.           SAVE
  82.           } ;
  83.        int font_handle ;                     // handle for outline font
  84.        FontObject *text ;                    // The object displaying the text
  85.        Saver *saver ;                        // saver for this window
  86.    } ;
  87.  
  88.  
  89. //
  90. // This class is the task itself.  The icon bar has a menu with 2 items.  The task responds
  91. // to clicks on the icon bar (click() function) and menu hits (menu() function).  Private
  92. // data includes the main window object.
  93. //
  94.  
  95.  
  96. class SaveEx : public Task
  97.    {
  98.    enum menu_items
  99.       {
  100.       INFO,                          // program info
  101.       QUIT                           // quit application
  102.       } ;
  103.    public:
  104.       SaveEx() ;
  105.       void click(int x, int y, int button, int icon) ;   // I want iconbar clicks
  106.       void menu (MenuItem items[]) ;                     // iconbar menu hit
  107.    private:
  108.       Window *mainwin ;                                  // the main window
  109.    } ;
  110.  
  111. #endif
  112.