]> git.saurik.com Git - wxWidgets.git/blame - include/wx/image.h
2nd attempt at MDI in wxMotif, using wxNotebook this time (still some probs).
[wxWidgets.git] / include / wx / image.h
CommitLineData
01111366
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: image.h
3// Purpose: wxImage class
4// Author: Robert Roebling
5// RCS-ID: $Id$
6// Copyright: (c) Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_IMAGE_H_
11#define _WX_IMAGE_H_
12
13#ifdef __GNUG__
14#pragma interface "image.h"
15#endif
16
17#include "wx/setup.h"
18#include "wx/object.h"
19#include "wx/string.h"
20#include "wx/gdicmn.h"
21
22//-----------------------------------------------------------------------------
23// classes
24//-----------------------------------------------------------------------------
25
26class WXDLLEXPORT wxImageHandler;
27class WXDLLEXPORT wxPNGHandler;
28class WXDLLEXPORT wxBMPHandler;
29class WXDLLEXPORT wxImage;
30
31//-----------------------------------------------------------------------------
32// wxImageHandler
33//-----------------------------------------------------------------------------
34
35class WXDLLEXPORT wxImageHandler: public wxObject
36{
37 DECLARE_DYNAMIC_CLASS(wxImageHandler)
38
39public:
40 wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; }
41
42 virtual bool LoadFile( wxImage *image, const wxString& name );
43 virtual bool SaveFile( wxImage *image, const wxString& name );
44
45 inline void SetName(const wxString& name) { m_name = name; }
46 inline void SetExtension(const wxString& ext) { m_extension = ext; }
47 inline void SetType(long type) { m_type = type; }
48 inline wxString GetName() const { return m_name; }
49 inline wxString GetExtension() const { return m_extension; }
50 inline long GetType() const { return m_type; }
51
52protected:
53 wxString m_name;
54 wxString m_extension;
55 long m_type;
56
57};
58
59//-----------------------------------------------------------------------------
60// wxPNGHandler
61//-----------------------------------------------------------------------------
62
63class WXDLLEXPORT wxPNGHandler: public wxImageHandler
64{
65 DECLARE_DYNAMIC_CLASS(wxPNGHandler)
66
67public:
68
fd0eed64
RR
69 inline wxPNGHandler()
70 {
71 m_name = "PNG file";
72 m_extension = "png";
73 m_type = wxBITMAP_TYPE_PNG;
74 };
75
76 virtual bool LoadFile( wxImage *image, const wxString& name );
77 virtual bool SaveFile( wxImage *image, const wxString& name );
01111366
RR
78};
79
80//-----------------------------------------------------------------------------
81// wxBMPHandler
82//-----------------------------------------------------------------------------
83
84class WXDLLEXPORT wxBMPHandler: public wxImageHandler
85{
86 DECLARE_DYNAMIC_CLASS(wxBMPHandler)
87
88public:
89
fd0eed64
RR
90 inline wxBMPHandler()
91 {
92 m_name = "BMP file";
93 m_extension = "bmp";
94 m_type = wxBITMAP_TYPE_BMP;
95 };
01111366 96
fd0eed64 97 virtual bool LoadFile( wxImage *image, const wxString& name );
01111366 98};
fd0eed64 99
01111366
RR
100//-----------------------------------------------------------------------------
101// wxImage
102//-----------------------------------------------------------------------------
103
104class WXDLLEXPORT wxImage: public wxObject
105{
106 DECLARE_DYNAMIC_CLASS(wxImage)
107
108 friend class WXDLLEXPORT wxImageHandler;
109
110public:
111
112 wxImage();
113 wxImage( int width, int height );
114 wxImage( const wxString& name, long type = wxBITMAP_TYPE_PNG );
115
116 wxImage( const wxImage& image );
117 wxImage( const wxImage* image );
118
119 void Create( int width, int height );
120 void Destroy();
121
122 virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG );
123 virtual bool SaveFile( const wxString& name, int type );
124
125 bool Ok() const;
126 int GetWidth() const;
127 int GetHeight() const;
128
129 char unsigned *GetData() const;
130 void SetData( char unsigned *data );
131
132 void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
133 unsigned char GetMaskRed() const;
134 unsigned char GetMaskGreen() const;
135 unsigned char GetMaskBlue() const;
136 void SetMask( bool mask = TRUE );
137 bool HasMask() const;
138
139 inline wxImage& operator = (const wxImage& image)
140 { if (*this == image) return (*this); Ref(image); return *this; }
141 inline bool operator == (const wxImage& image)
142 { return m_refData == image.m_refData; }
143 inline bool operator != (const wxImage& image)
144 { return m_refData != image.m_refData; }
145
146 static inline wxList& GetHandlers() { return sm_handlers; }
147 static void AddHandler( wxImageHandler *handler );
148 static void InsertHandler( wxImageHandler *handler );
149 static bool RemoveHandler( const wxString& name );
150 static wxImageHandler *FindHandler( const wxString& name );
151 static wxImageHandler *FindHandler( const wxString& extension, long imageType );
152 static wxImageHandler *FindHandler( long imageType );
153
154 static void CleanUpHandlers();
fd0eed64 155 static void InitStandardHandlers();
01111366
RR
156
157protected:
158
159 static wxList sm_handlers;
160
161};
162
163#endif
164 // _WX_IMAGE_H_