ComboView.st
author Claus Gittinger <cg@exept.de>
Sun, 26 Sep 1999 13:36:16 +0200
changeset 1560 8abb4de4f8f5
parent 1544 d8290e5a0b05
child 1622 ea4d9baf568f
permissions -rw-r--r--
added access to field.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1301
93a3ec8c339c OOPS - stefan what happened to your checkin (garbage)
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
     1
"
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     2
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     3
              All Rights Reserved
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     4
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     5
 This software is furnished under a license and may be used
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     6
 only in accordance with the terms of that license and with the
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     8
 be provided or otherwise made available to, or used by, any
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     9
 other person.  No title to or ownership of the software is
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    10
 hereby transferred.
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    11
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    12
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    13
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    14
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
View subclass:#ComboView
1306
56e90a9e5da1 renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents: 1301
diff changeset
    16
	instanceVariableNames:'field pullDownButton list listHolder listMsg action'
56e90a9e5da1 renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents: 1301
diff changeset
    17
	classVariableNames:'DefaultButtonForm'
56e90a9e5da1 renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents: 1301
diff changeset
    18
	poolDictionaries:''
56e90a9e5da1 renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents: 1301
diff changeset
    19
	category:'Views-Interactors'
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
263
865b7d99d3f5 added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
    22
!ComboView class methodsFor:'documentation'!
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    24
copyright
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    25
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    26
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    27
              All Rights Reserved
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    28
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    29
 This software is furnished under a license and may be used
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    30
 only in accordance with the terms of that license and with the
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    32
 be provided or otherwise made available to, or used by, any
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    33
 other person.  No title to or ownership of the software is
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    34
 hereby transferred.
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    35
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    36
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    37
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    38
!
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    39
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
documentation
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    A ComboView combines some field (typically an enterField or Label)
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    with a drop down list of default inputs;
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    ComboView is abstract, providing protocol common to ComboBoxView and
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    ComboListView. See documentation & examples there.
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    46
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    47
    [author:]
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    48
        Claus Gittinger
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    49
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    50
    [see also:]
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    51
        PopUpList
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1210
diff changeset
    52
        ComboListView ComboBoxView ExtendedComboBox
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    53
        PullDownMenu Label EntryField
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
"
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
!
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
examples
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
"
308
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
    59
  see examples in ComboListView and ComboBoxView
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
"
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
! !
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
263
865b7d99d3f5 added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
    63
!ComboView class methodsFor:'defaults'!
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
buttonForm
282
95209b20eaca commentary
Claus Gittinger <cg@exept.de>
parents: 280
diff changeset
    66
    "return the pull-buttons image"
95209b20eaca commentary
Claus Gittinger <cg@exept.de>
parents: 280
diff changeset
    67
1344
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
    68
    <resource: #style (#'comboView.downForm' 
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
    69
                       #'comboView.downFormFile')>
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    70
276
8f90ed6c37bc allow either fileName or form to be given by styleSheet
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    71
    |fileName form|
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
525
d0731a41d19f cache the pull-button image
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    73
    DefaultButtonForm notNil ifTrue:[
d0731a41d19f cache the pull-button image
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    74
        ^ DefaultButtonForm
d0731a41d19f cache the pull-button image
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    75
    ].
