Create the AHCI branch for Aman's work
[reactos.git] / base / applications / mspaint / palettemodel.cpp
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 */
8
9 /* INCLUDES *********************************************************/
10
11 #include "precomp.h"
12
13 /* FUNCTIONS ********************************************************/
14
15 PaletteModel::PaletteModel()
16 {
17 m_fgColor = 0x00000000;
18 m_bgColor = 0x00ffffff;
19 SelectPalette(1);
20 }
21
22 int PaletteModel::SelectedPalette()
23 {
24 return m_nSelectedPalette;
25 }
26
27 void PaletteModel::SelectPalette(int nPalette)
28 {
29 int modernColors[28] = {
30 0x000000, 0x464646, 0x787878, 0x300099, 0x241ced, 0x0078ff, 0x0ec2ff,
31 0x00f2ff, 0x1de6a8, 0x4cb122, 0xefb700, 0xf36d4d, 0x99362f, 0x98316f,
32 0xffffff, 0xdcdcdc, 0xb4b4b4, 0x3c5a9c, 0xb1a3ff, 0x7aaae5, 0x9ce4f5,
33 0xbdf9ff, 0xbcf9d3, 0x61bb9d, 0xead999, 0xd19a70, 0x8e6d54, 0xd5a5b5
34 };
35 int oldColors[28] = {
36 0x000000, 0x808080, 0x000080, 0x008080, 0x008000, 0x808000, 0x800000,
37 0x800080, 0x408080, 0x404000, 0xff8000, 0x804000, 0xff0040, 0x004080,
38 0xffffff, 0xc0c0c0, 0x0000ff, 0x00ffff, 0x00ff00, 0xffff00, 0xff0000,
39 0xff00ff, 0x80ffff, 0x80ff00, 0xffff80, 0xff8080, 0x8000ff, 0x4080ff
40 };
41 if (nPalette == 1)
42 CopyMemory(m_colors, modernColors, sizeof(m_colors));
43 else if (nPalette == 2)
44 CopyMemory(m_colors, oldColors, sizeof(m_colors));
45 else
46 return;
47 m_nSelectedPalette = nPalette;
48 NotifyPaletteChanged();
49 }
50
51 int PaletteModel::GetColor(int nIndex)
52 {
53 if (nIndex < 28)
54 return m_colors[nIndex];
55 else
56 return 0;
57 }
58
59 void PaletteModel::SetColor(int nIndex, int newColor)
60 {
61 if (nIndex < 28)
62 {
63 m_colors[nIndex] = newColor;
64 NotifyPaletteChanged();
65 }
66 }
67
68 int PaletteModel::GetFgColor()
69 {
70 return m_fgColor;
71 }
72
73 void PaletteModel::SetFgColor(int newColor)
74 {
75 m_fgColor = newColor;
76 NotifyColorChanged();
77 }
78
79 int PaletteModel::GetBgColor()
80 {
81 return m_bgColor;
82 }
83
84 void PaletteModel::SetBgColor(int newColor)
85 {
86 m_bgColor = newColor;
87 NotifyColorChanged();
88 }
89
90 void PaletteModel::NotifyColorChanged()
91 {
92 paletteWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
93 selectionWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
94 }
95
96 void PaletteModel::NotifyPaletteChanged()
97 {
98 paletteWindow.SendMessage(WM_PALETTEMODELPALETTECHANGED);
99 }