summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-30 11:46:13 -0400
committerPietro Gagliardi <[email protected]>2014-08-30 11:46:13 -0400
commitda42b979e793c2ccaeccaff2977a425ebc2af4d5 (patch)
tree19f15c3f17bfa672aafb1e8f31693e34bde24cdd
parentdf383ada764d883b5008988e506472548d052ae8 (diff)
Properly handled the LVN_GETDISPINFO notificaiton on Windows this time.
-rw-r--r--redo/table_windows.go70
1 files changed, 44 insertions, 26 deletions
diff --git a/redo/table_windows.go b/redo/table_windows.go
index 9fee4c4..21d681d 100644
--- a/redo/table_windows.go
+++ b/redo/table_windows.go
@@ -104,35 +104,53 @@ 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)):
- item.iImage = C.int(datum.Interface().(ImageIndex))
- case 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--
+ isText := true
+ if item.mask & C.LVIF_IMAGE != 0 {
+ if datum.Type() == reflect.TypeOf(ImageIndex(0)) {
+ item.iImage = C.int(datum.Interface().(ImageIndex))
+ isText = false
}
- 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
+ // 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)
+ 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.pushedrow && item.iSubItem == t.pushedcol {
- curstate |= C.checkboxStatePushed
- } else {
- curstate &^= C.checkboxStatePushed
+ }
+ if item.mask & C.LVIF_TEXT != 0 {
+ if isText {
+ s := fmt.Sprintf("%v", datum)
+ item.pszText = toUTF16(s)
}
- item.state = (curstate + 1) << 12
- default:
- s := fmt.Sprintf("%v", datum)
- item.pszText = toUTF16(s)
+ // else let the default handler work
}
}