1: ================================================================================
2:
3: Smalltalk.KSU defineClass: #ColorHSBView
4: superclass: #{UI.View}
5: indexedType: #none
6: private: false
7: instanceVariableNames: 'aspectSelector '
8: classInstanceVariableNames: ''
9: imports: ''
10: category: ''
11:
12: ================================================================================
13:
14: KSU.ColorHSBView method for 'accessing'
15:
16: aspectArea
17:
18: ^self bounds insetBy: self defaultInset
19:
20: ------------------------------------------------------------
21:
22: KSU.ColorHSBView method for 'accessing'
23:
24: aspectSelector
25:
26: ^aspectSelector
27:
28: ------------------------------------------------------------
29:
30: KSU.ColorHSBView method for 'accessing'
31:
32: aspectSelector: aSymbol
33:
34: aspectSelector := aSymbol
35:
36: ------------------------------------------------------------
37:
38: KSU.ColorHSBView method for 'controller accessing'
39:
40: defaultControllerClass
41:
42: ^KSU.ColorHSBController
43:
44: ------------------------------------------------------------
45:
46: KSU.ColorHSBView method for 'defaults'
47:
48: defaultInset
49:
50: ^6 @ 6
51:
52: ------------------------------------------------------------
53:
54: KSU.ColorHSBView method for 'displaying'
55:
56: displayAspectAreaOn: graphicsContext
57:
58: | pixmap gc area symbol left right top bottom |
59: pixmap := Pixmap extent: self aspectArea extent.
60: gc := pixmap graphicsContext.
61: area := pixmap bounds.
62: symbol := self aspectSelector.
63: left := area left.
64: right := area right.
65: top := area top.
66: bottom := area bottom.
67: left to: right - 1
68: do:
69: [:x |
70: | value color box |
71: value := (x - left) / (right - left).
72: color := self model color.
73: symbol = #hue
74: ifTrue:
75: [color := ColorValue
76: hue: value
77: saturation: 1 yourself
78: brightness: 1 yourself].
79: symbol = #saturation
80: ifTrue:
81: [color := ColorValue
82: hue: color hue
83: saturation: value
84: brightness: 1 yourself].
85: symbol = #brightness
86: ifTrue:
87: [color := ColorValue
88: hue: color hue
89: saturation: color saturation
90: brightness: value].
91: box := x @ top corner: (x + 1) @ bottom.
92: gc
93: paint: color;
94: displayRectangle: box].
95: pixmap
96: displayOn: graphicsContext at: self aspectArea origin;
97: close
98:
99: ------------------------------------------------------------
100:
101: KSU.ColorHSBView method for 'displaying'
102:
103: displayAspectAreasOutsideOn: graphicsContext
104:
105: graphicsContext paint: self backgroundColor.
106: (self bounds areasOutside: self aspectArea) do: [:aRectangle | graphicsContext displayRectangle: aRectangle]
107:
108: ------------------------------------------------------------
109:
110: KSU.ColorHSBView method for 'displaying'
111:
112: displayMarksOn: graphicsContext
113:
114: | symbol color value area point box points |
115: symbol := self aspectSelector.
116: color := self model color.
117: value := color perform: symbol.
118: area := self aspectArea.
119: point := ((value * area width + area left) @ area top) rounded.
120: box := 0 @ 0 corner: self defaultInset.
121: box := box align: box bottomCenter with: point.
122: points := Array
123: with: box bottomCenter
124: with: box topLeft
125: with: box topRight
126: with: box bottomCenter.
127: graphicsContext
128: paint: ColorValue black;
129: displayPolygon: points.
130: box := box insetBy: 1.
131: points := Array
132: with: box bottomCenter
133: with: box topLeft
134: with: box topRight
135: with: box bottomCenter.
136: graphicsContext
137: paint: ColorValue white;
138: displayPolygon: points.
139: point := ((value * area width + area left) @ area bottom) rounded.
140: box := 0 @ 0 corner: self defaultInset.
141: box := box align: box topCenter with: point.
142: points := Array
143: with: box topCenter
144: with: box bottomLeft
145: with: box bottomRight
146: with: box topCenter.
147: graphicsContext
148: paint: ColorValue black;
149: displayPolygon: points.
150: box := box insetBy: 1.
151: points := Array
152: with: box topCenter
153: with: box bottomLeft
154: with: box bottomRight
155: with: box topCenter.
156: graphicsContext
157: paint: ColorValue white;
158: displayPolygon: points
159:
160: ------------------------------------------------------------
161:
162: KSU.ColorHSBView method for 'displaying'
163:
164: displayOn: graphicsContext
165:
166: self model ifNil: [^nil].
167: self
168: displayAspectAreasOutsideOn: graphicsContext;
169: displayAspectAreaOn: graphicsContext;
170: displayMarksOn: graphicsContext
171:
172: ------------------------------------------------------------
173:
174: KSU.ColorHSBView method for 'initialize-release'
175:
176: initialize
177:
178: super initialize.
179: aspectSelector := nil.
180: ^self
181:
182: ------------------------------------------------------------
183:
184: KSU.ColorHSBView method for 'updating'
185:
186: update: aspectSymbol
187:
188: self invalidateNow
189:
190: ================================================================================
191:
192: KSU.ColorHSBView class
193: instanceVariableNames: ''
194:
195: ================================================================================
This document was generated by KSU.TextDoclet on 2012/11/10 at 10:56:49.