ReactOS  0.4.14-dev-115-g4576127
CardButton Class Reference

#include <cardbutton.h>

Collaboration diagram for CardButton:

Public Member Functions

void SetStyle (UINT uStyle)
 
UINT GetStyle ()
 
void SetText (TCHAR *fmt,...)
 
void SetFont (HFONT font)
 
void SetPlacement (UINT xJustify, UINT yJustify, int xAdjust, int yAdjust)
 
void SetForeColor (COLORREF cr)
 
void SetBackColor (COLORREF cr)
 
void Move (int x, int y, int width, int height)
 
void Show (bool fShow)
 
void Redraw ()
 
int Id ()
 
void SetIcon (HICON hicon, bool fRedraw)
 
void SetButtonProc (pButtonProc proc)
 
CardWindowGetCardWindow ()
 
bool Lock ()
 
bool UnLock ()
 

Static Public Member Functions

static COLORREF GetHighlight (COLORREF crBase)
 
static COLORREF GetShadow (COLORREF crBase)
 
static COLORREF GetFace (COLORREF crBase)
 

Private Member Functions

 CardButton (CardWindow &parent, int id, TCHAR *szText, UINT style, bool visible, int x, int y, int width, int height)
 
 ~CardButton ()
 
void AdjustPosition (int winwidth, int winheight)
 
void DrawRect (HDC hdc, RECT *rect, bool fNormal)
 
void Draw (HDC hdc, bool fNormal)
 
void Clip (HDC hdc)
 
int OnLButtonDown (HWND hwnd, int x, int y)
 
int OnMouseMove (HWND hwnd, int x, int y)
 
int OnLButtonUp (HWND hwnd, int x, int y)
 

Private Attributes

CardWindowparentWnd
 
RECT rect
 
int id
 
UINT uStyle
 
bool fVisible
 
int xadjust
 
int xjustify
 
int yadjust
 
int yjustify
 
HICON hIcon
 
HFONT hFont
 
TCHAR szText [MAXBUTTONTEXT]
 
COLORREF crBack
 
COLORREF crText
 
COLORREF crHighlight
 
COLORREF crShadow
 
COLORREF crShadow2
 
bool fMouseDown
 
bool fButtonDown
 
HANDLE mxlock
 
pButtonProc ButtonCallback
 

Friends

class CardWindow
 

Detailed Description

Definition at line 6 of file cardbutton.h.

Constructor & Destructor Documentation

◆ CardButton()

CardButton::CardButton ( CardWindow parent,
int  id,
TCHAR szText,
UINT  style,
bool  visible,
int  x,
int  y,
int  width,
int  height 
)
private

Definition at line 15 of file cardbutton.cpp.

19 {
20  crText = RGB(255,255,255);
21  crBack = RGB(0, 128, 0);
22 
23  xadjust = 0;
24  yadjust = 0;
25  xjustify = 0;
26  yjustify = 0;
27 
28  fMouseDown = false;
29  fButtonDown = false;
30 
31  hIcon = 0;
32 
33  SetText(szText);
34  Move(x, y, width, height);
35 
36  mxlock = CreateMutex(0, FALSE, 0);
37 
38  hFont = 0;
39 }
GLint GLint GLsizei width
Definition: gl.h:1546
void Move(int x, int y, int width, int height)
Definition: cardbutton.cpp:380
HFONT hFont
Definition: cardbutton.h:81
bool fVisible
Definition: cardbutton.h:73
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
UINT uStyle
Definition: cardbutton.h:72
COLORREF crText
Definition: cardbutton.h:86
HICON hIcon
Definition: cardbutton.h:80
bool fMouseDown
Definition: cardbutton.h:91
int yadjust
Definition: cardbutton.h:77
pButtonProc ButtonCallback
Definition: cardbutton.h:96
int xjustify
Definition: cardbutton.h:76
const DWORD Style
Definition: appswitch.c:71
#define CreateMutex
Definition: winbase.h:3580
r parent
Definition: btrfs.c:2897
TCHAR szText[MAXBUTTONTEXT]
Definition: cardbutton.h:83
bool fButtonDown
Definition: cardbutton.h:92
#define RGB(r, g, b)
Definition: wingdi.h:2935
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
COLORREF crBack
Definition: cardbutton.h:85
int xadjust
Definition: cardbutton.h:75
int yjustify
Definition: cardbutton.h:78
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
CardWindow & parentWnd
Definition: cardbutton.h:68
void SetText(TCHAR *fmt,...)
Definition: cardbutton.cpp:359
HANDLE mxlock
Definition: cardbutton.h:94

