ReactOS  0.4.12-dev-51-ge94618b
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 
23  DefWindowProc(WM_PAINT, wParam, lParam);
24 
25  for(b = 2; b < 30; b++)
26  for(a = 2; a < 29; a++)
27  if ((a + b) % 2 == 1)
29 
30  DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
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);
49  DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
50  DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT);
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)
64  paletteModel.SetFgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
65  return 0;
66 }
67 
69 {
70  if (GET_X_LPARAM(lParam) >= 31)
71  paletteModel.SetBgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
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
#define HDC
Definition: msvc.h:22
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
LONG top
Definition: windef.h:297
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
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
COLORREF rgbResult
Definition: commdlg.h:242
DWORD WINAPI GetSysColor(_In_ int)
WPARAM wParam
Definition: combotst.c:138
void SetBgColor(int newColor)
UINT_PTR WPARAM
Definition: windef.h:207
#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
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define a
Definition: ke_i.h:78
LONG_PTR LPARAM
Definition: windef.h:208
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
#define GET_X_LPARAM(lp)
Definition: precomp.h:67
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:99
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int UINT
Definition: ndis.h:50
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
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:589
#define GET_Y_LPARAM(lp)
Definition: precomp.h:68
LONG bottom
Definition: windef.h:299
#define BDR_RAISEDINNER
Definition: winuser.h:444
CHOOSECOLOR choosecolor
Definition: main.cpp:36
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139