ExtendedComboBox.st
author Claus Gittinger <cg@exept.de>
Sat, 18 Jan 2020 15:37:54 +0100
changeset 6209 76d74a400d6b
parent 6178 4227070538b7
child 6237 12ad20ee2671
permissions -rw-r--r--
#FEATURE by exept class: MenuPanel added: #grabMenuItemAtPoint: comment/format in: #itemAtPoint: changed: #processShortcut:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6154
acbfc5e42e07 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
     1
"{ Encoding: utf8 }"
acbfc5e42e07 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
     2
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
     3
"
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
     4
 COPYRIGHT (c) 1998 by eXept Software AG
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
     5
              All Rights Reserved
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
     6
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
     7
 This software is furnished under a license and may be used
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
     8
 only in accordance with the terms of that license and with the
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    10
 be provided or otherwise made available to, or used by, any
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    11
 other person.  No title to or ownership of the software is
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    12
 hereby transferred.
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    13
"
1830
66c131adec9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
66c131adec9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
    15
4728
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
    16
"{ NameSpace: Smalltalk }"
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
    17
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    18
View subclass:#ExtendedComboBox
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    19
	instanceVariableNames:'menuButton menuField menuWrapper adjust menuWidgetHolder
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    20
		menuWidget menuHeight openAction isReadOnly closeOnSelect
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    21
		menuExtent usePreferredWidthForMenu hasHorizontalScrollBar
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    22
		hasVerticalScrollBar miniScrollerHorizontal miniScrollerVertical
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    23
		autoHideScrollBars'
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    24
	classVariableNames:''
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    25
	poolDictionaries:''
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    26
	category:'Views-Interactors'
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
    27
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
    28
1273
0460739b9e97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
    29
PopUpView subclass:#MenuWrapper
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    30
	instanceVariableNames:'comboBox widget lastPointerView implicitGrabView eventHandler
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    31
		resizeCursor restoreCursor'
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    32
	classVariableNames:''
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    33
	poolDictionaries:''
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
    34
	privateIn:ExtendedComboBox
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
    35
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
    36
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    37
!ExtendedComboBox class methodsFor:'documentation'!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    38
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    39
copyright
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    40
"
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    41
 COPYRIGHT (c) 1998 by eXept Software AG
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    42
              All Rights Reserved
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    43
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    44
 This software is furnished under a license and may be used
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    45
 only in accordance with the terms of that license and with the
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    46
 inclusion of the above copyright notice.   This software may not
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    47
 be provided or otherwise made available to, or used by, any
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    48
 other person.  No title to or ownership of the software is
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    49
 hereby transferred.
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    50
"
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    51
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    52
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    53
!
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    54
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    55
documentation
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    56
"
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    57
    An ExtendedComboBox looks much like a ComboBox, but allows for any view
5443
79f472b09304 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5313
diff changeset
    58
    to be popped up 
79f472b09304 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5313
diff changeset
    59
    (in contrast to a ComboBox, which has a hardWired selectionInListmenu).
79f472b09304 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5313
diff changeset
    60
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    61
    The popped view may optionally be decorated with scrollBars.
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    62
    As a side effect, an ExtendedComboBox with a SelectionInListView or Menu
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    63
    can now be used as a replacement for ComboBoxes when long-lists are to be shown,
5443
79f472b09304 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5313
diff changeset
    64
    since those can now be scrolled or defined as hierarchical lists.
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    65
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    66
    [author:]
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    67
        Claus Atzkern
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    68
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    69
    [see also:]
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    70
        ComboBox ComboView
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    71
        PopUpList SelectionInListView
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    72
        ComboListView
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    73
        PullDownMenu Label EntryField
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    74
"
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    75
!
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
    76
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    77
examples
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    78
"
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
    79
    example: SelectionInListView
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    80
                                                                                [exBegin]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    81
    |top menu widget list sidx|
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    82
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    83
    top  := StandardSystemView extent:200@35.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    84
    menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    85
    list := #('foo' 'bar' 'baz' 'hjh' 'kk' 'claus' 'gjhj').
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    86
    sidx := 4.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    87
    menu bottomInset:(menu preferredExtent y negated).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    88
    menu contents:(list at:sidx).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    89
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    90
    widget := SelectionInListView new.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    91
    widget list:list.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    92
    widget doubleClickAction:[:i| menu contents:(widget at:i) ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    93
    widget selection:sidx.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    94
    menu menuWidget:widget.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    95
    top open.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    96
                                                                                [exEnd]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    97
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    98
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
    99
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   100
    example: FileSelectionTree
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   101
                                                                                [exBegin]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   102
    |top menu widget|
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   103
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   104
    top  := StandardSystemView extent:200@35.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   105
    menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   106
    menu bottomInset:(menu preferredExtent y negated).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   107
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   108
    widget := FileSelectionTree new.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   109
    widget directory:(Filename homeDirectory).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   110
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   111
    widget doubleClickAction:[:i||n|
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   112
        n := widget selectedNode.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   113
        n isDirectory ifFalse:[menu contents:(n pathName)]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   114
    ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   115
    menu menuHeight:400.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   116
    menu menuWidget:widget.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   117
    top  open.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   118
                                                                                [exEnd]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   119
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   120
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   121
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   122
    example: SelectionInTreeView
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   123
                                                                                [exBegin]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   124
    |top menu widget|
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   125
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   126
    top  := StandardSystemView extent:200@35.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   127
    menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   128
    menu bottomInset:(menu preferredExtent y negated).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   129
    menu contents:'foo'.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   130
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   131
    widget := SelectionInTreeView new.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   132
    widget root:(TreeItem newAsTreeFromSmalltalkClass:Object).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   133
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   134
    widget doubleClickAction:[:i||n|
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   135
        n := widget selectedNode.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   136
        n hasChildren ifFalse:[menu contents:(n name)]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   137
    ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   138
    menu menuHeight:300.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   139
    menu menuWidget:widget.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   140
    top  open.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   141
                                                                                [exEnd]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   142
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   143
    example: a menu from elsewhere
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   144
                                                                                [exBegin]
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   145
    |top menu widget models|
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   146
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   147
    models := Expecco::Browser openBrowsers 
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   148
                    collectAll:[:b | b project 
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   149
                                        ifNil:[#()]
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   150
                                        ifNotNil:[:p | p allBlockDescriptions]].
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   151
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   152
    top  := StandardSystemView extent:250@35.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   153
    menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   154
    menu bottomInset:(menu preferredExtent y negated).
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   155
    menu contents:'lets do the timeWarp again...'.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   156
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   157
    widget := Workflow::AbstractEditor
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   158
        dataTypeMenuFor:models receiver:nil selector:[:type | menu contents:type] 
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   159
        editorSelector:nil 
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   160
        withTemplateTypes:false 
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   161
        withUserTypeDefinition:false
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   162
        forFreeze:false.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   163
    menu menuWidget:widget.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   164
    top open.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   165
                                                                                [exEnd]
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   166
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   167
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   168
    example: Funny
1282
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   169
                                                                                [exBegin]
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   170
    |top menu widget|
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   171
5443
79f472b09304 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5313
diff changeset
   172
    Smalltalk loadPackage:'stx:libwidg3'.
1282
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   173
    top  := StandardSystemView extent:250@35.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   174
    menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   175
    menu bottomInset:(menu preferredExtent y negated).
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   176
    menu contents:'lets do the timeWarp again...'.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   177
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   178
    widget := ClockView new.
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   179
    menu menuHeight:[menu width].
1282
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   180
    menu menuWidget:widget.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   181
    top open.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   182
                                                                                [exEnd]
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   183
1285
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   184
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   185
    example: Funny - again 
1285
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   186
               (use widgets pref-width; even if the combo-box is smaller)
1282
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   187
                                                                                [exBegin]
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   188
    |top menu widget|
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   189
1284
1fb5f5cbd4d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   190
    top  := StandardSystemView extent:80@35.
1282
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   191
    menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   192
    menu bottomInset:(menu preferredExtent y negated).
1284
1fb5f5cbd4d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   193
    menu contents:'time...'.
1282
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   194
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   195
    widget := ClockView new.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   196
    menu menuWidget:widget.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   197
    menu usePreferredWidthForMenu:true.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   198
    top open.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
   199
                                                                                [exEnd]
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   200
1285
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   201
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   202
    example: Funny - again 
1285
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   203
               (use widgets pref-width; even if the combo-box is smaller,
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   204
                adjust the height for the width)
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   205
                                                                                [exBegin]
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   206
    |top menu widget|
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   207
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   208
    top  := StandardSystemView extent:80@35.
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   209
    menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   210
    menu bottomInset:(menu preferredExtent y negated).
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   211
    menu contents:'time...'.
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   212
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   213
    widget := ClockView new.
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   214
    menu menuWidget:widget.
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   215
    menu usePreferredWidthForMenu:true.
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   216
    menu menuHeight:[widget width].
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   217
    top open.
839acde3f42c fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents: 1284
diff changeset
   218
                                                                                [exEnd]
1406
982b813545c8 example
ah
parents: 1395
diff changeset
   219
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   220
    example: Subcanvas with a spec
1406
982b813545c8 example
ah
parents: 1395
diff changeset
   221
                                                                                [exBegin]
982b813545c8 example
ah
parents: 1395
diff changeset
   222
    |top menu widget list sidx spec|
982b813545c8 example
ah
parents: 1395
diff changeset
   223
982b813545c8 example
ah
parents: 1395
diff changeset
   224
    spec :=  #(#FullSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   225
          #window: 
982b813545c8 example
ah
parents: 1395
diff changeset
   226
           #(#WindowSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   227
              #name: 'Define Color'
982b813545c8 example
ah
parents: 1395
diff changeset
   228
              #layout: #(#LayoutFrame 13 0 29 0 352 0 159 0)
982b813545c8 example
ah
parents: 1395
diff changeset
   229
              #label: 'Define Color'
982b813545c8 example
ah
parents: 1395
diff changeset
   230
              #min: #(#Point 340 110)
982b813545c8 example
ah
parents: 1395
diff changeset
   231
              #max: #(#Point 1152 900)
982b813545c8 example
ah
parents: 1395
diff changeset
   232
              #bounds: #(#Rectangle 13 29 353 160)
982b813545c8 example
ah
parents: 1395
diff changeset
   233
              #usePreferredExtent: false
982b813545c8 example
ah
parents: 1395
diff changeset
   234
          )
982b813545c8 example
ah
parents: 1395
diff changeset
   235
          #component: 
982b813545c8 example
ah
parents: 1395
diff changeset
   236
           #(#SpecCollection
982b813545c8 example
ah
parents: 1395
diff changeset
   237
              #collection: 
982b813545c8 example
ah
parents: 1395
diff changeset
   238
               #(
982b813545c8 example
ah
parents: 1395
diff changeset
   239
                 #(#VerticalPanelViewSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   240
                    #name: 'VerticalPanel1'
982b813545c8 example
ah
parents: 1395
diff changeset
   241
                    #layout: #(#LayoutFrame 0 0.0 0 0.0 58 0 -40 1.0)
982b813545c8 example
ah
parents: 1395
diff changeset
   242
                    #component: 
982b813545c8 example
ah
parents: 1395
diff changeset
   243
                     #(#SpecCollection
982b813545c8 example
ah
parents: 1395
diff changeset
   244
                        #collection: 
982b813545c8 example
ah
parents: 1395
diff changeset
   245
                         #(
982b813545c8 example
ah
parents: 1395
diff changeset
   246
                           #(#LabelSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   247
                              #name: 'RedLabel'
982b813545c8 example
ah
parents: 1395
diff changeset
   248
                              #label: 'Red:'
982b813545c8 example
ah
parents: 1395
diff changeset
   249
                              #translateLabel: true
982b813545c8 example
ah
parents: 1395
diff changeset
   250
                              #adjust: #right
982b813545c8 example
ah
parents: 1395
diff changeset
   251
                              #extent: #(#Point 58 26)
982b813545c8 example
ah
parents: 1395
diff changeset
   252
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   253
                           #(#LabelSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   254
                              #name: 'GreenLabel'
982b813545c8 example
ah
parents: 1395
diff changeset
   255
                              #label: 'Green:'
982b813545c8 example
ah
parents: 1395
diff changeset
   256
                              #translateLabel: true
982b813545c8 example
ah
parents: 1395
diff changeset
   257
                              #adjust: #right
982b813545c8 example
ah
parents: 1395
diff changeset
   258
                              #extent: #(#Point 58 27)
982b813545c8 example
ah
parents: 1395
diff changeset
   259
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   260
                           #(#LabelSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   261
                              #name: 'BlueLabel'
982b813545c8 example
ah
parents: 1395
diff changeset
   262
                              #label: 'Blue:'
982b813545c8 example
ah
parents: 1395
diff changeset
   263
                              #translateLabel: true
982b813545c8 example
ah
parents: 1395
diff changeset
   264
                              #adjust: #right
982b813545c8 example
ah
parents: 1395
diff changeset
   265
                              #extent: #(#Point 58 26)
982b813545c8 example
ah
parents: 1395
diff changeset
   266
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   267
                        )
982b813545c8 example
ah
parents: 1395
diff changeset
   268
                    )
982b813545c8 example
ah
parents: 1395
diff changeset
   269
                    #horizontalLayout: #fit
982b813545c8 example
ah
parents: 1395
diff changeset
   270
                    #verticalLayout: #fitSpace
982b813545c8 example
ah
parents: 1395
diff changeset
   271
                    #horizontalSpace: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   272
                    #verticalSpace: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   273
                )
