]>
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 | ||
004fd0c8 DW |
27 | #if !USE_SHARED_LIBRARIES |
28 | IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) | |
29 | #endif | |
cdf1e714 | 30 | |
0e320a79 DW |
31 | /* |
32 | * Palette | |
33 | * | |
34 | */ | |
35 | ||
36 | wxPaletteRefData::wxPaletteRefData() | |
37 | { | |
cdf1e714 | 38 | m_hPalette = 0; |
0e320a79 DW |
39 | } |
40 | ||
41 | wxPaletteRefData::~wxPaletteRefData() | |
42 | { | |
cdf1e714 DW |
43 | if ( m_hPalette ) |
44 | return; | |
45 | // TODO: ::DeleteObject((HPALETTE) m_hPalette); | |
0e320a79 DW |
46 | } |
47 | ||
48 | wxPalette::wxPalette() | |
49 | { | |
50 | } | |
51 | ||
52 | wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) | |
53 | { | |
54 | Create(n, red, green, blue); | |
55 | } | |
56 | ||
57 | wxPalette::~wxPalette() | |
58 | { | |
59 | } | |
60 | ||
cdf1e714 DW |
61 | bool wxPalette::FreeResource(bool force) |
62 | { | |
63 | if ( M_PALETTEDATA && M_PALETTEDATA->m_hPalette) | |
64 | { | |
65 | // TODO: DeleteObject((HPALETTE)M_PALETTEDATA->m_hPalette); | |
66 | } | |
67 | return TRUE; | |
68 | } | |
69 | ||
0e320a79 DW |
70 | bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) |
71 | { | |
72 | UnRef(); | |
73 | ||
74 | m_refData = new wxPaletteRefData; | |
75 | ||
76 | // TODO | |
cdf1e714 DW |
77 | /* |
78 | NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) + | |
79 | (WORD)n * sizeof(PALETTEENTRY)); | |
80 | if (!npPal) | |
81 | return(FALSE); | |
82 | ||
83 | npPal->palVersion = 0x300; | |
84 | npPal->palNumEntries = n; | |
85 | ||
86 | int i; | |
87 | for (i = 0; i < n; i ++) | |
88 | { | |
89 | npPal->palPalEntry[i].peRed = red[i]; | |
90 | npPal->palPalEntry[i].peGreen = green[i]; | |
91 | npPal->palPalEntry[i].peBlue = blue[i]; | |
92 | npPal->palPalEntry[i].peFlags = 0; | |
93 | } | |
94 | M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal); | |
95 | LocalFree((HANDLE)npPal); | |
96 | */ | |
fb46a9a6 | 97 | return FALSE; |
0e320a79 DW |
98 | } |
99 | ||
100 | int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const | |
101 | { | |
102 | if ( !m_refData ) | |
103 | return FALSE; | |
104 | ||
105 | // TODO | |
106 | return FALSE; | |
107 | } | |
108 | ||
109 | bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const | |
110 | { | |
111 | if ( !m_refData ) | |
112 | return FALSE; | |
113 | ||
114 | if (index < 0 || index > 255) | |
115 | return FALSE; | |
cdf1e714 DW |
116 | // TODO |
117 | /* | |
118 | PALETTEENTRY entry; | |
119 | if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry)) | |
120 | { | |
121 | *red = entry.peRed; | |
122 | *green = entry.peGreen; | |
123 | *blue = entry.peBlue; | |
124 | return TRUE; | |
125 | } else | |
126 | return FALSE; | |
127 | */ | |
128 | return FALSE; | |
129 | } | |
0e320a79 | 130 | |
cdf1e714 DW |
131 | void wxPalette::SetHPALETTE(WXHPALETTE pal) |
132 | { | |
133 | if ( !m_refData ) | |
134 | m_refData = new wxPaletteRefData; | |
135 | ||
136 | M_PALETTEDATA->m_hPalette = pal; | |
0e320a79 DW |
137 | } |
138 | ||
139 |