1 // Scintilla source code edit control
3 ** Define a class that holds data in the X Pixmap (XPM) format.
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.
16 * Hold a pixmap in XPM format.
19 int pid
; // Assigned by container
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
);
31 ColourPair
*colourCodeTable
[256];
33 XPM(const char *textForm
);
34 XPM(const char *const *linesForm
);
36 void Init(const char *textForm
);
37 void Init(const char *const *linesForm
);
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
);
55 * A collection of pixmaps indexed by integer id.
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.
69 void Add(int ident
, const char *textForm
);
72 /// Give the largest height of the set.
74 /// Give the largest width of the set.
79 * An translucent image stoed as a sequence of RGBA bytes.
82 // Private so RGBAImage objects can not be copied
83 RGBAImage(const RGBAImage
&);
84 RGBAImage
&operator=(const RGBAImage
&);
87 std::vector
<unsigned char> pixelBytes
;
89 RGBAImage(int width_
, int height_
, const unsigned char *pixels_
);
90 RGBAImage(const XPM
&xpm
);
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);
100 * A collection of RGBAImage pixmaps indexed by integer id.
103 typedef std::map
<int, RGBAImage
*> ImageMap
;
105 mutable int height
; ///< Memorize largest height of the set.
106 mutable int width
; ///< Memorize largest width of the set.
110 /// Remove all images.
113 void Add(int ident
, RGBAImage
*image
);
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;