Change tabs to spaces.
authorSteven Edwards <winehacker@gmail.com>
Thu, 10 Mar 2005 16:08:08 +0000 (16:08 +0000)
committerSteven Edwards <winehacker@gmail.com>
Thu, 10 Mar 2005 16:08:08 +0000 (16:08 +0000)
svn path=/trunk/; revision=13910

14 files changed:
rosapps/games/solitaire/cardlib/cardbitmaps.cpp
rosapps/games/solitaire/cardlib/cardbutton.cpp
rosapps/games/solitaire/cardlib/cardcolor.cpp
rosapps/games/solitaire/cardlib/cardcount.cpp
rosapps/games/solitaire/cardlib/cardlib.cpp
rosapps/games/solitaire/cardlib/cardregion.cpp
rosapps/games/solitaire/cardlib/cardrgndraw.cpp
rosapps/games/solitaire/cardlib/cardrgnmouse.cpp
rosapps/games/solitaire/cardlib/cardstack.cpp
rosapps/games/solitaire/cardlib/cardwindow.cpp
rosapps/games/solitaire/cardlib/dropzone.cpp
rosapps/games/solitaire/solcreate.cpp
rosapps/games/solitaire/solgame.cpp
rosapps/games/solitaire/solitaire.cpp

index 530f651..9c5b4da 100644 (file)
@@ -1,8 +1,8 @@
 //\r
-//     CardLib - Card bitmap support\r
+//    CardLib - Card bitmap support\r
 //\r
-//     Freeware\r
-//     Copyright J Brown 2001\r
+//    Freeware\r
+//    Copyright J Brown 2001\r
 //\r
 #include <windows.h>\r
 #include "globals.h"\r
@@ -12,7 +12,7 @@
 #pragma comment( lib, "..\\CardLib\\cards16.lib" )\r
 \r
 extern "C" HINSTANCE WINAPI LoadLibrary16( PSTR );\r
-extern "C" void                 WINAPI FreeLibrary16( HINSTANCE );\r
+extern "C" void         WINAPI FreeLibrary16( HINSTANCE );\r
 #endif\r
 \r
 #define NUMCARDBITMAPS (52+16)\r
@@ -21,261 +21,261 @@ void PaintRect(HDC hdc, RECT *rect, COLORREF col);
 \r
 void LoadCardBitmapsFromLibrary(HINSTANCE hCardDll, int *pwidth, int *pheight)\r
 {\r
-       HBITMAP   hBitmap;\r
-       HDC               hdcCard;\r
-       HANDLE    hOld;\r
-       int             i, xpos;\r
-       int             width, height;\r
-       BITMAP bmp;\r
-\r
-       for(i = 0; i < NUMCARDBITMAPS; i++)\r
-       {\r
-               //convert into the range used by the cdt_xxx functions\r
-               int val;\r
-               \r
-               if(i < 52) val = (i % 4) * 13 + (i/4);\r
-               else       val = i;\r
-               \r
-               hBitmap = LoadBitmap(hCardDll, MAKEINTRESOURCE(val + 1));\r
-               GetObject(hBitmap, sizeof(bmp), &bmp);\r
-               \r
-               width  = bmp.bmWidth;\r
-               height = bmp.bmHeight;\r
-               \r
-               if(i == 0)      //if first time through, create BIG bitmap..\r
-               {\r
-                       HDC hdc = GetDC(0);\r
-                       __hdcCardBitmaps = CreateCompatibleDC(hdc);\r
-                       __hbmCardBitmaps = CreateCompatibleBitmap(hdc, width * NUMCARDBITMAPS, height);\r
-                       SelectObject(__hdcCardBitmaps, __hbmCardBitmaps);\r
-                       \r
-                       hdcCard = CreateCompatibleDC(0);\r
-                       \r
-                       ReleaseDC(0, hdc);\r
-               }\r
-               \r
-               hOld = SelectObject(hdcCard, hBitmap);\r
-               BitBlt(__hdcCardBitmaps, i*width, 0, width, height, hdcCard, 0, 0, SRCCOPY);\r
-               SelectObject(hdcCard, hOld);\r
-               \r
-               //Now draw a black border around each card...\r
-               xpos = i*width;\r
-               MoveToEx(__hdcCardBitmaps, xpos+2, 0, 0);\r
-               LineTo(__hdcCardBitmaps, xpos+width - 3, 0);\r
-               LineTo(__hdcCardBitmaps, xpos+width - 1, 2);\r
-               LineTo(__hdcCardBitmaps, xpos+width - 1, height - 3);   //vertical\r
-               LineTo(__hdcCardBitmaps, xpos+width - 3, height - 1);\r
-               LineTo(__hdcCardBitmaps, xpos+2, height - 1);\r
-               LineTo(__hdcCardBitmaps, xpos+0, height - 3);\r
-               LineTo(__hdcCardBitmaps, xpos+0, 2);\r
-               LineTo(__hdcCardBitmaps, xpos+2, 0);\r
-               \r
-               DeleteObject(hBitmap);\r
-       }\r
-       \r
-       DeleteDC(hdcCard);\r
-\r
-       *pwidth = width;\r
-       *pheight = height;\r
-                               \r
+    HBITMAP   hBitmap;\r
+    HDC          hdcCard;\r
+    HANDLE      hOld;\r
+    int        i, xpos;\r
+    int        width, height;\r
+    BITMAP bmp;\r
+\r
+    for(i = 0; i < NUMCARDBITMAPS; i++)\r
+    {\r
+        //convert into the range used by the cdt_xxx functions\r
+        int val;\r
+        \r
+        if(i < 52) val = (i % 4) * 13 + (i/4);\r
+        else       val = i;\r
+        \r
+        hBitmap = LoadBitmap(hCardDll, MAKEINTRESOURCE(val + 1));\r
+        GetObject(hBitmap, sizeof(bmp), &bmp);\r
+        \r
+        width  = bmp.bmWidth;\r
+        height = bmp.bmHeight;\r
+        \r
+        if(i == 0)    //if first time through, create BIG bitmap..\r
+        {\r
+            HDC hdc = GetDC(0);\r
+            __hdcCardBitmaps = CreateCompatibleDC(hdc);\r
+            __hbmCardBitmaps = CreateCompatibleBitmap(hdc, width * NUMCARDBITMAPS, height);\r
+            SelectObject(__hdcCardBitmaps, __hbmCardBitmaps);\r
+            \r
+            hdcCard = CreateCompatibleDC(0);\r
+            \r
+            ReleaseDC(0, hdc);\r
+        }\r
+        \r
+        hOld = SelectObject(hdcCard, hBitmap);\r
+        BitBlt(__hdcCardBitmaps, i*width, 0, width, height, hdcCard, 0, 0, SRCCOPY);\r
+        SelectObject(hdcCard, hOld);\r
+        \r
+        //Now draw a black border around each card...\r
+        xpos = i*width;\r
+        MoveToEx(__hdcCardBitmaps, xpos+2, 0, 0);\r
+        LineTo(__hdcCardBitmaps, xpos+width - 3, 0);\r
+        LineTo(__hdcCardBitmaps, xpos+width - 1, 2);\r
+        LineTo(__hdcCardBitmaps, xpos+width - 1, height - 3);    //vertical\r
+        LineTo(__hdcCardBitmaps, xpos+width - 3, height - 1);\r
+        LineTo(__hdcCardBitmaps, xpos+2, height - 1);\r
+        LineTo(__hdcCardBitmaps, xpos+0, height - 3);\r
+        LineTo(__hdcCardBitmaps, xpos+0, 2);\r
+        LineTo(__hdcCardBitmaps, xpos+2, 0);\r
+        \r
+        DeleteObject(hBitmap);\r
+    }\r
+    \r
+    DeleteDC(hdcCard);\r
+\r
+    *pwidth = width;\r
+    *pheight = height;\r
+                \r
 }\r
 \r
 void LoadCardBitmaps(void)\r
 {\r
-       HINSTANCE hCardDll;\r
-       \r
-\r
-       //If Windows NT/2000/XP\r
-       if(GetVersion() < 0x80000000)\r
-       {\r
-               hCardDll = LoadLibrary("cards.dll");\r
-\r
-               if(hCardDll == 0)\r
-               {\r
-                       MessageBox(0, "Error loading cards.dll (32bit)", "Shed", MB_OK | MB_ICONEXCLAMATION);\r
-                       PostQuitMessage(0);\r
-                       return;\r
-               }\r
-               \r
-               LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth, &__cardheight);\r
-               \r
-               FreeLibrary(hCardDll);\r
-       }\r
+    HINSTANCE hCardDll;\r
+    \r
+\r
+    //If Windows NT/2000/XP\r
+    if(GetVersion() < 0x80000000)\r
+    {\r
+        hCardDll = LoadLibrary("cards.dll");\r
+\r
+        if(hCardDll == 0)\r
+        {\r
+            MessageBox(0, "Error loading cards.dll (32bit)", "Shed", MB_OK | MB_ICONEXCLAMATION);\r
+            PostQuitMessage(0);\r
+            return;\r
+        }\r
+        \r
+        LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth, &__cardheight);\r
+        \r
+        FreeLibrary(hCardDll);\r
+    }\r
 #ifndef __REACTOS__\r
-       //Else, Win9X\r
-       else\r
-       {\r
-               hCardDll = LoadLibrary16("cards.dll");\r
-\r
-               if(hCardDll == 0)\r
-               {\r
-                       MessageBox(0, "Error loading cards.dll (16bit)", "Shed", MB_OK | MB_ICONEXCLAMATION);\r
-                       PostQuitMessage(0);\r
-                       return;\r
-               }\r
-\r
-               LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth, &__cardheight);\r
-\r
-               FreeLibrary16(hCardDll);\r
-       }\r
+    //Else, Win9X\r
+    else\r
+    {\r
+        hCardDll = LoadLibrary16("cards.dll");\r
+\r
+        if(hCardDll == 0)\r
+        {\r
+            MessageBox(0, "Error loading cards.dll (16bit)", "Shed", MB_OK | MB_ICONEXCLAMATION);\r
+            PostQuitMessage(0);\r
+            return;\r
+        }\r
+\r
+        LoadCardBitmapsFromLibrary(hCardDll, &__cardwidth, &__cardheight);\r
+\r
+        FreeLibrary16(hCardDll);\r
+    }\r
 #endif\r
 }\r
 \r
 void FreeCardBitmaps()\r
 {\r
-       DeleteObject (__hbmCardBitmaps);\r
-       DeleteDC     (__hdcCardBitmaps);\r
+    DeleteObject (__hbmCardBitmaps);\r
+    DeleteDC     (__hdcCardBitmaps);\r
 }\r
 //\r
-//     Paint a checkered rectangle, with each alternate\r
-//     pixel being assigned a different colour\r
+//    Paint a checkered rectangle, with each alternate\r
+//    pixel being assigned a different colour\r
 //\r
 static void DrawCheckedRect(HDC hdc, RECT *rect, COLORREF fg, COLORREF bg)\r
 {\r
-       static WORD wCheckPat[8] = \r
-       \r
-               0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555 \r
-       };\r
-\r
-       HBITMAP hbmp;\r
-       HBRUSH  hbr, hbrold;\r
-       COLORREF fgold, bgold;\r
-\r
-       hbmp = CreateBitmap(8, 8, 1, 1, wCheckPat);\r
-       hbr  = CreatePatternBrush(hbmp);\r
-\r
-       //UnrealizeObject(hbr);\r
-\r
-       SetBrushOrgEx(hdc, rect->left, rect->top, 0);\r
-\r
-       hbrold = (HBRUSH)SelectObject(hdc, hbr);\r
-\r
-       fgold = SetTextColor(hdc, fg);\r
-       bgold = SetBkColor(hdc, bg);\r
-       \r
-       PatBlt(hdc, rect->left, rect->top, \r
-                               rect->right - rect->left, \r
-                               rect->bottom - rect->top, \r
-                               PATCOPY);\r
-       \r
-       SetBkColor(hdc, bgold);\r
-       SetTextColor(hdc, fgold);\r
-       \r
-       SelectObject(hdc, hbrold);\r
-       DeleteObject(hbr);\r
-       DeleteObject(hbmp);\r
+    static WORD wCheckPat[8] = \r
+    { \r
+        0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555 \r
+    };\r
+\r
+    HBITMAP hbmp;\r
+    HBRUSH  hbr, hbrold;\r
+    COLORREF fgold, bgold;\r
+\r
+    hbmp = CreateBitmap(8, 8, 1, 1, wCheckPat);\r
+    hbr  = CreatePatternBrush(hbmp);\r
+\r
+    //UnrealizeObject(hbr);\r
+\r
+    SetBrushOrgEx(hdc, rect->left, rect->top, 0);\r
+\r
+    hbrold = (HBRUSH)SelectObject(hdc, hbr);\r
+\r
+    fgold = SetTextColor(hdc, fg);\r
+    bgold = SetBkColor(hdc, bg);\r
+    \r
+    PatBlt(hdc, rect->left, rect->top, \r
+                rect->right - rect->left, \r
+                rect->bottom - rect->top, \r
+                PATCOPY);\r
+    \r
+    SetBkColor(hdc, bgold);\r
+    SetTextColor(hdc, fgold);\r
+    \r
+    SelectObject(hdc, hbrold);\r
+    DeleteObject(hbr);\r
+    DeleteObject(hbmp);\r
 }\r
 \r
 void GetSinkCols(COLORREF crBase, COLORREF *fg, COLORREF *bg, COLORREF *sh1, COLORREF *sh2)\r
 {\r
-       if(bg) *bg       = crBase;\r
-       if(fg) *fg   = ColorScaleRGB(crBase, RGB(255,255,255), 0.2);//RGB(49, 99, 140);\r
-       if(sh1) *sh1 = ColorScaleRGB(crBase, RGB(0,0,0), 0.4);\r
-       if(sh2) *sh2 = ColorScaleRGB(crBase, RGB(0,0,0), 0.2);\r
+    if(bg) *bg     = crBase;\r
+    if(fg) *fg   = ColorScaleRGB(crBase, RGB(255,255,255), 0.2);//RGB(49, 99, 140);\r
+    if(sh1) *sh1 = ColorScaleRGB(crBase, RGB(0,0,0), 0.4);\r
+    if(sh2) *sh2 = ColorScaleRGB(crBase, RGB(0,0,0), 0.2);\r
 }\r
 \r
 HBITMAP CreateSinkBmp(HDC hdcCompat, HDC hdc, COLORREF col, int width, int height)\r
 {\r
-       HANDLE hold, hpold;\r
-       HBITMAP hbm = CreateCompatibleBitmap(hdcCompat, width, height);\r
-\r
-       HPEN hpfg, hpbg, hpsh, hpsh2;\r
-\r
-       RECT rect;\r
-       COLORREF fg, bg, shadow, shadow2;\r
-\r
-       GetSinkCols(col, &fg, &bg, &shadow, &shadow2);\r
-\r
-       hold = SelectObject(hdc, hbm);\r
-\r
-       //fill with a solid base colour\r
-       SetRect(&rect, 0,0,width,height);\r
-       PaintRect(hdc, &rect, MAKE_PALETTERGB(bg));\r
-\r
-       //draw the outline\r
-       hpfg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(fg));\r
-       hpbg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(bg));\r
-       hpsh = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow));\r
-       hpsh2= CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow2));        \r
-\r
-       hpold = SelectObject(hdc, hpsh);\r
-       MoveToEx(hdc, 2, 0, NULL);\r
-       LineTo  (hdc, width-3,0);\r
-       LineTo  (hdc, width-1, 2);\r
-       \r
-       SelectObject(hdc, hpold);\r
-       hpold = SelectObject(hdc, hpsh2);\r
-       LineTo  (hdc, width-1, height-3);       //vertical\r
-       LineTo  (hdc, width-3, height-1);\r
-       LineTo  (hdc, 2, height-1);\r
-       LineTo  (hdc, 0, height-3);\r
-       SelectObject(hdc, hpold);\r
-       hpold = SelectObject(hdc, hpsh);\r
-\r
-       //MoveToEx( hdc, 0, height-3,0);\r
-       LineTo  (hdc, 0, 2);\r
-       LineTo  (hdc, 2, 0);\r
-\r
-       SelectObject(hdc, hpold);\r
-\r
-       //draw the highlight (vertical)\r
-       hpold = SelectObject(hdc, hpfg);\r
-       MoveToEx(hdc, width - 2, 3, NULL);\r
-       LineTo  (hdc, width - 2, height - 2);\r
-       \r
-       //(horz)\r
-       MoveToEx(hdc, width - 3, height-2, NULL);\r
-       LineTo  (hdc, 3, height-2);\r
-       SelectObject(hdc, hpold);\r
-       \r
-       //draw the background\r
-       InflateRect(&rect, -2, -2);\r
-       DrawCheckedRect(hdc, &rect, MAKE_PALETTERGB(bg), MAKE_PALETTERGB(fg));\r
-\r
-       //overwrite the top-left background pixel\r
-       SetPixel(hdc, 2, 2, MAKE_PALETTERGB(bg));\r
-\r
-       DeleteObject(hpsh);\r
-       DeleteObject(hpsh2);\r
-       DeleteObject(hpfg);\r
-       DeleteObject(hpbg);\r
-\r
-       \r
-       return hbm;\r
+    HANDLE hold, hpold;\r
+    HBITMAP hbm = CreateCompatibleBitmap(hdcCompat, width, height);\r
+\r
+    HPEN hpfg, hpbg, hpsh, hpsh2;\r
+\r
+    RECT rect;\r
+    COLORREF fg, bg, shadow, shadow2;\r
+\r
+    GetSinkCols(col, &fg, &bg, &shadow, &shadow2);\r
+\r
+    hold = SelectObject(hdc, hbm);\r
+\r
+    //fill with a solid base colour\r
+    SetRect(&rect, 0,0,width,height);\r
+    PaintRect(hdc, &rect, MAKE_PALETTERGB(bg));\r
+\r
+    //draw the outline\r
+    hpfg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(fg));\r
+    hpbg = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(bg));\r
+    hpsh = CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow));\r
+    hpsh2= CreatePen(PS_SOLID, 0, MAKE_PALETTERGB(shadow2));    \r
+\r
+    hpold = SelectObject(hdc, hpsh);\r
+    MoveToEx(hdc, 2, 0, NULL);\r
+    LineTo  (hdc, width-3,0);\r
+    LineTo  (hdc, width-1, 2);\r
+    \r
+    SelectObject(hdc, hpold);\r
+    hpold = SelectObject(hdc, hpsh2);\r
+    LineTo  (hdc, width-1, height-3);    //vertical\r
+    LineTo  (hdc, width-3, height-1);\r
+    LineTo  (hdc, 2, height-1);\r
+    LineTo  (hdc, 0, height-3);\r
+    SelectObject(hdc, hpold);\r
+    hpold = SelectObject(hdc, hpsh);\r
+\r
+    //MoveToEx( hdc, 0, height-3,0);\r
+    LineTo  (hdc, 0, 2);\r
+    LineTo  (hdc, 2, 0);\r
+\r
+    SelectObject(hdc, hpold);\r
+\r
+    //draw the highlight (vertical)\r
+    hpold = SelectObject(hdc, hpfg);\r
+    MoveToEx(hdc, width - 2, 3, NULL);\r
+    LineTo  (hdc, width - 2, height - 2);\r
+    \r
+    //(horz)\r
+    MoveToEx(hdc, width - 3, height-2, NULL);\r
+    LineTo  (hdc, 3, height-2);\r
+    SelectObject(hdc, hpold);\r
+    \r
+    //draw the background\r
+    InflateRect(&rect, -2, -2);\r
+    DrawCheckedRect(hdc, &rect, MAKE_PALETTERGB(bg), MAKE_PALETTERGB(fg));\r
+\r
+    //overwrite the top-left background pixel\r
+    SetPixel(hdc, 2, 2, MAKE_PALETTERGB(bg));\r
+\r
+    DeleteObject(hpsh);\r
+    DeleteObject(hpsh2);\r
+    DeleteObject(hpfg);\r
+    DeleteObject(hpbg);\r
+\r
+    \r
+    return hbm;\r
 }\r
 \r
 \r
 \r
 void CopyColor(PALETTEENTRY *pe, COLORREF col)\r
 {\r
-       pe->peBlue  = GetBValue(col);\r
-       pe->peGreen = GetGValue(col);\r
-       pe->peRed   = GetRValue(col);\r
-       pe->peFlags = 0;\r
+    pe->peBlue  = GetBValue(col);\r
+    pe->peGreen = GetGValue(col);\r
+    pe->peRed   = GetRValue(col);\r
+    pe->peFlags = 0;\r
 }\r
 \r
 HPALETTE MakePaletteFromCols(COLORREF cols[], int nNumColours)\r
 {\r
-       LOGPALETTE      *lp;\r
-       HPALETTE        hPalette;\r
+    LOGPALETTE    *lp;\r
+    HPALETTE    hPalette;\r
 \r
-       //      Allocate memory for the logical palette\r
-       lp = (LOGPALETTE *)HeapAlloc(\r
-               GetProcessHeap(), 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * nNumColours);\r
+    //    Allocate memory for the logical palette\r
+    lp = (LOGPALETTE *)HeapAlloc(\r
+        GetProcessHeap(), 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * nNumColours);\r
 \r
-       lp->palNumEntries = nNumColours;\r
-       lp->palVersion    = 0x300;\r
+    lp->palNumEntries = nNumColours;\r
+    lp->palVersion    = 0x300;\r
 \r
-       //copy the colours into the logical palette format\r
-       for(int i = 0; i < nNumColours; i++)\r
-       {\r
-               CopyColor(&lp->palPalEntry[i], cols[i]);\r
-       }\r
+    //copy the colours into the logical palette format\r
+    for(int i = 0; i < nNumColours; i++)\r
+    {\r
+        CopyColor(&lp->palPalEntry[i], cols[i]);\r
+    }\r
 \r
-       // create palette!\r
-       hPalette = CreatePalette(lp);\r
+    // create palette!\r
+    hPalette = CreatePalette(lp);\r
 \r
-       HeapFree(GetProcessHeap(), 0, lp);\r
+    HeapFree(GetProcessHeap(), 0, lp);\r
 \r
-       return hPalette;\r
+    return hPalette;\r
 }\r
index 6c7ff8d..bfdfcf9 100644 (file)
@@ -1,8 +1,8 @@
 //\r
-//     CardLib - CardButton class\r
+//    CardLib - CardButton class\r
 //\r
-//     Freeware\r
-//     Copyright J Brown 2001\r
+//    Freeware\r
+//    Copyright J Brown 2001\r
 //\r
 #include <windows.h>\r
 #include <tchar.h>\r
 #include "cardcolor.h"\r
 \r
 HPALETTE UseNicePalette(HDC, HPALETTE);\r