982b813545c8 example
ah
parents: 1395
diff changeset
   274
                 #(#VerticalPanelViewSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   275
                    #name: 'VerticalPanel2'
982b813545c8 example
ah
parents: 1395
diff changeset
   276
                    #layout: #(#LayoutFrame 60 0 0 0.0 -160 1.0 -40 1.0)
982b813545c8 example
ah
parents: 1395
diff changeset
   277
                    #component: 
982b813545c8 example
ah
parents: 1395
diff changeset
   278
                     #(#SpecCollection
982b813545c8 example
ah
parents: 1395
diff changeset
   279
                        #collection: 
982b813545c8 example
ah
parents: 1395
diff changeset
   280
                         #(
982b813545c8 example
ah
parents: 1395
diff changeset
   281
                           #(#SliderSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   282
                              #name: 'RedSlider'
982b813545c8 example
ah
parents: 1395
diff changeset
   283
                              #tabable: true
982b813545c8 example
ah
parents: 1395
diff changeset
   284
                              #model: #red
982b813545c8 example
ah
parents: 1395
diff changeset
   285
                              #orientation: #horizontal
982b813545c8 example
ah
parents: 1395
diff changeset
   286
                              #stop: 255
982b813545c8 example
ah
parents: 1395
diff changeset
   287
                              #step: 1
982b813545c8 example
ah
parents: 1395
diff changeset
   288
                              #backgroundColor: #(#Color 100.0 0.0 0.0)
982b813545c8 example
ah
parents: 1395
diff changeset
   289
                              #extent: #(#Point 118 16)
982b813545c8 example
ah
parents: 1395
diff changeset
   290
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   291
                           #(#SliderSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   292
                              #name: 'GreenSlider'
982b813545c8 example
ah
parents: 1395
diff changeset
   293
                              #tabable: true
982b813545c8 example
ah
parents: 1395
diff changeset
   294
                              #model: #green
982b813545c8 example
ah
parents: 1395
diff changeset
   295
                              #orientation: #horizontal
982b813545c8 example
ah
parents: 1395
diff changeset
   296
                              #stop: 255
982b813545c8 example
ah
parents: 1395
diff changeset
   297
                              #step: 1
982b813545c8 example
ah
parents: 1395
diff changeset
   298
                              #backgroundColor: #(#Color 0.0 100.0 0.0)
982b813545c8 example
ah
parents: 1395
diff changeset
   299
                              #extent: #(#Point 118 16)
982b813545c8 example
ah
parents: 1395
diff changeset
   300
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   301
                           #(#SliderSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   302
                              #name: 'BlueSlider'
982b813545c8 example
ah
parents: 1395
diff changeset
   303
                              #tabable: true
982b813545c8 example
ah
parents: 1395
diff changeset
   304
                              #model: #blue
982b813545c8 example
ah
parents: 1395
diff changeset
   305
                              #orientation: #horizontal
982b813545c8 example
ah
parents: 1395
diff changeset
   306
                              #stop: 255
982b813545c8 example
ah
parents: 1395
diff changeset
   307
                              #step: 1
982b813545c8 example
ah
parents: 1395
diff changeset
   308
                              #backgroundColor: #(#Color 0.0 0.0 100.0)
982b813545c8 example
ah
parents: 1395
diff changeset
   309
                              #extent: #(#Point 118 16)
982b813545c8 example
ah
parents: 1395
diff changeset
   310
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   311
                        )
982b813545c8 example
ah
parents: 1395
diff changeset
   312
                    )
982b813545c8 example
ah
parents: 1395
diff changeset
   313
                    #horizontalLayout: #fit
982b813545c8 example
ah
parents: 1395
diff changeset
   314
                    #verticalLayout: #spreadSpace
982b813545c8 example
ah
parents: 1395
diff changeset
   315
                    #horizontalSpace: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   316
                    #verticalSpace: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   317
                )
982b813545c8 example
ah
parents: 1395
diff changeset
   318
                 #(#VerticalPanelViewSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   319
                    #name: 'VerticalPanel3'
982b813545c8 example
ah
parents: 1395
diff changeset
   320
                    #layout: #(#LayoutFrame -158 1 0 0.0 -120 1 -40 1.0)
982b813545c8 example
ah
parents: 1395
diff changeset
   321
                    #component: 
982b813545c8 example
ah
parents: 1395
diff changeset
   322
                     #(#SpecCollection
982b813545c8 example
ah
parents: 1395
diff changeset
   323
                        #collection: 
982b813545c8 example
ah
parents: 1395
diff changeset
   324
                         #(
982b813545c8 example
ah
parents: 1395
diff changeset
   325
                           #(#InputFieldSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   326
                              #name: 'RedField'
982b813545c8 example
ah
parents: 1395
diff changeset
   327
                              #model: #red
982b813545c8 example
ah
parents: 1395
diff changeset
   328
                              #type: #numberInRange
982b813545c8 example
ah
parents: 1395
diff changeset
   329
                              #numChars: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   330
                              #minValue: 0
982b813545c8 example
ah
parents: 1395
diff changeset
   331
                              #maxValue: 255
982b813545c8 example
ah
parents: 1395
diff changeset
   332
                              #extent: #(#Point 38 20)
982b813545c8 example
ah
parents: 1395
diff changeset
   333
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   334
                           #(#InputFieldSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   335
                              #name: 'GreenField'
982b813545c8 example
ah
parents: 1395
diff changeset
   336
                              #model: #green
982b813545c8 example
ah
parents: 1395
diff changeset
   337
                              #type: #numberInRange
982b813545c8 example
ah
parents: 1395
diff changeset
   338
                              #numChars: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   339
                              #minValue: 0
982b813545c8 example
ah
parents: 1395
diff changeset
   340
                              #maxValue: 255
982b813545c8 example
ah
parents: 1395
diff changeset
   341
                              #extent: #(#Point 38 20)
982b813545c8 example
ah
parents: 1395
diff changeset
   342
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   343
                           #(#InputFieldSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   344
                              #name: 'BlueField'
982b813545c8 example
ah
parents: 1395
diff changeset
   345
                              #model: #blue
982b813545c8 example
ah
parents: 1395
diff changeset
   346
                              #type: #numberInRange
982b813545c8 example
ah
parents: 1395
diff changeset
   347
                              #numChars: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   348
                              #minValue: 0
982b813545c8 example
ah
parents: 1395
diff changeset
   349
                              #maxValue: 255
982b813545c8 example
ah
parents: 1395
diff changeset
   350
                              #extent: #(#Point 38 20)
982b813545c8 example
ah
parents: 1395
diff changeset
   351
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   352
                        )
982b813545c8 example
ah
parents: 1395
diff changeset
   353
                    )
982b813545c8 example
ah
parents: 1395
diff changeset
   354
                    #horizontalLayout: #fit
982b813545c8 example
ah
parents: 1395
diff changeset
   355
                    #verticalLayout: #spreadSpace
982b813545c8 example
ah
parents: 1395
diff changeset
   356
                    #horizontalSpace: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   357
                    #verticalSpace: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   358
                )
982b813545c8 example
ah
parents: 1395
diff changeset
   359
                 #(#LabelSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   360
                    #name: 'PreviewBox'
982b813545c8 example
ah
parents: 1395
diff changeset
   361
                    #layout: #(#LayoutFrame -116 1 0 0.0 -2 1.0 -40 1.0)
982b813545c8 example
ah
parents: 1395
diff changeset
   362
                    #label: 'Preview'
982b813545c8 example
ah
parents: 1395
diff changeset
   363
                    #translateLabel: true
982b813545c8 example
ah
parents: 1395
diff changeset
   364
                    #level: -1
982b813545c8 example
ah
parents: 1395
diff changeset
   365
                )
982b813545c8 example
ah
parents: 1395
diff changeset
   366
                 #(#HorizontalPanelViewSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   367
                    #name: 'HorizontalPanel1'
982b813545c8 example
ah
parents: 1395
diff changeset
   368
                    #layout: #(#LayoutFrame 0 0.0 -32 1 0 1.0 0 1.0)
982b813545c8 example
ah
parents: 1395
diff changeset
   369
                    #component: 
982b813545c8 example
ah
parents: 1395
diff changeset
   370
                     #(#SpecCollection
982b813545c8 example
ah
parents: 1395
diff changeset
   371
                        #collection: 
982b813545c8 example
ah
parents: 1395
diff changeset
   372
                         #(
982b813545c8 example
ah
parents: 1395
diff changeset
   373
                           #(#ActionButtonSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   374
                              #name: 'CancelButton'
982b813545c8 example
ah
parents: 1395
diff changeset
   375
                              #label: 'Cancel'
982b813545c8 example
ah
parents: 1395
diff changeset
   376
                              #translateLabel: true
4729
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
   377
                              #model: #doCancel
1406
982b813545c8 example
ah
parents: 1395
diff changeset
   378
                              #extent: #(#Point 165 26)
982b813545c8 example
ah
parents: 1395
diff changeset
   379
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   380
                           #(#ActionButtonSpec
982b813545c8 example
ah
parents: 1395
diff changeset
   381
                              #name: 'OKButton'
982b813545c8 example
ah
parents: 1395
diff changeset
   382
                              #label: 'OK'
982b813545c8 example
ah
parents: 1395
diff changeset
   383
                              #translateLabel: true
4729
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
   384
                              #model: #doAccept
1406
982b813545c8 example
ah
parents: 1395
diff changeset
   385
                              #extent: #(#Point 166 26)
982b813545c8 example
ah
parents: 1395
diff changeset
   386
                          )
982b813545c8 example
ah
parents: 1395
diff changeset
   387
                        )
982b813545c8 example
ah
parents: 1395
diff changeset
   388
                    )
982b813545c8 example
ah
parents: 1395
diff changeset
   389
                    #horizontalLayout: #fitSpace
982b813545c8 example
ah
parents: 1395
diff changeset
   390
                    #verticalLayout: #centerMax
982b813545c8 example
ah
parents: 1395
diff changeset
   391
                    #horizontalSpace: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   392
                    #verticalSpace: 3
982b813545c8 example
ah
parents: 1395
diff changeset
   393
                )
982b813545c8 example
ah
parents: 1395
diff changeset
   394
              )
982b813545c8 example
ah
parents: 1395
diff changeset
   395
          )
982b813545c8 example
ah
parents: 1395
diff changeset
   396
      ).
982b813545c8 example
ah
parents: 1395
diff changeset
   397
982b813545c8 example
ah
parents: 1395
diff changeset
   398
    top  := StandardSystemView extent:200@35.
982b813545c8 example
ah
parents: 1395
diff changeset
   399
    menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
982b813545c8 example
ah
parents: 1395
diff changeset
   400
    list := #('foo' 'bar' 'baz' 'hjh' 'kk' 'claus' 'gjhj').
982b813545c8 example
ah
parents: 1395
diff changeset
   401
    sidx := 4.
982b813545c8 example
ah
parents: 1395
diff changeset
   402
    menu bottomInset:(menu preferredExtent y negated).
982b813545c8 example
ah
parents: 1395
diff changeset
   403
    menu contents:(list at:sidx).
982b813545c8 example
ah
parents: 1395
diff changeset
   404
982b813545c8 example
ah
parents: 1395
diff changeset
   405
    widget := SubCanvas new.
4729
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
   406
    widget client:(SimpleDialog new).
1406
982b813545c8 example
ah
parents: 1395
diff changeset
   407
    widget spec:spec.
982b813545c8 example
ah
parents: 1395
diff changeset
   408
    menu menuWidget:widget.
982b813545c8 example
ah
parents: 1395
diff changeset
   409
    top open.
982b813545c8 example
ah
parents: 1395
diff changeset
   410
                                                                                [exEnd]
982b813545c8 example
ah
parents: 1395
diff changeset
   411
982b813545c8 example
ah
parents: 1395
diff changeset
   412
982b813545c8 example
ah
parents: 1395
diff changeset
   413
982b813545c8 example
ah
parents: 1395
diff changeset
   414
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   415
"
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   416
! !
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   417
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   418
!ExtendedComboBox methodsFor:'accessing'!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   419
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   420
contents
4833
2d9306d5cef1 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4831
diff changeset
   421
    "return the value of the field (the model's value)"
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   422
4833
2d9306d5cef1 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4831
diff changeset
   423
    model isNil ifTrue:[
2d9306d5cef1 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4831
diff changeset
   424
        ^ menuField contents
2d9306d5cef1 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4831
diff changeset
   425
    ].
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   426
    ^ model value
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   427
!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   428
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   429
contents:aValue
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   430
    "set the value of the field (the models value)"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   431
3629
625d247dec4b changed #contents:
Claus Gittinger <cg@exept.de>
parents: 3567
diff changeset
   432
    model notNil ifTrue:[
625d247dec4b changed #contents:
Claus Gittinger <cg@exept.de>
parents: 3567
diff changeset
   433
        model value:aValue.
625d247dec4b changed #contents:
Claus Gittinger <cg@exept.de>
parents: 3567
diff changeset
   434
    ]
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   435
!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   436
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   437
menuExtent
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   438
    ^ menuExtent
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   439
!
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   440
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   441
menuExtent:anExtent
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   442
    menuExtent := anExtent.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   443
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   444
    anExtent notNil ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   445
        menuHeight := nil.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   446
    ] ifFalse:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   447
        menuHeight := anExtent y max:50.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   448
    ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   449
    usePreferredWidthForMenu := true.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   450
!
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
   451
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   452
menuWidget
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   453
    "get the menu widget or nil"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   454
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   455
    ^ menuWidget
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   456
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   457
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   458
menuWidget:aWidgetOrFilenameOrSequenceableCollectionOrNil
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   459
    "set the menu widget or nil.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   460
     In addition (this is a hack), a fileName, seqCollection or menu
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   461
     can be given. In those cases, a corresponding widget is created on the fly and set."
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   462
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   463
    menuWidget ~~ aWidgetOrFilenameOrSequenceableCollectionOrNil ifTrue:[
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   464
        menuWrapper notNil ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   465
            self closeMenu.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   466
            menuWrapper destroy.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   467
            menuWrapper := nil.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   468
        ].
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   469
        aWidgetOrFilenameOrSequenceableCollectionOrNil isView ifTrue:[
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   470
            menuWidget := aWidgetOrFilenameOrSequenceableCollectionOrNil.
2013
3f550c902871 care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents: 1944
diff changeset
   471
            ^ self
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
   472
        ].
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   473
        aWidgetOrFilenameOrSequenceableCollectionOrNil isFilename ifTrue:[
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   474
            self setupMenuWidgetForDirectory:aWidgetOrFilenameOrSequenceableCollectionOrNil.
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   475
            ^ self
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
   476
        ].
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   477
        aWidgetOrFilenameOrSequenceableCollectionOrNil isSequenceable ifTrue:[
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   478
            self setupMenuWidgetForList:aWidgetOrFilenameOrSequenceableCollectionOrNil.
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   479
            ^ self
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   480
        ].
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   481
        (aWidgetOrFilenameOrSequenceableCollectionOrNil isKindOf:Menu) ifTrue:[
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   482
            self setupMenuWidgetForMenu:aWidgetOrFilenameOrSequenceableCollectionOrNil.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   483
            ^ self
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   484
        ].
2904
b0b7eb41d6fa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2903
diff changeset
   485
b0b7eb41d6fa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2903
diff changeset
   486
        aWidgetOrFilenameOrSequenceableCollectionOrNil isNil ifTrue:[
b0b7eb41d6fa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2903
diff changeset
   487
            menuWidget := aWidgetOrFilenameOrSequenceableCollectionOrNil.
b0b7eb41d6fa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2903
diff changeset
   488
            ^ self
b0b7eb41d6fa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2903
diff changeset
   489
        ].
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   490
        self error:'invalid menuWidget'
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   491
    ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   492
! !
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   493
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   494
!ExtendedComboBox methodsFor:'accessing-actions'!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   495
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   496
openAction
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   497
    "returns the action, called before opening the pulldown menu"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   498
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   499
    ^ openAction
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   500
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   501
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   502
openAction:aOneArgBlock
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   503
    "set the action, called before opening the pulldown menu;
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   504
     the argument to the action is the menu widget"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   505
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   506
    openAction := aOneArgBlock
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   507
! !
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   508
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   509
!ExtendedComboBox methodsFor:'accessing-behavior'!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   510
2411
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   511
closeOnSelect
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   512
    "if true, then the comboList is closed when the model value/selection changed"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   513
2411
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   514
    ^ closeOnSelect
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   515
!
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   516
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   517
closeOnSelect:aBoolean
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   518
    "if true, then the comboList is closed when the model value/selection changed"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   519
2411
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   520
    closeOnSelect := aBoolean.
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   521
!
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   522
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   523
disable
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   524
    "disable me and my components"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   525
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   526
    self closeMenu.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   527
2461
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   528
    menuField disable.
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   529
    menuButton disable.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   530
!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   531
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   532
enable
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   533
    "enable me and my components"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   534
2461
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   535
    menuField enable.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   536
    menuButton enable
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   537
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   538
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   539
enabled
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   540
    "returns true, if enabled"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   541
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   542
    ^ menuButton enabled
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   543
!
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   544
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   545
readOnly
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   546
    "returns true if the menuField is readonly"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   547
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   548
    ^ isReadOnly
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   549
!
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   550
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   551
readOnly:aBoolean
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   552
    "set the menuField to be readonly or writable"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   553
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   554
    isReadOnly == aBoolean ifTrue:[ ^ self ].
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   555
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   556
    isReadOnly := aBoolean.
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   557
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   558
    menuField isNil ifTrue:[
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   559
        self createEditField.
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   560
    ].
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   561
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   562
    menuField readOnly:aBoolean.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   563
! !
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   564
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   565
!ExtendedComboBox methodsFor:'accessing-bg & border'!
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   566
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   567
backgroundColor
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   568
    "get the background color of the menu field"
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   569
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   570
    ^ menuField backgroundColor
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   571
!
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   572
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   573
backgroundColor:aColor
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   574
    "set the background color of the menu field"
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   575
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   576
    menuField backgroundColor:aColor
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   577
!
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   578
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   579
foregroundColor
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   580
    "return the foreground color of the menu field"
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   581
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   582
    ^ menuField foregroundColor
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   583
!
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   584
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   585
foregroundColor:aColor
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   586
    "set the foreground color of the menu field"
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   587
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   588
    menuField foregroundColor:aColor
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   589
! !
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   590
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   591
!ExtendedComboBox methodsFor:'accessing-channels'!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   592
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   593
enableChannel 
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   594
    "return a valueHolder for enable/disable"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   595
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   596
    ^ menuButton enableChannel
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   597
!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   598
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   599
enableChannel:aValueHolder 
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   600
    "set a valueHolder for enable/disable"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   601
2461
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   602
    menuField enableChannel:aValueHolder.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   603
    menuButton enableChannel:aValueHolder.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   604
!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   605
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   606
menuWidgetHolder
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   607
    "returns the menu widget or nil"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   608
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   609
    ^ menuWidgetHolder
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   610
!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   611
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   612
menuWidgetHolder:aHolder
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   613
    "returns the menu widget or nil"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   614
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   615
    menuWidgetHolder notNil ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   616
        menuWidgetHolder removeDependent:self
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   617
    ].
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   618
    menuWidgetHolder := aHolder.
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   619
    menuWidgetHolder notNil ifTrue:[
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   620
        menuWidgetHolder addDependent:self
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   621
    ].
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   622
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   623
    self menuWidget:(menuWidgetHolder value).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   624
!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   625
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   626
model:aModel
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   627
    "set the model"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   628
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   629
    super model:(aModel ? ValueHolder new).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   630
    menuField notNil ifTrue:[ menuField model:model ].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   631
! !
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   632
1848
5256c7de1045 access to input-field
Claus Gittinger <cg@exept.de>
parents: 1847
diff changeset
   633
!ExtendedComboBox methodsFor:'accessing-components'!
5256c7de1045 access to input-field
Claus Gittinger <cg@exept.de>
parents: 1847
diff changeset
   634
2461
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   635
editor
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   636
    ^ menuField
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   637
!
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   638
5575
f1a000b27035 #BUGFIX by mawalch
mawalch
parents: 5518
diff changeset
   639
menuButton
f1a000b27035 #BUGFIX by mawalch
mawalch
parents: 5518
diff changeset
   640
    "return the menuButton component"
f1a000b27035 #BUGFIX by mawalch
mawalch
parents: 5518
diff changeset
   641
f1a000b27035 #BUGFIX by mawalch
mawalch
parents: 5518
diff changeset
   642
    ^ menuButton
f1a000b27035 #BUGFIX by mawalch
mawalch
parents: 5518
diff changeset
   643
f1a000b27035 #BUGFIX by mawalch
mawalch
parents: 5518
diff changeset
   644
    "Created: 28.2.1996 / 15:03:14 / cg"
f1a000b27035 #BUGFIX by mawalch
mawalch
parents: 5518
diff changeset
   645
!
f1a000b27035 #BUGFIX by mawalch
mawalch
parents: 5518
diff changeset
   646
1848
5256c7de1045 access to input-field
Claus Gittinger <cg@exept.de>
parents: 1847
diff changeset
   647
menuField
2707
8643fcf4e814 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 2472
diff changeset
   648
    <resource: #obsolete>
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   649
2461
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   650
    self obsoleteMethodWarning:'Use #editor for ComboBox compatibility'.
1848
5256c7de1045 access to input-field
Claus Gittinger <cg@exept.de>
parents: 1847
diff changeset
   651
    ^ menuField
1857
3c1a9729f46c popup menu holder added
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
   652
!
3c1a9729f46c popup menu holder added
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
   653
3c1a9729f46c popup menu holder added
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
   654
menuHolder:anObject
3c1a9729f46c popup menu holder added
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
   655
    "change the one that provides the menu (via menuMsg)."
3c1a9729f46c popup menu holder added
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
   656
3c1a9729f46c popup menu holder added
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
   657
    super menuHolder:anObject.
2461
208fed751e87 do not use a Label if readOnly;
tm
parents: 2411
diff changeset
   658
    menuField notNil ifTrue:[  
1857
3c1a9729f46c popup menu holder added
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
   659
        menuField menuHolder:anObject
3c1a9729f46c popup menu holder added
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
   660
    ]
1848
5256c7de1045 access to input-field
Claus Gittinger <cg@exept.de>
parents: 1847
diff changeset
   661
! !
5256c7de1045 access to input-field
Claus Gittinger <cg@exept.de>
parents: 1847
diff changeset
   662
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   663
!ExtendedComboBox methodsFor:'accessing-default menus'!
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   664
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   665
directory:aDirectory
3646
1c9015f99ef3 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3629
diff changeset
   666
    <resource: #obsolete>
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   667
    "creates a FileSelectionTree as menuWidget - menu, setting the root to the directory"
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   668
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   669
    self obsoleteMethodWarning:'use #setupMenuWidgetForDirectory:'.
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   670
    self setupMenuWidgetForDirectory:aDirectory
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   671
!
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   672
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   673
list:aList
3646
1c9015f99ef3 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3629
diff changeset
   674
    <resource: #obsolete>
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   675
    "creates a SelectionInListView as menuWidget - menu setting the list"
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   676
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   677
    self obsoleteMethodWarning:'use #setupMenuWidgetForList:'.
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   678
    self setupMenuWidgetForList:aList
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   679
!
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   680
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   681
setupMenuWidgetForDirectory:aDirectory
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   682
    "creates a FileSelectionTree as menuWidget - setting the root to the directory"
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   683
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   684
    menuWidget isNil ifTrue:[
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   685
        self autoHideScrollBars:false.
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   686
        menuWidget := FileSelectionTree new.
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   687
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   688
        menuWidget doubleClickAction:[:aDummy||node|
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   689
            node := menuWidget selectedNode.
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   690
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   691
            node isDirectory ifFalse:[
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   692
                self contents:(node pathName)
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   693
            ]
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   694
        ]
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   695
    ].
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   696
    self menuHeight:400.
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   697
    menuWidget directory:aDirectory.
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   698
!
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   699
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   700
setupMenuWidgetForList:aList
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   701
    "creates a SelectionInListView as menuWidget - menu setting the list"
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   702
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   703
    menuWidget isNil ifTrue:[
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
   704
        menuWidget := SelectionInListView onDevice:(device ? Screen current).
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   705
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   706
        menuWidget doubleClickAction:[:anIndex| 
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   707
            self contents:(menuWidget at:anIndex)
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   708
        ]
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   709
    ].
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   710
    menuWidget list:aList
6178
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   711
!
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   712
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   713
setupMenuWidgetForMenu:aMenu
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   714
    "creates a MenuView as menuWidget"
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   715
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   716
    menuWidget isNil ifTrue:[
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   717
        menuWidget := MenuPanel new.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   718
        menuWidget verticalLayout:true.
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   719
        "/ menuWidget doubleClickAction:[:anIndex| 
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   720
        "/     self contents:(menuWidget at:anIndex)
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   721
        "/ ]
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   722
    ].
4227070538b7 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6154
diff changeset
   723
    menuWidget menu:aMenu
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   724
! !
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   725
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   726
!ExtendedComboBox methodsFor:'accessing-dimension'!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   727
5944
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   728
computePreferredExtent
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   729
    "compute & return the preferredExtent from the components' preferrences"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   730
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   731
    |fieldPref buttonPref m w h f|
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   732
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   733
    fieldPref  := menuField preferredExtent.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   734
    buttonPref := menuButton preferredExtent.
4498
e79dad5cc686 class: ExtendedComboBox
Stefan Vogel <sv@exept.de>
parents: 4166
diff changeset
   735
    f := 2 + gc font maxHeight + (gc font maxDescent * 2) + (menuField margin * 2).
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   736
    h := (fieldPref y max:f) max:buttonPref y.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   737
    m := margin max:1.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   738
    h := h + m + m.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   739
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   740
    w := (fieldPref x max:100) + buttonPref x.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   741
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   742
    menuWidget notNil ifTrue:[
3420
d112104710bb added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3289
diff changeset
   743
        f := menuWidget preferredWidth "widthOfContents" + buttonPref x + 20.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   744
        w := f max:w
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   745
    ].
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   746
    w := w + margin + margin.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   747
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   748
    ^ w @ h
5944
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   749
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   750
    "Created: / 09-11-2018 / 19:52:16 / Claus Gittinger"
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   751
!
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   752
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   753
menuHeight
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   754
    "get the maximum height of the menu widget or nil"
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   755
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   756
    ^ menuHeight
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   757
!
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   758
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   759
menuHeight:aHeight
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   760
    "set the maximum height of the menu widget or nil"
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   761
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
   762
    menuHeight := aHeight.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   763
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   764
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   765
usePreferredWidthForMenu
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   766
    "returns true if the menu is to be opened with its menu preferred width"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   767
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   768
    ^ usePreferredWidthForMenu
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   769
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   770
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   771
usePreferredWidthForMenu:aBoolean
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   772
    "open the menu with its preferred width"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   773
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   774
    usePreferredWidthForMenu := aBoolean
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   775
! !
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   776
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   777
!ExtendedComboBox methodsFor:'accessing-look'!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   778
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   779
adjust
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   780
    "returns the button-adjust symbol, which is one of
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   781
         #left  -> left adjust  
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   782
         #right -> right adjust"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   783
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   784
    ^ adjust ? #right
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   785
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   786
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   787
adjust:how
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   788
    "set the button-adjust, which must be one of
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   789
         #left  -> left adjust  
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   790
         #right -> right adjust"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   791
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   792
    |rightInset|
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   793
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   794
    (adjust ~~ how and:[(how == #left or:[how == #right])]) ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   795
        (adjust := how) == #left ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   796
            menuButton origin:0.0@0.0 corner:0.0@1.0
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   797
        ] ifFalse:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   798
            menuButton origin:1.0@0.0 corner:1.0@1.0
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   799
        ].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   800
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   801
        rightInset := menuButton leftInset.
6087
8577d65ffc75 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5944
diff changeset
   802
        menuButton leftInset:(menuButton rightInset) rightInset:rightInset.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   803
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   804
        rightInset := menuField leftInset.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   805
        menuField  leftInset:(menuField rightInset).
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   806
        menuField rightInset:rightInset.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   807
    ].
6087
8577d65ffc75 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5944
diff changeset
   808
8577d65ffc75 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5944
diff changeset
   809
    "Modified: / 16-07-2019 / 16:37:32 / Claus Gittinger"
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   810
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   811
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   812
font:aFont
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   813
    "set the font of the menu field"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   814
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   815
    super font:aFont.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   816
    menuField font:aFont.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   817
! !
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   818
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2173
diff changeset
   819
!ExtendedComboBox methodsFor:'accessing-scrollbars'!
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   820
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   821
autoHideScrollBars
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   822
    "set/clear the flag which controls if scrollBars should
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   823
     be made invisible dynamically, when there is nothing to scroll
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   824
     (and shown if there is)"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   825
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   826
    ^ autoHideScrollBars
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   827
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   828
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   829
autoHideScrollBars:aBoolean
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   830
    "set/clear the flag which controls if scrollBars should
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   831
     be made invisible dynamically, when there is nothing to scroll
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   832
     (and shown if there is)"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   833
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   834
    autoHideScrollBars := aBoolean
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   835
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   836
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   837
hasHorizontalScrollBar
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   838
    "return the horizontal scrollability.
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   839
     If disabled, the horizontal scrollBar is made invisible."
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   840
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   841
    ^ hasHorizontalScrollBar
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   842
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   843
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   844
hasHorizontalScrollBar:aBool
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   845
    "enable/disable horizontal scrollability.
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   846
     If disabled, the horizontal scrollBar is made invisible."
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   847
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   848
    hasHorizontalScrollBar := aBool
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   849
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   850
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   851
hasVerticalScrollBar
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   852
    "return the vertical scrollability.
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   853
     If disabled, the vertical scrollBar is made invisible."
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   854
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   855
    ^ hasVerticalScrollBar
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   856
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   857
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   858
hasVerticalScrollBar:aBool
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   859
    "enable/disable vertical scrollability.
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   860
     If disabled, the vertical scrollBar is made invisible."
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   861
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   862
    hasVerticalScrollBar := aBool
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   863
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   864
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   865
miniScrollerHorizontal
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   866
    "return the flag which controls if the horizontal scrollBar is either a miniScroller,
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   867
     or a full scrollBar."
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   868
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   869
    ^ miniScrollerHorizontal
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   870
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   871
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   872
miniScrollerHorizontal:aBool
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   873
    "control the horizontal scrollBar to be either a miniScroller,
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   874
     or a full scrollBar."
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   875
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   876
    miniScrollerHorizontal := aBool
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   877
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   878
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   879
miniScrollerVertical
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   880
    "return the flag which controls if the vertical scrollBar is either a miniScroller,
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   881
     or a full scrollBar."
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   882
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   883
    ^ miniScrollerVertical
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   884
!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   885
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   886
miniScrollerVertical:aBool
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   887
    "control the vertical scrollBar to be either a miniScroller,
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   888
     or a full scrollBar."
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   889
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   890
    miniScrollerVertical := aBool
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   891
! !
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   892
2411
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   893
!ExtendedComboBox methodsFor:'change & update'!
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   894
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   895
update:what with:aPara from:aModel
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   896
    "one of my models changed"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   897
2411
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   898
    aModel == self model ifTrue:[
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   899
        closeOnSelect ifTrue:[
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   900
            self closeMenu
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   901
        ].
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   902
        ^ self
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   903
    ].
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   904
    aModel == self menuWidgetHolder ifTrue:[
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   905
        self menuWidget:(aModel value).
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   906
        ^ self
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   907
    ].
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   908
    super update:what with:aPara from:aModel
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   909
! !
47fa3acd65a5 add: #closeOnSelect
ca
parents: 2404
diff changeset
   910
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   911
!ExtendedComboBox methodsFor:'error handling'!
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   912
2890
e302b773ba71 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2849
diff changeset
   913
doesNotUnderstand:aMessage 
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
   914
    "delegate messages to the widget"
2890
e302b773ba71 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2849
diff changeset
   915
    
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   916
    menuWidget notNil ifTrue:[
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   917
        ^ aMessage sendTo:menuWidget
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   918
    ].
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   919
    ^ super doesNotUnderstand:aMessage
2903
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   920
! !
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   921
be9322441131 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   922
!ExtendedComboBox methodsFor:'event handling'!
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   923
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   924
keyPress:key x:x y:y
2890
e302b773ba71 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2849
diff changeset
   925
    "handle a key press event"
e302b773ba71 ugly comments
Claus Gittinger <cg@exept.de>
parents: 2849
diff changeset
   926
2026
3b9f6e0aaad5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
   927
    <resource: #keyboard (#Return)>
3b9f6e0aaad5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
   928
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   929
    (key == Character space or:[key == #Return]) ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   930
        self enabled ifTrue:[
6106
78049c3f344d #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 6087
diff changeset
   931
            self openMenu.
78049c3f344d #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 6087
diff changeset
   932
            ^ self
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   933
        ]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   934
    ] ifFalse:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   935
        super keyPress:key x:x y:y
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   936
    ]
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   937
!
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   938
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   939
processEvent:anEvent
6154
acbfc5e42e07 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
   940
    "return true, if I have consumed the event"
acbfc5e42e07 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
   941
4166
92e2137c5ab2 changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
   942
    <resource: #keyboard (#Escape )>
92e2137c5ab2 changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
   943
3289
7bf0ddb4df39 bugfix - processEvents should have a look for which button is pressed
ca
parents: 3285
diff changeset
   944
    |evView button point x y|
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   945
3844
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   946
    anEvent isKeyPressEvent ifTrue:[
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   947
        anEvent key == #Escape ifTrue:[
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   948
            (menuWrapper notNil and:[menuWrapper realized]) ifTrue:[
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   949
                self closeMenu.
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   950
                ^ true.
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   951
            ]
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   952
        ]
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   953
    ].
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   954
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   955
    anEvent isButtonPressEvent ifFalse:[
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   956
        ^ false
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   957
    ].
3844
e88634883df1 close menu when pressing #Escape key
fm
parents: 3838
diff changeset
   958
6154
acbfc5e42e07 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
   959
    "/ a buttonPress
3289
7bf0ddb4df39 bugfix - processEvents should have a look for which button is pressed
ca
parents: 3285
diff changeset
   960
    button := anEvent state.
