Properly handled the LVN_GETDISPINFO notificaiton on Windows this time.

This commit is contained in:
Pietro Gagliardi 2014-08-30 11:46:13 -04:00
parent df383ada76
commit da42b979e7
1 changed files with 44 additions and 26 deletions

View File

@ -104,10 +104,22 @@ func tableGetCell(data unsafe.Pointer, item *C.LVITEMW) {
d := reflect.Indirect(reflect.ValueOf(t.data))
datum := d.Index(int(item.iItem)).Field(int(item.iSubItem))
printMask(item)
switch {
case datum.Type() == reflect.TypeOf(ImageIndex(0)):
isText := true
if item.mask & C.LVIF_IMAGE != 0 {
if datum.Type() == reflect.TypeOf(ImageIndex(0)) {
item.iImage = C.int(datum.Interface().(ImageIndex))
case datum.Kind() == reflect.Bool:
isText = false
}
// else let the default behavior work
}
if item.mask & C.LVIF_INDENT != 0 {
// always have an indent of zero
item.iIndent = 0
}
if item.mask & C.LVIF_STATE != 0 {
// start by not changing any state
item.stateMask = 0
if datum.Kind() == reflect.Bool {
item.stateMask = C.LVIS_STATEIMAGEMASK
// state image index is 1-based
curstate := ((item.state & C.LVIS_STATEIMAGEMASK) >> 12)
@ -130,10 +142,16 @@ printMask(item)
curstate &^= C.checkboxStatePushed
}
item.state = (curstate + 1) << 12
default:
isText = false
}
}
if item.mask & C.LVIF_TEXT != 0 {
if isText {
s := fmt.Sprintf("%v", datum)
item.pszText = toUTF16(s)
}
// else let the default handler work
}
}
// the column autoresize policy is simple: