support new viewStyle resource name format
authorClaus Gittinger <cg@exept.de>
Wed, 15 Oct 1997 13:34:27 +0200
changeset 1925 e4d67cc4f082
parent 1924 5d09bd2ff0c7
child 1926 e0966ecc8766
support new viewStyle resource name format (backward compatible)
ViewStyle.st
--- a/ViewStyle.st	Wed Oct 15 13:29:43 1997 +0200
+++ b/ViewStyle.st	Wed Oct 15 13:34:27 1997 +0200
@@ -10,6 +10,8 @@
  hereby transferred.
 "
 
+'From Smalltalk/X, Version:3.2.1 on 14-oct-1997 at 11:22:01 pm'                 !
+
 ResourcePack subclass:#ViewStyle
 	instanceVariableNames:'name is3D'
 	classVariableNames:''
@@ -92,6 +94,26 @@
     "Modified: 10.9.1995 / 10:59:38 / claus"
 !
 
+at:aKey default:default
+    "translate a string; if not present, return default.
+     Here, two keys are tried, iff the key is of the form 'foo.bar',
+     'fooBar' is also tried.
+     This has been added for a smooth migration towards names with a form of
+     'classname.itemKey' in the stylesheets."
+
+    |v i k2|
+
+    (self includesKey:aKey) ifTrue:[^ super at:aKey ifAbsent:default].
+    (i := aKey indexOf:$.) ~~ 0 ifTrue:[
+        k2 := (aKey copyTo:i-1) , (aKey copyFrom:i+1) asUppercaseFirst.
+        (self includesKey:k2) ifTrue:[^ super at:k2 ifAbsent:default].
+    ].
+    ^ default
+
+    "Created: 14.10.1997 / 00:21:15 / cg"
+    "Modified: 14.10.1997 / 00:26:48 / cg"
+!
+
 colorAt:aKey
     "retrieve a color resource - also aquire a device color
      to avoid repeated color allocations later"
@@ -176,5 +198,5 @@
 !ViewStyle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ViewStyle.st,v 1.13 1997-09-06 17:31:59 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ViewStyle.st,v 1.14 1997-10-15 11:34:27 cg Exp $'
 ! !