]> git.saurik.com Git - wxWidgets.git/blame - src/stc/scintilla/src/XPM.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / src / stc / scintilla / src / XPM.h
CommitLineData
9e730a78
RD
1// Scintilla source code edit control
2/** @file XPM.h
8e54aaed 3 ** Define a class that holds data in the X Pixmap (XPM) format.
9e730a78
RD
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
7e0c58e9
RD
11#ifdef SCI_NAMESPACE
12namespace Scintilla {
13#endif
14
9e730a78
RD
15/**
16 * Hold a pixmap in XPM format.
17 */
18class XPM {
9e96e16f 19 int pid; // Assigned by container
9e730a78
RD
20 int height;
21 int width;
22 int nColours;
23 char *data;
24 char codeTransparent;
25 char *codes;
1dcf666d
RD
26 ColourDesired *colours;
27 ColourDesired ColourDesiredFromCode(int ch) const;
28 ColourDesired ColourFromCode(int ch) const;
9e730a78
RD
29 void FillRun(Surface *surface, int code, int startX, int y, int x);
30 char **lines;
1dcf666d 31 ColourDesired *colourCodeTable[256];
9e730a78
RD
32public:
33 XPM(const char *textForm);
1dcf666d 34 XPM(const char *const *linesForm);
9e730a78
RD
35 ~XPM();
36 void Init(const char *textForm);
1dcf666d 37 void Init(const char *const *linesForm);
9e730a78 38 void Clear();
8e54aaed 39 /// Decompose image into runs and use FillRectangle for each run
9e730a78
RD
40 void Draw(Surface *surface, PRectangle &rc);
41 char **InLinesForm() { return lines; }
9e96e16f 42 void SetId(int pid_) { pid = pid_; }
1dcf666d
RD
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;
9e730a78
RD
47 static const char **LinesFormFromTextForm(const char *textForm);
48};
49
50/**
51 * A collection of pixmaps indexed by integer id.
52 */
53class XPMSet {
8e54aaed
RD
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.
9e730a78
RD
59public:
60 XPMSet();
61 ~XPMSet();
8e54aaed 62 /// Remove all XPMs.
9e730a78 63 void Clear();
8e54aaed 64 /// Add a XPM.
1dcf666d 65 void Add(int ident, const char *textForm);
8e54aaed 66 /// Get XPM by id.
1dcf666d 67 XPM *Get(int ident);
8e54aaed 68 /// Give the largest height of the set.
9e730a78 69 int GetHeight();
8e54aaed 70 /// Give the largest width of the set.
9e730a78
RD
71 int GetWidth();
72};
73
1dcf666d
RD
74/**
75 * An translucent image stoed as a sequence of RGBA bytes.
76 */
77class 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;
84public:
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 */
98class 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.
103public:
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
7e0c58e9
RD
118#ifdef SCI_NAMESPACE
119}
120#endif
121
9e730a78 122#endif