]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: palette.cpp | |
3 | // Purpose: wxPalette | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
cdf1e714 DW |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
0e320a79 | 14 | |
cdf1e714 DW |
15 | #ifndef WX_PRECOMP |
16 | #include <stdio.h> | |
17 | #include "wx/setup.h" | |
0e320a79 | 18 | #include "wx/palette.h" |
0e320a79 DW |
19 | #endif |
20 | ||
cdf1e714 DW |
21 | #define INCL_PM |
22 | #define INCL_GPI | |
23 | #include <os2.h> | |
24 | ||
25 | #include "assert.h" | |
26 | ||
27 | ||
0e320a79 DW |
28 | /* |
29 | * Palette | |
30 | * | |
31 | */ | |
32 | ||
33 | wxPaletteRefData::wxPaletteRefData() | |
34 | { | |
cdf1e714 | 35 | m_hPalette = 0; |
0e320a79 DW |
36 | } |
37 | ||
38 | wxPaletteRefData::~wxPaletteRefData() | |
39 | { | |
cdf1e714 DW |
40 | if ( m_hPalette ) |
41 | return; | |
42 | // TODO: ::DeleteObject((HPALETTE) m_hPalette); | |
0e320a79 DW |
43 | } |
44 | ||
45 | wxPalette::wxPalette() | |
46 | { | |
47 | } | |
48 | ||
49 | wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) | |
50 | { | |
51 | Create(n, red, green, blue); | |
52 | } | |
53 | ||
54 | wxPalette::~wxPalette() | |
55 | { | |
56 | } | |
57 | ||
cdf1e714 DW |
58 | bool wxPalette::FreeResource(bool force) |
59 | { | |
60 | if ( M_PALETTEDATA && M_PALETTEDATA->m_hPalette) | |
61 | { | |
62 | // TODO: DeleteObject((HPALETTE)M_PALETTEDATA->m_hPalette); | |
63 | } | |
64 | return TRUE; | |
65 | } | |
66 | ||
0e320a79 DW |
67 | bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) |
68 | { | |
69 | UnRef(); | |
70 | ||
71 | m_refData = new wxPaletteRefData; | |
72 | ||
73 | // TODO | |
cdf1e714 DW |
74 | /* |
75 | NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) + | |
76 | (WORD)n * sizeof(PALETTEENTRY)); | |
77 | if (!npPal) | |
78 | return(FALSE); | |
79 | ||
80 | npPal->palVersion = 0x300; | |
81 | npPal->palNumEntries = n; | |
82 | ||
83 | int i; | |
84 | for (i = 0; i < n; i ++) | |
85 | { | |
86 | npPal->palPalEntry[i].peRed = red[i]; | |
87 | npPal->palPalEntry[i].peGreen = green[i]; | |
88 | npPal->palPalEntry[i].peBlue = blue[i]; | |
89 | npPal->palPalEntry[i].peFlags = 0; | |
90 | } | |
91 | M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal); | |
92 | LocalFree((HANDLE)npPal); | |
93 | */ | |
0e320a79 DW |
94 | } |
95 | ||
96 | int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const | |
97 | { | |
98 | if ( !m_refData ) | |
99 | return FALSE; | |
100 | ||
101 | // TODO | |
102 | return FALSE; | |
103 | } | |
104 | ||
105 | bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const | |
106 | { | |
107 | if ( !m_refData ) | |
108 | return FALSE; | |
109 | ||
110 | if (index < 0 || index > 255) | |
111 | return FALSE; | |
cdf1e714 DW |
112 | // TODO |
113 | /* | |
114 | PALETTEENTRY entry; | |
115 | if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry)) | |
116 | { | |
117 | *red = entry.peRed; | |
118 | *green = entry.peGreen; | |
119 | *blue = entry.peBlue; | |
120 | return TRUE; | |
121 | } else | |
122 | return FALSE; | |
123 | */ | |
124 | return FALSE; | |
125 | } | |
0e320a79 | 126 | |
cdf1e714 DW |
127 | void wxPalette::SetHPALETTE(WXHPALETTE pal) |
128 | { | |
129 | if ( !m_refData ) | |
130 | m_refData = new wxPaletteRefData; | |
131 | ||
132 | M_PALETTEDATA->m_hPalette = pal; | |
0e320a79 DW |
133 | } |
134 | ||
135 |