forked from andlabs/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
progressbar.go
77 lines (61 loc) · 1.76 KB
/
progressbar.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
// 12 december 2015
package ui
import (
"unsafe"
)
// #include "ui.h"
import "C"
// ProgressBar is a Control that represents a horizontal bar that
// is filled in progressively over time as a process completes.
type ProgressBar struct {
c *C.uiControl
p *C.uiProgressBar
}
// NewProgressBar creates a new ProgressBar.
func NewProgressBar() *ProgressBar {
p := new(ProgressBar)
p.p = C.uiNewProgressBar()
p.c = (*C.uiControl)(unsafe.Pointer(p.p))
return p
}
// Destroy destroys the ProgressBar.
func (p *ProgressBar) Destroy() {
C.uiControlDestroy(p.c)
}
// LibuiControl returns the libui uiControl pointer that backs
// the Window. This is only used by package ui itself and should
// not be called by programs.
func (p *ProgressBar) LibuiControl() uintptr {
return uintptr(unsafe.Pointer(p.c))
}
// Handle returns the OS-level handle associated with this ProgressBar.
// On Windows this is an HWND of a standard Windows API
// PROGRESS_CLASS class (as provided by Common Controls
// version 6).
// On GTK+ this is a pointer to a GtkProgressBar.
// On OS X this is a pointer to a NSProgressIndicator.
func (p *ProgressBar) Handle() uintptr {
return uintptr(C.uiControlHandle(p.c))
}
// Show shows the ProgressBar.
func (p *ProgressBar) Show() {
C.uiControlShow(p.c)
}
// Hide hides the ProgressBar.
func (p *ProgressBar) Hide() {
C.uiControlHide(p.c)
}
// Enable enables the ProgressBar.
func (p *ProgressBar) Enable() {
C.uiControlEnable(p.c)
}
// Disable disables the ProgressBar.
func (p *ProgressBar) Disable() {
C.uiControlDisable(p.c)
}
// TODO Value
// SetValue sets the ProgressBar's currently displayed percentage
// to value. value must be between 0 and 100 inclusive.
func (p *ProgressBar) SetValue(value int) {
C.uiProgressBarSetValue(p.p, C.int(value))
}