home *** CD-ROM | disk | FTP | other *** search
-
- // graphics.h.graphic
-
- // Dreamscape - C++ class library for RISC OS
- // Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
- //
- // This library is free software; you can redistribute it and/or
- // modify it under the terms of the GNU Library General Public
- // License as published by the Free Software Foundation; either
- // version 2 of the License, or (at your option) any later version.
- // See the Dreamscape documentation for more information.
-
- #ifndef dreamscape_graphic_H
- #define dreamscape_graphic_H
-
- #include "window.h"
- #include "transform.h"
- #include "quality.h"
-
- class Graphic: public WindowRedrawable {
- class Handler;
- static struct Node { Handler *handler; Node *next; } *handlers;
-
- WinTransform transform;
- Quality quality;
-
- virtual void output(ostream &stream) const = 0;
-
- public:
- friend ostream &operator<<(ostream &stream, const Graphic &graphic)
- { graphic.output(stream); return stream; }
- virtual int get_data_size() const = 0;
- virtual Filetype get_filetype() const = 0;
-
- void set_transform(const WinTransform &matrix) { transform = matrix; }
- void get_transform(WinTransform &matrix) const { matrix = transform; }
- WinTransform get_transform() const { return transform; }
-
- void set_quality(Quality q) { quality = q; }
- Quality get_quality() const { return quality; }
-
- virtual WinBBox get_bbox() const = 0;
- virtual WinBBox get_transformed_bbox() const = 0;
- virtual WinBBox get_transformed_bbox(const WinTransform &matrix) const = 0;
-
- WinCoords get_size() const { return get_bbox().size(); }
- WinCoords get_transformed_size() const
- { return get_transformed_bbox().size(); }
- WinCoords get_transformed_size(const WinTransform &matrix) const
- { return get_transformed_bbox(matrix).size(); }
-
- static bool accept(Filetype type);
- static Graphic *load(const char *filename, Filetype type);
- static Graphic *load(const char *filename) { return load(filename, -1); }
- static Graphic *load(istream &stream, int size, Filetype type);
-
- class Handler {
- public:
- Handler();
- virtual ~Handler();
-
- virtual bool accept(Filetype type) = 0;
- virtual Graphic *load_file(const char *filename, Filetype type) = 0;
- virtual Graphic *load_data(istream &stream, int size, Filetype type) = 0;
- };
- friend Handler;
- };
-
- template <class Data, class Info>
- class GraphicLoader: public Loader<Data, Info> {
- public:
- bool accept(const Info &info) const { return Graphic::accept(info.type); }
- };
-
- #endif
-