MCPcopy
hub / github.com/lxn/walk / SaveState

Method SaveState

tableview.go:1619–1693  ·  view source on GitHub ↗

SaveState writes the UI state of the *TableView to the settings.

()

Source from the content-addressed store, hash-verified

1617
1618// SaveState writes the UI state of the *TableView to the settings.
1619func (tv *TableView) SaveState() error {
1620 if tv.columns.Len() == 0 {
1621 return nil
1622 }
1623
1624 if tv.state == nil {
1625 tv.state = new(tableViewState)
1626 }
1627
1628 tvs := tv.state
1629
1630 tvs.SortColumnName = tv.columns.items[tv.sortedColumnIndex].name
1631 tvs.SortOrder = tv.sortOrder
1632
1633 // tvs.Columns = make([]tableViewColumnState, tv.columns.Len())
1634
1635 for _, tvc := range tv.columns.items {
1636 var tvcs *tableViewColumnState
1637 for _, cur := range tvs.Columns {
1638 if cur.Name == tvc.name {
1639 tvcs = cur
1640 break
1641 }
1642 }
1643
1644 // tvcs := &tvs.Columns[i]
1645
1646 if tvcs == nil {
1647 tvs.Columns = append(tvs.Columns, new(tableViewColumnState))
1648 tvcs = tvs.Columns[len(tvs.Columns)-1]
1649 }
1650
1651 tvcs.Name = tvc.name
1652 tvcs.Title = tvc.titleOverride
1653 tvcs.Width = tvc.Width()
1654 tvcs.Visible = tvc.Visible()
1655 tvcs.Frozen = tvc.Frozen()
1656 tvcs.LastSeenDate = time.Now().Format("2006-01-02")
1657 }
1658
1659 visibleCols := tv.visibleColumns()
1660 frozenCount := tv.visibleFrozenColumnCount()
1661 normalCount := len(visibleCols) - frozenCount
1662 indices := make([]int32, len(visibleCols))
1663 var lp uintptr
1664 if frozenCount > 0 {
1665 lp = uintptr(unsafe.Pointer(&indices[0]))
1666
1667 if 0 == win.SendMessage(tv.hwndFrozenLV, win.LVM_GETCOLUMNORDERARRAY, uintptr(frozenCount), lp) {
1668 return newError("LVM_GETCOLUMNORDERARRAY")
1669 }
1670 }
1671 if normalCount > 0 {
1672 lp = uintptr(unsafe.Pointer(&indices[frozenCount]))
1673
1674 if 0 == win.SendMessage(tv.hwndNormalLV, win.LVM_GETCOLUMNORDERARRAY, uintptr(normalCount), lp) {
1675 return newError("LVM_GETCOLUMNORDERARRAY")
1676 }

Callers

nothing calls this directly

Calls 10

visibleColumnsMethod · 0.95
newErrorFunction · 0.85
FrozenMethod · 0.80
WriteStateMethod · 0.80
WidthMethod · 0.65
VisibleMethod · 0.65
SendMessageMethod · 0.65
LenMethod · 0.45
FormatMethod · 0.45

Tested by

no test coverage detected