home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / graphics / h / graphic < prev    next >
Encoding:
Text File  |  1996-09-15  |  2.4 KB  |  76 lines

  1.  
  2. // graphics.h.graphic
  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_graphic_H
  14. #define dreamscape_graphic_H
  15.  
  16. #include "window.h"
  17. #include "transform.h"
  18. #include "quality.h"
  19.  
  20. class Graphic: public WindowRedrawable {
  21.   class Handler;
  22.   static struct Node { Handler *handler; Node *next; } *handlers;
  23.  
  24.   WinTransform transform;
  25.   Quality quality;
  26.  
  27.   virtual void output(ostream &stream) const = 0;
  28.  
  29. public:
  30.   friend ostream &operator<<(ostream &stream, const Graphic &graphic)
  31.     { graphic.output(stream); return stream; }
  32.   virtual int get_data_size() const = 0;
  33.   virtual Filetype get_filetype() const = 0;
  34.  
  35.   void set_transform(const WinTransform &matrix) { transform = matrix; }
  36.   void get_transform(WinTransform &matrix) const { matrix = transform; }
  37.   WinTransform get_transform() const { return transform; }
  38.  
  39.   void set_quality(Quality q) { quality = q; }
  40.   Quality get_quality() const { return quality; }
  41.  
  42.   virtual WinBBox get_bbox() const = 0;
  43.   virtual WinBBox get_transformed_bbox() const = 0;
  44.   virtual WinBBox get_transformed_bbox(const WinTransform &matrix) const = 0;
  45.  
  46.   WinCoords get_size() const { return get_bbox().size(); }
  47.   WinCoords get_transformed_size() const
  48.     { return get_transformed_bbox().size(); }
  49.   WinCoords get_transformed_size(const WinTransform &matrix) const
  50.     { return get_transformed_bbox(matrix).size(); }
  51.  
  52.   static bool accept(Filetype type);
  53.   static Graphic *load(const char *filename, Filetype type);
  54.   static Graphic *load(const char *filename) { return load(filename, -1); }
  55.   static Graphic *load(istream &stream, int size, Filetype type);
  56.  
  57.   class Handler {
  58.   public:
  59.     Handler();
  60.     virtual ~Handler();
  61.  
  62.     virtual bool accept(Filetype type) = 0;
  63.     virtual Graphic *load_file(const char *filename, Filetype type) = 0;
  64.     virtual Graphic *load_data(istream &stream, int size, Filetype type) = 0;
  65.   };
  66.   friend Handler;
  67. };
  68.  
  69. template <class Data, class Info>
  70. class GraphicLoader: public Loader<Data, Info> {
  71. public:
  72.   bool accept(const Info &info) const { return Graphic::accept(info.type); }
  73. };
  74.  
  75. #endif
  76.