ReactOS  0.4.13-dev-482-ge57f103
cardwindow.cpp File Reference
#include "cardlib.h"
#include <tchar.h>
Include dependency graph for cardwindow.cpp:

Go to the source code of this file.

Functions

HPALETTE UseNicePalette (HDC hdc, HPALETTE hPalette)
 
void RestorePalette (HDC hdc, HPALETTE hOldPal)
 
HPALETTE MakePaletteFromCols (COLORREF cols[], int nNumColours)
 
void PaintRect (HDC hdc, RECT *rect, COLORREF colour)
 
HBITMAP CreateSinkBmp (HDC hdcCompat, HDC hdc, COLORREF col, int width, int height)
 
void GetSinkCols (COLORREF crBase, COLORREF *fg, COLORREF *bg, COLORREF *sh1, COLORREF *sh2)
 
void LoadCardBitmaps ()
 
void FreeCardBitmaps ()
 
void RegisterCardWindow ()
 

Variables

HPALETTE __holdplacepal
 
static TCHAR szCardName [] = _T("CardWnd32")
 
static bool fRegistered = false
 
static LONG uCardBitmapRef = 0
 

Function Documentation

◆ CreateSinkBmp()

HBITMAP CreateSinkBmp ( HDC  hdcCompat,
HDC  hdc,
COLORREF  col,
int  width,
int  height 
)

Definition at line 176 of file cardbitmaps.cpp.

177 {
178  HANDLE hold, hpold;
180 
181  HPEN hpfg, hpbg, hpsh, hpsh2;
182 
183  RECT rect;
184  COLORREF fg, bg, shadow, shadow2;
185 
186  GetSinkCols(col, &fg, &bg, &shadow, &shadow2);
187 
188  hold = SelectObject(hdc, hbm);
189 
190  //fill with a solid base colour
191  SetRect(&rect, 0,0,width,height);
193 
194  //draw the outline
195  hpfg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(fg));
196  hpbg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(bg));
197  hpsh = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow));
198  hpsh2= CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow2));
199 
200  hpold = SelectObject(hdc, hpsh);
201  MoveToEx(hdc, 2, 0, NULL);
202  LineTo (hdc, width-3,0);
203  LineTo (hdc, width-1, 2);
204 
205  SelectObject(hdc, hpold);
206  hpold = SelectObject(hdc, hpsh2);
207  LineTo (hdc, width-1, height-3); //vertical
208  LineTo (hdc, width-3, height-1);
209  LineTo (hdc, 2, height-1);
210  LineTo (hdc, 0, height-3);
211  SelectObject(hdc, hpold);
212  hpold = SelectObject(hdc, hpsh);
213 
214  //MoveToEx( hdc, 0, height-3,0);
215  LineTo (hdc, 0, 2);
216  LineTo (hdc, 2, 0);
217 
218  SelectObject(hdc, hpold);
219 
220  //draw the highlight (vertical)
221  hpold = SelectObject(hdc, hpfg);
222  MoveToEx(hdc, width - 2, 3, NULL);
223  LineTo (hdc, width - 2, height - 2);
224 
225  //(horz)
226  MoveToEx(hdc, width - 3, height-2, NULL);
227  LineTo (hdc, 3, height-2);
228  SelectObject(hdc, hpold);
229 
230  //draw the background
231  InflateRect(&rect, -2, -2);
233 
234  //overwrite the top-left background pixel
235  SetPixel(hdc, 2, 2, MAKE_PALETTERGB(bg));
236 
237  DeleteObject(hpsh);
238  DeleteObject(hpsh2);
239  DeleteObject(hpfg);
240  DeleteObject(hpbg);
241 
242 
243  return hbm;
244 }
void GetSinkCols(COLORREF crBase, COLORREF *fg, COLORREF *bg, COLORREF *sh1, COLORREF *sh2)
GLint GLint GLsizei width
Definition: gl.h:1546
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define MAKE_PALETTERGB(colref)
Definition: cardcolor.h:17
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
static void DrawCheckedRect(HDC hdc, RECT *rect, COLORREF fg, COLORREF bg)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
void PaintRect(HDC hdc, RECT *rect, COLORREF col)
Definition: cardlib.cpp:116
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PS_SOLID
Definition: wingdi.h:585
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:99
DWORD COLORREF
Definition: windef.h:285
HDC hdc
Definition: main.c:9
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
static HBITMAP
Definition: button.c:44

Referenced by CardWindow::CardWindow(), and CardWindow::SetBackColor().

◆ FreeCardBitmaps()

void FreeCardBitmaps ( )

Definition at line 123 of file cardbitmaps.cpp.

124 {
127 }
HBITMAP __hbmCardBitmaps
Definition: cardlib.cpp:19
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC __hdcCardBitmaps
Definition: cardlib.cpp:18
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by CardWindow::~CardWindow().

◆ GetSinkCols()

void GetSinkCols ( COLORREF  crBase,
COLORREF fg,
COLORREF bg,
COLORREF sh1,
COLORREF sh2 
)

Definition at line 168 of file cardbitmaps.cpp.

169 {
170  if(bg) *bg = crBase;
171  if(fg) *fg = ColorScaleRGB(crBase, RGB(255,255,255), 0.2);//RGB(49, 99, 140);
172  if(sh1) *sh1 = ColorScaleRGB(crBase, RGB(0,0,0), 0.4);
173  if(sh2) *sh2 = ColorScaleRGB(crBase, RGB(0,0,0), 0.2);
174 }
COLORREF ColorScaleRGB(const COLORREF Col1, const COLORREF Col2, const double Ratio)
Definition: cardcolor.cpp:154
#define RGB(r, g, b)
Definition: wingdi.h:2918

Referenced by CardWindow::CreateCardPalette(), and CreateSinkBmp().

◆ LoadCardBitmaps()

void LoadCardBitmaps ( )

Definition at line 82 of file cardbitmaps.cpp.

83 {
84  HINSTANCE hCardDll;
85 
86 
87  //If Windows NT/2000/XP
88  if(GetVersion() < 0x80000000)
89  {
90  hCardDll = LoadLibrary(TEXT("cards.dll"));
91 
92  if(hCardDll == 0)
93  {
94  MessageBox(0, TEXT("Error loading cards.dll (32bit)"), TEXT("Shed"), MB_OK | MB_ICONEXCLAMATION);
95  PostQuitMessage(0);
96  return;
97  }
98 
100 
101  FreeLibrary(hCardDll);
102  }
103 #ifndef __REACTOS__
104  //Else, Win9X
105  else
106  {
107  hCardDll = LoadLibrary16("cards.dll");
108 
109  if(hCardDll == 0)
110  {
111  MessageBox(0, "Error loading cards.dll (16bit)", "Shed", MB_OK | MB_ICONEXCLAMATION);
112  PostQuitMessage(0);
113  return;
114  }
115 
117 
118  FreeLibrary16(hCardDll);
119  }
120 #endif
121 }
#define LoadLibrary
Definition: winbase.h:3676
DWORD WINAPI GetVersion(VOID)
Definition: version.c:22
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define FreeLibrary(x)
Definition: compat.h:405
void LoadCardBitmapsFromLibrary(HINSTANCE hCardDll, int *pwidth, int *pheight)
Definition: cardbitmaps.cpp:21
#define MessageBox
Definition: winuser.h:5688
int __cardwidth
Definition: cardlib.cpp:25
HINSTANCE WINAPI LoadLibrary16(PSTR)
#define TEXT(s)
Definition: k32.h:26
void WINAPI FreeLibrary16(HINSTANCE)
#define MB_OK
Definition: winuser.h:784
int __cardheight
Definition: cardlib.cpp:26
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by CardWindow::CardWindow().

◆ MakePaletteFromCols()

HPALETTE MakePaletteFromCols ( COLORREF  cols[],
int  nNumColours 
)

Definition at line 256 of file cardbitmaps.cpp.

257 {
258  LOGPALETTE *lp;
259  HPALETTE hPalette;
260 
261  // Allocate memory for the logical palette
262  lp = (LOGPALETTE *)HeapAlloc(
263  GetProcessHeap(), 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * nNumColours);
264 
265  lp->palNumEntries = (WORD)nNumColours;
266  lp->palVersion = 0x300;
267 
268  //copy the colours into the logical palette format
269  for(int i = 0; i < nNumColours; i++)
270  {
271  CopyColor(&lp->palPalEntry[i], cols[i]);
272  }
273 
274  // create palette!
275  hPalette = CreatePalette(lp);
276 
277  HeapFree(GetProcessHeap(), 0, lp);
278 
279  return hPalette;
280 }
WORD palVersion
Definition: wingdi.h:1811
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
void CopyColor(PALETTEENTRY *pe, COLORREF col)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
unsigned short WORD
Definition: ntddk_ex.h:93
struct tagLOGPALETTE LOGPALETTE
WORD palNumEntries
Definition: wingdi.h:1812
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by CardWindow::CreateCardPalette().

