From 1095719d84a6ac5f90eefe8e23913f3e09ad692d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 26 Aug 2018 13:33:54 -0400 Subject: Migrated more controls. --- progressbar.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 progressbar.go (limited to 'progressbar.go') diff --git a/progressbar.go b/progressbar.go new file mode 100644 index 0000000..4c771df --- /dev/null +++ b/progressbar.go @@ -0,0 +1,39 @@ +// 12 december 2015 + +package ui + +import ( + "unsafe" +) + +// #include "pkgui.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 { + ControlBase + p *C.uiProgressBar +} + +// NewProgressBar creates a new ProgressBar. +func NewProgressBar() *ProgressBar { + p := new(ProgressBar) + + p.p = C.uiNewProgressBar() + + p.ControlBase = NewControlBase(p, uintptr(unsafe.Pointer(p.p))) + return p +} + +// Value returns the value currently shown in the ProgressBar. +func (p *ProgressBar) Value() int { + return int(C.uiProgressBarValue(p.p)) +} + +// SetValue sets the ProgressBar's currently displayed percentage +// to value. value must be between 0 and 100 inclusive, or -1 for +// an indeterminate progressbar. +func (p *ProgressBar) SetValue(value int) { + C.uiProgressBarSetValue(p.p, C.int(value)) +} -- cgit v1.2.3