author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 11 Jun 2018 10:50:04 +0100 | |
branch | jv |
changeset 8420 | 76e39223f5ab |
parent 7723 | 620e91f9b082 |
child 9054 | 828df4ac2f98 |
permissions | -rw-r--r-- |
53 | 1 |
" |
243 | 2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
8420 | 3 |
COPYRIGHT (c) 2016 Jan Vrany |
72 | 4 |
All Rights Reserved |
53 | 5 |
|
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
3678 | 13 |
"{ Package: 'stx:libview' }" |
14 |
||
6920 | 15 |
"{ NameSpace: Smalltalk }" |
16 |
||
243 | 17 |
ResourcePack subclass:#ViewStyle |
2775 | 18 |
instanceVariableNames:'name is3D viewGrey' |
617 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Views-Support' |
|
53 | 22 |
! |
23 |
||
24 |
!ViewStyle class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
8420 | 29 |
COPYRIGHT (c) 2016 Jan Vrany |
72 | 30 |
All Rights Reserved |
53 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
instances of this class keep all view-style specific information. |
|
72 | 44 |
The current viewStyle is kept in Views-classvariable called 'StyleSheet' |
45 |
and is instantiated with 'View defaultStyle:aStyleSymbol', which reads |
|
46 |
a stylesheet from a file '<aStyleSymbol>.style' (usually in the 'resources' |
|
47 |
directory. |
|
617 | 48 |
|
49 |
[see also:] |
|
2304
cbf9bb6fb83e
use #onDevice: instead of #on:
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
50 |
View |
cbf9bb6fb83e
use #onDevice: instead of #on:
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
51 |
( Configuration & Customization :html: custom/TOP.html#VIEWSTYLE ) |
617 | 52 |
|
53 |
[author:] |
|
2304
cbf9bb6fb83e
use #onDevice: instead of #on:
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
54 |
Claus Gittinger |
53 | 55 |
" |
56 |
! ! |
|
57 |
||
58 |
!ViewStyle class methodsFor:'instance creation'! |
|
59 |
||
3678 | 60 |
fromFile:aFileNameArg |
53 | 61 |
"get the preferences definitions from a file" |
62 |
||
5531 | 63 |
|aFileName prefs failed nm nmInStyles dir path baseName| |
53 | 64 |
|
3678 | 65 |
aFileName := aFileNameArg asFilename. |
66 |
(aFileName hasSuffix:'style') ifTrue:[ |
|
4681
3cd2041ea16d
#fromFile: - use (only) #getResorceFileName:forPackage
Stefan Vogel <sv@exept.de>
parents:
4289
diff
changeset
|
67 |
baseName := aFileName withoutSuffix baseName. |
3cd2041ea16d
#fromFile: - use (only) #getResorceFileName:forPackage
Stefan Vogel <sv@exept.de>
parents:
4289
diff
changeset
|
68 |
nm := aFileName. |
72 | 69 |
] ifFalse:[ |
4681
3cd2041ea16d
#fromFile: - use (only) #getResorceFileName:forPackage
Stefan Vogel <sv@exept.de>
parents:
4289
diff
changeset
|
70 |
baseName := aFileName baseName. |
3cd2041ea16d
#fromFile: - use (only) #getResorceFileName:forPackage
Stefan Vogel <sv@exept.de>
parents:
4289
diff
changeset
|
71 |
nm := aFileName withSuffix:'style'. |
72 | 72 |
]. |
5531 | 73 |
nm isAbsolute ifFalse:[ |
74 |
nmInStyles := 'styles' asFilename / nm |
|
75 |
]. |
|
76 |
||
3678 | 77 |
prefs := self new. |
4681
3cd2041ea16d
#fromFile: - use (only) #getResorceFileName:forPackage
Stefan Vogel <sv@exept.de>
parents:
4289
diff
changeset
|
78 |
prefs at:#name put:baseName. |
153 | 79 |
|
5531 | 80 |
nmInStyles notNil ifTrue:[ |
81 |
path := Smalltalk getResourceFileName:nmInStyles forPackage:'stx:libview'. |
|
82 |
]. |
|
83 |
path isNil ifTrue:[ |
|
84 |
path := Smalltalk getResourceFileName:nm forPackage:'stx:libview'. |
|
85 |
]. |
|
3057
5d7383ca3aef
oops - local style file (in resources) must still be found
Claus Gittinger <cg@exept.de>
parents:
3053
diff
changeset
|
86 |
path notNil ifTrue:[ |
4681
3cd2041ea16d
#fromFile: - use (only) #getResorceFileName:forPackage
Stefan Vogel <sv@exept.de>
parents:
4289
diff
changeset
|
87 |
dir := path asFilename directory pathName. |
3048
df43567e46cd
look for styles in the libview package-dir as well
Claus Gittinger <cg@exept.de>
parents:
2775
diff
changeset
|
88 |
]. |
4681
3cd2041ea16d
#fromFile: - use (only) #getResorceFileName:forPackage
Stefan Vogel <sv@exept.de>
parents:
4289
diff
changeset
|
89 |
failed := (prefs readFromFile:nm directory:dir) isNil. |
153 | 90 |
prefs at:#fileReadFailed put:failed. |
53 | 91 |
^ prefs |
92 |
||
72 | 93 |
" |
4681
3cd2041ea16d
#fromFile: - use (only) #getResorceFileName:forPackage
Stefan Vogel <sv@exept.de>
parents:
4289
diff
changeset
|
94 |
ViewStyle fromFile:'motif' |
3112 | 95 |
ViewStyle fromFile:'motif.style' |
96 |
ViewStyle fromFile:'normal.style' |
|
72 | 97 |
ViewStyle fromFile:'iris.style' |
3678 | 98 |
ViewStyle fromFile:'iris.style' asFilename |
72 | 99 |
" |
3052 | 100 |
|
3112 | 101 |
"Modified: / 10.12.1999 / 16:05:30 / cg" |
53 | 102 |
! ! |
103 |
||
5952 | 104 |
!ViewStyle class methodsFor:'constants'! |
105 |
||
7711 | 106 |
adwaita |
107 |
^ #Adwaita |
|
108 |
||
109 |
"Created: / 24-11-2016 / 17:54:58 / cg" |
|
110 |
! |
|
111 |
||
112 |
macosx_yosemite |
|
113 |
^ #'macosx_yosemite' |
|
114 |
||
115 |
"Created: / 24-11-2016 / 17:55:46 / cg" |
|
116 |
! |
|
117 |
||
7179 | 118 |
msWindows8 |
119 |
^ #mswindows8 |
|
120 |
! |
|
121 |
||
5952 | 122 |
msWindowsVista |
123 |
^ #mswindowsVista |
|
124 |
! |
|
125 |
||
126 |
msWindowsXP |
|
127 |
^ #mswindowsXP |
|
128 |
! |
|
129 |
||
130 |
normal |
|
131 |
^ #normal |
|
132 |
! ! |
|
133 |
||
53 | 134 |
!ViewStyle methodsFor:'accessing'! |
135 |
||
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
136 |
at:key |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
137 |
^ self at: key default: nil for: thisContext sender receiver |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
138 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
139 |
"Modified: / 10-09-1995 / 10:59:38 / claus" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
140 |
"Modified: / 19-07-2016 / 21:41:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
141 |
! |
243 | 142 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
143 |
at:key default:default |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
144 |
^ self at: key default: default for: thisContext sender receiver |
243 | 145 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
146 |
"Created: / 14-10-1997 / 00:21:15 / cg" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
147 |
"Modified: / 15-09-1998 / 21:47:13 / cg" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
148 |
"Modified: / 19-07-2016 / 21:41:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
243 | 149 |
! |
150 |
||
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
151 |
at:key default:default for: class |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
152 |
"Retrieve a style resource (color, image, string...) for given key and |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
153 |
view `class`. If not found, `default` is returned. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
154 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
155 |
Resource `key` is either a simple key (for example 'foo') or |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
156 |
compound key (for example 'bar.foo'). Resource is looked up |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
157 |
as follows: |
1925
e4d67cc4f082
support new viewStyle resource name format
Claus Gittinger <cg@exept.de>
parents:
1894
diff
changeset
|
158 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
159 |
1. key '<class name>.foo' is looked up, if it exists |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
160 |
then its value is returned. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
161 |
2. key 'bar.foo' is looked up, if it exists then |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
162 |
then its value is returned (only if key is compound) |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
163 |
3. key 'foo' is looked up, if it exists then |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
164 |
then its value is returned |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
165 |
4. `default` value is returned. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
166 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
167 |
This has been added to support fine-grained resource (mainly color) specification |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
168 |
allowing (easy) customization per widget class (in a somewhat predictable) way. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
169 |
All that while being backward compatible. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
170 |
" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
171 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
172 |
| i key1 key2 key3 | |
1925
e4d67cc4f082
support new viewStyle resource name format
Claus Gittinger <cg@exept.de>
parents:
1894
diff
changeset
|
173 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
174 |
i := key indexOf: $.. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
175 |
i ~~ 0 ifTrue:[ |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
176 |
key3 := (key copyFrom: i + 1). |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
177 |
key2 := key. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
178 |
] ifFalse:[ |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
179 |
key3 := key. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
180 |
key2 := nil. |
2347
c276691fdd72
allow for blocks in styleSheets
Claus Gittinger <cg@exept.de>
parents:
2304
diff
changeset
|
181 |
]. |
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
182 |
key1 := class class theNonMetaclass name , '.' , key3. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
183 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
184 |
(self includesKey:key1) ifTrue:[ |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
185 |
^ (super at:key1 ifAbsent:default) value |
1925
e4d67cc4f082
support new viewStyle resource name format
Claus Gittinger <cg@exept.de>
parents:
1894
diff
changeset
|
186 |
]. |
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
187 |
(key2 notNil and:[self includesKey:key2]) ifTrue:[ |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
188 |
^ (super at:key2 ifAbsent:default) value |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
189 |
]. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
190 |
(self includesKey:key3) ifTrue:[ |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
191 |
^ (super at:key3 ifAbsent:default) value |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
192 |
]. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
193 |
^ default value. |
1925
e4d67cc4f082
support new viewStyle resource name format
Claus Gittinger <cg@exept.de>
parents:
1894
diff
changeset
|
194 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
195 |
"Created: / 19-07-2016 / 22:21:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1925
e4d67cc4f082
support new viewStyle resource name format
Claus Gittinger <cg@exept.de>
parents:
1894
diff
changeset
|
196 |
! |
e4d67cc4f082
support new viewStyle resource name format
Claus Gittinger <cg@exept.de>
parents:
1894
diff
changeset
|
197 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
198 |
colorAt: key |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
199 |
^ self colorAt: key default: nil for: thisContext sender receiver |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
200 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
201 |
"Modified: / 19-07-2016 / 21:32:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
202 |
! |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
203 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
204 |
colorAt:key default:default |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
205 |
^ self colorAt:key default:default for: thisContext sender receiver |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
206 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
207 |
"Modified (format): / 19-07-2016 / 21:36:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
208 |
! |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
209 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
210 |
colorAt:key default:default for:class |
7402 | 211 |
"retrieve a color resource - also acquire a device color |
243 | 212 |
to avoid repeated color allocations later" |
213 |
||
6920 | 214 |
|value device deviceColor| |
215 |
||
216 |
device := Display. |
|
217 |
||
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
218 |
value := self at:key default:default for: class. |
6920 | 219 |
value isInteger ifTrue:[ |
220 |
value := Color rgbValue:value |
|
221 |
]. |
|
222 |
(value notNil and:[device notNil]) ifTrue:[ |
|
223 |
deviceColor := value onDevice:device. |
|
224 |
deviceColor notNil ifTrue:[^ deviceColor]. |
|
225 |
]. |
|
226 |
^ value |
|
243 | 227 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
228 |
"Created: / 19-07-2016 / 21:32:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
229 |
"Modified: / 19-07-2016 / 22:40:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
78 | 230 |
! |
231 |
||
243 | 232 |
doesNotUnderstand:aMessage |
233 |
^ self at:(aMessage selector) default:nil |
|
78 | 234 |
! |
235 |
||
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
236 |
fontAt:key |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
237 |
^ self fontAt: key default: nil for: thisContext sender receiver. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
238 |
! |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
239 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
240 |
fontAt:key default:default |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
241 |
^ self fontAt:key default:default for: thisContext sender receiver |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
242 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
243 |
"Modified: / 19-07-2016 / 22:42:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
244 |
! |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
245 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
246 |
fontAt:key default:default for: class |
7402 | 247 |
"retrieve a font resource - also acquire a device font |
243 | 248 |
to avoid repeated font allocations later" |
78 | 249 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
250 |
^ self deviceResourceAt:key default:default for: class |
78 | 251 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
252 |
"Created: / 19-07-2016 / 22:42:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
78 | 253 |
! |
254 |
||
72 | 255 |
is3D |
256 |
is3D isNil ifTrue:[ |
|
257 |
is3D := self at:#is3D default:false. |
|
53 | 258 |
]. |
72 | 259 |
^ is3D |
53 | 260 |
! |
261 |
||
72 | 262 |
name |
263 |
name isNil ifTrue:[ |
|
264 |
name := self at:#name default:'noname'. |
|
53 | 265 |
]. |
72 | 266 |
^ name |
2775 | 267 |
! |
268 |
||
269 |
viewGrey |
|
270 |
viewGrey isNil ifTrue:[ |
|
271 |
viewGrey := self at:#viewGrey default:nil. |
|
272 |
]. |
|
273 |
^ viewGrey |
|
243 | 274 |
! ! |
53 | 275 |
|
1894
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
276 |
!ViewStyle methodsFor:'error handling'! |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
277 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
278 |
nonexistingFileRead |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
279 |
"here, a non-existing stylesheet is treated as an error" |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
280 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
281 |
fileReadFailed := true. |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
282 |
^ self |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
283 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
284 |
"Created: 6.9.1997 / 11:40:16 / cg" |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
285 |
! ! |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
286 |
|
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
287 |
!ViewStyle methodsFor:'private'! |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
288 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
289 |
deviceResourceAt:key default:default for: class |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
290 |
"retrieve a resource - also acquire a device version |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
291 |
for the default display, to avoid repeated allocations later" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
292 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
293 |
|aResource deviceResource device| |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
294 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
295 |
device := Display. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
296 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
297 |
aResource := self at:key default:default for: class. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
298 |
(aResource notNil and:[device notNil]) ifTrue:[ |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
299 |
deviceResource := aResource onDevice:device. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
300 |
deviceResource notNil ifTrue:[^ deviceResource]. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
301 |
]. |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
302 |
^ aResource |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
303 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
304 |
"Created: / 19-07-2016 / 22:41:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
305 |
! ! |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
306 |
|
3678 | 307 |
!ViewStyle methodsFor:'queries'! |
308 |
||
309 |
isWindowsStyle |
|
310 |
"answer true if this is a MS-Windows style. |
|
311 |
XXX Currently we simply check the name" |
|
312 |
||
5054 | 313 |
|nm| |
314 |
||
315 |
nm := name ? self name. |
|
3678 | 316 |
|
5054 | 317 |
^ nm == #win95 |
318 |
or:[nm == #win98 |
|
319 |
or:[nm == #winXP |
|
320 |
or:[nm == #winVista ]]] |
|
4730 | 321 |
! |
322 |
||
5052
23a19186c25d
changed #isWindowsVistaStyle
Claus Gittinger <cg@exept.de>
parents:
4730
diff
changeset
|
323 |
isWindowsVistaStyle |
7686 | 324 |
^ (name ? self name) == #winVista |
5052
23a19186c25d
changed #isWindowsVistaStyle
Claus Gittinger <cg@exept.de>
parents:
4730
diff
changeset
|
325 |
|
7686 | 326 |
"Modified (format): / 19-11-2016 / 15:49:48 / cg" |
5052
23a19186c25d
changed #isWindowsVistaStyle
Claus Gittinger <cg@exept.de>
parents:
4730
diff
changeset
|
327 |
! |
23a19186c25d
changed #isWindowsVistaStyle
Claus Gittinger <cg@exept.de>
parents:
4730
diff
changeset
|
328 |
|
4730 | 329 |
isWindowsXPStyle |
330 |
"answer true if this is a MS-Windows-XP (or later) style. |
|
331 |
XXX Currently we simply check the name" |
|
332 |
||
5054 | 333 |
|nm| |
4730 | 334 |
|
5054 | 335 |
nm := name ? self name. |
336 |
||
337 |
^ nm == #winXP |
|
338 |
or:[nm == #winVista] |
|
3678 | 339 |
! ! |
340 |
||
3069 | 341 |
!ViewStyle methodsFor:'special'! |
342 |
||
343 |
newDerivedStyle |
|
344 |
"create and return a new style, which inherits from |
|
345 |
the receiver, but possibly overrides individual entries. |
|
346 |
This may be useful to give a single button some different |
|
347 |
look (in the future - read the comment in SimpleView>>viewStyle:)" |
|
348 |
||
349 |
^ self class new |
|
350 |
superPack:self; |
|
351 |
at:#is3D put:(self is3D); |
|
352 |
at:viewGrey put:(self viewGrey); |
|
353 |
yourself |
|
354 |
||
355 |
" |
|
356 |
|panel b1 b2 newStyle| |
|
357 |
||
358 |
panel := HorizontalPanelView new. |
|
359 |
panel add:(b1 := Button label:'oldStyle'). |
|
360 |
panel add:(b2 := Button label:'newStyle'). |
|
361 |
newStyle := b1 styleSheet newDerivedStyle. |
|
362 |
newStyle at:'button.activeBackgroundColor' put:Color blue. |
|
363 |
b2 styleSheet:newStyle. |
|
364 |
||
365 |
panel open |
|
366 |
" |
|
367 |
! ! |
|
368 |
||
253 | 369 |
!ViewStyle class methodsFor:'documentation'! |
370 |
||
371 |
version |
|
6920 | 372 |
^ '$Header$' |
5531 | 373 |
! |
374 |
||
375 |
version_CVS |
|
6920 | 376 |
^ '$Header$' |
7540
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
377 |
! |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
378 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
379 |
version_HG |
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
380 |
|
69b0ea8c4b30
ViewStyle: unified style resource lookup
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7402
diff
changeset
|
381 |
^ '$Changeset: <not expanded> $' |
253 | 382 |
! ! |
6920 | 383 |