◆ PaintRect()

void PaintRect ( HDC  hdc,
RECT rect,
COLORREF  colour 
)

Definition at line 116 of file cardlib.cpp.

117 {
118  COLORREF oldcr = SetBkColor(hdc, colour);
119  ExtTextOut(hdc, 0, 0, ETO_OPAQUE, rect, TEXT(""), 0, 0);
120  SetBkColor(hdc, oldcr);
121 }
& rect
Definition: startmenu.cpp:1413
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
#define ETO_OPAQUE
Definition: wingdi.h:646
DWORD COLORREF
Definition: windef.h:285
#define ExtTextOut
Definition: wingdi.h:4432
HDC hdc
Definition: main.c:9
#define TEXT(s)
Definition: k32.h:26

◆ RegisterCardWindow()

void RegisterCardWindow ( )

Definition at line 42 of file cardwindow.cpp.

43 {
44  WNDCLASSEX wc;
45 
46  //Window class for the main application parent window
47  wc.cbSize = sizeof(wc);
50  wc.cbClsExtra = 0;
51  wc.cbWndExtra = sizeof(CardWindow *);
52  wc.hInstance = GetModuleHandle(0);
53  wc.hIcon = 0;
55  wc.hbrBackground = 0;
56  wc.lpszMenuName = 0;
58  wc.hIconSm = 0;
59 
60  RegisterClassEx(&wc);
61 }
UINT style
Definition: winuser.h:3155
LPCSTR lpszMenuName
Definition: winuser.h:3163
#define RegisterClassEx
Definition: winuser.h:5703
HCURSOR hCursor
Definition: winuser.h:3161
WNDPROC lpfnWndProc
Definition: winuser.h:3156
static TCHAR szCardName[]
Definition: cardwindow.cpp:37
LPCSTR lpszClassName
Definition: winuser.h:3164
#define CS_HREDRAW
Definition: winuser.h:648
HICON hIconSm
Definition: winuser.h:3165
HINSTANCE hInstance
Definition: winuser.h:3159
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3154
HBRUSH hbrBackground
Definition: winuser.h:3162
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3158
static LRESULT CALLBACK CardWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: cardwindow.cpp:270
HICON hIcon
Definition: winuser.h:3160
#define CS_DBLCLKS
Definition: winuser.h:646
#define LoadCursor
Definition: winuser.h:5678
int cbClsExtra
Definition: winuser.h:3157
#define GetModuleHandle
Definition: winbase.h:3641
#define IDC_ARROW
Definition: winuser.h:682

◆ RestorePalette()

void RestorePalette ( HDC  hdc,
HPALETTE  hOldPal 
)

Definition at line 24 of file cardwindow.cpp.

25 {
26  SelectPalette(hdc, hOldPal, TRUE);
27 }
#define TRUE
Definition: types.h:120
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HDC hdc
Definition: main.c:9

Referenced by CardWindow::Paint(), CardWindow::SetBackColor(), and CardWindow::~CardWindow().

◆ UseNicePalette()

HPALETTE UseNicePalette ( HDC  hdc,
HPALETTE  hPalette 
)

Definition at line 14 of file cardwindow.cpp.

15 {
16  HPALETTE hOld;
17 
18  hOld = SelectPalette(hdc, hPalette, FALSE);
20 
21  return hOld;
22 }
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HDC hdc
Definition: main.c:9
UINT WINAPI RealizePalette(_In_ HDC)
Definition: palette.c:138

Referenced by CardWindow::CardWindow(), CardWindow::Paint(), CardRegion::PrepareDragBitmaps(), CardRegion::PrepareDragBitmapsThreed(), CardButton::Redraw(), and CardWindow::SetBackColor().

Variable Documentation

◆ __holdplacepal

HPALETTE __holdplacepal

◆ fRegistered

bool fRegistered = false
static

Definition at line 38 of file cardwindow.cpp.

Referenced by CardWindow::CardWindow().

◆ szCardName

TCHAR szCardName[] = _T("CardWnd32")
static

Definition at line 37 of file cardwindow.cpp.

Referenced by CardWindow::Create(), and RegisterCardWindow().

◆ uCardBitmapRef

LONG uCardBitmapRef = 0
static

Definition at line 39 of file cardwindow.cpp.

Referenced by CardWindow::CardWindow(), and CardWindow::~CardWindow().