blob: 27212b5be50843d49e92b13bb7f024f1934d244f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright 2013 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build windows
package declarative
import (
"github.com/lxn/walk"
)
type Alignment1D uint
const (
AlignDefault = Alignment1D(walk.AlignDefault)
AlignNear = Alignment1D(walk.AlignNear)
AlignCenter = Alignment1D(walk.AlignCenter)
AlignFar = Alignment1D(walk.AlignFar)
)
type TableViewColumn struct {
Name string
DataMember string
Format string
Title string
Alignment Alignment1D
Precision int
Width int
Hidden bool
Frozen bool
StyleCell func(style *walk.CellStyle)
LessFunc func(i, j int) bool
FormatFunc func(value interface{}) string
}
func (tvc TableViewColumn) Create(tv *walk.TableView) error {
w := walk.NewTableViewColumn()
if err := w.SetAlignment(walk.Alignment1D(tvc.Alignment)); err != nil {
return err
}
w.SetDataMember(tvc.DataMember)
if tvc.Format != "" {
if err := w.SetFormat(tvc.Format); err != nil {
return err
}
}
if err := w.SetPrecision(tvc.Precision); err != nil {
return err
}
w.SetName(tvc.Name)
if err := w.SetTitle(tvc.Title); err != nil {
return err
}
if err := w.SetVisible(!tvc.Hidden); err != nil {
return err
}
if err := w.SetFrozen(tvc.Frozen); err != nil {
return err
}
if err := w.SetWidth(tvc.Width); err != nil {
return err
}
w.SetLessFunc(tvc.LessFunc)
w.SetFormatFunc(tvc.FormatFunc)
return tv.Columns().Add(w)
}
|