◆ ~CardButton()

CardButton::~CardButton ( )
private

Definition at line 41 of file cardbutton.cpp.

42 {
44 }
#define CloseHandle
Definition: compat.h:398
HANDLE mxlock
Definition: cardbutton.h:94

Member Function Documentation

◆ AdjustPosition()

void CardButton::AdjustPosition ( int  winwidth,
int  winheight 
)
private

Definition at line 208 of file cardbutton.cpp.

209 {
210  int width = rect.right-rect.left;
211  int height = rect.bottom-rect.top;
212 
213  width = width & ~0x1;
214 
215  switch(xjustify)
216  {
217  case CS_XJUST_NONE:
218  break;
219 
220  case CS_XJUST_CENTER: //centered
221  rect.left = (winwidth - (width)) / 2;
222  rect.left += xadjust;
224  break;
225 
226  case CS_XJUST_RIGHT: //right-aligned
227  rect.left = winwidth - width;
228  rect.left += xadjust;
230  break;
231  }
232 
233  switch(yjustify)
234  {
235  case CS_YJUST_NONE:
236  break;
237 
238  case CS_YJUST_CENTER: //centered
239  rect.top = (winheight - (height)) / 2;
240  rect.top += yadjust;
242  break;
243 
244  case CS_YJUST_BOTTOM: //right-aligned
245  rect.top = winheight - height;
246  rect.top += yadjust;
248  break;
249  }
250 
251 }
GLint GLint GLsizei width
Definition: gl.h:1546
RECT rect
Definition: cardbutton.h:70
#define CS_XJUST_RIGHT
Definition: cardlib.h:38
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define CS_XJUST_NONE
Definition: cardlib.h:37
int yadjust
Definition: cardbutton.h:77
#define CS_XJUST_CENTER
Definition: cardlib.h:39
int xjustify
Definition: cardbutton.h:76
#define CS_YJUST_NONE
Definition: cardlib.h:41
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define CS_YJUST_BOTTOM
Definition: cardlib.h:42
int xadjust
Definition: cardbutton.h:75
int yjustify
Definition: cardbutton.h:78
#define CS_YJUST_CENTER
Definition: cardlib.h:43
LONG bottom
Definition: windef.h:294

Referenced by CardWindow::WndProc().

◆ Clip()

void CardButton::Clip ( HDC  hdc)
private

Definition at line 102 of file cardbutton.cpp.

103 {
104  if(fVisible == false) return;
105 
107 }
RECT rect
Definition: cardbutton.h:70
bool fVisible
Definition: cardbutton.h:73
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
HDC hdc
Definition: main.c:9
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
LONG bottom
Definition: windef.h:294

Referenced by CardWindow::Paint().

◆ Draw()

void CardButton::Draw ( HDC  hdc,
bool  fNormal 
)
private

Definition at line 109 of file cardbutton.cpp.

