updated Scintilla to 2.29
[TortoiseGit.git] / ext / scintilla / src / XPM.h
blobd8b59dd6d804c029e8275d125793ab24189b9fc6
1 // Scintilla source code edit control
2 /** @file XPM.h
3 ** Define a class that holds data in the X Pixmap (XPM) format.
4 **/
5 // Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #ifndef XPM_H
9 #define XPM_H
11 #ifdef SCI_NAMESPACE
12 namespace Scintilla {
13 #endif
15 /**
16 * Hold a pixmap in XPM format.
18 class XPM {
19 int pid; // Assigned by container
20 int height;
21 int width;
22 int nColours;
23 char *data;
24 char codeTransparent;
25 char *codes;
26 ColourPair *colours;
27 ColourDesired ColourDesiredFromCode(int ch) const;
28 ColourAllocated ColourFromCode(int ch) const;
29 void FillRun(Surface *surface, int code, int startX, int y, int x);
30 char **lines;
31 ColourPair *colourCodeTable[256];
32 public:
33 XPM(const char *textForm);
34 XPM(const char *const *linesForm);
35 ~XPM();
36 void Init(const char *textForm);
37 void Init(const char *const *linesForm);
38 void Clear();
39 /// Similar to same named method in ViewStyle:
40 void RefreshColourPalette(Palette &pal, bool want);
41 /// No palette used, so just copy the desired colours to the allocated colours
42 void CopyDesiredColours();
43 /// Decompose image into runs and use FillRectangle for each run
44 void Draw(Surface *surface, PRectangle &rc);
45 char **InLinesForm() { return lines; }
46 void SetId(int pid_) { pid = pid_; }
47 int GetId() const { return pid; }
48 int GetHeight() const { return height; }
49 int GetWidth() const { return width; }
50 void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const;
51 static const char **LinesFormFromTextForm(const char *textForm);
54 /**
55 * A collection of pixmaps indexed by integer id.
57 class XPMSet {
58 XPM **set; ///< The stored XPMs.
59 int len; ///< Current number of XPMs.
60 int maximum; ///< Current maximum number of XPMs, increased by steps if reached.
61 int height; ///< Memorize largest height of the set.
62 int width; ///< Memorize largest width of the set.
63 public:
64 XPMSet();
65 ~XPMSet();
66 /// Remove all XPMs.
67 void Clear();
68 /// Add a XPM.
69 void Add(int ident, const char *textForm);
70 /// Get XPM by id.
71 XPM *Get(int ident);
72 /// Give the largest height of the set.
73 int GetHeight();
74 /// Give the largest width of the set.
75 int GetWidth();
78 /**
79 * An translucent image stoed as a sequence of RGBA bytes.
81 class RGBAImage {
82 // Private so RGBAImage objects can not be copied
83 RGBAImage(const RGBAImage &);
84 RGBAImage &operator=(const RGBAImage &);
85 int height;
86 int width;
87 std::vector<unsigned char> pixelBytes;
88 public:
89 RGBAImage(int width_, int height_, const unsigned char *pixels_);
90 RGBAImage(const XPM &xpm);
91 virtual ~RGBAImage();
92 int GetHeight() const { return height; }
93 int GetWidth() const { return width; }
94 int CountBytes() const;
95 const unsigned char *Pixels() const;
96 void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff);
99 /**
100 * A collection of RGBAImage pixmaps indexed by integer id.
102 class RGBAImageSet {
103 typedef std::map<int, RGBAImage*> ImageMap;
104 ImageMap images;
105 mutable int height; ///< Memorize largest height of the set.
106 mutable int width; ///< Memorize largest width of the set.
107 public:
108 RGBAImageSet();
109 ~RGBAImageSet();
110 /// Remove all images.
111 void Clear();
112 /// Add an image.
113 void Add(int ident, RGBAImage *image);
114 /// Get image by id.
115 RGBAImage *Get(int ident);
116 /// Give the largest height of the set.
117 int GetHeight() const;
118 /// Give the largest width of the set.
119 int GetWidth() const;
122 #ifdef SCI_NAMESPACE
124 #endif
126 #endif