]> git.lyx.org Git - lyx.git/blob - src/graphics/Renderer.h
prepare for 1.1.6pre2
[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 class LyXImage;
26
27 /** Renderer is a base class that is used to take an image format, and
28  *  render it into a Pixmap in order to be able to display it later on
29  *  in LyX. Essentially it's job is to load an image format and create
30  *  a Pixmap from it. It also needs to do various transforms on the
31  *  image, like Rotation, Resize and color reduction.
32  *  
33  *  @Author Baruch Even, <baruch.even@writeme.com>
34  */
35 class Renderer : public noncopyable {
36 public:
37         /// c-tor.
38         Renderer();
39         /// d-tor.
40         virtual ~Renderer();
41
42         /// Set the filename that we will render
43         bool setFilename(string const & filename);
44
45         /// Render the image, doing the necessary transforms.
46         virtual bool renderImage() = 0;
47
48         /// Get the last rendered pixmap.
49         LyXImage * getPixmap() const;
50
51         /// Get the width of the pixmap.
52         unsigned int getWidth() const;
53
54         /// Get the height of the pixmap.
55         unsigned int getHeight() const;
56
57 protected:
58         /// Verify that the file is one that we can handle.
59         virtual bool isImageFormatOK(string const & filename) const = 0;
60
61         /// Set the pixmap.
62         void setPixmap(LyXImage * pixmap, unsigned int width, unsigned int height);
63         ///
64         string const & getFilename() const;
65
66 private:
67         /// Free the loaded pixmap
68         void freePixmap();
69         
70         /// The filename of the image file that we are responsible for.
71         string filename_;
72         /// The last rendered pixmap.
73         LyXImage * pixmap_;
74         /// The width of the rendered pixmap.
75         unsigned int width_;
76         /// The height of the rendered pixmap.
77         unsigned int height_;
78         /// is Pixmap ready?
79         bool pixmapLoaded_;
80 };
81
82 #endif