]> git.lyx.org Git - lyx.git/blob - src/graphics/Renderer.h
small patch from Dekel, begin introducing the real boost framework, get rid of the...
[lyx.git] / src / graphics / Renderer.h
1 // -*- C++ -*-
2 /* This file is part of
3  * =================================================
4  * 
5  *          LyX, The Document Processor
6  *          Copyright 1995 Matthias Ettrich.
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  *          This file Copyright 2000 Baruch Even
10  * ================================================= */
11
12 #ifndef RENDERER_H
13 #define RENDERER_H
14
15 #include <config.h>
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include "LString.h"
22 #include "X11/Xlib.h"
23 #include <boost/utility.hpp>
24
25 /** Renderer is a base class that is used to take an image format, and
26     render it into a Pixmap in order to be able to display it later on
27     in LyX. Essentially it's job is to load an image format and create
28     a Pixmap from it. It also needs to do various transforms on the
29     image, like Rotation, Resize and color reduction.
30  */
31 class Renderer : public noncopyable {
32 public:
33         /// c-tor.
34         Renderer();
35         /// d-tor.
36         virtual ~Renderer();
37
38         /// Set the filename that we will render
39         bool setFilename(string const & filename);
40
41         /// Render the image, doing the necessary transforms.
42         virtual bool renderImage() = 0;
43
44         /// Get the last rendered pixmap.
45         Pixmap getPixmap() const;
46
47         /// Get the width of the pixmap.
48         unsigned int getWidth() const;
49
50         /// Get the height of the pixmap.
51         unsigned int getHeight() const;
52
53 protected:
54         /// Verify that the file is one that we can handle.
55         virtual bool isImageFormatOK(string const & filename) const = 0;
56
57         /// Set the pixmap.
58         void setPixmap(Pixmap pixmap, unsigned int width, unsigned int height);
59         ///
60         string const & getFilename() const;
61
62 private:
63         /// Free the loaded pixmap
64         void freePixmap();
65         
66         /// The filename of the image file that we are responsible for.
67         string filename_;
68         /// The last rendered pixmap.
69         Pixmap pixmap_;
70         /// The width of the rendered pixmap.
71         unsigned int width_;
72         /// The height of the rendered pixmap.
73         unsigned int height_;
74         /// is Pixmap ready?
75         bool pixmapLoaded_;
76 };
77
78 #endif