.
authorclaus
Thu, 07 Sep 1995 14:48:20 +0200
changeset 72 f17df5ea35ed
parent 71 9f9243f5813b
child 73 2ee590cb9714
.
FNmEdtFld.st
FNmEntrBox.st
FilenameEditField.st
FilenameEnterBox.st
ImageSelBox.st
ImageSelectionBox.st
Separator.st
--- a/FNmEdtFld.st	Wed Aug 30 20:06:56 1995 +0200
+++ b/FNmEdtFld.st	Thu Sep 07 14:48:20 1995 +0200
@@ -11,7 +11,7 @@
 "
 
 EditField subclass:#FilenameEditField 
-       instanceVariableNames:'directoriesOnly filesOnly'
+       instanceVariableNames:'directoriesOnly filesOnly directory'
        classVariableNames:   ''
        poolDictionaries:''
        category:'Views-Text'
@@ -35,7 +35,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg2/Attic/FNmEdtFld.st,v 1.13 1995-08-30 18:06:13 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/Attic/FNmEdtFld.st,v 1.14 1995-09-07 12:47:59 claus Exp $
 "
 !
 
@@ -48,23 +48,34 @@
 "
 ! !
 
-!FilenameEditField methodsFor:'initialization'!
+!FilenameEditField class methodsFor:'defaults'!
 
-initialize
-    super initialize.
-    directoriesOnly := filesOnly := false.
+filenameCompletionBlock 
+    "return a block which can be used for fileName completion.
+     This has been extracted into a separate method, to allow reuse of
+     this code (for example, for use with regular editFields ..)"
 