-void    RestorePalette(HDC, HPALETTE);\r
+void     RestorePalette(HDC, HPALETTE);\r
 \r
 void PaintRect(HDC hdc, RECT *rect, COLORREF colour);\r
 \r
 CardButton::CardButton(CardWindow &parent, int Id, TCHAR *szText, UINT Style, bool visible,\r
-                                               int x, int y, int width, int height)\r
+                        int x, int y, int width, int height)\r
 \r
  : parentWnd(parent), id(Id), uStyle(Style), fVisible(visible), ButtonCallback(0)\r
 {\r
-       crText = RGB(255,255,255);\r
-       crBack = RGB(0, 128, 0);\r
-       \r
-       xadjust = 0;\r
-       yadjust = 0;\r
-       xjustify = 0;\r
-       yjustify = 0;\r
+    crText = RGB(255,255,255);\r
+    crBack = RGB(0, 128, 0);\r
+    \r
+    xadjust = 0;\r
+    yadjust = 0;\r
+    xjustify = 0;\r
+    yjustify = 0;\r
 \r
-       fMouseDown = false;\r
-       fButtonDown = false;\r
+    fMouseDown = false;\r
+    fButtonDown = false;\r
 \r
-       hIcon = 0;\r
+    hIcon = 0;\r
 \r
-       SetText(szText);\r
-       Move(x, y, width, height);\r
+    SetText(szText);\r
+    Move(x, y, width, height);\r
 \r
-       mxlock = CreateMutex(0, FALSE, 0);\r
+    mxlock = CreateMutex(0, FALSE, 0);\r
 \r
-       hFont = 0;\r
+    hFont = 0;\r
 }\r
 \r
 CardButton::~CardButton()\r
 {\r
-       CloseHandle(mxlock);\r
+    CloseHandle(mxlock);\r
 }\r
 \r
 void CardButton::DrawRect(HDC hdc, RECT *rect, bool fNormal)\r
 {\r
-       RECT fill;\r
-\r
-       HANDLE hOld;\r
-\r
-       HPEN hhi = CreatePen(0, 0, MAKE_PALETTERGB(crHighlight));\r
-       HPEN hsh = CreatePen(0, 0, MAKE_PALETTERGB(crShadow));\r
-       HPEN hbl = (HPEN)GetStockObject(BLACK_PEN);\r
-       \r
-       int x           = rect->left;\r
-       int y           = rect->top;\r
-       int width       = rect->right-rect->left - 1;\r
-       int height      = rect->bottom-rect->top - 1;\r
-       \r
-       SetRect(&fill, x+1, y+1, x+width-1, y+height-1);\r
-\r
-       int one = 1;\r
-       \r
-       if(!fNormal)\r
-       {\r
-               x += width;\r
-               y += height;\r
-               width = -width;\r
-               height = -height;\r
-               one = -1;\r
-               OffsetRect(&fill, 1, 1);\r
-       }\r
-       \r
-       if(fNormal)\r
-               hOld = SelectObject(hdc, hhi);\r
-       else\r
-               hOld = SelectObject(hdc, hhi);\r
-\r
-       MoveToEx(hdc, x, y+height, 0);\r
-       LineTo(hdc, x, y);\r
-       LineTo(hdc, x+width, y);\r
-       SelectObject(hdc, hOld);\r
-\r
-       hOld = SelectObject(hdc, hbl);\r
-       LineTo(hdc, x+width, y+height);\r
-       LineTo(hdc, x-one, y+height);\r
-       SelectObject(hdc, hOld);\r
-\r
-       hOld = SelectObject(hdc, hsh);\r
-       MoveToEx(hdc, x+one, y+height-one, 0);\r
-       LineTo(hdc, x+width-one, y+height-one);\r
-       LineTo(hdc, x+width-one, y);\r
-       SelectObject(hdc, hOld);\r
-\r
-       PaintRect(hdc, &fill, MAKE_PALETTERGB(crBack));\r
-\r
-       DeleteObject(hhi);\r
-       DeleteObject(hsh);\r
+    RECT fill;\r
+\r
+    HANDLE hOld;\r
+\r
+    HPEN hhi = CreatePen(0, 0, MAKE_PALETTERGB(crHighlight));\r
+    HPEN hsh = CreatePen(0, 0, MAKE_PALETTERGB(crShadow));\r
+    HPEN hbl = (HPEN)GetStockObject(BLACK_PEN);\r
+    \r
+    int x        = rect->left;\r
+    int y        = rect->top;\r
+    int width    = rect->right-rect->left - 1;\r
+    int height    = rect->bottom-rect->top - 1;\r
+    \r
+    SetRect(&fill, x+1, y+1, x+width-1, y+height-1);\r
+\r
+    int one = 1;\r
+    \r
+    if(!fNormal)\r
+    {\r
+        x += width;\r
+        y += height;\r
+        width = -width;\r
+        height = -height;\r
+        one = -1;\r
+        OffsetRect(&fill, 1, 1);\r
+    }\r
+    \r
+    if(fNormal)\r
+        hOld = SelectObject(hdc, hhi);\r
+    else\r
+        hOld = SelectObject(hdc, hhi);\r
+\r
+    MoveToEx(hdc, x, y+height, 0);\r
+    LineTo(hdc, x, y);\r
+    LineTo(hdc, x+width, y);\r
+    SelectObject(hdc, hOld);\r
+\r
+    hOld = SelectObject(hdc, hbl);\r
+    LineTo(hdc, x+width, y+height);\r
+    LineTo(hdc, x-one, y+height);\r
+    SelectObject(hdc, hOld);\r
+\r
+    hOld = SelectObject(hdc, hsh);\r
+    MoveToEx(hdc, x+one, y+height-one, 0);\r
+    LineTo(hdc, x+width-one, y+height-one);\r
+    LineTo(hdc, x+width-one, y);\r
+    SelectObject(hdc, hOld);\r
+\r
+    PaintRect(hdc, &fill, MAKE_PALETTERGB(crBack));\r
+\r
+    DeleteObject(hhi);\r
+    DeleteObject(hsh);\r
 }\r
 \r
 void CardButton::Clip(HDC hdc)\r
 {\r
-       if(fVisible == false) return;\r
-       \r
-       ExcludeClipRect(hdc, rect.left,  rect.top, rect.right, rect.bottom);\r
+    if(fVisible == false) return;\r
+    \r
+    ExcludeClipRect(hdc, rect.left,  rect.top, rect.right, rect.bottom);\r
 }\r
 \r
 void CardButton::Draw(HDC hdc, bool fNormal)\r
 {\r
-       SIZE textsize;\r
-       int x, y;               //text x, y\r
-       int ix, iy;             //icon x, y\r
-       int iconwidth = 0;\r
-\r
-       RECT cliprect;\r
-\r
-       if(fVisible == 0) return;\r
-\r
-       if(hFont == 0)\r
-               SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));    \r
-       else\r
-               SelectObject(hdc, hFont);       \r
-       \r
-       GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textsize);\r
-       \r
-       if(hIcon)\r
-       {\r
-               x = rect.left + 32 + 8;\r
-       }\r
-       else\r
-       {\r
-               if(uStyle & CB_ALIGN_LEFT)\r
-               {\r
-                       x = rect.left + iconwidth;\r
-               }\r
-               else if(uStyle & CB_ALIGN_RIGHT)\r
-               {\r
-                       x = rect.left + (rect.right-rect.left-iconwidth-textsize.cx);\r
-               }\r
-               else    //centered\r
-               {\r
-                       x = rect.right - rect.left - iconwidth;\r
-                       x = (x - textsize.cx) / 2;\r
-                       x += rect.left + iconwidth;\r
-               }\r
-       }\r
-       \r
-       y = rect.bottom - rect.top;\r
-       y = (y - textsize.cy) / 2;\r
-       y += rect.top;\r
-       \r
-       //calc icon position..\r
-       ix = rect.left + 4;\r
-       iy = rect.top + (rect.bottom-rect.top-32) / 2;\r
-\r
-       //if button is pressed, then shift text\r
-       if(fNormal == false && (uStyle & CB_PUSHBUTTON))\r
-       {\r
-               x += 1;\r
-               y += 1;\r
-               ix += 1;\r
-               iy += 1;\r
-       }\r
-\r
-       SetRect(&cliprect, x, y, x+textsize.cx, y+textsize.cy);\r
-       ExcludeClipRect(hdc, x, y, x+textsize.cx, y+textsize.cy);\r
-\r
-       //\r
-       //      Calc icon pos\r
-       //\r
-       \r
-       if(hIcon)\r
-       {\r
-               ExcludeClipRect(hdc, ix, iy, ix + 32, iy + 32);\r
-       }\r
-       \r
-       if(uStyle & CB_PUSHBUTTON)\r
-       {\r
-               DrawRect(hdc, &rect, fNormal);\r
-\r
-               SetBkColor(hdc,   MAKE_PALETTERGB(crBack));\r
-               SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));\r
-               \r
-               SelectClipRgn(hdc, 0);          \r
-\r
-               ExtTextOut(hdc, x, y, ETO_OPAQUE, &cliprect, szText, lstrlen(szText), 0);\r
-       }\r
-       else\r
-       {\r
-               SetBkColor(hdc,   MAKE_PALETTERGB(crBack));\r
-               SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));\r
-\r
-               SelectClipRgn(hdc, 0);\r
-\r
-               ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0);\r
-       }\r
-\r
-       if(hIcon)\r
-       {\r
-               HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBack));\r
-               DrawIconEx(hdc, ix, iy, hIcon, 32, 32, 0, hbr, 0);\r
-               DeleteObject(hbr);\r
-       }\r
+    SIZE textsize;\r
+    int x, y;        //text x, y\r
+    int ix, iy;        //icon x, y\r
+    int iconwidth = 0;\r
+\r
+    RECT cliprect;\r
+\r
+    if(fVisible == 0) return;\r
+\r
+    if(hFont == 0)\r
+        SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));    \r
+    else\r
+        SelectObject(hdc, hFont);    \r
+    \r
+    GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textsize);\r
+    \r
+    if(hIcon)\r
+    {\r
+        x = rect.left + 32 + 8;\r
+    }\r
+    else\r
+    {\r
+        if(uStyle & CB_ALIGN_LEFT)\r
+        {\r
+            x = rect.left + iconwidth;\r
+        }\r
+        else if(uStyle & CB_ALIGN_RIGHT)\r
+        {\r
+            x = rect.left + (rect.right-rect.left-iconwidth-textsize.cx);\r
+        }\r
+        else    //centered\r
+        {\r
+            x = rect.right - rect.left - iconwidth;\r
+            x = (x - textsize.cx) / 2;\r
+            x += rect.left + iconwidth;\r
+        }\r
+    }\r
+    \r
+    y = rect.bottom - rect.top;\r
+    y = (y - textsize.cy) / 2;\r
+    y += rect.top;\r
+    \r
+    //calc icon position..\r
+    ix = rect.left + 4;\r
+    iy = rect.top + (rect.bottom-rect.top-32) / 2;\r
+\r
+    //if button is pressed, then shift text\r
+    if(fNormal == false && (uStyle & CB_PUSHBUTTON))\r
+    {\r
+        x += 1;\r
+        y += 1;\r
+        ix += 1;\r
+        iy += 1;\r
+    }\r
+\r
+    SetRect(&cliprect, x, y, x+textsize.cx, y+textsize.cy);\r
+    ExcludeClipRect(hdc, x, y, x+textsize.cx, y+textsize.cy);\r
+\r
+    //\r
+    //    Calc icon pos\r
+    //\r
+    \r
+    if(hIcon)\r
+    {\r
+        ExcludeClipRect(hdc, ix, iy, ix + 32, iy + 32);\r
+    }\r
+    \r
+    if(uStyle & CB_PUSHBUTTON)\r
+    {\r
+        DrawRect(hdc, &rect, fNormal);\r
+\r
+        SetBkColor(hdc,   MAKE_PALETTERGB(crBack));\r
+        SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));\r
+        \r
+        SelectClipRgn(hdc, 0);        \r
+\r
+        ExtTextOut(hdc, x, y, ETO_OPAQUE, &cliprect, szText, lstrlen(szText), 0);\r
+    }\r
+    else\r
+    {\r
+        SetBkColor(hdc,      MAKE_PALETTERGB(crBack));\r
+        SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));\r
+\r
+        SelectClipRgn(hdc, 0);\r
+\r
+        ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0);\r
+    }\r
+\r
+    if(hIcon)\r
+    {\r
+        HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBack));\r
+        DrawIconEx(hdc, ix, iy, hIcon, 32, 32, 0, hbr, 0);\r
+        DeleteObject(hbr);\r
+    }\r
 \r
 }\r
 \r
 void CardButton::AdjustPosition(int winwidth, int winheight)\r
 {\r
-       int width = rect.right-rect.left;\r
-       int height = rect.bottom-rect.top;\r
-\r
-       width = width & ~0x1;\r
-\r
-       switch(xjustify)\r
-       {\r
-       case CS_XJUST_NONE:\r
-               break;\r
-\r
-       case CS_XJUST_CENTER:           //centered\r
-               rect.left = (winwidth - (width)) / 2;\r
-               rect.left += xadjust;\r
-               rect.right = rect.left+width;\r
-               break;\r
-\r
-       case CS_XJUST_RIGHT:            //right-aligned\r
-               rect.left = winwidth - width;\r
-               rect.left += xadjust;\r
-               rect.right = rect.left+width;\r
-               break;\r
-       }\r
-\r
-       switch(yjustify)\r
-       {\r
-       case CS_YJUST_NONE:\r
-               break;\r
-\r
-       case CS_YJUST_CENTER:           //centered\r
-               rect.top = (winheight - (height)) / 2;\r
-               rect.top += yadjust;\r
-               rect.bottom = rect.top+height;\r
-               break;\r
-\r
-       case CS_YJUST_BOTTOM:           //right-aligned\r
-               rect.top = winheight - height;\r
-               rect.top += yadjust;\r
-               rect.bottom = rect.top+height;\r
-               break;\r
-       }\r
+    int width = rect.right-rect.left;\r
+    int height = rect.bottom-rect.top;\r
+\r
+    width = width & ~0x1;\r
+\r
+    switch(xjustify)\r
+    {\r
+    case CS_XJUST_NONE:\r
+        break;\r
+\r
+    case CS_XJUST_CENTER:        //centered\r
+        rect.left = (winwidth - (width)) / 2;\r
+        rect.left += xadjust;\r
+        rect.right = rect.left+width;\r
+        break;\r
+\r
+    case CS_XJUST_RIGHT:        //right-aligned\r
+        rect.left = winwidth - width;\r
+        rect.left += xadjust;\r
+        rect.right = rect.left+width;\r
+        break;\r
+    }\r
+\r
+    switch(yjustify)\r
+    {\r
+    case CS_YJUST_NONE:\r
+        break;\r
+\r
+    case CS_YJUST_CENTER:        //centered\r
+        rect.top = (winheight - (height)) / 2;\r
+        rect.top += yadjust;\r
+        rect.bottom = rect.top+height;\r
+        break;\r
+\r
+    case CS_YJUST_BOTTOM:        //right-aligned\r
+        rect.top = winheight - height;\r
+        rect.top += yadjust;\r
+        rect.bottom = rect.top+height;\r
+        break;\r
+    }\r
 \r
 }\r
 \r
 int CardButton::OnLButtonDown(HWND hwnd, int x, int y)\r
 {\r
-       if((uStyle & CB_PUSHBUTTON) == 0) \r
-               return 0;\r
-\r
-       //make sure that the user is allowed to do something\r
-       if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)\r
-       {\r
-               return 0;\r
-       }\r
-       else\r
-       {\r
-               ReleaseMutex(mxlock);\r
-       }\r
-       \r
-       fMouseDown = true;\r
-       fButtonDown = true;\r
-\r
-       Redraw();\r
-\r
-       SetCapture(hwnd);\r
-\r
-       return 1;\r
+    if((uStyle & CB_PUSHBUTTON) == 0) \r
+        return 0;\r
+\r
+    //make sure that the user is allowed to do something\r
+    if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)\r
+    {\r
+        return 0;\r
+    }\r
+    else\r
+    {\r
+        ReleaseMutex(mxlock);\r
+    }\r
+    \r
+    fMouseDown = true;\r
+    fButtonDown = true;\r
+\r
+    Redraw();\r
+\r
+    SetCapture(hwnd);\r
+\r
+    return 1;\r
 }\r
 \r
 int CardButton::OnMouseMove(HWND hwnd, int x, int y)\r
 {\r
-       if(fMouseDown)\r
-       {\r
-               bool fOldButtonDown = fButtonDown;\r
-\r
-               POINT pt;\r
-               \r
-               pt.x = x;\r
-               pt.y = y;\r
-               \r
-               if(PtInRect(&rect, pt))\r
-                       fButtonDown = true;\r
-               else\r
-                       fButtonDown = false;\r
-               \r
-               if(fButtonDown != fOldButtonDown)\r
-                       Redraw();\r
-       }\r
-       \r
-       return 0;\r
+    if(fMouseDown)\r
+    {\r
+        bool fOldButtonDown = fButtonDown;\r
+\r
+        POINT pt;\r
+        \r
+        pt.x = x;\r
+        pt.y = y;\r
+        \r
+        if(PtInRect(&rect, pt))\r
+            fButtonDown = true;\r
+        else\r
+            fButtonDown = false;\r
+        \r
+        if(fButtonDown != fOldButtonDown)\r
+            Redraw();\r
+    }\r
+    \r
+    return 0;\r
 }\r
 \r
 int CardButton::OnLButtonUp(HWND hwnd, int x, int y)\r
 {\r
-       if(fMouseDown)\r
-       {\r
-               fMouseDown = false;\r
-               fButtonDown = false;\r
-               \r
-               if(uStyle & CB_PUSHBUTTON)\r
-               {\r
-                       Redraw();\r
-                       ReleaseCapture();\r
-               }\r
-               \r
-               //if have clicked the button\r
-               if(parentWnd.CardButtonFromPoint(x, y) == this)\r
-               {\r
-                       if(ButtonCallback)\r
-                       {\r
-                               ButtonCallback(*this);  \r
-                       }\r
-                       else\r
-                       {\r
-                               HWND hwnd = (HWND)parentWnd;\r
-                               SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(id, BN_CLICKED), (LONG)hwnd);\r
-                       }\r
-               }\r
-       }\r
-\r
-       return 0;\r
+    if(fMouseDown)\r
+    {\r
+        fMouseDown = false;\r
+        fButtonDown = false;\r
+        \r
+        if(uStyle & CB_PUSHBUTTON)\r
+        {\r
+            Redraw();\r
+            ReleaseCapture();\r
+        }\r
+        \r
+        //if have clicked the button\r
+        if(parentWnd.CardButtonFromPoint(x, y) == this)\r
+        {\r
+            if(ButtonCallback)\r
+            {\r
+                ButtonCallback(*this);    \r
+            }\r
+            else\r
+            {\r
+                HWND hwnd = (HWND)parentWnd;\r
+                SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(id, BN_CLICKED), (LONG)hwnd);\r
+            }\r
+        }\r
+    }\r
+\r
+    return 0;\r
 }\r
 \r
 #define _countof(array) (sizeof(array)/sizeof(array[0]))\r
 \r
 CardButton *CardWindow::CreateButton(int id, TCHAR *szText, UINT uStyle, bool fVisible, int x, int y, int width, int height)\r
 {\r
-       CardButton *cb;\r
-\r
-       if(nNumButtons == MAXBUTTONS) \r
-               return 0;\r
-\r
-       cb = new CardButton(*this, id, szText, uStyle, fVisible, x, y, width, height);\r
-       Buttons[nNumButtons++] = cb;\r
-\r
-       if(uStyle & CB_PUSHBUTTON)\r
-       {\r
-               cb->SetBackColor(CardButton::GetFace(crBackgnd));\r
-               //cb->SetBackColor(ScaleLumRGB(crBackgnd, 0.1));\r
-               cb->SetForeColor(RGB(255,255,255));\r
-       }\r
-       else\r
-       {\r
-               cb->SetBackColor(crBackgnd);\r
-               cb->SetForeColor(RGB(255,255,255));\r
-       }\r
-       \r
-       return cb;\r
+    CardButton *cb;\r
+\r
+    if(nNumButtons == MAXBUTTONS) \r
+        return 0;\r
+\r
+    cb = new CardButton(*this, id, szText, uStyle, fVisible, x, y, width, height);\r
+    Buttons[nNumButtons++] = cb;\r
+\r
+    if(uStyle & CB_PUSHBUTTON)\r
+    {\r
+        cb->SetBackColor(CardButton::GetFace(crBackgnd));\r
+        //cb->SetBackColor(ScaleLumRGB(crBackgnd, 0.1));\r
+        cb->SetForeColor(RGB(255,255,255));\r
+    }\r
+    else\r
+    {\r
+        cb->SetBackColor(crBackgnd);\r
+        cb->SetForeColor(RGB(255,255,255));\r
+    }\r
+    \r
+    return cb;\r
 }\r
 \r
 void CardButton::SetText(TCHAR *lpszFormat, ...)\r
 {\r
-       int count;\r
+    int count;\r
 \r
-       va_list args;\r
-       va_start(args, lpszFormat);\r
+    va_list args;\r
+    va_start(args, lpszFormat);\r
 \r
-       count = wvsprintf(szText, lpszFormat, args);\r
-       va_end(args);\r
+    count = wvsprintf(szText, lpszFormat, args);\r
+    va_end(args);\r
 }\r
 \r
 int CardButton::Id()\r
 {\r
-       return id;\r
+    return id;\r
 }\r
 \r
 void CardButton::Show(bool fShow)\r
 {\r
-       fVisible = fShow;\r
+    fVisible = fShow;\r
 }\r
 \r
 void CardButton::Move(int x, int y, int width, int height)\r
 {\r
-       SetRect(&rect, x, y, x+width, y+height);\r
+    SetRect(&rect, x, y, x+width, y+height);\r
 }\r
 \r
 void CardButton::Redraw()\r
 {\r
-       HDC hdc = GetDC((HWND)parentWnd);\r
+    HDC hdc = GetDC((HWND)parentWnd);\r
 \r
-       HPALETTE hOldPal = UseNicePalette(hdc, __hPalette);\r
+    HPALETTE hOldPal = UseNicePalette(hdc, __hPalette);\r
 \r
-       Draw(hdc, !fButtonDown);\r
-       \r
-       RestorePalette(hdc, hOldPal);\r
-       \r
-       ReleaseDC((HWND)parentWnd, hdc);\r
+    Draw(hdc, !fButtonDown);\r
+    \r
+    RestorePalette(hdc, hOldPal);\r
+    \r
+    ReleaseDC((HWND)parentWnd, hdc);\r
 }\r
 \r
 void CardButton::SetForeColor(COLORREF cr)\r
 {\r
-       crText = cr;\r
+    crText = cr;\r
 }\r
 \r
 void CardButton::SetBackColor(COLORREF cr)\r
 {\r
-       crBack = cr;\r
+    crBack = cr;\r
 \r
-       crHighlight = GetHighlight(cr);\r
-       crShadow    = GetShadow(cr);\r
-       \r
-       //crHighlight = ScaleLumRGB(cr, +0.25);\r
-       //crShadow    = ScaleLumRGB(cr, -0.25);\r
+    crHighlight = GetHighlight(cr);\r
+    crShadow    = GetShadow(cr);\r
+    \r
+    //crHighlight = ScaleLumRGB(cr, +0.25);\r
+    //crShadow    = ScaleLumRGB(cr, -0.25);\r
 }\r
 \r
-//     Static member\r
+//    Static member\r
 COLORREF CardButton::GetHighlight(COLORREF crBase)\r
 {\r
-       return ColorScaleRGB(crBase, RGB(255,255,255), 0.25);\r
+    return ColorScaleRGB(crBase, RGB(255,255,255), 0.25);\r
 }\r
 \r
-//     Static member\r
+//    Static member\r
 COLORREF CardButton::GetShadow(COLORREF crBase)\r
 {\r
-       return ColorScaleRGB(crBase, RGB(0,  0,  0),   0.25);\r
+    return ColorScaleRGB(crBase, RGB(0,  0,  0),   0.25);\r
 }\r
 \r
 COLORREF CardButton::GetFace(COLORREF crBase)\r
 {\r
-       return ColorScaleRGB(crBase, RGB(255,255,255), 0.1);\r
+    return ColorScaleRGB(crBase, RGB(255,255,255), 0.1);\r
 }\r
 \r
 void CardButton::SetPlacement(UINT xJustify, UINT yJustify, int xAdjust, int yAdjust)\r
 {\r
-       xadjust = xAdjust;\r
-       yadjust = yAdjust;\r
-       xjustify = xJustify;\r
-       yjustify = yJustify;\r
+    xadjust = xAdjust;\r
+    yadjust = yAdjust;\r
+    xjustify = xJustify;\r
+    yjustify = yJustify;\r
 }\r
 \r
 void CardButton::SetIcon(HICON hicon, bool fRedraw)\r
 {\r
-       hIcon = hicon;\r
-       \r
-       if(fRedraw)\r
-               Redraw();\r
+    hIcon = hicon;\r
+    \r
+    if(fRedraw)\r
+        Redraw();\r
 }\r
 \r
 void CardButton::SetFont(HFONT font)\r
 {\r
-       //don't delete the existing font..\r
-       hFont = font;\r
+    //don't delete the existing font..\r
+    hFont = font;\r
 }\r
 \r
 void CardButton::SetButtonProc(pButtonProc proc)\r
 {\r
-       ButtonCallback  = proc;\r
+    ButtonCallback    = proc;\r
 }\r
 \r
 bool CardButton::Lock()\r
 {\r
-       DWORD dw = WaitForSingleObject(mxlock, 0);\r
+    DWORD dw = WaitForSingleObject(mxlock, 0);\r
 \r
-       if(dw == WAIT_OBJECT_0)\r
-               return true; \r
-       else\r
-               return false;\r
+    if(dw == WAIT_OBJECT_0)\r
+        return true; \r
+    else\r
+        return false;\r
 }\r
 \r
 bool CardButton::UnLock()\r
 {\r
-       if(ReleaseMutex(mxlock))\r
-               return true;\r
-       else\r
-               return false;\r
+    if(ReleaseMutex(mxlock))\r
+        return true;\r
+    else\r
+        return false;\r
 }\r
 \r
 void CardButton::SetStyle(UINT style)\r
 {\r
-       uStyle = style;\r
+    uStyle = style;\r
 }\r
 \r
 UINT CardButton::GetStyle()\r
 {\r
-       return uStyle;\r
+    return uStyle;\r
 }\r
index 6d0e008..1d3348a 100644 (file)
@@ -1,5 +1,5 @@
 //\r
-//     Colour support\r
+//    Colour support\r
 //\r
 #include <windows.h>\r
 \r
 \r
 inline double fMax(double a, double b)\r
 {\r
-       return a < b ? b : a;\r
+    return a < b ? b : a;\r
 }\r
 \r
 inline double fMin(double a, double b)\r
 {\r
-       return a < b ? a : b;\r
+    return a < b ? a : b;\r
 }\r
 /******************************************************************************\r
   FUNCTION: RGBtoHLS\r
-  PURPOSE:     Convert from RGB to HLS\r
+  PURPOSE:     Convert from RGB to HLS\r
   IN: RGB color (0xBBGGRR)\r
   OUT: Hue, Saturation, Luminance from 0 to 1\r
   COPYRIGHT:1995-1997 Robert Mashlan\r
@@ -27,175 +27,175 @@ inline double fMin(double a, double b)
 ******************************************************************************/\r
 void RGBtoHLS(const COLORREF rgb, double *H, double *L, double *S ) \r
 {\r
-       double delta;\r
-       double r = (double)((rgb    )&0xFF)/255;\r
-       double g = (double)((rgb>> 8)&0xFF)/255;\r
-       double b = (double)((rgb>>16)&0xFF)/255;\r
-       double cmax = MAX3(r,g,b);\r
-       double cmin = MIN3(r,g,b);\r
-       *L=(cmax+cmin)/2.0;\r
-       \r
-       if(cmax == cmin) \r
-       {\r
-               *S = *H = 0; // it's really undefined\r
-       }\r
-       else \r
-       {\r
-               if(*L < 0.5)    *S = (cmax-cmin)/(cmax+cmin);\r
-               else                    *S = (cmax-cmin)/(2.0-cmax-cmin);\r
-               \r
-               delta = cmax - cmin;\r
-               \r
-               if(r == cmax) \r
-               {\r
-                       *H = (g - b) / delta;\r
-               }\r
-               else\r
-               {\r
-                       if(g == cmax) *H = 2.0 + (b-r) / delta;\r
-                       else          *H = 4.0 + (r-g) / delta;\r
-               }\r
-               *H /= 6.0;\r
-               if (*H < 0.0) *H += 1;\r
-       }\r
+    double delta;\r
+    double r = (double)((rgb    )&0xFF)/255;\r
+    double g = (double)((rgb>> 8)&0xFF)/255;\r
+    double b = (double)((rgb>>16)&0xFF)/255;\r
+    double cmax = MAX3(r,g,b);\r
+    double cmin = MIN3(r,g,b);\r
+    *L=(cmax+cmin)/2.0;\r
+    \r
+    if(cmax == cmin) \r
+    {\r
+        *S = *H = 0; // it's really undefined\r
+    }\r
+    else \r
+    {\r
+        if(*L < 0.5)    *S = (cmax-cmin)/(cmax+cmin);\r
+        else            *S = (cmax-cmin)/(2.0-cmax-cmin);\r
+        \r
+        delta = cmax - cmin;\r
+        \r
+        if(r == cmax) \r
+        {\r
+            *H = (g - b) / delta;\r
+        }\r
+        else\r
+        {\r
+            if(g == cmax) *H = 2.0 + (b-r) / delta;\r
+              else          *H = 4.0 + (r-g) / delta;\r
+        }\r
+          *H /= 6.0;\r
+          if (*H < 0.0) *H += 1;\r
+    }\r
 }\r
 \r
 /******************************************************************************\r
   FUNCTION: HueToRGB\r
-  PURPOSE:     Convert a hue (color) to RGB\r
+  PURPOSE:     Convert a hue (color) to RGB\r
   COPYRIGHT:1995-1997 Robert Mashlan\r
             Modified for LabWindows/CVI, 1999 Guillaume Dargaud\r
 ******************************************************************************/\r
 double HueToRGB(const double m1, const double m2, double h ) \r
 {\r
-       if (h<0) h+=1.0;\r
-       if (h>1) h-=1.0;\r
-       if (6.0*h < 1  ) return (m1+(m2-m1)*h*6.0);\r
-       if (2.0*h < 1  ) return m2;\r
-       if (3.0*h < 2.0) return (m1+(m2-m1)*((2.0/3.0)-h)*6.0);\r
-       return m1;\r
+    if (h<0) h+=1.0;\r
+    if (h>1) h-=1.0;\r
+    if (6.0*h < 1  ) return (m1+(m2-m1)*h*6.0);\r
+    if (2.0*h < 1  ) return m2;\r
+    if (3.0*h < 2.0) return (m1+(m2-m1)*((2.0/3.0)-h)*6.0);\r
+    return m1;\r
 }\r
 \r
 \r
 /******************************************************************************\r
   FUNCTION: HLStoRGB\r
-  PURPOSE:     Convert from HSL to RGB\r
-  IN:          Hue, Saturation, Luminance from 0 to 1\r
-  RETURN:      RGB color (0xBBGGRR)\r
+  PURPOSE:     Convert from HSL to RGB\r
+  IN:         Hue, Saturation, Luminance from 0 to 1\r
+  RETURN:     RGB color (0xBBGGRR)\r
   COPYRIGHT:1995-1997 Robert Mashlan\r
             Modified for LabWindows/CVI, 1999 Guillaume Dargaud\r
 ******************************************************************************/\r
 \r
 COLORREF HLStoRGB(const double H, const double L, const double S ) \r
 {\r
-       double r,g,b;\r
-       double m1, m2;\r
-\r
-       if(S == 0) \r
-       {\r
-               r = g = b = L;\r
-       }\r
-       else \r
-       {\r
-               if (L <= 0.5) \r
-                       m2 = L * (1.0 + S);\r
-               else         \r
-                       m2 = L + S - L * S;\r
-\r
-               m1 = 2.0 * L - m2;\r
-\r
-               r = HueToRGB(m1,m2,H+1.0/3.0);\r
-               g = HueToRGB(m1,m2,H);\r
-               b = HueToRGB(m1,m2,H-1.0/3.0);\r
-       }\r
+    double r,g,b;\r
+    double m1, m2;\r
+\r
+    if(S == 0) \r
+    {\r
+        r = g = b = L;\r
+    }\r
+    else \r
+    {\r
+        if (L <= 0.5) \r
+            m2 = L * (1.0 + S);\r
+        else         \r
+            m2 = L + S - L * S;\r
+\r
+        m1 = 2.0 * L - m2;\r
+\r
+        r = HueToRGB(m1,m2,H+1.0/3.0);\r
+        g = HueToRGB(m1,m2,H);\r
+        b = HueToRGB(m1,m2,H-1.0/3.0);\r
+    }\r
   \r
-       return RGB(r*255, g*255, b*255);\r
+    return RGB(r*255, g*255, b*255);\r
 }\r
 \r
 \r
 \r
 /******************************************************************************\r
   FUNCTION: ColorScaleHSL\r
-  PURPOSE:     Returns the HSL linear interpolated color between 2 colors\r
-                       (more natural looking than RGB interpolation)\r
-               For instance if the luminance is the same in Col1 and Col2, \r
-                       then the luminance of the result will be the same\r
-               If Ratio=0, you get Col1,\r
-                       If Ratio=1, you get Col2\r
+  PURPOSE:     Returns the HSL linear interpolated color between 2 colors\r
+            (more natural looking than RGB interpolation)\r
+               For instance if the luminance is the same in Col1 and Col2, \r
+                   then the luminance of the result will be the same\r
+               If Ratio=0, you get Col1,\r
+             If Ratio=1, you get Col2\r
   IN: Col1: low color in hex 0xBBGGRR format\r
-         Col2: high color in hex 0xBBGGRR format\r
-         Ratio: 0 for low color, 1 for high color, or in between\r
+        Col2: high color in hex 0xBBGGRR format\r
+        Ratio: 0 for low color, 1 for high color, or in between\r
   EXAMPLE: Col1=0, Col2=0xFF00FF, Ratio=0.5 returns 0x1F5F3F\r
 ******************************************************************************/\r
-COLORREF ColorScaleHSL(        const COLORREF Col1, const COLORREF Col2, const double Ratio) \r
+COLORREF ColorScaleHSL(    const COLORREF Col1, const COLORREF Col2, const double Ratio) \r
 {\r
-       static double H1, H2, S1, S2, L1, L2;\r
-       \r
-       if (Ratio<=0) return Col1;      // Ratio parameter must be between 0 and 1\r
-       else if (Ratio>=1) return Col2;\r
-\r
-       RGBtoHLS( Col1, &H1, &L1, &S1);\r
-       RGBtoHLS( Col2, &H2, &L2, &S2);\r
-       return HLStoRGB( H1+(H2-H1)*Ratio, L1+(L2-L1)*Ratio, S1+(S2-S1)*Ratio );\r
+    static double H1, H2, S1, S2, L1, L2;\r
+    \r
+    if (Ratio<=0) return Col1;    // Ratio parameter must be between 0 and 1\r
+    else if (Ratio>=1) return Col2;\r
+\r
+    RGBtoHLS( Col1, &H1, &L1, &S1);\r
+    RGBtoHLS( Col2, &H2, &L2, &S2);\r
+    return HLStoRGB( H1+(H2-H1)*Ratio, L1+(L2-L1)*Ratio, S1+(S2-S1)*Ratio );\r
 }\r
 \r
 \r
 /******************************************************************************\r
   FUNCTION: ColorScaleRGB\r
-  PURPOSE:     Returns the RGB linear interpolated color between 2 colors\r
-               If Ratio=0, you get Col1,\r
-                       If Ratio=1, you get Col2\r
+  PURPOSE:     Returns the RGB linear interpolated color between 2 colors\r
+               If Ratio=0, you get Col1,\r
+             If Ratio=1, you get Col2\r
   IN: Col1: low color in hex 0xBBGGRR format\r
-         Col2: high color in hex 0xBBGGRR format\r
-         Ratio: 0 for low color, 1 for high color, or in between\r
+        Col2: high color in hex 0xBBGGRR format\r
+        Ratio: 0 for low color, 1 for high color, or in between\r
   EXAMPLE: Col1=0, Col2=0xFF00FF, Ratio=0.5 returns 0x800080\r
 ******************************************************************************/\r
