author | Claus Gittinger <cg@exept.de> |
Fri, 11 Jul 2008 17:30:38 +0200 | |
changeset 3471 | f3cde37d9d53 |
parent 3427 | 9927e4970fce |
child 3472 | 20087c3d9dda |
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 |
|
71 |
^ #('a' 'b' 'c') |
|
72 |
! |
|
73 |
||
74 |
model |
|
75 |
^ fileNameEntryField model |
|
76 |
! |
|
77 |
||
78 |
model:aFilenameHolder |
|
79 |
fileNameEntryField model:aFilenameHolder. |
|
80 |
! ! |
|
81 |
||
82 |
!FilenameWidgetWithHistory methodsFor:'initialization'! |
|
83 |
||
84 |
initialize |
|
85 |
super initialize. |
|
86 |
||
87 |
fileNameEntryField := FilenameComboBoxView in:self. |
|
88 |
fileNameEntryField layout:(LayoutFrame |
|
89 |
leftFraction:0 offset:0 |
|
90 |
rightFraction:1 offset:-22 |
|
91 |
topFraction:0 offset:0 |
|
92 |
bottomFraction:1 offset:0). |
|
93 |
fileNameEntryField listHolder:(self historyList). |
|
94 |
||
95 |
browseButton := Button in:self. |
|
96 |
browseButton label:'...'. |
|
97 |
browseButton action:[self browseForDestinationDirectory]. |
|
98 |
browseButton layout:(LayoutFrame |
|
99 |
leftFraction:1 offset:-22 |
|
100 |
rightFraction:1 offset:-2 |
|
101 |
topFraction:0 offset:0 |
|
102 |
bottomFraction:1 offset:0). |
|
103 |
! ! |
|
104 |
||
105 |
!FilenameWidgetWithHistory methodsFor:'queries'! |
|
106 |
||
107 |
preferredExtent |
|
108 |
preferredExtent notNil ifTrue:[ |
|
109 |
^ preferredExtent |
|
110 |
]. |
|
111 |
||
3427
9927e4970fce
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3318
diff
changeset
|
112 |
preferredExtent := (fileNameEntryField preferredWidth + browseButton preferredWidth) |
3251 | 113 |
@ |
3427
9927e4970fce
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3318
diff
changeset
|
114 |
(fileNameEntryField preferredHeight "max: browseButton preferredExtent y"). |
3251 | 115 |
^ preferredExtent |
116 |
! ! |
|
117 |
||
118 |
!FilenameWidgetWithHistory methodsFor:'user actions'! |
|
119 |
||
120 |
browseForDestinationDirectory |
|
121 |
|dir| |
|
122 |
||
123 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
124 |
|dialog| |
|
125 |
||
126 |
dialog := ex parameter. |
|
127 |
dialog perform:#browseVisibleHolder with:true ifNotUnderstood:[]. |
|
128 |
ex proceed. |
|
129 |
] do:[ |
|
130 |
dir := Dialog |
|
131 |
requestDirectoryName:'Destination Directory' |
|
132 |
default:(self model value ? '.' asFilename pathName). |
|
133 |
]. |
|
134 |
dir isEmptyOrNil ifTrue:[ ^ self ]. |
|
135 |
||
136 |
self model value:dir. |
|
137 |
||
138 |
"Modified: / 02-10-2006 / 14:45:54 / cg" |
|
139 |
! ! |
|
140 |
||
141 |
!FilenameWidgetWithHistory class methodsFor:'documentation'! |
|
142 |
||
143 |
version |
|
3471 | 144 |
^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.4 2008-07-11 15:30:38 cg Exp $' |
3251 | 145 |
! ! |