void ScrollBar::DrawElement(C4TargetFacet &cgo) { // do scrolling // not quite perfect; but there's no OnIdle, and it's be a bit of overkill starting a timer if (fTopDown && fScrolling && iScrollPos>0) { --iScrollPos; OnPosChanged(); } if (fBottomDown && fScrolling) { if (iScrollPos < GetMaxScroll()) { ++iScrollPos; OnPosChanged(); } } // draw bar ScrollBarFacets &rUseGfx = pCustomGfx ? *pCustomGfx : ::GraphicsResource.sfctScroll; DynBarFacet bar = rUseGfx.barScroll; if (fTopDown) bar.fctBegin = rUseGfx.fctScrollDTop; if (fBottomDown) bar.fctEnd = rUseGfx.fctScrollDBottom; if (fHorizontal) DrawHBarByVGfx(cgo, bar); else DrawVBar(cgo, bar); // draw scroll pin if (fScrolling && HasPin()) { if (fHorizontal) rUseGfx.fctScrollPin.Draw(cgo.Surface, cgo.TargetX+rcBounds.x+C4GUI_ScrollArrowWdt+iScrollPos, cgo.TargetY+rcBounds.y); else rUseGfx.fctScrollPin.Draw(cgo.Surface, cgo.TargetX+rcBounds.x, cgo.TargetY+rcBounds.y+C4GUI_ScrollArrowHgt+iScrollPos); } }
void ScrollBar::DoDragging(CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam) { // move thumb iScrollPos = GetScrollByPos(iX, iY); // reflect movement in associated window OnPosChanged(); }
void AWidget::SetPosition(const ivec2& pos) { m_vPosition = pos; if(m_wParent) m_vAbsolutePosition = m_wParent->m_vAbsolutePosition + pos; else m_vAbsolutePosition = pos; OnPosChanged(); }
bool NFrameBase::SetPosImpl(int left, int top, bool force) { if(!force && (layout_ == LayoutLeft || layout_ == LayoutRight || layout_ == LayoutHFill || layout_ == LayoutHCenter)) left = frameRect_.Left; if(!force && (layout_ == LayoutTop || layout_ == LayoutBottom || layout_ == LayoutVFill || layout_ == LayoutVCenter)) top = frameRect_.Top; if(frameRect_.Left == left && frameRect_.Top == top) return false; Invalidate(); frameRect_.SetPos(left, top); OnPosChanged(left, top); Invalidate(); return true; }
LRESULT CDuiFrameWnd::HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam ) { LRESULT lRes = __super::HandleMessage(uMsg, wParam, lParam); switch (uMsg) { HANDLE_MSG (*this, WM_DROPFILES, OnDropFiles); HANDLE_MSG (*this, WM_DISPLAYCHANGE, OnDisplayChange); HANDLE_MSG (*this, WM_GETMINMAXINFO, OnGetMinMaxInfo); case WM_USER_PLAYING: return OnPlaying(*this, wParam, lParam); case WM_USER_POS_CHANGED: return OnPosChanged(*this, wParam, lParam); case WM_USER_END_REACHED: return OnEndReached(*this, wParam, lParam); } return lRes; }
void ScrollBar::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) { // inherited Element::MouseInput(rMouse, iButton, iX, iY, dwKeyParam); // not if scrolling is disabled if (!fScrolling) return; // reset arrow states bool fPrevDown = fTopDown || fBottomDown; fTopDown = fBottomDown = false; // not if dragging if (rMouse.pDragElement) return; // left mouse button down? if (rMouse.IsLDown()) // non-scroll-direction area check if (fHorizontal ? Inside<int32_t>(iY, 0, C4GUI_ScrollBarHgt) : Inside<int32_t>(iX, 0, C4GUI_ScrollBarWdt)) { // scroll-direction area check: up/left arrow if (fHorizontal ? Inside<int32_t>(iX, 0, C4GUI_ScrollArrowWdt-1) : Inside<int32_t>(iY, 0, C4GUI_ScrollArrowHgt-1)) fTopDown = true; // check down arrow else if (fHorizontal ? Inside<int32_t>(iX, GetBounds().Wdt-C4GUI_ScrollArrowWdt, GetBounds().Wdt-1) : Inside<int32_t>(iY, GetBounds().Hgt-C4GUI_ScrollArrowHgt, GetBounds().Hgt-1)) fBottomDown = true; else if (HasPin() && (fHorizontal ? Inside<int32_t>(iX, C4GUI_ScrollArrowWdt, GetBounds().Wdt-C4GUI_ScrollArrowWdt-1) : Inside<int32_t>(iY, C4GUI_ScrollArrowHgt, GetBounds().Hgt-C4GUI_ScrollArrowHgt-1))) { // move thumb here iScrollPos = GetScrollByPos(iX, iY); // reflect movement in associated window or do CB OnPosChanged(); // start dragging rMouse.pDragElement = this; GUISound("UI::Select"); } } // sound effekt when buttons are pressed if ((fTopDown || fBottomDown) != fPrevDown) GUISound("UI::Tick"); }
void SQRScrollBar::ProcessMove( bool bSendMsg ,bool bDRAG /*= false*/) { m_fRange = max( 1, m_fRange ); m_fPageSize = min( m_fPageSize, m_fRange ); m_fPageSize = max( m_fPageSize, 1 ); m_fCurPos = min( m_fCurPos, (float)( m_fRange - m_fPageSize ) ); m_fCurPos = max( (float)m_fCurPos, 0 ); CFRect rt1, rt2, rt3, rt4; m_pPressButton1->GetWndRect( rt1 ); m_pPressButton2->GetWndRect( rt2 ); m_pScrollBar->GetWndRect( rt3 ); SQRRootWnd* rootWnd = SQRWnd::GetRootWnd(); float zoom; if (rootWnd) zoom = rootWnd->GetZoomSize(); else zoom = 1.0f; float _min = zoom * m_WndZoom * SB_MIN_SIZE; float _min_wnd = ( (GetStyle()&SS_HSCROLL) != 0 ) ? (rt2.right - rt1.left) : (rt2.bottom - rt1.top); _min_wnd = (_min_wnd > 0 ? _min_wnd : _min) * 2 / 3; m_sbMinSize = (int32)(min( _min, _min_wnd )); CFPos posStart, posEnd; if( GetStyle()&SS_HSCROLL ) { if (m_fRange > m_fPageSize ) { rt3.right = rt3.left + (rt2.left - rt1.right ) * (LONG)m_fPageSize/ (LONG)m_fRange; if (rt3.right > rt2.left) { rt3.right = rt2.left; rt3.left = rt2.left - (rt2.left - rt1.right ) * (LONG)m_fPageSize/ (LONG)m_fRange; } if ( Isbottom() ) { rt3.left = rt3.left + rt2.left - rt3.right; rt3.right = rt2.left; } if (rt3.right - rt3.left <= m_sbMinSize) rt3.left = rt3.right - m_sbMinSize; } posStart.x = rt1.right; posEnd.x = rt2.left - ( rt3.right - rt3.left ); posStart.y = rt1.top; posEnd.y = rt2.top; } else { if ( m_fRange > m_fPageSize ) //ÏÔʾÄÚÈÝÂúÒ»ÆÁ£¬»¬¿éshow trueʱ£¬¼ÆË㻬¿éµÄ´óС { rt3.bottom = rt3.top + (rt2.top - rt1.bottom ) * (LONG)m_fPageSize/ (LONG)m_fRange; if ( rt3.bottom > rt2.top ) { rt3.bottom = rt2.top; rt3.top = rt2.top - (rt2.top - rt1.bottom ) * (LONG)m_fPageSize/ (LONG)m_fRange; } if ( Isbottom() ) { rt3.top = rt3.top + (rt2.top - rt3.bottom); rt3.bottom = rt2.top; } if (rt3.bottom - rt3.top <= m_sbMinSize) rt3.top = rt3.bottom - m_sbMinSize; } posStart.x = rt1.left; posEnd.x = rt2.left; posStart.y = rt1.bottom; posEnd.y = rt2.top - ( rt3.bottom - rt3.top ); } float fPos = ( m_fRange > m_fPageSize ) ? m_fCurPos/( m_fRange - m_fPageSize ) : 0; rt4.left = posEnd.x*fPos + posStart.x*( 1 - fPos ); rt4.right = rt4.left + ( rt3.right - rt3.left ); rt4.top = posEnd.y*fPos + posStart.y*( 1 - fPos ); rt4.bottom = rt4.top + ( rt3.bottom - rt3.top ); if (bDRAG) m_pScrollBar->ResizeRect( rt4, false ); else { if (Isbottom()) { m_pScrollBar->ResizeRect( rt3, false ); } else m_pScrollBar->ResizeRect( rt4, false ); } if( bSendMsg ) { SQRControl::SendCtrlMsg( SCROLL_MOVE, GetStyle()&SS_HSCROLL, (uint32)m_fCurPos ); OnPosChanged(); } }
void CmusikTrackCtrl::SetPosFromMouse() { CPoint pos; GetCursorPos( &pos ); ScreenToClient( &pos ); CRect rcClient; GetClientRect( &rcClient ); // vertical if ( GetStyle() & TBS_VERT ) { if ( pos.y >= rcClient.bottom && GetPos() != GetRangeMax() ) { SetPos( GetRangeMax() ); m_LastPos = GetRangeMax(); OnPosChanged(); return; } else if ( pos.y <= rcClient.top && GetPos() != GetRangeMin() ) { SetPos( GetRangeMin() ); m_LastPos = GetRangeMin(); OnPosChanged(); return; } else { int nLoc = rcClient.Height() - pos.y; float fRatio = (float)nLoc / rcClient.Height(); float nPos = (float)fRatio * (float)GetRangeMax(); int nFinal = GetRangeMax() - (int)nPos; if ( nFinal != m_LastPos ) { SetPos( nFinal ); m_LastPos = nFinal; OnPosChanged(); } return; } } // horizontal else { if ( pos.x >= rcClient.right && GetPos() != GetRangeMax() ) { SetPos( GetRangeMax() ); m_LastPos = GetRangeMax(); OnPosChanged(); return; } else if ( pos.x <= rcClient.left && GetPos() != GetRangeMin() ) { SetPos( GetRangeMin() ); m_LastPos = GetRangeMin(); OnPosChanged(); return; } else { int nLoc = rcClient.Width() - pos.x; float fRatio = (float)nLoc / rcClient.Width(); float nPos = (float)fRatio * (float)GetRangeMax(); int nFinal = GetRangeMax() - (int)nPos; if ( nFinal != m_LastPos ) { SetPos( nFinal ); m_LastPos = nFinal; OnPosChanged(); } return; } } }
BOOL CSonicSkin::OnWndMsg(UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DRAWITEM: { return OnDrawItem((LPDRAWITEMSTRUCT)lParam); } break; case WM_CTLCOLORSTATIC: { return OnCtlColorStatic((HDC)wParam, (HWND)lParam); } break; case WM_CTLCOLORBTN: { return OnCtlColorBtn((HDC)wParam, (HWND)lParam); } break; case WM_LBUTTONDBLCLK: { int x = LOWORD(lParam); int y = HIWORD(lParam); if(y < m_bg.wTitleHeight) { SendMessage(m_hWnd, WM_NCLBUTTONDBLCLK, HTCAPTION, 0); return FALSE; } } break; case WM_LBUTTONDOWN: { int x = LOWORD(lParam); int y = HIWORD(lParam); if(y < m_bg.wTitleHeight && m_bg.bEnableDrag) { SendMessage(m_hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); return FALSE; } } break; case WM_NCHITTEST: { return OnNCHittest(LOWORD(lParam), HIWORD(lParam)); } break; // assure the none-border window wont override the tray bar case WM_GETMINMAXINFO: { return OnGetMinMaxInfo((MINMAXINFO *)lParam); } break; case WM_WINDOWPOSCHANGING: { return OnPosChanging((LPWINDOWPOS)lParam); } break; case WM_WINDOWPOSCHANGED: { return OnPosChanged((LPWINDOWPOS)lParam); } break; case WM_ERASEBKGND: { return OnEraseBackground((HDC)wParam); } break; // erase NC paint case WM_NCACTIVATE: g_UI.SetCallWndProcRet(TRUE); return FALSE; case WM_NCPAINT: SetRgn(); case WM_NCCALCSIZE: g_UI.SetCallWndProcRet(0); return FALSE; } return TRUE; }