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 |
"
|
|
12 |
|
243
|
13 |
ResourcePack subclass:#ViewStyle
|
617
|
14 |
instanceVariableNames:'name is3D'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Support'
|
53
|
18 |
!
|
|
19 |
|
|
20 |
!ViewStyle class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
25 |
All Rights Reserved
|
53
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
documentation
|
|
37 |
"
|
|
38 |
instances of this class keep all view-style specific information.
|
72
|
39 |
The current viewStyle is kept in Views-classvariable called 'StyleSheet'
|
|
40 |
and is instantiated with 'View defaultStyle:aStyleSymbol', which reads
|
|
41 |
a stylesheet from a file '<aStyleSymbol>.style' (usually in the 'resources'
|
|
42 |
directory.
|
617
|
43 |
|
|
44 |
[see also:]
|
|
45 |
View
|
|
46 |
( Configuration & Customization :html: custom/TOP.html#VIEWSTYLE )
|
|
47 |
|
|
48 |
[author:]
|
|
49 |
Claus Gittinger
|
53
|
50 |
"
|
|
51 |
! !
|
|
52 |
|
|
53 |
!ViewStyle class methodsFor:'instance creation'!
|
|
54 |
|
|
55 |
fromFile:aFileName
|
|
56 |
"get the preferences definitions from a file"
|
|
57 |
|
153
|
58 |
|prefs failed nm|
|
53
|
59 |
|
72
|
60 |
prefs := self new.
|
|
61 |
(aFileName endsWith:'.style') ifTrue:[
|
153
|
62 |
nm := aFileName copyWithoutLast:6
|
72
|
63 |
] ifFalse:[
|
153
|
64 |
nm := aFileName
|
72
|
65 |
].
|
153
|
66 |
prefs at:#name put:nm.
|
|
67 |
|
|
68 |
failed := (prefs readFromFile:aFileName directory:'resources') isNil.
|
|
69 |
prefs at:#fileReadFailed put:failed.
|
53
|
70 |
^ prefs
|
|
71 |
|
72
|
72 |
"
|
|
73 |
ViewStyle fromFile:'motif.style'
|
|
74 |
ViewStyle fromFile:'normal.style'
|
|
75 |
ViewStyle fromFile:'iris.style'
|
|
76 |
"
|
53
|
77 |
! !
|
|
78 |
|
|
79 |
!ViewStyle methodsFor:'accessing'!
|
|
80 |
|
243
|
81 |
at:aKey
|
|
82 |
|sCls val|
|
|
83 |
|
|
84 |
sCls := thisContext sender receiver.
|
|
85 |
sCls isBehavior ifFalse:[sCls := sCls class].
|
|
86 |
(sCls isSubclassOf:SimpleView) ifTrue:[
|
|
87 |
val := self at:(sCls name , '.' , aKey) default:nil.
|
|
88 |
val notNil ifTrue:[^ val].
|
|
89 |
].
|
|
90 |
^ self at:aKey default:nil
|
|
91 |
|
|
92 |
"Modified: 10.9.1995 / 10:59:38 / claus"
|
|
93 |
!
|
|
94 |
|
|
95 |
colorAt:aKey
|
|
96 |
"retrieve a color resource - also aquire a device color
|
|
97 |
to avoid repeated color allocations later"
|
|
98 |
|
|
99 |
^ self deviceResourceAt:aKey default:nil
|
|
100 |
!
|
|
101 |
|
|
102 |
colorAt:aKey default:default
|
|
103 |
"retrieve a color resource - also aquire a device color
|
|
104 |
to avoid repeated color allocations later"
|
|
105 |
|
|
106 |
^ self deviceResourceAt:aKey default:default
|
|
107 |
!
|
|
108 |
|
78
|
109 |
deviceResourceAt:aKey default:default
|
|
110 |
"retrieve a resource - also aquire a device version
|
1226
|
111 |
for the default display, to avoid repeated allocations later"
|
78
|
112 |
|
228
|
113 |
|aResource deviceResource device|
|
78
|
114 |
|
1226
|
115 |
device := Display.
|
78
|
116 |
aResource := self at:aKey default:default.
|
228
|
117 |
aResource isNil ifTrue:[
|
1226
|
118 |
aResource := default
|
228
|
119 |
].
|
78
|
120 |
aResource notNil ifTrue:[
|
1226
|
121 |
device notNil ifTrue:[
|
|
122 |
deviceResource := aResource on:device.
|
|
123 |
]
|
228
|
124 |
].
|
|
125 |
deviceResource notNil ifTrue:[
|
1226
|
126 |
^ deviceResource
|
78
|
127 |
].
|
1006
|
128 |
^ aResource
|
1226
|
129 |
|
|
130 |
"Modified: 16.1.1997 / 17:50:15 / cg"
|
78
|
131 |
!
|
|
132 |
|
243
|
133 |
doesNotUnderstand:aMessage
|
|
134 |
^ self at:(aMessage selector) default:nil
|
78
|
135 |
!
|
|
136 |
|
243
|
137 |
fontAt:aKey
|
|
138 |
"retrieve a font resource - also aquire a device font
|
|
139 |
to avoid repeated font allocations later"
|
78
|
140 |
|
|
141 |
^ self deviceResourceAt:aKey default:nil
|
|
142 |
!
|
|
143 |
|
|
144 |
fontAt:aKey default:default
|
|
145 |
"retrieve a font resource - also aquire a device font
|
|
146 |
to avoid repeated font allocations later"
|
|
147 |
|
|
148 |
^ self deviceResourceAt:aKey default:default
|
|
149 |
!
|
|
150 |
|
72
|
151 |
is3D
|
|
152 |
is3D isNil ifTrue:[
|
|
153 |
is3D := self at:#is3D default:false.
|
53
|
154 |
].
|
72
|
155 |
^ is3D
|
53
|
156 |
!
|
|
157 |
|
72
|
158 |
name
|
|
159 |
name isNil ifTrue:[
|
|
160 |
name := self at:#name default:'noname'.
|
53
|
161 |
].
|
72
|
162 |
^ name
|
243
|
163 |
! !
|
53
|
164 |
|
253
|
165 |
!ViewStyle class methodsFor:'documentation'!
|
|
166 |
|
|
167 |
version
|
1226
|
168 |
^ '$Header: /cvs/stx/stx/libview/ViewStyle.st,v 1.12 1997-01-16 16:50:21 cg Exp $'
|
253
|
169 |
! !
|