]> git.saurik.com Git - wxWidgets.git/blob - src/os2/palette.cpp
OnEnter/OnDragOver API update (compiles, links, somewhat runs under wxGTK)
[wxWidgets.git] / src / os2 / palette.cpp
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
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include <stdio.h>
17 #include "wx/setup.h"
18 #include "wx/palette.h"
19 #endif
20
21 #define INCL_PM
22 #define INCL_GPI
23 #include <os2.h>
24
25 #include "assert.h"
26
27
28 /*
29 * Palette
30 *
31 */
32
33 wxPaletteRefData::wxPaletteRefData()
34 {
35 m_hPalette = 0;
36 }
37
38 wxPaletteRefData::~wxPaletteRefData()
39 {
40 if ( m_hPalette )
41 return;
42 // TODO: ::DeleteObject((HPALETTE) m_hPalette);
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
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
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
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 */
94 return FALSE;
95 }
96
97 int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
98 {
99 if ( !m_refData )
100 return FALSE;
101
102 // TODO
103 return FALSE;
104 }
105
106 bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
107 {
108 if ( !m_refData )
109 return FALSE;
110
111 if (index < 0 || index > 255)
112 return FALSE;
113 // TODO
114 /*
115 PALETTEENTRY entry;
116 if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry))
117 {
118 *red = entry.peRed;
119 *green = entry.peGreen;
120 *blue = entry.peBlue;
121 return TRUE;
122 } else
123 return FALSE;
124 */
125 return FALSE;
126 }
127
128 void wxPalette::SetHPALETTE(WXHPALETTE pal)
129 {
130 if ( !m_refData )
131 m_refData = new wxPaletteRefData;
132
133 M_PALETTEDATA->m_hPalette = pal;
134 }
135
136