예제 #1
0
파일: scrollview.go 프로젝트: JSchwehn/walk
func (sv *ScrollView) scroll(sb int32, cmd uint16) int {
	var pos int32
	var si win.SCROLLINFO
	si.CbSize = uint32(unsafe.Sizeof(si))
	si.FMask = win.SIF_PAGE | win.SIF_POS | win.SIF_RANGE | win.SIF_TRACKPOS

	win.GetScrollInfo(sv.hWnd, sb, &si)

	pos = si.NPos

	switch cmd {
	case win.SB_LINELEFT: // == win.SB_LINEUP
		pos -= 20

	case win.SB_LINERIGHT: // == win.SB_LINEDOWN
		pos += 20

	case win.SB_PAGELEFT: // == win.SB_PAGEUP
		pos -= int32(si.NPage)

	case win.SB_PAGERIGHT: // == win.SB_PAGEDOWN
		pos += int32(si.NPage)

	case win.SB_THUMBTRACK:
		pos = si.NTrackPos
	}

	if pos < 0 {
		pos = 0
	}
	if pos > si.NMax+1-int32(si.NPage) {
		pos = si.NMax + 1 - int32(si.NPage)
	}

	si.FMask = win.SIF_POS
	si.NPos = pos
	win.SetScrollInfo(sv.hWnd, sb, &si, true)

	return -int(pos)
}
예제 #2
0
파일: scrollview.go 프로젝트: JSchwehn/walk
func (sv *ScrollView) updateScrollBars() {
	s := sv.composite.Size()
	clb := sv.ClientBounds()

	var si win.SCROLLINFO
	si.CbSize = uint32(unsafe.Sizeof(si))
	si.FMask = win.SIF_PAGE | win.SIF_RANGE

	si.NMax = int32(s.Width - 1)
	si.NPage = uint32(clb.Width)
	win.SetScrollInfo(sv.hWnd, win.SB_HORZ, &si, false)
	sv.composite.SetX(sv.scroll(win.SB_HORZ, win.SB_THUMBPOSITION))

	si.NMax = int32(s.Height - 1)
	si.NPage = uint32(clb.Height)
	win.SetScrollInfo(sv.hWnd, win.SB_VERT, &si, false)
	sv.composite.SetY(sv.scroll(win.SB_VERT, win.SB_THUMBPOSITION))
}