110 {
111  SIZE textsize;
112  int x, y; //text x, y
113  int ix, iy; //icon x, y
114  int iconwidth = 0;
115 
116  RECT cliprect;
117 
118  if(fVisible == 0) return;
119 
120  if(hFont == 0)
122  else
124 
126 
127  if(hIcon)
128  {
129  x = rect.left + 32 + 8;
130  }
131  else
132  {
133  if(uStyle & CB_ALIGN_LEFT)
134  {
135  x = rect.left + iconwidth;
136  }
137  else if(uStyle & CB_ALIGN_RIGHT)
138  {
139  x = rect.left + (rect.right-rect.left-iconwidth-textsize.cx);
140  }
141  else //centered
142  {
143  x = rect.right - rect.left - iconwidth;
144  x = (x - textsize.cx) / 2;
145  x += rect.left + iconwidth;
146  }
147  }
148 
149  y = rect.bottom - rect.top;
150  y = (y - textsize.cy) / 2;
151  y += rect.top;
152 
153  //calc icon position..
154  ix = rect.left + 4;
155  iy = rect.top + (rect.bottom-rect.top-32) / 2;
156 
157  //if button is pressed, then shift text
158  if(fNormal == false && (uStyle & CB_PUSHBUTTON))
159  {
160  x += 1;
161  y += 1;
162  ix += 1;
163  iy += 1;
164  }
165 
166  SetRect(&cliprect, x, y, x+textsize.cx, y+textsize.cy);
167  ExcludeClipRect(hdc, x, y, x+textsize.cx, y+textsize.cy);
168 
169  //
170  // Calc icon pos
171  //
172 
173  if(hIcon)
174  {
175  ExcludeClipRect(hdc, ix, iy, ix + 32, iy + 32);
176  }
177 
178  if(uStyle & CB_PUSHBUTTON)
179  {
180  DrawRect(hdc, &rect, fNormal);
181 
183  SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
184 
185  SelectClipRgn(hdc, 0);
186 
187  ExtTextOut(hdc, x, y, ETO_OPAQUE, &cliprect, szText, lstrlen(szText), 0);
188  }
189  else
190  {
192  SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
193 
194  SelectClipRgn(hdc, 0);
195 
197  }
198 
199  if(hIcon)
200  {
201  HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBack));
202  DrawIconEx(hdc, ix, iy, hIcon, 32, 32, 0, hbr, 0);
203  DeleteObject(hbr);
204  }
205 
206 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define MAKE_PALETTERGB(colref)
Definition: cardcolor.h:17
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
HFONT hFont
Definition: cardbutton.h:81
RECT rect
Definition: cardbutton.h:70
bool fVisible
Definition: cardbutton.h:73
LONG top
Definition: windef.h:292
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
UINT uStyle
Definition: cardbutton.h:72
COLORREF crText
Definition: cardbutton.h:86
LONG left
Definition: windef.h:291
HICON hIcon
Definition: cardbutton.h:80
LONG right
Definition: windef.h:293
int iy
Definition: tritemp.h:491
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
#define ETO_OPAQUE
Definition: wingdi.h:646
void DrawRect(HDC hdc, RECT *rect, bool fNormal)
Definition: cardbutton.cpp:46
#define CB_PUSHBUTTON
Definition: cardlib.h:46
LONG cx
Definition: windef.h:319
#define CB_ALIGN_LEFT
Definition: cardlib.h:48
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
TCHAR szText[MAXBUTTONTEXT]
Definition: cardbutton.h:83
#define DEFAULT_GUI_FONT
Definition: wingdi.h:908
#define CB_ALIGN_RIGHT
Definition: cardlib.h:49
#define ExtTextOut
Definition: wingdi.h:4449
HDC hdc
Definition: main.c:9
COLORREF crBack
Definition: cardbutton.h:85
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define lstrlen
Definition: winbase.h:3700
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define GetTextExtentPoint32
Definition: wingdi.h:4467
LONG bottom
Definition: windef.h:294
LONG cy
Definition: windef.h:320

Referenced by Redraw().

◆ DrawRect()

void CardButton::DrawRect ( HDC  hdc,
RECT rect,
bool  fNormal 
)
private

Definition at line 46 of file cardbutton.cpp.

47 {
48  RECT fill;
49 
50  HANDLE hOld;
51 
52  HPEN hhi = CreatePen(0, 0, MAKE_PALETTERGB(crHighlight));
53  HPEN hsh = CreatePen(0, 0, MAKE_PALETTERGB(crShadow));
54  HPEN hbl = (HPEN)GetStockObject(BLACK_PEN);
55 
56  int x = rect->left;
57  int y = rect->top;
58  int width = rect->right-rect->left - 1;
59  int height = rect->bottom-rect->top - 1;
60 
61  SetRect(&fill, x+1, y+1, x+width-1, y+height-1);
62 
63  int one = 1;
64 
65  if(!fNormal)
66  {
67  x += width;
68  y += height;
69  width = -width;
70  height = -height;
71  one = -1;
72  OffsetRect(&fill, 1, 1);
73  }
74 
75  if(fNormal)
76  hOld = SelectObject(hdc, hhi);
77  else
78  hOld = SelectObject(hdc, hsh);
79 
80  MoveToEx(hdc, x, y+height, 0);
81  LineTo(hdc, x, y);
82  LineTo(hdc, x+width, y);
83  SelectObject(hdc, hOld);
84 
85  hOld = SelectObject(hdc, hbl);
86  LineTo(hdc, x+width, y+height);
87  LineTo(hdc, x-one, y+height);
88  SelectObject(hdc, hOld);
89 
90  hOld = SelectObject(hdc, hsh);
91  MoveToEx(hdc, x+one, y+height-one, 0);
93  LineTo(hdc, x+width-one, y);
94  SelectObject(hdc, hOld);
95 
97 
98  DeleteObject(hhi);
99  DeleteObject(hsh);
100 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
GLint GLint GLsizei width
Definition: gl.h:1546
#define MAKE_PALETTERGB(colref)
Definition: cardcolor.h:17
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
RECT rect
Definition: cardbutton.h:70
LONG top
Definition: windef.h:292
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)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
static double one
Definition: j0_y0.c:80
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
COLORREF crHighlight
Definition: cardbutton.h:87
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
HDC hdc
Definition: main.c:9
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
COLORREF crShadow
Definition: cardbutton.h:88
COLORREF crBack
Definition: cardbutton.h:85
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define BLACK_PEN
Definition: wingdi.h:902
void PaintRect(HDC hdc, RECT *rect, COLORREF colour)
Definition: cardlib.cpp:116
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
LONG bottom
Definition: windef.h:294

Referenced by Draw().

◆ GetCardWindow()

CardWindow& CardButton::GetCardWindow ( )
inline

Definition at line 41 of file cardbutton.h.

41 { return parentWnd; }
CardWindow & parentWnd
Definition: cardbutton.h:68

◆ GetFace()

COLORREF CardButton::GetFace ( COLORREF  crBase)
static

Definition at line 426 of file cardbutton.cpp.

427 {
428  return ColorScaleRGB(crBase, RGB(255,255,255), 0.1);
429 }
COLORREF ColorScaleRGB(const COLORREF Col1, const COLORREF Col2, const double Ratio)
Definition: cardcolor.cpp:154
#define RGB(r, g, b)
Definition: wingdi.h:2935

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

◆ GetHighlight()

COLORREF CardButton::GetHighlight ( COLORREF  crBase)
static

Definition at line 415 of file cardbutton.cpp.

416 {
417  return ColorScaleRGB(crBase, RGB(255,255,255), 0.25);
418 }
COLORREF ColorScaleRGB(const COLORREF Col1, const COLORREF Col2, const double Ratio)
Definition: cardcolor.cpp:154
#define RGB(r, g, b)
Definition: wingdi.h:2935

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

◆ GetShadow()

COLORREF CardButton::GetShadow ( COLORREF  crBase)
static

Definition at line 421 of file cardbutton.cpp.

422 {
423  return ColorScaleRGB(crBase, RGB(0, 0, 0), 0.25);
424 }
COLORREF ColorScaleRGB(const COLORREF Col1, const COLORREF Col2, const double Ratio)
Definition: cardcolor.cpp:154
#define RGB(r, g, b)
Definition: wingdi.h:2935

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

◆ GetStyle()

UINT CardButton::GetStyle ( )

Definition at line 481 of file cardbutton.cpp.

482 {
483  return uStyle;
484 }
UINT uStyle
Definition: cardbutton.h:72

◆ Id()

int CardButton::Id ( )

Definition at line 370 of file cardbutton.cpp.

371 {
372  return id;
373 }

◆ Lock()

bool CardButton::Lock ( void  )

Definition at line 458 of file cardbutton.cpp.

459 {
461 
462  if(dw == WAIT_OBJECT_0)
463  return true;
464  else
465  return false;
466 }
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID LPVOID DWORD dw
Definition: atlbase.h:40
HANDLE mxlock
Definition: cardbutton.h:94

◆ Move()

void CardButton::Move ( int  x,
int  y,
int  width,
int  height 
)

Definition at line 380 of file cardbutton.cpp.

381 {
382  SetRect(&rect, x, y, x+width, y+height);
383 }
GLint GLint GLsizei width
Definition: gl.h:1546
RECT rect
Definition: cardbutton.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by CardButton().