7bf0ddb4df39 bugfix - processEvents should have a look for which button is pressed
ca
parents: 3285
diff changeset
   961
    ((button == 1) or:[button == #select]) ifFalse:[
7bf0ddb4df39 bugfix - processEvents should have a look for which button is pressed
ca
parents: 3285
diff changeset
   962
        ^ false
7bf0ddb4df39 bugfix - processEvents should have a look for which button is pressed
ca
parents: 3285
diff changeset
   963
    ].
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   964
    (menuField notNil and:[menuField shown]) ifFalse:[
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   965
        ^ false
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   966
    ].
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   967
    (isReadOnly and:[self enabled]) ifFalse:[
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   968
        ^ false
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   969
    ].
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   970
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   971
    evView := anEvent view.
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   972
    evView isNil ifTrue:[^ false].
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   973
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   974
    point := Point x:(anEvent x) y:(anEvent y).
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   975
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   976
    evView ~~ menuField ifTrue:[
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   977
        (evView isSameOrComponentOf:menuField) ifFalse:[
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   978
            ^ false
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   979
        ].
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
   980
        point := device translatePoint:point fromView:evView toView:menuField.
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   981
    ].
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   982
    x := point x.
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   983
    (x between:0 and:menuField width) ifFalse:[^ false].
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   984
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   985
    y := point y.
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   986
    (y between:0 and:menuField height) ifFalse:[^ false].
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   987
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   988
    self openMenu.
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
   989
    ^ true
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   990
! !
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   991
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   992
!ExtendedComboBox methodsFor:'initialization'!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
   993
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   994
createEditField
4728
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
   995
    |nm fieldLevel|
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
   996
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
   997
    nm := styleSheet name.
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
   998
3282
3f94ea1cf64d test for unspecified menuField before creation
ca
parents: 3237
diff changeset
   999
    menuField isNil ifTrue:[
3f94ea1cf64d test for unspecified menuField before creation
ca
parents: 3237
diff changeset
  1000
        menuField := EditField in:self.
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1001
        menuField borderWidth:0.
3282
3f94ea1cf64d test for unspecified menuField before creation
ca
parents: 3237
diff changeset
  1002
    ].
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1003
    menuField origin:0.0 @ 0.0 corner:1.0 @ 1.0.
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1004
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1005
    styleSheet is3D ifTrue:[
4728
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1006
        (styleSheet at:'comboView.level' default:nil) notNil ifTrue:[
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1007
            fieldLevel := 0.
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1008
        ] ifFalse:[
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1009
            menuField leftInset:(ViewSpacing // 2).
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1010
        ]
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1011
    ].
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1012
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1013
    (nm = #win95 or:[nm = #win98 or:[ nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[
4728
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1014
        fieldLevel := 0.
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1015
        menuField leftInset:0.
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1016
    ].
4728
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1017
    fieldLevel := styleSheet at:'comboView.fieldLevel' default:fieldLevel.
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1018
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1019
    fieldLevel notNil ifTrue:[
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1020
        menuField level:fieldLevel.
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1021
    ].
8e258bf00d45 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4553
diff changeset
  1022
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1023
    menuButton notNil ifTrue:[ menuField rightInset:(menuButton leftInset negated) ].
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1024
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1025
    menuField menuHolder:(self menuHolder).
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1026
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1027
    menuField model:model.
4498
e79dad5cc686 class: ExtendedComboBox
Stefan Vogel <sv@exept.de>
parents: 4166
diff changeset
  1028
    menuField font:self font.
2462
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1029
    self shown ifTrue:[ menuField realize ].
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1030
!
8eaa99008134 checkin from browser
tm
parents: 2461
diff changeset
  1031
2472
dee96e84c441 *** empty log message ***
martin
parents: 2463
diff changeset
  1032
destroy
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1033
    |wgrp|
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1034
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1035
    (wgrp := self windowGroup) notNil ifTrue:[
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1036
       wgrp removePreEventHook:self.
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1037
    ].
2472
dee96e84c441 *** empty log message ***
martin
parents: 2463
diff changeset
  1038
    menuWidget notNil ifTrue:[
dee96e84c441 *** empty log message ***
martin
parents: 2463
diff changeset
  1039
        menuWidget destroy.
dee96e84c441 *** empty log message ***
martin
parents: 2463
diff changeset
  1040
    ].
3828
3c53c3bbcb37 release dependencies when destroyed or released
fm
parents: 3701
diff changeset
  1041
    self menuWidgetHolder:nil.
2472
dee96e84c441 *** empty log message ***
martin
parents: 2463
diff changeset
  1042
    super destroy
dee96e84c441 *** empty log message ***
martin
parents: 2463
diff changeset
  1043
!
dee96e84c441 *** empty log message ***
martin
parents: 2463
diff changeset
  1044
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1045
initStyle
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1046
    super initStyle.
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1047
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1048
    self borderWidth:(EditField defaultBorderWidth).
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1049
    self borderColor:(EditField defaultBorderColor).
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1050
!
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1051
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1052
initialize
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1053
    "setup defaults"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1054
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1055
    |prefExt prefWidth lvl rightInset leftInset halfSpacing nm|
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1056
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1057
    super initialize.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1058
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1059
    closeOnSelect := true.
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1060
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1061
    menuField isNil ifTrue:[
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1062
        self createEditField.
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1063
    ].
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1064
2173
41ed0651d789 use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  1065
    self initializeButton.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1066
    menuButton pressAction:[self openMenu].
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1067
    prefExt   := menuButton preferredExtent.
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1068
    prefWidth := prefExt x.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1069
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1070
    menuButton origin:1.0@0.0 corner:1.0@1.0.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1071
    styleSheet is3D ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1072
        halfSpacing := ViewSpacing // 2.
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1073
        leftInset := rightInset := prefWidth + halfSpacing.
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1074
        (lvl := styleSheet at:#'comboView.level' default:nil) notNil ifTrue:[
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1075
            self level:lvl.
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1076
"/            menuField level:0.
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1077
"/            menuField rightInset:margin.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1078
        ] ifFalse:[
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1079
            menuButton rightInset:halfSpacing.
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1080
"/            menuField leftInset:margin.
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1081
        ].
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1082
    ] ifFalse:[
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1083
        leftInset := prefWidth + menuButton borderWidth.
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1084
        rightInset := prefWidth.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1085
    ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1086
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1087
    "/ what a hack...
1696
f1bae6d68ffe eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents: 1648
diff changeset
  1088
    nm := styleSheet name.
3838
6b3f262cbb73 added: #initStyle
Claus Gittinger <cg@exept.de>
parents: 3829
diff changeset
  1089
    (nm = #win95 or:[nm = #win98 or:[nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1090
        lvl isNil ifTrue:[self level:-1].
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1091
        menuButton rightInset:0.
1696
f1bae6d68ffe eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents: 1648
diff changeset
  1092
        nm ~= #st80 ifTrue:[
3420
d112104710bb added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3289
diff changeset
  1093
            leftInset := (ArrowButton new preferredWidth).
3285
1541e5cf4395 bugfix winXP style
ca
parents: 3282
diff changeset
  1094
            rightInset := leftInset.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1095
        ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1096
    ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1097
    menuButton leftInset:leftInset negated.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1098
    self model:nil.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1099
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1100
    adjust                   := #right.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1101
    usePreferredWidthForMenu := false.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1102
    isReadOnly               := false.
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1103
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1104
    autoHideScrollBars       := true.
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1105
    hasHorizontalScrollBar   := true.
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1106
    hasVerticalScrollBar     := true.
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1107
    miniScrollerHorizontal   := true.
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1108
    miniScrollerVertical     := true.
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1109
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1110
    self readOnly:true.
2173
41ed0651d789 use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  1111
!
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1112
2173
41ed0651d789 use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  1113
initializeButton
41ed0651d789 use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  1114
    menuButton := ComboView comboButtonFor:self.
2157
6cfdf247519a destroy - release
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
  1115
!
6cfdf247519a destroy - release
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
  1116
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1117
realize
3237
50336fd7fbbe test for unspecified windowGroup
ca
parents: 3235
diff changeset
  1118
    |wgrp pullMenuIfClickedOnField|
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1119
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1120
    super realize.
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1121
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1122
    pullMenuIfClickedOnField := styleSheet at:#'comboView.pullMenuIfClickedOnField'
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1123
                   default:[ OperatingSystem isMSWINDOWSlike ].
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1124
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1125
    pullMenuIfClickedOnField == true ifTrue:[
3237
50336fd7fbbe test for unspecified windowGroup
ca
parents: 3235
diff changeset
  1126
        wgrp := self windowGroup.
50336fd7fbbe test for unspecified windowGroup
ca
parents: 3235
diff changeset
  1127
        wgrp notNil ifTrue:[ wgrp addPreEventHook:self ].
3235
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1128
    ].
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1129
!
e38e4be1602e comboView.pullMenuIfClickedOnField
ca
parents: 3134
diff changeset
  1130
2157
6cfdf247519a destroy - release
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
  1131
release
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1132
    "release dependencies"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1133
3828
3c53c3bbcb37 release dependencies when destroyed or released
fm
parents: 3701
diff changeset
  1134
    self menuWidgetHolder:nil.
2157
6cfdf247519a destroy - release
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
  1135
    super release.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1136
! !
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1137
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1138
!ExtendedComboBox methodsFor:'queries'!
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1139
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1140
menuIsScrollable
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1141
    "returns true if the menu is scrollable"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1142
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1143
    ^ (self hasVerticalScrollBar or:[self hasHorizontalScrollBar])
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1144
! !
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1145
4831
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1146
!ExtendedComboBox methodsFor:'testing'!
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1147
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1148
isComboView
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1149
    ^ true
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1150
! !
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1151
1890
b08a2a15cea6 category change
Claus Gittinger <cg@exept.de>
parents: 1868
diff changeset
  1152
!ExtendedComboBox methodsFor:'user interaction'!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1153
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1154
closeMenu
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1155
    "close the menu"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1156
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1157
    |id|
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1158
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1159
    menuWrapper notNil ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1160
        menuWrapper realized ifFalse:[
5916
daccd5012f7e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5575
diff changeset
  1161
            (id := menuWrapper drawableId) notNil ifTrue:[
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
  1162
                device unmapWindow:id
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1163
            ]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1164
        ] ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1165
           menuWrapper unmap
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1166
        ].
1273
0460739b9e97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
  1167
"/        menuWrapper windowGroup:nil.
0460739b9e97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
  1168
"/        self windowGroup removeView:menuWrapper.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1169
    ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1170
    menuButton turnOff.
5916
daccd5012f7e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5575
diff changeset
  1171
daccd5012f7e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5575
diff changeset
  1172
    "Modified: / 01-10-2018 / 17:04:34 / Claus Gittinger"
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1173
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1174
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1175
openMenu
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1176
    "pull the menu - triggered from the button"
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1177
4504
9ac5a87f55dc class: ExtendedComboBox
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1178
    |h w menuOrigin useableExt widgetPrfExt graphicsDevice|
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1179
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
  1180
    openAction notNil ifTrue:[
2069
7891c7d3af69 use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1181
        openAction valueWithOptionalArgument:menuWidget
1274
0f36e87f6b21 add openAction
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
  1182
    ].
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1183
    menuWrapper isNil ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1184
        menuWidget isNil ifTrue:[^ self].
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
  1185
        menuWrapper := MenuWrapper onDevice:(device ? Screen current).
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1186
        menuWrapper for:menuWidget in:self.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1187
    ].
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1188
    menuButton turnOn.
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1189
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
  1190
    graphicsDevice := device.
4504
9ac5a87f55dc class: ExtendedComboBox
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1191
    menuOrigin   := graphicsDevice translatePoint:(0@height) fromView:self toView:nil.
3879
4bd5dba1e6a5 fixed: #openMenu for multiple screen systems with varying heights
Claus Gittinger <cg@exept.de>
parents: 3844
diff changeset
  1192
    "/ notice, the position-dependent query: if there is a higher secondary screen,
4bd5dba1e6a5 fixed: #openMenu for multiple screen systems with varying heights
Claus Gittinger <cg@exept.de>
parents: 3844
diff changeset
  1193
    "/ this makes a difference in where a popUpMenu is allowed...
4bd5dba1e6a5 fixed: #openMenu for multiple screen systems with varying heights
Claus Gittinger <cg@exept.de>
parents: 3844
diff changeset
  1194
    "/ useableExt   := device usableExtent.
4504
9ac5a87f55dc class: ExtendedComboBox
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1195
    useableExt := graphicsDevice usableWidth @ (graphicsDevice usableHeightAt:menuOrigin).
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1196
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1197
    menuExtent notNil ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1198
        widgetPrfExt := menuExtent.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1199
    ] ifFalse:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1200
        widgetPrfExt := menuWrapper preferredExtent.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1201
    ].
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1202
    menuHeight isNil ifTrue:[
1392
2d4a90914f2b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1286
diff changeset
  1203
        menuHeight := (5 + widgetPrfExt y) min:(useableExt y // 2).
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1204
    ].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1205
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1206
    usePreferredWidthForMenu ifFalse:[
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1207
        w := width.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1208
    ] ifTrue:[
1392
2d4a90914f2b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1286
diff changeset
  1209
        (w := widgetPrfExt x+(menuWrapper borderWidth*2)) <= width ifTrue:[
4831
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1210
            "/ w := width
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1211
        ] ifFalse:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1212
            (w + menuOrigin x) > useableExt x ifTrue:[
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1213
                menuOrigin x:((useableExt x - w) max:0)
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1214
            ]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1215
        ]
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1216
    ].
1282
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1217
    "/ nice side-effect; set width first, to allow menuHeight
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1218
    "/ to be a block computing the height based upon the width.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1219
    "/ (allows for geometry adjustments)
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1220
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1221
    menuWrapper width:w.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1222
    h := (useableExt y - menuOrigin y - 4) min:(menuHeight value).
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1223
    menuWrapper height:h.
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1224
4269f064951c allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1225
    menuWrapper origin:menuOrigin extent:(w@h).
6106
78049c3f344d #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 6087
diff changeset
  1226
    menuWrapper beUndecorated.
1273
0460739b9e97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
  1227
    menuWrapper openModal.
2013
3f550c902871 care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents: 1944
diff changeset
  1228
    menuWrapper notNil ifTrue:[
3f550c902871 care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents: 1944
diff changeset
  1229
        menuWrapper realized ifTrue:[
3f550c902871 care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents: 1944
diff changeset
  1230
            self closeMenu
3f550c902871 care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents: 1944
diff changeset
  1231
        ].
1944
a9c42cd2c387 added: close menu if come back from open modal
tm
parents: 1890
diff changeset
  1232
    ].
2022
16e783eb5f2a use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1233
16e783eb5f2a use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1234
    "Modified: / 10.10.2001 / 14:44:22 / cg"
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1235
! !
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1236
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1237
!ExtendedComboBox::MenuWrapper class methodsFor:'documentation'!
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1238
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1239
documentation
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1240
"
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1241
    problem: we have a grab - and get all events;
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1242
    to simulate regular behaior inside, we have to synthetically simulate
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1243
    focus control and implicit grab on buttonPress.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1244
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1245
    [instance variables:]
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1246
        comboBox                <ExtendedComboBox>
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1247
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1248
        widget                  <View>          the widget which contains the menu
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1249
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1250
        lastPointerView         <View>          view which contained the
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1251
                                                mouse pointer.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1252
                                                used for enter/leave event generation.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1253
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1254
        implicitGrabView         <View>         view in which button was pressed;
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1255
                                                nilled when released (wherever).
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1256
                                                If non-nil, all events are forwarded to this
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1257
                                                one (for example to scroll with mouse outside the scrollbar)
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1258
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1259
        eventHandler            <OneArgBlock>   if not nil, the block will
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1260
                                                handle all inputEvents
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1261
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1262
        resizeCursor            <Cursor>        shown for resize handle
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1263
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1264
        restoreCursor           <Cursor>        default cursor
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1265
"
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1266
! !
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1267
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1268
!ExtendedComboBox::MenuWrapper methodsFor:'accessing'!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1269
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1270
application
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1271
    "return the application, under which this view was opened,
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1272
     or nil, if there is no application
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1273
    "
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1274
    ^ comboBox application
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1275
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1276
!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1277
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1278
clearImplicitGrab
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1279
    implicitGrabView := nil
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1280
!
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1281
5944
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
  1282
computePreferredExtent
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1283
    "compute & return the preferredExtent from the components' preferrences
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1284
    "
1284
1fb5f5cbd4d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
  1285
    ^ (widget preferredExtent max:(widget widthOfContents @ widget heightOfContents))
1fb5f5cbd4d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
  1286
      + (margin * 2) + 8.
5944
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
  1287
44e45047d2a5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5916
diff changeset
  1288
    "Created: / 09-11-2018 / 19:52:27 / Claus Gittinger"
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1289
!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1290
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1291
widget
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1292
    "returns the widget wrapped by the menuView
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1293
    "
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1294
    ^ widget
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1295
! !
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1296
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1297
!ExtendedComboBox::MenuWrapper methodsFor:'event handling'!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1298
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1299
dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1300
    "dispatch the event"
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1301
4504
9ac5a87f55dc class: ExtendedComboBox
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1302
    |x y oldGrabber p graphicsDevice|
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1303
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1304
    eventHandler notNil ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1305
        (eventHandler value:event) ifTrue:[^ self].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1306
    ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1307
1830
66c131adec9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
  1308
    (event isInputEvent not
66c131adec9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1713
diff changeset
  1309
    or:[event isPointerEnterLeaveEvent]) ifTrue:[
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1310
        super dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate.
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1311
        ^ self
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1312
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1313
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1314
    event isButtonMotionEvent ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1315
        implicitGrabView isNil ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1316
            (self isEventAssignedToResizeArea:event) ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1317
                self setupResizeEventHandler.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1318
                ^ self.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1319
            ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1320
        ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1321
    ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1322
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1323
    event isButtonPressEvent ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1324
        x := event x.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1325
        y := event y.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1326
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1327
        ((0@0 extent:self extent) containsPoint:(x @ y)) ifFalse:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1328
            comboBox closeMenu.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1329
            "/ if I took the grab from someone else, this buttonEvent should
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1330
            "/ also go to that one ...but not, if it falls into my own ext-comboBox (sigh)
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1331
            "/ (example: a sub-ext-box in an ext-box, clicking on the outer boxes menuButton)
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
  1332
            graphicsDevice := device.
4553
ed70817b44e8 Access graphicsDevice via method send instead of instVar access
Stefan Vogel <sv@exept.de>
parents: 4504
diff changeset
  1333
            (oldGrabber := graphicsDevice activePointerGrab) notNil ifTrue:[
4504
9ac5a87f55dc class: ExtendedComboBox
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1334
                p := graphicsDevice translatePoint:(x@y) fromView:self toView:comboBox.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1335
                ((0@0 extent:comboBox extent) containsPoint:p) ifFalse:[        
4504
9ac5a87f55dc class: ExtendedComboBox
Stefan Vogel <sv@exept.de>
parents: 4498
diff changeset
  1336
                    p := graphicsDevice translatePoint:(x@y) fromView:self toView:oldGrabber.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1337
                    event view:oldGrabber.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1338
                    event x:p x.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1339
                    event y:p y.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1340
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1341
                    "/ this is a hack
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1342
                    oldGrabber class == self class ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1343
                        oldGrabber clearImplicitGrab.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1344
                    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1345
                    oldGrabber dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1346
                ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1347
            ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1348
            ^  self.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1349
        ]
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1350
    ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1351
    self forwardEvent:event withFocusOn:focusViewOrNil.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1352
!
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1353
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1354
forwardEvent:ev withFocusOn:focusView
4729
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  1355
    "handle an event
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1356
    "
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1357
    |view x y p syntheticEvent|
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1358
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1359
    "/ situation: we get a buttonPress, set implicitGrab (for scrollbars etc.)
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1360
    "/ but never get the buttonRelease, since someone else (a popUp) grabbed the
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1361
    "/ pointer in the meantime, and has eaten the release event ... (double-sigh)
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1362
    implicitGrabView notNil ifTrue:[
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1363
        (ev isButtonReleaseEvent or:[self sensor leftButtonPressed]) ifFalse:[
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1364
            implicitGrabView := nil.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1365
        ].
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1366
    ].
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1367
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1368
    ((x := ev x) isNil or:[(y := ev y) isNil]) ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1369
        ^ self
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1370
    ].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1371
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1372
    implicitGrabView notNil ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1373
        ev isButtonEvent ifTrue:[
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
  1374
            p := device translatePoint:(x@y) fromView:self toView:implicitGrabView.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1375
            ev view:implicitGrabView.
2899
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1376
            ev x:p x.
e55595fe6a03 comments
Claus Gittinger <cg@exept.de>
parents: 2890
diff changeset
  1377
            ev y:p y.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1378
            implicitGrabView dispatchEvent:ev withFocusOn:focusView delegate:false.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1379
2900
e49cb2bac7aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2899
diff changeset
  1380
            (ev isButtonReleaseEvent "or:[ev isButtonMultiPressEvent]") ifTrue:[
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1381
                implicitGrabView := nil.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1382
            ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1383
            ^ self
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1384
        ]
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1385
    ].
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1386
4729
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  1387
    ev isKeyPressEvent ifTrue:[
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  1388
        ev key == #Escape ifTrue:[
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  1389
            self hideRequest.
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  1390
            ^ self.
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  1391
        ].
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  1392
    ].
