~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/sdk/wxscintilla/src/scintilla/src/XPM.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Scintilla source code edit control
 
2
/** @file XPM.h
 
3
 ** Define a classes to hold image data in the X Pixmap (XPM) and RGBA formats.
 
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
/* C::B begin */
 
12
#include <map>
 
13
#include <vector>
 
14
/* C::B end */
 
15
 
 
16
#ifdef SCI_NAMESPACE
 
17
namespace Scintilla {
 
18
#endif
 
19
 
 
20
/**
 
21
 * Hold a pixmap in XPM format.
 
22
 */
 
23
class XPM {
 
24
        int height;
 
25
        int width;
 
26
        int nColours;
 
27
        std::vector<unsigned char> pixels;
 
28
        ColourDesired colourCodeTable[256];
 
29
        char codeTransparent;
 
30
        ColourDesired ColourFromCode(int ch) const;
 
31
        void FillRun(Surface *surface, int code, int startX, int y, int x);
 
32
public:
 
33
        explicit XPM(const char *textForm);
 
34
        explicit XPM(const char *const *linesForm);
 
35
        ~XPM();
 
36
        void Init(const char *textForm);
 
37
        void Init(const char *const *linesForm);
 
38
        /// Decompose image into runs and use FillRectangle for each run
 
39
        void Draw(Surface *surface, PRectangle &rc);
 
40
        int GetHeight() const { return height; }
 
41
        int GetWidth() const { return width; }
 
42
        void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const;
 
43
private:
 
44
        static std::vector<const char *>LinesFormFromTextForm(const char *textForm);
 
45
};
 
46
 
 
47
/**
 
48
 * A translucent image stored as a sequence of RGBA bytes.
 
49
 */
 
50
class RGBAImage {
 
51
        // Private so RGBAImage objects can not be copied
 
52
        RGBAImage(const RGBAImage &);
 
53
        RGBAImage &operator=(const RGBAImage &);
 
54
        int height;
 
55
        int width;
 
56
        float scale;
 
57
        std::vector<unsigned char> pixelBytes;
 
58
public:
 
59
        RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_);
 
60
        explicit RGBAImage(const XPM &xpm);
 
61
        virtual ~RGBAImage();
 
62
        int GetHeight() const { return height; }
 
63
        int GetWidth() const { return width; }
 
64
        float GetScale() const { return scale; }
 
65
        float GetScaledHeight() const { return height / scale; }
 
66
        float GetScaledWidth() const { return width / scale; }
 
67
        int CountBytes() const;
 
68
        const unsigned char *Pixels() const;
 
69
        void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff);
 
70
};
 
71
 
 
72
/**
 
73
 * A collection of RGBAImage pixmaps indexed by integer id.
 
74
 */
 
75
class RGBAImageSet {
 
76
        typedef std::map<int, RGBAImage*> ImageMap;
 
77
        ImageMap images;
 
78
        mutable int height;     ///< Memorize largest height of the set.
 
79
        mutable int width;      ///< Memorize largest width of the set.
 
80
public:
 
81
        RGBAImageSet();
 
82
        ~RGBAImageSet();
 
83
        /// Remove all images.
 
84
        void Clear();
 
85
        /// Add an image.
 
86
        void Add(int ident, RGBAImage *image);
 
87
        /// Get image by id.
 
88
        RGBAImage *Get(int ident);
 
89
        /// Give the largest height of the set.
 
90
        int GetHeight() const;
 
91
        /// Give the largest width of the set.
 
92
        int GetWidth() const;
 
93
};
 
94
 
 
95
#ifdef SCI_NAMESPACE
 
96
}
 
97
#endif
 
98
 
 
99
#endif