-
Notifications
You must be signed in to change notification settings - Fork 3
/
editors.go
49 lines (39 loc) · 923 Bytes
/
editors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package gohotdraw
import (
_ "fmt"
)
type DrawingEditor interface {
FigureSelectionListener
GetView() DrawingView
SetView(view DrawingView)
SetTool(tool Tool)
GetTool() Tool
ToolDone()
}
type DefaultDrawingEditor struct {
view DrawingView
tool Tool
}
func NewDefaultDrawingEditor() *DefaultDrawingEditor {
editor := &DefaultDrawingEditor{}
return editor
}
func (this *DefaultDrawingEditor) GetView() DrawingView {
return this.view
}
func (this *DefaultDrawingEditor) SetView(view DrawingView) {
this.view = view
this.view.AddFigureSelectionListener(this)
}
func (this *DefaultDrawingEditor) GetTool() Tool {
return this.tool
}
func (this *DefaultDrawingEditor) SetTool(tool Tool) {
this.tool = tool
}
func (this *DefaultDrawingEditor) ToolDone() {
//do nothing, could be changed to set default tool
}
func (this *DefaultDrawingEditor) FigureSelectionChanged(view DrawingView) {
view.Repaint()
}