]> git.saurik.com Git - wxWidgets.git/blob - src/os2/palette.cpp
Take out statbrpm, add statline back in
[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 #if !USE_SHARED_LIBRARIES
28 IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
29 #endif
30
31 /*
32 * Palette
33 *
34 */
35
36 wxPaletteRefData::wxPaletteRefData()
37 {
38 m_hPalette = 0;
39 }
40
41 wxPaletteRefData::~wxPaletteRefData()
42 {
43 if ( m_hPalette )
44 return;
45 // TODO: ::DeleteObject((HPALETTE) m_hPalette);
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
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
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
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 */
97 return FALSE;
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;
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 }
130
131 void wxPalette::SetHPALETTE(WXHPALETTE pal)
132 {
133 if ( !m_refData )
134 m_refData = new wxPaletteRefData;
135
136 M_PALETTEDATA->m_hPalette = pal;
137 }
138
139