]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsImage.h
ad9c5c588fd2606cc5ead3be9ff0f404596e519b
[lyx.git] / src / graphics / GraphicsImage.h
1 // -*- C++ -*-
2 /**
3  * \file GraphicsImage.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Baruch Even
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  *
12  * An abstract base class for the images themselves.
13  * Allows the user to retrieve the pixmap, once loaded and to issue commands
14  * to modify it.
15  *
16  * The boost::functions newImage and loadableFormats are connected to the
17  * appropriate derived classes elsewhere, allowing the graphics cache to
18  * access them without knowing anything about their instantiation.
19  *
20  * The loading process can be asynchronous, but cropping, rotating and
21  * scaling block execution.
22  */
23
24 #ifndef GRAPHICSIMAGE_H
25 #define GRAPHICSIMAGE_H
26
27 #include "Dimension.h"
28
29 #include <boost/function.hpp>
30 #include <boost/signal.hpp>
31
32 #include <vector>
33
34 namespace lyx {
35
36 namespace support { class FileName; }
37
38 namespace graphics {
39
40 class Params;
41
42 class Image {
43 public:
44         /** This is to be connected to a function that will return a new
45          *  instance of a viable derived class.
46          */
47         static boost::function<Image *()> newImage;
48
49         ///
50         virtual ~Image() {}
51
52         /// Create a copy
53         virtual Image * clone() const = 0;
54
55         /// Get the image width
56         virtual unsigned int width() const = 0;
57
58         /// Get the image height
59         virtual unsigned int height() const = 0;
60
61         /// Is the image drawable ?
62         virtual bool isDrawable() const = 0;
63
64         /** At the end of the loading process inform the outside world
65          *  by emitting a signal
66          */
67         typedef boost::signal<void(bool)> SignalType;
68         ///
69         SignalType finishedLoading;
70
71         /** Start loading the image file.
72          *  The caller should expect this process to be asynchronous and
73          *  so should connect to the "finished" signal above.
74          */
75         virtual bool load(support::FileName const & filename) = 0;
76
77         /** Generate the pixmap.
78          *  Uses the params to decide on color, grayscale etc.
79          *  Returns true if the pixmap is created.
80          */
81         virtual bool setPixmap(Params const & params) = 0;
82
83 protected:
84         /// Must define default c-tor explicitly as we define a copy c-tor.
85         Image() {}
86         /// Don't copy the signal finishedLoading
87         Image(Image const &) {}
88 };
89
90
91 } // namespace graphics
92 } // namespace lyx
93
94 #endif // GRAPHICSIMAGE_H