d0731a41d19f cache the pull-button image
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    76
1334
cc79acaebf00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
    77
    form := StyleSheet at:#'comboView.downForm'.
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    78
    form isNil ifTrue:[
1334
cc79acaebf00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
    79
        fileName := StyleSheet at:#'comboView.downFormFile' "default:'ComboDn.14.xbm'".
605
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    80
        fileName notNil ifTrue:[form := Image fromFile:fileName].
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    81
    ].
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    82
    form isNil ifTrue:[
605
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    83
        form  := Form width:12 height:12 
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    84
                      fromArray:#[2r00000000 2r00000000
605
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    85
                                  "/ 2r00001111 2r00000000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    86
                                  "/ 2r00001111 2r00000000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    87
                                  2r00001111 2r00000000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    88
                                  2r00001111 2r00000000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    89
                                  2r00001111 2r00000000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    90
                                  2r01111111 2r11100000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    91
                                  2r00111111 2r11000000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    92
                                  2r00011111 2r10000000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    93
                                  2r00001111 2r00000000
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    94
                                  2r00000110 2r00000000
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    95
                                  2r00000000 2r00000000
605
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    96
                                  2r01111111 2r11100000
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    97
                                  2r00000000 2r00000000]
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    98
                      on:Display.
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    99
    ].
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
   100
    form notNil ifTrue:[
525
d0731a41d19f cache the pull-button image
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   101
        form := DefaultButtonForm := form onDevice:Display.
d0731a41d19f cache the pull-button image
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
   102
        ^ form
274
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
   103
    ].
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
   104
    ^ nil
92b51554b1d7 allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
   105
1344
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   106
    "Modified: / 28.4.1999 / 12:49:42 / cg"
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   107
!
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   108
415
82d22b1ce5f5 defaultFont
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   109
defaultFont
82d22b1ce5f5 defaultFont
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   110
    "/ for now - should come from the styleSheet
82d22b1ce5f5 defaultFont
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   111
82d22b1ce5f5 defaultFont
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   112
    ^ SelectionInListView defaultFont.
82d22b1ce5f5 defaultFont
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   113
82d22b1ce5f5 defaultFont
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   114
    "Created: 4.6.1997 / 15:44:17 / cg"
82d22b1ce5f5 defaultFont
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   115
!
82d22b1ce5f5 defaultFont
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
   116
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   117
defaultListMessage
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   118
    ^ #list
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   119
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   120
    "Created: 26.2.1997 / 19:34:50 / cg"
605
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
   121
!
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
   122
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
   123
updateStyleCache
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
   124
    DefaultButtonForm := nil
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
   125
a8da1eb4e180 smaller button
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
   126
    "Created: / 3.11.1997 / 15:28:48 / cg"
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   127
! !
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   128
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   129
!ComboView methodsFor:'accessing-behavior'!
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   130
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   131
action:aBlock
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   132
    "specify, a block, which is evaluated when the lists selection changes.
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   133
     This is an additional hook - normally, you would communicate with the model
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   134
     alone"
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   135
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   136
    action := aBlock.
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   137
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   138
    "Created: 26.7.1996 / 17:44:18 / cg"
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   139
    "Modified: 26.2.1997 / 19:37:18 / cg"
411
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   140
!
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   141
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   142
enabled
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   143
    "return true, if is enabled
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   144
    "
1207
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   145
    enableChannel isNil ifTrue:[^ true].
1294
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   146
    ^ enableChannel value
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   147
!
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   148
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   149
enabled:aBoolean
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   150
    "enable/disable components"
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   151
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   152
    self enableChannel value:aBoolean.
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   153
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   154
    "Modified: / 30.3.1999 / 14:56:18 / stefan"
411
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   155
! !
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   156
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   157
!ComboView methodsFor:'accessing-channels'!
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   158
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   159
enableChannel 
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   160
    "return a valueHolder for enable/disable
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   161
    "
1207
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   162
    enableChannel isNil ifTrue:[
1294
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   163
        self enableChannel:(true asValue).
411
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   164
    ].
1207
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   165
    ^ enableChannel
411
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   166
1294
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   167
    "Modified: / 30.3.1999 / 16:20:25 / stefan"
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
! !
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
!ComboView methodsFor:'accessing-components'!
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
1560
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   172
field
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   173
    "return the field (input or label) component.
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   174
     For knowledgable users only."
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   175
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   176
    ^ field
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   177
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   178
    "Created: / 26.9.1999 / 13:33:15 / cg"
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   179
!
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   180
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
menuButton
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    "return the menuButton component"
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    ^ pullDownButton
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "Created: 28.2.1996 / 15:03:14 / cg"
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
! !
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
!ComboView methodsFor:'accessing-contents'!
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   191
contents
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   192
    "get the contents of my field"
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   193
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   194
    ^ field model value
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   195
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   196
    "Created: 14.5.1996 / 13:05:16 / cg"
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   197
    "Modified: 26.2.1997 / 16:55:43 / cg"
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   198
!
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   199
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   200
contents:something
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   201
    "set the contents of my field; questionable"
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   202
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   203
    |m|
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   204
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   205
    (m := field model) notNil ifTrue:[
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   206
        m value:something
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   207
    ]
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   208
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   209
    "Created: 14.5.1996 / 13:05:33 / cg"
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   210
    "Modified: 26.2.1997 / 16:56:08 / cg"
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   211
!
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
   212
889
7879fffb4810 oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   213
list
7879fffb4810 oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   214
    "return the list"
7879fffb4810 oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   215
7879fffb4810 oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   216
    ^ list
7879fffb4810 oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   217
7879fffb4810 oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   218
    "Created: / 18.5.1998 / 18:58:08 / cg"
7879fffb4810 oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   219
!
7879fffb4810 oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   220
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
list:aList
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   222
    "set the list explicitely; used internally or 
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   223
     to be send from the outside if no model/listHolder is used."
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   224
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    list := aList.
1306
56e90a9e5da1 renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents: 1301
diff changeset
   226
    self enableStateChanged.
1294
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   227
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   228
    "Modified: / 30.3.1999 / 14:17:38 / stefan"
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
! !
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
853
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   231
!ComboView methodsFor:'accessing-look'!
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   232
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   233
backgroundColor
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   234
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   235
    ^field backgroundColor
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   236
!
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   237
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   238
backgroundColor:aColor
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   239
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   240
    field backgroundColor:aColor
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   241
!
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   242
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   243
font:aFont
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   244
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   245
    super font:aFont.
1183
667132091c2f ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents: 1126
diff changeset
   246
    self setFieldsFont:aFont.
853
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   247
!
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   248
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   249
foregroundColor
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   250
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   251
    ^field foregroundColor
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   252
!
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   253
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   254
foregroundColor:aColor
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   255
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   256
    field foregroundColor:aColor
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   257
! !
e7e1c2bbd6f1 color selectors
tz
parents: 683
diff changeset
   258
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   259
!ComboView methodsFor:'accessing-mvc'!
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   260
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   261
listHolder:aValueHolder
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   262
    "set the listHolder.
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   263
     If not set, the list is supposed to be set explicitely"
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   264
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   265
    listHolder notNil ifTrue:[
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   266
        listHolder removeDependent:self.
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   267
    ].
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   268
    listHolder := aValueHolder.
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   269
    listHolder notNil ifTrue:[
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   270
        aValueHolder addDependent:self.
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   271
    ].
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   272
    realized ifTrue:[
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   273
        self getListFromModel.
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   274
    ]
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   275
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   276
    "Modified: 26.2.1997 / 19:32:09 / cg"
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   277
!
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   278
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   279
listMessage:aSymbol
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   280
    "define the message selector sent to the model, to fetch
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   281
     the list. If not defined, #list is used"
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   282
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   283
    listMsg := aSymbol
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   284
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   285
    "Created: 14.2.1997 / 19:16:52 / cg"
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   286
    "Modified: 26.2.1997 / 19:33:09 / cg"
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   287
!
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   288
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   289
model:aModel
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   290
    "set the model, which is supposed to provide the boxes value.
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   291
     If a listMessage was defined, it is also responsible for providing
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   292
     the list"
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   293
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   294
    super model:aModel.
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   295
314
6ff49c930c71 fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents: 312
diff changeset
   296
    self getListFromModel.
6ff49c930c71 fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents: 312
diff changeset
   297
    self getValueFromModel.
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   298
314
6ff49c930c71 fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents: 312
diff changeset
   299
    "Modified: 28.2.1997 / 19:08:45 / cg"
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   300
! !
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   301
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   302
!ComboView methodsFor:'change & update'!
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   303
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   304
update:something with:aParameter from:changedObject
1207
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   305
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   306
    changedObject == model ifTrue:[
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   307
        listHolder isNil ifTrue:[
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   308
            self getListFromModel.
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   309
        ].
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   310
        self getValueFromModel.
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   311
        ^ self
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   312
    ].
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   313
    changedObject == listHolder ifTrue:[
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   314
        self getListFromModel.
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   315
        ^ self
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   316
    ].
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   317
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   318
    super update:something with:aParameter from:changedObject
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   319
1294
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   320
    "Created: / 15.7.1996 / 12:26:49 / cg"
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   321
    "Modified: / 28.2.1997 / 13:48:51 / cg"
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   322
    "Modified: / 30.3.1999 / 14:17:55 / stefan"
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   323
! !
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   324
869
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   325
!ComboView methodsFor:'event handling'!
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   326
1306
56e90a9e5da1 renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents: 1301
diff changeset
   327
enableStateChanged
1294
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   328
    "the enable state has changed - pass this to my field and pullDownButton"
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   329
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   330
    |msg|
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   331
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   332
    (enableChannel isNil or:[enableChannel value]) ifTrue:[
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   333
        msg := #enable
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   334
    ] ifFalse:[
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   335
        msg := #disable
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   336
    ].
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   337
    field perform:msg ifNotUnderstood:nil.
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   338
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   339
    (list size == 0) ifTrue:[
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   340
        msg := #disable
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   341
    ].
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   342
    pullDownButton perform:msg ifNotUnderstood:nil.
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   343
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   344
    "Modified: / 22.2.1999 / 00:47:46 / cg"
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   345
    "Modified: / 30.3.1999 / 14:17:10 / stefan"
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   346
!
36a0e9dcd813 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   347
869
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   348
keyPress:key x:x y:y
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   349
    (key == Character space
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   350
    or:[key == #Return]) ifTrue:[
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   351
        self pullMenu.
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   352
        ^ self.
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   353
    ].
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   354
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   355
    ^ super keyPress:key x:x y:y
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   356
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   357
    "Modified: / 21.4.1998 / 20:10:05 / cg"
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   358
! !
a1838cce9641 popup menu on space or return
Claus Gittinger <cg@exept.de>
parents: 853
diff changeset
   359
1325
3e36f7c5373b category change
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   360
!ComboView methodsFor:'initialize / release'!
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
1207
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   362
destroy
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   363
    listHolder notNil ifTrue:[
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   364
        listHolder removeDependent:self.
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   365
        listHolder := nil.
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   366
    ].
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   367
    super destroy
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   368
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   369
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   370
!
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   371
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
initialize
331
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   373
    |prefExt leftInset rightInset prefWidth halfSpacing l|
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
    super initialize.
308
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   376
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   377
    listMsg := self class defaultListMessage.
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   378
    aspectMsg := self class defaultAspectMessage.
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   379
    changeMsg := self class defaultChangeMessage.
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    self initializeField.
431
c6c92bef604a fixed origin of editField
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
   382
    field origin:0@0 corner:1.0@1.0.
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
331
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   384
    self initializeButton.
280
3936f0839b64 nicer spacing
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   385
    prefExt := pullDownButton preferredExtent.
3936f0839b64 nicer spacing
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   386
    prefWidth := prefExt x.
3936f0839b64 nicer spacing
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   387
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
    pullDownButton origin:1.0@0.0 corner:1.0@1.0.
217
82971d8b3938 care for 2D styles
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   389
    styleSheet is3D ifTrue:[
280
3936f0839b64 nicer spacing
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   390
        halfSpacing := ViewSpacing // 2.
3936f0839b64 nicer spacing
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   391
        leftInset := rightInset := prefWidth + halfSpacing.
1334
cc79acaebf00 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   392
        (l := styleSheet at:#'comboView.level' default:nil) notNil ifTrue:[
331
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   393
            self level:l.
319
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   394
            field level:0.
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   395
            field rightInset:margin.
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   396
        ] ifFalse:[
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   397
            pullDownButton rightInset:halfSpacing.
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   398
            field leftInset:halfSpacing
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   399
        ].
217
82971d8b3938 care for 2D styles
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   400
    ] ifFalse:[
280
3936f0839b64 nicer spacing
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   401
        leftInset := prefWidth + pullDownButton borderWidth.
3936f0839b64 nicer spacing
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   402
        rightInset := prefWidth.
217
82971d8b3938 care for 2D styles
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   403
    ].
1125
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   404
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   405
    (styleSheet name = #win95
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   406
    or:[styleSheet name = #st80]) ifTrue:[
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   407
        field level:0.
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   408
        self level:-1.
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   409
        pullDownButton rightInset:0.
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   410
        styleSheet name = #win95 ifTrue:[
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   411
            leftInset := (ArrowButton new preferredExtent x).
1126
dc790a73ac4d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1125
diff changeset
   412
            rightInset := leftInset.
1125
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   413
        ].
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   414
        field origin:0.0@0.0.
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   415
        field leftInset:0
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   416
"/        field topInset:1; bottomInset:1.
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   417
    ].
1126
dc790a73ac4d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1125
diff changeset
   418
    field rightInset:rightInset.
280
3936f0839b64 nicer spacing
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   419
    pullDownButton leftInset:leftInset negated.
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
247
a974233a33c1 use new #initialHeight:
dq
parents: 229
diff changeset
   421
    self initialHeight:field preferredExtent y + ViewSpacing.
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
    "
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
     |b|
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
     b := ComboBoxView new.
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
     b list:#('hello' 'world' 'this' 'is' 'st/x').
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
     b open
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
    "
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
1125
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   431
    "Created: / 28.2.1996 / 15:03:17 / cg"
6bb8029bbc29 geometry beautified
Claus Gittinger <cg@exept.de>
parents: 889
diff changeset
   432
    "Modified: / 8.9.1998 / 20:33:22 / cg"
331
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   433
!
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   434
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   435
initializeButton
1344
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   436
    <resource: #style (#'comboView.disabledDownForm' 
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   437
                       #'comboView.disabledDownFormFile')>
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   438
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   439
    |l1 l2|
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   440
512
97beb6e8acbe ST-80 compatible ComboBoxButton
Claus Gittinger <cg@exept.de>
parents: 437
diff changeset
   441
    pullDownButton := ComboBoxButton in:self.
331
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   442
    pullDownButton controller beTriggerOnDown.
1344
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   443
    pullDownButton logo:(l1 := self class buttonForm).
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   444
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   445
    l2 := styleSheet at:#'comboView.disabledDownFormFile'.
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   446
    l2 notNil ifTrue:[
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   447
        l2 := Image fromFile:l2.
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   448
    ] ifFalse:[
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   449
        l2 := styleSheet at:#'comboView.disabledDownForm'.
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   450
    ].    
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   451
    l2 notNil ifTrue:[
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   452
        pullDownButton passiveLogo:l1.
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   453
        pullDownButton activeLogo:l1.
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   454
        pullDownButton disabledLogo:l2.
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   455
    ].
331
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   456
    pullDownButton showLamp:false.
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   457
    pullDownButton activeLevel == pullDownButton passiveLevel ifTrue:[
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   458
        pullDownButton activeLevel:0.
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   459
    ].
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   460
    pullDownButton disable.
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   461
    pullDownButton pressAction:[self pullMenu].
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   462
1344
100e4d309847 support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   463
    "Modified: / 28.4.1999 / 13:09:42 / cg"
331
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   464
!
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   465
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   466
initializeField
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   467
    self subclassResponsibility
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   468
d6fad4b27a9a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   469
    "Created: 29.3.1997 / 11:17:14 / cg"
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
! !
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
!ComboView methodsFor:'message delegation'!
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
doesNotUnderstand:aMessage
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
    (field respondsTo:aMessage selector) ifTrue:[
1207
9019fe235f32 do not share my enableChannel with my buttons channel
tm
parents: 1183
diff changeset
   476
        ^ aMessage sendTo:field
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
    ].
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
    ^ super doesNotUnderstand:aMessage
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
    "Created: 28.2.1996 / 15:03:17 / cg"
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
    "Modified: 28.2.1996 / 15:06:09 / cg"
166
19f08c13b299 Forward respondsTo: message.
Stefan Vogel <sv@exept.de>
parents: 129
diff changeset
   482
!
19f08c13b299 Forward respondsTo: message.
Stefan Vogel <sv@exept.de>
parents: 129
diff changeset
   483
19f08c13b299 Forward respondsTo: message.
Stefan Vogel <sv@exept.de>
parents: 129
diff changeset
   484
respondsTo:aSymbol
19f08c13b299 Forward respondsTo: message.
Stefan Vogel <sv@exept.de>
parents: 129
diff changeset
   485
    ^ (field respondsTo:aSymbol) or:[super respondsTo:aSymbol]
19f08c13b299 Forward respondsTo: message.
Stefan Vogel <sv@exept.de>
parents: 129
diff changeset
   486
19f08c13b299 Forward respondsTo: message.
Stefan Vogel <sv@exept.de>
parents: 129
diff changeset
   487
    "Created: 2.5.1996 / 16:57:34 / stefan"
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
! !
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   490
!ComboView methodsFor:'private'!
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   491
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   492
getListFromModel
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   493
    "fetch the list - either from the listHolder, or
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   494
     from the model. If no listMessage was defined, fetch it
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   495
     using #list."
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   496
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   497
    listHolder notNil ifTrue:[
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   498
        self list:listHolder value
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   499
    ] ifFalse:[
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   500
        (model notNil and:[listMsg notNil]) ifTrue:[
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   501
            (model respondsTo:listMsg) ifTrue:[
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   502
                self list:(model perform:listMsg)
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   503
            ]
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   504
        ]
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   505
    ].
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   506
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   507
    "Created: 15.7.1996 / 12:22:56 / cg"
304
7ee03df31561 cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   508
    "Modified: 26.2.1997 / 19:40:58 / cg"
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   509
!
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   510
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   511
getValueFromModel
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   512
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   513
    "Modified: 15.7.1996 / 12:28:59 / cg"
1183
667132091c2f ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents: 1126
diff changeset
   514
!
667132091c2f ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents: 1126
diff changeset
   515
1210
55f2c4209f94 oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents: 1207
diff changeset
   516
setFieldsFont:aFont
55f2c4209f94 oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents: 1207
diff changeset
   517
    field font:aFont.
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   518
! !
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   519
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
!ComboView methodsFor:'queries'!
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
preferredExtent
285
a33d83de3849 commentary
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   523
    "compute & return the boxes preferredExtent from the components' preferrences"
a33d83de3849 commentary
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   524
683
a2593b4a3ce1 fixed preferredExtent to also look into the menus list
ca
parents: 605
diff changeset
   525
    |fieldPref buttonPref m menuPrefX menuPrefY w h|
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
312
ec32b0a6259a explicit preferredExtent
ca
parents: 310
diff changeset
   527
    "/ If I have an explicit preferredExtent ..
ec32b0a6259a explicit preferredExtent
ca
parents: 310
diff changeset
   528
ec32b0a6259a explicit preferredExtent
ca
parents: 310
diff changeset
   529
    preferredExtent notNil ifTrue:[
ec32b0a6259a explicit preferredExtent
ca
parents: 310
diff changeset
   530
        ^ preferredExtent
ec32b0a6259a explicit preferredExtent
ca
parents: 310
diff changeset
   531
    ].
ec32b0a6259a explicit preferredExtent
ca
parents: 310
diff changeset
   532
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    list isNil ifTrue:[
308
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   534
        self getListFromModel
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   535
    ].
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   536
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   537
    list isNil ifTrue:[
683
a2593b4a3ce1 fixed preferredExtent to also look into the menus list
ca
parents: 605
diff changeset
   538
        menuPrefX := menuPrefY := 0
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
    ] ifFalse:[
1544
d8290e5a0b05 Speedup
Stefan Vogel <sv@exept.de>
parents: 1348
diff changeset
   540
        m := (MenuView onDevice:device ? Screen current) labels:list.
302
8af5f51ce7a5 preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   541
        menuPrefX := m preferredExtent x.
1348
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   542
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   543
        "/ the menuView returns rubbish ...
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   544
"/        menuPrefY := (m preferredExtentForLines:1 cols:10) y
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   545
        
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   546
        "/ any non-strings ?
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   547
        menuPrefY := list 
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   548
            inject:('X' heightOn:self) 
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   549
            into:[:max :el | el isString ifTrue:[
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   550
                                max
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   551
                              ] ifFalse:[
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   552
                                max max:(el heightOn:self) 
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   553
                              ]
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   554
                 ].
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
    ].
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
302
8af5f51ce7a5 preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   557
    fieldPref := field preferredExtent.
8af5f51ce7a5 preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   558
    buttonPref := pullDownButton preferredExtent.
8af5f51ce7a5 preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   559
319
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   560
    w := ((fieldPref x max:menuPrefX) max:50) + buttonPref x.
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   561
    w := w + margin + margin.
683
a2593b4a3ce1 fixed preferredExtent to also look into the menus list
ca
parents: 605
diff changeset
   562
    h := (fieldPref y max:buttonPref y) max:menuPrefY.
319
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   563
    h := h + margin + margin.
920ef16160ae w95 style fixes
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   564
    ^ w @ h
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
1348
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   566
    "Created: / 28.2.1996 / 15:03:17 / cg"
b4bf740ec2fc fixed pref. extent
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   567
    "Modified: / 29.4.1999 / 11:27:54 / cg"
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
! !
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
!ComboView methodsFor:'user interaction'!
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
pullMenu
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   573
    "pull the menu - triggered from the button"
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   574
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
    |m org|
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
214
328a09259794 get list from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   577
    self getListFromModel.
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
    (list notNil and:[list notEmpty]) ifTrue:[
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   579
        m := PopUpMenu
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   580
                    labels:list
308
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   581
                    selectors:#select:
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   582
                    args:(1 to:list size)
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   583
                    receiver:self.
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
411
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   585
        m font:font.
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   586
        m menuView font:font.
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   587
        m menuView resize.
411
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   588
        m resize.
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   589
        m menuView width:(self width).
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   590
        m menuView sizeFixed:true.
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   591
        m hideOnRelease:false.
411
5a32b4247011 delegate font:
ca
parents: 332
diff changeset
   592
        m resize.
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   594
        org := device translatePoint:(0 @ self height) 
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   595
                                from:(self id)
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   596
                                  to:(device rootView id).
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
277
44eadbccc2b7 added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   598
        m showAt:org.
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
    ].
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    pullDownButton turnOff.
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    "Created: 28.2.1996 / 15:03:18 / cg"
308
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   604
    "Modified: 27.2.1997 / 15:18:00 / cg"
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   605
!
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   606
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   607
select:anIndex
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   608
    "sent from the popped menu, when an item was selected"
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   609
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   610
    self subclassResponsibility
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   611
922a96deba3e examples removed; cleanup
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   612
    "Modified: 27.2.1997 / 15:19:07 / cg"
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
! !
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
263
865b7d99d3f5 added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
   615
!ComboView class methodsFor:'documentation'!
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
version
1560
8abb4de4f8f5 added access to field.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
   618
    ^ '$Header: /cvs/stx/stx/libwidg2/ComboView.st,v 1.56 1999-09-26 11:36:16 cg Exp $'
129
a680f0b7508f intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
! !