-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbutton.go
90 lines (69 loc) · 2.4 KB
/
button.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package x11ui
import "log"
type Button struct {
*Window
}
func NewButton(title string, p *Window, dims ...int) *Window {
// var btn Window
if p == nil {
log.Fatal("Cannot Create Widget without Application")
}
btn := newWindow(p.Window.X, p, title, dims...)
btn.isButton = true
// btn.SetTitle(title)
// btn.Rect = newRect(dims...)
// sshot, gerr := xgraphics.NewDrawable(X, xproto.Drawable(btn.Window.Id))
// if gerr != nil {
// log.Println("Error Loading Drawable Image ", gerr)
// }
// sshot.XShowExtra("nothing", )
// log.Println("Trying to save ", btn.Title()+".png")
// sshot.SavePng(btn.Title() + ".png")
return btn
}
func NewToggleButton(title string, p *Window, dims ...int) *Window {
// var btn Window
btn := newWindow(p.Window.X, p, title, dims...)
btn.isButton = true
btn.isCheckBox = true
// btn.SetTitle(title)
// btn.Rect = newRect(dims...)
// sshot, gerr := xgraphics.NewDrawable(X, xproto.Drawable(btn.Window.Id))
// if gerr != nil {
// log.Println("Error Loading Drawable Image ", gerr)
// }
// sshot.XShowExtra("nothing", )
// log.Println("Trying to save ", btn.Title()+".png")
// sshot.SavePng(btn.Title() + ".png")
return btn
}
// // drawGopher draws the gopher image to the canvas.
// func drawGopher(canvas *xgraphics.Image, gopher image.Image,
// win *xwindow.Window) {
// // Find the rectangle of the canvas where we're going to draw the gopher.
// gopherRect := image.Rect(50, 50, 200, 200) // midRect(x, y, gopherWidth, gopherHeight, width, height)
// // If the rectangle contains no pixels, don't draw anything.
// if gopherRect.Empty() {
// return
// }
// // Output a little message.
// // log.Printf("Drawing gopher at (%d, %d)", x, y)
// // Get a subimage of the gopher that's in sync with gopherRect.
// gopherPt := image.Pt(0, 0)
// // gopherPt := image.Pt(gopher.Bounds().Min.X, gopher.Bounds().Min.Y)
// // if gopherRect.Min.X == 0 {
// // gopherPt.X = gopherWidth - gopherRect.Dx()
// // }
// // if gopherRect.Min.Y == 0 {
// // gopherPt.Y = gopherHeight - gopherRect.Dy()
// // }
// // Create the canvas subimage.
// subCanvas := canvas.SubImage(gopherRect).(*xgraphics.Image)
// // Blend the gopher image into the sub-canvas.
// // This does alpha blending.
// xgraphics.Blend(subCanvas, gopher, gopherPt)
// // Now draw the changes to the pixmap.
// subCanvas.XDraw()
// // And paint them to the window.
// subCanvas.XPaint(win.Id)
// }