-    entryCompletionBlock := [
+    ^ [:field :inDirectory :directoriesOnly :filesOnly |
 	|s f matchSet nMatch name words dir|
 
-	s := self contents.
+	s := field contents.
 	"
 	 find the last word ...
 	"
 	words := s asCollectionOfWords.
 	f := words last asFilename.
+	f isAbsolute ifFalse:[
+	     inDirectory asString ~= '.' ifTrue:[
+		 f := (inDirectory name asFilename construct:f) name asFilename
+	     ].
+	].
+	f isAbsolute ifTrue:[
+	    f := f pathName asFilename.
+	].
+
 	matchSet := f filenameCompletion.
 	dir := f directory.
+
 	directoriesOnly ifTrue:[
 	    matchSet := matchSet select:[:aFilename |
 		(dir construct:aFilename) isDirectory
@@ -81,8 +92,9 @@
 	    "
 	     more than one possible completion -
 	    "
-	    self changed:#directory with:f directoryName.
-	    device beep
+	    field changed:#directory with:f directoryName.
+	    field flash.
+	    field device beep.
 	].
 	"
 	 even with more than one possible completion,
@@ -93,14 +105,15 @@
 	    "
 	     exactly one possible completion -
 	    "
-	    f := dir construct:matchSet first.
+"/            f := dir construct:matchSet first.
+	    f := matchSet first asFilename.
 
 	    directoriesOnly ifTrue:[
 		name := f asString
 	    ] ifFalse:[
 		f isDirectory ifTrue:[
 		    (name endsWith:(Filename separator)) ifFalse:[
-			name := (f construct:'') asString
+			name := f asString , '/'
 		    ].
 		].
 	    ]
@@ -114,9 +127,28 @@
 	    s := s , (words at:idx) , ' '
 	].
 	s := s , name.
-	self contents:s.
-	self cursorToEndOfLine.
+	field contents:s.
+	field cursorToEndOfLine.
     ].
+! !
+
+!FilenameEditField methodsFor:'initialization'!
+
+initialize
+    super initialize.
+    directoriesOnly := filesOnly := false.
+    directory := '.' asFilename.
+
+    entryCompletionBlock := [
+	self class 
+	    filenameCompletionBlock 
+		value:self 
+		value:directory
+		value:directoriesOnly
+		value:filesOnly
+    ].
+
+    "Modified: 7.9.1995 / 10:20:46 / claus"
 !
 
 realize
@@ -129,6 +161,34 @@
 
 !FilenameEditField methodsFor:'accessing'!
 
+directory
+    ^ directory
+
+    "Modified: 7.9.1995 / 10:12:40 / claus"
+!
+
+directory:aFilename
+    directory := aFilename asFilename
+
+    "Modified: 7.9.1995 / 10:12:55 / claus"
+!
+
+showsDirectoriesOnly
+    "return if expanding names for directories only"
+
+    ^ directoriesOnly
+
+    "Modified: 6.9.1995 / 20:35:30 / claus"
+!
+
+showsFilesOnly
+    "return if expanding names for files only"
+
+    ^ filesOnly
+
+    "Modified: 6.9.1995 / 20:34:57 / claus"
+!
+
 directoriesOnly
     "set to expand names for directories only"
 
--- a/FNmEntrBox.st	Wed Aug 30 20:06:56 1995 +0200
+++ b/FNmEntrBox.st	Thu Sep 07 14:48:20 1995 +0200
@@ -35,7 +35,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg2/Attic/FNmEntrBox.st,v 1.5 1995-08-30 18:06:15 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/Attic/FNmEntrBox.st,v 1.6 1995-09-07 12:48:02 claus Exp $
 "
 !
 
@@ -60,6 +60,14 @@
 
 !FilenameEnterBox methodsFor:'accessing'!
 
+directory:aFilename
+    "set the directory"
+
+    enterField directory:aFilename
+
+    "Modified: 7.9.1995 / 10:33:00 / claus"
+!
+
 directoriesOnly
     "set to expand names for directories only"
 
--- a/FilenameEditField.st	Wed Aug 30 20:06:56 1995 +0200
+++ b/FilenameEditField.st	Thu Sep 07 14:48:20 1995 +0200
@@ -11,7 +11,7 @@
 "
 
 EditField subclass:#FilenameEditField 
-       instanceVariableNames:'directoriesOnly filesOnly'
+       instanceVariableNames:'directoriesOnly filesOnly directory'
        classVariableNames:   ''
        poolDictionaries:''
        category:'Views-Text'
@@ -35,7 +35,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg2/FilenameEditField.st,v 1.13 1995-08-30 18:06:13 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/FilenameEditField.st,v 1.14 1995-09-07 12:47:59 claus Exp $
 "
 !
 
@@ -48,23 +48,34 @@
 "
 ! !
 
-!FilenameEditField methodsFor:'initialization'!
+!FilenameEditField class methodsFor:'defaults'!
 
-initialize
-    super initialize.
-    directoriesOnly := filesOnly := false.
+filenameCompletionBlock 
+    "return a block which can be used for fileName completion.
+     This has been extracted into a separate method, to allow reuse of
+     this code (for example, for use with regular editFields ..)"
 
-    entryCompletionBlock := [
+    ^ [:field :inDirectory :directoriesOnly :filesOnly |
 	|s f matchSet nMatch name words dir|
 
-	s := self contents.
+	s := field contents.
 	"
 	 find the last word ...
 	"
 	words := s asCollectionOfWords.
 	f := words last asFilename.
+	f isAbsolute ifFalse:[
+	     inDirectory asString ~= '.' ifTrue:[
+		 f := (inDirectory name asFilename construct:f) name asFilename
+	     ].
+	].
+	f isAbsolute ifTrue:[
+	    f := f pathName asFilename.
+	].
+
 	matchSet := f filenameCompletion.
 	dir := f directory.
+
 	directoriesOnly ifTrue:[
 	    matchSet := matchSet select:[:aFilename |
 		(dir construct:aFilename) isDirectory
@@ -81,8 +92,9 @@
 	    "
 	     more than one possible completion -
 	    "
-	    self changed:#directory with:f directoryName.
-	    device beep
+	    field changed:#directory with:f directoryName.
+	    field flash.
+	    field device beep.
 	].
 	"
 	 even with more than one possible completion,
@@ -93,14 +105,15 @@
 	    "
 	     exactly one possible completion -
 	    "
-	    f := dir construct:matchSet first.
+"/            f := dir construct:matchSet first.
+	    f := matchSet first asFilename.
 
 	    directoriesOnly ifTrue:[
 		name := f asString
 	    ] ifFalse:[
 		f isDirectory ifTrue:[
 		    (name endsWith:(Filename separator)) ifFalse:[
-			name := (f construct:'') asString
+			name := f asString , '/'
 		    ].
 		].
 	    ]
@@ -114,9 +127,28 @@
 	    s := s , (words at:idx) , ' '
 	].
 	s := s , name.
-	self contents:s.
-	self cursorToEndOfLine.
+	field contents:s.
+	field cursorToEndOfLine.
     ].
+! !
+
+!FilenameEditField methodsFor:'initialization'!
+
+initialize
+    super initialize.
+    directoriesOnly := filesOnly := false.
+    directory := '.' asFilename.
+
+    entryCompletionBlock := [
+	self class 
+	    filenameCompletionBlock 
+		value:self 
+		value:directory
+		value:directoriesOnly
+		value:filesOnly
+    ].
+
+    "Modified: 7.9.1995 / 10:20:46 / claus"
 !
 
 realize
@@ -129,6 +161,34 @@
 
 !FilenameEditField methodsFor:'accessing'!
 
+directory
+    ^ directory
+
+    "Modified: 7.9.1995 / 10:12:40 / claus"
+!
+
+directory:aFilename
+    directory := aFilename asFilename
+
+    "Modified: 7.9.1995 / 10:12:55 / claus"
+!
+
+showsDirectoriesOnly
+    "return if expanding names for directories only"
+
+    ^ directoriesOnly
+
+    "Modified: 6.9.1995 / 20:35:30 / claus"
+!
+
+showsFilesOnly
+    "return if expanding names for files only"
+
+    ^ filesOnly
+
+    "Modified: 6.9.1995 / 20:34:57 / claus"
+!
+
 directoriesOnly
     "set to expand names for directories only"
 
--- a/FilenameEnterBox.st	Wed Aug 30 20:06:56 1995 +0200
+++ b/FilenameEnterBox.st	Thu Sep 07 14:48:20 1995 +0200
@@ -35,7 +35,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg2/FilenameEnterBox.st,v 1.5 1995-08-30 18:06:15 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/FilenameEnterBox.st,v 1.6 1995-09-07 12:48:02 claus Exp $
 "
 !
 
@@ -60,6 +60,14 @@
 
 !FilenameEnterBox methodsFor:'accessing'!
 
+directory:aFilename
+    "set the directory"
+
+    enterField directory:aFilename
+
+    "Modified: 7.9.1995 / 10:33:00 / claus"
+!
+
 directoriesOnly
     "set to expand names for directories only"
 
--- a/ImageSelBox.st	Wed Aug 30 20:06:56 1995 +0200
+++ b/ImageSelBox.st	Thu Sep 07 14:48:20 1995 +0200
@@ -76,9 +76,11 @@
 	    self topView withWaitCursorDo:[
 		image := Image fromFile:fileNameString.
 		image notNil ifTrue:[
-		    info label:'Size: ' ,
-			       (image width printString , ' x ' , image height printString),
-			       ' Depth: ' , image depth printString.
+		    info label:(resources string:'Size: %1 x %2' 
+					  with:image width printString
+					  with:image height printString),
+			       (resources string:' Depth: %1' 
+					    with:image depth printString).
 
 		    (image width <= 64 and:[image height <= 64]) ifFalse:[
 			image := image magnifiedPreservingRatioTo:64@64.
@@ -122,7 +124,7 @@
 
     super initialize.
 
-    label := 'Image dialog'.
+    label := (resources string:'Image dialog').
     labelField label:(resources string:'select an image file:').
 
     prefY := buttonPanel preferredExtent y.
--- a/ImageSelectionBox.st	Wed Aug 30 20:06:56 1995 +0200
+++ b/ImageSelectionBox.st	Thu Sep 07 14:48:20 1995 +0200
@@ -76,9 +76,11 @@
 	    self topView withWaitCursorDo:[
 		image := Image fromFile:fileNameString.
 		image notNil ifTrue:[
-		    info label:'Size: ' ,
-			       (image width printString , ' x ' , image height printString),
-			       ' Depth: ' , image depth printString.
+		    info label:(resources string:'Size: %1 x %2' 
+					  with:image width printString
+					  with:image height printString),
+			       (resources string:' Depth: %1' 
+					    with:image depth printString).
 
 		    (image width <= 64 and:[image height <= 64]) ifFalse:[
 			image := image magnifiedPreservingRatioTo:64@64.
@@ -122,7 +124,7 @@
 
     super initialize.
 
-    label := 'Image dialog'.
+    label := (resources string:'Image dialog').
     labelField label:(resources string:'select an image file:').
 
     prefY := buttonPanel preferredExtent y.
--- a/Separator.st	Wed Aug 30 20:06:56 1995 +0200
+++ b/Separator.st	Thu Sep 07 14:48:20 1995 +0200
@@ -129,7 +129,7 @@
 
 version 
 "
-$Header: /cvs/stx/stx/libwidg2/Separator.st,v 1.4 1995-08-30 18:06:41 claus Exp $
+$Header: /cvs/stx/stx/libwidg2/Separator.st,v 1.5 1995-09-07 12:48:20 claus Exp $
 "
 !
 
@@ -172,6 +172,12 @@
 
 !Separator methodsFor:'accessing'!
 
+orientation
+    "return the orientation (one of #horizontal or #vertical)"
+
+    ^ orientation
+!
+
 orientation:aSymbol
     "set the orientation to one of #horizontal or #vertical"