Fixed compiler errors.

This commit is contained in:
Pietro Gagliardi 2014-10-15 13:30:35 -04:00
parent 6b2dac4200
commit 0e32aff30b
10 changed files with 23 additions and 34 deletions

View File

@ -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))
}

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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)

View File

@ -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]

View File

@ -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 {

View File

@ -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)
}

View File

@ -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

View File

@ -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