◆ OnLButtonDown()

int CardButton::OnLButtonDown ( HWND  hwnd,
int  x,
int  y 
)
private

Definition at line 253 of file cardbutton.cpp.

254 {
255  if((uStyle & CB_PUSHBUTTON) == 0)
256  return 0;
257 
258  //make sure that the user is allowed to do something
260  {
261  return 0;
262  }
263  else
264  {
266  }
267 
268  fMouseDown = true;
269  fButtonDown = true;
270 
271  Redraw();
272 
273  SetCapture(hwnd);
274 
275  return 1;
276 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT uStyle
Definition: cardbutton.h:72
void Redraw()
Definition: cardbutton.cpp:385
bool fMouseDown
Definition: cardbutton.h:91
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define CB_PUSHBUTTON
Definition: cardlib.h:46
#define WAIT_OBJECT_0
Definition: winbase.h:387
bool fButtonDown
Definition: cardbutton.h:92
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
HWND WINAPI SetCapture(_In_ HWND hWnd)
HANDLE mxlock
Definition: cardbutton.h:94

Referenced by CardWindow::WndProc().

◆ OnLButtonUp()

int CardButton::OnLButtonUp ( HWND  hwnd,
int  x,
int  y 
)
private

Definition at line 301 of file cardbutton.cpp.

302 {
303  if(fMouseDown)
304  {
305  fMouseDown = false;
306  fButtonDown = false;
307 
308  if(uStyle & CB_PUSHBUTTON)
309  {
310  Redraw();
311  ReleaseCapture();
312  }
313 
314  //if have clicked the button
315  if(parentWnd.CardButtonFromPoint(x, y) == this)
316  {
317  if(ButtonCallback)
318  {
319  ButtonCallback(*this);
320  }
321  else
322  {
323  HWND hwnd = (HWND)parentWnd;
325  }
326  }
327  }
328 
329  return 0;
330 }
CardButton * CardButtonFromPoint(int x, int y)
Definition: cardwindow.cpp:229
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEWPARAM(l, h)
Definition: winuser.h:3948
HANDLE HWND
Definition: compat.h:13
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
UINT uStyle
Definition: cardbutton.h:72
void Redraw()
Definition: cardbutton.cpp:385
bool fMouseDown
Definition: cardbutton.h:91
pButtonProc ButtonCallback
Definition: cardbutton.h:96
#define CB_PUSHBUTTON
Definition: cardlib.h:46
bool fButtonDown
Definition: cardbutton.h:92
#define BN_CLICKED
Definition: winuser.h:1907
#define WM_COMMAND
Definition: winuser.h:1722
HWND WINAPI GetParent(_In_ HWND)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
CardWindow & parentWnd
Definition: cardbutton.h:68
#define SendMessage
Definition: winuser.h:5744

Referenced by CardWindow::WndProc().

◆ OnMouseMove()

int CardButton::OnMouseMove ( HWND  hwnd,
int  x,
int  y 
)
private

Definition at line 278 of file cardbutton.cpp.

279 {
280  if(fMouseDown)
281  {
282  bool fOldButtonDown = fButtonDown;
283 
284  POINT pt;
285 
286  pt.x = x;
287  pt.y = y;
288 
289  if(PtInRect(&rect, pt))
290  fButtonDown = true;
291  else
292  fButtonDown = false;
293 
294  if(fButtonDown != fOldButtonDown)
295  Redraw();
296  }
297 
298  return 0;
299 }
RECT rect
Definition: cardbutton.h:70
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
void Redraw()
Definition: cardbutton.cpp:385
bool fMouseDown
Definition: cardbutton.h:91
bool fButtonDown
Definition: cardbutton.h:92
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)

Referenced by CardWindow::WndProc().

◆ Redraw()

void CardButton::Redraw ( )

Definition at line 385 of file cardbutton.cpp.

386 {
387  HDC hdc = GetDC((HWND)parentWnd);
388 
389  HPALETTE hOldPal = UseNicePalette(hdc, __hPalette);
390 
391  Draw(hdc, !fButtonDown);
392 
393  RestorePalette(hdc, hOldPal);
394 
396 }
void RestorePalette(HDC, HPALETTE)
HDC WINAPI GetDC(_In_opt_ HWND)
HPALETTE UseNicePalette(HDC, HPALETTE)
Definition: cardwindow.cpp:14
static HDC
Definition: imagelist.c:92
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
bool fButtonDown
Definition: cardbutton.h:92
HPALETTE __hPalette
Definition: cardlib.cpp:28
HDC hdc
Definition: main.c:9
void Draw(HDC hdc, bool fNormal)
Definition: cardbutton.cpp:109
CardWindow & parentWnd
Definition: cardbutton.h:68

Referenced by OnLButtonDown(), OnLButtonUp(), OnMouseMove(), CardWindow::Paint(), and SetIcon().

◆ SetBackColor()

void CardButton::SetBackColor ( COLORREF  cr)

Definition at line 403 of file cardbutton.cpp.

404 {
405  crBack = cr;
406 
408  crShadow = GetShadow(cr);
409 
410  //crHighlight = ScaleLumRGB(cr, +0.25);
411  //crShadow = ScaleLumRGB(cr, -0.25);
412 }
static COLORREF GetHighlight(COLORREF crBase)
Definition: cardbutton.cpp:415
static COLORREF GetShadow(COLORREF crBase)
Definition: cardbutton.cpp:421
COLORREF crHighlight
Definition: cardbutton.h:87
COLORREF crShadow
Definition: cardbutton.h:88
COLORREF crBack
Definition: cardbutton.h:85

Referenced by CardWindow::SetBackColor().

◆ SetButtonProc()

void CardButton::SetButtonProc ( pButtonProc  proc)

Definition at line 453 of file cardbutton.cpp.

454 {
456 }
static HANDLE proc()
Definition: pdb.c:32
pButtonProc ButtonCallback
Definition: cardbutton.h:96

◆ SetFont()

void CardButton::SetFont ( HFONT  font)

Definition at line 447 of file cardbutton.cpp.

448 {
449  //don't delete the existing font..
450  hFont = font;
451 }
HFONT hFont
Definition: cardbutton.h:81
Definition: mk_font.cpp:20

◆ SetForeColor()

void CardButton::SetForeColor ( COLORREF  cr)

Definition at line 398 of file cardbutton.cpp.

399 {
400  crText = cr;
401 }
COLORREF crText
Definition: cardbutton.h:86

◆ SetIcon()

void CardButton::SetIcon ( HICON  hicon,
bool  fRedraw 
)

Definition at line 439 of file cardbutton.cpp.

440 {
441  hIcon = hicon;
442 
443  if(fRedraw)
444  Redraw();
445 }
HICON hIcon
Definition: cardbutton.h:80
void Redraw()
Definition: cardbutton.cpp:385

◆ SetPlacement()

void CardButton::SetPlacement ( UINT  xJustify,
UINT  yJustify,
int  xAdjust,
int  yAdjust 
)

Definition at line 431 of file cardbutton.cpp.

432 {
433  xadjust = xAdjust;
434  yadjust = yAdjust;
435  xjustify = xJustify;
436  yjustify = yJustify;
437 }
int yadjust
Definition: cardbutton.h:77
int xjustify
Definition: cardbutton.h:76
int xadjust
Definition: cardbutton.h:75
int yjustify
Definition: cardbutton.h:78

◆ SetStyle()

void CardButton::SetStyle ( UINT  uStyle)

Definition at line 476 of file cardbutton.cpp.

477 {
478  uStyle = style;
479 }
UINT uStyle
Definition: cardbutton.h:72
Arabic default style
Definition: afstyles.h:93

◆ SetText()

void CardButton::SetText ( TCHAR fmt,
  ... 
)

Definition at line 359 of file cardbutton.cpp.

