1: ================================================================================
  2: 
  3: Smalltalk.KSU defineClass: #ColorHSB
  4:     superclass: #{UI.ApplicationModel}
  5:     indexedType: #none
  6:     private: false
  7:     instanceVariableNames: 'hueGauge saturationGauge brightnessGauge '
  8:     classInstanceVariableNames: ''
  9:     imports: ''
 10:     category: 'KSU-Template'
 11: 
 12: ================================================================================
 13: 
 14: KSU.ColorHSB method for 'aspects'
 15: 
 16: brightnessGauge
 17: 
 18:     brightnessGauge
 19:         ifNil: 
 20:             [brightnessGauge := 0.5 asValue.
 21:             brightnessGauge compute: [:aValue | self updateColorBrightness: aValue]].
 22:     ^brightnessGauge
 23: 
 24: ------------------------------------------------------------
 25: 
 26: KSU.ColorHSB method for 'interface opening'
 27: 
 28: brightnessView
 29: 
 30:     | aView |
 31:     aView := ColorHSBView model: self.
 32:     aView aspectSelector: #brightness.
 33:     ^aView
 34: 
 35: ------------------------------------------------------------
 36: 
 37: KSU.ColorHSB method for 'accessing'
 38: 
 39: color
 40: 
 41:     | aColor |
 42:     aColor := ColorValue
 43:                 hue: (0 max: (self hueGauge value min: 1))
 44:                 saturation: (0 max: (self saturationGauge value min: 1))
 45:                 brightness: (0 max: (self brightnessGauge value min: 1)).
 46:     ^aColor
 47: 
 48: ------------------------------------------------------------
 49: 
 50: KSU.ColorHSB method for 'aspects'
 51: 
 52: hueGauge
 53: 
 54:     hueGauge
 55:         ifNil: 
 56:             [hueGauge := 0.5 asValue.
 57:             hueGauge compute: [:aValue | self updateColorHue: aValue]].
 58:     ^hueGauge
 59: 
 60: ------------------------------------------------------------
 61: 
 62: KSU.ColorHSB method for 'interface opening'
 63: 
 64: hueView
 65: 
 66:     | aView |
 67:     aView := ColorHSBView model: self.
 68:     aView aspectSelector: #hue.
 69:     ^aView
 70: 
 71: ------------------------------------------------------------
 72: 
 73: KSU.ColorHSB method for 'initialize-release'
 74: 
 75: initialize
 76: 
 77:     super initialize.
 78:     hueGauge := nil.
 79:     saturationGauge := nil.
 80:     brightnessGauge := nil.
 81:     ^self
 82: 
 83: ------------------------------------------------------------
 84: 
 85: KSU.ColorHSB method for 'interface opening'
 86: 
 87: postOpenWith: aBuilder
 88: 
 89:     super postOpenWith: aBuilder.
 90:     self updateColor
 91: 
 92: ------------------------------------------------------------
 93: 
 94: KSU.ColorHSB method for 'aspects'
 95: 
 96: saturationGauge
 97: 
 98:     saturationGauge
 99:         ifNil: 
