ReactOS  0.4.14-dev-115-g4576127
palette.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: PAINT for ReactOS
3  * LICENSE: LGPL
4  * FILE: base/applications/mspaint/palette.cpp
5  * PURPOSE: Window procedure of the palette window
6  * PROGRAMMERS: Benedikt Freisen
7  */
8 
9 /* INCLUDES *********************************************************/
10 
11 #include "precomp.h"
12 
13 /* FUNCTIONS ********************************************************/
14 
16 {
17  RECT rc = { 0, 0, 31, 32 };
18  HDC hDC = GetDC();
19  HPEN oldPen;
20  HBRUSH oldBrush;
21  int i, a, b;
22 
24 
25  for(b = 2; b < 30; b++)
26  for(a = 2; a < 29; a++)
27  if ((a + b) % 2 == 1)
29 
32  SetRect(&rc, 11, 12, 26, 27);
34  oldPen = (HPEN) SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
35  oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(paletteModel.GetBgColor()));
36  Rectangle(hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1);
37  DeleteObject(SelectObject(hDC, oldBrush));
38  SetRect(&rc, 4, 5, 19, 20);
40  oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(paletteModel.GetFgColor()));
41  Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
42  DeleteObject(SelectObject(hDC, oldBrush));
43  DeleteObject(SelectObject(hDC, oldPen));
44 
45  for(i = 0; i < 28; i++)
46  {
47  SetRect(&rc, 31 + (i % 14) * 16,
48  0 + (i / 14) * 16, 16 + 31 + (i % 14) * 16, 16 + 0 + (i / 14) * 16);
51  oldPen = (HPEN) SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
52  oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(paletteModel.GetColor(i)));
53  Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
54  DeleteObject(SelectObject(hDC, oldBrush));
55  DeleteObject(SelectObject(hDC, oldPen));
56  }
57  ReleaseDC(hDC);
58  return 0;
59 }
60 
62 {
63  if (GET_X_LPARAM(lParam) >= 31)
65  return 0;
66 }
67 
69 {
70  if (GET_X_LPARAM(lParam) >= 31)
72  return 0;
73 }
74 
76 {
77  if (GET_X_LPARAM(lParam) >= 31)
79  {
80  paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
83  }
84  return 0;
85 }
86 
88 {
89  if (GET_X_LPARAM(lParam) >= 31)
91  {
92  paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
95  }
96  return 0;
97 }
98 
100 {
102  return 0;
103 }
104 
106 {
108  return 0;
109 }
#define COLOR_BTNHILIGHT
Definition: winuser.h:928
LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: palette.cpp:87
#define BF_MIDDLE
Definition: winuser.h:468
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: palette.cpp:15
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HDC WINAPI GetDC(_In_opt_ HWND)
#define ChooseColor
Definition: commdlg.h:661
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:292
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
void SetColor(int nIndex, int newColor)
LRESULT OnPaletteModelPaletteChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: palette.cpp:105
UINT_PTR WPARAM
Definition: windef.h:207
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
COLORREF rgbResult
Definition: commdlg.h:242
DWORD WINAPI GetSysColor(_In_ int)
WPARAM wParam
Definition: combotst.c:138
void SetBgColor(int newColor)
#define BF_TOPLEFT
Definition: winuser.h:458
#define BF_RECT
Definition: winuser.h:462
LRESULT OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: palette.cpp:68
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define a
Definition: ke_i.h:78
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define BF_BOTTOMRIGHT
Definition: winuser.h:461
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: palette.cpp:61
#define b
Definition: ke_i.h:79
#define DefWindowProc
Definition: ros2win.h:31
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:93
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int GetColor(int nIndex)
#define WM_PAINT
Definition: winuser.h:1602
void SetFgColor(int newColor)
#define BDR_SUNKENOUTER
Definition: winuser.h:443
#define EDGE_RAISED
Definition: winuser.h:450
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: palette.cpp:99
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
PaletteModel paletteModel
Definition: main.cpp:28
unsigned int UINT
Definition: ndis.h:50
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
LRESULT OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: palette.cpp:75
#define PS_NULL
Definition: wingdi.h:590
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
LONG bottom
Definition: windef.h:294
#define BDR_RAISEDINNER
Definition: winuser.h:444
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
CHOOSECOLOR choosecolor
Definition: main.cpp:36
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139