Removed all code that uses OpenGL from Image.
[io/quag.git] / addons / Flux / samples / Diagram / Background.io
blob433494cbb5b851e6d03b3e750d5855ca4e6c954c
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(
13 box := DBox clone
14 addSubview(box)
15 box orderFront
16 box setPosition(screenToView(Mouse position) - (box size / 2))
17 box alignToGrid
18 box select
19 box beginEditMode
22 leftMouseDown := method(
23 subviews foreach(?unselect)
24 makeFirstResponder
25 shiftLeftMouseDown
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
37 glutPostRedisplay
40 updateSelection := method(
41 if(selectionArea,
42 removeSubview(selectionArea)
43 subviews foreach(v,
44 if(v ?isBox and selectionArea frame containsPoint(v center), v select)
46 setSelectionArea(nil)
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
70 draw := method(
71 backgroundColor glColor
72 size drawQuad
74 outlineColor glColor
75 glLineWidth(1)
76 glBegin(GL_LINES)
77 for(x, 0, width, gridSize,
78 glVertex2d(x, 0)
79 glVertex2d(x, height)
81 glEnd
83 glBegin(GL_LINES)
84 for(y, 0, height, gridSize,
85 glVertex2d(0, y)
86 glVertex2d(width, y)
88 glEnd
92 Background background := Background