Implemented Area.Repaint() on Windows.
This commit is contained in:
parent
5ddef41133
commit
3a16648b83
|
@ -289,10 +289,10 @@ static void adjustAreaScrollbars(HWND hwnd, void *data)
|
||||||
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
|
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void repaintArea(HWND hwnd)
|
void repaintArea(HWND hwnd, RECT *r)
|
||||||
{
|
{
|
||||||
// NULL - the whole area; TRUE - have windows erase if possible
|
// NULL - the whole area; TRUE - have windows erase if possible
|
||||||
if (InvalidateRect(hwnd, NULL, TRUE) == 0)
|
if (InvalidateRect(hwnd, r, TRUE) == 0)
|
||||||
xpanic("error flagging Area as needing repainting after event", GetLastError());
|
xpanic("error flagging Area as needing repainting after event", GetLastError());
|
||||||
if (UpdateWindow(hwnd) == 0)
|
if (UpdateWindow(hwnd) == 0)
|
||||||
xpanic("error repainting Area after event", GetLastError());
|
xpanic("error repainting Area after event", GetLastError());
|
||||||
|
@ -386,10 +386,16 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
return (LRESULT) areaKeyEvent(data, TRUE, wParam, lParam);
|
return (LRESULT) areaKeyEvent(data, TRUE, wParam, lParam);
|
||||||
case msgAreaSizeChanged:
|
case msgAreaSizeChanged:
|
||||||
adjustAreaScrollbars(hwnd, data);
|
adjustAreaScrollbars(hwnd, data);
|
||||||
repaintArea(hwnd); // this calls for an update
|
repaintArea(hwnd, NULL); // this calls for an update
|
||||||
|
return 0;
|
||||||
|
case msgAreaGetScroll:
|
||||||
|
getScrollPos(hwnd, (int *) wParam, (int *) lParam);
|
||||||
|
return 0;
|
||||||
|
case msgAreaRepaint:
|
||||||
|
repaintArea(hwnd, (RECT *) lParam);
|
||||||
return 0;
|
return 0;
|
||||||
case msgAreaRepaintAll:
|
case msgAreaRepaintAll:
|
||||||
repaintArea(hwnd);
|
repaintArea(hwnd, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
|
|
|
@ -46,6 +46,23 @@ func (a *area) SetSize(width, height int) {
|
||||||
C.SendMessageW(a._hwnd, C.msgAreaSizeChanged, 0, 0)
|
C.SendMessageW(a._hwnd, C.msgAreaSizeChanged, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *area) Repaint(r image.Rectangle) {
|
||||||
|
var hscroll, vscroll C.int
|
||||||
|
var rect C.RECT
|
||||||
|
|
||||||
|
C.SendMessageW(a._hwnd, C.msgAreaGetScroll, C.WPARAM(uintptr(unsafe.Pointer(&hscroll))), C.LPARAM(uintptr(unsafe.Pointer(&vscroll))))
|
||||||
|
r = r.Add(image.Pt(int(hscroll), int(vscroll))) // adjust by scroll position
|
||||||
|
r = image.Rect(0, 0, a.width, a.height).Intersect(r)
|
||||||
|
if r.Empty() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rect.left = C.LONG(r.Min.X)
|
||||||
|
rect.top = C.LONG(r.Min.Y)
|
||||||
|
rect.right = C.LONG(r.Max.X)
|
||||||
|
rect.bottom = C.LONG(r.Max.Y)
|
||||||
|
C.SendMessageW(a._hwnd, C.msgAreaRepaint, 0, C.LPARAM(uintptr(unsafe.Pointer(&rect))))
|
||||||
|
}
|
||||||
|
|
||||||
func (a *area) RepaintAll() {
|
func (a *area) RepaintAll() {
|
||||||
C.SendMessageW(a._hwnd, C.msgAreaRepaintAll, 0, 0)
|
C.SendMessageW(a._hwnd, C.msgAreaRepaintAll, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ enum {
|
||||||
msgCOMMAND, // WM_COMMAND proxy; see forwardCommand() in controls_windows.go
|
msgCOMMAND, // WM_COMMAND proxy; see forwardCommand() in controls_windows.go
|
||||||
msgNOTIFY, // WM_NOTIFY proxy
|
msgNOTIFY, // WM_NOTIFY proxy
|
||||||
msgAreaSizeChanged,
|
msgAreaSizeChanged,
|
||||||
|
msgAreaGetScroll,
|
||||||
|
msgAreaRepaint,
|
||||||
msgAreaRepaintAll,
|
msgAreaRepaintAll,
|
||||||
msgTabCurrentTabHasChildren,
|
msgTabCurrentTabHasChildren,
|
||||||
msgBeginModal,
|
msgBeginModal,
|
||||||
|
@ -122,7 +124,7 @@ extern void calculateBaseUnits(HWND, int *, int *, LONG *);
|
||||||
|
|
||||||
// area_window.c
|
// area_window.c
|
||||||
#define areaWindowClass L"gouiarea"
|
#define areaWindowClass L"gouiarea"
|
||||||
extern void repaintArea(HWND);
|
extern void repaintArea(HWND, RECT *);
|
||||||
extern DWORD makeAreaWindowClass(char **);
|
extern DWORD makeAreaWindowClass(char **);
|
||||||
extern HWND newArea(void *);
|
extern HWND newArea(void *);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue