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