-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
border.go
146 lines (122 loc) · 3.64 KB
/
border.go
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Copyright (c) 2017 Andrey Gayvoronsky <plandem@gmail.com>
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package styles
import (
"github.com/plandem/xlsx/internal/color"
"github.com/plandem/xlsx/internal/ml/primitives"
)
type borderTopSegmentOption byte
type borderBottomSegmentOption byte
type borderLeftSegmentOption byte
type borderRightSegmentOption byte
type borderDiagonalSegmentOption byte
type borderVerticalSegmentOption byte
type borderHorizontalSegmentOption byte
type borderOption struct {
Top borderTopSegmentOption
Bottom borderBottomSegmentOption
Left borderLeftSegmentOption
Right borderRightSegmentOption
Diagonal borderDiagonalSegmentOption
Vertical borderVerticalSegmentOption
Horizontal borderHorizontalSegmentOption
}
//Border is a 'namespace' for all possible settings for border
var Border borderOption
func (b *borderOption) DiagonalUp(s *Info) {
s.styleInfo.Border.DiagonalUp = true
}
func (b *borderOption) DiagonalDown(s *Info) {
s.styleInfo.Border.DiagonalDown = true
}
func (b *borderOption) Outline(s *Info) {
s.styleInfo.Border.Outline = true
}
func (b *borderOption) Type(t primitives.BorderStyleType) Option {
return func(s *Info) {
s.styleInfo.Border.Top.Type = t
s.styleInfo.Border.Bottom.Type = t
s.styleInfo.Border.Left.Type = t
s.styleInfo.Border.Right.Type = t
}
}
func (b *borderOption) Color(rgb string) Option {
return func(s *Info) {
rgb := color.New(rgb)
s.styleInfo.Border.Top.Color = rgb
s.styleInfo.Border.Bottom.Color = rgb
s.styleInfo.Border.Left.Color = rgb
s.styleInfo.Border.Right.Color = rgb
}
}
func (b *borderTopSegmentOption) Type(t primitives.BorderStyleType) Option {
return func(s *Info) {
s.styleInfo.Border.Top.Type = t
}
}
func (b *borderTopSegmentOption) Color(rgb string) Option {
return func(s *Info) {
s.styleInfo.Border.Top.Color = color.New(rgb)
}
}
func (b *borderBottomSegmentOption) Type(t primitives.BorderStyleType) Option {
return func(s *Info) {
s.styleInfo.Border.Bottom.Type = t
}
}
func (b *borderBottomSegmentOption) Color(rgb string) Option {
return func(s *Info) {
s.styleInfo.Border.Bottom.Color = color.New(rgb)
}
}
func (b *borderLeftSegmentOption) Type(t primitives.BorderStyleType) Option {
return func(s *Info) {
s.styleInfo.Border.Left.Type = t
}
}
func (b *borderLeftSegmentOption) Color(rgb string) Option {
return func(s *Info) {
s.styleInfo.Border.Left.Color = color.New(rgb)
}
}
func (b *borderRightSegmentOption) Type(t primitives.BorderStyleType) Option {
return func(s *Info) {
s.styleInfo.Border.Right.Type = t
}
}
func (b *borderRightSegmentOption) Color(rgb string) Option {
return func(s *Info) {
s.styleInfo.Border.Right.Color = color.New(rgb)
}
}
func (b *borderDiagonalSegmentOption) Type(t primitives.BorderStyleType) Option {
return func(s *Info) {
s.styleInfo.Border.Diagonal.Type = t
}
}
func (b *borderDiagonalSegmentOption) Color(rgb string) Option {
return func(s *Info) {
s.styleInfo.Border.Diagonal.Color = color.New(rgb)
}
}
func (b *borderVerticalSegmentOption) Type(t primitives.BorderStyleType) Option {
return func(s *Info) {
s.styleInfo.Border.Vertical.Type = t
}
}
func (b *borderVerticalSegmentOption) Color(rgb string) Option {
return func(s *Info) {
s.styleInfo.Border.Vertical.Color = color.New(rgb)
}
}
func (b *borderHorizontalSegmentOption) Type(t primitives.BorderStyleType) Option {
return func(s *Info) {
s.styleInfo.Border.Horizontal.Type = t
}
}
func (b *borderHorizontalSegmentOption) Color(rgb string) Option {
return func(s *Info) {
s.styleInfo.Border.Horizontal.Color = color.New(rgb)
}
}