MCPcopy
hub / github.com/lxn/walk / scroll

Method scroll

scrollview.go:263–302  ·  view source on GitHub ↗

scroll scrolls and returns new position in native pixels.

(sb int32, cmd uint16)

Source from the content-addressed store, hash-verified

261
262// scroll scrolls and returns new position in native pixels.
263func (sv *ScrollView) scroll(sb int32, cmd uint16) int {
264 var pos int32
265 var si win.SCROLLINFO
266 si.CbSize = uint32(unsafe.Sizeof(si))
267 si.FMask = win.SIF_PAGE | win.SIF_POS | win.SIF_RANGE | win.SIF_TRACKPOS
268
269 win.GetScrollInfo(sv.hWnd, sb, &si)
270
271 pos = si.NPos
272
273 switch cmd {
274 case win.SB_LINELEFT: // == win.SB_LINEUP
275 pos -= int32(sv.IntFrom96DPI(20))
276
277 case win.SB_LINERIGHT: // == win.SB_LINEDOWN
278 pos += int32(sv.IntFrom96DPI(20))
279
280 case win.SB_PAGELEFT: // == win.SB_PAGEUP
281 pos -= int32(si.NPage)
282
283 case win.SB_PAGERIGHT: // == win.SB_PAGEDOWN
284 pos += int32(si.NPage)
285
286 case win.SB_THUMBTRACK:
287 pos = si.NTrackPos
288 }
289
290 if pos < 0 {
291 pos = 0
292 }
293 if pos > si.NMax+1-int32(si.NPage) {
294 pos = si.NMax + 1 - int32(si.NPage)
295 }
296
297 si.FMask = win.SIF_POS
298 si.NPos = pos
299 win.SetScrollInfo(sv.hWnd, sb, &si, true)
300
301 return -int(pos)
302}
303
304func (sv *ScrollView) CreateLayoutItem(ctx *LayoutContext) LayoutItem {
305 svli := new(scrollViewLayoutItem)

Callers 2

WndProcMethod · 0.95
updateScrollBarsMethod · 0.95

Calls 1

IntFrom96DPIMethod · 0.80

Tested by

no test coverage detected