360 {
361  int count;
362 
363  va_list args;
364  va_start(args, lpszFormat);
365 
366  count = wvsprintf(szText, lpszFormat, args);
367  va_end(args);
368 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: match.c:390
#define wvsprintf
Definition: winuser.h:5767
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
TCHAR szText[MAXBUTTONTEXT]
Definition: cardbutton.h:83
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66

Referenced by CardButton().

◆ Show()

void CardButton::Show ( bool  fShow)

Definition at line 375 of file cardbutton.cpp.

376 {
377  fVisible = fShow;
378 }
bool fVisible
Definition: cardbutton.h:73

◆ UnLock()

bool CardButton::UnLock ( )

Definition at line 468 of file cardbutton.cpp.

469 {
470  if(ReleaseMutex(mxlock))
471  return true;
472  else
473  return false;
474 }
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
HANDLE mxlock
Definition: cardbutton.h:94

Friends And Related Function Documentation

◆ CardWindow

friend class CardWindow
friend

Definition at line 8 of file cardbutton.h.

Member Data Documentation

◆ ButtonCallback

pButtonProc CardButton::ButtonCallback
private

Definition at line 96 of file cardbutton.h.

Referenced by OnLButtonUp(), and SetButtonProc().

◆ crBack

COLORREF CardButton::crBack
private

Definition at line 85 of file cardbutton.h.

Referenced by CardButton(), Draw(), DrawRect(), and SetBackColor().

◆ crHighlight

COLORREF CardButton::crHighlight
private

Definition at line 87 of file cardbutton.h.

Referenced by DrawRect(), and SetBackColor().

◆ crShadow

COLORREF CardButton::crShadow
private

Definition at line 88 of file cardbutton.h.

Referenced by DrawRect(), and SetBackColor().

◆ crShadow2

COLORREF CardButton::crShadow2
private

Definition at line 89 of file cardbutton.h.

◆ crText

COLORREF CardButton::crText
private

Definition at line 86 of file cardbutton.h.

Referenced by CardButton(), Draw(), and SetForeColor().

◆ fButtonDown

bool CardButton::fButtonDown
private

Definition at line 92 of file cardbutton.h.

Referenced by CardButton(), OnLButtonDown(), OnLButtonUp(), OnMouseMove(), and Redraw().

◆ fMouseDown

bool CardButton::fMouseDown
private

Definition at line 91 of file cardbutton.h.

Referenced by CardButton(), OnLButtonDown(), OnLButtonUp(), and OnMouseMove().

◆ fVisible

bool CardButton::fVisible
private

Definition at line 73 of file cardbutton.h.

Referenced by CardWindow::CardButtonFromPoint(), Clip(), Draw(), and Show().

◆ hFont

HFONT CardButton::hFont
private

Definition at line 81 of file cardbutton.h.

Referenced by CardButton(), Draw(), and SetFont().

◆ hIcon

HICON CardButton::hIcon
private

Definition at line 80 of file cardbutton.h.

Referenced by CardButton(), Draw(), and SetIcon().

◆ id

int CardButton::id
private

Definition at line 71 of file cardbutton.h.

Referenced by Id().

◆ mxlock

HANDLE CardButton::mxlock
private

Definition at line 94 of file cardbutton.h.

Referenced by CardButton(), Lock(), OnLButtonDown(), UnLock(), and ~CardButton().

◆ parentWnd

CardWindow& CardButton::parentWnd
private

Definition at line 68 of file cardbutton.h.

Referenced by GetCardWindow(), OnLButtonUp(), and Redraw().

◆ rect

RECT CardButton::rect
private

◆ szText

TCHAR CardButton::szText[MAXBUTTONTEXT]
private

Definition at line 83 of file cardbutton.h.

Referenced by CardButton(), Draw(), and SetText().

◆ uStyle

UINT CardButton::uStyle
private

Definition at line 72 of file cardbutton.h.

Referenced by Draw(), GetStyle(), OnLButtonDown(), OnLButtonUp(), and SetStyle().

◆ xadjust

int CardButton::xadjust
private

Definition at line 75 of file cardbutton.h.

Referenced by AdjustPosition(), CardButton(), and SetPlacement().

◆ xjustify

int CardButton::xjustify
private

Definition at line 76 of file cardbutton.h.

Referenced by AdjustPosition(), CardButton(), and SetPlacement().

◆ yadjust

int CardButton::yadjust
private

Definition at line 77 of file cardbutton.h.

Referenced by AdjustPosition(), CardButton(), and SetPlacement().

◆ yjustify

int CardButton::yjustify
private

Definition at line 78 of file cardbutton.h.

Referenced by AdjustPosition(), CardButton(), and SetPlacement().


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