author | Claus Gittinger <cg@exept.de> |
Fri, 11 Jul 2008 21:40:24 +0200 | |
changeset 3474 | cde8a45f74f0 |
parent 3473 | 6bc7203cb7b7 |
child 3546 | b3269a9dec19 |
permissions | -rw-r--r-- |
3318 | 1 |
" |
2 |
COPYRIGHT (c) 2007 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
3251 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
14 |
SimpleView subclass:#FilenameWidgetWithHistory |
|
15 |
instanceVariableNames:'fileNameEntryField browseButton history' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Interactors' |
|
19 |
! |
|
20 |
||
21 |
!FilenameWidgetWithHistory class methodsFor:'documentation'! |
|
22 |
||
3318 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 2007 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
3471 | 37 |
documentation |
38 |
" |
|
39 |
A Filename InputField with history-list and a browse-button, which opens a file dialog. |
|
40 |
||
41 |
[author:] |
|
42 |
Claus Gittinger |
|
43 |
||
44 |
[see also:] |
|
45 |
ComboBoxView |
|
46 |
FilenameEditField |
|
47 |
FilenameComboBoxView |
|
48 |
" |
|
49 |
! |
|
50 |
||
3251 | 51 |
examples |
52 |
" |
|
53 |
[exBegin] |
|
54 |
|top b| |
|
55 |
||
56 |
top := StandardSystemView new. |
|
57 |
top extent:(300 @ 200). |
|
58 |
||
59 |
b := FilenameWidgetWithHistory in:top. |
|
60 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
61 |
b bottomInset:(b preferredExtent y negated). |
|
62 |
||
63 |
top open. |
|
64 |
[exEnd] |
|
65 |
" |
|
66 |
! ! |
|
67 |
||
68 |
!FilenameWidgetWithHistory methodsFor:'accessing'! |
|
69 |
||
70 |
historyList |
|
3474 | 71 |
history isNil ifTrue:[ |
72 |
history := nil asValue |
|
73 |
]. |
|
74 |
^ history |
|
3251 | 75 |
! |
76 |
||
77 |
model |
|
78 |
^ fileNameEntryField model |
|
79 |
! |
|
80 |
||
81 |
model:aFilenameHolder |
|
82 |
fileNameEntryField model:aFilenameHolder. |
|
83 |
! ! |
|
84 |
||
3472 | 85 |
!FilenameWidgetWithHistory methodsFor:'accessing - editField attributes'! |
86 |
||
87 |
acceptIfUnchanged:aBoolean |
|
88 |
fileNameEntryField acceptIfUnchanged:aBoolean |
|
89 |
! |
|
90 |
||
91 |
acceptOnLeave:aBoolean |
|
92 |
fileNameEntryField acceptOnLeave:aBoolean |
|
93 |
! |
|
94 |
||
95 |
acceptOnLostFocus:aBoolean |
|
96 |
fileNameEntryField acceptOnLostFocus:aBoolean |
|
97 |
! |
|
98 |
||
99 |
acceptOnPointerLeave:aBoolean |
|
100 |
fileNameEntryField acceptOnPointerLeave:aBoolean |
|
101 |
! |
|
102 |
||
103 |
acceptOnReturn:aBoolean |
|
104 |
fileNameEntryField acceptOnReturn:aBoolean |
|
105 |
! |
|
106 |
||
107 |
acceptOnTab:aBoolean |
|
108 |
fileNameEntryField acceptOnTab:aBoolean |
|
109 |
! |
|
110 |
||
111 |
contents:aString |
|
112 |
fileNameEntryField contents:aString |
|
113 |
! |
|
114 |
||
115 |
immediateAccept:aBoolean |
|
116 |
fileNameEntryField immediateAccept:aBoolean |
|
117 |
! |
|
118 |
||
119 |
maxChars:aBoolean |
|
120 |
fileNameEntryField maxChars:aBoolean |
|
121 |
! |
|
122 |
||
123 |
readOnly:aBoolean |
|
124 |
fileNameEntryField readOnly:aBoolean |
|
125 |
! ! |
|
126 |
||
3251 | 127 |
!FilenameWidgetWithHistory methodsFor:'initialization'! |
128 |
||
129 |
initialize |
|
130 |
super initialize. |
|
131 |
||
132 |
fileNameEntryField := FilenameComboBoxView in:self. |
|
133 |
fileNameEntryField layout:(LayoutFrame |
|
134 |
leftFraction:0 offset:0 |
|
135 |
rightFraction:1 offset:-22 |
|
136 |
topFraction:0 offset:0 |
|
137 |
bottomFraction:1 offset:0). |
|
138 |
fileNameEntryField listHolder:(self historyList). |
|
139 |
||
140 |
browseButton := Button in:self. |
|
141 |
browseButton label:'...'. |
|
142 |
browseButton action:[self browseForDestinationDirectory]. |
|
143 |
browseButton layout:(LayoutFrame |
|
144 |
leftFraction:1 offset:-22 |
|
145 |
rightFraction:1 offset:-2 |
|
146 |
topFraction:0 offset:0 |
|
147 |
bottomFraction:1 offset:0). |
|
148 |
! ! |
|
149 |
||
150 |
!FilenameWidgetWithHistory methodsFor:'queries'! |
|
151 |
||
152 |
preferredExtent |
|
153 |
preferredExtent notNil ifTrue:[ |
|
154 |
^ preferredExtent |
|
155 |
]. |
|
156 |
||
3427
9927e4970fce
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3318
diff
changeset
|
157 |
preferredExtent := (fileNameEntryField preferredWidth + browseButton preferredWidth) |
3251 | 158 |
@ |
3427
9927e4970fce
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3318
diff
changeset
|
159 |
(fileNameEntryField preferredHeight "max: browseButton preferredExtent y"). |
3251 | 160 |
^ preferredExtent |
161 |
! ! |
|
162 |
||
163 |
!FilenameWidgetWithHistory methodsFor:'user actions'! |
|
164 |
||
165 |
browseForDestinationDirectory |
|
166 |
|dir| |
|
167 |
||
168 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
169 |
|dialog| |
|
170 |
||
171 |
dialog := ex parameter. |
|
172 |
dialog perform:#browseVisibleHolder with:true ifNotUnderstood:[]. |
|
173 |
ex proceed. |
|
174 |
] do:[ |
|
175 |
dir := Dialog |
|
176 |
requestDirectoryName:'Destination Directory' |
|
177 |
default:(self model value ? '.' asFilename pathName). |
|
178 |
]. |
|
179 |
dir isEmptyOrNil ifTrue:[ ^ self ]. |
|
180 |
||
181 |
self model value:dir. |
|
182 |
||
183 |
"Modified: / 02-10-2006 / 14:45:54 / cg" |
|
184 |
! ! |
|
185 |
||
186 |
!FilenameWidgetWithHistory class methodsFor:'documentation'! |
|
187 |
||
188 |
version |
|
3474 | 189 |
^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.7 2008-07-11 19:40:24 cg Exp $' |
3251 | 190 |
! ! |