func (g *group) commitResize(c *allocation, d *sizing) { var r C.RECT // pretend that the client area of the group box only includes the actual empty space // container will handle the necessary adjustments properly r.left = 0 r.top = 0 r.right = C.LONG(c.width) r.bottom = C.LONG(c.height) g.container.move(&r) basecommitResize(g, c, d) }
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)))) }
// a tab control contains other controls; size appropriately func (t *tab) commitResize(c *allocation, d *sizing) { var r C.RECT // figure out what the rect for each child is... // the tab contents are children of the tab itself, so ignore c.x and c.y, which are relative to the window! r.left = C.LONG(0) r.top = C.LONG(0) r.right = C.LONG(c.width) r.bottom = C.LONG(c.height) C.tabGetContentRect(t._hwnd, &r) // and resize tabs // don't resize just the current tab; resize all tabs! for _, c := range t.tabs { // because each widget is actually a child of the Window, the origin is the one we calculated above c.move(&r) } // and now resize the tab control itself basecommitResize(t, c, d) }
// a tab control contains other controls; size appropriately func (t *tab) commitResize(c *allocation, d *sizing) { var r C.RECT // figure out what the rect for each child is... // the tab contents are children of the tab itself, so ignore c.x and c.y, which are relative to the window! r.left = C.LONG(0) r.top = C.LONG(0) r.right = C.LONG(c.width) r.bottom = C.LONG(c.height) C.tabGetContentRect(t._hwnd, &r) // and resize tabs // resize only the current tab; we trigger a resize on a tab change to make sure things look correct if len(t.tabs) > 0 { t.tabs[C.SendMessageW(t._hwnd, C.TCM_GETCURSEL, 0, 0)].move(&r) } // save the tab size so we can t.switchrect = r // and now resize the tab control itself basecommitResize(t, c, d) }
func (g *group) xpreferredSize(d *sizing) (width, height int) { var r C.RECT width, height = g.child.preferredSize(d) if width < int(g.textlen) { // if the text is longer, try not to truncate width = int(g.textlen) } r.left = 0 r.top = 0 r.right = C.LONG(width) r.bottom = C.LONG(height) // use negative numbers to increase the size of the rectangle if g.margined { marginRectDLU(&r, -groupYMarginTop, -groupYMarginBottom, -groupXMargin, -groupXMargin, d) } else { // unforutnately, as mentioned above, the size of a groupbox includes the label and border // 1 character cell (4DLU x, 8DLU y) on each side (but only 3DLU on the bottom) should be enough to make up for that; TODO is not, we can change it // TODO make these named constants marginRectDLU(&r, -8, -3, -4, -4, d) } return int(r.right - r.left), int(r.bottom - r.top) }
func marginRectDLU(r *C.RECT, top int, bottom int, left int, right int, d *sizing) { r.left += C.LONG(fromdlgunitsX(left, d)) r.top += C.LONG(fromdlgunitsY(top, d)) r.right -= C.LONG(fromdlgunitsX(right, d)) r.bottom -= C.LONG(fromdlgunitsY(bottom, d)) }