-COLORREF ColorScaleRGB(        const COLORREF Col1, \r
-                                               const COLORREF Col2, \r
-                                               const double Ratio) {\r
-       int R1=(Col1)&0xFF, G1=(Col1>>8)&0xFF, B1=(Col1>>16)&0xFF;\r
-       int R2=(Col2)&0xFF, G2=(Col2>>8)&0xFF, B2=(Col2>>16)&0xFF;\r
-\r
-       if (Ratio<=0) return Col1;      // Ratio parameter must be between 0 and 1\r
-       else if (Ratio>=1) return Col2;\r
-\r
-/*     return RGB(\r
-                      (R1 + (R2 - R1) * (Ratio + 0.02) + 0.5),         // rounding\r
-                          (G1 + (G2 - G1) * (Ratio - 0.00) + 0.5),\r
-                          (B1 + (B2 - B1) * (Ratio + 0.05) + 0.5)\r
-                          );*/\r
-\r
-       /*double r = Ratio;\r
-       if(Col2 == 0)\r
-               r = 1-Ratio;\r
-       else\r
-               r = 1+Ratio;\r
-       R1 = (int)(double(R1) * r + 0.5);\r
-       G1 = (int)(double(G1) * r + 0.5);\r
-       B1 = (int)(double(B1) * r + 0.5);\r
-       return RGB(R1,G1,B1);*/\r
-\r
-       return RGB(\r
-                          (R1 + (R2 - R1) * (Ratio + 0.02) + 0.5),             // rounding\r
-                          (G1 + (G2 - G1) * (Ratio - 0.00) + 0.5),\r
-                          (B1 + (B2 - B1) * (Ratio + 0.05) + 0.5)\r
-                          );\r
+COLORREF ColorScaleRGB(    const COLORREF Col1, \r
+                        const COLORREF Col2, \r
+                        const double Ratio) {\r
+    int R1=(Col1)&0xFF, G1=(Col1>>8)&0xFF, B1=(Col1>>16)&0xFF;\r
+    int R2=(Col2)&0xFF, G2=(Col2>>8)&0xFF, B2=(Col2>>16)&0xFF;\r
+\r
+    if (Ratio<=0) return Col1;    // Ratio parameter must be between 0 and 1\r
+    else if (Ratio>=1) return Col2;\r
+\r
+/*    return RGB(\r
+               (R1 + (R2 - R1) * (Ratio + 0.02) + 0.5),        // rounding\r
+               (G1 + (G2 - G1) * (Ratio - 0.00) + 0.5),\r
+               (B1 + (B2 - B1) * (Ratio + 0.05) + 0.5)\r
+               );*/\r
+\r
+    /*double r = Ratio;\r
+    if(Col2 == 0)\r
+        r = 1-Ratio;\r
+    else\r
+        r = 1+Ratio;\r
+    R1 = (int)(double(R1) * r + 0.5);\r
+    G1 = (int)(double(G1) * r + 0.5);\r
+    B1 = (int)(double(B1) * r + 0.5);\r
+    return RGB(R1,G1,B1);*/\r
+\r
+    return RGB(\r
+               (R1 + (R2 - R1) * (Ratio + 0.02) + 0.5),        // rounding\r
+               (G1 + (G2 - G1) * (Ratio - 0.00) + 0.5),\r
+               (B1 + (B2 - B1) * (Ratio + 0.05) + 0.5)\r
+               );\r
 }\r
 \r
 \r
 \r
 COLORREF ColorDarker(COLORREF col, double ratio)\r
 {\r
-       return ColorScaleHSL(col, RGB(0,0,0), ratio);\r
+    return ColorScaleHSL(col, RGB(0,0,0), ratio);\r
 }\r
 \r
 COLORREF ColorLighter(COLORREF col, double ratio)\r
 {\r
-       return ColorScaleHSL(col, RGB(255,255,255), ratio);\r
+    return ColorScaleHSL(col, RGB(255,255,255), ratio);\r
 }\r
 \r
 //\r
-//     Experimental!!!\r
+//    Experimental!!!\r
 //\r
 #if 0\r
 \r
@@ -203,135 +203,135 @@ typedef enum { Red, Green, Blue };
 \r
 void RGBtoHLS(COLORREF rgb, double *Hue, double *Lum, double *Sat)\r
 {\r
-       double mn, mx;\r
-       int major;\r
-\r
-       BYTE red, green, blue;\r
-\r
-       red    = GetRValue(rgb);\r
-       green  = GetGValue(rgb);\r
-       blue   = GetBValue(rgb);\r
-\r
-       if(red < green)\r
-       {\r
-               mn = red; mx = green; major = Green;\r
-       }\r
-       else\r
-       {\r
-               mn = green; mx = red; major = Red;\r
-       }\r
-\r
-       if(blue < mn)\r
-       {\r
-               mn = blue;\r
-       }\r
-       else if(blue > mx)\r
-       {\r
-               mx = blue; major = Blue;\r
-       }\r
-\r
-       if(mn == mx)\r
-       {\r
-               *Lum = mn / 255;\r
-               *Sat = 0;\r
-               *Hue = 0;\r
-       }\r
-       else\r
-       {\r
-               *Lum = (mx + mn) / 510;\r
-\r
-               if(*Lum <= 0.5)\r
-                       *Sat = (mx-mn) / (mn+mx);\r
-               else\r
-                       *Sat = (mx-mn) / (510-mn-mx);\r
-\r
-               switch(major)\r
-               {\r
-               case Red:   *Hue = (green-blue) * 60.0 / (mx-mn) + 360.0;\r
-                                   break;\r
-\r
-               case Green: *Hue = (blue-red) * 60.0 / (mx-mn) + 120.0;\r
-                               break;\r
-\r
-               case Blue:  *Hue = (red-green) * 60.0 / (mx-mn) + 240.0;\r
-                               break;\r
-\r
-               }\r
-\r
-               if(*Hue > 360.0)\r
-                       *Hue -= 360.0;\r
-       }\r
+    double mn, mx;\r
+    int major;\r
+\r
+    BYTE red, green, blue;\r
+\r
+    red    = GetRValue(rgb);\r
+    green  = GetGValue(rgb);\r
+    blue   = GetBValue(rgb);\r
+\r
+    if(red < green)\r
+    {\r
+        mn = red; mx = green; major = Green;\r
+    }\r
+    else\r
+    {\r
+        mn = green; mx = red; major = Red;\r
+    }\r
+\r
+    if(blue < mn)\r
+    {\r
+        mn = blue;\r
+    }\r
+    else if(blue > mx)\r
+    {\r
+        mx = blue; major = Blue;\r
+    }\r
+\r
+    if(mn == mx)\r
+    {\r
+        *Lum = mn / 255;\r
+        *Sat = 0;\r
+        *Hue = 0;\r
+    }\r
+    else\r
+    {\r
+        *Lum = (mx + mn) / 510;\r
+\r
+        if(*Lum <= 0.5)\r
+            *Sat = (mx-mn) / (mn+mx);\r
+        else\r
+            *Sat = (mx-mn) / (510-mn-mx);\r
+\r
+        switch(major)\r
+        {\r
+        case Red:   *Hue = (green-blue) * 60.0 / (mx-mn) + 360.0;\r
+                    break;\r
+\r
+        case Green: *Hue = (blue-red) * 60.0 / (mx-mn) + 120.0;\r
+                    break;\r
+\r
+        case Blue:  *Hue = (red-green) * 60.0 / (mx-mn) + 240.0;\r
+                    break;\r
+\r
+        }\r
+\r
+        if(*Hue > 360.0)\r
+            *Hue -= 360.0;\r
+    }\r
 }\r
 \r
 static BYTE Value(double m1, double m2, double hue)\r
 {\r
 \r
-       if(hue > 360)           hue -= 360;\r
-       else if(hue < 0)        hue += 360;\r
+    if(hue > 360)        hue -= 360;\r
+    else if(hue < 0)    hue += 360;\r
 \r
-       if(hue < 60)\r
-               m1 = m1 + (m2 - m1) * hue / 60;\r
-       else if(hue < 180)\r
-               m1 = m2;\r
-       else if(hue < 240)\r
-               m1 = m1 + (m2 - m1) * (240 - hue) / 60;\r
+    if(hue < 60)\r
+        m1 = m1 + (m2 - m1) * hue / 60;\r
+    else if(hue < 180)\r
+        m1 = m2;\r
+    else if(hue < 240)\r
+        m1 = m1 + (m2 - m1) * (240 - hue) / 60;\r
 \r
-       return (BYTE)(m1 * 255);\r
+    return (BYTE)(m1 * 255);\r
 }\r
 \r
 COLORREF HLStoRGB(const double Hue, const double Lum, const double Sat)\r
 {\r
-       BYTE red, green, blue;\r
+    BYTE red, green, blue;\r
 \r
-       if(Sat == 0)\r
-       {\r
-               red = green = blue = (BYTE)(Lum * 255);         \r
-       }\r
-       else\r
-       {\r
-               double m1, m2;\r
+    if(Sat == 0)\r
+    {\r
+        red = green = blue = (BYTE)(Lum * 255);        \r
+    }\r
+    else\r
+    {\r
+        double m1, m2;\r
 \r
-               if(Lum <= 0.5)\r
-                       m2 = Lum + Lum * Sat;\r
-               else\r
-                       m2 = Lum + Sat - Lum * Sat;\r
+        if(Lum <= 0.5)\r
+            m2 = Lum + Lum * Sat;\r
+        else\r
+            m2 = Lum + Sat - Lum * Sat;\r
 \r
-               m1 = 2 * Lum - m2;\r
+        m1 = 2 * Lum - m2;\r
 \r
-               red   = Value(m1, m2, Hue + 120);\r
-               green = Value(m1, m2, Hue);\r
-               blue  = Value(m1, m2, Hue - 120);\r
-       }\r
+        red   = Value(m1, m2, Hue + 120);\r
+        green = Value(m1, m2, Hue);\r
+        blue  = Value(m1, m2, Hue - 120);\r
+    }\r
 \r
-       return RGB(red, green, blue);\r
+    return RGB(red, green, blue);\r
 }\r
 \r
 COLORREF ScaleLumRGB(COLORREF col1, double ratio)\r
 {\r
-       double H1, L1, S1;\r
+    double H1, L1, S1;\r
 \r
-       RGBtoHLS(col1, &H1, &L1, &S1);\r
+    RGBtoHLS(col1, &H1, &L1, &S1);\r
 \r
-       L1 += L1 * ratio;\r
+    L1 += L1 * ratio;\r
 \r
-       return HLStoRGB(H1, L1, S1);\r
+    return HLStoRGB(H1, L1, S1);\r
 }\r
 \r
 COLORREF ColorScaleHSL(const COLORREF Col1, const COLORREF Col2, const double Ratio) \r
 {\r
-       static double H1, H2, S1, S2, L1, L2;\r
-       \r
-       if(Ratio <= 0)          return Col1;    // Ratio parameter must be between 0 and 1\r
-       else if(Ratio >= 1)     return Col2;\r
+    static double H1, H2, S1, S2, L1, L2;\r
+    \r
+    if(Ratio <= 0)        return Col1;    // Ratio parameter must be between 0 and 1\r
+    else if(Ratio >= 1)    return Col2;\r
 \r
-       RGBtoHLS( Col1, &H1, &L1, &S1);\r
-       RGBtoHLS( Col2, &H2, &L2, &S2);\r
+    RGBtoHLS( Col1, &H1, &L1, &S1);\r
+    RGBtoHLS( Col2, &H2, &L2, &S2);\r
 \r
-       return HLStoRGB( H1 /*+ (H2 - H1 ) * Ratio*/, L1 + (L2 - L1) * Ratio, S1 + (S2 - S1) * Ratio * 2);\r
+    return HLStoRGB( H1 /*+ (H2 - H1 ) * Ratio*/, L1 + (L2 - L1) * Ratio, S1 + (S2 - S1) * Ratio * 2);\r
 }\r
 \r
 COLORREF ColorScaleRGB(const COLORREF Col1, const COLORREF Col2, const double Ratio)\r
 {\r
-       return ColorScaleHSL(Col1, Col2, Ratio);\r
+    return ColorScaleHSL(Col1, Col2, Ratio);\r
 }\r
 #endif\r
index d8ab036..7321858 100644 (file)
@@ -1,90 +1,90 @@
 //\r
-//     CardCount is a helper library for CardStacks.\r
-//     \r
-//     When you initialize a CardCount object with a \r
+//    CardCount is a helper library for CardStacks.\r
+//    \r
+//    When you initialize a CardCount object with a \r
 //  cardstack, it keeps track of the number of cards\r
-//     the stack contains.\r
+//    the stack contains.\r
 //\r
-//     e.g. CardCount count(cardstack);\r
+//    e.g. CardCount count(cardstack);\r
 //\r
-//     Then you can do:\r
-//     \r
-//             int num_fives = count[5]\r
-//             \r
-//             count.Add(cardstack2);          - combine with another stack\r
+//    Then you can do:\r
+//    \r
+//        int num_fives = count[5]\r
+//        \r
+//        count.Add(cardstack2);        - combine with another stack\r
 //\r
-//             int num_aces = count[1]         - aces low\r
-//             int num_aces = count[14]    - aces high\r
+//        int num_aces = count[1]        - aces low\r
+//        int num_aces = count[14]    - aces high\r
 //\r
-//             count.Clear();\r
+//        count.Clear();\r
 //\r
 #include "cardcount.h"\r
 \r
 CardCount::CardCount()\r
 {\r
-       Clear();\r
+    Clear();\r
 }\r
 \r
 CardCount::CardCount(const CardStack &cs)\r
 {\r
-       Init(cs);\r
+    Init(cs);\r
 }\r
 \r
 void CardCount::Clear()\r
 {\r
-       for(int i = 0; i < 13; i++)\r
-               count[i] = 0;\r
+    for(int i = 0; i < 13; i++)\r
+        count[i] = 0;\r
 }\r
 \r
 void CardCount::Add(const CardStack &cs)\r
 {\r
-       for(int i = 0; i < cs.NumCards(); i++)\r
-       {\r
-               Card card = cs[i];\r
+    for(int i = 0; i < cs.NumCards(); i++)\r
+    {\r
+        Card card = cs[i];\r
 \r
-               int val = card.LoVal();\r
-               count[val - 1]++;\r
-       }\r
+        int val = card.LoVal();\r
+        count[val - 1]++;\r
+    }\r
 }\r
 \r
 void CardCount::Sub(const CardStack &cs)\r
 {\r
-       for(int i = 0; i < cs.NumCards(); i++)\r
-       {\r
-               Card card = cs[i];\r
-               int val = card.LoVal();\r
-               \r
-               if(count[val - 1] > 0)\r
-                       count[val - 1]--;\r
-       }\r
+    for(int i = 0; i < cs.NumCards(); i++)\r
+    {\r
+        Card card = cs[i];\r
+        int val = card.LoVal();\r
+        \r
+        if(count[val - 1] > 0)\r
+            count[val - 1]--;\r
+    }\r
 }\r
 \r
 void CardCount::Init(const CardStack &cs)\r
 {\r
-       Clear();\r
-       Add(cs);\r
+    Clear();\r
+    Add(cs);\r
 }\r
 \r
 int CardCount::operator [] (size_t index) const\r
 {\r
-       if(index < 1) return 0;\r
-       else if(index > 14)  return 0;  //if out of range\r
-       else if(index == 14) index = 1; //if a "ace-high"\r
+    if(index < 1) return 0;\r
+    else if(index > 14)  return 0;    //if out of range\r
+    else if(index == 14) index = 1;    //if a "ace-high"\r
 \r
-       return count[index - 1];\r
+    return count[index - 1];\r
 }\r
 \r
 //\r
-//     Decrement specified item by one\r
+//    Decrement specified item by one\r
 //\r
 void CardCount::Dec(size_t index)\r
 {\r
-       if(index < 1) return;\r
-       else if(index > 14)  return;    //if out of range\r
-       else if(index == 14) index = 1; //if a "ace-high"\r
+    if(index < 1) return;\r
+    else if(index > 14)  return;    //if out of range\r
+    else if(index == 14) index = 1;    //if a "ace-high"\r
 \r
-       index -= 1;\r
+    index -= 1;\r
 \r
-       if(count[index] > 0) \r
-               count[index]--;\r
+    if(count[index] > 0) \r
+        count[index]--;\r
 }\r
index 6006c9e..acd37c0 100644 (file)
@@ -1,8 +1,8 @@
 //\r
-//     CardLib - not much of interest in here\r
+//    CardLib - not much of interest in here\r
 //\r
-//     Freeware\r
-//     Copyright J Brown 2001\r
+//    Freeware\r
+//    Copyright J Brown 2001\r
 //\r
 #include <windows.h>\r
 #include "cardlib.h"\r
@@ -14,27 +14,27 @@ void LoadCardBitmaps(void);
 extern double __CARDZOOMSPEED;\r
 \r
 //\r
-//     Global variables!\r
+//    Global variables!\r
 //\r
 HDC     __hdcCardBitmaps;\r
 HBITMAP __hbmCardBitmaps;\r
 \r
-HDC            __hdcPlaceHolder;\r
-HBITMAP        __hbmPlaceHolder;\r
+HDC        __hdcPlaceHolder;\r
+HBITMAP    __hbmPlaceHolder;\r
 HPALETTE __holdplacepal;\r
 \r
-int            __cardwidth;\r
-int            __cardheight;\r
+int        __cardwidth;\r
+int        __cardheight;\r
 \r
 HPALETTE __hPalette;\r
 \r
 \r
 //\r
-//     Cardlib global functions!\r
+//    Cardlib global functions!\r
 //\r
 void CardLib_SetZoomSpeed(int speed)\r
 {\r
-       __CARDZOOMSPEED = (double)speed;\r
+    __CARDZOOMSPEED = (double)speed;\r
 }\r
 \r
 /*\r
@@ -44,10 +44,10 @@ void CardLib_SetZoomSpeed(int speed)
   would have unpredicted side-effects.\r
 \r
   e.g. Card card(Hearts, 4);\r
-       if(card == 4)   - how does 4 get converted??\r
-                             It uses the Card(int uval) constructor,\r
-                                                 which results in a 2 of clubs...\r
-                                                 not what was expected\r
+       if(card == 4)    - how does 4 get converted??\r
+                          It uses the Card(int uval) constructor,\r
+                          which results in a 2 of clubs...\r
+                          not what was expected\r
 */ \r
 /*\r
 void CardLib_SetAcesHigh(bool fHigh);\r
@@ -62,55 +62,55 @@ bool operator >= (const Card &lhs, const Card &rhs);
 /*\r
 void CardLib_SetAcesHigh(bool fHigh)\r
 {\r
-       __CARDLIB_ACES_HIGH = fHigh;\r
+    __CARDLIB_ACES_HIGH = fHigh;\r
 }\r
 \r
 bool operator == (const Card &lhs, const Card &rhs)\r
 {\r
-       if(__CARDLIB_ACES_HIGH)\r
-               return lhs.HiVal() == rhs.HiVal();\r
-       else\r
-               return lhs.LoVal() == rhs.LoVal();\r
+    if(__CARDLIB_ACES_HIGH)\r
+        return lhs.HiVal() == rhs.HiVal();\r
+    else\r
+        return lhs.LoVal() == rhs.LoVal();\r
 }\r
 \r
 bool operator != (const Card &lhs, const Card &rhs)\r
 {\r
-       if(__CARDLIB_ACES_HIGH)\r
-               return lhs.HiVal() != rhs.HiVal();\r
-       else\r
-               return lhs.LoVal() != rhs.LoVal();\r
+    if(__CARDLIB_ACES_HIGH)\r
+        return lhs.HiVal() != rhs.HiVal();\r
+    else\r
+        return lhs.LoVal() != rhs.LoVal();\r
 }\r
 \r
 bool operator > (const Card &lhs, const Card &rhs)\r
 {\r
-       if(__CARDLIB_ACES_HIGH)\r
-               return lhs.HiVal() > rhs.HiVal();\r
-       else\r
-               return lhs.LoVal() > rhs.LoVal();\r
+    if(__CARDLIB_ACES_HIGH)\r
+        return lhs.HiVal() > rhs.HiVal();\r
+    else\r
+        return lhs.LoVal() > rhs.LoVal();\r
 }\r
 \r
 bool operator >= (const Card &lhs, const Card &rhs)\r
 {\r
-       if(__CARDLIB_ACES_HIGH)\r
-               return lhs.HiVal() >= rhs.HiVal();\r
-       else\r
-               return lhs.LoVal() >= rhs.LoVal();\r
+    if(__CARDLIB_ACES_HIGH)\r
+        return lhs.HiVal() >= rhs.HiVal();\r
+    else\r
+        return lhs.LoVal() >= rhs.LoVal();\r
 }\r
 \r
 bool operator < (const Card &lhs, const Card &rhs)\r
 {\r
-       if(__CARDLIB_ACES_HIGH)\r
-               return lhs.HiVal() < rhs.HiVal();\r
-       else\r
-               return lhs.LoVal() < rhs.LoVal();\r
+    if(__CARDLIB_ACES_HIGH)\r
+        return lhs.HiVal() < rhs.HiVal();\r
+    else\r
+        return lhs.LoVal() < rhs.LoVal();\r
 }\r
 \r
 bool operator <= (const Card &lhs, const Card &rhs)\r
 {\r
-       if(__CARDLIB_ACES_HIGH)\r
-               return lhs.HiVal() <= rhs.HiVal();\r
-       else\r
-               return lhs.LoVal() <= rhs.LoVal();\r
+    if(__CARDLIB_ACES_HIGH)\r
+        return lhs.HiVal() <= rhs.HiVal();\r
+    else\r
+        return lhs.LoVal() <= rhs.LoVal();\r
 }\r
 */\r
 \r
index 8ecf4be..5eb1c3f 100644 (file)
@@ -1,8 +1,8 @@
 //\r
-//     CardLib - CardRegion class\r
+//    CardLib - CardRegion class\r
 //\r
-//     Freeware\r
-//     Copyright J Brown 2001\r
+//    Freeware\r
+//    Copyright J Brown 2001\r
 //\r
 #include <windows.h>\r
 \r
@@ -18,641 +18,641 @@ void PaintRect(HDC hdc, RECT *rect, COLORREF colour);
 CardRegion::CardRegion(CardWindow &parent, int Id, bool visible, int x, int y, int xOffset, int yOffset) \r
 : id(Id), parentWnd(parent), xpos(x), ypos(y), xoffset(xOffset), yoffset(yOffset), fVisible(visible)\r
 {\r
-       width  = __cardwidth;\r
-       height = __cardheight;\r
+    width  = __cardwidth;\r
+    height = __cardheight;\r
 \r
-       crBackgnd  = RGB(0, 64, 100);\r
+    crBackgnd  = RGB(0, 64, 100);\r
 \r
-       uFaceDirType   = CS_FACE_UP;\r
-       nFaceDirOption = 0;\r
-       uEmptyImage  = CS_EI_SUNK;\r
+    uFaceDirType   = CS_FACE_UP;\r
+    nFaceDirOption = 0;\r
+    uEmptyImage  = CS_EI_SUNK;\r
 \r
-       fVisible         = visible;\r
+    fVisible     = visible;\r
 \r
-       nThreedCount = 1;\r
-       nBackCardIdx = 53;\r
+    nThreedCount = 1;\r
+    nBackCardIdx = 53;\r
 \r
-       Update();                               //Update this stack's size+card count\r
+    Update();                //Update this stack's size+card count\r
 \r
-       hdcBackGnd = 0;\r
-       hbmBackGnd = 0;\r
-       hdcDragCard = 0;\r
-       hbmDragCard = 0;\r
+    hdcBackGnd = 0;\r
+    hbmBackGnd = 0;\r
+    hdcDragCard = 0;\r
+    hbmDragCard = 0;\r
 \r
-       nDragCardWidth = 0;\r
-       nDragCardHeight = 0;\r
-       \r
-       CanDragCallback  = 0;\r
-       CanDropCallback  = 0;\r
-       AddCallback      = 0;\r
-       RemoveCallback   = 0;\r
-       ClickCallback    = 0;\r
-       DblClickCallback = 0;\r
+    nDragCardWidth = 0;\r
+    nDragCardHeight = 0;\r
+    \r
+    CanDragCallback  = 0;\r
+    CanDropCallback  = 0;\r
+    AddCallback      = 0;\r
+    RemoveCallback   = 0;\r
+    ClickCallback    = 0;\r
+    DblClickCallback = 0;\r
 \r
-       uDragRule = CS_DRAG_ALL;\r
-       uDropRule = CS_DROP_ALL;\r
+    uDragRule = CS_DRAG_ALL;\r
+    uDropRule = CS_DROP_ALL;\r
 \r
-       xjustify = yjustify = xadjust = yadjust = 0;\r
+    xjustify = yjustify = xadjust = yadjust = 0;\r
 \r
-       nFlashCount             = 0;\r
-       fFlashVisible   = false;\r
-       uFlashTimer             = (UINT)-1;\r
+    nFlashCount        = 0;\r
+    fFlashVisible    = false;\r
+    uFlashTimer        = (UINT)-1;\r
 \r
-       fMouseDragging = false;\r
+    fMouseDragging = false;\r
 \r
-       mxlock = CreateMutex(0, FALSE, 0);\r
+    mxlock = CreateMutex(0, FALSE, 0);\r
 }\r
 \r
 CardRegion::~CardRegion()\r
 {\r
-       CloseHandle(mxlock);\r
+    CloseHandle(mxlock);\r
 }\r
 \r
 void CardRegion::SetBackColor(COLORREF cr)\r
 {\r
-       crBackgnd = cr;\r
+    crBackgnd = cr;\r
 }\r
 \r
 int CardRegion::CalcApparentCards(int realnum)\r
 {\r
-       return ((realnum + nThreedCount - 1) - (realnum + nThreedCount - 1) % nThreedCount) / nThreedCount;\r
+    return ((realnum + nThreedCount - 1) - (realnum + nThreedCount - 1) % nThreedCount) / nThreedCount;\r
 }\r
 \r
 void CardRegion::CalcApparentCards()\r
 {\r
-       nNumApparentCards = CalcApparentCards(cardstack.NumCards());\r
+    nNumApparentCards = CalcApparentCards(cardstack.NumCards());\r
 }\r
 \r
 \r
 void CardRegion::UpdateSize(void)\r
 {\r
-       if(cardstack.NumCards() > 0)\r
-       {\r
-               if(xoffset > 0)\r
-                       width  = (nNumApparentCards - 1) * xoffset + __cardwidth;\r
-               else\r
-                       width  = (nNumApparentCards - 1) * -xoffset + __cardwidth;\r
-\r
-               if(yoffset > 0)\r
-                       height = (nNumApparentCards - 1) * yoffset + __cardheight;\r
-               else\r
-                       height = (nNumApparentCards - 1) * -yoffset + __cardheight;\r
-       }\r
-       else\r
-       {\r
-               width = __cardwidth;\r
-               height = __cardheight;\r
-       }\r
+    if(cardstack.NumCards() > 0)\r
+    {\r
+        if(xoffset > 0)\r
+            width  = (nNumApparentCards - 1) * xoffset + __cardwidth;\r
+        else\r
+            width  = (nNumApparentCards - 1) * -xoffset + __cardwidth;\r
+\r
+        if(yoffset > 0)\r
+            height = (nNumApparentCards - 1) * yoffset + __cardheight;\r
+        else\r
+            height = (nNumApparentCards - 1) * -yoffset + __cardheight;\r
+    }\r
+    else\r
+    {\r
+        width = __cardwidth;\r
+        height = __cardheight;\r
+    }\r
 }\r
 \r
 CardRegion *CardWindow::CreateRegion(int id, bool fVisible, int x, int y, int xoffset, int yoffset)\r
 {\r
-       CardRegion *cr;\r
+    CardRegion *cr;\r
 \r
-       if(nNumCardRegions == MAXCARDSTACKS)\r
-               return FALSE;\r
+    if(nNumCardRegions == MAXCARDSTACKS)\r
+        return FALSE;\r
 \r
-       cr = new CardRegion(*this, id, fVisible, x, y, xoffset, yoffset);\r
-       cr->SetBackColor(crBackgnd);\r
-       cr->SetBackCardIdx(nBackCardIdx);\r
+    cr = new CardRegion(*this, id, fVisible, x, y, xoffset, yoffset);\r
+    cr->SetBackColor(crBackgnd);\r
+    cr->SetBackCardIdx(nBackCardIdx);\r
 \r
-       Regions[nNumCardRegions++] = cr;\r
-       \r
-       return cr;\r
+    Regions[nNumCardRegions++] = cr;\r
+    \r
+    return cr;\r
 }\r
 \r
 int CardRegion::GetOverlapRatio(int x, int y, int w, int h)\r
 {\r
-       RECT me, him;\r
-       RECT inter;\r
-       SetRect(&him, x, y, x+w, y+h);\r
-       SetRect(&me,  xpos, ypos, xpos+width, ypos+height);\r
+    RECT me, him;\r
+    RECT inter;\r
+    SetRect(&him, x, y, x+w, y+h);\r
+    SetRect(&me,  xpos, ypos, xpos+width, ypos+height);\r
 \r
-       //see if the specified rectangle overlaps us\r
-       if(IntersectRect(&inter, &me, &him))\r
-       {\r
-               int wi = inter.right  - inter.left;\r
-               int hi = inter.bottom - inter.top;\r
+    //see if the specified rectangle overlaps us\r
+    if(IntersectRect(&inter, &me, &him))\r
+    {\r
+        int wi = inter.right  - inter.left;\r
+        int hi = inter.bottom - inter.top;\r
 \r
-               int overlap = wi * hi;\r
-               int total   = width * height;\r
+        int overlap = wi * hi;\r
+        int total   = width * height;\r
 \r
-               int percent = (overlap << 16) / total;\r
-               return (percent * 100) >> 16;\r
-       }\r
-       //do not overlap\r
-       else\r
-       {\r
-               return 0;\r
-       }\r
+        int percent = (overlap << 16) / total;\r
+        return (percent * 100) >> 16;\r
+    }\r
+    //do not overlap\r
+    else\r
+    {\r
+        return 0;\r
+    }\r
 }\r
 \r
 bool CardRegion::SetDragRule(UINT uDragType, pCanDragProc proc)\r
 { \r
-       switch(uDragType)\r
-       {\r
-       case CS_DRAG_NONE: case CS_DRAG_ALL: case CS_DRAG_TOP:\r
-               uDragRule = uDragType;\r
-               return true;\r
+    switch(uDragType)\r
+    {\r
+    case CS_DRAG_NONE: case CS_DRAG_ALL: case CS_DRAG_TOP:\r
+        uDragRule = uDragType;\r
+        return true;\r
 \r
-       case CS_DRAG_CALLBACK:\r
-               uDragRule = uDragType;\r
-               CanDragCallback = proc;\r
-               return true;\r
+    case CS_DRAG_CALLBACK:\r
+        uDragRule = uDragType;\r
+        CanDragCallback = proc;\r
+        return true;\r
 \r
-       default:\r
-               return false;\r
-       }\r
+    default:\r
+        return false;\r
+    }\r
 }\r
 \r
 bool CardRegion::SetDropRule(UINT uDropType, pCanDropProc proc)\r
 { \r
-       switch(uDropType)\r
-       {\r
-       case CS_DROP_NONE: case CS_DROP_ALL: \r
-               uDropRule = uDropType;\r
-               return true;\r
+    switch(uDropType)\r
+    {\r
+    case CS_DROP_NONE: case CS_DROP_ALL: \r
+        uDropRule = uDropType;\r
+        return true;\r
 \r
-       case CS_DROP_CALLBACK:\r
-               uDropRule = uDropType;\r
-               CanDropCallback = proc;\r
-               return true;\r
+    case CS_DROP_CALLBACK:\r
+        uDropRule = uDropType;\r
+        CanDropCallback = proc;\r
+        return true;\r
 \r
-       default:\r
-               return false;\r
-       }\r
+    default:\r
+        return false;\r
+    }\r
 }\r
 \r
 void CardRegion::SetClickProc(pClickProc proc)\r
 {\r
-       ClickCallback = proc;\r
+    ClickCallback = proc;\r
 }\r
 \r
 void CardRegion::SetDblClickProc(pClickProc proc)\r
 {\r
-       DblClickCallback = proc;\r
+    DblClickCallback = proc;\r
 }\r
 \r
 void CardRegion::SetAddCardProc(pAddProc proc)\r
 {\r
-       AddCallback = proc;\r
+    AddCallback = proc;\r
 }\r
 \r
 void CardRegion::SetRemoveCardProc(pRemoveProc proc)\r
 {\r
-       RemoveCallback = proc;\r
+    RemoveCallback = proc;\r
 }\r
 \r
 void CardRegion::Update()\r
 {\r
-       CalcApparentCards();\r
-       UpdateSize(); \r
-       UpdateFaceDir(cardstack);\r
+    CalcApparentCards();\r
+    UpdateSize(); \r
+    UpdateFaceDir(cardstack);\r
 }\r
 \r
 \r
 bool CardRegion::SetThreedCount(int count)\r
 {\r
-       if(count < 1) \r
-       {\r
-               return false;\r
-       }\r
-       else\r
-       {\r
-               nThreedCount = count;\r
-               return true;\r
-       }\r
+    if(count < 1) \r
+    {\r
+        return false;\r
+    }\r
+    else\r
+    {\r
+        nThreedCount = count;\r
+        return true;\r
+    }\r
 }\r
 \r
 void CardRegion::SetOffsets(int x, int y)\r
 {\r
-       xoffset = x;\r
-       yoffset = y;\r
+    xoffset = x;\r
+    yoffset = y;\r
 }\r
 \r
 void CardRegion::SetPos(int x, int y)\r
 {\r
-       xpos = x;\r
-       ypos = y;\r
+    xpos = x;\r
+    ypos = y;\r
 }\r
 \r
 void CardRegion::Show(bool fShow)\r
 {\r
-       fVisible = fShow;\r
+    fVisible = fShow;\r
 }\r
 \r
 bool CardRegion::IsVisible()\r
 { \r
-       return fVisible;\r
+    return fVisible;\r
 }\r
 \r
 void CardRegion::SetPlacement(UINT xJustify, UINT yJustify, int xAdjust, int yAdjust)\r
 {\r
-       xjustify = xJustify;\r
-       yjustify = yJustify;\r
-       xadjust  = xAdjust;\r
-       yadjust  = yAdjust;\r
+    xjustify = xJustify;\r
+    yjustify = yJustify;\r
+    xadjust  = xAdjust;\r
+    yadjust  = yAdjust;\r
 }\r
 \r
 void CardRegion::SetFaceDirection(UINT uDirType, int nOption)\r
 {\r
-       switch(uDirType)\r
-       {\r
-       case CS_FACE_UP:     case CS_FACE_DOWN: case CS_FACE_DOWNUP:\r
-       case CS_FACE_UPDOWN: case CS_FACE_ANY:\r
-               uFaceDirType    = uDirType;\r
-               nFaceDirOption  = nOption;\r
+    switch(uDirType)\r
+    {\r
+    case CS_FACE_UP:     case CS_FACE_DOWN: case CS_FACE_DOWNUP:\r
+    case CS_FACE_UPDOWN: case CS_FACE_ANY:\r
+        uFaceDirType    = uDirType;\r
+        nFaceDirOption  = nOption;\r
 \r
-               UpdateFaceDir(cardstack);\r
+        UpdateFaceDir(cardstack);\r
 \r
-               break;\r
-       }\r
+        break;\r
+    }\r
 }\r
 \r
 UINT CardRegion::GetFaceDirection(int *pnOption)\r
 {\r
-       if(pnOption)\r
-               *pnOption = nFaceDirOption;\r
+    if(pnOption)\r
+        *pnOption = nFaceDirOption;\r
 \r
-       return uFaceDirType;\r
+    return uFaceDirType;\r
 }\r
 \r
 void CardRegion::AdjustPosition(int winwidth, int winheight)\r
 {\r
-       Update();                       //Update this stack's card count + size\r
-\r
-       switch(xjustify)\r
-       {\r
-       default: case CS_XJUST_NONE: break;\r
-       \r
-       case CS_XJUST_CENTER:           //centered\r
-               xpos = (winwidth - (width & ~0x1)) / 2;\r
-               xpos += xadjust;\r
+    Update();            //Update this stack's card count + size\r
 \r
-               if(xoffset < 0) xpos += (width - __cardwidth);\r
-       \r
-               break;\r
-\r
-       case CS_XJUST_RIGHT:            //right-aligned\r
-               xpos = winwidth - __cardwidth;//width - 20;\r
-               xpos += xadjust;\r
-               break;\r
-       }\r
-\r
-       switch(yjustify)\r
-       {\r
-       default: case CS_YJUST_NONE: break;\r
-       \r
-       case CS_YJUST_CENTER:           //centered\r
-               ypos = (winheight - height) / 2;\r
-               ypos += yadjust;\r
-               if(yoffset < 0) ypos += (height - __cardheight);\r
-               break;\r
+    switch(xjustify)\r
+    {\r
+    default: case CS_XJUST_NONE: break;\r
+    \r
+    case CS_XJUST_CENTER:        //centered\r
+        xpos = (winwidth - (width & ~0x1)) / 2;\r
+        xpos += xadjust;\r
+\r
+        if(xoffset < 0)    xpos += (width - __cardwidth);\r
+    \r
+        break;\r
+\r
+    case CS_XJUST_RIGHT:        //right-aligned\r
+        xpos = winwidth - __cardwidth;//width - 20;\r
+        xpos += xadjust;\r
+        break;\r
+    }\r
+\r
+    switch(yjustify)\r
+    {\r
+    default: case CS_YJUST_NONE: break;\r
+    \r
+    case CS_YJUST_CENTER:        //centered\r
+        ypos = (winheight - height) / 2;\r
+        ypos += yadjust;\r
+        if(yoffset < 0)    ypos += (height - __cardheight);\r
+        break;\r
 \r
-       case CS_YJUST_BOTTOM:           //bottom-aligned\r
-               ypos = winheight - __cardheight;//height - 20;\r
-               ypos += yadjust;\r
-               break;\r
-       }\r
+    case CS_YJUST_BOTTOM:        //bottom-aligned\r
+        ypos = winheight - __cardheight;//height - 20;\r
+        ypos += yadjust;\r
+        break;\r
+    }\r
 \r
 }\r
 \r
 \r
 void CardRegion::Flash(int count, int milliseconds)\r
 {\r
-       if(count <= 0) return;\r
+    if(count <= 0) return;\r
 \r
-       nFlashCount             = count;\r
-       fFlashVisible   = false;\r
-       uFlashTimer             = SetTimer((HWND)parentWnd, (WPARAM)this, milliseconds, 0);\r
-       \r
-       parentWnd.Redraw();\r
+    nFlashCount        = count;\r
+    fFlashVisible   = false;\r
+    uFlashTimer        = SetTimer((HWND)parentWnd, (WPARAM)this, milliseconds, 0);\r
+    \r
+    parentWnd.Redraw();\r
 }\r
 \r
 void CardRegion::StopFlash()\r
 {\r
-       if(uFlashTimer != (UINT)-1)\r
-       {\r
-               KillTimer((HWND)parentWnd, uFlashTimer);\r
-               nFlashCount             = 0;\r
-               uFlashTimer             = (UINT)-1;\r
-               fFlashVisible   = true;\r
-       }\r
+    if(uFlashTimer != (UINT)-1)\r
+    {\r
+        KillTimer((HWND)parentWnd, uFlashTimer);\r
+        nFlashCount        = 0;\r
+        uFlashTimer        = (UINT)-1;\r
+        fFlashVisible    = true;\r
+    }\r
 }\r
 \r
 void CardRegion::DoFlash()\r
 {\r
-       if(uFlashTimer != (UINT)-1)\r
-       {\r
-               fFlashVisible = !fFlashVisible;\r
+    if(uFlashTimer != (UINT)-1)\r
+    {\r
+        fFlashVisible = !fFlashVisible;\r
 \r
-               if(--nFlashCount == 0)\r
-               {\r
-                       KillTimer((HWND)parentWnd, uFlashTimer);\r
-                       uFlashTimer = (UINT)-1;\r
-                       fFlashVisible = true;\r
-               }\r
-       \r
-               parentWnd.Redraw();\r
-       }\r
+        if(--nFlashCount == 0)\r
+        {\r
+            KillTimer((HWND)parentWnd, uFlashTimer);\r
+            uFlashTimer = (UINT)-1;\r
+            fFlashVisible = true;\r
+        }\r
+    \r
+        parentWnd.Redraw();\r
+    }\r
 }\r
 \r
 int CardRegion::Id()\r
 {\r
-       return id;\r
+    return id;\r
 }\r
 \r
 void CardRegion::SetEmptyImage(UINT uImage)\r
 {\r
-       switch(uImage)\r
-       {\r
-       case CS_EI_NONE: case CS_EI_SUNK:\r
-               uEmptyImage = uImage;\r
-               break;\r
+    switch(uImage)\r
+    {\r
+    case CS_EI_NONE: case CS_EI_SUNK:\r
+        uEmptyImage = uImage;\r
+        break;\r
 \r
-       default:\r
-               uEmptyImage = CS_EI_NONE;\r
-               break;\r
-       }\r
-       \r
+    default:\r
+        uEmptyImage = CS_EI_NONE;\r
+        break;\r
+    }\r
+    \r
 }\r
 \r
 void CardRegion::SetBackCardIdx(UINT uBackIdx)\r
 {\r
-       if(uBackIdx >= 52 && uBackIdx <= 68)\r
-               nBackCardIdx = uBackIdx;\r
+    if(uBackIdx >= 52 && uBackIdx <= 68)\r
+        nBackCardIdx = uBackIdx;\r
 }\r
 \r
 void CardRegion::SetCardStack(const CardStack &cs)\r
 { \r
-       //make a complete copy of the specified stack..\r
-       cardstack = cs; \r
+    //make a complete copy of the specified stack..\r
+    cardstack = cs; \r
 \r
-       // Update the face-direction and stack-size\r
-       Update();\r
+    // Update the face-direction and stack-size\r
+    Update();\r
 }\r
 \r
 const CardStack & CardRegion::GetCardStack()\r
 { \r
-       //return reference to our internal stack\r
-       return cardstack; \r
+    //return reference to our internal stack\r
+    return cardstack; \r
 }\r
 \r
 //\r
-//     Update specified card-stack using THIS stack's\r
+//    Update specified card-stack using THIS stack's\r
 //  face direction rules!\r
 //\r
 void CardRegion::UpdateFaceDir(CardStack &cards)\r
 {\r
-       int i, n, num;\r
+    int i, n, num;\r
 \r
-       num = cards.NumCards();\r
+    num = cards.NumCards();\r
 \r
-       //Now apply the face direction rules..\r
-       switch(uFaceDirType)\r
-       {\r
-       case CS_FACE_UP:\r
+    //Now apply the face direction rules..\r
+    switch(uFaceDirType)\r
+    {\r
+    case CS_FACE_UP:\r
 \r
-               for(i = 0; i < num; i++)\r
-               {\r
-                       cards[i].SetFaceUp(true);\r
-               }\r
+        for(i = 0; i < num; i++)\r
+        {\r
+            cards[i].SetFaceUp(true);\r
+        }\r
 \r
-               break;\r
+        break;\r
 \r
-       case CS_FACE_DOWN:\r
+    case CS_FACE_DOWN:\r
 \r
-               for(i = 0; i < num; i++)\r
-               {\r
-                       cards[i].SetFaceUp(false);\r
-               }\r
+        for(i = 0; i < num; i++)\r
+        {\r
+            cards[i].SetFaceUp(false);\r
+        }\r
 \r
-               break;\r
+        break;\r
 \r
-       case CS_FACE_DOWNUP:\r
+    case CS_FACE_DOWNUP:\r
 \r
-               num = cardstack.NumCards();\r
-               n = min(nFaceDirOption, num);\r
+        num = cardstack.NumCards();\r
+        n = min(nFaceDirOption, num);\r
 \r
-               //bottom n cards..\r
-               for(i = 0; i < n; i++)\r
-               {\r
-                       cards[num - i - 1].SetFaceUp(false);\r
-               }\r
+        //bottom n cards..\r
+        for(i = 0; i < n; i++)\r
+        {\r
+            cards[num - i - 1].SetFaceUp(false);\r
+        }\r
 \r
-               for(i = n; i < num; i++)\r
-               {\r
-                       cards[num - i - 1].SetFaceUp(true);\r
-               }\r
+        for(i = n; i < num; i++)\r
+        {\r
+            cards[num - i - 1].SetFaceUp(true);\r
+        }\r
 \r
-               break;\r
+        break;\r
 \r
-       case CS_FACE_UPDOWN:\r
+    case CS_FACE_UPDOWN:\r
 \r
-               num = cardstack.NumCards();\r
-               n = min(nFaceDirOption, num);\r
+        num = cardstack.NumCards();\r
+        n = min(nFaceDirOption, num);\r
 \r
-               for(i = 0; i < n; i++)\r
-               {\r
-                       cards[num - i - 1].SetFaceUp(true);\r
-               }\r
+        for(i = 0; i < n; i++)\r
+        {\r
+            cards[num - i - 1].SetFaceUp(true);\r
+        }\r
 \r
-               for(i = n; i < num; i++)\r
-               {\r
-                       cards[num - i - 1].SetFaceUp(false);\r
-               }\r
+        for(i = n; i < num; i++)\r
+        {\r
+            cards[num - i - 1].SetFaceUp(false);\r
+        }\r
 \r
-               break;\r
+        break;\r
 \r
-       case CS_FACE_ANY:       //cards can be any orientation\r
-       default:\r
-               break;\r
-       }\r
+    case CS_FACE_ANY:    //cards can be any orientation\r
+    default:\r
+        break;\r
+    }\r
 }\r
 \r
 bool CardRegion::MoveCard(CardRegion *pDestStack, int nNumCards, bool fAnimate)\r
 {\r
-       HDC hdc;\r
+    HDC hdc;\r
 \r
-       int x, y;\r
+    int x, y;\r
 \r
-       if(pDestStack == 0) return false; //{ forcedfacedir = -1 ;return 0; }\r
+    if(pDestStack == 0) return false; //{ forcedfacedir = -1 ;return 0; }\r
 \r
-       if(nNumCards < 0 || nNumCards > cardstack.NumCards())\r
-               return false;\r
+    if(nNumCards < 0 || nNumCards > cardstack.NumCards())\r
+        return false;\r
 \r
-       x = xpos + xoffset * (nNumApparentCards - nNumCards);\r
-       y = ypos + yoffset * (nNumApparentCards - nNumCards);\r
+    x = xpos + xoffset * (nNumApparentCards - nNumCards);\r
+    y = ypos + yoffset * (nNumApparentCards - nNumCards);\r
 \r
-       oldx = x;\r
-       oldy = y;\r
-       \r
-       dragstack = cardstack.Pop(nNumCards);\r
+    oldx = x;\r
+    oldy = y;\r
+    \r
+    dragstack = cardstack.Pop(nNumCards);\r
 \r
-       //Alter the drag-stack so that it's cards are the same way up\r
-       //as the destination. Use the destination's drag-rules\r
-       //instead of this ones!!\r
-       CardStack temp;\r
-       temp.Push(pDestStack->GetCardStack());\r
-       temp.Push(dragstack);\r
+    //Alter the drag-stack so that it's cards are the same way up\r
+    //as the destination. Use the destination's drag-rules\r
+    //instead of this ones!!\r
+    CardStack temp;\r
+    temp.Push(pDestStack->GetCardStack());\r
+    temp.Push(dragstack);\r
 \r
-       pDestStack->UpdateFaceDir(temp);\r
+    pDestStack->UpdateFaceDir(temp);\r
 \r
-       dragstack = temp.Pop(nNumCards);\r
+    dragstack = temp.Pop(nNumCards);\r
 \r
-       if(fAnimate)\r
-       {\r
-               iNumDragCards = nNumCards;\r
-               PrepareDragBitmaps(nNumCards);\r
-       }\r
+    if(fAnimate)\r
+    {\r
+        iNumDragCards = nNumCards;\r
+        PrepareDragBitmaps(nNumCards);\r
+    }\r
 \r
-       Update();               //Update this stack's size+card count\r
+    Update();        //Update this stack's size+card count\r
 \r
-       if(fAnimate)\r
-       {\r
-               hdc = GetDC((HWND)parentWnd);\r
+    if(fAnimate)\r
+    {\r
+        hdc = GetDC((HWND)parentWnd);\r
 \r
-               ZoomCard(hdc, x, y, pDestStack);\r
-               \r
-               ReleaseDC((HWND)parentWnd, hdc);\r
-               ReleaseDragBitmaps();\r
-       }\r
+        ZoomCard(hdc, x, y, pDestStack);\r
+        \r
+        ReleaseDC((HWND)parentWnd, hdc);\r
+        ReleaseDragBitmaps();\r
+    }\r
 \r
-       // Get a copy of the cardstack\r
-       CardStack cs = pDestStack->GetCardStack();\r
-       cs.Push(dragstack);\r
-       \r
-       pDestStack->SetCardStack(cs);\r
-       \r
-       //cs = pDestStack->GetCardStack();\r
-       //pDestStack->Update();\r
-       //pDestStack->UpdateFaceDir(cs);\r
+    // Get a copy of the cardstack\r
+    CardStack cs = pDestStack->GetCardStack();\r
+    cs.Push(dragstack);\r
+    \r
+    pDestStack->SetCardStack(cs);\r
+    \r
+    //cs = pDestStack->GetCardStack();\r
+    //pDestStack->Update();\r
+    //pDestStack->UpdateFaceDir(cs);\r
 \r
-       RedrawIfNotDim(pDestStack, false);\r
+    RedrawIfNotDim(pDestStack, false);\r
 \r
-       //forcedfacedir = -1;\r
-       return true;\r
+    //forcedfacedir = -1;\r
+    return true;\r
 }\r
 \r
 //\r
-//     Simple wrappers\r
+//    Simple wrappers\r
 //\r
 int CardRegion::NumCards() const\r
 {\r
-       if(fMouseDragging)\r
-               return cardstack.NumCards() + dragstack.NumCards();\r
-       else\r
-               return cardstack.NumCards(); \r
+    if(fMouseDragging)\r
+        return cardstack.NumCards() + dragstack.NumCards();\r
+    else\r
+        return cardstack.NumCards(); \r
 }\r
 \r
 bool CardRegion::Lock()\r
 {\r
-       DWORD dw = WaitForSingleObject(mxlock, 0);\r
+    DWORD dw = WaitForSingleObject(mxlock, 0);\r
 \r
-       if(dw == WAIT_OBJECT_0)\r
-       {\r
-               //TRACE("LockStack succeeded\n");\r
-               return true; \r
-       }\r
-       else\r
-       {\r
-               //TRACE("LockStack failed\n");\r
-               return false;\r
-       }\r
-       return false;\r
+    if(dw == WAIT_OBJECT_0)\r
+    {\r
+        //TRACE("LockStack succeeded\n");\r
+        return true; \r
+    }\r
+    else\r
+    {\r
+        //TRACE("LockStack failed\n");\r
+        return false;\r
+    }\r
+    return false;\r
 }\r
 \r
 bool CardRegion::UnLock()\r
 {\r
-       if(ReleaseMutex(mxlock))\r
-       {\r
-               //TRACE("Unlocking stack\n");\r
-               return true;\r
-       }\r
-       else\r
-       {\r
-               //TRACE("Unlocking stack failed\n");    \r
-               return false;\r
-       }\r
+    if(ReleaseMutex(mxlock))\r
+    {\r
+        //TRACE("Unlocking stack\n");\r
+        return true;\r
+    }\r
+    else\r
+    {\r
+        //TRACE("Unlocking stack failed\n");    \r
+        return false;\r
+    }\r
 }\r
 \r
 bool CardRegion::PlayCard(CardRegion *pDestStack, int value, int num)\r
 {\r
-       //search the stack for the specified card value...\r
-       while(num--)\r
-       {\r
-               for(int i = 0; i < cardstack.NumCards(); i++)\r
-               {\r
-                       if(cardstack[i].HiVal() == value)\r
-                       {\r
-                               //swap the card with one at top pos...\r
-                               Card card = cardstack.RemoveCard(i);\r
-                               cardstack.Push(card);\r
+    //search the stack for the specified card value...\r
+    while(num--)\r
+    {\r
+        for(int i = 0; i < cardstack.NumCards(); i++)\r
+        {\r
+            if(cardstack[i].HiVal() == value)\r
+            {\r
+                //swap the card with one at top pos...\r
+                Card card = cardstack.RemoveCard(i);\r
+                cardstack.Push(card);\r
 \r
-                               Redraw();\r
+                Redraw();\r
 \r
-                               MoveCard(pDestStack, 1, true);\r
-                               break;\r
-                       }\r
-               }\r
-       }\r
+                MoveCard(pDestStack, 1, true);\r
+                break;\r
+            }\r
+        }\r
+    }\r
 \r
-       return true;\r
+    return true;\r
 }\r
 \r
 //\r
-//     Redraw the current stack if it has a different\r
-//     layout than the comparison stack.\r
+//    Redraw the current stack if it has a different\r
+//    layout than the comparison stack.\r
 //\r
 void CardRegion::RedrawIfNotDim(CardRegion *pCompare, bool fFullRedraw)\r
 {\r
-       //\r
-       //\r
-       //\r
-       if( pCompare->xoffset != xoffset || \r
-               pCompare->yoffset != yoffset || \r
-               pCompare->nThreedCount != nThreedCount ||\r
-               pCompare->uFaceDirType != uFaceDirType ||\r
-               pCompare->uFaceDirType != CS_FACE_ANY\r
-               )\r
-       {\r
-               if(fFullRedraw)\r
-                       parentWnd.Redraw();\r
-               else\r
-                       pCompare->Redraw();\r
-       }\r
-       \r
+    //\r
+    //\r
+    //\r
+    if( pCompare->xoffset != xoffset || \r
+        pCompare->yoffset != yoffset || \r
+        pCompare->nThreedCount != nThreedCount ||\r
+        pCompare->uFaceDirType != uFaceDirType ||\r
+        pCompare->uFaceDirType != CS_FACE_ANY\r
+        )\r
+    {\r
+        if(fFullRedraw)\r
+            parentWnd.Redraw();\r
+        else\r
+            pCompare->Redraw();\r
+    }\r
+    \r
 }\r
 \r
 //\r
-//     SimulateDrag mimicks the complete drag+drop process.\r
+//    SimulateDrag mimicks the complete drag+drop process.\r
 //  It basically just a MoveCard(..), but it calls the\r
 //  event callbacks as well.\r
 //\r
 bool CardRegion::SimulateDrag(CardRegion *pDestStack, int iNumDragCards, bool fAnimate)\r
 {\r
-       if(pDestStack == 0)\r
-               return false;\r
+    if(pDestStack == 0)\r
+        return false;\r
 \r
-       if(CanDragCards(iNumDragCards) != false)\r
+    if(CanDragCards(iNumDragCards) != false)\r
     {\r
-               //make a list of the cards that would be in the drag list\r
-               CardStack tempstack = cardstack.Top(iNumDragCards);\r
+        //make a list of the cards that would be in the drag list\r
+        CardStack tempstack = cardstack.Top(iNumDragCards);\r
 \r
-               if(pDestStack->CanDropCards(tempstack)) \r
-               {\r
-                       MoveCard(pDestStack, iNumDragCards, fAnimate);          \r
-                               \r
-                       if(RemoveCallback)\r
-                               RemoveCallback(*this, iNumDragCards);\r
+        if(pDestStack->CanDropCards(tempstack)) \r
+        {\r
+            MoveCard(pDestStack, iNumDragCards, fAnimate);        \r
+                \r
+            if(RemoveCallback)\r
+                RemoveCallback(*this, iNumDragCards);\r
 \r
-                       if(pDestStack->AddCallback)\r
-                               pDestStack->AddCallback(*pDestStack, pDestStack->cardstack);\r
-               \r
-                       RedrawIfNotDim(pDestStack, true);\r
-               }       \r
+            if(pDestStack->AddCallback)\r
+                pDestStack->AddCallback(*pDestStack, pDestStack->cardstack);\r
+        \r
+            RedrawIfNotDim(pDestStack, true);\r
+        }    \r
 \r
-       }\r
+    }\r
 \r
-       return true;\r
+    return true;\r
 }\r
