5#define TIMERID_NOTIFY1 1
6#define TIMERID_DELAY1 2
18 m_evtSet.addEvent(EVENTID(EventSliderPos));
19 m_evtSet.addEvent(EVENTID(EventSliderValueTip));
45SSliderBar::RANGE SSliderBar::_GetPartRange(
int nLength,
int nThumbSize, BOOL bThumbInRail,
int nMin,
int nMax,
int nValue, UINT uSBCode)
47 int64_t nRailLen = nLength - nThumbSize;
49 int nHalfThumb = nThumbSize / 2;
50 int64_t nSelect = nRailLen * (nValue - nMin) / (nMax - nMin);
57 rRet.value2 = nLength;
60 rRet.value1 += nHalfThumb;
61 rRet.value2 -= nHalfThumb;
66 rRet.value2 = nLength;
67 rRet.value1 += nHalfThumb;
68 rRet.value2 -= nHalfThumb;
72 rRet.value2 = (int)nSelect;
75 rRet.value1 += nHalfThumb;
77 rRet.value2 += nHalfThumb;
80 rRet.value1 = (int)nSelect;
81 rRet.value2 = (int)nSelect + nThumbSize;
100 CRect rc(rcClient.left, rcClient.Height() - r.value2, rcClient.right, rcClient.Height() - r.value1);
101 rc.OffsetRect(0, rcClient.top);
102 int nSliderSize = smax(szThumb.cx, szRail.cx);
103 rc.DeflateRect((rcClient.Width() - nSliderSize) / 2, 0);
104 if (uSBCode != SC_THUMB)
106 rc.DeflateRect((nSliderSize - szRail.cx) / 2, 0);
113 CRect rc(r.value1, rcClient.top, r.value2, rcClient.bottom);
114 rc.OffsetRect(rcClient.left, 0);
115 int nSliderSize = smax(szThumb.cy, szRail.cy);
116 rc.DeflateRect(0, (rcClient.Height() - nSliderSize) / 2);
117 if (uSBCode != SC_THUMB)
119 rc.DeflateRect(0, (nSliderSize - szRail.cy) / 2);
180 if (uHit == SC_THUMB)
217 int nInterHei = (
IsVertical() ? rcRail.Height() : rcRail.Width());
235 ShowValueInTip(nNewTrackPos);
263 EventSliderPos evt(
this);
275 SIZE sizeThumb = { 0 };
281 szRet.cx = smax(sizeBg.cx, sizeThumb.cx);
286 szRet.cy = smax(sizeBg.cy, sizeThumb.cy);
294 __baseCls::OnColorize(cr);
301 __baseCls::OnScaleChanged(scale);
305BOOL SSliderBar::SetValue(THIS_
int nValue)
309 return __baseCls::SetValue(nValue);
312void SSliderBar::ShowValueInTip(
int nValue)
317 rcThumb.InflateRect(5, 5);
318 SStringT buf = SStringT().
Format(_T(
"%d"), nValue);
319 EventSliderValueTip evt(
this);
Helper class for painting.
SAutoRefPtr< ISkinObj > m_pSkinPos
前景资源
BOOL IsVertical() SCONST OVERRIDE
判断进度条是否为竖直状态
SAutoRefPtr< ISkinObj > m_pSkinBg
背景资源
CRect GetPartRect(UINT uSBCode)
void OnMouseMove(UINT nFlags, CPoint point)
鼠标移动
void OnMouseLeave()
鼠标移动事件
SAutoRefPtr< ISkinObj > m_pSkinThumb
virtual void OnColorize(COLORREF cr)
处理颜色化事件
virtual void OnScaleChanged(int scale)
处理缩放变化事件
int HitTest(CPoint pt)
测试点
void OnPaint(IRenderTarget *pRT)
绘制
void OnLButtonUp(UINT nFlags, CPoint point)
左键抬起
LRESULT NotifyPos(SliderBarAction action, int value)
通知
SIZE GetDesiredSize(int nParentWid, int nParentHei)
获取大小
void OnLButtonDown(UINT nFlags, CPoint point)
左键按下
BOOL __cdecl Format(HINSTANCE hInst, UINT nFormatID,...)
Formats a string using a format string and variable arguments.
BOOL FireEvent(IEvtArgs *evt) OVERRIDE
Fires an event.
ISwndContainer * GetContainer() OVERRIDE
Retrieves the container associated with this window.
virtual CRect GetClientRect() const
Retrieves the client rectangle of the window.
virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter)
Prepare rendering environment.
void InvalidateRect(LPCRECT lprect) OVERRIDE
Invalidates a specific rectangle area of the window.
SWND SetCapture() OVERRIDE
Sets the window to capture the mouse.
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Restore rendering environment.
BOOL IsDisabled(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is disabled.
SAutoRefPtr< ISkinObj > m_pBgSkin
void Invalidate() OVERRIDE
Invalidates the entire window.
void GetScaleSkin(SAutoRefPtr< ISkinObj > &pSkin, int nScale)
Retrieves a scaled skin object based on the current scale factor.
BOOL ReleaseCapture() OVERRIDE
Releases the mouse capture from the window.
Interface for rendering target objects.
void SetToolTip(LPCRECT rc, UINT tipAlign, LPCTSTR pszTip) PURE
Displays a tooltip at the specified position.