Morph subclass: #ComboBox instanceVariableNames: 'text list downButton ' classVariableNames: '' poolDictionaries: '' category: 'Aytar - Common Controls'! !ComboBox commentStamp: 'OA 11/4/2002 13:55' prior: 0! ComboBox is a regular combo box control, except it does not resize automatically to fit the contents. This class demonstrates both inheritence by extending and mapping. instance variables: text - a TextMorph for editing and viewing the contents of the combo box list - a ListBox for the drop-down options downbutton - a button to show or hide the list. common methods: initialize - initializes a fairly designed ComboBox addItem: aString - adds an item to the list. Also accepts numbers text: aString - change the value displayed on the combo box text - retrieve the value displayed on the combo box. events: no events have been defined for this object.! !ComboBox methodsFor: 'accessing' stamp: 'OA 11/4/2002 13:53'! addItem: aString " adds an item to the list, directly maps to the list box " list addItem: aString! ! !ComboBox methodsFor: 'accessing' stamp: 'OA 11/4/2002 13:53'! text " Retrieve the text displayed. Directly maps to text morph" ^ text contents! ! !ComboBox methodsFor: 'accessing' stamp: 'OA 11/4/2002 13:54'! text: aString " Set the text to be displayed. Directly maps to text morph" text contentsWrapped: aString. text width: self width.! ! !ComboBox methodsFor: 'events-processing' stamp: 'OA 11/4/2002 13:58'! gotClicked " a private method to perform combo box behavior when clicked on the list." self text: (list selectedItem). self showOrHideList.! ! !ComboBox methodsFor: 'initialization' stamp: 'OA 11/4/2002 13:56'! initialize "initialize instance variables to their default values" super initialize. text _ TextMorph new. list _ ListBox new. list initialize. list clickAction: [self gotClicked]. downButton _ ShapeButton new. downButton initialize. downButton label: 'v'. downButton shape: 1. downButton clickAction: [self showOrHideList]. self addMorph: text. self addMorph: list. self addMorphFront: downButton. ComboBox defaultProperties: self. self refresh. self showOrHideList.! ! !ComboBox methodsFor: 'visual properties' stamp: 'OA 11/4/2002 13:59'! extent: aPoint " overriden the method to refresh the control " super extent: aPoint. self refresh.! ! !ComboBox methodsFor: 'visual properties' stamp: 'OA 11/4/2002 13:59'! height: aNumber " overriden the method to refresh the control " super height: aNumber. self refresh.! ! !ComboBox methodsFor: 'visual properties' stamp: 'OA 11/4/2002 13:57'! refresh " redraw the control when necessary." text position: self position. text extent: self extent. list position: self position + (0@self height). list width: self width. list height: 130. downButton width: 16. downButton height: self height - 2. downButton left: self left + self width - 17. downButton top: self top + 1.! ! !ComboBox methodsFor: 'visual properties' stamp: 'OA 11/4/2002 13:58'! showOrHideList "private method for combo box behavior " list visible ifTrue: [list visible: false] ifFalse: [list visible: true]. self refresh.! ! !ComboBox methodsFor: 'visual properties' stamp: 'OA 11/4/2002 13:59'! width: aNumber " overriden the method to refresh the control " super width: aNumber. self refresh.! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! ComboBox class instanceVariableNames: ''! !ComboBox class methodsFor: 'instance creation' stamp: 'OA 11/4/2002 14:00'! defaultProperties: aComboBox "default properties for a standart combo box." aComboBox extent: 120@18. aComboBox color: Color white. aComboBox text: 'ComboBox'! ! Morph subclass: #DemonstrationMorph instanceVariableNames: 'interval rand ' classVariableNames: '' poolDictionaries: '' category: 'Aytar - Common Controls'! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 19:24'! drawRectangles "redraw the spectrum" | r n currentTop| "first clear all current rectangles" self removeAllMorphs. "now redraw them" currentTop _ self top + self height - 5. n _ rand nextInt: 12. (1 to: n) do: [:i | r _ self newElement: i. r top: currentTop. r left: self left. self addMorph: r. currentTop _ currentTop - 5. ].! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 18:24'! extent: aPoint "do nothing"! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 18:25'! height: aNumber "do nothing"! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 18:24'! initialize super initialize. rand _ Random new. super extent: 10@60. self color: Color black. self interval: 200.! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 12:30'! interval ^interval! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 12:29'! interval: aNumber interval _ aNumber! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 19:23'! newElement: n "Create a new RectangleMorph with the color according to its position" | r | r _ RectangleMorph new. r extent: 10@4. "if n is less then 5, rectangle is light green" n < 5 ifTrue: [ r color: Color green. r borderColor: Color lightGreen. ^r ]. "if n is greater than 8, rectangle is orange" n > 8 ifTrue: [ r color: Color orange. r borderColor: Color orange. ^r ]. "Otherwise rectangle is yellow" r color: Color yellow. r borderColor: Color yellow. ^r! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 12:30'! step self drawRectangles! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 12:29'! stepTime ^interval! ! !DemonstrationMorph methodsFor: 'as yet unclassified' stamp: 'OA 11/5/2002 18:25'! width: aNumber "do nothing"! ! BorderedMorph subclass: #ListBox instanceVariableNames: 'items itemData selectedItem normalColor normalForeColor highlightColor selectedColor selectedForeColor lastListIndex listIndex clickAction doubleClickAction containers maxVisibleItems topItem lastItem sBar ' classVariableNames: '' poolDictionaries: '' category: 'Aytar - Common Controls'! !ListBox commentStamp: 'OA 11/4/2002 14:31' prior: 0! This is a standart list box control with items, item data and visual effects. instance variables: items - an Ordered Collection of String values to be listed itemData - an Ordered Colection of any value which is associated with the list. clickAction - action to be performed when the list is clicked. doubleClickAction - action to be performed when the list is doubleClicked common methods: initialize - initializes the list box with default properties. addItem: aString - adds an item to the list, numgers work as well. removeItem: anIndex - removes item at selected index itemData: anObject at: anIndex - sets the item data at the specified index. removeItemDataAt: anIndex - removes item data at the selected index. clear - clears the list. listIndex - returns the listIndex of the selected item. returns nil if nothing is selected. selectedItem - returns the selected item as string. clickAction: aBlock - sets the action to be performed when clicked doubleClickAction: aBlock - sets the action to be performed when double clicked.! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 22:50'! addItem: aString items = nil ifTrue: [items _ OrderedCollection new]. itemData = nil ifTrue: [itemData _ OrderedCollection new]. items add: aString asString. itemData add: nil. self clearList. self showList.! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 21:14'! clear items _ OrderedCollection new. itemData _ OrderedCollection new. self clearList.! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 19:21'! itemData ^ itemData! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 19:19'! itemData: anOrderedCollection itemData _ anOrderedCollection! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/4/2002 14:27'! itemData: anObject at: anIndex anIndex <= items size ifTrue: [ itemData at: anIndex put: anObject ]! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 19:22'! itemDataAt: anIndex anIndex <= items size ifTrue: [ ^ itemData at: anIndex ].! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 19:15'! items ^items! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 21:03'! items: anOrderedCollection items _ anOrderedCollection. itemData _ OrderedCollection new. (1 to: anOrderedCollection size) do: [:i | itemData add: nil ]. self clearList. self showList.! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/3/2002 02:38'! listIndex ^ listIndex.! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/5/2002 21:03'! listIndex: aNumber lastListIndex _ listIndex. listIndex _ aNumber. selectedItem _ items at: aNumber. listIndex < topItem ifTrue:[ sBar setValue: (listIndex * (sBar scrollDelta)) asFloat. ^ true ]. listIndex > lastItem ifTrue:[ sBar setValue: ((listIndex - maxVisibleItems + 1) * (sBar scrollDelta)) asFloat. ^ true ]. self updateList.! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 21:18'! removeItem: anIndex items = nil ifTrue: [^ false]. anIndex <= items size ifTrue:[ items removeAt: anIndex. self removeItemDataAt: anIndex. ]. self clearList. self showList.! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 21:18'! removeItemDataAt: anIndex itemData = nil ifTrue:[^ false]. anIndex <= items size ifTrue: [ ^ itemData removeAt: anIndex ].! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/2/2002 19:12'! selectedItem ^ selectedItem! ! !ListBox methodsFor: 'accessing' stamp: 'OA 11/5/2002 21:17'! selectedItem: aNumber ^ self listIndex: aNumber.! ! !ListBox methodsFor: 'event handling' stamp: 'OA 11/5/2002 01:07'! handlesKeyboard: evt ^true! ! !ListBox methodsFor: 'event handling' stamp: 'OA 11/5/2002 01:06'! hasFocus ^ true.! ! !ListBox methodsFor: 'event handling' stamp: 'OA 11/5/2002 01:12'! keyStroke: event | aChar | (self scrollByKeyboard: event) ifTrue: [^self]. aChar _ event keyCharacter. ^ self keyPressed: aChar ! ! !ListBox methodsFor: 'event handling' stamp: 'OA 11/5/2002 20:43'! scrollByKeyboard: event (listIndex = nil) ifTrue:[listIndex _ 0]. event keyValue = 30 ifTrue: [ listIndex = 1 ifTrue:[^true]. self listIndex: listIndex - 1. ^ true]. event keyValue = 31 ifTrue: [ listIndex = items size ifTrue:[^true]. self listIndex: listIndex + 1. ^ true]. ^ false! ! !ListBox methodsFor: 'events-processing' stamp: 'OA 11/3/2002 14:38'! clickAction: aBlock clickAction _ aBlock.! ! !ListBox methodsFor: 'events-processing' stamp: 'OA 11/2/2002 21:21'! doubleClickAction: aBlock | b | doubleClickAction _ aBlock. containers ~= nil ifTrue: [ (1 to: containers size) do: [:i | b _ containers at: i. b doubleClickAction: aBlock. ]. ].! ! !ListBox methodsFor: 'events-processing' stamp: 'OA 11/3/2002 14:39'! gotClicked: aNumber | n | n _ (aNumber // 14) + 1. (n > (items size)) ifTrue: [n _ items size]. self listIndex: (n + topItem - 1). clickAction ~= nil ifTrue: [clickAction value].! ! !ListBox methodsFor: 'events-processing' stamp: 'OA 11/3/2002 13:45'! gotDoubleClicked doubleClickAction ~= nil ifTrue: [doubleClickAction value].! ! !ListBox methodsFor: 'events-processing' stamp: 'OA 11/5/2002 20:47'! keyPressed: aChar | s | s _ listIndex. s = 0 ifTrue:[s _ 1]. (s to: items size) do: [:i | (aChar = (((items at: i) at: 1) asCharacter)) ifTrue:[ self listIndex: i. ^ true. ]. ].! ! !ListBox methodsFor: 'initialization' stamp: 'OA 11/3/2002 02:06'! initialize super initialize. sBar _ ScrollBarForNonModels new. self addMorph: sBar. ListBox defaultProperties: self. maxVisibleItems _ (self height // 14). topItem _ 1. lastItem _ maxVisibleItems. self color: normalColor. containers _ OrderedCollection new! ! !ListBox methodsFor: 'scrolling' stamp: 'OA 11/3/2002 00:52'! hideOrShowScrollBar ^true! ! !ListBox methodsFor: 'scrolling' stamp: 'OA 11/3/2002 13:25'! scrollBarValue: scrollValue topItem _ (scrollValue * items size). topItem < 1 ifTrue: [ topItem _ 1. sBar value: sBar scrollDelta. ]. lastItem _ topItem + maxVisibleItems - 1. (lastItem > (items size)) ifTrue: [ lastItem _ items size. topItem _ lastItem - maxVisibleItems + 1. ]. self clearList. self showList! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/2/2002 23:55'! extent: aPoint super extent: aPoint. maxVisibleItems _ (self height // 2) + 1. lastItem ~= nil ifTrue: [lastItem _ topItem + maxVisibleItems]. self clearList. self showList.! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/2/2002 23:56'! height: aNumber super height: aNumber. maxVisibleItems _ (self height // 2) + 1. lastItem ~= nil ifTrue: [lastItem _ topItem + maxVisibleItems]. self clearList. self showList.! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/5/2002 21:16'! highlightColor ^highlightColor! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/2/2002 19:34'! highlightColor: aColor highlightColor _ aColor.! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/5/2002 21:16'! normalColor ^normalColor! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/2/2002 19:33'! normalColor: aColor normalColor _ aColor.! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/5/2002 21:16'! normalForeColor ^normalForeColor! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/2/2002 21:45'! normalForeColor: aColor normalForeColor _ aColor.! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/5/2002 21:16'! selectedColor ^selectedColor! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/2/2002 19:36'! selectedColor: aColor selectedColor _ aColor! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/5/2002 21:16'! selectedForeColor ^selectedForeColor! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/2/2002 21:45'! selectedForeColor: aColor selectedForeColor _ aColor.! ! !ListBox methodsFor: 'visual properties' stamp: 'OA 11/2/2002 23:53'! width: aNumber super width: aNumber. self clearList. self showList.! ! !ListBox methodsFor: 'private' stamp: 'OA 11/2/2002 23:57'! clearList | b | containers = nil ifTrue: [^ false]. ((containers size) > 0) ifTrue: [ (1 to: containers size) do: [:i | b _ containers at: i. b delete. ]. ]. containers _ OrderedCollection new.! ! !ListBox methodsFor: 'private' stamp: 'OA 11/5/2002 21:09'! showList | b currentTop sD pD l| sBar top: self top. sBar left: self left + self width - sBar width. sBar height: self height. containers = nil ifTrue:[^ false]. items = nil ifTrue:[^ false]. topItem = nil ifTrue:[^ false]. currentTop _ self top + 2. l _ lastItem. ((items size) < maxVisibleItems) ifTrue: [l _ items size]. (topItem to: l) do: [:i | ((items at: i) ~= nil) ifTrue: [ b _ ShapeButton new. b initialize. b shape: 1. b alignment: 1. b label: (items at: i). self addMorph: b. b normalColor: normalColor. b normalBorderColor: normalColor. b normalBorderWidth: 0. b normalForeColor: normalForeColor. b hoverColor: highlightColor. b hoverBorderColor: highlightColor. b hoverBorderWidth: 0. b hoverForeColor: normalForeColor. b height: 14. b width: self width - 2 - sBar width. b top: currentTop. b left: self left + 2. b index: i. b clickAction: [self gotClicked: (self cursorPoint y - self top)]. b doubleClickAction: [self gotDoubleClicked]. b doubleClickAction: doubleClickAction. b turnOnHoverEffect. b turnOffMouseDownEffect. currentTop _ currentTop + 14. containers add: b ]. ]. ((items size) > maxVisibleItems) ifTrue: [ sD _ (1 / (items size)) asFloat. pD _ ((items size - maxVisibleItems) / (items size)) asFloat. sBar scrollDelta: sD pageDelta: pD. sBar interval: (1 - pD) asFloat. sBar value: (topItem / (items size)) asFloat. ] ifFalse: [ sBar scrollDelta: 0.02 pageDelta: 0.2. sBar interval: 1.0 ]. self updateList! ! !ListBox methodsFor: 'private' stamp: 'OA 11/3/2002 13:41'! updateList | b | listIndex = nil ifTrue: [^ false]. listIndex > (maxVisibleItems + topItem - 1) ifTrue: [^ false]. listIndex < topItem ifTrue: [^ false]. (lastListIndex ~= nil and: [lastListIndex >= topItem and: [lastListIndex <= (lastItem)]]) ifTrue: [b _ containers at: (lastListIndex - topItem + 1). b normalColor: normalColor. b normalBorderColor: normalColor. b normalForeColor: normalForeColor. b turnOnHoverEffect]. b _ containers at: listIndex - topItem + 1. b normalColor: selectedColor. b normalBorderColor: selectedColor. b normalForeColor: selectedForeColor. b turnOffHoverEffect! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! ListBox class instanceVariableNames: ''! !ListBox class methodsFor: 'instance creation' stamp: 'OA 11/2/2002 21:58'! defaultProperties: aListBox aListBox borderColor: Color lightGray. aListBox normalColor: Color white. aListBox highlightColor: Color paleBlue. aListBox selectedColor: Color blue. aListBox normalForeColor: Color black. aListBox selectedForeColor: Color white. aListBox extent: 100@200.! ! ScrollBar subclass: #ScrollBarForNonModels instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Aytar - Common Controls'! !ScrollBarForNonModels commentStamp: 'OA 11/4/2002 14:04' prior: 0! Squeak's ScrollBar control only works with ModelMorph subclasses. This ScrollBar overrides the method regarding the ModelMorphs and sends the value of the ScrollBar to its owner, which has a 'scrollBarValue: aValue' method.! !ScrollBarForNonModels methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 14:04'! setValue: newValue "send the value to your owner" | v | v _ newValue roundTo: scrollDelta. owner scrollBarValue: v.! ! Morph subclass: #ShapeButton instanceVariableNames: 'label hasHoverEffect hasMouseDownEffect normalColor normalForeColor normalBorderColor normalBorderWidth hoverColor hoverForeColor hoverBorderColor hoverBorderWidth downColor downForeColor downBorderColor downBorderWidth mouseOverAction mouseLeaveAction mouseDownAction mouseStillDownAction mouseUpAction clickAction doubleClickAction mask alignment index ' classVariableNames: '' poolDictionaries: '' category: 'Aytar - Common Controls'! !ShapeButton commentStamp: 'OA 11/4/2002 14:21' prior: 0! A 2 dimensional shaped button with rollover, rolloff and down effects, customizable for all of the enlistend events. instance variables: alignment - states where the label will be aligned. 1 - left 2 - right 3 - center index - provided in case if it is necessary to index buttons hasHoverEffect - states whether the hovereffect will be performed or not. hasMouseDownEffect - states whether the down effect will be performed or not. variables starting with normal - sets visual properties when the mouse cursor is not over the button variables starting with hover - sets visual properties when the mouse cursor is over the button variables starting with mouseDown - sets visual properties when the mouse is pressed on the button action variables - sets the blocks for the respective actions. label - a StringMorph mask - a Shape, it is either a Rectangle or an EllipseMorph. common methods: initialize - initializes control with default properties. turnOnHoverEffect - enables hover effect turnOffHoverEffect - disables hover effect turnOnMouseDownEffect - enables down effect turnOffMouseDownEffect - disables down effect events-processing category - sets the actions for respective events.! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 17:23'! click: evt clickAction ~= nil ifTrue: [clickAction value]! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 17:23'! doubleClick: evt doubleClickAction ~= nil ifTrue: [doubleClickAction value]! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 15:59'! handlesMouseDown: evt ^ true.! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 15:59'! handlesMouseOver: evt ^ true.! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 18:09'! handlesMouseStillDown: evt ^ true.! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 17:22'! mouseDown: evt hasMouseDownEffect ifTrue: [ self color: downColor. self borderColor: downBorderColor. self foreColor: downForeColor. self borderWidth: downBorderWidth. ]. mouseDownAction ~= nil ifTrue: [mouseDownAction value]. evt hand waitForClicksOrDrag: self event: evt! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 16:34'! mouseEnter: evt hasHoverEffect ifTrue: [ self color: hoverColor. self borderColor: hoverBorderColor. self foreColor: hoverForeColor. self borderWidth: hoverBorderWidth. ]. mouseOverAction~= nil ifTrue: [mouseOverAction value].! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 16:25'! mouseLeave: evt hasHoverEffect ifTrue: [ self color: normalColor. self borderColor: normalBorderColor. self foreColor: normalForeColor. self borderWidth: normalBorderWidth. ]. mouseLeaveAction ~= nil ifTrue:[mouseLeaveAction value]! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 18:11'! mouseStillDown: evt mouseStillDownAction ~= nil ifTrue:[mouseStillDownAction value]! ! !ShapeButton methodsFor: 'event handling' stamp: 'OA 11/2/2002 17:43'! mouseUp: evt hasMouseDownEffect ifTrue: [ self color: normalColor. self borderColor: normalBorderColor. self foreColor: normalForeColor. self borderWidth: normalBorderWidth. ]. mouseUpAction ~= nil ifTrue: [mouseUpAction value].! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:27'! clickAction ^clickAction! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:26'! clickAction: aBlock clickAction _ aBlock.! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:27'! doubleClickAction ^doubleClickAction! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:26'! doubleClickAction: aBlock doubleClickAction _ aBlock.! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:27'! mouseDownAction ^mouseDownAction! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:26'! mouseDownAction: aBlock mouseDownAction _ aBlock.! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 18:12'! mouseEnterAction ^mouseOverAction! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 18:12'! mouseEnterAction: aBlock mouseOverAction _ aBlock.! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:27'! mouseLeaveAction ^mouseLeaveAction! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:26'! mouseLeaveAction: aBlock mouseLeaveAction _ aBlock.! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 18:10'! mouseStillDownAction ^ mouseStillDownAction! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 18:10'! mouseStillDownAction: aBlock mouseStillDownAction _ aBlock! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 18:12'! mouseUpAction ^ mouseUpAction.! ! !ShapeButton methodsFor: 'events-processing' stamp: 'OA 11/2/2002 17:42'! mouseUpAction: aBlock mouseUpAction _ aBlock.! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:09'! hasHoverEffect hasHoverEffect = nil ifTrue: [hasHoverEffect _ false]. ^ hasHoverEffect! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:19'! hoverBorderColor ^hoverBorderColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:18'! hoverBorderColor: aColor hoverBorderColor _ aColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:19'! hoverBorderWidth ^ hoverBorderWidth! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:19'! hoverBorderWidth: aNumber hoverBorderWidth _ aNumber! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:17'! hoverColor ^ hoverColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:18'! hoverColor: aColor hoverColor _ aColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:19'! hoverForeColor ^hoverForeColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:18'! hoverForeColor: aColor hoverForeColor _ aColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/4/2002 23:39'! normalBorderColor ^normalBorderColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 17:13'! normalBorderColor: aColor normalBorderColor _ aColor. self borderColor: aColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/4/2002 23:39'! normalBorderWidth ^ normalBorderWidth! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 17:12'! normalBorderWidth: aNumber normalBorderWidth _ aNumber. self borderWidth: aNumber.! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/4/2002 23:38'! normalColor ^ normalColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 17:12'! normalColor: aColor normalColor _ aColor. self color: aColor.! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/4/2002 23:38'! normalForeColor ^normalForeColor! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 17:12'! normalForeColor: aColor normalForeColor _ aColor. self foreColor: aColor.! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:08'! turnOffHoverEffect hasHoverEffect _ false! ! !ShapeButton methodsFor: 'hover effect' stamp: 'OA 11/2/2002 16:07'! turnOnHoverEffect hasHoverEffect _ true! ! !ShapeButton methodsFor: 'initialization' stamp: 'OA 11/4/2002 14:18'! index "get the index" ^ index.! ! !ShapeButton methodsFor: 'initialization' stamp: 'OA 11/4/2002 14:18'! index: aNumber "set the index" index _ aNumber.! ! !ShapeButton methodsFor: 'initialization' stamp: 'OA 11/4/2002 14:18'! initialize "initialize the contol with default properties." super initialize. super color: Color transparent. self shape: 3. alignment _ 3. label _ StringMorph new. label initialize. self label: 'ShapeButton'. self addMorph: label. ShapeButton defaultProperties: self. self refresh.! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:10'! hasMouseDownEffect hasMouseDownEffect = nil ifTrue:[hasMouseDownEffect _ false]. ^ hasMouseDownEffect! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:20'! mouseDownBorderColor ^downBorderColor! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:21'! mouseDownBorderColor: aColor downBorderColor _ aColor! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:21'! mouseDownBorderWidth ^downBorderWidth! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:22'! mouseDownBorderWidth: aNumber downBorderWidth _ aNumber! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:21'! mouseDownColor ^downColor! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:22'! mouseDownColor: aColor downColor _ aColor! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:21'! mouseDownForeColor ^downForeColor! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:22'! mouseDownForeColor: aColor downForeColor _ aColor! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:08'! turnOffMouseDownEffect hasMouseDownEffect _ false! ! !ShapeButton methodsFor: 'mouse down effect' stamp: 'OA 11/2/2002 16:08'! turnOnMouseDownEffect hasMouseDownEffect _ true! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/4/2002 21:36'! alignCenter self alignment: 3! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/4/2002 21:36'! alignLeft self alignment: 1! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/4/2002 21:36'! alignRight self alignment: 2! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 19:03'! alignment ^ alignment ! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 19:07'! alignment: aNumber "1 - Left aligned, 2 - Right aligned, 3 - Center" alignment _ aNumber. self refresh. ! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 16:52'! borderColor ^ normalBorderColor! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 17:09'! borderColor: aColor mask borderColor: aColor! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 16:16'! borderWidth ^ normalBorderWidth! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 17:08'! borderWidth: aNumber mask borderWidth: aNumber! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 16:16'! color ^ normalColor! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 17:09'! color: aColor mask color: aColor.! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 15:48'! extent: aPoint super extent: aPoint. self refresh! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 16:17'! foreColor ^ normalForeColor.! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 17:09'! foreColor: aColor label color: aColor.! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 15:50'! height: anInteger super height: anInteger. self refresh.! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 15:46'! label ^ label contents.! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 15:51'! label: aString label contents: aString. self refresh! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 19:05'! refresh label ~= nil ifTrue: [ alignment = 1 ifTrue: [ label left: self left + 2 ]. alignment = 2 ifTrue: [ label left: self left + self width - label width - 2. ]. alignment = 3 ifTrue: [ label left: self left + ((self width - label width) // 2). ]. label top: self top + ((self height - label height) // 2). ]. mask ~= nil ifTrue: [ mask extent: self extent. mask position: self position. ]! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/4/2002 23:49'! shape: anInteger " Set the shape of the button. 1 - Rectangle, 2 - Oval, 3 - Rounded Rectangle" anInteger < 1 ifTrue: [^false]. anInteger > 3 ifTrue:[^false]. mask ~= nil ifTrue: [mask delete]. anInteger = 1 ifTrue:[ mask _ ShapeButton shapeRectangle: self. self addMorphBack: mask. ^ true ]. anInteger = 2 ifTrue: [ mask _ ShapeButton shapeOval: self. self addMorphBack: mask. ^ true ]. anInteger = 3 ifTrue: [ mask _ ShapeButton shapeRoundedRectangle: self. mask cornerStyle: #rounded. self addMorphBack: mask. ^ true ]. label comeToFront.! ! !ShapeButton methodsFor: 'visual properties' stamp: 'OA 11/2/2002 15:50'! width: anInteger super width: anInteger. self refresh.! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! ShapeButton class instanceVariableNames: ''! !ShapeButton class methodsFor: 'Shapes' stamp: 'OA 11/2/2002 13:48'! shapeOval: aShapeButton | m | m _ EllipseMorph new. m extent = aShapeButton extent. m position = aShapeButton position. aShapeButton extent = m extent. ^ m! ! !ShapeButton class methodsFor: 'Shapes' stamp: 'OA 11/2/2002 13:45'! shapeRectangle: aShapeButton | m | m _ RectangleMorph new. m extent: aShapeButton extent. m position: aShapeButton position. ^ m! ! !ShapeButton class methodsFor: 'Shapes' stamp: 'OA 11/2/2002 13:51'! shapeRoundedRectangle: aShapeButton | m | m _ RectangleMorph new. m cornerStyle: #rounded. m extent: aShapeButton extent. m position: aShapeButton position. ^ m! ! !ShapeButton class methodsFor: 'instance creation' stamp: 'OA 11/2/2002 19:06'! defaultProperties: aShapeButton | s | s _ aShapeButton. s normalColor: Color gray. s normalBorderColor: Color black. s normalForeColor: Color black. s normalBorderWidth: 1. s hoverColor: Color gray. s hoverBorderWidth: 2. s hoverForeColor: Color black. s hoverBorderColor: Color black. s mouseDownColor: Color black. s mouseDownForeColor: Color gray. s mouseDownBorderWidth: 2. s mouseDownBorderColor: Color white. s turnOnHoverEffect. s turnOnMouseDownEffect. s extent: 80@30.! ! BorderedMorph subclass: #SimpleButton instanceVariableNames: 'label clickAction doubleClickAction ' classVariableNames: '' poolDictionaries: '' category: 'Aytar - Common Controls'! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 17:35'! click: evt clickAction ~= nil ifTrue: [clickAction value]! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:11'! clickAction ^clickAction! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:08'! clickAction: aBlock clickAction _ aBlock! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 17:35'! doubleClick: evt doubleClickAction ~= nil ifTrue: [doubleClickAction value]! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:11'! doubleClickAction ^doubleClickAction! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:08'! doubleClickAction: aBlock doubleClickAction _ aBlock! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:06'! extent: aPoint super extent: aPoint. self refresh.! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 17:24'! foreColor ^label color! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:07'! foreColor: aColor label color: aColor! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:08'! handlesMouseDown: evt ^ true! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:06'! height: aNumber super height: aNumber. self refresh.! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:12'! initialize "Initialize my properties and instance variables" super initialize. "initialize all properties and instance variables I inherited from my super class" "Now initialize my specific properties and instance variables" self color: Color lightGray. self borderColor: Color black. label _ StringMorph new. label contents: 'SimpleButton'. self addMorph: label. self extent: 80@25.! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:12'! label ^label contents! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 20:58'! label: aString label contents: aString. self refresh! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:09'! mouseDown: evt "wait for other events" evt hand waitForClicksOrDrag: self event: evt! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:05'! refresh label top: self top + ((self height - label height) // 2). label left: self left + ((self width - label width) // 2).! ! !SimpleButton methodsFor: 'as yet unclassified' stamp: 'OA 11/4/2002 16:06'! width: aNumber super width: aNumber. self refresh.! !