what would we do without solitaire and winemine !!!
Added: trunk/reactos/base/applications/games/directory.rbuild
Added: trunk/reactos/base/applications/games/solitaire/
Added: trunk/reactos/base/applications/games/solitaire/ReadMe.txt
Added: trunk/reactos/base/applications/games/solitaire/cardlib/
Added: trunk/reactos/base/applications/games/solitaire/cardlib/card.h
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardbitmaps.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardbutton.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardbutton.h
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardcolor.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardcolor.h
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardcount.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardcount.h
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardlib.cpp
Added: trunk/reactos/base/applications/games/solitaire/cardlib/cardlib.h
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardregion.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardregion.h
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardrgndraw.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardrgnmouse.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardstack.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardstack.h
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardwindow.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardwindow.h
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/dropzone.cpp
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/dropzone.h
Added: trunk/reactos/base/applications/games/solitaire/cardlib/globals.h
Added: trunk/reactos/base/applications/games/solitaire/icon1.ico
Added: trunk/reactos/base/applications/games/solitaire/resource.h
Added: trunk/reactos/base/applications/games/solitaire/sol.rc
Added: trunk/reactos/base/applications/games/solitaire/solcreate.cpp
Added: trunk/reactos/base/applications/games/solitaire/solgame.cpp
Added: trunk/reactos/base/applications/games/solitaire/solitaire.cpp
Added: trunk/reactos/base/applications/games/solitaire/solitaire.h
Added: trunk/reactos/base/applications/games/solitaire/solitaire.rbuild
Added: trunk/reactos/base/applications/games/winemine/
Added: trunk/reactos/base/applications/games/winemine/De.rc
Added: trunk/reactos/base/applications/games/winemine/En.rc
Added: trunk/reactos/base/applications/games/winemine/README
Added: trunk/reactos/base/applications/games/winemine/dialog.c
Added: trunk/reactos/base/applications/games/winemine/dialog.h
Added: trunk/reactos/base/applications/games/winemine/main.c
Added: trunk/reactos/base/applications/games/winemine/main.h
Added: trunk/reactos/base/applications/games/winemine/rc/
Added: trunk/reactos/base/applications/games/winemine/rc/Thumbs.db
Added: trunk/reactos/base/applications/games/winemine/rc/faces.bmp
Added: trunk/reactos/base/applications/games/winemine/rc/leds.bmp
Added: trunk/reactos/base/applications/games/winemine/rc/mines.bmp
Added: trunk/reactos/base/applications/games/winemine/rc/winemine.ico
Added: trunk/reactos/base/applications/games/winemine/resource.h
Added: trunk/reactos/base/applications/games/winemine/winemine.rbuild
Added: trunk/reactos/base/applications/games/winemine/winemine.rc
_____
Added: trunk/reactos/base/applications/games/directory.rbuild
--- trunk/reactos/base/applications/games/directory.rbuild
2006-02-04 10:04:41 UTC (rev 84)
+++ trunk/reactos/base/applications/games/directory.rbuild
2006-02-04 12:21:58 UTC (rev 85)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<rbuild
xmlns:xi="http://www.w3.org/2001/XInclude">
+ <group>
+<!--
+ <directory name="solitaire">
+ <xi:include href="solitaire/solitaire.xml" />
+ </directory>
+
+ <directory name="winemine">
+ <xi:include href="winemine/winemine.xml" />
+ </directory>
+-->
+ </group>
+</rbuild>
_____
Added: trunk/reactos/base/applications/games/solitaire/ReadMe.txt
--- trunk/reactos/base/applications/games/solitaire/ReadMe.txt
2006-02-04 10:04:41 UTC (rev 84)
+++ trunk/reactos/base/applications/games/solitaire/ReadMe.txt
2006-02-04 12:21:58 UTC (rev 85)
@@ -0,0 +1,22 @@
+Solitaire for ReactOS
+
+/*****************************************
+A complete working example of the CardLib
+card-game library.
+
+Freeware
+Copyright J Brown 2001
+
+Updates at
http://www.catch22.net
+
+******************************************/
+
+The author has given permission to use these sources
+under Public Domain. Do what thou will but please give
+credit where credit is due.
+
+If you wish to use cardlib to write another card game
+for ReactOS please make cardlib a static lib.
+
+-sedwards
+
_____
Added: trunk/reactos/base/applications/games/solitaire/cardlib/card.h
--- trunk/reactos/base/applications/games/solitaire/cardlib/card.h
2006-02-04 10:04:41 UTC (rev 84)
+++ trunk/reactos/base/applications/games/solitaire/cardlib/card.h
2006-02-04 12:21:58 UTC (rev 85)
@@ -0,0 +1,105 @@
+//
+// CardLib - Card class
+//
+// Freeware
+// Copyright J Brown 2001
+//
+
+#ifndef _CARD_INCLUDED
+#define _CARD_INCLUDED
+
+enum eSuit { Clubs = 0, Diamonds = 1, Hearts = 2, Spades = 3 };
+enum eValue { Ace = 1, Two = 2, Three = 3, Four = 4, Five = 5, Six = 6,
Seven = 7,
+ Eight = 8, Nine = 9, Ten = 10, Jack = 11, Queen = 12,
King = 13 };
+
+inline int MAKE_CARD(int Value, int Suit)
+{
+ if(Value < 1) Value = 1;
+ if(Value == 14) Value = 1;
+ if(Value > 13) Value = 13;
+
+ if(Suit < 0) Suit = 0;
+ if(Suit > 3) Suit = 3;
+
+ return ((Value - 1) * 4 + Suit);
+}
+
+class Card
+{
+ friend class CardStack;
+
+public:
+
+ Card()
+ {
+ nValue = 0; //ace of spades by default
+ fFaceUp = true;
+ }
+
+ Card(int value, int suit) //specify a face value [1-13]
and suit [0-3]
+ {
+ nValue = MAKE_CARD(value, suit);
+ fFaceUp = true;
+ }
+
+ Card(int index) //specify a 0-51 index
+ {
+ if(index < 0) index = 0;
+ if(index > 51) index = 51;
+
+ nValue = index;
+ fFaceUp = true;
+ }
+
+ int Suit() const
+ {
+ return (nValue % 4);
+ }
+
+ int LoVal() const
+ {
+ return (nValue / 4) + 1;
+ }
+
+ int HiVal() const
+ {
+ return ((nValue < 4) ? 14 : (nValue / 4) + 1);
+ }
+
+ int Idx() const //unique value (0-51 etc)
+ {
+ return nValue;
+ }
+
+ bool FaceUp() const
+ {
+ return fFaceUp;
+ }
+
+ bool FaceDown() const
+ {
+ return !fFaceUp;
+ }
+
+ void SetFaceUp(bool fTrue)
+ {
+ fFaceUp = fTrue;
+ }
+
+ bool IsBlack() const
+ {
+ return Suit() == 0 || Suit() == 3;
+ }
+
+ bool IsRed() const
+ {
+ return !IsBlack();
+ }
+
+private:
+
+ int nValue;
+ bool fFaceUp;
+};
+
+#endif
_____
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardbitmaps.cpp
---
trunk/reactos/base/applications/games/solitaire/cardlib/cardbitmaps.cpp
2006-02-04 10:04:41 UTC (rev 84)
+++
trunk/reactos/base/applications/games/solitaire/cardlib/cardbitmaps.cpp
2006-02-04 12:21:58 UTC (rev 85)
@@ -0,0 +1,281 @@
+//
+// CardLib - Card bitmap support
+//
+// Freeware
+// Copyright J Brown 2001
+//
+#include <windows.h>
+#include "globals.h"
+#include "cardcolor.h"
+
+#ifndef __REACTOS__
+#pragma comment( lib, "..\\CardLib\\cards16.lib" )
+
+extern "C" HINSTANCE WINAPI LoadLibrary16( PSTR );
+extern "C" void WINAPI FreeLibrary16( HINSTANCE );
+#endif
+
+#define NUMCARDBITMAPS (52+16)
+
+void PaintRect(HDC hdc, RECT *rect, COLORREF col);
+
+void LoadCardBitmapsFromLibrary(HINSTANCE hCardDll, int *pwidth, int
*pheight)
+{
+ HBITMAP hBitmap;
+ HDC hdcCard = NULL;
+ 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);
+
+ *pwidth = width;
+ *pheight = height;
+
+}
+
+void LoadCardBitmaps(void)
+{
+ HINSTANCE hCardDll;
+
+
+ //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);
+ }
+#ifndef __REACTOS__
+ //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;
+ }
+
+ LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth,
&__cardheight);
+
+ FreeLibrary16(hCardDll);
+ }
+#endif
+}
+
+void FreeCardBitmaps()
+{
+ DeleteObject (__hbmCardBitmaps);
+ DeleteDC (__hdcCardBitmaps);
+}
+//
+// 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
+ };
+
+ HBITMAP hbmp;
+ HBRUSH hbr, hbrold;
+ COLORREF fgold, bgold;
+
+ hbmp = CreateBitmap(8, 8, 1, 1, wCheckPat);
+ hbr = CreatePatternBrush(hbmp);
+
+ //UnrealizeObject(hbr);
+
+ SetBrushOrgEx(hdc, rect->left, rect->top, 0);
+
+ 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);
+}
+
+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);
+}
+
+HBITMAP CreateSinkBmp(HDC hdcCompat, HDC hdc, COLORREF col, int width,
int height)
+{
+ HANDLE hold, hpold;
+ HBITMAP hbm = CreateCompatibleBitmap(hdcCompat, width, height);
+
+ HPEN hpfg, hpbg, hpsh, hpsh2;
+
+ RECT rect;
+ COLORREF fg, bg, shadow, shadow2;
+
+ GetSinkCols(col, &fg, &bg, &shadow, &shadow2);
+
+ hold = SelectObject(hdc, hbm);
+
+ //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));
+
+ 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);
+
+ 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));
+
+ //overwrite the top-left background pixel
+ SetPixel(hdc, 2, 2, MAKE_PALETTERGB(bg));
+
+ DeleteObject(hpsh);
+ DeleteObject(hpsh2);
+ DeleteObject(hpfg);
+ DeleteObject(hpbg);
+
+
+ return hbm;
+}
+
+
+
+void CopyColor(PALETTEENTRY *pe, COLORREF col)
+{
+ 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;
+
+ // Allocate memory for the logical palette
+ lp = (LOGPALETTE *)HeapAlloc(
+ GetProcessHeap(), 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY)
* nNumColours);
+
+ 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]);
+ }
+
+ // create palette!
+ hPalette = CreatePalette(lp);
+
+ HeapFree(GetProcessHeap(), 0, lp);
+
+ return hPalette;
+}
_____
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardbutton.cpp
---
trunk/reactos/base/applications/games/solitaire/cardlib/cardbutton.cpp
2006-02-04 10:04:41 UTC (rev 84)
+++
trunk/reactos/base/applications/games/solitaire/cardlib/cardbutton.cpp
2006-02-04 12:21:58 UTC (rev 85)
@@ -0,0 +1,489 @@
+//
+// CardLib - CardButton class
+//
+// Freeware
+// Copyright J Brown 2001
+//
+#include <windows.h>
+#include <tchar.h>
+
+#include "cardlib.h"
+#include "cardwindow.h"
+#include "cardbutton.h"
+#include "cardcolor.h"
+
+HPALETTE UseNicePalette(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)
+
+ : 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;
+
+ fMouseDown = false;
+ fButtonDown = false;
+
+ hIcon = 0;
+
+ SetText(szText);
+ Move(x, y, width, height);
+
+ mxlock = CreateMutex(0, FALSE, 0);
+
+ hFont = 0;
+}
+
+CardButton::~CardButton()
+{
+ CloseHandle(mxlock);
+}
+
+void CardButton::DrawRect(HDC hdc, RECT *rect, bool fNormal)
+{
+ RECT fill;
+
+ 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);
+
+ 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);
+
+ 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);
+
+ PaintRect(hdc, &fill, MAKE_PALETTERGB(crBack));
+
+ DeleteObject(hhi);
+ DeleteObject(hsh);
+}
+
+void CardButton::Clip(HDC hdc)
+{
+ 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;
+
+ RECT cliprect;
+
+ 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 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);
+
+ //
+ // 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);
+
+ 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);
+
+ 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);
+ }
+
+}
+
+void CardButton::AdjustPosition(int winwidth, int winheight)
+{
+ int width = rect.right-rect.left;
+ int height = rect.bottom-rect.top;
+
+ width = width & ~0x1;
+
+ 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_RIGHT: //right-aligned
+ rect.left = winwidth - width;
+ rect.left += xadjust;
+ rect.right = rect.left+width;
+ 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_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;
+
+ //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();
+
+ SetCapture(hwnd);
+
+ return 1;
+}
+
+int CardButton::OnMouseMove(HWND hwnd, int x, int y)
+{
+ 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;
+}
+
+int CardButton::OnLButtonUp(HWND hwnd, int x, int y)
+{
+ if(fMouseDown)
+ {
+ fMouseDown = false;
+ fButtonDown = false;
+
+ if(uStyle & CB_PUSHBUTTON)
+ {
+ Redraw();
+ ReleaseCapture();
+ }
+
+ //if have clicked the button
+ if(parentWnd.CardButtonFromPoint(x, y) == this)
+ {
+ if(ButtonCallback)
+ {
+ ButtonCallback(*this);
+ }
+ else
+ {
+ HWND hwnd = (HWND)parentWnd;
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(id,
BN_CLICKED), (LONG)hwnd);
+ }
+ }
+ }
+
+ return 0;
+}
+
+#define _countof(array) (sizeof(array)/sizeof(array[0]))
+
+CardButton *CardWindow::CreateButton(int id, TCHAR *szText, UINT
uStyle, bool fVisible, int x, int y, int width, int height)
+{
+ CardButton *cb;
+
+ if(nNumButtons == MAXBUTTONS)
+ return 0;
+
+ cb = new CardButton(*this, id, szText, uStyle, fVisible, x, y,
width, height);
+ Buttons[nNumButtons++] = cb;
+
+ if(uStyle & CB_PUSHBUTTON)
+ {
+ cb->SetBackColor(CardButton::GetFace(crBackgnd));
+ //cb->SetBackColor(ScaleLumRGB(crBackgnd, 0.1));
+ cb->SetForeColor(RGB(255,255,255));
+ }
+ else
+ {
+ cb->SetBackColor(crBackgnd);
+ cb->SetForeColor(RGB(255,255,255));
+ }
+
+ return cb;
+}
+
+void CardButton::SetText(TCHAR *lpszFormat, ...)
+{
+ int count;
+
+ va_list args;
+ va_start(args, lpszFormat);
+
+ count = wvsprintf(szText, lpszFormat, args);
+ va_end(args);
+}
+
+int CardButton::Id()
+{
+ return id;
+}
+
+void CardButton::Show(bool fShow)
+{
+ fVisible = fShow;
+}
+
+void CardButton::Move(int x, int y, int width, int height)
+{
+ SetRect(&rect, x, y, x+width, y+height);
+}
+
+void CardButton::Redraw()
+{
+ HDC hdc = GetDC((HWND)parentWnd);
+
+ HPALETTE hOldPal = UseNicePalette(hdc, __hPalette);
+
+ Draw(hdc, !fButtonDown);
+
+ RestorePalette(hdc, hOldPal);
+
+ ReleaseDC((HWND)parentWnd, hdc);
+}
+
+void CardButton::SetForeColor(COLORREF cr)
+{
+ crText = cr;
+}
+
+void CardButton::SetBackColor(COLORREF cr)
+{
+ crBack = cr;
+
+ crHighlight = GetHighlight(cr);
+ crShadow = GetShadow(cr);
+
+ //crHighlight = ScaleLumRGB(cr, +0.25);
+ //crShadow = ScaleLumRGB(cr, -0.25);
+}
+
+// Static member
+COLORREF CardButton::GetHighlight(COLORREF crBase)
+{
+ return ColorScaleRGB(crBase, RGB(255,255,255), 0.25);
+}
+
+// Static member
+COLORREF CardButton::GetShadow(COLORREF crBase)
+{
+ return ColorScaleRGB(crBase, RGB(0, 0, 0), 0.25);
+}
+
+COLORREF CardButton::GetFace(COLORREF crBase)
+{
+ return ColorScaleRGB(crBase, RGB(255,255,255), 0.1);
+}
+
+void CardButton::SetPlacement(UINT xJustify, UINT yJustify, int
xAdjust, int yAdjust)
+{
+ xadjust = xAdjust;
+ yadjust = yAdjust;
+ xjustify = xJustify;
+ yjustify = yJustify;
+}
+
+void CardButton::SetIcon(HICON hicon, bool fRedraw)
+{
+ hIcon = hicon;
+
+ if(fRedraw)
+ Redraw();
+}
+
+void CardButton::SetFont(HFONT font)
+{
+ //don't delete the existing font..
+ hFont = font;
+}
+
+void CardButton::SetButtonProc(pButtonProc proc)
+{
+ ButtonCallback = proc;
+}
+
+bool CardButton::Lock()
+{
+ DWORD dw = WaitForSingleObject(mxlock, 0);
+
+ if(dw == WAIT_OBJECT_0)
+ return true;
+ else
+ return false;
+}
+
+bool CardButton::UnLock()
+{
+ if(ReleaseMutex(mxlock))
+ return true;
+ else
+ return false;
+}
+
+void CardButton::SetStyle(UINT style)
+{
+ uStyle = style;
+}
+
+UINT CardButton::GetStyle()
+{
+ return uStyle;
+}
_____
Added:
trunk/reactos/base/applications/games/solitaire/cardlib/cardbutton.h
--- trunk/reactos/base/applications/games/solitaire/cardlib/cardbutton.h
2006-02-04 10:04:41 UTC (rev 84)
+++ trunk/reactos/base/applications/games/solitaire/cardlib/cardbutton.h
2006-02-04 12:21:58 UTC (rev 85)
@@ -0,0 +1,101 @@
+#ifndef CARDBUTTON_INCLUDED
+#define CARDBUTTON_INCLUDED
+
+#define MAXBUTTONTEXT 64
+
+#include "cardlib.h"
+
+class CardButton
+{
+ friend class CardWindow;
+
+ //
+ // Constructor is PRIVATE - only a
+ // CardWindow can create buttons!
+ //
+ CardButton(CardWindow &parent, int id, TCHAR *szText, UINT
style, bool visible,
+ int x, int y, int width, int height);
+
+ ~CardButton();
+
+public:
+
+ 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);
+
+ CardWindow &GetCardWindow() { return parentWnd; }
+
+ bool Lock();
+ bool UnLock();
+
+ static COLORREF GetHighlight(COLORREF crBase);
+ static COLORREF GetShadow(COLORREF crBase);
+ static COLORREF GetFace(COLORREF crBase);
+
+private:
+
+ //
+ // Private member functions
+ //
+ void AdjustPosition(int winwidth, int winheight);
+
+ void DrawRect(HDC hdc, RECT *rect, bool fNormal);
[truncated at 1000 lines; 7027 more skipped]