index 32d8bbf..a5da84d 100644 (file)
@@ -1,8 +1,8 @@
 //\r
-//     CardLib - CardRegion drawing support\r
+//    CardLib - CardRegion drawing support\r
 //\r
-//     Freeware\r
-//     Copyright J Brown 2001\r
+//    Freeware\r
+//    Copyright J Brown 2001\r
 //\r
 #include <windows.h>\r
 #include "cardlib.h"\r
@@ -15,33 +15,33 @@ void CardBlt(HDC hdc, int x, int y, int nCardNum);
 void DrawCard(HDC hdc, int x, int y, HDC hdcSource, int width, int height);\r
 \r
 //\r
-//     Draw specified card at position x, y\r
-//     xoff   - source offset from left of card\r
-//     yoff   - source offset from top of card\r
-//     width  - width to draw\r
-//     height - height to draw\r
+//    Draw specified card at position x, y\r
+//    xoff   - source offset from left of card\r
+//    yoff   - source offset from top of card\r
+//    width  - width to draw\r
+//    height - height to draw\r
 //\r
 void CardBlt(HDC hdc, int x, int y, int nCardNum)//, int xoff, int yoff, int width, int height)\r
 {\r
-       int sx = nCardNum * __cardwidth;\r
-       int sy = 0;\r
-       int width  = __cardwidth;\r
-       int height = __cardheight;\r
+    int sx = nCardNum * __cardwidth;\r
+    int sy = 0;\r
+    int width  = __cardwidth;\r
+    int height = __cardheight;\r
 \r
-       //draw main center band\r
-       BitBlt(hdc, x+2, y, width - 4, height, __hdcCardBitmaps, sx+2, sy+0, SRCCOPY);\r
+    //draw main center band\r
+    BitBlt(hdc, x+2, y, width - 4, height, __hdcCardBitmaps, sx+2, sy+0, SRCCOPY);\r
 \r
-       //draw the two bits to the left\r
-       BitBlt(hdc, x,   y+2, 1, height - 4, __hdcCardBitmaps, sx+0, sy+2, SRCCOPY);\r
-       BitBlt(hdc, x+1, y+1, 1, height - 2, __hdcCardBitmaps, sx+1, sy+1, SRCCOPY);\r
+    //draw the two bits to the left\r
+    BitBlt(hdc, x,   y+2, 1, height - 4, __hdcCardBitmaps, sx+0, sy+2, SRCCOPY);\r
+    BitBlt(hdc, x+1, y+1, 1, height - 2, __hdcCardBitmaps, sx+1, sy+1, SRCCOPY);\r
 \r
-       //draw the two bits to the right\r
-       BitBlt(hdc, x+width-2, y+1, 1, height - 2, __hdcCardBitmaps, sx+width-2, sy+1, SRCCOPY);\r
-       BitBlt(hdc, x+width-1, y+2, 1, height - 4, __hdcCardBitmaps, sx+width-1, sy+2, SRCCOPY);\r
+    //draw the two bits to the right\r
+    BitBlt(hdc, x+width-2, y+1, 1, height - 2, __hdcCardBitmaps, sx+width-2, sy+1, SRCCOPY);\r
+    BitBlt(hdc, x+width-1, y+2, 1, height - 4, __hdcCardBitmaps, sx+width-1, sy+2, SRCCOPY);\r
 }\r
 \r
 //\r
-//     Draw a shape this this:\r
+//    Draw a shape this this:\r
 //\r
 //   ++++++++++++\r
 //  ++++++++++++++\r
@@ -49,44 +49,44 @@ void CardBlt(HDC hdc, int x, int y, int nCardNum)//, int xoff, int yoff, int wid
 //\r
 void DrawHorzCardStrip(HDC hdc, int x, int y, int nCardNum, int height, BOOL fDrawTips)\r
 {\r
-       int sx  = nCardNum * __cardwidth;\r
-       int sy  = 0;\r
-       int one = 1;\r
-       int two = 2;\r
-       BOOL tips = fDrawTips ? FALSE : TRUE;\r
+    int sx  = nCardNum * __cardwidth;\r
+    int sy  = 0;\r
+    int one = 1;\r
+    int two = 2;\r
+    BOOL tips = fDrawTips ? FALSE : TRUE;\r
 \r
-       if(height == 0) return;\r
+    if(height == 0) return;\r
 \r
-       if(height < 0)\r
-       {\r
-               sy = sy + __cardheight;\r
-               y  -= height;\r
-               one = -one;\r
-               two = -two;\r
-       }\r
+    if(height < 0)\r
+    {\r
+        sy = sy + __cardheight;\r
+        y  -= height;\r
+        one = -one;\r
+        two = -two;\r
+    }\r
 \r
-       // draw the main vertical band\r
-       //\r
-       BitBlt(hdc, x + 2, y, __cardwidth - 4, height, __hdcCardBitmaps, sx+2, sy, SRCCOPY);\r
+    // draw the main vertical band\r
+    //\r
+    BitBlt(hdc, x + 2, y, __cardwidth - 4, height, __hdcCardBitmaps, sx+2, sy, SRCCOPY);\r
 \r
-       //if(height <= 1) return;\r
+    //if(height <= 1) return;\r
 \r
-       // draw the "lips" at the left and right\r
-       BitBlt(hdc, x+1,             y+one, 1, height-one*tips, __hdcCardBitmaps, sx+1,             sy+one, SRCCOPY);\r
-       BitBlt(hdc, x+__cardwidth-2, y+one, 1, height-one*tips, __hdcCardBitmaps, sx+__cardwidth-2, sy+one, SRCCOPY);\r
+    // draw the "lips" at the left and right\r
+    BitBlt(hdc, x+1,             y+one, 1, height-one*tips, __hdcCardBitmaps, sx+1,             sy+one, SRCCOPY);\r
+    BitBlt(hdc, x+__cardwidth-2, y+one, 1, height-one*tips, __hdcCardBitmaps, sx+__cardwidth-2, sy+one, SRCCOPY);\r
 \r
-       //if(height <= 2) return;\r
+    //if(height <= 2) return;\r
 \r
-       // draw the outer-most lips\r
-       BitBlt(hdc, x,               y+two, 1, height-two*tips, __hdcCardBitmaps, sx,               sy+two, SRCCOPY);\r
-       BitBlt(hdc, x+__cardwidth-1, y+two, 1, height-two*tips, __hdcCardBitmaps, sx+__cardwidth-1, sy+two, SRCCOPY);   \r
+    // draw the outer-most lips\r
+    BitBlt(hdc, x,               y+two, 1, height-two*tips, __hdcCardBitmaps, sx,               sy+two, SRCCOPY);\r
+    BitBlt(hdc, x+__cardwidth-1, y+two, 1, height-two*tips, __hdcCardBitmaps, sx+__cardwidth-1, sy+two, SRCCOPY);    \r
 }\r
 \r
 //\r
-//     Draw a shape like this:\r
+//    Draw a shape like this:\r
 //\r
 //     +++\r
-//       +++\r
+//      +++\r
 //   +++\r
 //   +++\r
 //   +++\r
