Properly handled the LVN_GETDISPINFO notificaiton on Windows this time.
This commit is contained in:
parent
df383ada76
commit
da42b979e7
|
@ -104,35 +104,53 @@ func tableGetCell(data unsafe.Pointer, item *C.LVITEMW) {
|
||||||
d := reflect.Indirect(reflect.ValueOf(t.data))
|
d := reflect.Indirect(reflect.ValueOf(t.data))
|
||||||
datum := d.Index(int(item.iItem)).Field(int(item.iSubItem))
|
datum := d.Index(int(item.iItem)).Field(int(item.iSubItem))
|
||||||
printMask(item)
|
printMask(item)
|
||||||
switch {
|
isText := true
|
||||||
case datum.Type() == reflect.TypeOf(ImageIndex(0)):
|
if item.mask & C.LVIF_IMAGE != 0 {
|
||||||
item.iImage = C.int(datum.Interface().(ImageIndex))
|
if datum.Type() == reflect.TypeOf(ImageIndex(0)) {
|
||||||
case datum.Kind() == reflect.Bool:
|
item.iImage = C.int(datum.Interface().(ImageIndex))
|
||||||
item.stateMask = C.LVIS_STATEIMAGEMASK
|
isText = false
|
||||||
// state image index is 1-based
|
|
||||||
curstate := ((item.state & C.LVIS_STATEIMAGEMASK) >> 12)
|
|
||||||
if curstate > 0 {
|
|
||||||
curstate--
|
|
||||||
}
|
}
|
||||||
if datum.Bool() == true {
|
// else let the default behavior work
|
||||||
curstate |= C.checkboxStateChecked
|
}
|
||||||
} else {
|
if item.mask & C.LVIF_INDENT != 0 {
|
||||||
curstate &^= C.checkboxStateChecked
|
// 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)
|
||||||
|
if curstate > 0 {
|
||||||
|
curstate--
|
||||||
|
}
|
||||||
|
if datum.Bool() == true {
|
||||||
|
curstate |= C.checkboxStateChecked
|
||||||
|
} else {
|
||||||
|
curstate &^= C.checkboxStateChecked
|
||||||
|
}
|
||||||
|
if item.iItem == t.hotrow && item.iSubItem == t.hotcol {
|
||||||
|
curstate |= C.checkboxStateHot
|
||||||
|
} else {
|
||||||
|
curstate &^= C.checkboxStateHot
|
||||||
|
}
|
||||||
|
if item.iItem == t.pushedrow && item.iSubItem == t.pushedcol {
|
||||||
|
curstate |= C.checkboxStatePushed
|
||||||
|
} else {
|
||||||
|
curstate &^= C.checkboxStatePushed
|
||||||
|
}
|
||||||
|
item.state = (curstate + 1) << 12
|
||||||
|
isText = false
|
||||||
}
|
}
|
||||||
if item.iItem == t.hotrow && item.iSubItem == t.hotcol {
|
}
|
||||||
curstate |= C.checkboxStateHot
|
if item.mask & C.LVIF_TEXT != 0 {
|
||||||
} else {
|
if isText {
|
||||||
curstate &^= C.checkboxStateHot
|
s := fmt.Sprintf("%v", datum)
|
||||||
|
item.pszText = toUTF16(s)
|
||||||
}
|
}
|
||||||
if item.iItem == t.pushedrow && item.iSubItem == t.pushedcol {
|
// else let the default handler work
|
||||||
curstate |= C.checkboxStatePushed
|
|
||||||
} else {
|
|
||||||
curstate &^= C.checkboxStatePushed
|
|
||||||
}
|
|
||||||
item.state = (curstate + 1) << 12
|
|
||||||
default:
|
|
||||||
s := fmt.Sprintf("%v", datum)
|
|
||||||
item.pszText = toUTF16(s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue