diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2DlgItemVScr.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2DlgItemVScr.cpp')
-rw-r--r-- | src/T2DLL/T2DlgItemVScr.cpp | 143 |
1 files changed, 137 insertions, 6 deletions
diff --git a/src/T2DLL/T2DlgItemVScr.cpp b/src/T2DLL/T2DlgItemVScr.cpp index 3b4b55a..e852793 100644 --- a/src/T2DLL/T2DlgItemVScr.cpp +++ b/src/T2DLL/T2DlgItemVScr.cpp @@ -1,3 +1,4 @@ +#include "T2BitImage.h" #include "T2DlgItemVScr.h" T2DlgItemVScr::T2DlgItemVScr(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette) @@ -5,20 +6,150 @@ T2DlgItemVScr::T2DlgItemVScr(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalett { } -/*virtual*/ int T2DlgItemVScr::OnT2DlgItemEraseBkgnd(CDC*) { +/*virtual*/ BOOL T2DlgItemVScr::OnT2DlgItemEraseBkgnd(CDC* dc) { + CRect rect; + GetClientRect(rect); + + int savedDC = dc->SaveDC(); + + dc->SelectPalette(mPalette, false); + dc->RealizePalette(); + + CPen pen1; + pen1.CreatePen(PS_SOLID, 0, PALETTERGB(255, 255, 255)); + + CPen pen2; + pen2.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133)); + + CPen pen3; + pen3.CreatePen(PS_SOLID, 0, PALETTEINDEX(255)); + + CBrush brush; + brush.CreateSolidBrush(PALETTERGB(204, 204, 204)); + + dc->SelectObject(pen2); + dc->MoveTo(rect.right - 1, rect.top); + dc->LineTo(rect.left, rect.top); + dc->LineTo(rect.left, rect.bottom); + + dc->SelectObject(pen1); + dc->MoveTo(rect.right - 1, rect.top + 1); + dc->LineTo(rect.right - 1, rect.bottom - 1); + dc->LineTo(rect.left, rect.bottom - 1); + + int thumbPosition, thumbSize; + CalcScrollBarThumb(&thumbPosition, &thumbSize); + + int upImg; + if (!IsScrollable()) + upImg = 200; + else + upImg = (mUpImage == 100) ? 100 : 0; + + RECT imgRect; + T2BitImage *image = GetObjectImage(imgRect, "DLGITEM:UArrow", upImg); + + RECT destRect = rect; + destRect.top = 0; + destRect.bottom = imgRect.bottom - imgRect.top; + dc->Rectangle(&destRect); + image->CopyImage(dc, imgRect, destRect, 0, NULL); + + int dnImg; + if (!IsScrollable()) + dnImg = 200; + else + dnImg = (mDownImage == 100) ? 100 : 0; + + image = GetObjectImage(imgRect, "DLGITEM:UArrow", dnImg); + + destRect = rect; + destRect.top = destRect.bottom - (imgRect.bottom - imgRect.top); + dc->Rectangle(&destRect); + image->CopyImage(dc, imgRect, destRect, 0, NULL); + + destRect.left = rect.left + 1; + destRect.top = 16; + destRect.right = rect.right - 1; + destRect.bottom = thumbPosition; + if (destRect.top < destRect.bottom) + dc->FillRect(&destRect, &brush); + + destRect.left = rect.left + 1; + destRect.top = thumbPosition + thumbSize; + destRect.right = rect.right - 1; + destRect.bottom = rect.bottom - 16; + if (destRect.top < destRect.bottom) + dc->FillRect(&destRect, &brush); + + if (thumbSize > 0) { + destRect.left = rect.left + 1; + destRect.top = thumbPosition; + destRect.right = rect.right - 1; + destRect.bottom = thumbPosition + thumbSize; + dc->FillRect(&destRect, &brush); + + dc->SelectObject(pen3); + dc->MoveTo(destRect.right - 1, destRect.top); + dc->LineTo(destRect.right - 1, destRect.bottom - 1); + dc->LineTo(destRect.left, destRect.bottom - 1); + dc->LineTo(destRect.left, destRect.top); + dc->LineTo(destRect.right - 1, destRect.top); + + dc->SelectObject(pen2); + dc->MoveTo(destRect.right - 2, destRect.top + 1); + dc->LineTo(destRect.right - 2, destRect.bottom - 2); + dc->LineTo(destRect.left + 1, destRect.bottom - 2); + + dc->SelectObject(pen1); + dc->MoveTo(destRect.right - 2, destRect.top + 1); + dc->LineTo(destRect.left + 1, destRect.top + 1); + dc->LineTo(destRect.left + 1, destRect.bottom - 1); + } + + dc->RestoreDC(savedDC); + + return true; } -/*virtual*/ int T2DlgItemVScr::ScrollBarHittest(CPoint) const { +/*virtual*/ int T2DlgItemVScr::ScrollBarHittest(CPoint pt) const { + if (!IsScrollable()) + return 0; + + CRect theCRect; + GetClientRect(theCRect); + + int area = 0; + + int theThumbPosition, theThumbSize; + CalcScrollBarThumb(&theThumbPosition, &theThumbSize); + + if (theCRect.top <= pt.y && pt.y < (theCRect.top + 16)) + area = Area_Up; + else if ((theCRect.top + 16) <= pt.y && pt.y < theThumbPosition) + area = Area_PageUp; + else if (theThumbPosition <= pt.y && pt.y < (theThumbPosition + theThumbSize)) + area = Area_Thumb; + else if ((theThumbPosition + theThumbSize) <= pt.y && pt.y < (theCRect.bottom - 16)) + area = Area_PageDown; + else if ((theCRect.bottom - 16) <= pt.y && pt.y < theCRect.bottom) + area = Area_Down; + + return area; } -/*virtual*/ void T2DlgItemVScr::GetUpButtonRect(const CRect&, CRect&) const { +/*virtual*/ void T2DlgItemVScr::GetUpButtonRect(const CRect& clientRect, CRect& buttonRect) const { + buttonRect = CRect(clientRect.left, clientRect.top, clientRect.right, clientRect.top + 16); } -/*virtual*/ void T2DlgItemVScr::GetDnButtonRect(const CRect&, CRect&) const { +/*virtual*/ void T2DlgItemVScr::GetDnButtonRect(const CRect& clientRect, CRect& buttonRect) const { + buttonRect = CRect(clientRect.left, clientRect.bottom - 16, clientRect.right, clientRect.bottom); } -/*virtual*/ int T2DlgItemVScr::PositionToValue(const CPoint&) const { +/*virtual*/ int T2DlgItemVScr::PositionToValue(const CPoint& pt) const { + return pt.y; } -/*virtual*/ int T2DlgItemVScr::PositionToValue(const CRect&) const { +/*virtual*/ int T2DlgItemVScr::PositionToValue(const CRect& rect) const { + return rect.Height(); } |