100:             [saturationGauge := 0.5 asValue.
101:             saturationGauge compute: [:aValue | self updateColorSaturation: aValue]].
102:     ^saturationGauge
103: 
104: ------------------------------------------------------------
105: 
106: KSU.ColorHSB method for 'interface opening'
107: 
108: saturationView
109: 
110:     | aView |
111:     aView := ColorHSBView model: self.
112:     aView aspectSelector: #saturation.
113:     ^aView
114: 
115: ------------------------------------------------------------
116: 
117: KSU.ColorHSB method for 'private'
118: 
119: updateColor
120: 
121:     self builder
122:         ifNotNil: 
123:             [:aBuilder |
124:             aBuilder window
125:                 ifNotNil: 
126:                     [:aWindow |
127:                     aWindow
128:                         background: self color;
129:                         display]]
130: 
131: ------------------------------------------------------------
132: 
133: KSU.ColorHSB method for 'private'
134: 
135: updateColorBrightness: aValue
136: 
137:     InputState default altDown
138:         ifTrue: 
139:             [self hueGauge value = aValue ifFalse: [self hueGauge value: aValue].
140:             self saturationGauge value = aValue ifFalse: [self saturationGauge value: aValue]].
141:     self updateColor
142: 
143: ------------------------------------------------------------
144: 
145: KSU.ColorHSB method for 'private'
146: 
147: updateColorHue: aValue
148: 
149:     InputState default altDown
150:         ifTrue: 
151:             [self saturationGauge value = aValue ifFalse: [self saturationGauge value: aValue].
152:             self brightnessGauge value = aValue ifFalse: [self brightnessGauge value: aValue]].
153:     self updateColor
154: 
155: ------------------------------------------------------------
156: 
157: KSU.ColorHSB method for 'private'
158: 
159: updateColorSaturation: aValue
160: 
161:     InputState default altDown
162:         ifTrue: 
163:             [self hueGauge value = aValue ifFalse: [self hueGauge value: aValue].
164:             self brightnessGauge value = aValue ifFalse: [self brightnessGauge value: aValue]].
165:     self updateColor
166: 
167: ================================================================================
168: 
169: KSU.ColorHSB class
170:     instanceVariableNames: ''
171: 
172: ================================================================================
173: 
174: KSU.ColorHSB class method for 'examples'
175: 
176: example1
177:     "KSU.ColorHSB example1."
178: 
179:     | anApplication |
180:     anApplication := KSU.ColorHSB new.
181:     anApplication open.
182:     ^anApplication
183: 
184: ------------------------------------------------------------
185: 
186: KSU.ColorHSB class method for 'resources'
187: 
188: menuBar
189:     "Tools.MenuEditor new openOnClass: self andSelector: #menuBar"
190: 
191:     <resource: #menu>
192:     ^#(#{UI.Menu} #(
193:             #(#{UI.MenuItem} 
194:                 #rawLabel: 'ファイル' 
195:                 #submenu: #(#{UI.Menu} #(
196:                         #(#{UI.MenuItem} 
197:                             #rawLabel: '終了' 
198:                             #value: #closeRequest ) ) #(1 ) nil ) ) ) #(1 ) nil ) decodeAsLiteralArray
199: 
200: ------------------------------------------------------------
201: 
202: KSU.ColorHSB class method for 'interface specs'
203: 
204: windowSpec
205:     "Tools.UIPainter new openOnClass: self andSelector: #windowSpec"
206: 
207:     <resource: #canvas>
208:     ^#(#{UI.FullSpec} 
209:         #window: 
210:         #(#{UI.WindowSpec} 
211:             #label: '色相・彩度・明度' 
212:             #min: #(#{Core.Point} 512 160 ) 
213:             #max: #(#{Core.Point} 512 160 ) 
214:             #bounds: #(#{Graphics.Rectangle} 1024 640 1536 800 ) 
215:             #flags: 4 
216:             #menu: #menuBar ) 
217:         #component: 
218:         #(#{UI.SpecCollection} 
219:             #collection: #(
220:                 #(#{UI.LabelSpec} 
221:                     #layout: #(#{Core.Point} 24 17 ) 
222:                     #name: #hueLabel 
223:                     #colors: 
224:                     #(#{UI.LookPreferences} 
225:                         #setBackgroundColor: #(#{Graphics.ColorValue} #pink ) ) 
226:                     #label: '色相 :' ) 
227:                 #(#{UI.LabelSpec} 
228:                     #layout: #(#{Core.Point} 24 49 ) 
229:                     #name: #saturationLabel 
230:                     #colors: 
231:                     #(#{UI.LookPreferences} 
232:                         #setBackgroundColor: #(#{Graphics.ColorValue} 6143 8191 6143 ) ) 
233:                     #label: '彩度:' ) 
234:                 #(#{UI.LabelSpec} 
235:                     #layout: #(#{Core.Point} 24 81 ) 
236:                     #name: #brightnessLabel 
237:                     #colors: 
238:                     #(#{UI.LookPreferences} 
239:                         #setBackgroundColor: #(#{Graphics.ColorValue} 6143 6143 8191 ) ) 
240:                     #label: '明度:' ) 
241:                 #(#{UI.ArbitraryComponentSpec} 
242:                     #layout: #(#{Graphics.Rectangle} 72 17 488 40 ) 
243:                     #name: #hueView 
244:                     #component: #hueView ) 
245:                 #(#{UI.ArbitraryComponentSpec} 
246:                     #layout: #(#{Graphics.Rectangle} 72 49 488 72 ) 
247:                     #name: #saturationView 
248:                     #component: #saturationView ) 
249:                 #(#{UI.ArbitraryComponentSpec} 
250:                     #layout: #(#{Graphics.Rectangle} 72 81 488 104 ) 
251:                     #name: #brightnessView 
252:                     #component: #brightnessView ) ) ) )
253: 
254: ================================================================================

This document was generated by KSU.TextDoclet on 2012/11/10 at 10:32:57.