1: ================================================================================ 2: 3: Smalltalk.KSU defineClass: #ColorRGB 4: superclass: #{KSU.ColorAbstract} 5: indexedType: #none 6: private: false 7: instanceVariableNames: 'redField greenField blueField ' 8: classInstanceVariableNames: '' 9: imports: '' 10: category: 'KSU-Template' 11: 12: ================================================================================ 13: 14: KSU.ColorRGB method for 'aspects' 15: 16: blueField 17: 18: blueField ifNil: [blueField := (self valueString: self blueGauge value) asValue]. 19: ^blueField 20: 21: ------------------------------------------------------------ 22: 23: KSU.ColorRGB method for 'aspects' 24: 25: blueGauge 26: 27: ^self thirdGauge 28: 29: ------------------------------------------------------------ 30: 31: KSU.ColorRGB method for 'accessing' 32: 33: color 34: 35: | aColor | 36: aColor := ColorValue 37: red: (0 max: (self redGauge value min: 1)) 38: green: (0 max: (self greenGauge value min: 1)) 39: blue: (0 max: (self blueGauge value min: 1)). 40: ^aColor 41: 42: ------------------------------------------------------------ 43: 44: KSU.ColorRGB method for 'aspects' 45: 46: greenField 47: 48: greenField ifNil: [greenField := (self valueString: self greenGauge value) asValue]. 49: ^greenField 50: 51: ------------------------------------------------------------ 52: 53: KSU.ColorRGB method for 'aspects' 54: 55: greenGauge 56: 57: ^self secondGauge 58: 59: ------------------------------------------------------------ 60: 61: KSU.ColorRGB method for 'initialize-release' 62: 63: initialize 64: 65: super initialize. 66: redField := nil. 67: greenField := nil. 68: blueField := nil. 69: ^self 70: 71: ------------------------------------------------------------ 72: 73: KSU.ColorRGB method for 'aspects' 74: 75: redField 76: 77: redField ifNil: [redField := (self valueString: self redGauge value) asValue]. 78: ^redField 79: 80: ------------------------------------------------------------ 81: 82: KSU.ColorRGB method for 'aspects' 83: 84: redGauge 85: 86: ^self firstGauge 87: 88: ------------------------------------------------------------ 89: 90: KSU.ColorRGB method for 'private' 91: 92: updateColor 93: 94: #('red' 'green' 'blue') do: 95: [:aString | 96: | gaugeModel fieldModel gaugeString fieldString | 97: gaugeModel := self perform: (aString , 'Gauge') asSymbol. 98: fieldModel := self perform: (aString , 'Field') asSymbol. 99: gaugeString := self valueString: gaugeModel value. 100: fieldString := fieldModel value. 101: gaugeString = fieldString ifFalse: [fieldModel value: gaugeString]]. 102: super updateColor 103: 104: ------------------------------------------------------------ 105: 106: KSU.ColorRGB method for 'private' 107: 108: valueString: aValue 109: 110: ^(aValue roundTo: 0.01) printString 111: 112: ================================================================================ 113: 114: KSU.ColorRGB class 115: instanceVariableNames: '' 116: 117: ================================================================================ 118: 119: KSU.ColorRGB class method for 'examples' 120: 121: example1 122: "KSU.ColorRGB example1." 123: 124: | anApplication | 125: anApplication := KSU.ColorRGB new. 126: anApplication open. 127: ^anApplication 128: 129: ------------------------------------------------------------ 130: 131: KSU.ColorRGB class method for 'interface specs' 132: 133: windowSpec 134: "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" 135: 136: <resource: #canvas> 137: ^#(#{UI.FullSpec} 138: #window: 139: #(#{UI.WindowSpec} 140: #label: '加法混色' 141: #min: #(#{Core.Point} 512 160 ) 142: #max: #(#{Core.Point} 512 160 ) 143: #bounds: #(#{Graphics.Rectangle} 1023 719 1535 879 ) 144: #flags: 4 145: #menu: #menuBar ) 146: #component: 147: #(#{UI.SpecCollection} 148: #collection: #( 149: #(#{UI.LabelSpec} 150: #layout: #(#{Core.Point} 24 17 ) 151: #name: #redLabel 152: #colors: 153: #(#{UI.LookPreferences} 154: #setBackgroundColor: #(#{Graphics.ColorValue} #pink ) ) 155: #label: '赤:' ) 156: #(#{UI.LabelSpec} 157: #layout: #(#{Core.Point} 24 49 ) 158: #name: #greenLabel 159: #colors: 160: #(#{UI.LookPreferences} 161: #setBackgroundColor: #(#{Graphics.ColorValue} 6143 8191 6143 ) ) 162: #label: '緑:' ) 163: #(#{UI.LabelSpec} 164: #layout: #(#{Core.Point} 24 81 ) 165: #name: #blueLabel 166: #colors: 167: #(#{UI.LookPreferences} 168: #setBackgroundColor: #(#{Graphics.ColorValue} 6143 6143 8191 ) ) 169: #label: '青:' ) 170: #(#{UI.InputFieldSpec} 171: #layout: #(#{Graphics.Rectangle} 64 17 128 40 ) 172: #name: #redField 173: #colors: 174: #(#{UI.LookPreferences} 175: #setBackgroundColor: #(#{Graphics.ColorValue} #pink ) ) 176: #model: #redField 177: #alignment: #center 178: #isReadOnly: true 179: #type: #string ) 180: #(#{UI.InputFieldSpec} 181: #layout: #(#{Graphics.Rectangle} 64 49 128 72 ) 182: #name: #greenField 183: #colors: 184: #(#{UI.LookPreferences} 185: #setBackgroundColor: #(#{Graphics.ColorValue} 6143 8191 6143 ) ) 186: #model: #greenField 187: #alignment: #center 188: #isReadOnly: true ) 189: #(#{UI.InputFieldSpec} 190: #layout: #(#{Graphics.Rectangle} 64 81 128 104 ) 191: #name: #blueField 192: #colors: 193: #(#{UI.LookPreferences} 194: #setBackgroundColor: #(#{Graphics.ColorValue} 6143 6143 8191 ) ) 195: #model: #blueField 196: #alignment: #center 197: #isReadOnly: true ) 198: #(#{UI.SliderSpec} 199: #layout: #(#{Graphics.Rectangle} 144 16 488 40 ) 200: #name: #redGauge 201: #colors: 202: #(#{UI.LookPreferences} 203: #setBackgroundColor: #(#{Graphics.ColorValue} #pink ) ) 204: #model: #redGauge 205: #orientation: #horizontal 206: #start: 0 207: #stop: 1 208: #step: 0.01 ) 209: #(#{UI.SliderSpec} 210: #layout: #(#{Graphics.Rectangle} 144 48 488 72 ) 211: #name: #greenGauge 212: #colors: 213: #(#{UI.LookPreferences} 214: #setBackgroundColor: #(#{Graphics.ColorValue} 6143 8191 6143 ) ) 215: #model: #greenGauge 216: #orientation: #horizontal 217: #start: 0 218: #stop: 1 219: #step: 0.01 ) 220: #(#{UI.SliderSpec} 221: #layout: #(#{Graphics.Rectangle} 144 80 488 104 ) 222: #name: #blueGauge 223: #colors: 224: #(#{UI.LookPreferences} 225: #setBackgroundColor: #(#{Graphics.ColorValue} 6143 6143 8191 ) ) 226: #model: #blueGauge 227: #orientation: #horizontal 228: #start: 0 229: #stop: 1 230: #step: 0.01 ) ) ) ) 231: 232: ================================================================================
This document was generated by KSU.TextDoclet on 2012/11/10 at 10:56:49.