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
|
72
|
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.
|
53
|
43 |
"
|
|
44 |
! !
|
|
45 |
|
|
46 |
!ViewStyle class methodsFor:'instance creation'!
|
|
47 |
|
|
48 |
fromFile:aFileName
|
|
49 |
"get the preferences definitions from a file"
|
|
50 |
|
153
|
51 |
|prefs failed nm|
|
53
|
52 |
|
72
|
53 |
prefs := self new.
|
|
54 |
(aFileName endsWith:'.style') ifTrue:[
|
153
|
55 |
nm := aFileName copyWithoutLast:6
|
72
|
56 |
] ifFalse:[
|
153
|
57 |
nm := aFileName
|
72
|
58 |
].
|
153
|
59 |
prefs at:#name put:nm.
|
|
60 |
|
|
61 |
failed := (prefs readFromFile:aFileName directory:'resources') isNil.
|
|
62 |
prefs at:#fileReadFailed put:failed.
|
53
|
63 |
^ prefs
|
|
64 |
|
72
|
65 |
"
|
|
66 |
ViewStyle fromFile:'motif.style'
|
|
67 |
ViewStyle fromFile:'normal.style'
|
|
68 |
ViewStyle fromFile:'iris.style'
|
|
69 |
"
|
53
|
70 |
! !
|
|
71 |
|
|
72 |
!ViewStyle methodsFor:'accessing'!
|
|
73 |
|
243
|
74 |
at:aKey
|
|
75 |
|sCls val|
|
|
76 |
|
|
77 |
sCls := thisContext sender receiver.
|
|
78 |
sCls isBehavior ifFalse:[sCls := sCls class].
|
|
79 |
(sCls isSubclassOf:SimpleView) ifTrue:[
|
|
80 |
val := self at:(sCls name , '.' , aKey) default:nil.
|
|
81 |
val notNil ifTrue:[^ val].
|
|
82 |
].
|
|
83 |
^ self at:aKey default:nil
|
|
84 |
|
|
85 |
"Modified: 10.9.1995 / 10:59:38 / claus"
|
|
86 |
!
|
|
87 |
|
|
88 |
colorAt:aKey
|
|
89 |
"retrieve a color resource - also aquire a device color
|
|
90 |
to avoid repeated color allocations later"
|
|
91 |
|
|
92 |
^ self deviceResourceAt:aKey default:nil
|
|
93 |
!
|
|
94 |
|
|
95 |
colorAt:aKey default:default
|
|
96 |
"retrieve a color resource - also aquire a device color
|
|
97 |
to avoid repeated color allocations later"
|
|
98 |
|
|
99 |
^ self deviceResourceAt:aKey default:default
|
|
100 |
!
|
|
101 |
|
78
|
102 |
deviceResourceAt:aKey default:default
|
|
103 |
"retrieve a resource - also aquire a device version
|
|
104 |
to avoid repeated allocations later"
|
|
105 |
|
228
|
106 |
|aResource deviceResource device|
|
78
|
107 |
|
228
|
108 |
device := Screen current.
|
78
|
109 |
aResource := self at:aKey default:default.
|
228
|
110 |
aResource isNil ifTrue:[
|
|
111 |
aResource := default
|
|
112 |
].
|
78
|
113 |
aResource notNil ifTrue:[
|
228
|
114 |
deviceResource := aResource on:device.
|
|
115 |
].
|
|
116 |
deviceResource notNil ifTrue:[
|
|
117 |
^ deviceResource
|
78
|
118 |
].
|
|
119 |
^ nil
|
|
120 |
!
|
|
121 |
|
243
|
122 |
doesNotUnderstand:aMessage
|
|
123 |
^ self at:(aMessage selector) default:nil
|
78
|
124 |
!
|
|
125 |
|
243
|
126 |
fontAt:aKey
|
|
127 |
"retrieve a font resource - also aquire a device font
|
|
128 |
to avoid repeated font allocations later"
|
78
|
129 |
|
|
130 |
^ self deviceResourceAt:aKey default:nil
|
|
131 |
!
|
|
132 |
|
|
133 |
fontAt:aKey default:default
|
|
134 |
"retrieve a font resource - also aquire a device font
|
|
135 |
to avoid repeated font allocations later"
|
|
136 |
|
|
137 |
^ self deviceResourceAt:aKey default:default
|
|
138 |
!
|
|
139 |
|
72
|
140 |
is3D
|
|
141 |
is3D isNil ifTrue:[
|
|
142 |
is3D := self at:#is3D default:false.
|
53
|
143 |
].
|
72
|
144 |
^ is3D
|
53
|
145 |
!
|
|
146 |
|
72
|
147 |
name
|
|
148 |
name isNil ifTrue:[
|
|
149 |
name := self at:#name default:'noname'.
|
53
|
150 |
].
|
72
|
151 |
^ name
|
243
|
152 |
! !
|
53
|
153 |
|
253
|
154 |
!ViewStyle class methodsFor:'documentation'!
|
|
155 |
|
|
156 |
version
|
|
157 |
^ '$Header: /cvs/stx/stx/libview/ViewStyle.st,v 1.9 1995-11-23 18:08:48 cg Exp $'
|
|
158 |
! !
|