]> git.saurik.com Git - wxWidgets.git/blame - src/os2/palette.cpp
made wxPanel be auto layout aware
[wxWidgets.git] / src / os2 / palette.cpp
CommitLineData
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
33wxPaletteRefData::wxPaletteRefData()
34{
cdf1e714 35 m_hPalette = 0;
0e320a79
DW
36}
37
38wxPaletteRefData::~wxPaletteRefData()
39{
cdf1e714
DW
40 if ( m_hPalette )
41 return;
42 // TODO: ::DeleteObject((HPALETTE) m_hPalette);
0e320a79
DW
43}
44
45wxPalette::wxPalette()
46{
47}
48
49wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
50{
51 Create(n, red, green, blue);
52}
53
54wxPalette::~wxPalette()
55{
56}
57
cdf1e714
DW
58bool 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
67bool 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*/
fb46a9a6 94 return FALSE;
0e320a79
DW
95}
96
97int 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
106bool 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;
cdf1e714
DW
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}
0e320a79 127
cdf1e714
DW
128void wxPalette::SetHPALETTE(WXHPALETTE pal)
129{
130 if ( !m_refData )
131 m_refData = new wxPaletteRefData;
132
133 M_PALETTEDATA->m_hPalette = pal;
0e320a79
DW
134}
135
136