From VisualWorks® NonCommercial, 7.5 of April 16, 2007 on September 23, 2008 at 5:56:08 pm BMIChecker4 Smalltalk UI.ApplicationModel false none height weight bmi (none) (none) BMIChecker4 class interface specs windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: 'BMI checker' #bounds: #(#{Graphics.Rectangle} 640 400 840 520 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutSizedOrigin} 15 0 15 0 46 18 ) #label: 'Height:' ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutSizedOrigin} 15 0 50 0 46 18 ) #label: 'Weight:' ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutSizedOrigin} 15 0 85 0 29 18 ) #label: 'BMI:' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.LayoutSizedOrigin} 70 0 13 0 100 23 ) #model: #height #type: #number ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.LayoutSizedOrigin} 70 0 48 0 100 23 ) #model: #weight #type: #number ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.LayoutSizedOrigin} 70 0 83 0 100 23 ) #name: #bmi #model: #bmi #type: #number ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutSizedOrigin} 175 0 15 0 10 18 ) #label: 'm' ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutSizedOrigin} 175 0 50 0 16 18 ) #label: 'kg' ) ) ) ) BMIChecker4 accessing bmi: aValueHolder bmi := aValueHolder height: aValueHolder height := aValueHolder. aValueHolder onChangeSend: #bmiChanged to: self weight: aValueHolder weight := aValueHolder. aValueHolder onChangeSend: #bmiChanged to: self BMIChecker4 aspects bmi "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^bmi isNil ifTrue: [bmi := 0 asValue] ifFalse: [bmi] height "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^height isNil ifTrue: [height := 0 asValue] ifFalse: [height] weight "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^weight isNil ifTrue: [weight := 0 asValue] ifFalse: [weight] BMIChecker4 updating bmiChanged | bmiValue component fieldColor | bmiValue := self weight value / (self height value ** 2). self bmi value: bmiValue. fieldColor := bmiValue < 18.5 ifTrue: [ColorValue white] ifFalse: [ bmiValue < 20 ifTrue: [ColorValue yellow] ifFalse: [ bmiValue < 30 ifTrue: [ColorValue orange] ifFalse: [ColorValue red]]]. self builder notNil ifTrue: [ component := self builder componentAt: #bmi. component lookPreferences: (component lookPreferences setBackgroundColor: fieldColor)] BMIChecker4 initialize-release initialize super initialize. self height value: 1.704. self height onChangeSend: #bmiChanged to: self. self weight value: 60.4. self weight onChangeSend: #bmiChanged to: self BMIChecker4 interface opening postBuildWith: aBuilder self bmiChanged