summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2DlgItemHScr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2DlgItemHScr.cpp')
-rw-r--r--src/T2DLL/T2DlgItemHScr.cpp141
1 files changed, 134 insertions, 7 deletions
diff --git a/src/T2DLL/T2DlgItemHScr.cpp b/src/T2DLL/T2DlgItemHScr.cpp
index e282124..add3d0c 100644
--- a/src/T2DLL/T2DlgItemHScr.cpp
+++ b/src/T2DLL/T2DlgItemHScr.cpp
@@ -1,22 +1,149 @@
+#include "T2BitImage.h"
#include "T2DlgItemHScr.h"
-T2DlgItemHScr::T2DlgItemHScr(T2TowerDoc*, T2ImageObj*, CPalette*) {
+T2DlgItemHScr::T2DlgItemHScr(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette)
+ : T2DlgItemScr(towerDoc, imageObj, palette)
+{
}
-/*virtual*/ int T2DlgItemHScr::OnT2DlgItemEraseBkgnd(CDC*) {
+/*virtual*/ BOOL T2DlgItemHScr::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);
+
+ RECT imgRect;
+ T2BitImage *image = GetObjectImage(
+ imgRect,
+ "DLGITEM:LArrow",
+ !IsScrollable() ? 200 : (mUpImage == 100) ? 100 : 0);
+
+ RECT destRect = rect;
+ destRect.left = 0;
+ destRect.right = imgRect.right - imgRect.left;
+ dc->Rectangle(&destRect);
+ image->CopyImage(dc, imgRect, destRect, 0, NULL);
+
+ image = GetObjectImage(
+ imgRect,
+ "DLGITEM:LArrow",
+ !IsScrollable() ? 200 : (mDownImage == 100) ? 100 : 0);
+
+ destRect = rect;
+ destRect.left = destRect.right - (imgRect.right - imgRect.left);
+ dc->Rectangle(&destRect);
+ image->CopyImage(dc, imgRect, destRect, 0, NULL);
+
+ destRect.left = 16;
+ destRect.top = rect.top + 1;
+ destRect.right = thumbPosition;
+ destRect.bottom = rect.bottom - 1;
+ if (destRect.left < destRect.right)
+ dc->FillRect(&destRect, &brush);
+
+ destRect.left = thumbPosition + thumbSize;
+ destRect.top = rect.top + 1;
+ destRect.right = rect.right - 16;
+ destRect.bottom = rect.bottom - 1;
+ if (destRect.left < destRect.right)
+ dc->FillRect(&destRect, &brush);
+
+ if (thumbSize > 0) {
+ destRect.left = thumbPosition;
+ destRect.top = rect.top + 1;
+ destRect.right = thumbPosition + thumbSize;
+ destRect.bottom = rect.bottom - 1;
+ 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 T2DlgItemHScr::ScrollBarHittest(CPoint) const {
+/*virtual*/ int T2DlgItemHScr::ScrollBarHittest(CPoint pt) const {
+ if (!IsScrollable())
+ return 0;
+
+ CRect theCRect;
+ GetClientRect(theCRect);
+
+ int area = 0;
+
+ int theThumbPosition, theThumbSize;
+ CalcScrollBarThumb(&theThumbPosition, &theThumbSize);
+
+ if (theCRect.left <= pt.x && pt.x < (theCRect.left + 16))
+ area = Area_Up;
+ else if ((theCRect.left + 16) <= pt.x && pt.x < theThumbPosition)
+ area = Area_PageUp;
+ else if (theThumbPosition <= pt.x && pt.x < (theThumbPosition + theThumbSize))
+ area = Area_Thumb;
+ else if ((theThumbPosition + theThumbSize) <= pt.x && pt.x < (theCRect.right - 16))
+ area = Area_PageDown;
+ else if ((theCRect.right - 16) <= pt.x && pt.x < theCRect.right)
+ area = Area_Down;
+
+ return area;
}
-/*virtual*/ void T2DlgItemHScr::GetUpButtonRect(const CRect&, CRect&) const {
+/*virtual*/ void T2DlgItemHScr::GetUpButtonRect(const CRect& clientRect, CRect& buttonRect) const {
+ buttonRect = CRect(clientRect.left, clientRect.top, clientRect.left + 16, clientRect.bottom);
}
-/*virtual*/ void T2DlgItemHScr::GetDnButtonRect(const CRect&, CRect&) const {
+/*virtual*/ void T2DlgItemHScr::GetDnButtonRect(const CRect& clientRect, CRect& buttonRect) const {
+ buttonRect = CRect(clientRect.right - 16, clientRect.top, clientRect.right, clientRect.bottom);
}
-/*virtual*/ int T2DlgItemHScr::PositionToValue(const CPoint&) const {
+/*virtual*/ int T2DlgItemHScr::PositionToValue(const CPoint& pt) const {
+ return pt.x;
}
-/*virtual*/ int T2DlgItemHScr::PositionToValue(const CRect&) const {
+/*virtual*/ int T2DlgItemHScr::PositionToValue(const CRect& rect) const {
+ return rect.Width();
}