home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / low-level / h / dataload next >
Encoding:
Text File  |  1996-07-17  |  2.5 KB  |  101 lines

  1.  
  2. // low-level.h.dataload
  3.  
  4. // Dreamscape - C++ class library for RISC OS
  5. // Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
  6. //
  7. // This library is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU Library General Public
  9. // License as published by the Free Software Foundation; either
  10. // version 2 of the License, or (at your option) any later version.
  11. // See the Dreamscape documentation for more information.
  12.  
  13. #ifndef dreamscape_dataload_H
  14. #define dreamscape_dataload_H
  15.  
  16. #include "bool.h"
  17.  
  18. #include "loader.h"
  19. #include "coords.h"
  20. #include "wimpmsg.h"
  21.  
  22. class istream;
  23. typedef struct wimp_t_ *wimp_t;
  24. typedef struct wimp_w_ *wimp_w;
  25.  
  26. class DataLoadProtocol {
  27.   static class Initialise {
  28.   public:
  29.     Initialise();
  30.   } init;
  31.   friend Initialise;
  32.  
  33.   class Info;
  34.   class Client;
  35.   static struct Node {
  36.     Client *h;
  37.     unsigned priority;
  38.     Node *next;
  39.   } *handlers;
  40.   static bool (*temp_data_save_handler)(const wimp_message *message);
  41.  
  42.   static bool message_data_load(const wimp_message *message, void *handle);
  43.   static bool message_data_save(const wimp_message *message, void *handle);
  44.   static bool message_ram_fetch(const wimp_message *message, void *handle);
  45.   static bool message_ram_transmit(const wimp_message *message,
  46.         void *handle);
  47.   static char *buffer;
  48.   static int buffer_size, received, bounce_code, bounce_icon;
  49.   static wimp_w bounce_window;
  50.   static ScrCoords bounce_pos;
  51.   static Filetype bounce_type;
  52.  
  53.   static void fill_in_info(Info &info, const wimp_message *message);
  54.  
  55. public:
  56.   class Info {
  57.   public:
  58.     Filetype type;
  59.     int size;
  60.     wimp_w window;
  61.     int icon;
  62.     ScrCoords pos;
  63.  
  64.     unsigned shift: 1;
  65.     unsigned control: 1;
  66.     unsigned alt: 1;
  67.   };
  68.   class Client {
  69.   public:
  70.     virtual void *accept_data(const Info &info) = 0;
  71.     virtual void *accept_file(const Info &info) = 0;
  72.     virtual void load_data(const Info &info, istream &stream,
  73.             void *handle) = 0;
  74.     virtual void load_file(const Info &info, const char *filename,
  75.             void *handle) = 0;
  76.   };
  77.  
  78.   static void register_client(Client *handler, unsigned priority);
  79.   static void register_temp_data_save_handler(bool (*function)(const
  80.         wimp_message *message))
  81.     { temp_data_save_handler = function; }
  82.  
  83.   // Priorities:
  84.   //   Clipboard paster (exclusive)    0x010
  85.   //   Gadgets (high)            0x100
  86.   //   Window/iconbar icon        0x200
  87.   //   File opener (low)        0x300
  88.  
  89. private:
  90.   static struct TempFileInfo {
  91.     wimp_t task;
  92.     wimp_w window;
  93.  
  94.     Info info;
  95.     Client *client;
  96.     void *handle;
  97.   } *temp_file;
  98. };
  99.  
  100. #endif
  101.