-
Notifications
You must be signed in to change notification settings - Fork 0
/
css.go
157 lines (118 loc) · 4.75 KB
/
css.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
147
148
149
150
151
152
153
154
155
156
157
// Copyright (C) 2013 Andras Belicza. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Built-in static CSS themes of GWU.
package gwu
type CSSRule interface {
Selector() string
SetSelector(selector string)
Style() Style
render(w writer)
}
type cssRuleImpl struct {
style *styleImpl
selector string
}
func NewCSSRule() CSSRule {
return &cssRuleImpl{style: newStyleImpl()}
}
func (css *cssRuleImpl) Selector() string {
return css.selector
}
func (css *cssRuleImpl) SetSelector(s string) {
css.selector = s
}
func (css *cssRuleImpl) Style() Style {
return css.style
}
func (css *cssRuleImpl) render(w writer) {
w.Writes(css.selector)
w.Write(_STR_CB_OP)
css.Style().renderAttrs(w)
w.Write(_STR_CB_CL)
}
type CSSRuleCollection interface {
AddRule(r CSSRule)
render(w writer)
}
type cssRuleCollectionImpl struct {
rules []cssRuleImpl
}
func (coll *cssRuleCollectionImpl) AddRule(r CSSRule) {
coll.rules = append(coll.rules, cssRuleImpl{style: r.Style().(*styleImpl), selector: r.Selector()})
}
func (css *cssRuleCollectionImpl) render(w writer) {
for _, rule := range css.rules {
rule.render(w)
}
}
// Built-in CSS themes.
const (
THEME_DEFAULT = "default" // Default CSS theme
THEME_DEBUG = "debug" // Debug CSS theme, useful for developing/debugging purposes.
)
// resNameStaticCss returns the CSS resource name
// for the specified CSS theme.
func resNameStaticCss(theme string) string {
// E.g. "gowut-default-0.8.0.css"
return "gowut-" + theme + "-" + GOWUT_VERSION + ".css"
}
var staticCss map[string][]byte = make(map[string][]byte)
func init() {
staticCss[resNameStaticCss(THEME_DEFAULT)] = []byte("" +
`
.gwuimg-collapsed {background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAATUlEQVQ4y83RsQkAMAhEURNc+iZw7KQNgnjGRlv5D0SRMQPgADjVbr3AuzCz1QJYKAUyiAYiqAx4aHe/p9XAn6C/IQ1kb9TfMATYcM5cL5cg3qDaS5UAAAAASUVORK5CYII=)}
.gwuimg-expanded {background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAATElEQVQ4y2NgGGjACGNUVlb+J0Vje3s7IwMDAwMT1VxAiitgtlPfBcS4Atl22rgAnyvQbaedC7C5ApvtVHEBXlBZWfmfUKwwMQx5AADNQhjmAryM3wAAAABJRU5ErkJggg==)}
.gwuimg-collapsed, .gwuimg-expanded {background-position:0px 0px; background-repeat:no-repeat}
body {font-family:Arial}
.gwu-Window {}
.gwu-Panel {}
.gwu-Table {}
.gwu-Label {}
.gwu-Link {}
.gwu-Image {}
.gwu-Button {}
.gwu-CheckBox {}
.gwu-CheckBox-Disabled {color:#888}
.gwu-RadioButton {}
.gwu-RadioButton-Disabled {color:#888}
.gwu-ListBox {}
.gwu-TextBox {}
.gwu-PasswBox {}
.gwu-Html {}
.gwu-SwitchButton {}
.gwu-SwitchButton-On-Active {background:#00a000; color:#d0ffd0}
.gwu-SwitchButton-Off-Active {background:#d03030; color:#ffd0d0}
.gwu-SwitchButton-On-Inactive, .gwu-SwitchButton-Off-Inactive {background:#606060; color:#909090}
.gwu-SwitchButton-On-Inactive:enabled, .gwu-SwitchButton-Off-Inactive:enabled {cursor:pointer}
.gwu-SwitchButton-On-Active, .gwu-SwitchButton-Off-Active, .gwu-SwitchButton-On-Inactive, .gwu-SwitchButton-Off-Inactive {margin:0px;border: 0px; width:100%}
.gwu-SwitchButton-On-Active:disabled, .gwu-SwitchButton-Off-Active:disabled, .gwu-SwitchButton-On-Inactive:disabled, .gwu-SwitchButton-Off-Inactive:disabled {color:black}
.gwu-Expander {}
.gwu-Expander-Header, .gwu-Expander-Header-Expanded {padding-left:19px; cursor:pointer}
.gwu-Expander-Content {padding-left:19px}
.gwu-TabBar {}
.gwu-TabBar-Top {padding:0px 5px 0px 5px; border-bottom:5px solid #8080f8}
.gwu-TabBar-Bottom {padding:0px 5px 0px 5px; border-top:5px solid #8080f8}
.gwu-TabBar-Left {padding:5px 0px 5px 0px; border-right:5px solid #8080f8}
.gwu-TabBar-Right {padding:5px 0px 5px 0px; border-left:5px solid #8080f8}
.gwu-TabBar-NotSelected {padding-left:5px; padding-right:5px; border:1px solid white ; background:#c0c0ff; cursor:default}
.gwu-TabBar-Selected {padding-left:5px; padding-right:5px; border:1px solid #8080f8; background:#8080f8; cursor:default}
.gwu-TabPanel {}
.gwu-TabPanel-Content {border:1px solid #8080f8; width:100%; height:100%}
`)
staticCss[resNameStaticCss(THEME_DEBUG)] = []byte(string(staticCss[resNameStaticCss(THEME_DEFAULT)]) +
`
.gwu-Window td, .gwu-Table td, .gwu-Panel td, .gwu-TabPanel td {border:1px solid black}
`)
}