2 Background
:= View
clone do(
3 newSlot("gridSize", 10)
4 setBackgroundColor(Point clone set(.1, .1, .1, 1))
5 setOutlineColor(Point clone set(1, 1, 1, .03))
6 resizeWidthWithSuperview
7 resizeHeightWithSuperview
8 newSlot("selectionArea", nil
)
10 newSlot("lastBox", nil
)
12 doubleLeftMouseDown
:= method(
16 box
setPosition(screenToView(Mouse position
) - (box size
/ 2))
22 leftMouseDown
:= method(
23 subviews
foreach(?unselect
)
28 shiftLeftMouseDown
:= method(
29 if(selectionArea
== nil
,
30 selectionArea
= SelectionArea
31 selectionArea position
copy(Mouse position
)
32 selectionArea size
set(0, 0)
33 addSubview(selectionArea
)
34 selectionArea makeFirstResponder
35 selectionArea orderFront
40 updateSelection
:= method(
42 removeSubview(selectionArea
)
44 if(v ?isBox
and selectionArea frame
containsPoint(v center
), v select
)
50 leftMouseUp
:= method(updateSelection
)
52 shiftLeftMouseUp
:= method(updateSelection
)
54 rightMouseDown
:= method(
55 writeln("add code to add a line")
58 rightMouseUp
:= method(
61 keyboard
:= method(key
,
62 writeln("Background keyboard")
63 if(key
== GLUT_KEY_ESC
, glutFullScreen
) // escape
64 if(key
== 24, subviews
select(?isSelected
) foreach(?delete
)) // control
-x
65 //8 = delete
1, 127 = delete
2
68 acceptsFirstResponder
:= false
71 backgroundColor glColor
77 for(x
, 0, width
, gridSize
,
84 for(y
, 0, height
, gridSize
,
92 Background background
:= Background