Change tabs to spaces.
Modified: trunk/rosapps/games/solitaire/cardlib/cardbitmaps.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardcolor.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardcount.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardlib.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardregion.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardrgndraw.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardrgnmouse.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardstack.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardwindow.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/dropzone.cpp
Modified: trunk/rosapps/games/solitaire/solcreate.cpp
Modified: trunk/rosapps/games/solitaire/solgame.cpp
Modified: trunk/rosapps/games/solitaire/solitaire.cpp
_____
Modified: trunk/rosapps/games/solitaire/cardlib/cardbitmaps.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardbitmaps.cpp
2005-03-10 14:06:14 UTC (rev 13909)
+++ trunk/rosapps/games/solitaire/cardlib/cardbitmaps.cpp
2005-03-10 16:08:08 UTC (rev 13910)
@@ -1,8 +1,8 @@
//
-// CardLib - Card bitmap support
+// CardLib - Card bitmap support
//
-// Freeware
-// Copyright J Brown 2001
+// Freeware
+// Copyright J Brown 2001
//
#include <windows.h>
#include "globals.h"
@@ -12,7 +12,7 @@
#pragma comment( lib, "..\\CardLib\\cards16.lib" )
extern "C" HINSTANCE WINAPI LoadLibrary16( PSTR );
-extern "C" void WINAPI FreeLibrary16( HINSTANCE );
+extern "C" void WINAPI FreeLibrary16( HINSTANCE );
#endif
#define NUMCARDBITMAPS (52+16)
@@ -21,261 +21,261 @@
void LoadCardBitmapsFromLibrary(HINSTANCE hCardDll, int *pwidth, int
*pheight)
{
- HBITMAP hBitmap;
- HDC hdcCard;
- HANDLE hOld;
- int i, xpos;
- int width, height;
- BITMAP bmp;
+ HBITMAP hBitmap;
+ HDC hdcCard;
+ HANDLE hOld;
+ int i, xpos;
+ int width, height;
+ BITMAP bmp;
- for(i = 0; i < NUMCARDBITMAPS; i++)
- {
- //convert into the range used by the cdt_xxx functions
- int val;
-
- if(i < 52) val = (i % 4) * 13 + (i/4);
- else val = i;
-
- hBitmap = LoadBitmap(hCardDll, MAKEINTRESOURCE(val +
1));
- GetObject(hBitmap, sizeof(bmp), &bmp);
-
- width = bmp.bmWidth;
- height = bmp.bmHeight;
-
- if(i == 0) //if first time through, create BIG
bitmap..
- {
- HDC hdc = GetDC(0);
- __hdcCardBitmaps = CreateCompatibleDC(hdc);
- __hbmCardBitmaps = CreateCompatibleBitmap(hdc,
width * NUMCARDBITMAPS, height);
- SelectObject(__hdcCardBitmaps,
__hbmCardBitmaps);
-
- hdcCard = CreateCompatibleDC(0);
-
- ReleaseDC(0, hdc);
- }
-
- hOld = SelectObject(hdcCard, hBitmap);
- BitBlt(__hdcCardBitmaps, i*width, 0, width, height,
hdcCard, 0, 0, SRCCOPY);
- SelectObject(hdcCard, hOld);
-
- //Now draw a black border around each card...
- xpos = i*width;
- MoveToEx(__hdcCardBitmaps, xpos+2, 0, 0);
- LineTo(__hdcCardBitmaps, xpos+width - 3, 0);
- LineTo(__hdcCardBitmaps, xpos+width - 1, 2);
- LineTo(__hdcCardBitmaps, xpos+width - 1, height - 3);
//vertical
- LineTo(__hdcCardBitmaps, xpos+width - 3, height - 1);
- LineTo(__hdcCardBitmaps, xpos+2, height - 1);
- LineTo(__hdcCardBitmaps, xpos+0, height - 3);
- LineTo(__hdcCardBitmaps, xpos+0, 2);
- LineTo(__hdcCardBitmaps, xpos+2, 0);
-
- DeleteObject(hBitmap);
- }
-
- DeleteDC(hdcCard);
+ for(i = 0; i < NUMCARDBITMAPS; i++)
+ {
+ //convert into the range used by the cdt_xxx functions
+ int val;
+
+ if(i < 52) val = (i % 4) * 13 + (i/4);
+ else val = i;
+
+ hBitmap = LoadBitmap(hCardDll, MAKEINTRESOURCE(val + 1));
+ GetObject(hBitmap, sizeof(bmp), &bmp);
+
+ width = bmp.bmWidth;
+ height = bmp.bmHeight;
+
+ if(i == 0) //if first time through, create BIG bitmap..
+ {
+ HDC hdc = GetDC(0);
+ __hdcCardBitmaps = CreateCompatibleDC(hdc);
+ __hbmCardBitmaps = CreateCompatibleBitmap(hdc, width *
NUMCARDBITMAPS, height);
+ SelectObject(__hdcCardBitmaps, __hbmCardBitmaps);
+
+ hdcCard = CreateCompatibleDC(0);
+
+ ReleaseDC(0, hdc);
+ }
+
+ hOld = SelectObject(hdcCard, hBitmap);
+ BitBlt(__hdcCardBitmaps, i*width, 0, width, height, hdcCard, 0,
0, SRCCOPY);
+ SelectObject(hdcCard, hOld);
+
+ //Now draw a black border around each card...
+ xpos = i*width;
+ MoveToEx(__hdcCardBitmaps, xpos+2, 0, 0);
+ LineTo(__hdcCardBitmaps, xpos+width - 3, 0);
+ LineTo(__hdcCardBitmaps, xpos+width - 1, 2);
+ LineTo(__hdcCardBitmaps, xpos+width - 1, height - 3);
//vertical
+ LineTo(__hdcCardBitmaps, xpos+width - 3, height - 1);
+ LineTo(__hdcCardBitmaps, xpos+2, height - 1);
+ LineTo(__hdcCardBitmaps, xpos+0, height - 3);
+ LineTo(__hdcCardBitmaps, xpos+0, 2);
+ LineTo(__hdcCardBitmaps, xpos+2, 0);
+
+ DeleteObject(hBitmap);
+ }
+
+ DeleteDC(hdcCard);
- *pwidth = width;
- *pheight = height;
-
+ *pwidth = width;
+ *pheight = height;
+
}
void LoadCardBitmaps(void)
{
- HINSTANCE hCardDll;
-
+ HINSTANCE hCardDll;
+
- //If Windows NT/2000/XP
- if(GetVersion() < 0x80000000)
- {
- hCardDll = LoadLibrary("cards.dll");
+ //If Windows NT/2000/XP
+ if(GetVersion() < 0x80000000)
+ {
+ hCardDll = LoadLibrary("cards.dll");
- if(hCardDll == 0)
- {
- MessageBox(0, "Error loading cards.dll (32bit)",
"Shed", MB_OK | MB_ICONEXCLAMATION);
- PostQuitMessage(0);
- return;
- }
-
- LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth,
&__cardheight);
-
- FreeLibrary(hCardDll);
- }
+ if(hCardDll == 0)
+ {
+ MessageBox(0, "Error loading cards.dll (32bit)", "Shed",
MB_OK | MB_ICONEXCLAMATION);
+ PostQuitMessage(0);
+ return;
+ }
+
+ LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth,
&__cardheight);
+
+ FreeLibrary(hCardDll);
+ }
#ifndef __REACTOS__
- //Else, Win9X
- else
- {
- hCardDll = LoadLibrary16("cards.dll");
+ //Else, Win9X
+ else
+ {
+ hCardDll = LoadLibrary16("cards.dll");
- if(hCardDll == 0)
- {
- MessageBox(0, "Error loading cards.dll (16bit)",
"Shed", MB_OK | MB_ICONEXCLAMATION);
- PostQuitMessage(0);
- return;
- }
+ if(hCardDll == 0)
+ {
+ MessageBox(0, "Error loading cards.dll (16bit)", "Shed",
MB_OK | MB_ICONEXCLAMATION);
+ PostQuitMessage(0);
+ return;
+ }
- LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth,
&__cardheight);
+ LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth,
&__cardheight);
- FreeLibrary16(hCardDll);
- }
+ FreeLibrary16(hCardDll);
+ }
#endif
}
void FreeCardBitmaps()
{
- DeleteObject (__hbmCardBitmaps);
- DeleteDC (__hdcCardBitmaps);
+ DeleteObject (__hbmCardBitmaps);
+ DeleteDC (__hdcCardBitmaps);
}
//
-// Paint a checkered rectangle, with each alternate
-// pixel being assigned a different colour
+// Paint a checkered rectangle, with each alternate
+// pixel being assigned a different colour
//
static void DrawCheckedRect(HDC hdc, RECT *rect, COLORREF fg, COLORREF
bg)
{
- static WORD wCheckPat[8] =
- {
- 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa,
0x5555
- };
+ static WORD wCheckPat[8] =
+ {
+ 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555
+ };
- HBITMAP hbmp;
- HBRUSH hbr, hbrold;
- COLORREF fgold, bgold;
+ HBITMAP hbmp;
+ HBRUSH hbr, hbrold;
+ COLORREF fgold, bgold;
- hbmp = CreateBitmap(8, 8, 1, 1, wCheckPat);
- hbr = CreatePatternBrush(hbmp);
+ hbmp = CreateBitmap(8, 8, 1, 1, wCheckPat);
+ hbr = CreatePatternBrush(hbmp);
- //UnrealizeObject(hbr);
+ //UnrealizeObject(hbr);
- SetBrushOrgEx(hdc, rect->left, rect->top, 0);
+ SetBrushOrgEx(hdc, rect->left, rect->top, 0);
- hbrold = (HBRUSH)SelectObject(hdc, hbr);
+ hbrold = (HBRUSH)SelectObject(hdc, hbr);
- fgold = SetTextColor(hdc, fg);
- bgold = SetBkColor(hdc, bg);
-
- PatBlt(hdc, rect->left, rect->top,
- rect->right - rect->left,
- rect->bottom - rect->top,
- PATCOPY);
-
- SetBkColor(hdc, bgold);
- SetTextColor(hdc, fgold);
-
- SelectObject(hdc, hbrold);
- DeleteObject(hbr);
- DeleteObject(hbmp);
+ fgold = SetTextColor(hdc, fg);
+ bgold = SetBkColor(hdc, bg);
+
+ PatBlt(hdc, rect->left, rect->top,
+ rect->right - rect->left,
+ rect->bottom - rect->top,
+ PATCOPY);
+
+ SetBkColor(hdc, bgold);
+ SetTextColor(hdc, fgold);
+
+ SelectObject(hdc, hbrold);
+ DeleteObject(hbr);
+ DeleteObject(hbmp);
}
void GetSinkCols(COLORREF crBase, COLORREF *fg, COLORREF *bg, COLORREF
*sh1, COLORREF *sh2)
{
- if(bg) *bg = crBase;
- if(fg) *fg = ColorScaleRGB(crBase, RGB(255,255,255),
0.2);//RGB(49, 99, 140);
- if(sh1) *sh1 = ColorScaleRGB(crBase, RGB(0,0,0), 0.4);
- if(sh2) *sh2 = ColorScaleRGB(crBase, RGB(0,0,0), 0.2);
+ if(bg) *bg = crBase;
+ if(fg) *fg = ColorScaleRGB(crBase, RGB(255,255,255),
0.2);//RGB(49, 99, 140);
+ if(sh1) *sh1 = ColorScaleRGB(crBase, RGB(0,0,0), 0.4);
+ if(sh2) *sh2 = ColorScaleRGB(crBase, RGB(0,0,0), 0.2);
}
HBITMAP CreateSinkBmp(HDC hdcCompat, HDC hdc, COLORREF col, int width,
int height)
{
- HANDLE hold, hpold;
- HBITMAP hbm = CreateCompatibleBitmap(hdcCompat, width, height);
+ HANDLE hold, hpold;
+ HBITMAP hbm = CreateCompatibleBitmap(hdcCompat, width, height);
- HPEN hpfg, hpbg, hpsh, hpsh2;
+ HPEN hpfg, hpbg, hpsh, hpsh2;
- RECT rect;
- COLORREF fg, bg, shadow, shadow2;
+ RECT rect;
+ COLORREF fg, bg, shadow, shadow2;
- GetSinkCols(col, &fg, &bg, &shadow, &shadow2);
+ GetSinkCols(col, &fg, &bg, &shadow, &shadow2);
- hold = SelectObject(hdc, hbm);
+ hold = SelectObject(hdc, hbm);
- //fill with a solid base colour
- SetRect(&rect, 0,0,width,height);
- PaintRect(hdc, &rect, MAKE_PALETTERGB(bg));
+ //fill with a solid base colour
+ SetRect(&rect, 0,0,width,height);
+ PaintRect(hdc, &rect, MAKE_PALETTERGB(bg));
- //draw the outline
- hpfg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(fg));
- hpbg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(bg));
- hpsh = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow));
- hpsh2= CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow2));
+ //draw the outline
+ hpfg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(fg));
+ hpbg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(bg));
+ hpsh = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow));
+ hpsh2= CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow2));
- hpold = SelectObject(hdc, hpsh);
- MoveToEx(hdc, 2, 0, NULL);
- LineTo (hdc, width-3,0);
- LineTo (hdc, width-1, 2);
-
- SelectObject(hdc, hpold);
- hpold = SelectObject(hdc, hpsh2);
- LineTo (hdc, width-1, height-3); //vertical
- LineTo (hdc, width-3, height-1);
- LineTo (hdc, 2, height-1);
- LineTo (hdc, 0, height-3);
- SelectObject(hdc, hpold);
- hpold = SelectObject(hdc, hpsh);
+ hpold = SelectObject(hdc, hpsh);
+ MoveToEx(hdc, 2, 0, NULL);
+ LineTo (hdc, width-3,0);
+ LineTo (hdc, width-1, 2);
+
+ SelectObject(hdc, hpold);
+ hpold = SelectObject(hdc, hpsh2);
+ LineTo (hdc, width-1, height-3); //vertical
+ LineTo (hdc, width-3, height-1);
+ LineTo (hdc, 2, height-1);
+ LineTo (hdc, 0, height-3);
+ SelectObject(hdc, hpold);
+ hpold = SelectObject(hdc, hpsh);
- //MoveToEx( hdc, 0, height-3,0);
- LineTo (hdc, 0, 2);
- LineTo (hdc, 2, 0);
+ //MoveToEx( hdc, 0, height-3,0);
+ LineTo (hdc, 0, 2);
+ LineTo (hdc, 2, 0);
- SelectObject(hdc, hpold);
+ SelectObject(hdc, hpold);
- //draw the highlight (vertical)
- hpold = SelectObject(hdc, hpfg);
- MoveToEx(hdc, width - 2, 3, NULL);
- LineTo (hdc, width - 2, height - 2);
-
- //(horz)
- MoveToEx(hdc, width - 3, height-2, NULL);
- LineTo (hdc, 3, height-2);
- SelectObject(hdc, hpold);
-
- //draw the background
- InflateRect(&rect, -2, -2);
- DrawCheckedRect(hdc, &rect, MAKE_PALETTERGB(bg),
MAKE_PALETTERGB(fg));
+ //draw the highlight (vertical)
+ hpold = SelectObject(hdc, hpfg);
+ MoveToEx(hdc, width - 2, 3, NULL);
+ LineTo (hdc, width - 2, height - 2);
+
+ //(horz)
+ MoveToEx(hdc, width - 3, height-2, NULL);
+ LineTo (hdc, 3, height-2);
+ SelectObject(hdc, hpold);
+
+ //draw the background
+ InflateRect(&rect, -2, -2);
+ DrawCheckedRect(hdc, &rect, MAKE_PALETTERGB(bg),
MAKE_PALETTERGB(fg));
- //overwrite the top-left background pixel
- SetPixel(hdc, 2, 2, MAKE_PALETTERGB(bg));
+ //overwrite the top-left background pixel
+ SetPixel(hdc, 2, 2, MAKE_PALETTERGB(bg));
- DeleteObject(hpsh);
- DeleteObject(hpsh2);
- DeleteObject(hpfg);
- DeleteObject(hpbg);
+ DeleteObject(hpsh);
+ DeleteObject(hpsh2);
+ DeleteObject(hpfg);
+ DeleteObject(hpbg);
-
- return hbm;
+
+ return hbm;
}
void CopyColor(PALETTEENTRY *pe, COLORREF col)
{
- pe->peBlue = GetBValue(col);
- pe->peGreen = GetGValue(col);
- pe->peRed = GetRValue(col);
- pe->peFlags = 0;
+ pe->peBlue = GetBValue(col);
+ pe->peGreen = GetGValue(col);
+ pe->peRed = GetRValue(col);
+ pe->peFlags = 0;
}
HPALETTE MakePaletteFromCols(COLORREF cols[], int nNumColours)
{
- LOGPALETTE *lp;
- HPALETTE hPalette;
+ LOGPALETTE *lp;
+ HPALETTE hPalette;
- // Allocate memory for the logical palette
- lp = (LOGPALETTE *)HeapAlloc(
- GetProcessHeap(), 0, sizeof(LOGPALETTE) +
sizeof(PALETTEENTRY) * nNumColours);
+ // Allocate memory for the logical palette
+ lp = (LOGPALETTE *)HeapAlloc(
+ GetProcessHeap(), 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY)
* nNumColours);
- lp->palNumEntries = nNumColours;
- lp->palVersion = 0x300;
+ lp->palNumEntries = nNumColours;
+ lp->palVersion = 0x300;
- //copy the colours into the logical palette format
- for(int i = 0; i < nNumColours; i++)
- {
- CopyColor(&lp->palPalEntry[i], cols[i]);
- }
+ //copy the colours into the logical palette format
+ for(int i = 0; i < nNumColours; i++)
+ {
+ CopyColor(&lp->palPalEntry[i], cols[i]);
+ }
- // create palette!
- hPalette = CreatePalette(lp);
+ // create palette!
+ hPalette = CreatePalette(lp);
- HeapFree(GetProcessHeap(), 0, lp);
+ HeapFree(GetProcessHeap(), 0, lp);
- return hPalette;
+ return hPalette;
}
_____
Modified: trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp
2005-03-10 14:06:14 UTC (rev 13909)
+++ trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp
2005-03-10 16:08:08 UTC (rev 13910)
@@ -1,8 +1,8 @@
//
-// CardLib - CardButton class
+// CardLib - CardButton class
//
-// Freeware
-// Copyright J Brown 2001
+// Freeware
+// Copyright J Brown 2001
//
#include <windows.h>
#include <tchar.h>
@@ -13,477 +13,477 @@
#include "cardcolor.h"
HPALETTE UseNicePalette(HDC, HPALETTE);
-void RestorePalette(HDC, HPALETTE);
+void RestorePalette(HDC, HPALETTE);
void PaintRect(HDC hdc, RECT *rect, COLORREF colour);
CardButton::CardButton(CardWindow &parent, int Id, TCHAR *szText, UINT
Style, bool visible,
- int x, int y, int width,
int height)
+ int x, int y, int width, int height)
: parentWnd(parent), id(Id), uStyle(Style), fVisible(visible),
ButtonCallback(0)
{
- crText = RGB(255,255,255);
- crBack = RGB(0, 128, 0);
-
- xadjust = 0;
- yadjust = 0;
- xjustify = 0;
- yjustify = 0;
+ crText = RGB(255,255,255);
+ crBack = RGB(0, 128, 0);
+
+ xadjust = 0;
+ yadjust = 0;
+ xjustify = 0;
+ yjustify = 0;
- fMouseDown = false;
- fButtonDown = false;
+ fMouseDown = false;
+ fButtonDown = false;
- hIcon = 0;
+ hIcon = 0;
- SetText(szText);
- Move(x, y, width, height);
+ SetText(szText);
+ Move(x, y, width, height);
- mxlock = CreateMutex(0, FALSE, 0);
+ mxlock = CreateMutex(0, FALSE, 0);
- hFont = 0;
+ hFont = 0;
}
CardButton::~CardButton()
{
- CloseHandle(mxlock);
+ CloseHandle(mxlock);
}
void CardButton::DrawRect(HDC hdc, RECT *rect, bool fNormal)
{
- RECT fill;
+ RECT fill;
- HANDLE hOld;
+ HANDLE hOld;
- HPEN hhi = CreatePen(0, 0, MAKE_PALETTERGB(crHighlight));
- HPEN hsh = CreatePen(0, 0, MAKE_PALETTERGB(crShadow));
- HPEN hbl = (HPEN)GetStockObject(BLACK_PEN);
-
- int x = rect->left;
- int y = rect->top;
- int width = rect->right-rect->left - 1;
- int height = rect->bottom-rect->top - 1;
-
- SetRect(&fill, x+1, y+1, x+width-1, y+height-1);
+ HPEN hhi = CreatePen(0, 0, MAKE_PALETTERGB(crHighlight));
+ HPEN hsh = CreatePen(0, 0, MAKE_PALETTERGB(crShadow));
+ HPEN hbl = (HPEN)GetStockObject(BLACK_PEN);
+
+ int x = rect->left;
+ int y = rect->top;
+ int width = rect->right-rect->left - 1;
+ int height = rect->bottom-rect->top - 1;
+
+ SetRect(&fill, x+1, y+1, x+width-1, y+height-1);
- int one = 1;
-
- if(!fNormal)
- {
- x += width;
- y += height;
- width = -width;
- height = -height;
- one = -1;
- OffsetRect(&fill, 1, 1);
- }
-
- if(fNormal)
- hOld = SelectObject(hdc, hhi);
- else
- hOld = SelectObject(hdc, hhi);
+ int one = 1;
+
+ if(!fNormal)
+ {
+ x += width;
+ y += height;
+ width = -width;
+ height = -height;
+ one = -1;
+ OffsetRect(&fill, 1, 1);
+ }
+
+ if(fNormal)
+ hOld = SelectObject(hdc, hhi);
+ else
+ hOld = SelectObject(hdc, hhi);
- MoveToEx(hdc, x, y+height, 0);
- LineTo(hdc, x, y);
- LineTo(hdc, x+width, y);
- SelectObject(hdc, hOld);
+ MoveToEx(hdc, x, y+height, 0);
+ LineTo(hdc, x, y);
+ LineTo(hdc, x+width, y);
+ SelectObject(hdc, hOld);
- hOld = SelectObject(hdc, hbl);
- LineTo(hdc, x+width, y+height);
- LineTo(hdc, x-one, y+height);
- SelectObject(hdc, hOld);
+ hOld = SelectObject(hdc, hbl);
+ LineTo(hdc, x+width, y+height);
+ LineTo(hdc, x-one, y+height);
+ SelectObject(hdc, hOld);
- hOld = SelectObject(hdc, hsh);
- MoveToEx(hdc, x+one, y+height-one, 0);
- LineTo(hdc, x+width-one, y+height-one);
- LineTo(hdc, x+width-one, y);
- SelectObject(hdc, hOld);
+ hOld = SelectObject(hdc, hsh);
+ MoveToEx(hdc, x+one, y+height-one, 0);
+ LineTo(hdc, x+width-one, y+height-one);
+ LineTo(hdc, x+width-one, y);
+ SelectObject(hdc, hOld);
- PaintRect(hdc, &fill, MAKE_PALETTERGB(crBack));
+ PaintRect(hdc, &fill, MAKE_PALETTERGB(crBack));
- DeleteObject(hhi);
- DeleteObject(hsh);
+ DeleteObject(hhi);
+ DeleteObject(hsh);
}
void CardButton::Clip(HDC hdc)
{
- if(fVisible == false) return;
-
- ExcludeClipRect(hdc, rect.left, rect.top, rect.right,
rect.bottom);
+ if(fVisible == false) return;
+
+ ExcludeClipRect(hdc, rect.left, rect.top, rect.right,
rect.bottom);
}
void CardButton::Draw(HDC hdc, bool fNormal)
{
- SIZE textsize;
- int x, y; //text x, y
- int ix, iy; //icon x, y
- int iconwidth = 0;
+ SIZE textsize;
+ int x, y; //text x, y
+ int ix, iy; //icon x, y
+ int iconwidth = 0;
- RECT cliprect;
+ RECT cliprect;
- if(fVisible == 0) return;
+ if(fVisible == 0) return;
- if(hFont == 0)
- SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- else
- SelectObject(hdc, hFont);
-
- GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textsize);
-
- if(hIcon)
- {
- x = rect.left + 32 + 8;
- }
- else
- {
- if(uStyle & CB_ALIGN_LEFT)
- {
- x = rect.left + iconwidth;
- }
- else if(uStyle & CB_ALIGN_RIGHT)
- {
- x = rect.left +
(rect.right-rect.left-iconwidth-textsize.cx);
- }
- else //centered
- {
- x = rect.right - rect.left - iconwidth;
- x = (x - textsize.cx) / 2;
- x += rect.left + iconwidth;
- }
- }
-
- y = rect.bottom - rect.top;
- y = (y - textsize.cy) / 2;
- y += rect.top;
-
- //calc icon position..
- ix = rect.left + 4;
- iy = rect.top + (rect.bottom-rect.top-32) / 2;
+ if(hFont == 0)
+ SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
+ else
+ SelectObject(hdc, hFont);
+
+ GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textsize);
+
+ if(hIcon)
+ {
+ x = rect.left + 32 + 8;
+ }
+ else
+ {
+ if(uStyle & CB_ALIGN_LEFT)
+ {
+ x = rect.left + iconwidth;
+ }
+ else if(uStyle & CB_ALIGN_RIGHT)
+ {
+ x = rect.left +
(rect.right-rect.left-iconwidth-textsize.cx);
+ }
+ else //centered
+ {
+ x = rect.right - rect.left - iconwidth;
+ x = (x - textsize.cx) / 2;
+ x += rect.left + iconwidth;
+ }
+ }
+
+ y = rect.bottom - rect.top;
+ y = (y - textsize.cy) / 2;
+ y += rect.top;
+
+ //calc icon position..
+ ix = rect.left + 4;
+ iy = rect.top + (rect.bottom-rect.top-32) / 2;
- //if button is pressed, then shift text
- if(fNormal == false && (uStyle & CB_PUSHBUTTON))
- {
- x += 1;
- y += 1;
- ix += 1;
- iy += 1;
- }
+ //if button is pressed, then shift text
+ if(fNormal == false && (uStyle & CB_PUSHBUTTON))
+ {
+ x += 1;
+ y += 1;
+ ix += 1;
+ iy += 1;
+ }
- SetRect(&cliprect, x, y, x+textsize.cx, y+textsize.cy);
- ExcludeClipRect(hdc, x, y, x+textsize.cx, y+textsize.cy);
+ SetRect(&cliprect, x, y, x+textsize.cx, y+textsize.cy);
+ ExcludeClipRect(hdc, x, y, x+textsize.cx, y+textsize.cy);
- //
- // Calc icon pos
- //
-
- if(hIcon)
- {
- ExcludeClipRect(hdc, ix, iy, ix + 32, iy + 32);
- }
-
- if(uStyle & CB_PUSHBUTTON)
- {
- DrawRect(hdc, &rect, fNormal);
+ //
+ // Calc icon pos
+ //
+
+ if(hIcon)
+ {
+ ExcludeClipRect(hdc, ix, iy, ix + 32, iy + 32);
+ }
+
+ if(uStyle & CB_PUSHBUTTON)
+ {
+ DrawRect(hdc, &rect, fNormal);
- SetBkColor(hdc, MAKE_PALETTERGB(crBack));
- SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
-
- SelectClipRgn(hdc, 0);
+ SetBkColor(hdc, MAKE_PALETTERGB(crBack));
+ SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
+
+ SelectClipRgn(hdc, 0);
- ExtTextOut(hdc, x, y, ETO_OPAQUE, &cliprect, szText,
lstrlen(szText), 0);
- }
- else
- {
- SetBkColor(hdc, MAKE_PALETTERGB(crBack));
- SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
+ ExtTextOut(hdc, x, y, ETO_OPAQUE, &cliprect, szText,
lstrlen(szText), 0);
+ }
+ else
+ {
+ SetBkColor(hdc, MAKE_PALETTERGB(crBack));
+ SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
- SelectClipRgn(hdc, 0);
+ SelectClipRgn(hdc, 0);
- ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText,
lstrlen(szText), 0);
- }
+ ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText,
lstrlen(szText), 0);
+ }
- if(hIcon)
- {
- HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBack));
- DrawIconEx(hdc, ix, iy, hIcon, 32, 32, 0, hbr, 0);
- DeleteObject(hbr);
- }
+ if(hIcon)
+ {
+ HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBack));
+ DrawIconEx(hdc, ix, iy, hIcon, 32, 32, 0, hbr, 0);
+ DeleteObject(hbr);
+ }
}
void CardButton::AdjustPosition(int winwidth, int winheight)
{
- int width = rect.right-rect.left;
- int height = rect.bottom-rect.top;
+ int width = rect.right-rect.left;
+ int height = rect.bottom-rect.top;
- width = width & ~0x1;
+ width = width & ~0x1;
- switch(xjustify)
- {
- case CS_XJUST_NONE:
- break;
+ switch(xjustify)
+ {
+ case CS_XJUST_NONE:
+ break;
- case CS_XJUST_CENTER: //centered
- rect.left = (winwidth - (width)) / 2;
- rect.left += xadjust;
- rect.right = rect.left+width;
- break;
+ case CS_XJUST_CENTER: //centered
+ rect.left = (winwidth - (width)) / 2;
+ rect.left += xadjust;
+ rect.right = rect.left+width;
+ break;
- case CS_XJUST_RIGHT: //right-aligned
- rect.left = winwidth - width;
- rect.left += xadjust;
- rect.right = rect.left+width;
- break;
- }
+ case CS_XJUST_RIGHT: //right-aligned
+ rect.left = winwidth - width;
+ rect.left += xadjust;
+ rect.right = rect.left+width;
+ break;
+ }
- switch(yjustify)
- {
- case CS_YJUST_NONE:
- break;
+ switch(yjustify)
+ {
+ case CS_YJUST_NONE:
+ break;
- case CS_YJUST_CENTER: //centered
- rect.top = (winheight - (height)) / 2;
- rect.top += yadjust;
- rect.bottom = rect.top+height;
- break;
+ case CS_YJUST_CENTER: //centered
+ rect.top = (winheight - (height)) / 2;
+ rect.top += yadjust;
+ rect.bottom = rect.top+height;
+ break;
- case CS_YJUST_BOTTOM: //right-aligned
- rect.top = winheight - height;
- rect.top += yadjust;
- rect.bottom = rect.top+height;
- break;
- }
+ case CS_YJUST_BOTTOM: //right-aligned
+ rect.top = winheight - height;
+ rect.top += yadjust;
+ rect.bottom = rect.top+height;
+ break;
+ }
}
int CardButton::OnLButtonDown(HWND hwnd, int x, int y)
{
- if((uStyle & CB_PUSHBUTTON) == 0)
- return 0;
+ if((uStyle & CB_PUSHBUTTON) == 0)
+ return 0;
- //make sure that the user is allowed to do something
- if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)
- {
- return 0;
- }
- else
- {
- ReleaseMutex(mxlock);
- }
-
- fMouseDown = true;
- fButtonDown = true;
+ //make sure that the user is allowed to do something
+ if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)
+ {
+ return 0;
+ }
+ else
+ {
+ ReleaseMutex(mxlock);
+ }
+
+ fMouseDown = true;
+ fButtonDown = true;
- Redraw();
+ Redraw();
- SetCapture(hwnd);
+ SetCapture(hwnd);
- return 1;
+ return 1;
}
int CardButton::OnMouseMove(HWND hwnd, int x, int y)
{
- if(fMouseDown)
- {
- bool fOldButtonDown = fButtonDown;
+ if(fMouseDown)
+ {
+ bool fOldButtonDown = fButtonDown;
- POINT pt;
-
- pt.x = x;
- pt.y = y;
-
- if(PtInRect(&rect, pt))
- fButtonDown = true;
- else
- fButtonDown = false;
-
- if(fButtonDown != fOldButtonDown)
- Redraw();
- }
-
- return 0;
+ POINT pt;
+
+ pt.x = x;
+ pt.y = y;
+
+ if(PtInRect(&rect, pt))
+ fButtonDown = true;
+ else
+ fButtonDown = false;
+
+ if(fButtonDown != fOldButtonDown)
+ Redraw();
+ }
[truncated at 1000 lines; 7184 more skipped]