FilenameWidgetWithHistory.st
author Claus Gittinger <cg@exept.de>
Fri, 30 May 2008 14:26:05 +0200
changeset 3427 9927e4970fce
parent 3318 5a0aff0fd23a
child 3471 f3cde37d9d53
permissions -rw-r--r--
added preferredWidth & preferredHeight
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3318
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     1
"
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     2
 COPYRIGHT (c) 2007 by eXept Software AG
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     3
              All Rights Reserved
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     4
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     5
 This software is furnished under a license and may be used
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     6
 only in accordance with the terms of that license and with the
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     8
 be provided or otherwise made available to, or used by, any
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     9
 other person.  No title to or ownership of the software is
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    10
 hereby transferred.
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    11
"
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
SimpleView subclass:#FilenameWidgetWithHistory
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'fileNameEntryField browseButton history'
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Views-Interactors'
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!FilenameWidgetWithHistory class methodsFor:'documentation'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
3318
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    23
copyright
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    24
"
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    25
 COPYRIGHT (c) 2007 by eXept Software AG
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    26
              All Rights Reserved
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    27
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    28
 This software is furnished under a license and may be used
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    29
 only in accordance with the terms of that license and with the
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    31
 be provided or otherwise made available to, or used by, any
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    32
 other person.  No title to or ownership of the software is
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    33
 hereby transferred.
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    34
"
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    35
!
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    36
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
examples
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
                                                                        [exBegin]
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
     |top b|
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
     top := StandardSystemView new.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
     top extent:(300 @ 200).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
     b := FilenameWidgetWithHistory in:top.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
     b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
     b bottomInset:(b preferredExtent y negated).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
     top open.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
                                                                        [exEnd]
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
"
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!FilenameWidgetWithHistory methodsFor:'accessing'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
historyList
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    ^ #('a' 'b' 'c')
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
model
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    ^ fileNameEntryField model
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
model:aFilenameHolder
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    fileNameEntryField model:aFilenameHolder.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
!FilenameWidgetWithHistory methodsFor:'initialization'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
initialize
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    super initialize.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    fileNameEntryField := FilenameComboBoxView in:self.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    fileNameEntryField layout:(LayoutFrame
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
                                  leftFraction:0 offset:0 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
                                  rightFraction:1 offset:-22 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
                                  topFraction:0 offset:0 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
                                  bottomFraction:1 offset:0).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    fileNameEntryField listHolder:(self historyList).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    browseButton := Button in:self.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    browseButton label:'...'.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    browseButton action:[self browseForDestinationDirectory].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    browseButton layout:(LayoutFrame
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
                                  leftFraction:1 offset:-22 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
                                  rightFraction:1 offset:-2 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
                                  topFraction:0 offset:0 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
                                  bottomFraction:1 offset:0).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
!FilenameWidgetWithHistory methodsFor:'queries'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
preferredExtent
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    preferredExtent notNil ifTrue:[
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        ^ preferredExtent
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    ].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
3427
9927e4970fce added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    98
    preferredExtent := (fileNameEntryField preferredWidth + browseButton preferredWidth)
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
                       @
3427
9927e4970fce added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
   100
                       (fileNameEntryField preferredHeight "max: browseButton preferredExtent y").
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ^ preferredExtent
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
!FilenameWidgetWithHistory methodsFor:'user actions'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
browseForDestinationDirectory
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    |dir|
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    Dialog aboutToOpenBoxNotificationSignal handle:[:ex |
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
        |dialog|
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
        dialog := ex parameter.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
        dialog perform:#browseVisibleHolder with:true ifNotUnderstood:[].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
        ex proceed.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    ] do:[
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
        dir := Dialog 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
                requestDirectoryName:'Destination Directory'
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
                default:(self model value ? '.' asFilename pathName).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    ].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    dir isEmptyOrNil ifTrue:[ ^ self ].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    self model value:dir.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    "Modified: / 02-10-2006 / 14:45:54 / cg"
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
!FilenameWidgetWithHistory class methodsFor:'documentation'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
version
3427
9927e4970fce added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
   130
    ^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.3 2008-05-30 12:26:05 cg Exp $'
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
! !