ReactOS 0.4.17-dev-470-gf9e3448
palettemodel.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4 * PURPOSE: Keep track of palette data, notify listeners
5 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6 * Copyright 2021-2026 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7 */
8
9#include "precomp.h"
10
12
13/* FUNCTIONS ********************************************************/
14
16{
17 m_fgColor = RGB(0, 0, 0);
18 m_bgColor = RGB(255, 255, 255);
20}
21
23{
24 return m_nSelectedPalette;
25}
26
28{
29 static const COLORREF modernColors[NUM_COLORS] =
30 {
31 0x000000, 0x464646, 0x787878, 0x300099, 0x241ced, 0x0078ff, 0x0ec2ff,
32 0x00f2ff, 0x1de6a8, 0x4cb122, 0xefb700, 0xf36d4d, 0x99362f, 0x98316f,
33 0xffffff, 0xdcdcdc, 0xb4b4b4, 0x3c5a9c, 0xb1a3ff, 0x7aaae5, 0x9ce4f5,
34 0xbdf9ff, 0xbcf9d3, 0x61bb9d, 0xead999, 0xd19a70, 0x8e6d54, 0xd5a5b5
35 };
36 static const COLORREF oldColors[NUM_COLORS] =
37 {
38 0x000000, 0x808080, 0x000080, 0x008080, 0x008000, 0x808000, 0x800000,
39 0x800080, 0x408080, 0x404000, 0xff8000, 0x804000, 0xff0040, 0x004080,
40 0xffffff, 0xc0c0c0, 0x0000ff, 0x00ffff, 0x00ff00, 0xffff00, 0xff0000,
41 0xff00ff, 0x80ffff, 0x80ff00, 0xffff80, 0xff8080, 0x8000ff, 0x4080ff
42 };
43 static const COLORREF grayscale[NUM_COLORS] =
44 {
45 0x000000, 0x090909, 0x121212, 0x1C1C1C, 0x252525, 0x2F2F2F, 0x383838,
46 0x424242, 0x4B4B4B, 0x555555, 0x5E5E5E, 0x676767, 0x717171, 0x7B7B7B,
47 0xFFFFFF, 0xF6F6F6, 0xEDEDED, 0xE3E3E3, 0xD9D9D9, 0xD0D0D0, 0xC7C7C7,
48 0xBDBDBD, 0xB4B4B4, 0xAAAAAA, 0xA1A1A1, 0x979797, 0x8E8E8E, 0x848484
49 };
50 switch (nPalette)
51 {
52 case PAL_MODERN:
53 CopyMemory(m_colors, modernColors, sizeof(m_colors));
54 break;
55 case PAL_OLDTYPE:
56 CopyMemory(m_colors, oldColors, sizeof(m_colors));
57 break;
58 case PAL_GRAYSCALE:
59 case PAL_MONOCHROME:
60 CopyMemory(m_colors, grayscale, sizeof(m_colors));
61 break;
62 }
63 m_nSelectedPalette = nPalette;
64 m_fgColor = RGB(0, 0, 0);
65 m_bgColor = RGB(255, 255, 255);
67}
68
70{
71 if (nIndex < NUM_COLORS)
72 return m_colors[nIndex];
73 else
74 return 0;
75}
76
77void PaletteModel::SetColor(UINT nIndex, COLORREF newColor)
78{
79 if (nIndex < NUM_COLORS)
80 {
81 m_colors[nIndex] = newColor;
83 }
84}
85
87{
88 return m_fgColor;
89}
90
92{
93 m_fgColor = newColor;
95}
96
98{
99 return m_bgColor;
100}
101
103{
104 m_bgColor = newColor;
106}
107
109{
110 if (paletteWindow.IsWindow())
112 if (canvasWindow.IsWindow())
114 if (textEditWindow.IsWindow())
116}
117
119{
120 if (paletteWindow.IsWindow())
121 paletteWindow.Invalidate(FALSE);
122}
#define WM_PALETTEMODELCOLORCHANGED
Definition: precomp.h:54
CTextEditWindow textEditWindow
Definition: textedit.cpp:12
CCanvasWindow canvasWindow
Definition: canvas.cpp:11
PAL_TYPE SelectedPalette()
COLORREF GetBgColor() const
void SetFgColor(COLORREF newColor)
void SetBgColor(COLORREF newColor)
void SelectPalette(PAL_TYPE nPalette)
void NotifyPaletteChanged()
void SetColor(UINT nIndex, COLORREF newColor)
COLORREF GetFgColor() const
PAL_TYPE m_nSelectedPalette
Definition: palettemodel.h:26
COLORREF GetColor(UINT nIndex) const
COLORREF m_fgColor
Definition: palettemodel.h:27
COLORREF m_colors[NUM_COLORS]
Definition: palettemodel.h:25
COLORREF m_bgColor
Definition: palettemodel.h:28
void NotifyColorChanged()
#define FALSE
Definition: types.h:117
#define RGB(r, g, b)
Definition: precomp.h:67
unsigned int UINT
Definition: sysinfo.c:13
#define CopyMemory
Definition: minwinbase.h:29
CPaletteWindow paletteWindow
Definition: palette.cpp:19
PaletteModel paletteModel
PAL_TYPE
Definition: palettemodel.h:13
@ PAL_MONOCHROME
Definition: palettemodel.h:17
@ PAL_GRAYSCALE
Definition: palettemodel.h:16
@ PAL_MODERN
Definition: palettemodel.h:14
@ PAL_OLDTYPE
Definition: palettemodel.h:15
#define NUM_COLORS
Definition: palettemodel.h:10
DWORD COLORREF
Definition: windef.h:100