ReactOS  0.4.15-dev-5492-g47f3a4e
palettemodel.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: PAINT for ReactOS
3  * LICENSE: LGPL
4  * FILE: base/applications/mspaint/palettemodel.cpp
5  * PURPOSE: Keep track of palette data, notify listeners
6  * PROGRAMMERS: Benedikt Freisen
7  * Katayama Hirofumi MZ
8  */
9 
10 /* INCLUDES *********************************************************/
11 
12 #include "precomp.h"
13 
14 /* FUNCTIONS ********************************************************/
15 
17 {
18  m_fgColor = 0x00000000;
19  m_bgColor = 0x00ffffff;
21 }
22 
24 {
25  return m_nSelectedPalette;
26 }
27 
29 {
30  static const COLORREF modernColors[NUM_COLORS] =
31  {
32  0x000000, 0x464646, 0x787878, 0x300099, 0x241ced, 0x0078ff, 0x0ec2ff,
33  0x00f2ff, 0x1de6a8, 0x4cb122, 0xefb700, 0xf36d4d, 0x99362f, 0x98316f,
34  0xffffff, 0xdcdcdc, 0xb4b4b4, 0x3c5a9c, 0xb1a3ff, 0x7aaae5, 0x9ce4f5,
35  0xbdf9ff, 0xbcf9d3, 0x61bb9d, 0xead999, 0xd19a70, 0x8e6d54, 0xd5a5b5
36  };
37  static const COLORREF oldColors[NUM_COLORS] =
38  {
39  0x000000, 0x808080, 0x000080, 0x008080, 0x008000, 0x808000, 0x800000,
40  0x800080, 0x408080, 0x404000, 0xff8000, 0x804000, 0xff0040, 0x004080,
41  0xffffff, 0xc0c0c0, 0x0000ff, 0x00ffff, 0x00ff00, 0xffff00, 0xff0000,
42  0xff00ff, 0x80ffff, 0x80ff00, 0xffff80, 0xff8080, 0x8000ff, 0x4080ff
43  };
44  switch (nPalette)
45  {
46  case PAL_MODERN:
47  CopyMemory(m_colors, modernColors, sizeof(m_colors));
48  break;
49  case PAL_OLDTYPE:
50  CopyMemory(m_colors, oldColors, sizeof(m_colors));
51  break;
52  }
53  m_nSelectedPalette = nPalette;
55 }
56 
58 {
59  if (nIndex < NUM_COLORS)
60  return m_colors[nIndex];
61  else
62  return 0;
63 }
64 
65 void PaletteModel::SetColor(UINT nIndex, COLORREF newColor)
66 {
67  if (nIndex < NUM_COLORS)
68  {
69  m_colors[nIndex] = newColor;
71  }
72 }
73 
75 {
76  return m_fgColor;
77 }
78 
80 {
81  m_fgColor = newColor;
83 }
84 
86 {
87  return m_bgColor;
88 }
89 
91 {
92  m_bgColor = newColor;
94 }
95 
97 {
98  if (paletteWindow.IsWindow())
100  if (selectionWindow.IsWindow())
102  if (textEditWindow.IsWindow())
104 }
105 
107 {
108  if (paletteWindow.IsWindow())
110 }
PAL_TYPE m_nSelectedPalette
Definition: palettemodel.h:25
void SelectPalette(PAL_TYPE nPalette)
void SetFgColor(COLORREF newColor)
void NotifyPaletteChanged()
COLORREF m_bgColor
Definition: palettemodel.h:27
COLORREF m_fgColor
Definition: palettemodel.h:26
#define NUM_COLORS
Definition: palettemodel.h:11
COLORREF m_colors[NUM_COLORS]
Definition: palettemodel.h:24
#define WM_PALETTEMODELCOLORCHANGED
Definition: precomp.h:35
COLORREF GetBgColor() const
COLORREF GetFgColor() const
void SetBgColor(COLORREF newColor)
void SetColor(UINT nIndex, COLORREF newColor)
COLORREF GetColor(UINT nIndex) const
void NotifyColorChanged()
DWORD COLORREF
Definition: windef.h:300
#define CopyMemory
Definition: winbase.h:1668
PAL_TYPE
Definition: palettemodel.h:13
CPaletteWindow paletteWindow
Definition: main.cpp:68
#define WM_PALETTEMODELPALETTECHANGED
Definition: precomp.h:36
unsigned int UINT
Definition: ndis.h:50
PAL_TYPE SelectedPalette()
CTextEditWindow textEditWindow
Definition: main.cpp:81
CSelectionWindow selectionWindow
Definition: main.cpp:71