--- trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp.bak 2005-03-10 04:04:27 UTC (rev 13904)
+++ trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp.bak 2005-03-10 04:05:53 UTC (rev 13905)
@@ -1,489 +0,0 @@
-//
-// CardLib - CardButton class
-//
-// Freeware
-// Copyright J Brown 2001
-//
-#include <windows.h>
-#include <tchar.h>
-
-#include "cardlib.h"
-#include "cardwindow.h"
-#include "cardbutton.h"
-#include "cardcolor.h"
-
-HPALETTE UseNicePalette(HDC, HPALETTE);
-void RestorePalette(HDC, HPALETTE);
-
-void PaintRect(HDC hdc, RECT *rect, COLORREF colour);
-
-CardButton::CardButton(CardWindow &parent, int Id, TCHAR *szText, UINT Style, bool visible,
- int x, int y, int width, int height)
-
- : parentWnd(parent), id(Id), fVisible(visible), uStyle(Style), ButtonCallback(0)
-{
- crText = RGB(255,255,255);
- crBack = RGB(0, 128, 0);
-
- xadjust = 0;
- yadjust = 0;
- xjustify = 0;
- yjustify = 0;
-
- fMouseDown = false;
- fButtonDown = false;
-
- hIcon = 0;
-
- SetText(szText);
- Move(x, y, width, height);
-
- mxlock = CreateMutex(0, FALSE, 0);
-
- hFont = 0;
-}
-
-CardButton::~CardButton()
-{
- CloseHandle(mxlock);
-}
-
-void CardButton::DrawRect(HDC hdc, RECT *rect, bool fNormal)
-{
- RECT fill;
-
- HANDLE hOld;
-
- HPEN hhi = CreatePen(0, 0, MAKE_PALETTERGB(crHighlight));
- HPEN hsh = CreatePen(0, 0, MAKE_PALETTERGB(crShadow));
- HPEN hbl = (HPEN)GetStockObject(BLACK_PEN);
-
- int x = rect->left;
- int y = rect->top;
- int width = rect->right-rect->left - 1;
- int height = rect->bottom-rect->top - 1;
-
- SetRect(&fill, x+1, y+1, x+width-1, y+height-1);
-
- int one = 1;
-
- if(!fNormal)
- {
- x += width;
- y += height;
- width = -width;
- height = -height;
- one = -1;
- OffsetRect(&fill, 1, 1);
- }
-
- if(fNormal)
- hOld = SelectObject(hdc, hhi);
- else
- hOld = SelectObject(hdc, hhi);
-
- MoveToEx(hdc, x, y+height, 0);
- LineTo(hdc, x, y);
- LineTo(hdc, x+width, y);
- SelectObject(hdc, hOld);
-
- hOld = SelectObject(hdc, hbl);
- LineTo(hdc, x+width, y+height);
- LineTo(hdc, x-one, y+height);
- SelectObject(hdc, hOld);
-
- hOld = SelectObject(hdc, hsh);
- MoveToEx(hdc, x+one, y+height-one, 0);
- LineTo(hdc, x+width-one, y+height-one);
- LineTo(hdc, x+width-one, y);
- SelectObject(hdc, hOld);
-
- PaintRect(hdc, &fill, MAKE_PALETTERGB(crBack));
-
- DeleteObject(hhi);
- DeleteObject(hsh);
-}
-
-void CardButton::Clip(HDC hdc)
-{
- if(fVisible == false) return;
-
- ExcludeClipRect(hdc, rect.left, rect.top, rect.right, rect.bottom);
-}
-
-void CardButton::Draw(HDC hdc, bool fNormal)
-{
- SIZE textsize;
- int x, y; //text x, y
- int ix, iy; //icon x, y
- int iconwidth = 0;
-
- RECT cliprect;
-
- if(fVisible == 0) return;
-
- if(hFont == 0)
- SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- else
- SelectObject(hdc, hFont);
-
- GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textsize);
-
- if(hIcon)
- {
- x = rect.left + 32 + 8;
- }
- else
- {
- if(uStyle & CB_ALIGN_LEFT)
- {
- x = rect.left + iconwidth;
- }
- else if(uStyle & CB_ALIGN_RIGHT)
- {
- x = rect.left + (rect.right-rect.left-iconwidth-textsize.cx);
- }
- else //centered
- {
- x = rect.right - rect.left - iconwidth;
- x = (x - textsize.cx) / 2;
- x += rect.left + iconwidth;
- }
- }
-
- y = rect.bottom - rect.top;
- y = (y - textsize.cy) / 2;
- y += rect.top;
-
- //calc icon position..
- ix = rect.left + 4;
- iy = rect.top + (rect.bottom-rect.top-32) / 2;
-
- //if button is pressed, then shift text
- if(fNormal == false && (uStyle & CB_PUSHBUTTON))
- {
- x += 1;
- y += 1;
- ix += 1;
- iy += 1;
- }
-
- SetRect(&cliprect, x, y, x+textsize.cx, y+textsize.cy);
- ExcludeClipRect(hdc, x, y, x+textsize.cx, y+textsize.cy);
-
- //
- // Calc icon pos
- //
-
- if(hIcon)
- {
- ExcludeClipRect(hdc, ix, iy, ix + 32, iy + 32);
- }
-
- if(uStyle & CB_PUSHBUTTON)
- {
- DrawRect(hdc, &rect, fNormal);
-
- SetBkColor(hdc, MAKE_PALETTERGB(crBack));
- SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
-
- SelectClipRgn(hdc, 0);
-
- ExtTextOut(hdc, x, y, ETO_OPAQUE, &cliprect, szText, lstrlen(szText), 0);
- }
- else
- {
- SetBkColor(hdc, MAKE_PALETTERGB(crBack));
- SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));
-
- SelectClipRgn(hdc, 0);
-
- ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0);
- }
-
- if(hIcon)
- {
- HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBack));
- DrawIconEx(hdc, ix, iy, hIcon, 32, 32, 0, hbr, 0);
- DeleteObject(hbr);
- }
-
-}
-
-void CardButton::AdjustPosition(int winwidth, int winheight)
-{
- int width = rect.right-rect.left;
- int height = rect.bottom-rect.top;
-
- width = width & ~0x1;
-
- switch(xjustify)
- {
- case CS_XJUST_NONE:
- break;
-
- case CS_XJUST_CENTER: //centered
- rect.left = (winwidth - (width)) / 2;
- rect.left += xadjust;
- rect.right = rect.left+width;
- break;
-
- case CS_XJUST_RIGHT: //right-aligned
- rect.left = winwidth - width;
- rect.left += xadjust;
- rect.right = rect.left+width;
- break;
- }
-
- switch(yjustify)
- {
- case CS_YJUST_NONE:
- break;
-
- case CS_YJUST_CENTER: //centered
- rect.top = (winheight - (height)) / 2;
- rect.top += yadjust;
- rect.bottom = rect.top+height;
- break;
-
- case CS_YJUST_BOTTOM: //right-aligned
- rect.top = winheight - height;
- rect.top += yadjust;
- rect.bottom = rect.top+height;
- break;
- }
-
-}
-
-int CardButton::OnLButtonDown(HWND hwnd, int x, int y)
-{
- if((uStyle & CB_PUSHBUTTON) == 0)
- return 0;
-
- //make sure that the user is allowed to do something
- if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)
- {
- return 0;
- }
- else
- {
- ReleaseMutex(mxlock);
- }
-
- fMouseDown = true;
- fButtonDown = true;
-
- Redraw();
-
- SetCapture(hwnd);
-
- return 1;
-}
-
-int CardButton::OnMouseMove(HWND hwnd, int x, int y)
-{
- if(fMouseDown)
- {
- bool fOldButtonDown = fButtonDown;
-
- POINT pt;
-
- pt.x = x;
- pt.y = y;
-
- if(PtInRect(&rect, pt))
- fButtonDown = true;
- else
- fButtonDown = false;
-
- if(fButtonDown != fOldButtonDown)
- Redraw();
- }
-
- return 0;
-}
-
-int CardButton::OnLButtonUp(HWND hwnd, int x, int y)
-{
- if(fMouseDown)
- {
- fMouseDown = false;
- fButtonDown = false;
-
- if(uStyle & CB_PUSHBUTTON)
- {
- Redraw();
- ReleaseCapture();
- }
-
- //if have clicked the button
- if(parentWnd.CardButtonFromPoint(x, y) == this)
- {
- if(ButtonCallback)
- {
- ButtonCallback(*this);
- }
- else
- {
- HWND hwnd = (HWND)parentWnd;
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(id, BN_CLICKED), (LONG)hwnd);
- }
- }
- }
-
- return 0;
-}
-
-#define _countof(array) (sizeof(array)/sizeof(array[0]))
-
-CardButton *CardWindow::CreateButton(int id, TCHAR *szText, UINT uStyle, bool fVisible, int x, int y, int width, int height)
-{
- CardButton *cb;
-
- if(nNumButtons == MAXBUTTONS)
- return 0;
-
- cb = new CardButton(*this, id, szText, uStyle, fVisible, x, y, width, height);
- Buttons[nNumButtons++] = cb;
-
- if(uStyle & CB_PUSHBUTTON)
- {
- cb->SetBackColor(CardButton::GetFace(crBackgnd));
- //cb->SetBackColor(ScaleLumRGB(crBackgnd, 0.1));
- cb->SetForeColor(RGB(255,255,255));
- }
- else
- {
- cb->SetBackColor(crBackgnd);
- cb->SetForeColor(RGB(255,255,255));
- }
-
- return cb;
-}
-
-void CardButton::SetText(TCHAR *lpszFormat, ...)
-{
- int count;
-
- va_list args;
- va_start(args, lpszFormat);
-
- count = wvsprintf(szText, lpszFormat, args);
- va_end(args);
-}
-
-int CardButton::Id()
-{
- return id;
-}
-
-void CardButton::Show(bool fShow)
-{
- fVisible = fShow;
-}
-
-void CardButton::Move(int x, int y, int width, int height)
-{
- SetRect(&rect, x, y, x+width, y+height);
-}
-
-void CardButton::Redraw()
-{
- HDC hdc = GetDC((HWND)parentWnd);
-
- HPALETTE hOldPal = UseNicePalette(hdc, __hPalette);
-
- Draw(hdc, !fButtonDown);
-
- RestorePalette(hdc, hOldPal);
-
- ReleaseDC((HWND)parentWnd, hdc);
-}
-
-void CardButton::SetForeColor(COLORREF cr)
-{
- crText = cr;
-}
-
-void CardButton::SetBackColor(COLORREF cr)
-{
- crBack = cr;
-
- crHighlight = GetHighlight(cr);
- crShadow = GetShadow(cr);
-
- //crHighlight = ScaleLumRGB(cr, +0.25);
- //crShadow = ScaleLumRGB(cr, -0.25);
-}
-
-// Static member
-COLORREF CardButton::GetHighlight(COLORREF crBase)
-{
- return ColorScaleRGB(crBase, RGB(255,255,255), 0.25);
-}
-
-// Static member
-COLORREF CardButton::GetShadow(COLORREF crBase)
-{
- return ColorScaleRGB(crBase, RGB(0, 0, 0), 0.25);
-}
-
-COLORREF CardButton::GetFace(COLORREF crBase)
-{
- return ColorScaleRGB(crBase, RGB(255,255,255), 0.1);
-}
-
-void CardButton::SetPlacement(UINT xJustify, UINT yJustify, int xAdjust, int yAdjust)
-{
- xadjust = xAdjust;
- yadjust = yAdjust;
- xjustify = xJustify;
- yjustify = yJustify;
-}
-
-void CardButton::SetIcon(HICON hicon, bool fRedraw)
-{
- hIcon = hicon;
-
- if(fRedraw)
- Redraw();
-}
-
-void CardButton::SetFont(HFONT font)
-{
- //don't delete the existing font..
- hFont = font;
-}
-
-void CardButton::SetButtonProc(pButtonProc proc)
-{
- ButtonCallback = proc;
-}
-
-bool CardButton::Lock()
-{
- DWORD dw = WaitForSingleObject(mxlock, 0);
-
- if(dw == WAIT_OBJECT_0)
- return true;
- else
- return false;
-}
-
-bool CardButton::UnLock()
-{
- if(ReleaseMutex(mxlock))
- return true;
- else
- return false;
-}
-
-void CardButton::SetStyle(UINT style)
-{
- uStyle = style;
-}
-
-UINT CardButton::GetStyle()
-{
- return uStyle;
-}
\ No newline at end of file
--- trunk/rosapps/games/solitaire/cardlib/cardrgnmouse.cpp.bak 2005-03-10 04:04:27 UTC (rev 13904)
+++ trunk/rosapps/games/solitaire/cardlib/cardrgnmouse.cpp.bak 2005-03-10 04:05:53 UTC (rev 13905)
@@ -1,618 +0,0 @@
-//
-// CardLib - CardRegion mouse-related stuff
-//
-// Freeware
-// Copyright J Brown 2001
-//
-#include <windows.h>
-#include <math.h>
-
-#include "cardlib.h"
-#include "cardwindow.h"
-#include "cardregion.h"
-
-double __CARDZOOMSPEED = 32;
-
-int ClipCard(HDC hdc, int x, int y, int width, int height);
-void DrawCard(HDC hdc, int x, int y, HDC hdcSource, int width, int height);
-
-#ifdef _DEBUG
-
-static pDebugClickProc DebugStackClickProc = 0;
-
-void CardLib_SetStackClickProc(pDebugClickProc proc)
-{
- DebugStackClickProc = proc;
-}
-
-#endif
-
-CardRegion *CardWindow::GetBestStack(int x, int y, int w, int h)
-{
- int maxoverlap = 0;
- int maxoverlapidx = -1;
-
- //find the stack which is most covered by the dropped
- //cards. Only include those which allow drops.
- //
- for(int i = 0; i < nNumCardRegions; i++)
- {
- int percent = Regions[i]->GetOverlapRatio(x, y, w, h);
-
- //if this stack has the biggest coverage yet
- if(percent > maxoverlap && Regions[i]->IsVisible())
- {
- maxoverlap = percent;
- maxoverlapidx = i;
- }
- }
-
- //if we found a stack to drop onto
- if(maxoverlapidx != -1)
- {
- return Regions[maxoverlapidx];
- }
- else
- {
- return 0;
- }
-}
-
-bool CardRegion::IsPointInStack(int x, int y)
-{
- int axpos = xoffset < 0 ? xpos + (nNumApparentCards-1)*xoffset : xpos;
- int aypos = yoffset < 0 ? ypos + (nNumApparentCards-1)*yoffset : ypos;
-
- if(x >= axpos && x < axpos + width && y >= aypos && y < aypos + height && fVisible)
- return true;
- else
- return false;
-}
-
-int CardRegion::GetNumDragCards(int x, int y)
-{
- int cardindex = 0; //index from stack start
- int maxidx;
-
- //make x,y relative to the stack's upper left corner
- x -= xpos + (xoffset < 0 ? (nNumApparentCards/*cardstack.NumCards()*/ - 1) * xoffset : 0);
- y -= ypos + (yoffset < 0 ? (nNumApparentCards/*cardstack.NumCards()*/ - 1) * yoffset : 0);
-
- //if stack is empty, cannot drag any cards from it
- if(cardstack.NumCards() <= 0)
- return 0;
-
- //see which card in the stack has been clicked on
- //top-bottom ordering
- if(yoffset > 0)
- {
- if(y < height - __cardheight)
- cardindex = y / yoffset;
- else
- cardindex = cardstack.NumCards() - 1;
- }
- else if(yoffset < 0)
- {
- if(y < __cardheight)
- cardindex = cardstack.NumCards() - 1;
- else
- cardindex = cardstack.NumCards() - ((y - __cardheight) / -yoffset) - 2;
- }
- else //yoffset == 0
- {
- cardindex = cardstack.NumCards() - 1;
- }
-
- maxidx = cardindex;
-
- //if left-right
- if(xoffset > 0)
- {
- if(x < width - __cardwidth)
- cardindex = x / xoffset;
- else
- cardindex = cardstack.NumCards() - 1;
- }
- else if(xoffset < 0)
- {
- if(x < __cardwidth)
- cardindex = cardstack.NumCards() - 1;
- else
- cardindex = cardstack.NumCards() - ((x - __cardwidth) / -xoffset) - 2;
- }
- else
- {
- cardindex = cardstack.NumCards() - 1;
- }
-
- if(cardindex > maxidx) cardindex = maxidx;
-
- if(cardindex > cardstack.NumCards())
- cardindex = 1;
-
- //if are trying to drag too many cards at once
- return cardstack.NumCards() - cardindex;
-}
-
-bool CardRegion::CanDragCards(int iNumCards)
-{
- if(iNumCards <= 0) return false;
- if(nThreedCount > 1 && iNumCards > 1) return false;
-
- if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)
- {
-// TRACE("Failed to gain access to card stack\n");
- return false;
- }
-
- ReleaseMutex(mxlock);
-
- switch(uDragRule)
- {
- case CS_DRAG_ALL:
- return true;
-
- case CS_DRAG_TOP:
-
- if(iNumCards == 1)
- return true;
- else
- return false;
-
- case CS_DRAG_NONE:
- return false;
-
- case CS_DRAG_CALLBACK:
-
- if(CanDragCallback)
- {
- return CanDragCallback(*this, iNumCards);
- }
- else
- {
- return false;
- }
-
- default:
- return false;
- }
-}
-
-bool CardRegion::CanDropCards(CardStack &cards)
-{
- if(WaitForSingleObject(mxlock, 0) != WAIT_OBJECT_0)
- {
- return false;
- }
-
- ReleaseMutex(mxlock);
-
- switch(uDropRule)
- {
- case CS_DROP_ALL:
- return true;
-
- case CS_DROP_NONE:
- return false;
-
- case CS_DROP_CALLBACK:
-
- if(CanDropCallback)
- {
- return CanDropCallback(*this, cards);
- }
- else
- {
- return false;
- }
-
- default:
- return false;
- }
-}
-
-bool CardRegion::OnLButtonDblClk(int x, int y)
-{
- iNumDragCards = GetNumDragCards(x, y);
-
- if(DblClickCallback)
- DblClickCallback(*this, iNumDragCards);
-
- return true;
-}
-
-bool CardRegion::OnLButtonDown(int x, int y)
-{
- iNumDragCards = GetNumDragCards(x, y);
-
-#ifdef _DEBUG
- if(DebugStackClickProc)
- {
- if(!DebugStackClickProc(*this))
- return false;
- }
-#endif
-
- if(ClickCallback)
- ClickCallback(*this, iNumDragCards);
-
- if(CanDragCards(iNumDragCards) != false)
- {
-
- //offset of the mouse cursor relative to the top-left corner
- //of the cards that are being dragged
- mousexoffset = x - xpos - xoffset * (nNumApparentCards - iNumDragCards);
- mouseyoffset = y - ypos - yoffset * (nNumApparentCards - iNumDragCards);
-
- if(xoffset < 0)
- mousexoffset += -xoffset * (iNumDragCards - 1);
-
- if(yoffset < 0)
- mouseyoffset += -yoffset * (iNumDragCards - 1);
-
- //remove the cards from the source stack
- dragstack = cardstack.Pop(iNumDragCards);
-
- //prepare the back buffer, and the drag image
- PrepareDragBitmaps(iNumDragCards);
-
- oldx = x - mousexoffset;
- oldy = y - mouseyoffset;
-
- Update(); //Update this stack's card count + size
-
- SetCapture((HWND)parentWnd);
-
- //set AFTER settings the dragstack...
- fMouseDragging = true;
-
- return true;
- }
-
- return false;
-}
-
-bool CardRegion::OnLButtonUp(int x, int y)
-{
- CardRegion *pDestStack = 0;
- HDC hdc;
- int dropstackid = CS_DROPZONE_NODROP;
-
- RECT dragrect;
- DropZone *dropzone;
-
- fMouseDragging = false;
-
- //first of all, see if any drop zones have been registered
- SetRect(&dragrect, x-mousexoffset, y-mouseyoffset, x-mousexoffset+nDragCardWidth, y-mouseyoffset+nDragCardHeight);
-
- dropzone = parentWnd.GetDropZoneFromRect(&dragrect);
-
- if(dropzone)
- {
- dropstackid = dropzone->DropCards(dragstack);
-
- if(dropstackid != CS_DROPZONE_NODROP)
- pDestStack = parentWnd.CardRegionFromId(dropstackid);
- else
- pDestStack = 0;
- }
- else
- {
- pDestStack = parentWnd.GetBestStack(x - mousexoffset, y - mouseyoffset, nDragCardWidth, nDragCardHeight);
- }
-
- // If have found a stack to drop onto
- //
- if(pDestStack && pDestStack->CanDropCards(dragstack))
- {
- hdc = GetDC((HWND)parentWnd);
- // UseNicePalette(hdc);
- ZoomCard(hdc, x - mousexoffset, y - mouseyoffset, pDestStack);
- ReleaseDC((HWND)parentWnd, hdc);
-
- //
- //add the cards to the destination stack
- //
- CardStack temp = pDestStack->GetCardStack();
- temp.Push(dragstack);
-
- pDestStack->SetCardStack(temp);
-// pDestStack->Update(); //Update this stack's card count + size
-// pDestStack->UpdateFaceDir(temp);
-
- // Call the remove callback on THIS stack, if one is specified
- //
- if(RemoveCallback)
- RemoveCallback(*this, iNumDragCards);
-
- // Call the add callback, if one is specified
- //
- if(pDestStack->AddCallback)
- pDestStack->AddCallback(*pDestStack, pDestStack->cardstack);//index, deststack->numcards);
-
- RedrawIfNotDim(pDestStack, true);
- }
-
- //
- // Otherwise, let the cards snap back onto this stack
- //
- else
- {
-
- hdc = GetDC((HWND)parentWnd);
- ZoomCard(hdc, x - mousexoffset, y - mouseyoffset, this);
- cardstack += dragstack;
- ReleaseDC((HWND)parentWnd, hdc);
-
- Update(); //Update this stack's card count + size
- }
-
- ReleaseDragBitmaps();
- ReleaseCapture();
-
- return true;
-}
-
-bool CardRegion::OnMouseMove(int x, int y)
-{
- HDC hdc;
-
- hdc = GetDC((HWND)parentWnd);
-
- x -= mousexoffset;
- y -= mouseyoffset;
-
- MoveDragCardTo(hdc, x, y);
-
- //BitBlt(hdc, nDragCardWidth+10, 0, nDragCardWidth, nDragCardHeight, hdcBackGnd, 0, 0, SRCCOPY);
- //BitBlt(hdc, 0, 0, nDragCardWidth, nDragCardHeight, hdcDragCard, 0, 0, SRCCOPY);
-
- ReleaseDC((HWND)parentWnd, hdc);
-
- oldx = x;
- oldy = y;
-
- return true;
-}
-
-//
-// There is a bug in BitBlt when the source x,y
-// become < 0. So this wrapper function simply adjusts
-// the coords so that we never try to blt in from this range
-//
-BOOL ClippedBitBlt(HDC hdcDest, int x, int y, int width, int height, HDC hdcSrc, int srcx, int srcy, DWORD dwROP)
-{
- if(srcx < 0)
- {
- x = 0 - srcx;
- width = width + srcx;
- srcx = 0;
- }
-
- if(srcy < 0)
- {
- y = 0 - srcy;
- height = height + srcy;
- srcy = 0;
- }
-
- return BitBlt(hdcDest, x, y, width, height, hdcSrc, srcx, srcy, dwROP);
-}
-
-void CardRegion::MoveDragCardTo(HDC hdc, int x, int y)
-{
- RECT inter, rect1, rect2;
-
- //mask off the new position of the drag-card, so
- //that it will not be painted over
- ClipCard(hdc, x, y, nDragCardWidth, nDragCardHeight);
-
- //restore the area covered by the card at its previous position
- BitBlt(hdc, oldx, oldy, nDragCardWidth, nDragCardHeight, hdcBackGnd, 0, 0, SRCCOPY);
-
- //remove clipping so we can draw the card at its new place
- SelectClipRgn(hdc, NULL);
-
- //if the card's old and new positions overlap, then we
- //need some funky code to update the "saved background" image,
- SetRect(&rect1, oldx, oldy, oldx+nDragCardWidth, oldy+nDragCardHeight);
- SetRect(&rect2, x, y, x+nDragCardWidth, y+nDragCardHeight);
-
- if(IntersectRect(&inter, &rect1, &rect2))
- {
- int interwidth = inter.right-inter.left;
- int interheight = inter.bottom-inter.top;
- int destx, desty, srcx, srcy;
-
- if(rect2.left > rect1.left)
- {
- destx = 0; srcx = nDragCardWidth - interwidth;
- }
- else
- {
- destx = nDragCardWidth - interwidth; srcx = 0;
- }
-
- if(rect2.top > rect1.top)
- {
- desty = 0; srcy = nDragCardHeight - interheight;
- }
- else
- {
- desty = nDragCardHeight - interheight; srcy = 0;
- }
-
- //shift the bit we didn't use for the restore (due to the clipping)
- //into the opposite corner
- BitBlt(hdcBackGnd, destx,desty, interwidth, interheight, hdcBackGnd, srcx, srcy, SRCCOPY);
-
- ExcludeClipRect(hdcBackGnd, destx, desty, destx+interwidth, desty+interheight);
-
- //this bit requires us to clip the BitBlt (from screen to background)
- //as BitBlt is a bit buggy it seems
- ClippedBitBlt(hdcBackGnd, 0,0, nDragCardWidth, nDragCardHeight, hdc, x, y, SRCCOPY);
- SelectClipRgn(hdcBackGnd, NULL);
- }
- else
- {
- BitBlt(hdcBackGnd, 0,0, nDragCardWidth, nDragCardHeight, hdc, x, y, SRCCOPY);
- }
-
- //finally draw the card to the screen
- DrawCard(hdc, x, y, hdcDragCard, nDragCardWidth, nDragCardHeight);
-}
-
-
-//extern "C" int _fltused(void) { return 0; }
-//extern "C" int _ftol(void) { return 0; }
-
-//
-// Better do this in fixed-point, to stop
-// VC from linking in floatingpoint-long conversions
-//
-//#define FIXED_PREC_MOVE
-#ifdef FIXED_PREC_MOVE
-#define PRECISION 12
-void ZoomCard(HDC hdc, int xpos, int ypos, CARDSTACK *dest)
-{
- long dx, dy, x , y;
-
-
- int apparentcards;
- x = xpos << PRECISION; y = ypos << PRECISION;
-
- oldx = (int)xpos;
- oldy = (int)ypos;
-
- apparentcards=dest->numcards/dest->threedcount;
-
- int idestx = dest->xpos + dest->xoffset * (apparentcards);// - iNumDragCards);
- int idesty = dest->ypos + dest->yoffset * (apparentcards);// - iNumDragCards);
-
- //normalise the motion vector
- dx = (idestx<<PRECISION) - x;
- dy = (idesty<<PRECISION) - y;
- long recip = (1 << PRECISION) / 1;//sqrt(dx*dx + dy*dy);
-
- dx *= recip * 16;//CARDZOOMSPEED;
- dy *= recip * 16;//CARDZOOMSPEED;
-
[truncated at 1000 lines; 119 more skipped]