summaryrefslogtreecommitdiff
path: root/area_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-25 09:10:06 -0400
committerPietro Gagliardi <[email protected]>2014-03-25 09:40:14 -0400
commit2b48f7cabfbf269ac5d5ff292a7c788715ecd411 (patch)
tree502c627720d044a7c73ae7b333eb3ebb5435a906 /area_windows.go
parent13370c22d314f6e8b7d87e692e392f3606388703 (diff)
Wrote the code to actually scroll Areas on Windows.
Diffstat (limited to 'area_windows.go')
-rw-r--r--area_windows.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/area_windows.go b/area_windows.go
index 4b4eedc..01080e5 100644
--- a/area_windows.go
+++ b/area_windows.go
@@ -51,6 +51,7 @@ func paintArea(s *sysData) {
var xrect _RECT
var ps _PAINTSTRUCT
+ var si _SCROLLINFO
// TODO send _TRUE if we want to erase the clip area
r1, _, _ := _getUpdateRect.Call(
@@ -61,15 +62,36 @@ func paintArea(s *sysData) {
return
}
+ si.cbSize = uint32(unsafe.Sizeof(si))
+ si.fMask = _SIF_POS | _SIF_TRACKPOS
+ r1, _, err := _getScrollInfo.Call(
+ uintptr(s.hwnd),
+ uintptr(_SB_HORZ),
+ uintptr(unsafe.Pointer(&si)))
+ if r1 == 0 { // failure
+ panic(fmt.Errorf("error getting horizontal scroll position for Area repaint: %v", err))
+ }
+ hscroll := int(si.nPos)
+ si.cbSize = uint32(unsafe.Sizeof(si)) // MSDN example code reinitializes this each time, so we'll do it too just to be safe
+ si.fMask = _SIF_POS | _SIF_TRACKPOS
+ r1, _, err = _getScrollInfo.Call(
+ uintptr(s.hwnd),
+ uintptr(_SB_VERT),
+ uintptr(unsafe.Pointer(&si)))
+ if r1 == 0 { // failure
+ panic(fmt.Errorf("error getting vertical scroll position for Area repaint: %v", err))
+ }
+ vscroll := int(si.nPos)
+
cliprect := image.Rect(int(xrect.Left), int(xrect.Top), int(xrect.Right), int(xrect.Bottom))
- // TODO offset cliprect by scroll position
+ cliprect = cliprect.Add(image.Pt(hscroll, vscroll)) // adjust by scroll position
// make sure the cliprect doesn't fall outside the size of the Area
cliprect = cliprect.Intersect(image.Rect(0, 0, 320, 240)) // TODO change when adding resizing
if cliprect.Empty() { // still no update rect
return
}
- r1, _, err := _beginPaint.Call(
+ r1, _, err = _beginPaint.Call(
uintptr(s.hwnd),
uintptr(unsafe.Pointer(&ps)))
if r1 == 0 { // failure