void CContainerUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcsicmp(pstrName, _T("inset")) == 0 ) { RECT rcInset = { 0 }; LPTSTR pstr = NULL; rcInset.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcInset.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetInset(rcInset); } else if( _tcsicmp(pstrName, _T("mousechild")) == 0 ) SetMouseChildEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("vscrollbar")) == 0 ) { EnableScrollBar(_tcsicmp(pstrValue, _T("true")) == 0, GetHorizontalScrollBar() != NULL); } else if( _tcsicmp(pstrName, _T("vscrollbarstyle")) == 0 ) { m_sVerticalScrollBarStyle = pstrValue; EnableScrollBar(TRUE, GetHorizontalScrollBar() != NULL); if( GetVerticalScrollBar() ) { LPCTSTR pStyle = m_pManager->GetStyle(m_sVerticalScrollBarStyle); if( pStyle ) { GetVerticalScrollBar()->ApplyAttributeList(pStyle); } else { GetVerticalScrollBar()->ApplyAttributeList(pstrValue); } } } //else if( _tcsicmp(pstrName, _T("vscrollbarstyle")) == 0 ) { // EnableScrollBar(true, GetHorizontalScrollBar() != NULL); // if( GetVerticalScrollBar() ) GetVerticalScrollBar()->ApplyAttributeList(pstrValue); //} else if( _tcsicmp(pstrName, _T("hscrollbar")) == 0 ) { EnableScrollBar(GetVerticalScrollBar() != NULL, _tcsicmp(pstrValue, _T("true")) == 0); } else if( _tcsicmp(pstrName, _T("hscrollbarstyle")) == 0 ) { m_sHorizontalScrollBarStyle = pstrValue; EnableScrollBar(TRUE, GetHorizontalScrollBar() != NULL); if( GetHorizontalScrollBar() ) { LPCTSTR pStyle = m_pManager->GetStyle(m_sHorizontalScrollBarStyle); if( pStyle ) { GetHorizontalScrollBar()->ApplyAttributeList(pStyle); } else { GetHorizontalScrollBar()->ApplyAttributeList(pstrValue); } } } //else if( _tcsicmp(pstrName, _T("hscrollbarstyle")) == 0 ) { // EnableScrollBar(GetVerticalScrollBar() != NULL, true); // if( GetHorizontalScrollBar() ) GetHorizontalScrollBar()->ApplyAttributeList(pstrValue); //} else if( _tcsicmp(pstrName, _T("childpadding")) == 0 ) SetChildPadding(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("scrollstepsize")) == 0 ) SetScrollStepSize(_ttoi(pstrValue)); else CControlUI::SetAttribute(pstrName, pstrValue); }
ScrollableControl::ScrollableControl() { _vScrollBar = new ScrollBar(); GetVerticalScrollBar()->SetAlignment(ALIGNMENT_VCENTER_RIGHT); GetVerticalScrollBar()->SetOrientation(ORIENTATION_VERTICAL); GetVerticalScrollBar()->onValueChanged.bind(this, &ScrollableControl::OnVerticalValueChanged); GetVerticalScrollBar()->Hide(); AddChild(GetVerticalScrollBar()); _hScrollBar = new ScrollBar(); GetHorizontalScrollBar()->SetAlignment(ALIGNMENT_BOTTOM_HCENTER); GetHorizontalScrollBar()->SetOrientation(ORIENTATION_HORIZONTAL); GetHorizontalScrollBar()->onValueChanged.bind(this, &ScrollableControl::OnHorizontalValueChanged); GetHorizontalScrollBar()->Hide(); AddChild(GetHorizontalScrollBar()); }
long CMemoryCardView::OnVScroll(unsigned int nType, unsigned int nThumb) { switch(nType) { case SB_LINEDOWN: m_viewState.m_nScrollPosition += 5; break; case SB_LINEUP: m_viewState.m_nScrollPosition -= 5; break; case SB_PAGEDOWN: m_viewState.m_nScrollPosition += 35; break; case SB_PAGEUP: m_viewState.m_nScrollPosition -= 35; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: m_viewState.m_nScrollPosition = GetVerticalScrollBar().GetThumbPosition(); break; default: return FALSE; break; } UpdateScrollPosition(); return TRUE; }
/* * Fill 'Axes' dialog with values */ void update_axisgrid_ui(AGridUI *ui, Quark *q) { tickmarks *t = axisgrid_get_data(q); if (t && ui) { char buf[128]; int i; Widget vbar; SetOptionChoice(ui->type, t->type); if (is_log_axis(q)) { if (t->tmajor <= 1.0) { t->tmajor = 10.0; } sprintf(buf, "%g", t->tmajor); } else if (is_logit_axis(q)) { if (t->tmajor <= 0.0) { t->tmajor = 0.1; } else if (t->tmajor >= 0.5) { t->tmajor = 0.4; } sprintf(buf, "%g", t->tmajor); } else if (t->tmajor > 0) { sprintf(buf, "%g", t->tmajor); } else { strcpy(buf, "UNDEFINED"); } TextSetString(ui->tmajor, buf); SpinChoiceSetValue(ui->nminor, t->nminor); SetOptionChoice(ui->tlfont, t->tl_tprops.font); SetOptionChoice(ui->tlcolor, t->tl_tprops.color); SetOptionChoice(ui->tlskip, t->tl_skip); SetOptionChoice(ui->tlstagger, t->tl_staggered); TextSetString(ui->tlappstr, t->tl_appstr); TextSetString(ui->tlprestr, t->tl_prestr); SetOptionChoice(ui->tlstarttype, t->tl_starttype == TYPE_SPEC); if (t->tl_starttype == TYPE_SPEC) { sprintf(buf, "%f", t->tl_start); TextSetString(ui->tlstart, buf); sprintf(buf, "%f", t->tl_stop); TextSetString(ui->tlstop, buf); } SetOptionChoice(ui->tlstoptype, t->tl_stoptype == TYPE_SPEC); if (t->tl_stoptype == TYPE_SPEC) { sprintf(buf, "%f", t->tl_stop); TextSetString(ui->tlstop, buf); } SetFormatChoice(ui->tlform, &t->tl_format); TextSetString(ui->tlformula, t->tl_formula); sprintf(buf, "%.2f", t->tl_gap.x); TextSetString(ui->tlgap_para, buf); sprintf(buf, "%.2f", t->tl_gap.y); TextSetString(ui->tlgap_perp, buf); SpinChoiceSetValue(ui->tlcharsize, t->tl_tprops.charsize); SetAngleChoice(ui->tlangle, t->tl_tprops.angle); SetOptionChoice(ui->autonum, t->t_autonum - 2); ToggleButtonSetState(ui->tround, t->t_round); ToggleButtonSetState(ui->tgrid, t->gprops.onoff); SetPenChoice(ui->tgridpen, &t->gprops.line.pen); SpinChoiceSetValue(ui->tgridlinew, t->gprops.line.width); SetOptionChoice(ui->tgridlines, t->gprops.line.style); ToggleButtonSetState(ui->tmgrid, t->mgprops.onoff); SetPenChoice(ui->tmgridpen, &t->mgprops.line.pen); SpinChoiceSetValue(ui->tmgridlinew, t->mgprops.line.width); SetOptionChoice(ui->tmgridlines, t->mgprops.line.style); SetPenChoice(ui->barpen, &t->bar.pen); SpinChoiceSetValue(ui->barlinew, t->bar.width); SetOptionChoice(ui->barlines, t->bar.style); SetOptionChoice(ui->tinout, t->props.inout); SpinChoiceSetValue(ui->tlen, t->props.size); SetPenChoice(ui->tpen, &t->props.line.pen); SpinChoiceSetValue(ui->tlinew, t->props.line.width); SetOptionChoice(ui->tlines, t->props.line.style); SetOptionChoice(ui->tminout, t->mprops.inout); SpinChoiceSetValue(ui->tmlen, t->mprops.size); SetPenChoice(ui->tmpen, &t->mprops.line.pen); SpinChoiceSetValue(ui->tmlinew, t->mprops.line.width); SetOptionChoice(ui->tmlines, t->mprops.line.style); SetOptionChoice(ui->specticks, t->t_spec); SpinChoiceSetValue(ui->nspec, t->nticks); for (i = 0; i < t->nticks; i++) { sprintf(buf, "%.9g", t->tloc[i].wtpos); TextSetString(ui->specloc[i], buf); if (t->tloc[i].type == TICK_TYPE_MAJOR) { TextSetString(ui->speclabel[i], t->tloc[i].label); } else { TextSetString(ui->speclabel[i], ""); } } /* set reasonable scrolling */ vbar = GetVerticalScrollBar(ui->sw); if (vbar) { int maxval; GetScrollBarValues(vbar, NULL, &maxval, NULL, NULL); SetScrollBarIncrement(vbar, (int) rint(maxval/MAX_TICKS)); } } }
void ScrollableControl::SetHeight(SizeType height) { if (GetHeight() == height) return; Button::SetHeight(height); GetVerticalScrollBar()->SetHeight(height); }