]> git.lyx.org Git - lyx.git/blob - src/graphics/Renderer.C
citation patch from Angus
[lyx.git] / src / graphics / Renderer.C
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 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include <config.h>
17 #include "Renderer.h"
18
19 #include FORMS_H_LOCATION
20 #include "support/filetools.h"
21
22
23 Renderer::Renderer()
24         : width_(0), height_(0), pixmapLoaded_(false)
25 {}
26         
27 Renderer::~Renderer()
28 {
29         freePixmap();
30 }
31
32 bool Renderer::setFilename(string const & filename)
33 {
34         // Make sure file exists and is readable.
35         if (! IsFileReadable(filename)) {
36                 return false;
37         }
38         
39         // Verify that the file format is correct.
40         if (! isImageFormatOK(filename)) {
41                 return false;
42         }
43                         
44         filename_ = filename;
45         return true;
46 }
47
48 bool Renderer::renderImage()
49 {
50         return false;
51 }
52
53 bool Renderer::isImageFormatOK(string const & /*filename*/) const
54 {
55         return false;
56 }
57
58 void Renderer::setPixmap(Pixmap pixmap, unsigned int width, unsigned int height)
59 {
60         freePixmap();
61
62         pixmap_ = pixmap;
63         width_ = width;
64         height_ = height;
65         pixmapLoaded_ = true;
66 }
67
68 Pixmap Renderer::getPixmap() const
69 { return pixmap_; }
70
71 unsigned int Renderer::getWidth() const
72 { return width_; }
73
74 unsigned int Renderer::getHeight() const
75 { return height_; }
76
77 string const & Renderer::getFilename() const
78 { return filename_; }
79
80 void Renderer::freePixmap()
81 {
82         if (pixmapLoaded_)
83                 XFreePixmap(fl_display, pixmap_);
84 }