]> git.lyx.org Git - lyx.git/blob - src/graphics/Renderer.C
use more std::functors add some of my own, some change to fl_display etc. read the...
[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
28 Renderer::~Renderer()
29 {
30         freePixmap();
31 }
32
33
34 bool Renderer::setFilename(string const & filename)
35 {
36         // Make sure file exists and is readable.
37         if (! IsFileReadable(filename)) {
38                 return false;
39         }
40         
41         // Verify that the file format is correct.
42         if (! isImageFormatOK(filename)) {
43                 return false;
44         }
45                         
46         filename_ = filename;
47         return true;
48 }
49
50
51 bool Renderer::renderImage()
52 {
53         return false;
54 }
55
56
57 bool Renderer::isImageFormatOK(string const & /*filename*/) const
58 {
59         return false;
60 }
61
62
63 void Renderer::setPixmap(Pixmap pixmap,
64                          unsigned int width, unsigned int height)
65 {
66         freePixmap();
67
68         pixmap_ = pixmap;
69         width_ = width;
70         height_ = height;
71         pixmapLoaded_ = true;
72 }
73
74
75 Pixmap Renderer::getPixmap() const
76 {
77         return pixmap_;
78 }
79
80
81 unsigned int Renderer::getWidth() const
82 {
83         return width_;
84 }
85
86
87 unsigned int Renderer::getHeight() const
88 {
89         return height_;
90 }
91
92
93 string const & Renderer::getFilename() const
94 {
95         return filename_;
96 }
97
98
99 void Renderer::freePixmap()
100 {
101         if (pixmapLoaded_)
102                 XFreePixmap(fl_get_display(), pixmap_);
103 }