@@ -99,515 +99,515 @@ void DrawHorzCardStrip(HDC hdc, int x, int y, int nCardNum, int height, BOOL fDr
 //\r
 void DrawVertCardStrip(HDC hdc, int x, int y, int nCardNum, int width, BOOL fDrawTips)\r
 {\r
-       int sx  = nCardNum * __cardwidth;\r
-       int sy  = 0;\r
-       int one = 1;\r
-       int two = 2;\r
-       BOOL tips = fDrawTips ? FALSE : TRUE;\r
-\r
-       if(width == 0) return;\r
-       \r
-\r
-       if(width < 0)\r
-       {\r
-               sx = sx + __cardwidth;\r
-               x  -= width;\r
-               one = -1;\r
-               two = -2;\r
-       }\r
-\r
-       // draw the main vertical band\r
-       //\r
-       BitBlt(hdc, x, y + 2, width, __cardheight - 4, __hdcCardBitmaps, sx, sy+2, SRCCOPY);\r
-\r
-       //if(width <= 1) return;\r
-\r
-       // draw the "lips" at the top and bottom\r
-       BitBlt(hdc, x+one, y+1,              width-one*tips, 1, __hdcCardBitmaps, sx+one, sy + 1,              SRCCOPY);\r
-       BitBlt(hdc, x+one, y+__cardheight-2, width-one*tips, 1, __hdcCardBitmaps, sx+one, sy + __cardheight-2, SRCCOPY);\r
-\r
-       //if(width <= 2) return;\r
-\r
-       // draw the outer-most lips\r
-       BitBlt(hdc, x+two, y,                width-two*tips, 1, __hdcCardBitmaps, sx+two, sy,                  SRCCOPY);\r
-       BitBlt(hdc, x+two, y+__cardheight-1, width-two*tips, 1, __hdcCardBitmaps, sx+two, sy + __cardheight-1, SRCCOPY);\r
+    int sx  = nCardNum * __cardwidth;\r
+    int sy  = 0;\r
+    int one = 1;\r
+    int two = 2;\r
+    BOOL tips = fDrawTips ? FALSE : TRUE;\r
+\r
+    if(width == 0) return;\r
+    \r
+\r
+    if(width < 0)\r
+    {\r
+        sx = sx + __cardwidth;\r
+        x  -= width;\r
+        one = -1;\r
+        two = -2;\r
+    }\r
+\r
+    // draw the main vertical band\r
+    //\r
+    BitBlt(hdc, x, y + 2, width, __cardheight - 4, __hdcCardBitmaps, sx, sy+2, SRCCOPY);\r
+\r
+    //if(width <= 1) return;\r
+\r
+    // draw the "lips" at the top and bottom\r
+    BitBlt(hdc, x+one, y+1,              width-one*tips, 1, __hdcCardBitmaps, sx+one, sy + 1,              SRCCOPY);\r
+    BitBlt(hdc, x+one, y+__cardheight-2, width-one*tips, 1, __hdcCardBitmaps, sx+one, sy + __cardheight-2, SRCCOPY);\r
+\r
+    //if(width <= 2) return;\r
+\r
+    // draw the outer-most lips\r
+    BitBlt(hdc, x+two, y,                width-two*tips, 1, __hdcCardBitmaps, sx+two, sy,                  SRCCOPY);\r
+    BitBlt(hdc, x+two, y+__cardheight-1, width-two*tips, 1, __hdcCardBitmaps, sx+two, sy + __cardheight-1, SRCCOPY);\r
 }\r
 \r
 //\r
-//     xdir -   <0 or >0\r
-//     ydir -   <0 or >0\r
+//    xdir -   <0 or >0\r
+//    ydir -   <0 or >0\r
 //\r
 void DrawCardCorner(HDC hdc, int x, int y, int cardval, int xdir, int ydir)\r
 {\r
-       int sx = cardval * __cardwidth;\r
-       int sy = 0;\r
-\r
-       HDC hdcSource = __hdcCardBitmaps;\r
-\r
-       if(xdir < 0) \r
-       {\r
-               x  += __cardwidth + xdir - 1;\r
-               sx += __cardwidth + xdir - 1;\r
-       }\r
-       else\r
-       {\r
-               x  += xdir;\r
-               sx += xdir;\r
-       }\r
-\r
-       if(ydir < 0) \r
-       {\r
-               y  += __cardheight + ydir - 1;\r
-               sy += __cardheight + ydir - 1;\r
-       }\r
-       else\r
-       {\r
-               y  += ydir;\r
-               sy += ydir;\r
-       }\r
-\r
-       //convert x,y directions to -1, +1\r
-       xdir = xdir < 0 ? -1 : 1;\r
-       ydir = ydir < 0 ? -1 : 1;\r
-\r
-       SetPixel(hdc, x+xdir, y ,     GetPixel(hdcSource, sx+xdir, sy));\r
-       SetPixel(hdc, x,      y,      GetPixel(hdcSource, sx,      sy));\r
-       SetPixel(hdc, x,      y+ydir, GetPixel(hdcSource, sx,      sy+ydir));\r
+    int sx = cardval * __cardwidth;\r
+    int sy = 0;\r
+\r
+    HDC hdcSource = __hdcCardBitmaps;\r
+\r
+    if(xdir < 0) \r
+    {\r
+        x  += __cardwidth + xdir - 1;\r
+        sx += __cardwidth + xdir - 1;\r
+    }\r
+    else\r
+    {\r
+        x  += xdir;\r
+        sx += xdir;\r
+    }\r
+\r
+    if(ydir < 0) \r
+    {\r
+        y  += __cardheight + ydir - 1;\r
+        sy += __cardheight + ydir - 1;\r
+    }\r
+    else\r
+    {\r
+        y  += ydir;\r
+        sy += ydir;\r
+    }\r
+\r
+    //convert x,y directions to -1, +1\r
+    xdir = xdir < 0 ? -1 : 1;\r
+    ydir = ydir < 0 ? -1 : 1;\r
+\r
+    SetPixel(hdc, x+xdir, y ,     GetPixel(hdcSource, sx+xdir, sy));\r
+    SetPixel(hdc, x,      y,      GetPixel(hdcSource, sx,      sy));\r
+    SetPixel(hdc, x,      y+ydir, GetPixel(hdcSource, sx,      sy+ydir));\r
 \r
 }\r
 \r
 //\r
-//     Draw a card (i.e. miss out the corners)\r
+//    Draw a card (i.e. miss out the corners)\r
 //\r
 void DrawCard(HDC hdc, int x, int y, HDC hdcDragCard, int width, int height)\r
 {\r
-       //draw main center band\r
-       BitBlt(hdc, x+2, y, width - 4, height, hdcDragCard, 2, 0, SRCCOPY);\r
+    //draw main center band\r
+    BitBlt(hdc, x+2, y, width - 4, height, hdcDragCard, 2, 0, SRCCOPY);\r
 \r
-       //draw the two bits to the left\r
-       BitBlt(hdc, x,   y+2, 1, height - 4, hdcDragCard, 0, 2, SRCCOPY);\r
-       BitBlt(hdc, x+1, y+1, 1, height - 2, hdcDragCard, 1, 1, SRCCOPY);\r
+    //draw the two bits to the left\r
+    BitBlt(hdc, x,   y+2, 1, height - 4, hdcDragCard, 0, 2, SRCCOPY);\r
+    BitBlt(hdc, x+1, y+1, 1, height - 2, hdcDragCard, 1, 1, SRCCOPY);\r
 \r
-       //draw the two bits to the right\r
-       BitBlt(hdc, x+width-2, y+1, 1, height - 2, hdcDragCard, width-2, 1, SRCCOPY);\r
-       BitBlt(hdc, x+width-1, y+2, 1, height - 4, hdcDragCard, width-1, 2, SRCCOPY);\r
+    //draw the two bits to the right\r
+    BitBlt(hdc, x+width-2, y+1, 1, height - 2, hdcDragCard, width-2, 1, SRCCOPY);\r
+    BitBlt(hdc, x+width-1, y+2, 1, height - 4, hdcDragCard, width-1, 2, SRCCOPY);\r
 }\r
 \r
 //\r
-//     Clip a card SHAPE - basically any rectangle\r
+//    Clip a card SHAPE - basically any rectangle\r
 //  with rounded corners\r
 //\r
 int ClipCard(HDC hdc, int x, int y, int width, int height)\r
 {\r
-       ExcludeClipRect(hdc, x+2,               y,       x+2+width-4, y+  height);\r
-       ExcludeClipRect(hdc, x,                 y+2, x+1,                 y+2+height-4);\r
-       ExcludeClipRect(hdc, x+1,               y+1, x+2,                 y+1+height-2);\r
-       ExcludeClipRect(hdc, x+width-2, y+1, x+width-2+1, y+1+height-2);\r
-       ExcludeClipRect(hdc, x+width-1, y+2, x+width-1+1, y+2+height-4);\r
-       return 0;\r
+    ExcludeClipRect(hdc, x+2,        y,     x+2+width-4, y+  height);\r
+    ExcludeClipRect(hdc, x,            y+2, x+1,          y+2+height-4);\r
+    ExcludeClipRect(hdc, x+1,        y+1, x+2,          y+1+height-2);\r
+    ExcludeClipRect(hdc, x+width-2, y+1, x+width-2+1, y+1+height-2);\r
+    ExcludeClipRect(hdc, x+width-1, y+2, x+width-1+1, y+2+height-4);\r
+    return 0;\r
 }\r
 \r
 void CardRegion::Clip(HDC hdc)\r
 {\r
-       int numtoclip;\r
-\r
-       if(fVisible == false) \r
-               return;\r
-\r
-       Update();                               //Update this stack's size+card count\r
-       numtoclip = nNumApparentCards;\r
-\r
-       //if we are making this stack flash on/off, then only \r
-       //clip the stack for drawing if the flash is in its ON state\r
-       if(nFlashCount != 0)\r
-       {\r
-               if(fFlashVisible == FALSE)\r
-                       numtoclip = 0;\r
-       }\r
-\r
-       //if offset along a diagonal\r
-       if(xoffset != 0 && yoffset != 0 && cardstack.NumCards() != 0)\r
-       {\r
-               for(int j = 0; j < numtoclip; j ++)\r
-               {       \r
-                       ClipCard(hdc, xpos + xoffset * j, ypos + yoffset * j, __cardwidth, __cardheight);\r
-               }       \r
-       }\r
-       //otherwise if just offset along a horizontal/vertical axis\r
-       else\r
-       {\r
-               if(yoffset < 0 && numtoclip > 0)\r
-               {\r
-                       ClipCard(hdc, xpos, ypos-((numtoclip-1)*-yoffset), width, height);\r
-               }\r
-               else if(xoffset < 0 && numtoclip > 0)\r
-               {\r
-                       ClipCard(hdc, xpos-((numtoclip-1)*-xoffset), ypos, width, height);\r
-               }\r
-               else\r
-               {\r
-                       ClipCard(hdc, xpos, ypos, width, height);\r
-               }\r
-       }\r
+    int numtoclip;\r
+\r
+    if(fVisible == false) \r
+        return;\r
+\r
+    Update();                //Update this stack's size+card count\r
+    numtoclip = nNumApparentCards;\r
+\r
+    //if we are making this stack flash on/off, then only \r
+    //clip the stack for drawing if the flash is in its ON state\r
+    if(nFlashCount != 0)\r
+    {\r
+        if(fFlashVisible == FALSE)\r
+            numtoclip = 0;\r
+    }\r
+\r
+    //if offset along a diagonal\r
+    if(xoffset != 0 && yoffset != 0 && cardstack.NumCards() != 0)\r
+    {\r
+        for(int j = 0; j < numtoclip; j ++)\r
+        {    \r
+            ClipCard(hdc, xpos + xoffset * j, ypos + yoffset * j, __cardwidth, __cardheight);\r
+        }    \r
+    }\r
+    //otherwise if just offset along a horizontal/vertical axis\r
+    else\r
+    {\r
+        if(yoffset < 0 && numtoclip > 0)\r
+        {\r
+            ClipCard(hdc, xpos, ypos-((numtoclip-1)*-yoffset), width, height);\r
+        }\r
+        else if(xoffset < 0 && numtoclip > 0)\r
+        {\r
+            ClipCard(hdc, xpos-((numtoclip-1)*-xoffset), ypos, width, height);\r
+        }\r
+        else\r
+        {\r
+            ClipCard(hdc, xpos, ypos, width, height);\r
+        }\r
+    }\r
 \r
 }\r
 \r
 void CardRegion::Render(HDC hdc)\r
 {\r
-       int cardnum = 0;\r
-       int numtodraw;\r
-       BOOL fDrawTips;\r
-       \r
-       Update();                       //Update this stack's card count + size\r
-\r
-       numtodraw = nNumApparentCards;\r
-\r
-       if(nFlashCount != 0)\r
-       {\r
-               if(fFlashVisible == false)\r
-                       numtodraw = 0;\r
-       }\r
-\r
-       if(fVisible == 0) return;\r
-       \r
-       cardnum = cardstack.NumCards() - numtodraw;\r
-       int counter;\r
-\r
-       for(counter = 0; counter < numtodraw; counter++)\r
-       {\r
-               int cardval;\r
-               \r
-               int x = xoffset * counter + xpos;\r
-               int y = yoffset * counter + ypos;\r
-\r
-               //if about to draw last card, then actually draw the top card\r
-               if(counter == numtodraw - 1) cardnum = cardstack.NumCards() - 1;\r
-               \r
-               Card card = cardstack.cardlist[cardnum];\r
-               cardval = card.Idx();\r
-               \r
-               if(card.FaceDown())\r
-                       cardval = nBackCardIdx; //card-back\r
-                       \r
-               //only draw the visible part of the card\r
-               if(counter < numtodraw - 1)\r
-               {\r
-                       if(yoffset != 0 && xoffset != 0)\r
-                               fDrawTips = FALSE;\r
-                       else\r
-                               fDrawTips = TRUE;\r
-\r
-                       if(yoffset != 0 && abs(xoffset) == 1 || xoffset != 0 && abs(yoffset) == 1)\r
-                               fDrawTips = TRUE;\r
-\r
-                       //draw horizontal strips\r
-                       if(yoffset > 0) \r
-                       {\r
-                               DrawHorzCardStrip(hdc, x, y, cardval, yoffset, fDrawTips);\r
-                       }\r
-                       else if(yoffset < 0)\r
-                       {\r
-                               DrawHorzCardStrip(hdc, x, y+__cardheight+yoffset, cardval, yoffset, fDrawTips);\r
-                       }\r
-\r
-                       //draw some vertical bars\r
-                       if(xoffset > 0)\r
-                       {\r
-                               DrawVertCardStrip(hdc, x, y, cardval, xoffset, fDrawTips);\r
-                       }\r
-                       else if(xoffset < 0)\r
-                       {\r
-                               DrawVertCardStrip(hdc, x+__cardwidth+xoffset, y, cardval, xoffset, fDrawTips);\r
-                       }\r
-\r
-                       if(yoffset != 0 && xoffset != 0)//fDrawTips == FALSE)\r
-                       {\r
-                               //if we didn't draw any tips, then this is a 2-dim stack\r
-                               //(i.e, it goes at a diagonal).\r
-                               //in this case, we need to fill in the small triangle in\r
-                               //each corner!\r
-                               DrawCardCorner(hdc, x, y, cardval, xoffset, yoffset);\r
-                       }\r
-               }\r
-               //if the top card, draw the whole thing\r
-               else\r
-               {\r
-                       CardBlt(hdc, x, y, cardval);\r
-               }\r
-\r
-               cardnum ++;\r
-\r
-       } //end of index\r
-       \r
-       if(counter == 0)        //if the cardstack is empty, then draw it that way\r
-       {\r
-               int x = xpos;\r
-               int y = ypos;\r
-               \r
-               switch(uEmptyImage)\r
-               {\r
-               default: case CS_EI_NONE:\r
-                       //this wipes the RECT variable, so watch out!\r
-                       //SetRect(&rect, x, y, x+__cardwidth, y+__cardheight);\r
-                       //PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));\r
-                       parentWnd.PaintCardRgn(hdc, x, y, __cardwidth, __cardheight, x, y);\r
-                       break;\r
-                       \r
-               case CS_EI_SUNK:        //case CS_EI_CIRC: case CS_EI_X:\r
-                       DrawCard(hdc, x, y, __hdcPlaceHolder, __cardwidth, __cardheight);\r
-                       break;\r
-               }\r
-               \r
-       }\r
-\r
-       return;\r
+    int cardnum = 0;\r
+    int numtodraw;\r
+    BOOL fDrawTips;\r
+    \r
+    Update();            //Update this stack's card count + size\r
+\r
+    numtodraw = nNumApparentCards;\r
+\r
+    if(nFlashCount != 0)\r
+    {\r
+        if(fFlashVisible == false)\r
+            numtodraw = 0;\r
+    }\r
+\r
+    if(fVisible == 0) return;\r
+    \r
+    cardnum = cardstack.NumCards() - numtodraw;\r
+    int counter;\r
+\r
+    for(counter = 0; counter < numtodraw; counter++)\r
+    {\r
+        int cardval;\r
+        \r
+        int x = xoffset * counter + xpos;\r
+        int y = yoffset * counter + ypos;\r
+\r
+        //if about to draw last card, then actually draw the top card\r
+        if(counter == numtodraw - 1) cardnum = cardstack.NumCards() - 1;\r
+        \r
+        Card card = cardstack.cardlist[cardnum];\r
+        cardval = card.Idx();\r
+        \r
+        if(card.FaceDown())\r
+            cardval = nBackCardIdx;    //card-back\r
+            \r
+        //only draw the visible part of the card\r
+        if(counter < numtodraw - 1)\r
+        {\r
+            if(yoffset != 0 && xoffset != 0)\r
+                fDrawTips = FALSE;\r
+            else\r
+                fDrawTips = TRUE;\r
+\r
+            if(yoffset != 0 && abs(xoffset) == 1 ||    xoffset != 0 && abs(yoffset) == 1)\r
+                fDrawTips = TRUE;\r
+\r
+            //draw horizontal strips\r
+            if(yoffset > 0) \r
+            {\r
+                DrawHorzCardStrip(hdc, x, y, cardval, yoffset, fDrawTips);\r
+            }\r
+            else if(yoffset < 0)\r
+            {\r
+                DrawHorzCardStrip(hdc, x, y+__cardheight+yoffset, cardval, yoffset, fDrawTips);\r
+            }\r
+\r
+            //draw some vertical bars\r
+            if(xoffset > 0)\r
+            {\r
+                DrawVertCardStrip(hdc, x, y, cardval, xoffset, fDrawTips);\r
+            }\r
+            else if(xoffset < 0)\r
+            {\r
+                DrawVertCardStrip(hdc, x+__cardwidth+xoffset, y, cardval, xoffset, fDrawTips);\r
+            }\r
+\r
+            if(yoffset != 0 && xoffset != 0)//fDrawTips == FALSE)\r
+            {\r
+                //if we didn't draw any tips, then this is a 2-dim stack\r
+                //(i.e, it goes at a diagonal).\r
+                //in this case, we need to fill in the small triangle in\r
+                //each corner!\r
+                DrawCardCorner(hdc, x, y, cardval, xoffset, yoffset);\r
+            }\r
+        }\r
+        //if the top card, draw the whole thing\r
+        else\r
+        {\r
+            CardBlt(hdc, x, y, cardval);\r
+        }\r
+\r
+        cardnum ++;\r
+\r
+    } //end of index\r
+    \r
+    if(counter == 0)    //if the cardstack is empty, then draw it that way\r
+    {\r
+        int x = xpos;\r
+        int y = ypos;\r
+        \r
+        switch(uEmptyImage)\r
+        {\r
+        default: case CS_EI_NONE:\r
+            //this wipes the RECT variable, so watch out!\r
+            //SetRect(&rect, x, y, x+__cardwidth, y+__cardheight);\r
+            //PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));\r
+            parentWnd.PaintCardRgn(hdc, x, y, __cardwidth, __cardheight, x, y);\r
+            break;\r
+            \r
+        case CS_EI_SUNK:    //case CS_EI_CIRC: case CS_EI_X:\r
+            DrawCard(hdc, x, y, __hdcPlaceHolder, __cardwidth, __cardheight);\r
+            break;\r
+        }\r
+        \r
+    }\r
+\r
+    return;\r
 }\r
 \r
 int calc_offset(int offset, int numcards, int numtodrag, int realvisible)\r
 {\r
-       if(offset >= 0)\r
-               return -offset * numcards;\r
-       else\r
-               return -offset * (numtodrag)       + \r
-                          -offset * (realvisible - 1);\r
+    if(offset >= 0)\r
+        return -offset * numcards;\r
+    else\r
+        return -offset * (numtodrag)       + \r
+               -offset * (realvisible - 1);\r
 }\r
 \r
 void CardRegion::PrepareDragBitmaps(int numtodrag)\r
 {\r
-       RECT rect;\r
-       HDC hdc;\r
-       int icard;\r
-       int numcards = cardstack.NumCards();\r
-       int xoff, yoff;\r
-\r
-       if(nThreedCount > 1)\r
-       {\r
-               PrepareDragBitmapsThreed(numtodrag);\r
-               return;\r
-       }\r
-\r
-       //work out how big the bitmaps need to be\r
-       nDragCardWidth  = (numtodrag - 1) * abs(xoffset) + __cardwidth;\r
-       nDragCardHeight = (numtodrag - 1) * abs(yoffset) + __cardheight;\r
-\r
-       //Create bitmap for the back-buffer\r
-       hdc = GetDC(NULL);\r
-       hdcBackGnd = CreateCompatibleDC(hdc);\r
-       hbmBackGnd = CreateCompatibleBitmap(hdc, nDragCardWidth, nDragCardHeight);\r
-       SelectObject(hdcBackGnd, hbmBackGnd);\r
-\r
-       //Create bitmap for the drag-image\r
-       hdcDragCard = CreateCompatibleDC(hdc);\r
-       hbmDragCard = CreateCompatibleBitmap(hdc, nDragCardWidth, nDragCardHeight);\r
-       SelectObject(hdcDragCard, hbmDragCard);\r
-       ReleaseDC(NULL, hdc);\r
-\r
-       UseNicePalette(hdcBackGnd,  __hPalette);\r
-       UseNicePalette(hdcDragCard, __hPalette);\r
-\r
-       int realvisible = numcards / nThreedCount;\r
-\r
-       //if(numcards > 0 && realvisible == 0) realvisible = 1;\r
-       int iwhichcard = numcards - 1;\r
-       if(nThreedCount == 1) iwhichcard = 0;\r
-\r
-       //grab the first bit of background so we can prep the back buffer; do this by\r
-       //rendering the card stack (minus the card we are dragging) to the temporary\r
-       //background buffer, so it appears if we have lifted the card from the stack\r
-       //PaintRect(hdcBackGnd, &rect, crBackgnd);\r
-       SetRect(&rect, 0, 0, nDragCardWidth, nDragCardHeight);\r
+    RECT rect;\r
+    HDC hdc;\r
+    int icard;\r
+    int numcards = cardstack.NumCards();\r
+    int xoff, yoff;\r
+\r
+    if(nThreedCount > 1)\r
+    {\r
+        PrepareDragBitmapsThreed(numtodrag);\r
+        return;\r
+    }\r
+\r
+    //work out how big the bitmaps need to be\r
+    nDragCardWidth  = (numtodrag - 1) * abs(xoffset) + __cardwidth;\r
+    nDragCardHeight = (numtodrag - 1) * abs(yoffset) + __cardheight;\r
+\r
+    //Create bitmap for the back-buffer\r
+    hdc = GetDC(NULL);\r
+    hdcBackGnd = CreateCompatibleDC(hdc);\r
+    hbmBackGnd = CreateCompatibleBitmap(hdc, nDragCardWidth, nDragCardHeight);\r
+    SelectObject(hdcBackGnd, hbmBackGnd);\r
+\r
+    //Create bitmap for the drag-image\r
+    hdcDragCard = CreateCompatibleDC(hdc);\r
+    hbmDragCard = CreateCompatibleBitmap(hdc, nDragCardWidth, nDragCardHeight);\r
+    SelectObject(hdcDragCard, hbmDragCard);\r
+    ReleaseDC(NULL, hdc);\r
+\r
+    UseNicePalette(hdcBackGnd,  __hPalette);\r
+    UseNicePalette(hdcDragCard, __hPalette);\r
+\r
+    int realvisible = numcards / nThreedCount;\r
+\r
+    //if(numcards > 0 && realvisible == 0) realvisible = 1;\r
+    int iwhichcard = numcards - 1;\r
+    if(nThreedCount == 1) iwhichcard = 0;\r
+\r
+    //grab the first bit of background so we can prep the back buffer; do this by\r
+    //rendering the card stack (minus the card we are dragging) to the temporary\r
+    //background buffer, so it appears if we have lifted the card from the stack\r
+    //PaintRect(hdcBackGnd, &rect, crBackgnd);\r
+    SetRect(&rect, 0, 0, nDragCardWidth, nDragCardHeight);\r
  \r
-       xoff = calc_offset(xoffset, numcards, numtodrag, realvisible);\r
-       yoff = calc_offset(yoffset, numcards, numtodrag, realvisible);\r
-       \r
-       parentWnd.PaintCardRgn(hdcBackGnd, 0, 0, nDragCardWidth, nDragCardHeight, xpos - xoff,  ypos - yoff);\r
-\r
-       //\r
-       //      Render the cardstack into the back-buffer. The stack\r
-       //      has already had the dragcards removed, so just draw\r
-       //      what is left\r
-       //\r
-       for(icard = 0; icard < realvisible; icard++)\r
-       {\r
-               Card card = cardstack.cardlist[iwhichcard];\r
-               int nCardVal;\r
-               \r
-               nCardVal = card.FaceUp() ? card.Idx() : nBackCardIdx;\r
-\r
-               xoff = xoffset * icard + calc_offset(xoffset, numcards, numtodrag, realvisible);//- xoffset * ((numcards+numtodrag) / nThreedCount - numtodrag);\r
-               yoff = yoffset * icard + calc_offset(yoffset, numcards, numtodrag, realvisible);//- yoffset * ((numcards+numtodrag) / nThreedCount - numtodrag);\r
-\r
-               CardBlt(hdcBackGnd, xoff, yoff, nCardVal);\r
-               iwhichcard++;\r
-       }\r
-       \r
-       //\r
-       // If there are no cards under this one, just draw the place holder\r
-       //\r
-       if(numcards == 0)   \r
-       {\r
-               int xoff = 0, yoff = 0;\r
-\r
-               if(xoffset < 0) xoff = nDragCardWidth  -  __cardwidth;\r
-               if(yoffset < 0) yoff = nDragCardHeight -  __cardheight;\r
-\r
-               switch(uEmptyImage)\r
-               {\r
-               case CS_EI_NONE:\r
-                       //No need to draw anything: We already cleared the\r
-                       //back-buffer before the main loop..\r
-\r
-                       //SetRect(&rc, xoff, yoff, xoff+ __cardwidth, yoff + __cardheight);\r
-                       //PaintRect(hdcBackGnd, &rc, MAKE_PALETTERGB(crBackgnd));\r
-                       //parentWnd.PaintCardRgn(hdcBackGnd, xoff, yoff, __cardwidth, __cardheight, xpos, ypos);// + xoff, ypos + yoff);\r
-                       break;\r
-\r
-               case CS_EI_SUNK:\r
-                       DrawCard(hdcBackGnd, xoff, yoff, __hdcPlaceHolder, __cardwidth, __cardheight);\r
-                       break;\r
-               }\r
-       }\r
-\r
-       //\r
-       //      now render the drag-cards into the dragcard image\r
-       //\r
-       PaintRect(hdcDragCard, &rect, crBackgnd);\r
-\r
-       for(icard = 0; icard < numtodrag; icard++)\r
-       {\r
-               int nCardVal;\r
-\r
-               if(xoffset >= 0) xoff =  xoffset * icard;\r
-               else                     xoff = -xoffset * (numtodrag - icard - 1);\r
-                       \r
-               if(yoffset >= 0) yoff =  yoffset * icard;\r
-               else             yoff = -yoffset * (numtodrag - icard - 1);\r
-\r
-               Card card = dragstack.cardlist[icard];\r
-               \r
-               nCardVal = card.FaceUp() ? card.Idx() : nBackCardIdx;\r
-\r
-               CardBlt(hdcDragCard, xoff, yoff, nCardVal);\r
-       }\r
+    xoff = calc_offset(xoffset, numcards, numtodrag, realvisible);\r
+    yoff = calc_offset(yoffset, numcards, numtodrag, realvisible);\r
+    \r
+    parentWnd.PaintCardRgn(hdcBackGnd, 0, 0, nDragCardWidth, nDragCardHeight, xpos - xoff,    ypos - yoff);\r
+\r
+    //\r
+    //    Render the cardstack into the back-buffer. The stack\r
+    //    has already had the dragcards removed, so just draw\r
+    //    what is left\r
+    //\r
+    for(icard = 0; icard < realvisible; icard++)\r
+    {\r
+        Card card = cardstack.cardlist[iwhichcard];\r
+        int nCardVal;\r
+        \r
+        nCardVal = card.FaceUp() ? card.Idx() : nBackCardIdx;\r
+\r
+        xoff = xoffset * icard + calc_offset(xoffset, numcards, numtodrag, realvisible);//- xoffset * ((numcards+numtodrag) / nThreedCount - numtodrag);\r
+        yoff = yoffset * icard + calc_offset(yoffset, numcards, numtodrag, realvisible);//- yoffset * ((numcards+numtodrag) / nThreedCount - numtodrag);\r
+\r
+        CardBlt(hdcBackGnd, xoff, yoff, nCardVal);\r
+        iwhichcard++;\r
+    }\r
+    \r
+    //\r
+    // If there are no cards under this one, just draw the place holder\r
+    //\r
+    if(numcards == 0)   \r
+    {\r
+        int xoff = 0, yoff = 0;\r
+\r
+        if(xoffset < 0)    xoff = nDragCardWidth  -  __cardwidth;\r
+        if(yoffset < 0)    yoff = nDragCardHeight -  __cardheight;\r
+\r
+        switch(uEmptyImage)\r
+        {\r
+        case CS_EI_NONE:\r
+            //No need to draw anything: We already cleared the\r
+            //back-buffer before the main loop..\r
+\r
+            //SetRect(&rc, xoff, yoff, xoff+ __cardwidth, yoff + __cardheight);\r
+            //PaintRect(hdcBackGnd, &rc, MAKE_PALETTERGB(crBackgnd));\r
+            //parentWnd.PaintCardRgn(hdcBackGnd, xoff, yoff, __cardwidth, __cardheight, xpos, ypos);// + xoff, ypos + yoff);\r
+            break;\r
+\r
+        case CS_EI_SUNK:\r
+            DrawCard(hdcBackGnd, xoff, yoff, __hdcPlaceHolder, __cardwidth, __cardheight);\r
+            break;\r
+        }\r
+    }\r
+\r
+    //\r
+    //    now render the drag-cards into the dragcard image\r
+    //\r
+    PaintRect(hdcDragCard, &rect, crBackgnd);\r
+\r
+    for(icard = 0; icard < numtodrag; icard++)\r
+    {\r
+        int nCardVal;\r
+\r
+        if(xoffset >= 0) xoff =  xoffset * icard;\r
+        else              xoff = -xoffset * (numtodrag - icard - 1);\r
+            \r
+        if(yoffset >= 0) yoff =  yoffset * icard;\r
+        else             yoff = -yoffset * (numtodrag - icard - 1);\r
+\r
+        Card card = dragstack.cardlist[icard];\r
+        \r
+        nCardVal = card.FaceUp() ? card.Idx() : nBackCardIdx;\r
+\r
+        CardBlt(hdcDragCard, xoff, yoff, nCardVal);\r
+    }\r
 }\r
 \r
 void CardRegion::PrepareDragBitmapsThreed(int numtodrag)\r
 {\r
-       RECT rect;\r
-       HDC hdc;\r
-       int icard;\r
-       int numunder = 0;\r
-       int iwhichcard;\r
-\r
-       int numcards = cardstack.NumCards();\r
-\r
-       //work out how big the bitmaps need to be\r
-       nDragCardWidth  = (numtodrag - 1) * abs(xoffset) + __cardwidth;\r
-       nDragCardHeight = (numtodrag - 1) * abs(yoffset) + __cardheight;\r
-\r
-       //Create bitmap for the back-buffer\r
-       hdc = GetDC(NULL);\r
-       hdcBackGnd = CreateCompatibleDC(hdc);\r
-       hbmBackGnd = CreateCompatibleBitmap(hdc, nDragCardWidth, nDragCardHeight);\r
-       SelectObject(hdcBackGnd, hbmBackGnd);\r
-\r
-       //create bitmap for the drag-image\r
-       hdcDragCard = CreateCompatibleDC(hdc);\r
-       hbmDragCard = CreateCompatibleBitmap(hdc, nDragCardWidth, nDragCardHeight);\r
-       SelectObject(hdcDragCard, hbmDragCard);\r
-       ReleaseDC(NULL, hdc);\r
-\r
-       UseNicePalette(hdcBackGnd,  __hPalette);\r
-       UseNicePalette(hdcDragCard, __hPalette);\r
-\r
-       //grab the first bit of background so we can prep the back buffer; do this by\r
-       //rendering the card stack (minus the card we are dragging) to the temporary\r
-       //background buffer, so it appears if we have lifted the card from the stack\r
-       //--SetRect(&rect, 0, 0, nDragCardWidth, nDragCardHeight);\r
-       //--PaintRect(hdcBackGnd, &rect, crBackgnd);\r
-\r
-       int threedadjust = numcards  % nThreedCount == 0;\r
-       \r
-       numunder = CalcApparentCards(numcards);\r
-       iwhichcard = (numcards+numtodrag) - numunder - 1;\r
-       if(nThreedCount == 1) iwhichcard = 0;\r
-       \r
-       int xoff = calc_offset(xoffset, numunder, numtodrag, numunder);\r
-       int yoff = calc_offset(yoffset, numunder, numtodrag, numunder);\r
-\r
-       parentWnd.PaintCardRgn(hdcBackGnd, 0,0, nDragCardWidth,nDragCardHeight, xpos - xoff,ypos - yoff);\r
-\r
-       //\r
-       //      Render the cardstack into the back-buffer. The stack\r
-       //      has already had the dragcards removed, so just draw\r
-       //      what is left\r
-       //\r
-       for(icard = 0; icard < numunder; icard++)\r
-       {\r
-               Card card = cardstack.cardlist[iwhichcard];\r
-               int nCardVal = card.FaceUp() ? card.Idx() : nBackCardIdx;\r
-\r
-               CardBlt(hdcBackGnd, \r
-                               xoffset * icard - xoffset*(numunder-numtodrag+threedadjust),\r
-                               yoffset * icard - yoffset*(numunder-numtodrag+threedadjust),\r
-                               nCardVal);\r
-\r
-               iwhichcard++;\r
-       }\r
-       \r
-       //\r
-       // If there are no cards under this one, just draw the place holder\r
-       //\r
-       if(numcards == 0)   \r
-       {\r
-               switch(uEmptyImage)\r
-               {\r
-               case CS_EI_NONE:\r
-                       //no need! we've already cleared the whole\r
-                       //back-buffer before the main loop!\r
-                       //SetRect(&rect, 0, 0, __cardwidth, __cardheight);\r
-                       //PaintRect(hdcBackGnd, &rect, MAKE_PALETTERGB(crBackgnd));\r
-                       break;\r
-\r
-               case CS_EI_SUNK:\r
-                       DrawCard(hdcBackGnd, 0, 0, __hdcPlaceHolder, __cardwidth, __cardheight);\r
-                       break;\r
-       \r
-               }\r
-       }\r
-\r
-       //\r
-       //      now render the drag-cards into the dragcard image\r
-       //\r
-       PaintRect(hdcDragCard, &rect, crBackgnd);\r
-       \r
-       for(icard = 0; icard < numtodrag; icard++)\r
-       {\r
-               Card card = dragstack.cardlist[icard];\r
-               int nCardVal = card.FaceUp() ? card.Idx() : nBackCardIdx;\r
-\r
-               CardBlt(hdcDragCard, xoffset * icard, yoffset * icard, nCardVal);\r
-       }\r
+    RECT rect;\r
+    HDC hdc;\r
+    int icard;\r
+    int numunder = 0;\r
+    int iwhichcard;\r
+\r
+    int numcards = cardstack.NumCards();\r
+\r
+    //work out how big the bitmaps need to be\r
+    nDragCardWidth  = (numtodrag - 1) * abs(xoffset) + __cardwidth;\r
+    nDragCardHeight = (numtodrag - 1) * abs(yoffset) + __cardheight;\r
+\r
+    //Create bitmap for the back-buffer\r
+    hdc = GetDC(NULL);\r
+    hdcBackGnd = CreateCompatibleDC(hdc);\r
+    hbmBackGnd = CreateCompatibleBitmap(hdc, nDragCardWidth, nDragCardHeight);\r
+    SelectObject(hdcBackGnd, hbmBackGnd);\r
+\r
+    //create bitmap for the drag-image\r
+    hdcDragCard = CreateCompatibleDC(hdc);\r
+    hbmDragCard = CreateCompatibleBitmap(hdc, nDragCardWidth, nDragCardHeight);\r
+    SelectObject(hdcDragCard, hbmDragCard);\r
+    ReleaseDC(NULL, hdc);\r
+\r
+    UseNicePalette(hdcBackGnd,  __hPalette);\r
+    UseNicePalette(hdcDragCard, __hPalette);\r
+\r
+    //grab the first bit of background so we can prep the back buffer; do this by\r
+    //rendering the card stack (minus the card we are dragging) to the temporary\r
+    //background buffer, so it appears if we have lifted the card from the stack\r
+    //--SetRect(&rect, 0, 0, nDragCardWidth, nDragCardHeight);\r
+    //--PaintRect(hdcBackGnd, &rect, crBackgnd);\r
+\r
+    int threedadjust = numcards  % nThreedCount == 0;\r
+    \r
+    numunder = CalcApparentCards(numcards);\r
+    iwhichcard = (numcards+numtodrag) - numunder - 1;\r
+    if(nThreedCount == 1) iwhichcard = 0;\r
+    \r
+    int xoff = calc_offset(xoffset, numunder, numtodrag, numunder);\r
+    int yoff = calc_offset(yoffset, numunder, numtodrag, numunder);\r
+\r
+    parentWnd.PaintCardRgn(hdcBackGnd, 0,0,    nDragCardWidth,nDragCardHeight,    xpos - xoff,ypos - yoff);\r
+\r
+    //\r
+    //    Render the cardstack into the back-buffer. The stack\r
+    //    has already had the dragcards removed, so just draw\r
+    //    what is left\r
+    //\r
+    for(icard = 0; icard < numunder; icard++)\r
+    {\r
+        Card card = cardstack.cardlist[iwhichcard];\r
+        int nCardVal = card.FaceUp() ? card.Idx() : nBackCardIdx;\r
+\r
+        CardBlt(hdcBackGnd, \r
+                xoffset * icard - xoffset*(numunder-numtodrag+threedadjust),\r
+                yoffset * icard - yoffset*(numunder-numtodrag+threedadjust),\r
+                nCardVal);\r
+\r
+        iwhichcard++;\r
+    }\r
+    \r
+    //\r
+    // If there are no cards under this one, just draw the place holder\r
+    //\r
+    if(numcards == 0)   \r
+    {\r
+        switch(uEmptyImage)\r
+        {\r
+        case CS_EI_NONE:\r
+            //no need! we've already cleared the whole\r
+            //back-buffer before the main loop!\r
+            //SetRect(&rect, 0, 0, __cardwidth, __cardheight);\r
+            //PaintRect(hdcBackGnd, &rect, MAKE_PALETTERGB(crBackgnd));\r
+            break;\r
+\r
+        case CS_EI_SUNK:\r
+            DrawCard(hdcBackGnd, 0, 0, __hdcPlaceHolder, __cardwidth, __cardheight);\r
+            break;\r
+    \r
+        }\r
+    }\r
+\r
+    //\r
+    //    now render the drag-cards into the dragcard image\r
+    //\r
+    PaintRect(hdcDragCard, &rect, crBackgnd);\r
+    \r
+    for(icard = 0; icard < numtodrag; icard++)\r
+    {\r
+        Card card = dragstack.cardlist[icard];\r
+        int nCardVal = card.FaceUp() ? card.Idx() : nBackCardIdx;\r
+\r
+        CardBlt(hdcDragCard, xoffset * icard, yoffset * icard, nCardVal);\r
+    }\r
 }\r
 \r
 void CardRegion::ReleaseDragBitmaps(void)\r
 {\r
-       //SelectObject(hdcBackGnd, hOld1);\r
-       DeleteObject(hbmBackGnd);\r
-       DeleteDC(hdcBackGnd);\r
+    //SelectObject(hdcBackGnd, hOld1);\r
+    DeleteObject(hbmBackGnd);\r
+    DeleteDC(hdcBackGnd);\r
 \r
-       //SelectObject(hdcDragCard, hOld2);\r
-       DeleteObject(hbmDragCard);\r
-       DeleteDC(hdcDragCard);\r
+    //SelectObject(hdcDragCard, hOld2);\r
+    DeleteObject(hbmDragCard);\r
+    DeleteDC(hdcDragCard);\r
 }\r
 \r
 \r
 void CardRegion::Redraw()\r
 {\r
-       HDC hdc = GetDC((HWND)parentWnd);\r
+    HDC hdc = GetDC((HWND)parentWnd);\r
 \r
-       Update();\r
-       Render(hdc);\r
+    Update();\r
+    Render(hdc);\r
 \r
-       ReleaseDC((HWND)parentWnd, hdc);\r
+    ReleaseDC((HWND)parentWnd, hdc);\r
 }\r
index 4e9bd52..317986a 100644 (file)
@@ -1,8 +1,8 @@
 //\r
-//     CardLib - CardRegion mouse-related stuff\r
+//    CardLib - CardRegion mouse-related stuff\r
 //\r
-//     Freeware\r
-//     Copyright J Brown 2001\r
+//    Freeware\r
+//    Copyright J Brown 2001\r
 //\r
 #include <windows.h>\r
 #include <math.h>\r
@@ -29,454 +29,454 @@ static pDebugClickProc DebugStackClickProc = 0;
 \r
 void CardLib_SetStackClickProc(pDebugClickProc proc)\r
 {\r
-       DebugStackClickProc = proc;\r
+    DebugStackClickProc = proc;\r
 }\r
 \r
 #endif\r
 \r
 CardRegion *CardWindow::GetBestStack(int x, int y, int w, int h)\r
 {\r
-       int maxoverlap    =  0;\r
-       int maxoverlapidx = -1;\r
-\r
-       //find the stack which is most covered by the dropped\r
-       //cards. Only include those which allow drops.\r
-       //\r
-       for(int i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               int percent = Regions[i]->GetOverlapRatio(x, y, w, h);\r
-\r
-               //if this stack has the biggest coverage yet\r
-               if(percent > maxoverlap && Regions[i]->IsVisible())\r
-               {\r
-                       maxoverlap = percent;\r
-                       maxoverlapidx = i;\r
-               }\r
-       }\r
-       \r
-       //if we found a stack to drop onto\r
-       if(maxoverlapidx != -1)\r
-       {\r
-               return Regions[maxoverlapidx];\r
-       }\r
-       else\r
-       {\r
-               return 0;\r
-       }\r
+    int maxoverlap    =  0;\r
+    int maxoverlapidx = -1;\r
+\r
+    //find the stack which is most covered by the dropped\r
+    //cards. Only include those which allow drops.\r
+    //\r
+    for(int i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        int percent = Regions[i]->GetOverlapRatio(x, y, w, h);\r
+\r
+        //if this stack has the biggest coverage yet\r
+        if(percent > maxoverlap && Regions[i]->IsVisible())\r
+        {\r
+            maxoverlap = percent;\r
+            maxoverlapidx = i;\r
+        }\r
+    }\r
+    \r
+    //if we found a stack to drop onto\r
+    if(maxoverlapidx != -1)\r
+    {\r
+        return Regions[maxoverlapidx];\r
+    }\r
+    else\r
+    {\r
+        return 0;\r
+    }\r
 }\r
 \r
 bool CardRegion::IsPointInStack(int x, int y)\r
 {\r
-       int axpos = xoffset < 0 ? xpos + (nNumApparentCards-1)*xoffset : xpos;\r
-       int aypos = yoffset < 0 ? ypos + (nNumApparentCards-1)*yoffset : ypos;\r
-       \r
-       if(x >= axpos && x < axpos + width && y >= aypos && y < aypos + height && fVisible)\r
-               return true;\r
-       else\r
-               return false;\r
+    int axpos = xoffset < 0 ? xpos + (nNumApparentCards-1)*xoffset : xpos;\r
+    int aypos = yoffset < 0 ? ypos + (nNumApparentCards-1)*yoffset : ypos;\r
+    \r
+    if(x >= axpos && x < axpos + width && y >= aypos && y < aypos + height && fVisible)\r
+        return true;\r
+    else\r
+        return false;\r
 }\r
 \r
 int CardRegion::GetNumDragCards(int x, int y)\r
 {\r
-       int cardindex = 0;              //index from stack start\r
-       int maxidx;\r
-\r
-       //make x,y relative to the stack's upper left corner\r
-       x -= xpos + (xoffset < 0 ? (nNumApparentCards/*cardstack.NumCards()*/ - 1) * xoffset : 0);\r
-       y -= ypos + (yoffset < 0 ? (nNumApparentCards/*cardstack.NumCards()*/ - 1) * yoffset : 0);\r
-       \r
-       //if stack is empty, cannot drag any cards from it\r
-       if(cardstack.NumCards() <= 0)\r
-               return 0;\r
-\r
-       //see which card in the stack has been clicked on\r
-       //top-bottom ordering\r
-       if(yoffset > 0)\r
-       {\r
-               if(y < height - __cardheight)\r
-                       cardindex = y / yoffset;\r
-               else\r
-                       cardindex = cardstack.NumCards() - 1;\r
-       }\r
-       else if(yoffset < 0)\r
-       {\r
-               if(y < __cardheight)\r
-                       cardindex = cardstack.NumCards() - 1;\r
-               else\r
-                       cardindex = cardstack.NumCards() - ((y - __cardheight) / -yoffset) - 2;\r
-       }\r
-       else    //yoffset == 0\r
-       {\r
-               cardindex = cardstack.NumCards() - 1;\r
-       }\r
-\r
-       maxidx = cardindex;\r
-\r
-       //if left-right\r
-       if(xoffset > 0)\r
-       {\r
-               if(x < width - __cardwidth)\r
-                       cardindex = x / xoffset;\r
-               else\r
-                       cardindex = cardstack.NumCards() - 1;\r
-       }\r
-       else if(xoffset < 0)\r
-       {\r
-               if(x < __cardwidth)\r
-                       cardindex = cardstack.NumCards() - 1;\r
-               else\r
-                       cardindex = cardstack.NumCards() - ((x - __cardwidth) / -xoffset) - 2;\r
-       }\r
-       else\r
-       {\r
-               cardindex = cardstack.NumCards() - 1;\r
-       }\r
-\r
-       if(cardindex > maxidx) cardindex = maxidx;\r
-\r
-       if(cardindex > cardstack.NumCards())\r
-               cardindex = 1;\r
-\r
-       //if are trying to drag too many cards at once\r
-       return cardstack.NumCards() - cardindex;\r
+    int cardindex = 0;        //index from stack start\r
+    int maxidx;\r
+\r
+    //make x,y relative to the stack's upper left corner\r
+    x -= xpos + (xoffset < 0 ? (nNumApparentCards/*cardstack.NumCards()*/ - 1) * xoffset : 0);\r
+    y -= ypos + (yoffset < 0 ? (nNumApparentCards/*cardstack.NumCards()*/ - 1) * yoffset : 0);\r
+    \r
+    //if stack is empty, cannot drag any cards from it\r
+    if(cardstack.NumCards() <= 0)\r
+        return 0;\r
+\r
+    //see which card in the stack has been clicked on\r
+    //top-bottom ordering\r
+    if(yoffset > 0)\r
+    {\r
+        if(y < height - __cardheight)\r
+            cardindex = y / yoffset;\r
+        else\r
+            cardindex = cardstack.NumCards() - 1;\r
+    }\r
+    else if(yoffset < 0)\r
+    {\r
+        if(y < __cardheight)\r
+            cardindex = cardstack.NumCards() - 1;\r
+        else\r
+            cardindex = cardstack.NumCards() - ((y - __cardheight) / -yoffset) - 2;\r
+    }\r
+    else    //yoffset == 0\r
+    {\r
+        cardindex = cardstack.NumCards() - 1;\r
+    }\r
+\r
+    maxidx = cardindex;\r
+\r
+    //if left-right\r
+    if(xoffset > 0)\r
+    {\r
+        if(x < width - __cardwidth)\r
+            cardindex = x / xoffset;\r
+        else\r
+            cardindex = cardstack.NumCards() - 1;\r
+    }\r
+    else if(xoffset < 0)\r
+    {\r
+        if(x < __cardwidth)\r
+            cardindex = cardstack.NumCards() - 1;\r
+        else\r
+            cardindex = cardstack.NumCards() - ((x - __cardwidth) / -xoffset) - 2;\r
+    }\r
+    else\r
+    {\r
+        cardindex = cardstack.NumCards() - 1;\r
+    }\r
+\r
+    if(cardindex > maxidx) cardindex = maxidx;\r
+\r
+    if(cardindex > cardstack.NumCards())\r
+        cardindex = 1;\r
+\r
+    //if are trying to drag too many cards at once\r
+    return cardstack.NumCards() - cardindex;\r
 }\r
 \r
 bool CardRegion::CanDragCards(int iNumCards)\r
 {\r
-       if(iNumCards <= 0) return false;\r
-       if(nThreedCount > 1 && iNumCards > 1) return false;\r
-\r
-       if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)\r
-       {\r
-//             TRACE("Failed to gain access to card stack\n");\r
-               return false;\r
-       }\r
-\r
-       ReleaseMutex(mxlock);\r
-\r
-       switch(uDragRule)\r
-       {\r
-       case CS_DRAG_ALL:\r
-               return true;\r
-               \r
-       case CS_DRAG_TOP:\r
-\r
-               if(iNumCards == 1)\r
-                       return true;\r
-               else\r
-                       return false;\r
-               \r
-       case CS_DRAG_NONE:\r
-               return false;\r
-               \r
-       case CS_DRAG_CALLBACK:\r
-               \r
-               if(CanDragCallback)\r
-               {\r
-                       return CanDragCallback(*this, iNumCards);\r
-               }\r
-               else\r
-               {\r
-                       return false;\r
-               }\r
-               \r
-       default:\r
-               return false;\r
-       }\r
+    if(iNumCards <= 0) return false;\r
+    if(nThreedCount > 1 && iNumCards > 1) return false;\r
+\r
+    if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)\r
+    {\r
+//        TRACE("Failed to gain access to card stack\n");\r
+        return false;\r
+    }\r
+\r
+    ReleaseMutex(mxlock);\r
+\r
+    switch(uDragRule)\r
+    {\r
+    case CS_DRAG_ALL:\r
+        return true;\r
+        \r
+    case CS_DRAG_TOP:\r
+\r
+        if(iNumCards == 1)\r
+            return true;\r
+        else\r
+            return false;\r
+        \r
+    case CS_DRAG_NONE:\r
+        return false;\r
+        \r
+    case CS_DRAG_CALLBACK:\r
+        \r
+        if(CanDragCallback)\r
+        {\r
+            return CanDragCallback(*this, iNumCards);\r
+        }\r
+        else\r
+        {\r
+            return false;\r
+        }\r
+        \r
+    default:\r
+        return false;\r
+    }\r
 }\r
 \r
 bool CardRegion::CanDropCards(CardStack &cards)\r
 {\r
-       if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)\r
-       {\r
-               return false;\r
-       }\r
-\r
-       ReleaseMutex(mxlock);\r
-\r
-       switch(uDropRule)\r
-       {\r
-       case CS_DROP_ALL:\r
-               return true;\r
-\r
-       case CS_DROP_NONE:\r
-               return false;\r
-\r
-       case CS_DROP_CALLBACK:\r
-               \r
-               if(CanDropCallback)\r
-               {\r
-                       return CanDropCallback(*this, cards);\r
-               }\r
-               else\r
-               {\r
-                       return false;\r
-               }\r
-\r
-       default:\r
-               return false;\r
-       }\r
+    if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)\r
+    {\r
+        return false;\r
+    }\r
+\r
+    ReleaseMutex(mxlock);\r
+\r
+    switch(uDropRule)\r
+    {\r
+    case CS_DROP_ALL:\r
+        return true;\r
+\r
+    case CS_DROP_NONE:\r
+        return false;\r
+\r
+    case CS_DROP_CALLBACK:\r
+        \r
+        if(CanDropCallback)\r
+        {\r
+            return CanDropCallback(*this, cards);\r
+        }\r
+        else\r
+        {\r
+            return false;\r
+        }\r
+\r
+    default:\r
+        return false;\r
+    }\r
 }\r
 \r
 bool CardRegion::OnLButtonDblClk(int x, int y)\r
 {\r
-       iNumDragCards = GetNumDragCards(x, y); \r
+    iNumDragCards = GetNumDragCards(x, y); \r
 \r
-       if(DblClickCallback)\r
-               DblClickCallback(*this, iNumDragCards);\r
+    if(DblClickCallback)\r
+        DblClickCallback(*this, iNumDragCards);\r
 \r
-       return true;\r
+    return true;\r
 }\r
 \r
 bool CardRegion::OnLButtonDown(int x, int y)\r
 {\r
-       iNumDragCards = GetNumDragCards(x, y); \r
+    iNumDragCards = GetNumDragCards(x, y); \r
 \r
 #ifdef _DEBUG\r
-       if(DebugStackClickProc)\r
-       {\r
-               if(!DebugStackClickProc(*this))\r
-                       return false;\r
-       }\r
+    if(DebugStackClickProc)\r
+    {\r
+        if(!DebugStackClickProc(*this))\r
+            return false;\r
+    }\r
 #endif\r
 \r
-       if(ClickCallback)\r
-               ClickCallback(*this, iNumDragCards);\r
+    if(ClickCallback)\r
+        ClickCallback(*this, iNumDragCards);\r
 \r
-       if(CanDragCards(iNumDragCards) != false)\r
+    if(CanDragCards(iNumDragCards) != false)\r
     {\r
 \r
-               //offset of the mouse cursor relative to the top-left corner\r
-               //of the cards that are being dragged\r
-               mousexoffset = x - xpos - xoffset * (nNumApparentCards - iNumDragCards);\r
-               mouseyoffset = y - ypos - yoffset * (nNumApparentCards - iNumDragCards);\r
-               \r
-               if(xoffset < 0)\r
-                       mousexoffset += -xoffset * (iNumDragCards - 1);\r
+        //offset of the mouse cursor relative to the top-left corner\r
+        //of the cards that are being dragged\r
+        mousexoffset = x - xpos - xoffset * (nNumApparentCards - iNumDragCards);\r
+        mouseyoffset = y - ypos - yoffset * (nNumApparentCards - iNumDragCards);\r
+        \r
+        if(xoffset < 0)\r
+            mousexoffset += -xoffset * (iNumDragCards - 1);\r
 \r
-               if(yoffset < 0)\r
-                       mouseyoffset += -yoffset * (iNumDragCards - 1);\r
-               \r
-               //remove the cards from the source stack\r
-               dragstack = cardstack.Pop(iNumDragCards);\r
+        if(yoffset < 0)\r
+            mouseyoffset += -yoffset * (iNumDragCards - 1);\r
+        \r
+        //remove the cards from the source stack\r
+        dragstack = cardstack.Pop(iNumDragCards);\r
 \r
-               //prepare the back buffer, and the drag image\r
-               PrepareDragBitmaps(iNumDragCards);\r
+        //prepare the back buffer, and the drag image\r
+        PrepareDragBitmaps(iNumDragCards);\r
 \r
-               oldx = x - mousexoffset;\r
-               oldy = y - mouseyoffset;\r
-               \r
-               Update();                       //Update this stack's card count + size\r
+        oldx = x - mousexoffset;\r
+        oldy = y - mouseyoffset;\r
+        \r
+        Update();            //Update this stack's card count + size\r
 \r
-               SetCapture((HWND)parentWnd);\r
+        SetCapture((HWND)parentWnd);\r
 \r
-               //set AFTER settings the dragstack...\r
-               fMouseDragging = true;\r
+        //set AFTER settings the dragstack...\r
+        fMouseDragging = true;\r
 \r
-               return true;\r
-       }\r
+        return true;\r
+    }\r
 \r
