ReactOS 0.4.15-dev-7958-gcd0bb1a
CPaletteWindow Class Reference

#include <palette.h>

Inheritance diagram for CPaletteWindow:
Collaboration diagram for CPaletteWindow:

Public Member Functions

 CPaletteWindow ()
 
virtual ~CPaletteWindow ()
 

Protected Member Functions

LRESULT OnEraseBkgnd (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnPaint (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnRButtonDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonDblClk (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnRButtonDblClk (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMouseMove (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonUp (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnPaletteModelColorChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
INT DoHitTest (INT xPos, INT yPos) const
 

Protected Attributes

HBITMAP m_hbmCached
 

Detailed Description

Definition at line 14 of file palette.h.

Constructor & Destructor Documentation

◆ CPaletteWindow()

CPaletteWindow::CPaletteWindow ( )

Definition at line 23 of file palette.cpp.

25{
26}
HBITMAP m_hbmCached
Definition: palette.h:35
#define NULL
Definition: types.h:112

◆ ~CPaletteWindow()

CPaletteWindow::~CPaletteWindow ( )
virtual

Definition at line 28 of file palette.cpp.

29{
30 if (m_hbmCached)
32}
pKey DeleteObject()

Member Function Documentation

◆ DoHitTest()

INT CPaletteWindow::DoHitTest ( INT  xPos,
INT  yPos 
) const
protected

Definition at line 55 of file palette.cpp.

56{
57 RECT rcClient;
58 GetClientRect(&rcClient);
59
60 /* delta x and y */
61 INT dx = (xPos - X_COLORBOX_OFFSET), dy = (yPos - Y_MARGIN);
62
63 /* horizontal and vertical indexes */
64 INT ix = (dx / CXY_COLORBOX), iy = (dy / CXY_COLORBOX);
65
66 /* Is it inside of a color box? */
67 if (0 <= ix && ix < HALF_COLOR_COUNT && 0 <= iy && iy < 2)
68 return ix + (iy * HALF_COLOR_COUNT); /* return the color index */
69
70 return -1; /* Not found */
71}
#define CXY_COLORBOX
Definition: palette.h:10
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
#define Y_MARGIN
Definition: palette.cpp:14
#define HALF_COLOR_COUNT
Definition: palette.cpp:17
#define X_COLORBOX_OFFSET
Definition: palette.cpp:15
int iy
Definition: tritemp.h:491
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by OnLButtonDblClk(), OnLButtonDown(), OnRButtonDblClk(), and OnRButtonDown().

◆ OnEraseBkgnd()

LRESULT CPaletteWindow::OnEraseBkgnd ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 73 of file palette.cpp.

74{
75 return TRUE; /* Avoid flickering */
76}
#define TRUE
Definition: types.h:120

◆ OnLButtonDblClk()

LRESULT CPaletteWindow::OnLButtonDblClk ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 157 of file palette.cpp.

158{
160 COLORREF rgbColor = paletteModel.GetFgColor();
161 if (iColor != -1 && mainWindow.ChooseColor(&rgbColor))
162 {
163 paletteModel.SetColor(iColor, rgbColor);
164 paletteModel.SetFgColor(rgbColor);
165 }
166 return 0;
167}
CMainWindow mainWindow
Definition: main.cpp:25
BOOL ChooseColor(IN OUT COLORREF *prgbColor)
Definition: main.cpp:282
INT DoHitTest(INT xPos, INT yPos) const
Definition: palette.cpp:55
void SetFgColor(COLORREF newColor)
void SetColor(UINT nIndex, COLORREF newColor)
COLORREF GetFgColor() const
LPARAM lParam
Definition: combotst.c:139
PaletteModel paletteModel
DWORD COLORREF
Definition: windef.h:300
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
_In_ ULONG iColor
Definition: xlateobj.h:17

◆ OnLButtonDown()

LRESULT CPaletteWindow::OnLButtonDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 140 of file palette.cpp.

141{
143 if (iColor != -1)
145 SetCapture();
146 return 0;
147}
COLORREF GetColor(UINT nIndex) const
HWND WINAPI SetCapture(_In_ HWND hWnd)

◆ OnLButtonUp()

LRESULT CPaletteWindow::OnLButtonUp ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 211 of file palette.cpp.

212{
213 if (::GetCapture() != m_hWnd)
214 return 0;
215
217 return 0;
218}
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
HWND WINAPI GetCapture(void)
Definition: message.c:2881

◆ OnMouseMove()

LRESULT CPaletteWindow::OnMouseMove ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 187 of file palette.cpp.

188{
189 if (::GetCapture() != m_hWnd)
190 return 0;
191
194
195 RECT rc;
197
198 POINT ptCenter = { (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2 };
199
200 DWORD dwExpectedBar1ID = ((pt.y < ptCenter.y) ? BAR1ID_TOP : BAR1ID_BOTTOM);
201
202 if (registrySettings.Bar1ID != dwExpectedBar1ID)
203 {
204 registrySettings.Bar1ID = dwExpectedBar1ID;
206 }
207
208 return 0;
209}
RegistrySettings registrySettings
Definition: registry.cpp:14
#define BAR1ID_TOP
Definition: registry.h:50
#define BAR1ID_BOTTOM
Definition: registry.h:51
BOOL GetWindowRect(LPRECT lpRect) const
Definition: atlwin.h:816
BOOL PostMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1044
#define pt(x, y)
Definition: drawing.c:79
unsigned long DWORD
Definition: ntddk_ex.h:95
long y
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define WM_SIZE
Definition: winuser.h:1611
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)

◆ OnPaint()

LRESULT CPaletteWindow::OnPaint ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 78 of file palette.cpp.

79{
80 RECT rc, rcClient;
81 GetClientRect(&rcClient);
82
83 PAINTSTRUCT ps;
84 HDC hDC = BeginPaint(&ps);
85
86 /* To avoid flickering, we use a memory bitmap.
87 The left and top values are zeros in client rectangle */
89 m_hbmCached = CachedBufferDIB(m_hbmCached, rcClient.right, rcClient.bottom);
90 HGDIOBJ hbmOld = ::SelectObject(hMemDC, m_hbmCached);
91
92 /* Fill the background (since WM_ERASEBKGND handling is disabled) */
93 ::FillRect(hMemDC, &rcClient, (HBRUSH)(COLOR_3DFACE + 1));
94
95 /* Draw the big box that contains the black box and the white box */
97 ::DrawEdge(hMemDC, &rc, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
99 for (INT y = rc.top; y < rc.bottom; ++y)
100 {
101 BOOL bLight = (y & 1);
102 for (INT x = rc.left; x < rc.right; ++x)
103 {
104 if (bLight)
105 ::SetPixelV(hMemDC, x, y, rgbLight);
106 bLight = !bLight;
107 }
108 }
109
110 /* Draw the white box in the big box, at 5/8 position */
111 rc.left = X_MARGIN + (CXY_BIGBOX * 5 / 8) - (CXY_SELECTEDBOX / 2);
112 rc.top = Y_MARGIN + (CXY_BIGBOX * 5 / 8) - (CXY_SELECTEDBOX / 2);
113 rc.right = rc.left + CXY_SELECTEDBOX;
114 rc.bottom = rc.top + CXY_SELECTEDBOX;
116
117 /* Draw the black box (overlapping the white box), at 3/8 position */
118 rc.left = X_MARGIN + (CXY_BIGBOX * 3 / 8) - (CXY_SELECTEDBOX / 2);
119 rc.top = Y_MARGIN + (CXY_BIGBOX * 3 / 8) - (CXY_SELECTEDBOX / 2);
120 rc.right = rc.left + CXY_SELECTEDBOX;
121 rc.bottom = rc.top + CXY_SELECTEDBOX;
123
124 /* Draw the normal color boxes */
125 for (INT i = 0; i < COLOR_COUNT; i++)
126 {
127 getColorBoxRect(&rc, rcClient, i);
129 }
130
131 /* Transfer bits (hDC <-- hMemDC) */
132 ::BitBlt(hDC, 0, 0, rcClient.right, rcClient.bottom, hMemDC, 0, 0, SRCCOPY);
133
134 ::SelectObject(hMemDC, hbmOld);
135 ::DeleteDC(hMemDC);
136 EndPaint(&ps);
137 return 0;
138}
static HDC hDC
Definition: 3dtext.c:33
#define CXY_BIGBOX
Definition: palette.h:11
COLORREF GetBgColor() const
HBITMAP CachedBufferDIB(HBITMAP hbm, int minimalWidth, int minimalHeight)
Definition: dib.cpp:115
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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
static HDC
Definition: imagelist.c:92
#define COLOR_COUNT
Definition: palette.cpp:16
#define CXY_SELECTEDBOX
Definition: palette.cpp:12
static VOID drawColorBox(HDC hDC, LPCRECT prc, COLORREF rgbColor, UINT nBorder)
Definition: palette.cpp:34
static VOID getColorBoxRect(LPRECT prc, const RECT &rcClient, INT iColor)
Definition: palette.cpp:45
#define X_MARGIN
Definition: palette.cpp:13
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI SetPixelV(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
DWORD WINAPI GetSysColor(_In_ int)
#define BDR_SUNKENOUTER
Definition: winuser.h:443
#define EDGE_SUNKEN
Definition: winuser.h:451
#define COLOR_3DHIGHLIGHT
Definition: winuser.h:936
#define BF_ADJUST
Definition: winuser.h:470
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define BDR_RAISEDINNER
Definition: winuser.h:444
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define BF_RECT
Definition: winuser.h:462
#define COLOR_3DFACE
Definition: winuser.h:929

◆ OnPaletteModelColorChanged()

LRESULT CPaletteWindow::OnPaletteModelColorChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 181 of file palette.cpp.

182{
183 Invalidate(FALSE);
184 return 0;
185}
#define FALSE
Definition: types.h:117

◆ OnRButtonDblClk()

LRESULT CPaletteWindow::OnRButtonDblClk ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 169 of file palette.cpp.

170{
172 COLORREF rgbColor = paletteModel.GetBgColor();
173 if (iColor != -1 && mainWindow.ChooseColor(&rgbColor))
174 {
175 paletteModel.SetColor(iColor, rgbColor);
176 paletteModel.SetBgColor(rgbColor);
177 }
178 return 0;
179}
void SetBgColor(COLORREF newColor)

◆ OnRButtonDown()

LRESULT CPaletteWindow::OnRButtonDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 149 of file palette.cpp.

Member Data Documentation

◆ m_hbmCached

HBITMAP CPaletteWindow::m_hbmCached
protected

Definition at line 35 of file palette.h.

Referenced by OnPaint(), and ~CPaletteWindow().


The documentation for this class was generated from the following files: