author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 16:54:10 +0100 | |
changeset 219 | 9ff0660f447f |
parent 182 | b5f7fdff0f6d |
child 228 | 2dbfa10f87d4 |
permissions | -rw-r--r-- |
53 | 1 |
" |
2 |
COPYRIGHT (c) 1994 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 |
||
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 |
version |
|
219
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
182
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libview/ViewStyle.st,v 1.6 1995-11-11 15:53:18 cg Exp $' |
53 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
instances of this class keep all view-style specific information. |
|
72 | 43 |
The current viewStyle is kept in Views-classvariable called 'StyleSheet' |
44 |
and is instantiated with 'View defaultStyle:aStyleSymbol', which reads |
|
45 |
a stylesheet from a file '<aStyleSymbol>.style' (usually in the 'resources' |
|
46 |
directory. |
|
53 | 47 |
" |
48 |
! ! |
|
49 |
||
50 |
!ViewStyle class methodsFor:'instance creation'! |
|
51 |
||
52 |
fromFile:aFileName |
|
53 |
"get the preferences definitions from a file" |
|
54 |
||
153 | 55 |
|prefs failed nm| |
53 | 56 |
|
72 | 57 |
prefs := self new. |
58 |
(aFileName endsWith:'.style') ifTrue:[ |
|
153 | 59 |
nm := aFileName copyWithoutLast:6 |
72 | 60 |
] ifFalse:[ |
153 | 61 |
nm := aFileName |
72 | 62 |
]. |
153 | 63 |
prefs at:#name put:nm. |
64 |
||
65 |
failed := (prefs readFromFile:aFileName directory:'resources') isNil. |
|
66 |
prefs at:#fileReadFailed put:failed. |
|
53 | 67 |
^ prefs |
68 |
||
72 | 69 |
" |
70 |
ViewStyle fromFile:'motif.style' |
|
71 |
ViewStyle fromFile:'normal.style' |
|
72 |
ViewStyle fromFile:'iris.style' |
|
73 |
" |
|
53 | 74 |
! ! |
75 |
||
76 |
!ViewStyle methodsFor:'accessing'! |
|
77 |
||
78 | 78 |
deviceResourceAt:aKey default:default |
79 |
"retrieve a resource - also aquire a device version |
|
80 |
to avoid repeated allocations later" |
|
81 |
||
82 |
|aResource| |
|
83 |
||
84 |
aResource := self at:aKey default:default. |
|
85 |
aResource notNil ifTrue:[ |
|
153 | 86 |
^ aResource on:Screen current |
78 | 87 |
]. |
88 |
^ nil |
|
89 |
! |
|
90 |
||
91 |
colorAt:aKey default:default |
|
92 |
"retrieve a color resource - also aquire a device color |
|
93 |
to avoid repeated color allocations later" |
|
94 |
||
95 |
^ self deviceResourceAt:aKey default:default |
|
96 |
! |
|
97 |
||
98 |
colorAt:aKey |
|
99 |
"retrieve a color resource - also aquire a device color |
|
100 |
to avoid repeated color allocations later" |
|
101 |
||
102 |
^ self deviceResourceAt:aKey default:nil |
|
103 |
! |
|
104 |
||
105 |
fontAt:aKey default:default |
|
106 |
"retrieve a font resource - also aquire a device font |
|
107 |
to avoid repeated font allocations later" |
|
108 |
||
109 |
^ self deviceResourceAt:aKey default:default |
|
110 |
! |
|
111 |
||
112 |
fontAt:aKey |
|
113 |
"retrieve a font resource - also aquire a device font |
|
114 |
to avoid repeated font allocations later" |
|
115 |
||
116 |
^ self deviceResourceAt:aKey default:nil |
|
117 |
! |
|
118 |
||
72 | 119 |
at:aKey |
182 | 120 |
|sCls val| |
121 |
||
122 |
sCls := thisContext sender receiver. |
|
123 |
sCls isBehavior ifFalse:[sCls := sCls class]. |
|
124 |
(sCls isSubclassOf:SimpleView) ifTrue:[ |
|
125 |
val := self at:(sCls name , '.' , aKey) default:nil. |
|
126 |
val notNil ifTrue:[^ val]. |
|
127 |
]. |
|
72 | 128 |
^ self at:aKey default:nil |
182 | 129 |
|
130 |
"Modified: 10.9.1995 / 10:59:38 / claus" |
|
53 | 131 |
! |
132 |
||
72 | 133 |
is3D |
134 |
is3D isNil ifTrue:[ |
|
135 |
is3D := self at:#is3D default:false. |
|
53 | 136 |
]. |
72 | 137 |
^ is3D |
53 | 138 |
! |
139 |
||
72 | 140 |
name |
141 |
name isNil ifTrue:[ |
|
142 |
name := self at:#name default:'noname'. |
|
53 | 143 |
]. |
72 | 144 |
^ name |
53 | 145 |
! |
146 |
||
147 |
doesNotUnderstand:aMessage |
|
72 | 148 |
^ self at:(aMessage selector) default:nil |
53 | 149 |
! ! |