-       return false;\r
+    return false;\r
 }\r
 \r
 bool CardRegion::OnLButtonUp(int x, int y)\r
 {\r
-       CardRegion *pDestStack = 0;\r
-       HDC hdc;\r
-       int dropstackid = CS_DROPZONE_NODROP;\r
-       \r
-       RECT dragrect;\r
-       DropZone *dropzone;\r
-\r
-       fMouseDragging = false;\r
-\r
-       //first of all, see if any drop zones have been registered\r
-       SetRect(&dragrect, x-mousexoffset, y-mouseyoffset, x-mousexoffset+nDragCardWidth, y-mouseyoffset+nDragCardHeight);\r
-\r
-       dropzone = parentWnd.GetDropZoneFromRect(&dragrect);\r
-\r
-       if(dropzone)\r
-       {\r
-               dropstackid = dropzone->DropCards(dragstack);\r
-               \r
-               if(dropstackid != CS_DROPZONE_NODROP)\r
-                       pDestStack = parentWnd.CardRegionFromId(dropstackid);\r
-               else\r
-                       pDestStack = 0;\r
-       }\r
-       else\r
-       {\r
-               pDestStack = parentWnd.GetBestStack(x - mousexoffset, y - mouseyoffset, nDragCardWidth, nDragCardHeight);\r
-       }\r
-       \r
-       // If have found a stack to drop onto\r
-       //\r
-       TRACE ( "can I drop card?\n" );\r
-       if(pDestStack && pDestStack->CanDropCards(dragstack)) \r
-       {\r
-               TRACE ( "yes, dropping card\n" );\r
-               hdc = GetDC((HWND)parentWnd);\r
-               //                      UseNicePalette(hdc);\r
-               ZoomCard(hdc, x - mousexoffset, y  - mouseyoffset, pDestStack);\r
-               ReleaseDC((HWND)parentWnd, hdc);\r
-               \r
-               //\r
-               //add the cards to the destination stack\r
-               //\r
-               CardStack temp = pDestStack->GetCardStack();\r
-               temp.Push(dragstack);\r
-               \r
-               pDestStack->SetCardStack(temp);\r
-//             pDestStack->Update();           //Update this stack's card count + size\r
-//             pDestStack->UpdateFaceDir(temp);\r
-               \r
-               //      Call the remove callback on THIS stack, if one is specified\r
-               //\r
-               if(RemoveCallback)\r
-                       RemoveCallback(*this, iNumDragCards);\r
-\r
-               //      Call the add callback, if one is specified\r
-               //\r
-               if(pDestStack->AddCallback)\r
-                       pDestStack->AddCallback(*pDestStack, pDestStack->cardstack);//index, deststack->numcards);\r
-               \r
-               RedrawIfNotDim(pDestStack, true);\r
-               TRACE ( "done dropping card\n" );\r
-       }\r
-\r
-       //\r
-       //      Otherwise, let the cards snap back onto this stack\r
-       //\r
-       else\r
-       {\r
-               TRACE ( "no, putting card back\n" );\r
-               hdc = GetDC((HWND)parentWnd);\r
-               TRACE ( "calling ZoomCard()\n" );\r
-               ZoomCard(hdc, x - mousexoffset, y - mouseyoffset, this);\r
-               TRACE ( "cardstack += dragstack\n" );\r
-               cardstack += dragstack;\r
-               TRACE ( "calling ReleaseDC()\n" );\r
-               ReleaseDC((HWND)parentWnd, hdc);\r
-\r
-               TRACE ( "calling Update()\n" );\r
-               Update();               //Update this stack's card count + size\r
-               TRACE ( "done putting card back\n" );\r
-       }\r
-       \r
-       ReleaseDragBitmaps();\r
-       ReleaseCapture();\r
-       \r
-       TRACE ( "OnLButtonUp() done\n" );\r
-       return true;\r
+    CardRegion *pDestStack = 0;\r
+    HDC hdc;\r
+    int dropstackid = CS_DROPZONE_NODROP;\r
+    \r
+    RECT dragrect;\r
+    DropZone *dropzone;\r
+\r
+    fMouseDragging = false;\r
+\r
+    //first of all, see if any drop zones have been registered\r
+    SetRect(&dragrect, x-mousexoffset, y-mouseyoffset, x-mousexoffset+nDragCardWidth, y-mouseyoffset+nDragCardHeight);\r
+\r
+    dropzone = parentWnd.GetDropZoneFromRect(&dragrect);\r
+\r
+    if(dropzone)\r
+    {\r
+        dropstackid = dropzone->DropCards(dragstack);\r
+        \r
+        if(dropstackid != CS_DROPZONE_NODROP)\r
+            pDestStack = parentWnd.CardRegionFromId(dropstackid);\r
+        else\r
+            pDestStack = 0;\r
+    }\r
+    else\r
+    {\r
+        pDestStack = parentWnd.GetBestStack(x - mousexoffset, y - mouseyoffset, nDragCardWidth, nDragCardHeight);\r
+    }\r
+    \r
+    // If have found a stack to drop onto\r
+    //\r
+    TRACE ( "can I drop card?\n" );\r
+    if(pDestStack && pDestStack->CanDropCards(dragstack)) \r
+    {\r
+        TRACE ( "yes, dropping card\n" );\r
+        hdc = GetDC((HWND)parentWnd);\r
+        //            UseNicePalette(hdc);\r
+        ZoomCard(hdc, x - mousexoffset, y  - mouseyoffset, pDestStack);\r
+        ReleaseDC((HWND)parentWnd, hdc);\r
+        \r
+        //\r
+        //add the cards to the destination stack\r
+        //\r
+        CardStack temp = pDestStack->GetCardStack();\r
+        temp.Push(dragstack);\r
+        \r
+        pDestStack->SetCardStack(temp);\r
+//        pDestStack->Update();        //Update this stack's card count + size\r
+//        pDestStack->UpdateFaceDir(temp);\r
+        \r
+        //    Call the remove callback on THIS stack, if one is specified\r
+        //\r
+        if(RemoveCallback)\r
+            RemoveCallback(*this, iNumDragCards);\r
+\r
+        //    Call the add callback, if one is specified\r
+        //\r
+        if(pDestStack->AddCallback)\r
+            pDestStack->AddCallback(*pDestStack, pDestStack->cardstack);//index, deststack->numcards);\r
+        \r
+        RedrawIfNotDim(pDestStack, true);\r
+        TRACE ( "done dropping card\n" );\r
+    }\r
+\r
+    //\r
+    //    Otherwise, let the cards snap back onto this stack\r
+    //\r
+    else\r
+    {\r
+        TRACE ( "no, putting card back\n" );\r
+        hdc = GetDC((HWND)parentWnd);\r
+        TRACE ( "calling ZoomCard()\n" );\r
+        ZoomCard(hdc, x - mousexoffset, y - mouseyoffset, this);\r
+        TRACE ( "cardstack += dragstack\n" );\r
+        cardstack += dragstack;\r
+        TRACE ( "calling ReleaseDC()\n" );\r
+        ReleaseDC((HWND)parentWnd, hdc);\r
+\r
+        TRACE ( "calling Update()\n" );\r
+        Update();        //Update this stack's card count + size\r
+        TRACE ( "done putting card back\n" );\r
+    }\r
+    \r
+    ReleaseDragBitmaps();\r
+    ReleaseCapture();\r
+    \r
+    TRACE ( "OnLButtonUp() done\n" );\r
+    return true;\r
 }\r
 \r
 bool CardRegion::OnMouseMove(int x, int y)\r
 {\r
-       HDC hdc;\r
-\r
-       hdc = GetDC((HWND)parentWnd);\r
-               \r
-       x -= mousexoffset;\r
-       y -= mouseyoffset;\r
-               \r
-       MoveDragCardTo(hdc, x, y);\r
-\r
-       //BitBlt(hdc, nDragCardWidth+10, 0, nDragCardWidth, nDragCardHeight, hdcBackGnd, 0, 0, SRCCOPY);\r
-       //BitBlt(hdc, 0, 0, nDragCardWidth, nDragCardHeight, hdcDragCard, 0, 0, SRCCOPY);\r
-       \r
-       ReleaseDC((HWND)parentWnd, hdc);\r
-               \r
-       oldx = x;\r
-       oldy = y;\r
-       \r
-       return true;\r
+    HDC hdc;\r
+\r
+    hdc = GetDC((HWND)parentWnd);\r
+        \r
+    x -= mousexoffset;\r
+    y -= mouseyoffset;\r
+        \r
+    MoveDragCardTo(hdc, x, y);\r
+\r
+    //BitBlt(hdc, nDragCardWidth+10, 0, nDragCardWidth, nDragCardHeight, hdcBackGnd, 0, 0, SRCCOPY);\r
+    //BitBlt(hdc, 0, 0, nDragCardWidth, nDragCardHeight, hdcDragCard, 0, 0, SRCCOPY);\r
+    \r
+    ReleaseDC((HWND)parentWnd, hdc);\r
+        \r
+    oldx = x;\r
+    oldy = y;\r
+    \r
+    return true;\r
 }\r
 \r
 //\r
-//     There is a bug in BitBlt when the source x,y\r
-//     become < 0. So this wrapper function simply adjusts\r
-//     the coords so that we never try to blt in from this range\r
+//    There is a bug in BitBlt when the source x,y\r
+//    become < 0. So this wrapper function simply adjusts\r
+//    the coords so that we never try to blt in from this range\r
 //\r
 BOOL ClippedBitBlt(HDC hdcDest, int x, int y, int width, int height, HDC hdcSrc, int srcx, int srcy, DWORD dwROP)\r
 {\r
-       if(srcx < 0)\r
-       {\r
-               x = 0 - srcx;\r
-               width = width + srcx;\r
-               srcx = 0;\r
-       }\r
-\r
-       if(srcy < 0)\r
-       {\r
-               y = 0 - srcy;\r
-               height = height + srcy;\r
-               srcy = 0;\r
-       }\r
-\r
-       return BitBlt(hdcDest, x, y, width, height, hdcSrc, srcx, srcy, dwROP);\r
+    if(srcx < 0)\r
+    {\r
+        x = 0 - srcx;\r
+        width = width + srcx;\r
+        srcx = 0;\r
+    }\r
+\r
+    if(srcy < 0)\r
+    {\r
+        y = 0 - srcy;\r
+        height = height + srcy;\r
+        srcy = 0;\r
+    }\r
+\r
+    return BitBlt(hdcDest, x, y, width, height, hdcSrc, srcx, srcy, dwROP);\r
 }\r
 \r
 void CardRegion::MoveDragCardTo(HDC hdc, int x, int y)\r
 {\r
-       RECT inter, rect1, rect2;\r
-\r
-       //mask off the new position of the drag-card, so\r
-       //that it will not be painted over\r
-       ClipCard(hdc, x, y, nDragCardWidth, nDragCardHeight);\r
-       \r
-       //restore the area covered by the card at its previous position\r
-       BitBlt(hdc, oldx, oldy, nDragCardWidth, nDragCardHeight, hdcBackGnd, 0, 0, SRCCOPY);\r
-\r
-       //remove clipping so we can draw the card at its new place\r
-       SelectClipRgn(hdc, NULL);\r
-       \r
-       //if the card's old and new positions overlap, then we\r
-       //need some funky code to update the "saved background" image,\r
-       SetRect(&rect1, oldx, oldy, oldx+nDragCardWidth, oldy+nDragCardHeight);\r
-       SetRect(&rect2,    x,    y,    x+nDragCardWidth,    y+nDragCardHeight);\r
-       \r
-       if(IntersectRect(&inter, &rect1, &rect2))\r
-       {\r
-               int interwidth = inter.right-inter.left;\r
-               int interheight = inter.bottom-inter.top;\r
-               int destx, desty, srcx, srcy;\r
-               \r
-               if(rect2.left > rect1.left) \r
-               {       \r
-                       destx = 0; srcx = nDragCardWidth - interwidth; \r
-               }\r
-               else\r
-               {\r
-                       destx = nDragCardWidth  - interwidth; srcx = 0;\r
-               }\r
-               \r
-               if(rect2.top  > rect1.top) \r
-               {\r
-                       desty = 0; srcy = nDragCardHeight - interheight;\r
-               }\r
-               else \r
-               {\r
-                       desty = nDragCardHeight - interheight; srcy = 0;\r
-               }\r
-               \r
-               //shift the bit we didn't use for the restore (due to the clipping)\r
-               //into the opposite corner\r
-               BitBlt(hdcBackGnd, destx,desty, interwidth, interheight, hdcBackGnd, srcx, srcy, SRCCOPY);\r
-               \r
-               ExcludeClipRect(hdcBackGnd, destx, desty, destx+interwidth, desty+interheight);\r
-               \r
-               //this bit requires us to clip the BitBlt (from screen to background)\r
-               //as BitBlt is a bit buggy it seems\r
-               ClippedBitBlt(hdcBackGnd, 0,0, nDragCardWidth, nDragCardHeight, hdc, x, y, SRCCOPY);\r
-               SelectClipRgn(hdcBackGnd, NULL);\r
-       }\r
-       else\r
-       {\r
-               BitBlt(hdcBackGnd, 0,0, nDragCardWidth, nDragCardHeight, hdc, x, y, SRCCOPY);\r
-       }\r
-       \r
-       //finally draw the card to the screen\r
-       DrawCard(hdc, x, y, hdcDragCard, nDragCardWidth, nDragCardHeight);\r
+    RECT inter, rect1, rect2;\r
+\r
+    //mask off the new position of the drag-card, so\r
+    //that it will not be painted over\r
+    ClipCard(hdc, x, y, nDragCardWidth, nDragCardHeight);\r
+    \r
+    //restore the area covered by the card at its previous position\r
+    BitBlt(hdc, oldx, oldy, nDragCardWidth, nDragCardHeight, hdcBackGnd, 0, 0, SRCCOPY);\r
+\r
+    //remove clipping so we can draw the card at its new place\r
+    SelectClipRgn(hdc, NULL);\r
+    \r
+    //if the card's old and new positions overlap, then we\r
+    //need some funky code to update the "saved background" image,\r
+    SetRect(&rect1, oldx, oldy, oldx+nDragCardWidth, oldy+nDragCardHeight);\r
+    SetRect(&rect2,    x,    y,    x+nDragCardWidth,    y+nDragCardHeight);\r
+    \r
+    if(IntersectRect(&inter, &rect1, &rect2))\r
+    {\r
+        int interwidth = inter.right-inter.left;\r
+        int interheight = inter.bottom-inter.top;\r
+        int destx, desty, srcx, srcy;\r
+        \r
+        if(rect2.left > rect1.left) \r
+        {    \r
+            destx = 0; srcx = nDragCardWidth - interwidth; \r
+        }\r
+        else\r
+        {\r
+            destx = nDragCardWidth  - interwidth; srcx = 0;\r
+        }\r
+        \r
+        if(rect2.top  > rect1.top) \r
+        {\r
+            desty = 0; srcy = nDragCardHeight - interheight;\r
+        }\r
+        else \r
+        {\r
+            desty = nDragCardHeight - interheight; srcy = 0;\r
+        }\r
+        \r
+        //shift the bit we didn't use for the restore (due to the clipping)\r
+        //into the opposite corner\r
+        BitBlt(hdcBackGnd, destx,desty, interwidth, interheight, hdcBackGnd, srcx, srcy, SRCCOPY);\r
+        \r
+        ExcludeClipRect(hdcBackGnd, destx, desty, destx+interwidth, desty+interheight);\r
+        \r
+        //this bit requires us to clip the BitBlt (from screen to background)\r
+        //as BitBlt is a bit buggy it seems\r
+        ClippedBitBlt(hdcBackGnd, 0,0, nDragCardWidth, nDragCardHeight, hdc, x, y, SRCCOPY);\r
+        SelectClipRgn(hdcBackGnd, NULL);\r
+    }\r
+    else\r
+    {\r
+        BitBlt(hdcBackGnd, 0,0, nDragCardWidth, nDragCardHeight, hdc, x, y, SRCCOPY);\r
+    }\r
+    \r
+    //finally draw the card to the screen\r
+    DrawCard(hdc, x, y, hdcDragCard, nDragCardWidth, nDragCardHeight);\r
 }\r
 \r
 \r
