]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/msw/palette.h | |
3 | // Purpose: wxPalette class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PALETTE_H_ | |
13 | #define _WX_PALETTE_H_ | |
14 | ||
15 | #include "wx/gdiobj.h" | |
16 | ||
17 | class WXDLLEXPORT wxPalette; | |
18 | ||
19 | class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData | |
20 | { | |
21 | friend class WXDLLEXPORT wxPalette; | |
22 | public: | |
23 | wxPaletteRefData(void); | |
24 | ~wxPaletteRefData(void); | |
25 | protected: | |
26 | WXHPALETTE m_hPalette; | |
27 | }; | |
28 | ||
29 | #define M_PALETTEDATA ((wxPaletteRefData *)m_refData) | |
30 | ||
31 | class WXDLLEXPORT wxPalette: public wxPaletteBase | |
32 | { | |
33 | DECLARE_DYNAMIC_CLASS(wxPalette) | |
34 | ||
35 | public: | |
36 | wxPalette(void); | |
37 | inline wxPalette(const wxPalette& palette) : wxPaletteBase(palette) { Ref(palette); } | |
38 | ||
39 | wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); | |
40 | ~wxPalette(void); | |
41 | bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); | |
42 | int GetPixel(unsigned char red, unsigned char green, unsigned char blue) const; | |
43 | bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; | |
44 | ||
45 | virtual bool Ok(void) const { return (m_refData != NULL) ; } | |
46 | ||
47 | inline wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; } | |
48 | inline bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; } | |
49 | inline bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; } | |
50 | ||
51 | virtual bool FreeResource(bool force = false); | |
52 | ||
53 | inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); } | |
54 | void SetHPALETTE(WXHPALETTE pal); | |
55 | }; | |
56 | ||
57 | #endif | |
58 | // _WX_PALETTE_H_ |