]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xformsImage.h
Tiny clean-ups.
[lyx.git] / src / frontends / xforms / xformsImage.h
1 // -*- C++ -*-
2 /**
3  * \file xformsImage.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 /* An instantiation of Image that makes use of the xforms lirary routines
13  * to load and store the image in memory.
14  */
15
16 #ifndef XFORMSIMAGE_H
17 #define XFORMSIMAGE_H
18
19
20 #include "graphics/GraphicsImage.h"
21
22 #include <X11/X.h>
23
24 struct flimage_;
25 typedef flimage_ FL_IMAGE;
26
27 namespace lyx {
28 namespace graphics {
29
30 class xformsImage : public Image
31 {
32 public:
33         /// Access to this class is through this static method.
34         static ImagePtr newImage();
35
36         /// Return the list of loadable formats.
37         static FormatList loadableFormats();
38
39         ///
40         ~xformsImage();
41         ///
42         Pixmap getPixmap() const;
43
44         /// Internal callbacks.
45         void statusCB(std::string const &);
46         void errorCB(std::string const &);
47
48 private:
49         /// Create a copy
50         virtual Image * clone_impl() const;
51         /// Get the image width
52         virtual unsigned int getWidth_impl() const;
53         /// Get the image height
54         virtual unsigned int getHeight_impl() const;
55         /// Is the image drawable ?
56         virtual bool isDrawable_impl() const;
57         /** Load the image file into memory.
58          *  The process is asynchronous, so this method starts the loading.
59          *  When finished, the Image::finishedLoading signal is emitted.
60          */
61         virtual void load_impl(std::string const & filename);
62         /** Generate the pixmap, based on the current state of
63          *  image_ (clipped, rotated, scaled etc).
64          *  Uses the params to decide on color, grayscale etc.
65          *  Returns true if the pixmap is created.
66          */
67         bool setPixmap_impl(Params const & params);
68         /// Clip the image using params.
69         virtual void clip_impl(Params const & params);
70
71         /// Rotate the image using params.
72         virtual void rotate_impl(Params const & params);
73
74         /// Scale the image using params.
75         virtual void scale_impl(Params const & params);
76
77         /// Access to the class is through newImage() and clone.
78         xformsImage();
79         ///
80         xformsImage(xformsImage const &);
81
82         /// The xforms container.
83         FL_IMAGE * image_;
84
85         /// The pixmap itself.
86         Pixmap pixmap_;
87
88         /// Is the pixmap initialized?
89         enum PixmapStatus {
90                 ///
91                 PIXMAP_UNINITIALISED,
92                 ///
93                 PIXMAP_FAILED,
94                 ///
95                 PIXMAP_SUCCESS
96         };
97
98         PixmapStatus pixmap_status_;
99 };
100
101 } // namespace graphics
102 } // namespace lyx
103
104 #endif // XFORMSIMAGE_H