diff --git a/redo/area_darwin.go b/redo/area_darwin.go index 509c05d..ad82777 100644 --- a/redo/area_darwin.go +++ b/redo/area_darwin.go @@ -35,6 +35,20 @@ func (a *area) SetSize(width, height int) { C.moveControl(a._id, 0, 0, C.intptr_t(a.width), C.intptr_t(a.height)) } +func (a *area) Repaint(r image.Rectangle) { + var s C.struct_xrect + + r = image.Rect(0, 0, a.width, a.height).Intersect(r) + if r.Empty() { + return + } + s.x = C.intptr_t(r.Min.X) + s.y = C.intptr_t(r.Min.Y) + s.width = C.intptr_t(r.Dx()) + s.height = C.intptr_t(r.Dy()) + C.areaRepaint(a._id, s) +} + func (a *area) RepaintAll() { C.areaRepaintAll(a._id) } diff --git a/redo/area_darwin.m b/redo/area_darwin.m index d76f3a1..b3d095e 100644 --- a/redo/area_darwin.m +++ b/redo/area_darwin.m @@ -188,6 +188,17 @@ uintptr_t keyCode(id e) return (uintptr_t) ([toNSEvent(e) keyCode]); } +void areaRepaint(id view, struct xrect r) +{ + NSRect s; + + s.origin.x = (CGFloat) r.x; + s.origin.y = (CGFloat) r.y; + s.size.width = (CGFloat) r.width; + s.size.height = (CGFloat) r.height; + [toNSView(view) displayRect:s]; +} + void areaRepaintAll(id view) { [toNSView(view) display]; diff --git a/redo/objc_darwin.h b/redo/objc_darwin.h index d4a58d0..826334c 100644 --- a/redo/objc_darwin.h +++ b/redo/objc_darwin.h @@ -125,6 +125,7 @@ extern intptr_t buttonNumber(id); extern intptr_t clickCount(id); extern uintptr_t pressedMouseButtons(void); extern uintptr_t keyCode(id); +extern void areaRepaint(id, struct xrect); extern void areaRepaintAll(id); /* common_darwin.m */