@@ -484,159 +484,159 @@ void CardRegion::MoveDragCardTo(HDC hdc, int x, int y)
 //extern "C" int _ftol(void) { return 0; }\r
 \r
 //\r
-//     Better do this in fixed-point, to stop\r
-//     VC from linking in floatingpoint-long conversions\r
+//    Better do this in fixed-point, to stop\r
+//    VC from linking in floatingpoint-long conversions\r
 //\r
 //#define FIXED_PREC_MOVE\r
 #ifdef  FIXED_PREC_MOVE\r
 #define PRECISION 12\r
 void ZoomCard(HDC hdc, int xpos, int ypos, CARDSTACK *dest)\r
 {\r
-       long dx, dy, x , y;\r
+    long dx, dy, x , y;\r
 \r
-       \r
-       int apparentcards;\r
-       x = xpos << PRECISION; y = ypos << PRECISION;\r
+    \r
+    int apparentcards;\r
+    x = xpos << PRECISION; y = ypos << PRECISION;\r
 \r
-       oldx = (int)xpos;\r
-       oldy = (int)ypos;\r
+    oldx = (int)xpos;\r
+    oldy = (int)ypos;\r
 \r
-       apparentcards=dest->numcards/dest->threedcount;\r
+    apparentcards=dest->numcards/dest->threedcount;\r
 \r
-       int idestx = dest->xpos + dest->xoffset * (apparentcards);// - iNumDragCards); \r
-       int idesty = dest->ypos + dest->yoffset * (apparentcards);// - iNumDragCards);\r
+    int idestx = dest->xpos + dest->xoffset * (apparentcards);// - iNumDragCards); \r
+    int idesty = dest->ypos + dest->yoffset * (apparentcards);// - iNumDragCards);\r
 \r
-       //normalise the motion vector\r
-       dx = (idestx<<PRECISION) - x;\r
-       dy = (idesty<<PRECISION) - y;\r
-       long recip = (1 << PRECISION) / 1;//sqrt(dx*dx + dy*dy);\r
+    //normalise the motion vector\r
+    dx = (idestx<<PRECISION) - x;\r
+    dy = (idesty<<PRECISION) - y;\r
+    long recip = (1 << PRECISION) / 1;//sqrt(dx*dx + dy*dy);\r
 \r
-       dx *= recip * 16;//CARDZOOMSPEED; \r
-       dy *= recip * 16;//CARDZOOMSPEED;\r
+    dx *= recip * 16;//CARDZOOMSPEED; \r
+    dy *= recip * 16;//CARDZOOMSPEED;\r
 \r
-       //if(dx < 0) dxinc = 1.001; else\r
+    //if(dx < 0) dxinc = 1.001; else\r
 \r
-       for(;;)\r
-       {\r
-               int ix, iy;\r
-               x += dx;\r
-               y += dy;\r
+    for(;;)\r
+    {\r
+        int ix, iy;\r
+        x += dx;\r
+        y += dy;\r
 \r
-               ix = (int)x>>PRECISION;\r
-               iy = (int)y>>PRECISION;\r
-               if(dx < 0 && ix < idestx) ix = idestx;\r
-               else if(dx > 0 && ix > idestx) ix = idestx;\r
+        ix = (int)x>>PRECISION;\r
+        iy = (int)y>>PRECISION;\r
+        if(dx < 0 && ix < idestx) ix = idestx;\r
+        else if(dx > 0 && ix > idestx) ix = idestx;\r
 \r
-               if(dy < 0 && iy < idesty) iy = idesty;\r
-               else if(dy > 0 && iy > idesty) iy = idesty;\r
+        if(dy < 0 && iy < idesty) iy = idesty;\r
+        else if(dy > 0 && iy > idesty) iy = idesty;\r
 \r
-               MoveDragCardTo(hdc, ix, iy);\r
+        MoveDragCardTo(hdc, ix, iy);\r
 \r
-               if(ix == idestx && iy == idesty)\r
-                       break;\r
+        if(ix == idestx && iy == idesty)\r
+            break;\r
 \r
-               oldx = (int)x >> PRECISION;\r
-               oldy = (int)y >> PRECISION;\r
+        oldx = (int)x >> PRECISION;\r
+        oldy = (int)y >> PRECISION;\r
 \r
-               //dx *= 1.2;\r
-               //dy *= 1.2;\r
+        //dx *= 1.2;\r
+        //dy *= 1.2;\r
 \r
-               Sleep(10);\r
-       }\r
+        Sleep(10);\r
+    }\r
 }\r
 #else\r
 void CardRegion::ZoomCard(HDC hdc, int xpos, int ypos, CardRegion *pDestStack)\r
 {\r
-       TRACE ( "ENTER ZoomCard()\n" );\r
-       double dx, dy, x ,y;\r
-       int apparentcards;\r
-       x = (double)xpos; y = (double)ypos;\r
-\r
-       oldx = (int)x;\r
-       oldy = (int)y;\r
-\r
-       apparentcards = pDestStack->cardstack.NumCards() / pDestStack->nThreedCount;\r
-\r
-       int idestx = pDestStack->xpos + pDestStack->xoffset * (apparentcards);\r
-       int idesty = pDestStack->ypos + pDestStack->yoffset * (apparentcards);\r
-\r
-       if(pDestStack->yoffset < 0)\r
-               idesty += pDestStack->yoffset * (iNumDragCards-1);\r
-\r
-       if(pDestStack->xoffset < 0)\r
-               idestx += pDestStack->xoffset * (iNumDragCards-1);\r
-\r
-       //normalise the motion vector\r
-       dx = idestx - x;\r
-       dy = idesty - y;\r
-       if ( fabs(dx) + fabs(dy) < 0.001f )\r
-       {\r
-               MoveDragCardTo(hdc, idestx, idesty);\r
-               return;\r
-       }\r
-       double recip = 1.0 / sqrt(dx*dx + dy*dy);\r
-       dx *= recip * __CARDZOOMSPEED; dy *= recip * __CARDZOOMSPEED;\r
-\r
-       //if(dx < 0) dxinc = 1.001; else\r
-\r
-       for(;;)\r
-       {\r
-               bool attarget = true;\r
-               int ix, iy;\r
-               x += dx;\r
-               y += dy;\r
-\r
-               ix = (int)x;\r
-               iy = (int)y;\r
-\r
-               if(dx < 0.0 && ix < idestx) ix = idestx;\r
-               else if(dx > 0.0 && ix > idestx) ix = idestx;\r
-               else attarget = false;\r
-\r
-               if(dy < 0.0 && iy < idesty) iy = idesty;\r
-               else if(dy > 0.0 && iy > idesty) iy = idesty;\r
-               else attarget = false;\r
-\r
-               //if the target stack wants the drag cards drawn differently\r
-               //to how they are, then redraw the drag card image just before\r
-               //the cards land\r
-               /*if(attarget == true)\r
-               {\r
-                       for(int i = 0; i < iNumDragCards; i++)\r
-                       {\r
-                               int xdraw = pDestStack->xoffset*i;\r
-                               int ydraw = pDestStack->yoffset*i;\r
-\r
-                               if(pDestStack->yoffset < 0)\r
-                                       ydraw = -pDestStack->yoffset * (iNumDragCards-i-1);\r
-                               if(pDestStack->xoffset < 0)\r
-                                       xdraw = -pDestStack->xoffset * (iNumDragCards-i-1);\r
-\r
-                               if(pDestStack->facedirection == CS_FACEUP && \r
-                                       pDestStack->numcards+i >= dest->numfacedown)\r
-                               {\r
-                                       //cdtDraw(hdcDragCard, xdraw, ydraw, iDragCards[i], ectFACES, 0);\r
-                               }\r
-                               else\r
-                               {\r
-                                       //cdtDraw(hdcDragCard, xdraw, ydraw, CARDSTACK::backcard, ectBACKS, 0);\r
-                               }\r
-                       }\r
-               }*/\r
-\r
-               MoveDragCardTo(hdc, ix, iy);\r
-\r
-               if(attarget || ix == idestx && iy == idesty)\r
-                       break;\r
-\r
-               oldx = (int)x;\r
-               oldy = (int)y;\r
-\r
-               //dx *= 1.2;\r
-               //dy *= 1.2;\r
-\r
-               Sleep(10);\r
-       }\r
-       TRACE ( "EXIT ZoomCard()\n" );\r
+    TRACE ( "ENTER ZoomCard()\n" );\r
+    double dx, dy, x ,y;\r
+    int apparentcards;\r
+    x = (double)xpos; y = (double)ypos;\r
+\r
+    oldx = (int)x;\r
+    oldy = (int)y;\r
+\r
+    apparentcards = pDestStack->cardstack.NumCards() / pDestStack->nThreedCount;\r
+\r
+    int idestx = pDestStack->xpos + pDestStack->xoffset * (apparentcards);\r
+    int idesty = pDestStack->ypos + pDestStack->yoffset * (apparentcards);\r
+\r
+    if(pDestStack->yoffset < 0)\r
+        idesty += pDestStack->yoffset * (iNumDragCards-1);\r
+\r
+    if(pDestStack->xoffset < 0)\r
+        idestx += pDestStack->xoffset * (iNumDragCards-1);\r
+\r
+    //normalise the motion vector\r
+    dx = idestx - x;\r
+    dy = idesty - y;\r
+    if ( fabs(dx) + fabs(dy) < 0.001f )\r
+    {\r
+        MoveDragCardTo(hdc, idestx, idesty);\r
+        return;\r
+    }\r
+    double recip = 1.0 / sqrt(dx*dx + dy*dy);\r
+    dx *= recip * __CARDZOOMSPEED; dy *= recip * __CARDZOOMSPEED;\r
+\r
+    //if(dx < 0) dxinc = 1.001; else\r
+\r
+    for(;;)\r
+    {\r
+        bool attarget = true;\r
+        int ix, iy;\r
+        x += dx;\r
+        y += dy;\r
+\r
+        ix = (int)x;\r
+        iy = (int)y;\r
+\r
+        if(dx < 0.0 && ix < idestx) ix = idestx;\r
+        else if(dx > 0.0 && ix > idestx) ix = idestx;\r
+        else attarget = false;\r
+\r
+        if(dy < 0.0 && iy < idesty) iy = idesty;\r
+        else if(dy > 0.0 && iy > idesty) iy = idesty;\r
+        else attarget = false;\r
+\r
+        //if the target stack wants the drag cards drawn differently\r
+        //to how they are, then redraw the drag card image just before\r
+        //the cards land\r
+        /*if(attarget == true)\r
+        {\r
+            for(int i = 0; i < iNumDragCards; i++)\r
+            {\r
+                int xdraw = pDestStack->xoffset*i;\r
+                int ydraw = pDestStack->yoffset*i;\r
+\r
+                if(pDestStack->yoffset < 0)\r
+                    ydraw = -pDestStack->yoffset * (iNumDragCards-i-1);\r
+                if(pDestStack->xoffset < 0)\r
+                    xdraw = -pDestStack->xoffset * (iNumDragCards-i-1);\r
+\r
+                if(pDestStack->facedirection == CS_FACEUP && \r
+                    pDestStack->numcards+i >= dest->numfacedown)\r
+                {\r
+                    //cdtDraw(hdcDragCard, xdraw, ydraw, iDragCards[i], ectFACES, 0);\r
+                }\r
+                else\r
+                {\r
+                    //cdtDraw(hdcDragCard, xdraw, ydraw, CARDSTACK::backcard, ectBACKS, 0);\r
+                }\r
+            }\r
+        }*/\r
+\r
+        MoveDragCardTo(hdc, ix, iy);\r
+\r
+        if(attarget || ix == idestx && iy == idesty)\r
+            break;\r
+\r
+        oldx = (int)x;\r
+        oldy = (int)y;\r
+\r
+        //dx *= 1.2;\r
+        //dy *= 1.2;\r
+\r
+        Sleep(10);\r
+    }\r
+    TRACE ( "EXIT ZoomCard()\n" );\r
 }\r
 #endif\r
index 147c096..06b9f25 100644 (file)
@@ -1,8 +1,8 @@
 //\r
-//     CardLib - CardStack class\r
+//    CardLib - CardStack class\r
 //\r
-//     Freeware\r
-//     Copyright J Brown 2001\r
+//    Freeware\r
+//    Copyright J Brown 2001\r
 //\r
 #include <windows.h>\r
 #include <stdlib.h>\r
 \r
 Card &CardStack::operator[] (size_t index)\r
 {\r
-       if(index >= (size_t)nNumCards) index = nNumCards - 1;\r
-       return cardlist[nNumCards - index - 1];\r
+    if(index >= (size_t)nNumCards) index = nNumCards - 1;\r
+    return cardlist[nNumCards - index - 1];\r
 }\r
 \r
 const Card &CardStack::operator[] (size_t index) const\r
 {\r
-       if(index >= (size_t)nNumCards) index = nNumCards - 1;\r
-       return cardlist[nNumCards - index - 1];\r
+    if(index >= (size_t)nNumCards) index = nNumCards - 1;\r
+    return cardlist[nNumCards - index - 1];\r
 }\r
 \r
-//     Subscripting operator for a constant sequence\r
+//    Subscripting operator for a constant sequence\r
 //\r
 /*Card CardStack::operator[] (size_t index) const\r
 {\r
-       return cardlist[index];\r
+    return cardlist[index];\r
 }*/\r
 \r
 //\r
-//     Subscripting operator for a non-const sequence\r
+//    Subscripting operator for a non-const sequence\r
 //\r
 /*CardStack::ref  CardStack::operator[] (size_t index)\r
 {\r
-       return ref(this, index);\r
+    return ref(this, index);\r
 }*/\r
 \r
 void CardStack::Clear()\r
 {\r
-       nNumCards = 0;\r
+    nNumCards = 0;\r
 }\r
 \r
 void CardStack::NewDeck()\r
 {\r
-       nNumCards = 52;\r
+    nNumCards = 52;\r
 \r
-       for(int i = 0; i < 52; i++)\r
-               cardlist[i].nValue = i;\r
+    for(int i = 0; i < 52; i++)\r
+        cardlist[i].nValue = i;\r
 }\r
 \r
 void CardStack::Shuffle()\r
 {\r
-       int src, dest;\r
-       Card temp;\r
-\r
-       //shuffle 8 times..\r
-       for(int i = 0; i < 8; i++)\r
-               for(dest = nNumCards - 1; dest > 0; dest--)\r
-               {\r
-                       //want to do this:\r
-                       //  bad:   src = rand() % (dest + 1)\r
-                       //  good:  src = rand() / (RAND_MAX / (dest+1) + 1)\r
-                       \r
-                       //positions from 0 to dest\r
-                       src = rand() / (RAND_MAX / (dest+1) + 1);\r
-                       \r
-                       //swap the cards\r
-                       temp           = cardlist[src];\r
-                       cardlist[src]  = cardlist[dest];\r
-                       cardlist[dest] = temp;\r
-               }\r
+    int src, dest;\r
+    Card temp;\r
+\r
+    //shuffle 8 times..\r
+    for(int i = 0; i < 8; i++)\r
+        for(dest = nNumCards - 1; dest > 0; dest--)\r
+        {\r
+            //want to do this:\r
+            //  bad:   src = rand() % (dest + 1)\r
+            //  good:  src = rand() / (RAND_MAX / (dest+1) + 1)\r
+            \r
+            //positions from 0 to dest\r
+            src = rand() / (RAND_MAX / (dest+1) + 1);\r
+            \r
+            //swap the cards\r
+            temp           = cardlist[src];\r
+            cardlist[src]  = cardlist[dest];\r
+            cardlist[dest] = temp;\r
+        }\r
 }\r
 \r
 void CardStack::Reverse()\r
 {\r
-       for(int i = 0; i < nNumCards / 2; i++)\r
-       {\r
-               Card temp                   = cardlist[i];\r
-               cardlist[i]                 = cardlist[nNumCards - i - 1];\r
-               cardlist[nNumCards - i - 1] = temp;\r
-       }\r
+    for(int i = 0; i < nNumCards / 2; i++)\r
+    {\r
+        Card temp                   = cardlist[i];\r
+        cardlist[i]                 = cardlist[nNumCards - i - 1];\r
+        cardlist[nNumCards - i - 1] = temp;\r
+    }\r
 }\r
 \r
 void CardStack::Push(const Card card)\r
 {\r
-       if(nNumCards < MAX_CARDSTACK_SIZE)\r
-               cardlist[nNumCards++] = card;\r
+    if(nNumCards < MAX_CARDSTACK_SIZE)\r
+        cardlist[nNumCards++] = card;\r
 }\r
 \r
 void CardStack::Push(const CardStack &cardstack)\r
 {\r
-       if(nNumCards + cardstack.nNumCards < MAX_CARDSTACK_SIZE)\r
-       {\r
-               int num = cardstack.NumCards();\r
-               \r
-               for(int i = 0; i < num; i++)\r
-                       cardlist[nNumCards++] = cardstack.cardlist[i];\r
-       }\r
+    if(nNumCards + cardstack.nNumCards < MAX_CARDSTACK_SIZE)\r
+    {\r
+        int num = cardstack.NumCards();\r
+        \r
+        for(int i = 0; i < num; i++)\r
+            cardlist[nNumCards++] = cardstack.cardlist[i];\r
+    }\r
 }\r
 \r
 CardStack& CardStack::operator += (Card card)\r
 {\r
-       Push(card);\r
-       return *this;\r
+    Push(card);\r
+    return *this;\r
 }\r
 \r
 CardStack& CardStack::operator += (CardStack &cs)\r
 {\r
-       Push(cs);\r
-       return *this;\r
+    Push(cs);\r
+    return *this;\r
 }\r
 \r
 CardStack CardStack::operator +  (Card card)\r
 {\r
-       CardStack poo = *this;\r
-       poo.Push(card);\r
-       return poo;\r
+    CardStack poo = *this;\r
+    poo.Push(card);\r
+    return poo;\r
 }\r
 \r
 CardStack CardStack::operator + (CardStack &cs)\r
 {\r
-       CardStack poo = *this;\r
-       poo.Push(cs);\r
-       return poo;\r
+    CardStack poo = *this;\r
+    poo.Push(cs);\r
+    return poo;\r
 }\r
 \r
 \r
 Card CardStack::Pop()\r
 {\r
-       if(nNumCards > 0)\r
-               return cardlist[--nNumCards];\r
-       else\r
-               return 0;\r
+    if(nNumCards > 0)\r
+        return cardlist[--nNumCards];\r
+    else\r
+        return 0;\r
 }\r
 \r
 CardStack CardStack::Pop(int items)\r
 {\r
-       if(items <= nNumCards && nNumCards > 0)\r
-       {\r
-               CardStack cs(*this, nNumCards - items);\r
+    if(items <= nNumCards && nNumCards > 0)\r
+    {\r
+        CardStack cs(*this, nNumCards - items);\r
 \r
-               nNumCards -= items;\r
+        nNumCards -= items;\r
 \r
-               return cs;\r
-       }\r
-       else\r
-       {\r
-               return CardStack();\r
-       }\r
+        return cs;\r
+    }\r
+    else\r
+    {\r
+        return CardStack();\r
+    }\r
 }\r
 \r
 Card CardStack::Top()\r
 {\r
-       if(nNumCards > 0)\r
-               return cardlist[nNumCards - 1];\r
-       else\r
-               return 0;\r
+    if(nNumCards > 0)\r
+        return cardlist[nNumCards - 1];\r
+    else\r
+        return 0;\r
 }\r
 \r
 CardStack CardStack::Top(int items)\r
 {\r
-       if(items <= nNumCards && nNumCards > 0)\r
-       {\r
-               return CardStack (*this, nNumCards - items);\r
-       }\r
-       else\r
-       {\r
-               return CardStack();\r
-       }\r
+    if(items <= nNumCards && nNumCards > 0)\r
+    {\r
+        return CardStack (*this, nNumCards - items);\r
+    }\r
+    else\r
+    {\r
+        return CardStack();\r
+    }\r
 \r
 }\r
 \r
 Card CardStack::RemoveCard(size_t index)\r
 {\r
-       if(nNumCards == 0 || index >= (size_t)nNumCards)\r
-               return 0;\r
+    if(nNumCards == 0 || index >= (size_t)nNumCards)\r
+        return 0;\r
 \r
-       //put index into reverse range..\r
-       index = nNumCards - index - 1;\r
+    //put index into reverse range..\r
+    index = nNumCards - index - 1;\r
 \r
-       Card temp = cardlist[index];\r
+    Card temp = cardlist[index];\r
 \r
-       nNumCards--;\r
+    nNumCards--;\r
 \r
-       for(size_t i = index; i < (size_t)nNumCards; i++)\r
-       {\r
-               cardlist[i] = cardlist[i+1];\r
-       }\r
+    for(size_t i = index; i < (size_t)nNumCards; i++)\r
+    {\r
+        cardlist[i] = cardlist[i+1];\r
+    }\r
 \r
-       return temp;\r
+    return temp;\r
 }\r
 \r
 void CardStack::InsertCard(size_t index, Card card)\r
 {\r
-       if(nNumCards == MAX_CARDSTACK_SIZE)\r
-               return;\r
+    if(nNumCards == MAX_CARDSTACK_SIZE)\r
+        return;\r
 \r
-       if(index > (size_t)nNumCards)\r
-               return;\r
+    if(index > (size_t)nNumCards)\r
+        return;\r
 \r
-       if((size_t)nNumCards == index)\r
-       {\r
-               cardlist[nNumCards] = card;\r
-               nNumCards++;\r
-               return;\r
-       }\r
+    if((size_t)nNumCards == index)\r
+    {\r
+        cardlist[nNumCards] = card;\r
+        nNumCards++;\r
+        return;\r
+    }\r
 \r
-       //put index into reverse range..\r
-       index = nNumCards - index - 1;\r
+    //put index into reverse range..\r
+    index = nNumCards - index - 1;\r
 \r
-       nNumCards++;\r
+    nNumCards++;\r
 \r
-       //make room for the card\r
-       for(size_t i = nNumCards; i > index; i--)\r
-       {\r
-               cardlist[i] = cardlist[i - 1];\r
-       }\r
+    //make room for the card\r
+    for(size_t i = nNumCards; i > index; i--)\r
+    {\r
+        cardlist[i] = cardlist[i - 1];\r
+    }\r
 \r
-       cardlist[index] = card;\r
+    cardlist[index] = card;\r
 }\r
 \r
 \r
 void CardStack::Print()\r
 {\r
-//     for(int i = 0; i < nNumCards; i++)\r
-//             cout << cardlist[i].HiVal() << " ";\r
+//    for(int i = 0; i < nNumCards; i++)\r
+//        cout << cardlist[i].HiVal() << " ";\r
 }\r
 \r
 CardStack::CardStack(CardStack &copythis, size_t fromindex)\r
 {\r
-       nNumCards = copythis.nNumCards - fromindex;\r
+    nNumCards = copythis.nNumCards - fromindex;\r
 \r
-       for(int i = 0; i < nNumCards; i++)\r
-               cardlist[i] = copythis.cardlist[fromindex + i];\r
+    for(int i = 0; i < nNumCards; i++)\r
+        cardlist[i] = copythis.cardlist[fromindex + i];\r
 }\r
 \r
index 1f27c13..4455086 100644 (file)
@@ -1,8 +1,8 @@
 //\r
-//     CardLib - CardWindow class\r
+//    CardLib - CardWindow class\r
 //\r
-//     Freeware\r
-//     Copyright J Brown 2001\r
+//    Freeware\r
+//    Copyright J Brown 2001\r
 //\r
 #include <windows.h>\r
 #include <tchar.h>\r
@@ -18,26 +18,26 @@ extern HPALETTE __holdplacepal;
 \r
 HPALETTE UseNicePalette(HDC hdc, HPALETTE hPalette)\r
 {\r
-       HPALETTE hOld;\r
+    HPALETTE hOld;\r
 \r
-       hOld = SelectPalette(hdc, hPalette, FALSE);\r
-       RealizePalette(hdc);\r
+    hOld = SelectPalette(hdc, hPalette, FALSE);\r
+    RealizePalette(hdc);\r
 \r
-       return hOld;\r
+    return hOld;\r
 }\r
 \r
 void RestorePalette(HDC hdc, HPALETTE hOldPal)\r
 {\r
-       SelectPalette(hdc, hOldPal, TRUE);\r
+    SelectPalette(hdc, hOldPal, TRUE);\r
 }\r
 \r
 HPALETTE MakePaletteFromCols(COLORREF cols[], int nNumColours);\r
-void    PaintRect(HDC hdc, RECT *rect, COLORREF colour);\r
+void     PaintRect(HDC hdc, RECT *rect, COLORREF colour);\r
 HBITMAP  CreateSinkBmp(HDC hdcCompat, HDC hdc, COLORREF col, int width, int height);\r
 void     GetSinkCols(COLORREF crBase, COLORREF *fg, COLORREF *bg, COLORREF *sh1, COLORREF *sh2);\r
 \r
-void    LoadCardBitmaps();\r
-void    FreeCardBitmaps();\r
+void     LoadCardBitmaps();\r
+void     FreeCardBitmaps();\r
 \r
 static TCHAR szCardName[]   = _T("CardWnd32");\r
 static bool  fRegistered    = false;\r
@@ -46,296 +46,296 @@ static LONG  uCardBitmapRef = 0;
 \r
 void RegisterCardWindow()\r
 {\r
-       WNDCLASSEX wc;\r
-\r
-       //Window class for the main application parent window\r
-       wc.cbSize                       = sizeof(wc);\r
-       wc.style                        = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;\r
-       wc.lpfnWndProc          = CardWindow::CardWndProc;\r
-       wc.cbClsExtra           = 0;\r
-       wc.cbWndExtra           = sizeof(CardWindow *);\r
-       wc.hInstance            = GetModuleHandle(0);\r
-       wc.hIcon                        = 0;\r
-       wc.hCursor                      = LoadCursor (NULL, IDC_ARROW);\r
-       wc.hbrBackground        = 0;\r
-       wc.lpszMenuName         = 0;\r
-       wc.lpszClassName        = szCardName;\r
-       wc.hIconSm                      = 0;\r
-\r
-       RegisterClassEx(&wc);\r
+    WNDCLASSEX wc;\r
+\r
+    //Window class for the main application parent window\r
+    wc.cbSize            = sizeof(wc);\r
+    wc.style            = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;\r
+    wc.lpfnWndProc        = CardWindow::CardWndProc;\r
+    wc.cbClsExtra        = 0;\r
+    wc.cbWndExtra        = sizeof(CardWindow *);\r
+    wc.hInstance        = GetModuleHandle(0);\r
+    wc.hIcon            = 0;\r
+    wc.hCursor            = LoadCursor (NULL, IDC_ARROW);\r
+    wc.hbrBackground    = 0;\r
+    wc.lpszMenuName        = 0;\r
+    wc.lpszClassName    = szCardName;\r
+    wc.hIconSm            = 0;\r
+\r
+    RegisterClassEx(&wc);\r
 }\r
 \r
 CardWindow::CardWindow() : m_hWnd(0)\r
 {\r
-       HDC hdc = GetDC(0);\r
+    HDC hdc = GetDC(0);\r
 \r
-       nNumButtons       = 0;\r
-       nNumCardRegions   = 0;\r
-       nNumDropZones     = 0;\r
-       nBackCardIdx      = 53;\r
+    nNumButtons       = 0;\r
+    nNumCardRegions   = 0;\r
+    nNumDropZones     = 0;\r
+    nBackCardIdx      = 53;\r
 \r
-       ResizeWndCallback = 0;\r
-       hbmBackImage      = 0;\r
-       hdcBackImage      = 0;\r
+    ResizeWndCallback = 0;\r
+    hbmBackImage      = 0;\r
+    hdcBackImage      = 0;\r
 \r
-       srand((unsigned)GetTickCount());\r
+    srand((unsigned)GetTickCount());\r
 \r
-       //All colours (buttons, highlights, decks)\r
-       //are calculated off this single base colour\r
-       crBackgnd = PALETTERGB(0,80,0);//PALETTERGB(0,64,100);\r
+    //All colours (buttons, highlights, decks)\r
+    //are calculated off this single base colour\r
+    crBackgnd = PALETTERGB(0,80,0);//PALETTERGB(0,64,100);\r
 \r
-       // If uCardBitmapRef was previously zero, then\r
-       // load the card bitmaps\r
-       if(1 == InterlockedIncrement(&uCardBitmapRef))\r
-       {\r
-               LoadCardBitmaps();\r
+    // If uCardBitmapRef was previously zero, then\r
+    // load the card bitmaps\r
+    if(1 == InterlockedIncrement(&uCardBitmapRef))\r
+    {\r
+        LoadCardBitmaps();\r
 \r
-               __hPalette  = CreateCardPalette();\r
+        __hPalette  = CreateCardPalette();\r
 \r
-               __hdcPlaceHolder  = CreateCompatibleDC(hdc);\r
-       \r
-               __holdplacepal  = UseNicePalette(__hdcPlaceHolder, __hPalette);\r
+        __hdcPlaceHolder  = CreateCompatibleDC(hdc);\r
+    \r
+        __holdplacepal  = UseNicePalette(__hdcPlaceHolder, __hPalette);\r
 \r
-               __hbmPlaceHolder  = CreateSinkBmp(hdc, __hdcPlaceHolder, crBackgnd, __cardwidth, __cardheight);\r
+        __hbmPlaceHolder  = CreateSinkBmp(hdc, __hdcPlaceHolder, crBackgnd, __cardwidth, __cardheight);\r
 \r
-       }\r
+    }\r
 \r
-       ReleaseDC(0, hdc);\r
+    ReleaseDC(0, hdc);\r
 \r
-       //register the window class if necessary\r
-       if(!fRegistered)\r
-       {\r
-               fRegistered = true;\r
-               RegisterCardWindow();\r
-       }\r
+    //register the window class if necessary\r
+    if(!fRegistered)\r
+    {\r
+        fRegistered = true;\r
+        RegisterCardWindow();\r
+    }\r
 \r
 }\r
 \r
 BOOL CardWindow::Create(HWND hwndParent, DWORD dwExStyle, DWORD dwStyle, int x, int y, int width, int height)\r
 {\r
-       if(m_hWnd)\r
-               return FALSE;\r
+    if(m_hWnd)\r
+        return FALSE;\r
 \r
-       //Create the window associated with this object\r
-       m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, szCardName, 0, \r
-               WS_CHILD | WS_VISIBLE,\r
-               0,0,100,100, \r
-               hwndParent, 0, GetModuleHandle(0), this);\r
+    //Create the window associated with this object\r
+    m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, szCardName, 0, \r
+        WS_CHILD | WS_VISIBLE,\r
+        0,0,100,100, \r
+        hwndParent, 0, GetModuleHandle(0), this);\r
 \r
