diff --git a/newctrl/container_windows.go b/newctrl/container_windows.go index 61a7296..fe40f01 100644 --- a/newctrl/container_windows.go +++ b/newctrl/container_windows.go @@ -59,7 +59,7 @@ func (c *container) hide() { func (c *container) parent() *controlParent { return &controlParent{c.hwnd} -) +} //export storeContainerHWND func storeContainerHWND(data unsafe.Pointer, hwnd C.HWND) { @@ -100,7 +100,7 @@ func (w *window) beginResize() (d *sizing) { d = new(sizing) - C.calculateBaseUnits(c.hwnd, &baseX, &baseY, &internalLeading) + C.calculateBaseUnits(w.hwnd, &baseX, &baseY, &internalLeading) d.baseX = baseX d.baseY = baseY d.internalLeading = internalLeading @@ -124,8 +124,8 @@ func (w *window) beginResize() (d *sizing) { } func marginRectDLU(r *C.RECT, top int, bottom int, left int, right int, d *sizing) { - r.left += fromdlgunitsX(left, d) - r.top += fromdlgunitsY(top, d) - r.right -= fromdlgunitsX(right, d) - r.bottom -= fromdlgunitsY(bottom, d) + 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)) } diff --git a/newctrl/control_windows.go b/newctrl/control_windows.go index 106727b..1da8a60 100644 --- a/newctrl/control_windows.go +++ b/newctrl/control_windows.go @@ -8,9 +8,6 @@ import "C" type controlParent struct { hwnd C.HWND } -type sizing struct { - // TODO -} // don't specify preferredSize in any of these; they're per-control diff --git a/newctrl/grid.go b/newctrl/grid.go index 0400ec0..f8fd616 100644 --- a/newctrl/grid.go +++ b/newctrl/grid.go @@ -364,7 +364,6 @@ func (g *grid) resize(x int, y int, width int, height int, d *sizing) { // 8) and FINALLY we draw for _, ycol := range gg { - current = nil for _, i := range ycol { if i != -1 { // treat empty cells like spaces g.controls[i].control.resize( @@ -374,7 +373,7 @@ func (g *grid) resize(x int, y int, width int, height int, d *sizing) { } } - return allocations + return } func (g *grid) preferredSize(d *sizing) (width, height int) { diff --git a/newctrl/group_windows.go b/newctrl/group_windows.go index 98569d6..9a025c5 100644 --- a/newctrl/group_windows.go +++ b/newctrl/group_windows.go @@ -17,7 +17,7 @@ func newGroup(text string, control Control) Group { C.WS_EX_CONTROLPARENT) g := &group{ controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd), - child: control + child: control, } g.fpreferredSize = g.preferredSize g.fresize = g.resize @@ -46,7 +46,7 @@ func (g *group) preferredSize(d *sizing) (width, height int) { width, height = g.child.preferredSize(d) if width < int(g.textlen) { // if the text is longer, try not to truncate - width = int(g._textlen) + width = int(g.textlen) } r.left = 0 r.top = 0 diff --git a/newctrl/label_windows.go b/newctrl/label_windows.go index 3a9e3b7..1e6089d 100644 --- a/newctrl/label_windows.go +++ b/newctrl/label_windows.go @@ -12,7 +12,7 @@ type label struct { var labelclass = toUTF16("STATIC") -func newLabel(text string) { +func newLabel(text string) Label { hwnd := C.newControl(labelclass, // SS_NOPREFIX avoids accelerator translation; SS_LEFTNOWORDWRAP clips text past the end // controls are vertically aligned to the top by default (thanks Xeek in irc.freenode.net/#winapi) diff --git a/newctrl/simplegrid.go b/newctrl/simplegrid.go index 2e8767e..ac1f0ee 100644 --- a/newctrl/simplegrid.go +++ b/newctrl/simplegrid.go @@ -14,8 +14,6 @@ import ( // One Control can be marked as "stretchy": when the Window containing the SimpleGrid is resized, the cell containing that Control resizes to take any remaining space; its row and column are adjusted accordingly (so other filling controls in the same row and column will fill to the new height and width, respectively). // A stretchy Control implicitly fills its cell. // All cooridnates in a SimpleGrid are given in (row,column) form with (0,0) being the top-left cell. -// -// As a special rule, to ensure proper appearance, non-standalone Labels are automatically made filling. type SimpleGrid interface { Control @@ -65,9 +63,6 @@ func NewSimpleGrid(nPerRow int, controls ...Control) SimpleGrid { ch[row] = make([]int, nPerRow) for x := 0; x < nPerRow; x++ { cc[row][x] = controls[i] - if l, ok := controls[i].(Label); ok && !l.isStandalone() { - cf[row][x] = true - } i++ } } @@ -83,7 +78,7 @@ func NewSimpleGrid(nPerRow int, controls ...Control) SimpleGrid { container: newContainer(), } p := g.container.parent() - for _, cc := range g.cc { + for _, cc := range g.controls { for _, c := range cc { c.setParent(p) } @@ -166,7 +161,6 @@ func (g *simpleGrid) resize(x int, y int, width int, height int, d *sizing) { // 4) draw startx := x for row, xcol := range g.controls { - current = nil // reset on new columns for col, c := range xcol { w := g.widths[row][col] h := g.heights[row][col] diff --git a/newctrl/stack.go b/newctrl/stack.go index 053cb5b..dfa4b64 100644 --- a/newctrl/stack.go +++ b/newctrl/stack.go @@ -47,6 +47,7 @@ func newStack(o orientation, controls ...Control) Stack { for _, c := range s.controls { c.setParent(p) } + return s } // NewHorizontalStack creates a new Stack that arranges the given Controls horizontally. @@ -122,7 +123,7 @@ func (s *stack) resize(x int, y int, width int, height int, d *sizing) { } // 3) now actually place controls for i, c := range s.controls { - as := c.resize(x, y, s.width[i], s.height[i], d) + c.resize(x, y, s.width[i], s.height[i], d) if s.orientation == horizontal { x += s.width[i] + d.xpadding } else { diff --git a/newctrl/tab_windows.go b/newctrl/tab_windows.go index f4481c6..af642ea 100644 --- a/newctrl/tab_windows.go +++ b/newctrl/tab_windows.go @@ -38,7 +38,7 @@ func newTab() Tab { // TODO margined func (t *tab) Append(name string, control Control) { c := newContainer() - control.setParent(&containerParent{c.hwnd}) + control.setParent(&controlParent{c.hwnd}) t.tabs = append(t.tabs, c) t.children = append(t.children, control) // initially hide tab 1..n controls; if we don't, they'll appear over other tabs, resulting in weird behavior @@ -75,8 +75,8 @@ return C.TRUE/*TODO } func (t *tab) preferredSize(d *sizing) (width, height int) { - for _, s := range t.tabs { - w, h := s.child.preferredSize(d) + for _, c := range t.children { + w, h := c.preferredSize(d) if width < w { width = w } @@ -102,7 +102,7 @@ func (t *tab) resize(x int, y int, width int, height int, d *sizing) { r.top = C.LONG(0) r.right = C.LONG(width) r.bottom = C.LONG(height) - C.tabGetContentRect(t._hwnd, &r) + C.tabGetContentRect(t.hwnd, &r) // and resize tabs // don't resize just the current tab; resize all tabs! for i, _ := range t.tabs { @@ -110,6 +110,4 @@ func (t *tab) resize(x int, y int, width int, height int, d *sizing) { t.tabs[i].resize(int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top), d) t.children[i].resize(int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top), d) } - // and now resize the tab control itself - basecommitResize(t, c, d) } diff --git a/newctrl/table_windows.go b/newctrl/table_windows.go index 8f46609..054a29b 100644 --- a/newctrl/table_windows.go +++ b/newctrl/table_windows.go @@ -26,7 +26,7 @@ type table struct { func finishNewTable(b *tablebase, ty reflect.Type) Table { hwnd := C.newControl(C.xWC_LISTVIEW, C.LVS_REPORT|C.LVS_OWNERDATA|C.LVS_NOSORTHEADER|C.LVS_SHOWSELALWAYS|C.LVS_SINGLESEL|C.WS_HSCROLL|C.WS_VSCROLL|C.WS_TABSTOP, - C.WS_EX_CLIENTEDGE), // WS_EX_CLIENTEDGE without WS_BORDER will show the canonical visual styles border (thanks to MindChild in irc.efnet.net/#winprog) + C.WS_EX_CLIENTEDGE) // WS_EX_CLIENTEDGE without WS_BORDER will show the canonical visual styles border (thanks to MindChild in irc.efnet.net/#winprog) t := &table{ controlSingleHWND: newControlSingleHWND(hwnd), tablebase: b, @@ -43,7 +43,7 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table { // LVS_EX_SUBITEMIMAGES gives us images in subitems, which will be important when both images and checkboxes are added C.tableAddExtendedStyles(t.hwnd, C.LVS_EX_FULLROWSELECT|C.LVS_EX_SUBITEMIMAGES) // this must come after the subclass because it uses one of our private messages - C.SendMessageW(t._hwnd, C.msgTableMakeInitialCheckboxImageList, 0, 0) + C.SendMessageW(t.hwnd, C.msgTableMakeInitialCheckboxImageList, 0, 0) for i := 0; i < ty.NumField(); i++ { C.tableAppendColumn(t.hwnd, C.int(i), toUTF16(ty.Field(i).Name)) } @@ -147,7 +147,7 @@ func (t *table) autoresize() { t.RLock() defer t.RUnlock() if !t.noautosize { - C.tableAutosizeColumns(t._hwnd, t.colcount) + C.tableAutosizeColumns(t.hwnd, t.colcount) } } @@ -170,7 +170,7 @@ func tableSetHot(data unsafe.Pointer, row C.int, col C.int) { t.hotrow = row t.hotcol = col if redraw { - C.tableUpdate(t._hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len())) + C.tableUpdate(t.hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len())) } } @@ -179,7 +179,7 @@ func tablePushed(data unsafe.Pointer, row C.int, col C.int) { t := (*table)(data) t.pushedrow = row t.pushedcol = col - C.tableUpdate(t._hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len())) + C.tableUpdate(t.hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len())) } //export tableToggled diff --git a/newctrl/window_windows.go b/newctrl/window_windows.go index cfcb091..2286ade 100644 --- a/newctrl/window_windows.go +++ b/newctrl/window_windows.go @@ -100,7 +100,7 @@ func windowResize(data unsafe.Pointer, r *C.RECT) { if w.margined { marginRectDLU(r, marginDialogUnits, marginDialogUnits, marginDialogUnits, marginDialogUnits, d) } - w.child.resize(int(r.left), int (r.top), int(r.right - r.left), int(r.bottom - r.top), TODO) + w.child.resize(int(r.left), int (r.top), int(r.right - r.left), int(r.bottom - r.top), d) } //export windowClosing