-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcellattribs.go
93 lines (78 loc) · 2.48 KB
/
cellattribs.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
package washeet
// NewDefaultCellAttribs return a pointer to a new instance of CellAttribs
// with default settings.
func NewDefaultCellAttribs() *CellAttribs {
cAttribs := &CellAttribs{
txtAttribs: newDefaultTextAttributes(),
txtAlign: AlignRight,
fgColor: defaultColors.cellStroke,
bgColor: defaultColors.cellFill,
fontSize: uint8(14),
}
return cAttribs
}
// SetBold sets/unsets the cell text's bold attribute.
func (cAttribs *CellAttribs) SetBold(flag bool) {
cAttribs.txtAttribs.setBold(flag)
}
// SetItalics sets/unsets the cell text's italics attribute.
func (cAttribs *CellAttribs) SetItalics(flag bool) {
cAttribs.txtAttribs.setItalics(flag)
}
// SetUnderline sets/unsets the cell text's underline attribute.
func (cAttribs *CellAttribs) SetUnderline(flag bool) {
cAttribs.txtAttribs.setUnderline(flag)
}
// IsBold returns whether bold attribute is set or not.
func (cAttribs *CellAttribs) IsBold() bool {
return cAttribs.txtAttribs.isBold()
}
// IsItalics returns whether italics attribute is set or not.
func (cAttribs *CellAttribs) IsItalics() bool {
return cAttribs.txtAttribs.isItalics()
}
// IsUnderline returns whether underline attribute is set or not.
func (cAttribs *CellAttribs) IsUnderline() bool {
return cAttribs.txtAttribs.isUnderline()
}
// GetAlignment returns the cell text alignment setting.
func (cAttribs *CellAttribs) GetAlignment() TextAlignType {
return cAttribs.txtAlign
}
// SetAlignment sets the cell text alignment setting.
func (cAttribs *CellAttribs) SetAlignment(align TextAlignType) {
cAttribs.txtAlign = align
}
// GetFGColor returns the foreground color setting.
func (cAttribs *CellAttribs) GetFGColor() *Color {
return cAttribs.fgColor
}
// SetFGColor sets the foreground color.
func (cAttribs *CellAttribs) SetFGColor(color *Color) {
if color == nil {
color = defaultColors.cellStroke
}
cAttribs.fgColor = color
}
// GetBGColor returns the background color setting.
func (cAttribs *CellAttribs) GetBGColor() *Color {
return cAttribs.bgColor
}
// SetBGColor sets the background color.
func (cAttribs *CellAttribs) SetBGColor(color *Color) {
if color == nil {
color = defaultColors.cellFill
}
cAttribs.bgColor = color
}
// GetFontSize returns the font size setting in pixels.
func (cAttribs *CellAttribs) GetFontSize() uint8 {
return cAttribs.fontSize
}
// SetFontSize sets the font size provided in pixels.
func (cAttribs *CellAttribs) SetFontSize(size uint8) {
if size == 0 {
size = constCellFontSizePx
}
cAttribs.fontSize = size
}