c0f052e4f414 class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  1393
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1394
    view := self detectViewAtX:x y:y.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1395
    view isNil ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1396
        ^ super dispatchEvent:ev withFocusOn:focusView delegate:false
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1397
    ].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1398
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
  1399
    p := device translatePoint:(x@y) fromView:self toView:view.
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1400
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1401
    ev isButtonPressEvent ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1402
        (view wantsFocusWithButtonPress) ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1403
            view requestFocus.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1404
        ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1405
        view ~~ self ifTrue:[ "/ can this ever be self ?
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1406
            implicitGrabView := view.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1407
        ]
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1408
    ].
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1409
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1410
    ev isButtonMotionEvent ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1411
        lastPointerView ~~ view ifTrue:[
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1412
            "/ must generate enter/leave ... (sigh)
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1413
            lastPointerView notNil ifTrue:[
2125
67e0f2c9ad4d event types are private to WindowEvent;
ca
parents: 2069
diff changeset
  1414
                "/ XXX: should be fixed
6147
486df069a8cd #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6109
diff changeset
  1415
                syntheticEvent := WindowEvent pointerLeave:0 view:lastPointerView.
486df069a8cd #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6109
diff changeset
  1416
                syntheticEvent delegatedFrom:self.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1417
                lastPointerView dispatchEvent:syntheticEvent withFocusOn:nil delegate:false.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1418
            ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1419
            view notNil ifTrue:[
2125
67e0f2c9ad4d event types are private to WindowEvent;
ca
parents: 2069
diff changeset
  1420
                syntheticEvent := WindowEvent pointerEnter:0 x:x y:y view:view.
6147
486df069a8cd #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6109
diff changeset
  1421
                syntheticEvent delegatedFrom:self.
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1422
                view dispatchEvent:syntheticEvent withFocusOn:nil delegate:false.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1423
            ].
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1424
            lastPointerView := view.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1425
        ].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1426
    ].
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1427
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1428
    ev view:view.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1429
    ev x:p x.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1430
    ev y:p y.
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1431
    view dispatchEvent:ev withFocusOn:focusView delegate:false.
2022
16e783eb5f2a use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1432
16e783eb5f2a use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1433
    "Modified: / 10.10.2001 / 13:54:20 / cg"
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1434
!
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1435
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1436
setupResizeEventHandler
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1437
    |clickExtent clickPoint|
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1438
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1439
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1440
    self windowGroup showCursor:resizeCursor.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1441
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1442
    eventHandler := [:ev|
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1443
        ev isButtonEvent ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1444
            clickPoint notNil ifTrue:[
3469
afe2dab00abb pretty print fix
fm
parents: 3420
diff changeset
  1445
                ev isButtonMotionEvent ifTrue:[ 
afe2dab00abb pretty print fix
fm
parents: 3420
diff changeset
  1446
                    |offset extent|
afe2dab00abb pretty print fix
fm
parents: 3420
diff changeset
  1447
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1448
                    offset := self sensor mousePoint - clickPoint.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1449
                    extent := (clickExtent + offset) max:(comboBox width)@50.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1450
                    self extent:extent.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1451
                ] ifFalse:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1452
                    ev isButtonReleaseEvent ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1453
                        comboBox menuExtent:self extent.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1454
                    ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1455
                    clickPoint := clickExtent := nil.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1456
                ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1457
            ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1458
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1459
            clickPoint isNil ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1460
                ev isButtonMotionEvent ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1461
                    (self isEventAssignedToResizeArea:ev) ifFalse:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1462
                        self windowGroup showCursor:restoreCursor.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1463
                        clickPoint := clickExtent := eventHandler := nil.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1464
                    ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1465
                ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1466
                ev isButtonPressEvent ifTrue:[  "/ start resize
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1467
                    clickPoint  := self sensor mousePoint.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1468
                    clickExtent := self extent.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1469
                ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1470
            ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1471
        ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1472
        ev isInputEvent
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1473
    ].
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1474
! !
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1475
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1476
!ExtendedComboBox::MenuWrapper methodsFor:'focus handling'!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1477
1630
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1478
wantsFocusWithButtonPress
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1479
    "views which do not like to take the keyboard focus
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1480
     with buttonPress can do so by redefining this
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1481
     to return false"
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1482
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1483
    ^ false
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1484
01dc20096011 grabbing cleaned up;
ca
parents: 1614
diff changeset
  1485
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1486
! !
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1487
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1488
!ExtendedComboBox::MenuWrapper methodsFor:'initialization'!
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1489
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1490
for:aWidget in:aReceiver 
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1491
    "create a wrapper for a widget and the receiver, an extented comboBox
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1492
    "
3829
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1493
    |hasScr isAdded|
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1494
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1495
    comboBox := aReceiver.
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1496
    widget   := aWidget.
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1497
    hasScr   := aWidget isScrollWrapper.
3829
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1498
    isAdded  := false.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1499
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1500
    comboBox menuIsScrollable ifTrue:[
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1501
        hasScr ifFalse:[
3829
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1502
            "/ we have to add the scrooledView to self before
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1503
            "/ setting the scrolledView - application should
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1504
            "/ derive from my comboBox (build within subCanvas)
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1505
            widget := ScrollableView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:self.
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1506
            widget scrolledView:aWidget.
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1507
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1508
            hasScr := isAdded := true.
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1509
        ].
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1510
        widget horizontalScrollable:(comboBox hasHorizontalScrollBar).
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1511
        widget   verticalScrollable:(comboBox hasVerticalScrollBar).
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1512
        widget       horizontalMini:(comboBox miniScrollerHorizontal).
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1513
        widget         verticalMini:(comboBox miniScrollerVertical).
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1514
        widget   autoHideScrollBars:(comboBox autoHideScrollBars).
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1515
    ].
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1516
3829
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1517
    isAdded ifFalse:[
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1518
        widget origin:0.0 @ 0.0 corner:1.0 @ 1.0.
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1519
        self add:widget.
b408134570d5 MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents: 3828
diff changeset
  1520
    ].
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1521
    hasScr ifTrue:[
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1522
        widget level:0.
1272
c3eb38fa149d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
  1523
        widget := widget scrolledView.
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1524
    ].    
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1525
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1526
1273
0460739b9e97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
  1527
hideRequest
0460739b9e97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
  1528
    "hide request from windowGroup (i.e. via Escape key).
5313
0bf66dd418b5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
  1529
     Can be redefined in subclasses which don't like this"
1273
0460739b9e97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
  1530
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1531
    eventHandler := nil.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1532
    comboBox closeMenu.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1533
!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1534
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1535
initialize
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1536
    super initialize.
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1537
    super level:0.
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1538
    super borderWidth:1.
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1539
    self enableMotionEvents.
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1540
!
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1541
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1542
level:aNumber
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1543
!
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1544
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1545
mapped
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1546
    "grab resources (mouse and keyboard)
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1547
    "
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1548
    eventHandler := nil.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1549
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1550
    resizeCursor isNil ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1551
        restoreCursor := self cursor.
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
  1552
        resizeCursor  := Cursor fourWay onDevice:device.
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1553
    ].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1554
    super mapped.
2709
c43fad2a54c4 initial focus
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
  1555
    self assignInitialKeyboardFocus.
1868
445f3285bbb2 checkin from browser
ca
parents: 1857
diff changeset
  1556
    widget notNil ifTrue:[widget level:0].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1557
! !
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1558
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1559
!ExtendedComboBox::MenuWrapper methodsFor:'queries'!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1560
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1561
isEventAssignedToResizeArea:ev
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1562
    |x y|
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1563
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1564
    ((x := ev x) notNil and:[(y := ev y) notNil]) ifTrue:[ |evView|
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1565
        evView := ev view.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1566
        
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1567
        evView ~~ self ifTrue:[ |p|
4992
635f9ede0c38 device access
Claus Gittinger <cg@exept.de>
parents: 4833
diff changeset
  1568
            p := device translatePoint:(x@y) fromView:evView toView:self.
3134
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1569
            x := p x.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1570
            y := p y.
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1571
        ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1572
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1573
        (x - width)  abs <= 5 ifTrue:[
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1574
            (y - height) abs <= 5 ifTrue:[^ true].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1575
        ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1576
    ].
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1577
    ^ false
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1578
!
d0a3d82a5bcd support resizing popup widget
ca
parents: 2904
diff changeset
  1579
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1580
raiseDeiconified
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1581
    ^ self raise
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1582
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1583
!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1584
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1585
type
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1586
    ^ nil.
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1587
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1588
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1589
! !
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1590
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1591
!ExtendedComboBox::MenuWrapper methodsFor:'searching'!
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1592
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1593
detectViewAtX:x y:y
1224
f499a42e072d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1594
    "detect view at x@y. if no view is detected or
5518
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1595
     it is my view, nil is returned"
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1596
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1597
    |v|
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1598
5518
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1599
    (x notNil and:[y notNil 
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1600
     and:[(x between:0 and:width) 
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1601
     and:[y between:0 and:height]]]) ifTrue:[
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1602
        v := self detectViewAt:x@y.
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1603
        v ~~ self ifTrue:[
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1604
            ^ v
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1605
        ].
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1606
    ].
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1607
    ^ nil
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1608
5518
bfc9d39b42c0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5443
diff changeset
  1609
    "Modified (comment): / 15-03-2017 / 20:46:45 / stefan"
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1610
! !
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1611
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1612
!ExtendedComboBox class methodsFor:'documentation'!
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1613
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1614
version
4831
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1615
    ^ '$Header$'
3828
3c53c3bbcb37 release dependencies when destroyed or released
fm
parents: 3701
diff changeset
  1616
!
3c53c3bbcb37 release dependencies when destroyed or released
fm
parents: 3701
diff changeset
  1617
3c53c3bbcb37 release dependencies when destroyed or released
fm
parents: 3701
diff changeset
  1618
version_CVS
4831
d4bbefd9f9ca class: ExtendedComboBox
Claus Gittinger <cg@exept.de>
parents: 4729
diff changeset
  1619
    ^ '$Header$'
1179
fd1e5968db2f initial checkin
ps
parents:
diff changeset
  1620
! !
4166
92e2137c5ab2 changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  1621