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