|
Class: ExtendedComboBox
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ExtendedComboBox
- Package:
- stx:libwidg2
- Category:
- Views-Interactors
- Version:
- rev:
1.99
date: 2024/03/18 12:54:40
- user: cg
- file: ExtendedComboBox.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
An ExtendedComboBox looks much like a ComboBox, but allows for any view
to be popped up
(in contrast to a ComboBox, which has a hardWired selectionInListmenu).
The popped view may optionally be decorated with scrollBars.
As a side effect, an ExtendedComboBox with a SelectionInListView or Menu
can now be used as a replacement for ComboBoxes when long-lists are to be shown,
since those can now be scrolled or defined as hierarchical lists.
copyrightCOPYRIGHT (c) 1998 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
accessing
-
contents
-
return the value of the field (the model's value)
-
contents: aValue
-
set the value of the field (the models value)
-
menuExtent
-
-
menuExtent: anExtent
-
-
menuWidget
-
get the menu widget or nil
-
menuWidget: aWidgetOrFilenameOrSequenceableCollectionOrNil
-
set the menu widget or nil.
In addition (this is a hack), a fileName, seqCollection or menu
can be given. In those cases, a corresponding widget is created on the fly and set.
accessing-actions
-
openAction
-
returns the action, called before opening the pulldown menu
-
openAction: aOneArgBlock
-
set the action, called before opening the pulldown menu;
the argument to the action is the menu widget
accessing-behavior
-
closeOnSelect
-
if true, then the comboList is closed when the model value/selection changed
-
closeOnSelect: aBoolean
-
if true, then the comboList is closed when the model value/selection changed
-
enabled
-
returns true, if enabled
-
enabled: aBoolean
-
enable/disable me and my components
-
readOnly
-
returns true if the menuField is readonly
-
readOnly: aBoolean
-
set the menuField to be readonly or writable
accessing-bg & border
-
backgroundColor
-
get the background color of the menu field
-
backgroundColor: aColor
-
set the background color of the menu field
-
foregroundColor
-
return the foreground color of the menu field
-
foregroundColor: aColor
-
set the foreground color of the menu field
accessing-channels
-
enableChannel
-
return a valueHolder for enable/disable
-
enableChannel: aValueHolder
-
set a valueHolder for enable/disable
-
menuWidgetHolder
-
returns the menu widget or nil
-
menuWidgetHolder: aHolder
-
returns the menu widget or nil
-
model: aModel
-
set the model
accessing-components
-
editor
-
-
menuButton
-
return the menuButton component
-
menuField
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
menuHolder: anObject
-
change the one that provides the menu (via menuMsg).
accessing-default menus
-
directory: aDirectory
-
creates a FileSelectionTree as menuWidget - menu, setting the root to the directory
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
list: aList
-
creates a SelectionInListView as menuWidget - menu setting the list
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
setupMenuWidgetForDirectory: aDirectory
-
creates a FileSelectionTree as menuWidget - setting the root to the directory
-
setupMenuWidgetForList: aList
-
creates a SelectionInListView as menuWidget - menu setting the list
-
setupMenuWidgetForMenu: aMenu
-
creates a MenuView as menuWidget
accessing-dimension
-
computePreferredExtent
-
compute & return the preferredExtent from the components' preferrences
-
menuHeight
-
get the maximum height of the menu widget or nil
-
menuHeight: aHeight
-
set the maximum height of the menu widget or nil
-
usePreferredWidthForMenu
-
returns true if the menu is to be opened with its menu preferred width
-
usePreferredWidthForMenu: aBoolean
-
open the menu with its preferred width
accessing-look
-
adjust
-
returns the button-adjust symbol, which is one of
#left -> left adjust
#right -> right adjust
-
adjust: how
-
set the button-adjust, which must be one of
#left -> left adjust
#right -> right adjust
-
font: aFont
-
set the font of the menu field
accessing-scrollbars
-
autoHideScrollBars
-
set/clear the flag which controls if scrollBars should
be made invisible dynamically, when there is nothing to scroll
(and shown if there is)
-
autoHideScrollBars: aBoolean
-
set/clear the flag which controls if scrollBars should
be made invisible dynamically, when there is nothing to scroll
(and shown if there is)
-
hasHorizontalScrollBar
-
return the horizontal scrollability.
If disabled, the horizontal scrollBar is made invisible.
-
hasHorizontalScrollBar: aBool
-
enable/disable horizontal scrollability.
If disabled, the horizontal scrollBar is made invisible.
-
hasVerticalScrollBar
-
return the vertical scrollability.
If disabled, the vertical scrollBar is made invisible.
-
hasVerticalScrollBar: aBool
-
enable/disable vertical scrollability.
If disabled, the vertical scrollBar is made invisible.
-
miniScrollerHorizontal
-
return the flag which controls if the horizontal scrollBar is either a miniScroller,
or a full scrollBar.
-
miniScrollerHorizontal: aBool
-
control the horizontal scrollBar to be either a miniScroller,
or a full scrollBar.
-
miniScrollerVertical
-
return the flag which controls if the vertical scrollBar is either a miniScroller,
or a full scrollBar.
-
miniScrollerVertical: aBool
-
control the vertical scrollBar to be either a miniScroller,
or a full scrollBar.
change & update
-
update: what with: aPara from: aModel
-
one of my models changed
error handling
-
doesNotUnderstand: aMessage
-
delegate messages to the widget
event handling
-
keyPress: key x: x y: y
-
handle a key press event
-
processEvent: anEvent
-
return true, if I have consumed the event
initialization
-
createEditField
-
-
destroy
-
(comment from inherited method)
unmap & destroy - make me invisible, destroy subviews then
make me unknown to the device
-
initStyle
-
(comment from inherited method)
this method sets up all style dependent things.
If redefined, make sure that super initStyle is sent
-
initialize
-
setup defaults
-
initializeButton
-
-
realize
-
(comment from inherited method)
realize - make visible;
realizing is done very late (after layout is fixed) to avoid
visible rearranging of windows on the screen
-
release
-
release dependencies
queries
-
menuIsScrollable
-
returns true if the menu is scrollable
testing
-
isComboView
-
yes, I am a comboBox-like widget
user interaction
-
closeMenu
-
close the menu
-
openMenu
-
pull the menu - triggered from the button
MenuWrapper
example: SelectionInListView
|top menu widget list sidx|
top := StandardSystemView extent:200@35.
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
list := #('foo' 'bar' 'baz' 'hjh' 'kk' 'claus' 'gjhj').
sidx := 4.
menu bottomInset:(menu preferredExtent y negated).
menu contents:(list at:sidx).
widget := SelectionInListView new.
widget list:list.
widget doubleClickAction:[:i| menu contents:(widget at:i) ].
widget selection:sidx.
menu menuWidget:widget.
top open.
|
example: FileSelectionTree
|top menu widget|
top := StandardSystemView extent:200@35.
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
menu bottomInset:(menu preferredExtent y negated).
widget := FileSelectionTree new.
widget directory:(Filename homeDirectory).
widget doubleClickAction:[:i||n|
n := widget selectedNode.
n isDirectory ifFalse:[menu contents:(n pathName)]
].
menu menuHeight:400.
menu menuWidget:widget.
top open.
|
example: SelectionInTreeView
|top menu widget|
top := StandardSystemView extent:200@35.
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
menu bottomInset:(menu preferredExtent y negated).
menu contents:'foo'.
widget := SelectionInTreeView new.
widget root:(TreeItem newAsTreeFromSmalltalkClass:Object).
widget doubleClickAction:[:i||n|
n := widget selectedNode.
n hasChildren ifFalse:[menu contents:(n name)]
].
menu menuHeight:300.
menu menuWidget:widget.
top open.
|
example: a menu from elsewhere
|top menu widget models|
models := Expecco::Browser openBrowsers
collectAll:[:b | b project
ifNil:[#()]
ifNotNil:[:p | p allBlockDescriptions]].
top := StandardSystemView extent:250@35.
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
menu bottomInset:(menu preferredExtent y negated).
menu contents:'lets do the timeWarp again...'.
widget := Workflow::AbstractEditor
dataTypeMenuFor:models receiver:nil selector:[:type | menu contents:type]
editorSelector:nil
withTemplateTypes:false
withUserTypeDefinition:false
forFreeze:false.
menu menuWidget:widget.
top open.
|
example: Funny
|top menu widget|
Smalltalk loadPackage:'stx:libwidg3'.
top := StandardSystemView extent:250@35.
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
menu bottomInset:(menu preferredExtent y negated).
menu contents:'lets do the timeWarp again...'.
widget := ClockView new.
menu menuHeight:[menu width].
menu menuWidget:widget.
top open.
|
example: Funny - again
(use widgets pref-width; even if the combo-box is smaller)
|top menu widget|
top := StandardSystemView extent:80@35.
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
menu bottomInset:(menu preferredExtent y negated).
menu contents:'time...'.
widget := ClockView new.
menu menuWidget:widget.
menu usePreferredWidthForMenu:true.
top open.
|
example: Funny - again
(use widgets pref-width; even if the combo-box is smaller,
adjust the height for the width)
|top menu widget|
top := StandardSystemView extent:80@35.
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
menu bottomInset:(menu preferredExtent y negated).
menu contents:'time...'.
widget := ClockView new.
menu menuWidget:widget.
menu usePreferredWidthForMenu:true.
menu menuHeight:[widget width].
top open.
|
example: Subcanvas with a spec
|top menu widget list sidx spec|
spec := #(#FullSpec
#window:
#(#WindowSpec
#name: 'Define Color'
#layout: #(#LayoutFrame 13 0 29 0 352 0 159 0)
#label: 'Define Color'
#min: #(#Point 340 110)
#max: #(#Point 1152 900)
#bounds: #(#Rectangle 13 29 353 160)
#usePreferredExtent: false
)
#component:
#(#SpecCollection
#collection:
#(
#(#VerticalPanelViewSpec
#name: 'VerticalPanel1'
#layout: #(#LayoutFrame 0 0.0 0 0.0 58 0 -40 1.0)
#component:
#(#SpecCollection
#collection:
#(
#(#LabelSpec
#name: 'RedLabel'
#label: 'Red:'
#translateLabel: true
#adjust: #right
#extent: #(#Point 58 26)
)
#(#LabelSpec
#name: 'GreenLabel'
#label: 'Green:'
#translateLabel: true
#adjust: #right
#extent: #(#Point 58 27)
)
#(#LabelSpec
#name: 'BlueLabel'
#label: 'Blue:'
#translateLabel: true
#adjust: #right
#extent: #(#Point 58 26)
)
)
)
#horizontalLayout: #fit
#verticalLayout: #fitSpace
#horizontalSpace: 3
#verticalSpace: 3
)
#(#VerticalPanelViewSpec
#name: 'VerticalPanel2'
#layout: #(#LayoutFrame 60 0 0 0.0 -160 1.0 -40 1.0)
#component:
#(#SpecCollection
#collection:
#(
#(#SliderSpec
#name: 'RedSlider'
#tabable: true
#model: #red
#orientation: #horizontal
#stop: 255
#step: 1
#backgroundColor: #(#Color 100.0 0.0 0.0)
#extent: #(#Point 118 16)
)
#(#SliderSpec
#name: 'GreenSlider'
#tabable: true
#model: #green
#orientation: #horizontal
#stop: 255
#step: 1
#backgroundColor: #(#Color 0.0 100.0 0.0)
#extent: #(#Point 118 16)
)
#(#SliderSpec
#name: 'BlueSlider'
#tabable: true
#model: #blue
#orientation: #horizontal
#stop: 255
#step: 1
#backgroundColor: #(#Color 0.0 0.0 100.0)
#extent: #(#Point 118 16)
)
)
)
#horizontalLayout: #fit
#verticalLayout: #spreadSpace
#horizontalSpace: 3
#verticalSpace: 3
)
#(#VerticalPanelViewSpec
#name: 'VerticalPanel3'
#layout: #(#LayoutFrame -158 1 0 0.0 -120 1 -40 1.0)
#component:
#(#SpecCollection
#collection:
#(
#(#InputFieldSpec
#name: 'RedField'
#model: #red
#type: #numberInRange
#numChars: 3
#minValue: 0
#maxValue: 255
#extent: #(#Point 38 20)
)
#(#InputFieldSpec
#name: 'GreenField'
#model: #green
#type: #numberInRange
#numChars: 3
#minValue: 0
#maxValue: 255
#extent: #(#Point 38 20)
)
#(#InputFieldSpec
#name: 'BlueField'
#model: #blue
#type: #numberInRange
#numChars: 3
#minValue: 0
#maxValue: 255
#extent: #(#Point 38 20)
)
)
)
#horizontalLayout: #fit
#verticalLayout: #spreadSpace
#horizontalSpace: 3
#verticalSpace: 3
)
#(#LabelSpec
#name: 'PreviewBox'
#layout: #(#LayoutFrame -116 1 0 0.0 -2 1.0 -40 1.0)
#label: 'Preview'
#translateLabel: true
#level: -1
)
#(#HorizontalPanelViewSpec
#name: 'HorizontalPanel1'
#layout: #(#LayoutFrame 0 0.0 -32 1 0 1.0 0 1.0)
#component:
#(#SpecCollection
#collection:
#(
#(#ActionButtonSpec
#name: 'CancelButton'
#label: 'Cancel'
#translateLabel: true
#model: #doCancel
#extent: #(#Point 165 26)
)
#(#ActionButtonSpec
#name: 'OKButton'
#label: 'OK'
#translateLabel: true
#model: #doAccept
#extent: #(#Point 166 26)
)
)
)
#horizontalLayout: #fitSpace
#verticalLayout: #centerMax
#horizontalSpace: 3
#verticalSpace: 3
)
)
)
).
top := StandardSystemView extent:200@35.
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top.
list := #('foo' 'bar' 'baz' 'hjh' 'kk' 'claus' 'gjhj').
sidx := 4.
menu bottomInset:(menu preferredExtent y negated).
menu contents:(list at:sidx).
widget := SubCanvas new.
widget client:(SimpleDialog new).
widget spec:spec.
menu menuWidget:widget.
top open.
|
|