]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/XPM.h
Fix spurious label editing in generic wx{List,Tree,DataView}Ctrl.
[wxWidgets.git] / src / stc / scintilla / src / XPM.h
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.
7
8 #ifndef XPM_H
9 #define XPM_H
10
11 #ifdef SCI_NAMESPACE
12 namespace Scintilla {
13 #endif
14
15 /**
16 * Hold a pixmap in XPM format.
17 */
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 ColourDesired *colours;
27 ColourDesired ColourDesiredFromCode(int ch) const;
28 ColourDesired ColourFromCode(int ch) const;
29 void FillRun(Surface *surface, int code, int startX, int y, int x);
30 char **lines;
31 ColourDesired *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 /// Decompose image into runs and use FillRectangle for each run
40 void Draw(Surface *surface, PRectangle &rc);
41 char **InLinesForm() { return lines; }
42 void SetId(int pid_) { pid = pid_; }
43 int GetId() const { return pid; }
44 int GetHeight() const { return height; }
45 int GetWidth() const { return width; }
46 void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const;
47 static const char **LinesFormFromTextForm(const char *textForm);
48 };
49
50 /**
51 * A collection of pixmaps indexed by integer id.
52 */
53 class XPMSet {
54 XPM **set; ///< The stored XPMs.
55 int len; ///< Current number of XPMs.
56 int maximum; ///< Current maximum number of XPMs, increased by steps if reached.
57 int height; ///< Memorize largest height of the set.
58 int width; ///< Memorize largest width of the set.
59 public:
60 XPMSet();
61 ~XPMSet();
62 /// Remove all XPMs.
63 void Clear();
64 /// Add a XPM.
65 void Add(int ident, const char *textForm);
66 /// Get XPM by id.
67 XPM *Get(int ident);
68 /// Give the largest height of the set.
69 int GetHeight();
70 /// Give the largest width of the set.
71 int GetWidth();
72 };
73
74 /**
75 * An translucent image stoed as a sequence of RGBA bytes.
76 */
77 class RGBAImage {
78 // Private so RGBAImage objects can not be copied
79 RGBAImage(const RGBAImage &);
80 RGBAImage &operator=(const RGBAImage &);
81 int height;
82 int width;
83 std::vector<unsigned char> pixelBytes;
84 public:
85 RGBAImage(int width_, int height_, const unsigned char *pixels_);
86 RGBAImage(const XPM &xpm);
87 virtual ~RGBAImage();
88 int GetHeight() const { return height; }
89 int GetWidth() const { return width; }
90 int CountBytes() const;
91 const unsigned char *Pixels() const;
92 void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff);
93 };
94
95 /**
96 * A collection of RGBAImage pixmaps indexed by integer id.
97 */
98 class RGBAImageSet {
99 typedef std::map<int, RGBAImage*> ImageMap;
100 ImageMap images;
101 mutable int height; ///< Memorize largest height of the set.
102 mutable int width; ///< Memorize largest width of the set.
103 public:
104 RGBAImageSet();
105 ~RGBAImageSet();
106 /// Remove all images.
107 void Clear();
108 /// Add an image.
109 void Add(int ident, RGBAImage *image);
110 /// Get image by id.
111 RGBAImage *Get(int ident);
112 /// Give the largest height of the set.
113 int GetHeight() const;
114 /// Give the largest width of the set.
115 int GetWidth() const;
116 };
117
118 #ifdef SCI_NAMESPACE
119 }
120 #endif
121
122 #endif