summaryrefslogtreecommitdiff
path: root/prev/progressbar_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-12-11 20:37:59 -0500
committerPietro Gagliardi <[email protected]>2015-12-11 20:37:59 -0500
commitf8e3f12ab02b528f2a05a4f713d7af7ea8e44b42 (patch)
tree82dedf4d37f0f6d31e88ebb2ca1ce6499dead261 /prev/progressbar_windows.go
parente34c561ed5bedeb180437ec165882b98d70d38c1 (diff)
LET'S GET THIS FINAL REWRITE EVER STARTED
Diffstat (limited to 'prev/progressbar_windows.go')
-rw-r--r--prev/progressbar_windows.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/prev/progressbar_windows.go b/prev/progressbar_windows.go
new file mode 100644
index 0000000..807b0c1
--- /dev/null
+++ b/prev/progressbar_windows.go
@@ -0,0 +1,52 @@
+// 4 november 2014
+
+package ui
+
+import (
+ "fmt"
+)
+
+// #include "winapi_windows.h"
+import "C"
+
+type progressbar struct {
+ *controlSingleHWND
+}
+
+func newProgressBar() ProgressBar {
+ hwnd := C.newControl(C.xPROGRESS_CLASS,
+ C.PBS_SMOOTH,
+ 0)
+ p := &progressbar{
+ controlSingleHWND: newControlSingleHWND(hwnd),
+ }
+ p.fpreferredSize = p.xpreferredSize
+ p.fnTabStops = func() int {
+ // progress bars are not tab stops
+ return 0
+ }
+ return p
+}
+
+func (p *progressbar) Percent() int {
+ return int(C.SendMessageW(p.hwnd, C.PBM_GETPOS, 0, 0))
+}
+
+func (p *progressbar) SetPercent(percent int) {
+ if percent < 0 || percent > 100 {
+ panic(fmt.Errorf("given ProgressBar percentage %d out of range", percent))
+ }
+ // TODO circumvent aero
+ C.SendMessageW(p.hwnd, C.PBM_SETPOS, C.WPARAM(percent), 0)
+}
+
+const (
+ // via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx
+ // this is the double-width option
+ progressbarWidth = 237
+ progressbarHeight = 8
+)
+
+func (p *progressbar) xpreferredSize(d *sizing) (width, height int) {
+ return fromdlgunitsX(progressbarWidth, d), fromdlgunitsY(progressbarHeight, d)
+}