-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.go
63 lines (52 loc) · 1.46 KB
/
application.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package impress
import (
"image"
"github.com/codeation/impress/clipboard"
"github.com/codeation/impress/driver"
"github.com/codeation/impress/event"
)
// Application represents application top level window
type Application struct {
driver driver.Driver
frame *Frame
}
// MakeApplication creates a top application window for specified GUI driver
func MakeApplication(d driver.Driver, rect image.Rectangle, title string) *Application {
app := &Application{
driver: d,
}
app.driver.Init()
app.driver.Size(rect)
app.driver.Title(title)
app.frame = &Frame{framer: app.driver.NewFrame(image.Rect(0, 0, rect.Dx(), rect.Dy()))}
return app
}
// Close destroys application resources
func (app *Application) Close() {
app.frame.Drop()
app.driver.Done()
}
// Sync flushes graphics content to screen driver
func (app *Application) Sync() {
app.driver.Sync()
}
// Title sets application window title
func (app *Application) Title(title string) {
app.driver.Title(title)
}
// Size sets application window size
func (app *Application) Size(rect image.Rectangle) {
app.driver.Size(rect)
}
// ClipboardGet requests event with clipboard content
func (app *Application) ClipboardGet(typeID int) {
app.driver.ClipboardGet(typeID)
}
// ClipboardPut set content to OS clipboard
func (app *Application) ClipboardPut(c clipboard.Clipboarder) {
app.driver.ClipboardPut(c)
}
// Chan returns event channel
func (app *Application) Chan() <-chan event.Eventer {
return app.driver.Chan()
}