]> git.lyx.org Git - lyx.git/blob - src/graphics/Renderer.C
prepare for 1.1.6pre2
[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 #include "frontends/support/LyXImage.h"
23
24 Renderer::Renderer()
25         : width_(0), height_(0), pixmapLoaded_(false)
26 {}
27         
28 Renderer::~Renderer()
29 {
30         freePixmap();
31 }
32
33 bool Renderer::setFilename(string const & filename)
34 {
35         // Make sure file exists and is readable.
36         if (! IsFileReadable(filename)) {
37                 return false;
38         }
39         
40         // Verify that the file format is correct.
41         if (! isImageFormatOK(filename)) {
42                 return false;
43         }
44                         
45         filename_ = filename;
46         return true;
47 }
48
49 bool Renderer::renderImage()
50 {
51         return false;
52 }
53
54 bool Renderer::isImageFormatOK(string const & /*filename*/) const
55 {
56         return false;
57 }
58
59 void Renderer::setPixmap(LyXImage * pixmap, unsigned int width, unsigned int height)
60 {
61         freePixmap();
62
63         pixmap_ = pixmap;
64         width_ = width;
65         height_ = height;
66         pixmapLoaded_ = true;
67 }
68
69 LyXImage * Renderer::getPixmap() const
70 {
71         return pixmap_;
72 }
73
74 unsigned int Renderer::getWidth() const
75 { return width_; }
76
77 unsigned int Renderer::getHeight() const
78 {
79         return height_;
80 }
81
82 string const & Renderer::getFilename() const
83 {
84         return filename_;
85 }
86
87 void Renderer::freePixmap()
88 {
89         if (pixmapLoaded_)
90                 XFreePixmap(fl_get_display(), pixmap_->getPixmap());
91 }