]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: palette.h | |
3 | // Purpose: wxPalette class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
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 | #ifdef __GNUG__ | |
16 | #pragma interface "palette.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/gdiobj.h" | |
f97c9854 | 20 | #include "wx/list.h" |
9b6dbb09 JS |
21 | |
22 | class WXDLLEXPORT wxPalette; | |
23 | ||
f97c9854 JS |
24 | // Palette for one display |
25 | class wxXPalette : public wxObject | |
26 | { | |
27 | DECLARE_DYNAMIC_CLASS(wxXPalette) | |
28 | ||
29 | public: | |
30 | wxXPalette(); | |
31 | ||
32 | WXDisplay* m_display; | |
33 | int m_pix_array_n; | |
34 | unsigned long* m_pix_array; | |
35 | WXColormap m_cmap; | |
36 | bool m_destroyable; | |
37 | }; | |
38 | ||
9b6dbb09 JS |
39 | class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData |
40 | { | |
41 | friend class WXDLLEXPORT wxPalette; | |
42 | public: | |
43 | wxPaletteRefData(); | |
44 | ~wxPaletteRefData(); | |
16c1f7f3 | 45 | |
9b6dbb09 | 46 | protected: |
f97c9854 | 47 | wxList m_palettes; |
9b6dbb09 JS |
48 | }; |
49 | ||
50 | #define M_PALETTEDATA ((wxPaletteRefData *)m_refData) | |
51 | ||
52 | class WXDLLEXPORT wxPalette: public wxGDIObject | |
53 | { | |
54 | DECLARE_DYNAMIC_CLASS(wxPalette) | |
55 | ||
56 | public: | |
57 | wxPalette(); | |
58 | inline wxPalette(const wxPalette& palette) { Ref(palette); } | |
59 | inline wxPalette(const wxPalette* palette) { UnRef(); if (palette) Ref(*palette); } | |
60 | ||
61 | wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); | |
62 | ~wxPalette(); | |
63 | bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); | |
64 | int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const; | |
65 | bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; | |
66 | ||
67 | virtual bool Ok() const { return (m_refData != NULL) ; } | |
68 | ||
69 | inline wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; } | |
70 | inline bool operator == (const wxPalette& palette) { return m_refData == palette.m_refData; } | |
71 | inline bool operator != (const wxPalette& palette) { return m_refData != palette.m_refData; } | |
72 | ||
f97c9854 JS |
73 | // Motif-specific |
74 | WXColormap GetXColormap(WXDisplay* display = NULL) const; | |
75 | bool TransferBitmap(void *data, int depth, int size); | |
76 | bool TransferBitmap8(unsigned char *data, unsigned long size, void *dest, unsigned int bpp); | |
77 | unsigned long *GetXPixArray(WXDisplay* display, int *pix_array_n); | |
78 | void PutXColormap(WXDisplay* display, WXColormap cmap, bool destroyable); | |
9b6dbb09 JS |
79 | }; |
80 | ||
81 | #endif | |
82 | // _WX_PALETTE_H_ |