IUISlider* CUIPanel::addSlider(const std::string& sLabel, int iMin, int iMax, int iPos, bool bButtons, int iInsertAt) { std::map<std::string, CUISlider*>::iterator it = m_mapSliders.find(sLabel); if (it != m_mapSliders.end()) return (*it).second; CMFCRibbonSlider* pSlider = new CMFCRibbonSlider(CUIManager::getInstance()->getNextUIID()); if (!pSlider) return NULL; pSlider->SetRange(iMin, iMax); pSlider->SetPos(iPos); pSlider->SetZoomButtons(bButtons); m_pPanel->Insert(pSlider, iInsertAt); CUISlider* pUISlider = new CUISlider(pSlider); m_mapSliders[sLabel] = pUISlider; return pUISlider; }
afx_msg BOOL CLineComputeView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { int wheelCount = zDelta/120; GLdouble deltaZoom = (wheelCount>0)? 0.1f: -0.1f; CMainFrame *pMain = (CMainFrame *)AfxGetApp()->m_pMainWnd; CMFCRibbonSlider *pSlider = DYNAMIC_DOWNCAST(CMFCRibbonSlider, pMain->m_wndRibbonBar.FindByID(ID_SLIDER_VIEWZOOM)); scale += deltaZoom; scale = scale < 0.1? 0.1: scale; scale = scale > 10? 10: scale; pSlider->SetPos(scale*10); RenderScene(); return true; }
void CMainFrame::SetSliderPos (int nPos, UINT nID) { CArray<CMFCRibbonBaseElement*, CMFCRibbonBaseElement*> ar; m_wndRibbonBar.GetElementsByID (nID, ar); for (int i = 0; i < ar.GetSize (); i++) { CMFCRibbonSlider* pSlider = DYNAMIC_DOWNCAST (CMFCRibbonSlider, ar[i]); if (pSlider != NULL) { if (pSlider->GetPos () != nPos) { pSlider->SetPos (nPos); } } } }