-       return TRUE;\r
+    return TRUE;\r
 }\r
 \r
 BOOL CardWindow::Destroy()\r
 {\r
-       DestroyWindow(m_hWnd);\r
-       m_hWnd = 0;\r
+    DestroyWindow(m_hWnd);\r
+    m_hWnd = 0;\r
 \r
-       return TRUE;\r
+    return TRUE;\r
 }\r
 \r
 CardWindow::~CardWindow()\r
 {\r
-       if(m_hWnd)\r
-               DestroyWindow(m_hWnd);\r
+    if(m_hWnd)\r
+        DestroyWindow(m_hWnd);\r
 \r
-       DeleteAll();\r
+    DeleteAll();\r
 \r
-       if(0 == InterlockedDecrement(&uCardBitmapRef))\r
-       {\r
-               FreeCardBitmaps();\r
+    if(0 == InterlockedDecrement(&uCardBitmapRef))\r
+    {\r
+        FreeCardBitmaps();\r
 \r
-               DeleteObject(__hbmPlaceHolder);\r
-               DeleteDC    (__hdcPlaceHolder);\r
+        DeleteObject(__hbmPlaceHolder);\r
+        DeleteDC    (__hdcPlaceHolder);\r
 \r
-               RestorePalette(__hdcPlaceHolder, __holdplacepal);\r
+        RestorePalette(__hdcPlaceHolder, __holdplacepal);\r
 \r
-               if(__hPalette)\r
-                       DeleteObject(__hPalette);\r
-       }\r
+        if(__hPalette)\r
+            DeleteObject(__hPalette);\r
+    }\r
 }\r
 \r
 bool CardWindow::DeleteAll()\r
 {\r
-       int i;\r
+    int i;\r
 \r
-       for(i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               delete Regions[i];\r
-       }\r
+    for(i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        delete Regions[i];\r
+    }\r
 \r
-       for(i = 0; i < nNumButtons; i++)\r
-       {\r
-               delete Buttons[i];\r
-       }\r
+    for(i = 0; i < nNumButtons; i++)\r
+    {\r
+        delete Buttons[i];\r
+    }\r
 \r
-       for(i = 0; i < nNumDropZones; i++)\r
-       {\r
-               delete dropzone[i];\r
-       }\r
+    for(i = 0; i < nNumDropZones; i++)\r
+    {\r
+        delete dropzone[i];\r
+    }\r
 \r
-       nNumCardRegions = nNumButtons = nNumDropZones = 0;\r
+    nNumCardRegions = nNumButtons = nNumDropZones = 0;\r
 \r
-       return true;\r
+    return true;\r
 }\r
 \r
 void CardWindow::SetBackColor(COLORREF cr)\r
 {\r
-       crBackgnd = cr;\r
-       int i;\r
-       \r
-       //\r
-       // Create the exact palette we need to render the buttons/stacks\r
-       //\r
-       RestorePalette(__hdcPlaceHolder, __holdplacepal);\r
-\r
-       if(__hPalette)\r
-               DeleteObject(__hPalette);\r
-\r
-       __hPalette = CreateCardPalette();\r
-\r
-       //\r
-       // re-create the place-holder!\r
-       HDC hdc = GetDC(m_hWnd);\r
-\r
-       DeleteObject(__hbmPlaceHolder);\r
-\r
-       __holdplacepal = UseNicePalette(__hdcPlaceHolder, __hPalette);\r
-\r
-       __hbmPlaceHolder = CreateSinkBmp(hdc, __hdcPlaceHolder, crBackgnd, __cardwidth, __cardheight);\r
-       //SelectObject(__hdcPlaceHolder, __hbmPlaceHolder);\r
-\r
-       //reset all buttons to same colour\r
-       for(i = 0; i < nNumButtons; i++)\r
-       {\r
-               if(Buttons[i]->GetStyle() & CB_PUSHBUTTON)\r
-               {\r
-                       Buttons[i]->SetBackColor(ColorScaleRGB(crBackgnd, RGB(255,255,255), 0.1));\r
-               }\r
-               else\r
-               {\r
-                       Buttons[i]->SetBackColor(crBackgnd);\r
-               }\r
-       }\r
-\r
-       for(i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               Regions[i]->SetBackColor(crBackgnd);\r
-       }\r
-\r
-\r
-       ReleaseDC(m_hWnd, hdc);\r
+    crBackgnd = cr;\r
+    int i;\r
+    \r
+    //\r
+    // Create the exact palette we need to render the buttons/stacks\r
+    //\r
+    RestorePalette(__hdcPlaceHolder, __holdplacepal);\r
+\r
+    if(__hPalette)\r
+        DeleteObject(__hPalette);\r
+\r
+    __hPalette = CreateCardPalette();\r
+\r
+    //\r
+    // re-create the place-holder!\r
+    HDC hdc = GetDC(m_hWnd);\r
+\r
+    DeleteObject(__hbmPlaceHolder);\r
+\r
+    __holdplacepal = UseNicePalette(__hdcPlaceHolder, __hPalette);\r
+\r
+    __hbmPlaceHolder = CreateSinkBmp(hdc, __hdcPlaceHolder, crBackgnd, __cardwidth, __cardheight);\r
+    //SelectObject(__hdcPlaceHolder, __hbmPlaceHolder);\r
+\r
+    //reset all buttons to same colour\r
+    for(i = 0; i < nNumButtons; i++)\r
+    {\r
+        if(Buttons[i]->GetStyle() & CB_PUSHBUTTON)\r
+        {\r
+            Buttons[i]->SetBackColor(ColorScaleRGB(crBackgnd, RGB(255,255,255), 0.1));\r
+        }\r
+        else\r
+        {\r
+            Buttons[i]->SetBackColor(crBackgnd);\r
+        }\r
+    }\r
+\r
+    for(i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        Regions[i]->SetBackColor(crBackgnd);\r
+    }\r
+\r
+\r
+    ReleaseDC(m_hWnd, hdc);\r
 }\r
 \r
 COLORREF CardWindow::GetBackColor()\r
 {\r
-       return crBackgnd;\r
+    return crBackgnd;\r
 }\r
 \r
 CardButton* CardWindow::CardButtonFromPoint(int x, int y)\r
 {\r
-       CardButton *bptr = 0;\r
-\r
-       POINT pt;\r
-       pt.x = x;\r
-       pt.y = y;\r
-\r
-       //Search BACKWARDS...to reflect the implicit Z-order that\r
-       //the button creation provided\r
-       for(int i = nNumButtons - 1; i >= 0; i--)\r
-       {\r
-               bptr = Buttons[i];\r
-               if(PtInRect(&bptr->rect, pt) && bptr->fVisible)\r
-                       return bptr;\r
-       }\r
-\r
-       return 0;       \r
+    CardButton *bptr = 0;\r
+\r
+    POINT pt;\r
+    pt.x = x;\r
+    pt.y = y;\r
+\r
+    //Search BACKWARDS...to reflect the implicit Z-order that\r
+    //the button creation provided\r
+    for(int i = nNumButtons - 1; i >= 0; i--)\r
+    {\r
+        bptr = Buttons[i];\r
+        if(PtInRect(&bptr->rect, pt) && bptr->fVisible)\r
+            return bptr;\r
+    }\r
+\r
+    return 0;    \r
 }\r
 \r
 CardRegion* CardWindow::CardRegionFromPoint(int x, int y)\r
 {\r
-       POINT pt;\r
-       pt.x = x;\r
-       pt.y = y;\r
-\r
-       //Search BACKWARDS...to reflect the implicit Z-order that\r
-       //the stack creation provided\r
-       for(int i = nNumCardRegions - 1; i >= 0; i--)\r
-       {\r
-               if(Regions[i]->IsPointInStack(x, y))\r
-                       return Regions[i];\r
-       }\r
-\r
-       return 0;       \r
+    POINT pt;\r
+    pt.x = x;\r
+    pt.y = y;\r
+\r
+    //Search BACKWARDS...to reflect the implicit Z-order that\r
+    //the stack creation provided\r
+    for(int i = nNumCardRegions - 1; i >= 0; i--)\r
+    {\r
+        if(Regions[i]->IsPointInStack(x, y))\r
+            return Regions[i];\r
+    }\r
+\r
+    return 0;    \r
 }\r
 \r
 //\r
-//     Forward all window messages onto the appropriate\r
+//    Forward all window messages onto the appropriate\r
 //  class instance\r
 //\r
 LRESULT CALLBACK CardWindow::CardWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)\r
 {\r
-       CardWindow *cw = (CardWindow *)GetWindowLong(hwnd, 0);\r
-       return cw->WndProc(hwnd, iMsg, wParam, lParam);\r
+    CardWindow *cw = (CardWindow *)GetWindowLong(hwnd, 0);\r
+    return cw->WndProc(hwnd, iMsg, wParam, lParam);\r
 }\r
 \r
 void CardWindow::Paint(HDC hdc)\r
 {\r
-       int i;\r
-       RECT rect;\r
-       HPALETTE hOldPal;\r
-\r
-       hOldPal = UseNicePalette(hdc, __hPalette);\r
-\r
-       //\r
-       //      Clip the card stacks so that they won't\r
-       //      get painted over\r
-       //\r
-       for(i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               Regions[i]->Clip(hdc);\r
-       }\r
-\r
-       //\r
-       //      Clip the buttons \r
-       //\r
-       for(i = 0; i < nNumButtons; i++)\r
-       {\r
-               Buttons[i]->Clip(hdc);\r
-       }\r
-\r
-\r
-       //      Now paint the whole screen with background colour, \r
-       //\r
-       GetClientRect(m_hWnd, &rect);\r
-       \r
-       //PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));\r
-       PaintCardRgn(hdc, 0, 0, rect.right, rect.bottom, 0, 0);\r
-       SelectClipRgn(hdc, NULL);\r
-\r
-       //      Don't let cards draw over buttons, so clip buttons again\r
-       //\r
-       for(i = 0; i < nNumButtons; i++)\r
-       {\r
-               Buttons[i]->Clip(hdc);\r
-       }\r
-\r
-       //      Paint each card stack in turn\r
-       //\r
-       for(i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               Regions[i]->Render(hdc);\r
-       }\r
-               \r
-       //      Paint each button now\r
-       //\r
-       SelectClipRgn(hdc, NULL);\r
-\r
-       for(i = 0; i < nNumButtons; i++)\r
-       {\r
-               Buttons[i]->Redraw();\r
-       }\r
-\r
-       RestorePalette(hdc, hOldPal);\r
+    int i;\r
+    RECT rect;\r
+    HPALETTE hOldPal;\r
+\r
+    hOldPal = UseNicePalette(hdc, __hPalette);\r
+\r
+    //\r
+    //    Clip the card stacks so that they won't\r
+    //    get painted over\r
+    //\r
+    for(i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        Regions[i]->Clip(hdc);\r
+    }\r
+\r
+    //\r
+    //    Clip the buttons \r
+    //\r
+    for(i = 0; i < nNumButtons; i++)\r
+    {\r
+        Buttons[i]->Clip(hdc);\r
+    }\r
+\r
+\r
+    //    Now paint the whole screen with background colour, \r
+    //\r
+    GetClientRect(m_hWnd, &rect);\r
+    \r
+    //PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));\r
+    PaintCardRgn(hdc, 0, 0, rect.right, rect.bottom, 0, 0);\r
+    SelectClipRgn(hdc, NULL);\r
+\r
+    //    Don't let cards draw over buttons, so clip buttons again\r
+    //\r
+    for(i = 0; i < nNumButtons; i++)\r
+    {\r
+        Buttons[i]->Clip(hdc);\r
+    }\r
+\r
+    //    Paint each card stack in turn\r
+    //\r
+    for(i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        Regions[i]->Render(hdc);\r
+    }\r
+        \r
+    //    Paint each button now\r
+    //\r
+    SelectClipRgn(hdc, NULL);\r
+\r
+    for(i = 0; i < nNumButtons; i++)\r
+    {\r
+        Buttons[i]->Redraw();\r
+    }\r
+\r
+    RestorePalette(hdc, hOldPal);\r
 }\r
 \r
 \r
@@ -343,469 +343,469 @@ void CardWindow::Paint(HDC hdc)
 \r
 LRESULT CALLBACK CardWindow::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)\r
 {\r
-       HDC hdc;\r
-       PAINTSTRUCT ps;\r
-\r
-       CREATESTRUCT *cs;\r
-\r
-       static CardButton *buttonptr   = 0;\r
-       static CardRegion *stackptr    = 0;\r
-\r
-       int x, y, i;\r
-\r
-       switch(iMsg)\r
-       {\r
-       case WM_NCCREATE:\r
-\r
-               // When we created this window, we passed in the\r
-               // pointer to the class object (CardWindow *) in the\r
-               // call to CreateWindow.\r
-               cs = (CREATESTRUCT *)lParam;\r
-\r
-               //\r
-               // associate this class with the window\r
-               //\r
-               SetWindowLong(hwnd, 0, (LONG)cs->lpCreateParams);\r
-\r
-               return 1;\r
-\r
-       case WM_NCDESTROY:\r
-               // Don't delete anything here..\r
-               break;\r
-\r
-       case WM_SIZE:\r
-               nWidth = LOWORD(lParam);\r
-               nHeight = HIWORD(lParam);\r
-               \r
-               //\r
-               // reposition all the stacks and buttons\r
-               // in case any of them are centered, right-justified etc\r
-               //\r
-               for(i = 0; i < nNumCardRegions; i++)\r
-               {\r
-                       Regions[i]->AdjustPosition(nWidth, nHeight);\r
-               }\r
-       \r
-               for(i = 0; i < nNumButtons; i++)\r
-               {\r
-                       Buttons[i]->AdjustPosition(nWidth, nHeight);\r
-               }\r
-\r
-               // \r
-               // Call the user-defined resize proc AFTER all the stacks\r
-               // have been positioned\r
-               //\r
-               if(ResizeWndCallback) \r
-                       ResizeWndCallback(nWidth, nHeight);\r
-\r
-               return 0;\r
-\r
-       case WM_PAINT:\r
-\r
-               hdc = BeginPaint(hwnd, &ps);\r
-\r
-               Paint(hdc);\r
-\r
-               EndPaint(hwnd, &ps);\r
-               return 0;\r
-\r
-       case WM_TIMER:\r
-               \r
-               //find the timer object in the registered funcs\r
-               /*if(wParam >= 0x10000)\r
-               {\r
-                       for(i = 0; i < nRegFuncs; i++)\r
-                       {\r
-                               if(RegFuncs[i].id == wParam)\r
-                               {\r
-                                       KillTimer(hwnd, wParam);\r
-       \r
-                                       //call the registered function!!\r
-                                       RegFuncs[i].func(RegFuncs[i].dwParam);\r
-       \r
-                                       RegFuncs[i] = RegFuncs[nRegFuncs-1];\r
-                                       nRegFuncs--;\r
-                               }\r
-                       }\r
-               }\r
-               else*/\r
-               {\r
-                       //find the cardstack\r
-                       CardRegion *stackobj = (CardRegion *)wParam;//CardStackFromId(wParam);\r
-                       stackobj->DoFlash();\r
-               }\r
-\r
-               return 0;\r
-\r
-       case WM_LBUTTONDBLCLK:\r
-\r
-               x = (short)LOWORD(lParam);\r
-               y = (short)HIWORD(lParam);\r
-\r
-               if((buttonptr = CardButtonFromPoint(x, y)) != 0)\r
-               {\r
-                       buttonptr->OnLButtonDown(hwnd, x, y);\r
-                       return 0;\r
-               }\r
-\r
-               if((stackptr = CardRegionFromPoint(x, y)) != 0)\r
-               {\r
-                       stackptr->OnLButtonDblClk(x, y);\r
-                       stackptr = 0;\r
-               }\r
-\r
-               return 0;\r
-\r
-       case WM_LBUTTONDOWN:\r
-\r
-               x = (short)LOWORD(lParam);\r
-               y = (short)HIWORD(lParam);\r
-\r
-               //if clicked on a button\r
-               if((buttonptr = CardButtonFromPoint(x, y)) != 0)\r
-               {\r
-                       if(buttonptr->OnLButtonDown(hwnd, x, y) == 0)\r
-                               buttonptr = 0;\r
-\r
-                       return 0;\r
-               }\r
-\r
-               if((stackptr = CardRegionFromPoint(x, y)) != 0)\r
-               {\r
-                       if(!stackptr->OnLButtonDown(x, y))\r
-                               stackptr = 0;\r
-               }\r
-               \r
-               return 0;\r
-\r
-       case WM_LBUTTONUP:\r
-               \r
-               x = (short)LOWORD(lParam);\r
-               y = (short)HIWORD(lParam);\r
-\r
-               //\r
-               // if we were clicking a button\r
-               //\r
-               if(buttonptr != 0)\r
-               {\r
-                       buttonptr->OnLButtonUp(hwnd, x, y);\r
-                       buttonptr = 0;\r
-                       return 0;\r
-               }\r
-               \r
-               if(stackptr != 0)\r
-               {\r
-                       stackptr->OnLButtonUp(x, y);\r
-                       stackptr = 0;\r
-                       return 0;\r
-               }\r
-\r
-               return 0;\r
-\r
-       case WM_MOUSEMOVE:\r
-               \r
-               x = (short)LOWORD(lParam);\r
-               y = (short)HIWORD(lParam);\r
-\r
-               // if we were clicking a button\r
-               if(buttonptr != 0)\r
-               {\r
-                       buttonptr->OnMouseMove(hwnd, x, y);\r
-                       return 0;\r
-               }\r
-\r
-               if(stackptr != 0)\r
-               {\r
-                       return stackptr->OnMouseMove(x, y);\r
-               }\r
-               \r
-               return 0;\r
-\r
-       }\r
-\r
-       return DefWindowProc (hwnd, iMsg, wParam, lParam);\r
+    HDC hdc;\r
+    PAINTSTRUCT ps;\r
+\r
+    CREATESTRUCT *cs;\r
+\r
+    static CardButton *buttonptr   = 0;\r
+    static CardRegion *stackptr    = 0;\r
+\r
+    int x, y, i;\r
+\r
+    switch(iMsg)\r
+    {\r
+    case WM_NCCREATE:\r
+\r
+        // When we created this window, we passed in the\r
+        // pointer to the class object (CardWindow *) in the\r
+        // call to CreateWindow.\r
+        cs = (CREATESTRUCT *)lParam;\r
+\r
+        //\r
+        // associate this class with the window\r
+        //\r
+        SetWindowLong(hwnd, 0, (LONG)cs->lpCreateParams);\r
+\r
+        return 1;\r
+\r
+    case WM_NCDESTROY:\r
+        // Don't delete anything here..\r
+        break;\r
+\r
+    case WM_SIZE:\r
+        nWidth = LOWORD(lParam);\r
+        nHeight = HIWORD(lParam);\r
+        \r
+        //\r
+        // reposition all the stacks and buttons\r
+        // in case any of them are centered, right-justified etc\r
+        //\r
+        for(i = 0; i < nNumCardRegions; i++)\r
+        {\r
+            Regions[i]->AdjustPosition(nWidth, nHeight);\r
+        }\r
+    \r
+        for(i = 0; i < nNumButtons; i++)\r
+        {\r
+            Buttons[i]->AdjustPosition(nWidth, nHeight);\r
+        }\r
+\r
+        // \r
+        // Call the user-defined resize proc AFTER all the stacks\r
+        // have been positioned\r
+        //\r
+        if(ResizeWndCallback) \r
+            ResizeWndCallback(nWidth, nHeight);\r
+\r
+        return 0;\r
+\r
+    case WM_PAINT:\r
+\r
+        hdc = BeginPaint(hwnd, &ps);\r
+\r
+        Paint(hdc);\r
+\r
+        EndPaint(hwnd, &ps);\r
+        return 0;\r
+\r
+    case WM_TIMER:\r
+        \r
+        //find the timer object in the registered funcs\r
+        /*if(wParam >= 0x10000)\r
+        {\r
+            for(i = 0; i < nRegFuncs; i++)\r
+            {\r
+                if(RegFuncs[i].id == wParam)\r
+                {\r
+                    KillTimer(hwnd, wParam);\r
+    \r
+                    //call the registered function!!\r
+                    RegFuncs[i].func(RegFuncs[i].dwParam);\r
+    \r
+                    RegFuncs[i] = RegFuncs[nRegFuncs-1];\r
+                    nRegFuncs--;\r
+                }\r
+            }\r
+        }\r
+        else*/\r
+        {\r
+            //find the cardstack\r
+            CardRegion *stackobj = (CardRegion *)wParam;//CardStackFromId(wParam);\r
+            stackobj->DoFlash();\r
+        }\r
+\r
+        return 0;\r
+\r
+    case WM_LBUTTONDBLCLK:\r
+\r
+        x = (short)LOWORD(lParam);\r
+        y = (short)HIWORD(lParam);\r
+\r
+        if((buttonptr = CardButtonFromPoint(x, y)) != 0)\r
+        {\r
+            buttonptr->OnLButtonDown(hwnd, x, y);\r
+            return 0;\r
+        }\r
+\r
+        if((stackptr = CardRegionFromPoint(x, y)) != 0)\r
+        {\r
+            stackptr->OnLButtonDblClk(x, y);\r
+            stackptr = 0;\r
+        }\r
+\r
+        return 0;\r
+\r
+    case WM_LBUTTONDOWN:\r
+\r
+        x = (short)LOWORD(lParam);\r
+        y = (short)HIWORD(lParam);\r
+\r
+        //if clicked on a button\r
+        if((buttonptr = CardButtonFromPoint(x, y)) != 0)\r
+        {\r
+            if(buttonptr->OnLButtonDown(hwnd, x, y) == 0)\r
+                buttonptr = 0;\r
+\r
+            return 0;\r
+        }\r
+\r
+        if((stackptr = CardRegionFromPoint(x, y)) != 0)\r
+        {\r
+            if(!stackptr->OnLButtonDown(x, y))\r
+                stackptr = 0;\r
+        }\r
+        \r
+        return 0;\r
+\r
+    case WM_LBUTTONUP:\r
+        \r
+        x = (short)LOWORD(lParam);\r
+        y = (short)HIWORD(lParam);\r
+\r
+        //\r
+        // if we were clicking a button\r
+        //\r
+        if(buttonptr != 0)\r
+        {\r
+            buttonptr->OnLButtonUp(hwnd, x, y);\r
+            buttonptr = 0;\r
+            return 0;\r
+        }\r
+        \r
+        if(stackptr != 0)\r
+        {\r
+            stackptr->OnLButtonUp(x, y);\r
+            stackptr = 0;\r
+            return 0;\r
+        }\r
+\r
+        return 0;\r
+\r
+    case WM_MOUSEMOVE:\r
+        \r
+        x = (short)LOWORD(lParam);\r
+        y = (short)HIWORD(lParam);\r
+\r
+        // if we were clicking a button\r
+        if(buttonptr != 0)\r
+        {\r
+            buttonptr->OnMouseMove(hwnd, x, y);\r
+            return 0;\r
+        }\r
+\r
+        if(stackptr != 0)\r
+        {\r
+            return stackptr->OnMouseMove(x, y);\r
+        }\r
+        \r
+        return 0;\r
+\r
+    }\r
+\r
+      return DefWindowProc (hwnd, iMsg, wParam, lParam);\r
 }\r
 \r
 \r
 CardRegion* CardWindow::CardRegionFromId(int id)\r
 {\r
-       for(int i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               if(Regions[i]->id == id)\r
-                       return Regions[i];\r
-       }\r
+    for(int i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        if(Regions[i]->id == id)\r
+            return Regions[i];\r
+    }\r
 \r
-       return 0;\r
+    return 0;\r
 }\r
 \r
 CardButton* CardWindow::CardButtonFromId(int id)\r
 {\r
-       for(int i = 0; i < nNumButtons; i++)\r
-       {\r
-               if(Buttons[i]->id == id)\r
-                       return Buttons[i];\r
-       }\r
+    for(int i = 0; i < nNumButtons; i++)\r
+    {\r
+        if(Buttons[i]->id == id)\r
+            return Buttons[i];\r
+    }\r
 \r
-       return 0;\r
+    return 0;\r
 }\r
 \r
 void CardWindow::Redraw()\r
 {\r
-       InvalidateRect(m_hWnd, 0, 0);\r
-       UpdateWindow(m_hWnd);\r
+    InvalidateRect(m_hWnd, 0, 0);\r
+    UpdateWindow(m_hWnd);\r
 }\r
 \r
 bool CardWindow::DeleteButton(CardButton *pButton)\r
 {\r
-       for(int i = 0; i < nNumButtons; i++)\r
-       {\r
-               if(Buttons[i] == pButton)\r
-               {\r
-                       CardButton *cb = Buttons[i];\r
-                       \r
-                       //shift any after this one backwards\r
-                       for(int j = i; j < nNumButtons - 1; j++)\r
-                       {\r
-                               Buttons[j] = Buttons[j + 1];\r
-                       }\r
-\r
-                       delete cb;\r
-                       nNumButtons--;\r
-                       \r
-                       return true;\r
-               }\r
-       }\r
-\r
-       return false;\r
+    for(int i = 0; i < nNumButtons; i++)\r
+    {\r
+        if(Buttons[i] == pButton)\r
+        {\r
+            CardButton *cb = Buttons[i];\r
+            \r
+            //shift any after this one backwards\r
+            for(int j = i; j < nNumButtons - 1; j++)\r
+            {\r
+                Buttons[j] = Buttons[j + 1];\r
+            }\r
+\r
+            delete cb;\r
+            nNumButtons--;\r
+            \r
+            return true;\r
+        }\r
+    }\r
+\r
+    return false;\r
 }\r
 \r
 bool CardWindow::DeleteRegion(CardRegion *pRegion)\r
 {\r
-       for(int i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               if(Regions[i] == pRegion)\r
-               {\r
-                       CardRegion *cr = Regions[i];\r
-                       \r
-                       //shift any after this one backwards\r
-                       for(int j = i; j < nNumCardRegions - 1; j++)\r
-                       {\r
-                               Regions[j] = Regions[j + 1];\r
-                       }\r
-\r
-                       delete cr;\r
-                       nNumCardRegions--;\r
-\r
-                       return true;\r
-               }\r
-       }\r
-\r
-       return false;\r
+    for(int i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        if(Regions[i] == pRegion)\r
+        {\r
+            CardRegion *cr = Regions[i];\r
+            \r
+            //shift any after this one backwards\r
+            for(int j = i; j < nNumCardRegions - 1; j++)\r
+            {\r
+                Regions[j] = Regions[j + 1];\r
+            }\r
+\r
+            delete cr;\r
+            nNumCardRegions--;\r
+\r
+            return true;\r
+        }\r
+    }\r
+\r
+    return false;\r
 }\r
 \r
 void CardWindow::EmptyStacks(void)\r
 {\r
-       for(int i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               Regions[i]->Clear();\r
-               Regions[i]->Update();\r
-       }\r
+    for(int i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        Regions[i]->Clear();\r
+        Regions[i]->Update();\r
+    }\r
 \r
-       Redraw();\r
+    Redraw();\r
 }\r
 \r
 bool CardWindow::DistributeStacks(int nIdFrom, int nNumStacks, UINT xJustify, int xSpacing, int nStartX)\r
 {\r
-       int numvisiblestacks = 0;\r
-       int curx = nStartX;\r
-       int startindex = -1;\r
-       int i;\r
-\r
-       //find the stack which starts with our ID\r
-       for(i = 0; i < nNumCardRegions; i++)\r
-       {\r
-               if(Regions[i]->Id() == nIdFrom)\r
-               {\r
-                       startindex = i;\r
-                       break;\r
-               }\r
-       }\r
-\r
-       //if didn't find, return\r
-       if(i == nNumCardRegions) return false;\r
-\r
-       //count the stacks that are visible\r
-       for(i = startindex; i < startindex + nNumStacks; i++)\r
-       {\r
-               if(Regions[i]->IsVisible())\r
-                       numvisiblestacks++;\r
-       }\r
-       \r
-       if(xJustify == CS_XJUST_CENTER)\r
-       {\r
-               //startx -= ((numvisiblestacks + spacing) * cardwidth - spacing) / 2;\r
-               int viswidth;\r
-               viswidth = numvisiblestacks * __cardwidth;\r
-               viswidth += xSpacing * (numvisiblestacks - 1);\r
-               curx = -(viswidth  - __cardwidth) / 2;\r
-\r
-               for(i = startindex; i < startindex + nNumStacks; i++)\r
-               {\r
-                       if(Regions[i]->IsVisible())\r
-                       {\r
-                               Regions[i]->xadjust = curx;\r
-                               Regions[i]->xjustify = CS_XJUST_CENTER;\r
-                               curx += Regions[i]->width + xSpacing;\r
-                       }\r
-                       \r
-               }\r
-       }\r
-\r
-       if(xJustify == CS_XJUST_RIGHT)\r
-       {\r
-               nStartX -= ((numvisiblestacks + xSpacing) * __cardwidth - xSpacing);\r
-       }\r
-       \r
-       if(xJustify == CS_XJUST_NONE)\r
-       {\r
-               for(i = startindex; i < startindex + nNumStacks; i++)\r
-               {\r
-                       if(Regions[i]->IsVisible())\r
-                       {\r
-                               Regions[i]->xpos = curx;\r
-                               curx += Regions[i]->width + xSpacing;\r
-                               Regions[i]->UpdateSize();\r
-                       }\r
-                       \r
-               }\r
-       }\r
-\r
-       return 0;\r
+    int numvisiblestacks = 0;\r
+    int curx = nStartX;\r
+    int startindex = -1;\r
+    int i;\r
+\r
+    //find the stack which starts with our ID\r
+    for(i = 0; i < nNumCardRegions; i++)\r
+    {\r
+        if(Regions[i]->Id() == nIdFrom)\r
+        {\r
+            startindex = i;\r
+            break;\r
+        }\r
+    }\r
+\r
+    //if didn't find, return\r
+    if(i == nNumCardRegions) return false;\r
+\r
+    //count the stacks that are visible\r
+    for(i = startindex; i < startindex + nNumStacks; i++)\r
+    {\r
+        if(Regions[i]->IsVisible())\r
+            numvisiblestacks++;\r
+    }\r
+    \r
+    if(xJustify == CS_XJUST_CENTER)\r
+    {\r
+        //startx -= ((numvisiblestacks + spacing) * cardwidth - spacing) / 2;\r
+        int viswidth;\r
+        viswidth = numvisiblestacks * __cardwidth;\r
+        viswidth += xSpacing * (numvisiblestacks - 1);\r
+        curx = -(viswidth  - __cardwidth) / 2;\r
+\r
+        for(i = startindex; i < startindex + nNumStacks; i++)\r
+        {\r
+            if(Regions[i]->IsVisible())\r
+            {\r
+                Regions[i]->xadjust = curx;\r
+                Regions[i]->xjustify = CS_XJUST_CENTER;\r
+                curx += Regions[i]->width + xSpacing;\r
+            }\r
+            \r
+        }\r
+    }\r
+\r
+    if(xJustify == CS_XJUST_RIGHT)\r
+    {\r
+        nStartX -= ((numvisiblestacks + xSpacing) * __cardwidth - xSpacing);\r
+    }\r
+    \r
+    if(xJustify == CS_XJUST_NONE)\r
+    {\r
+        for(i = startindex; i < startindex + nNumStacks; i++)\r
+        {\r
+            if(Regions[i]->IsVisible())\r
+            {\r
+                Regions[i]->xpos = curx;\r
+                curx += Regions[i]->width + xSpacing;\r
+                Regions[i]->UpdateSize();\r
+            }\r
+            \r
+        }\r
+    }\r
+\r
+    return 0;\r