summaryrefslogtreecommitdiff
path: root/prev/progressbar_darwin.go
blob: 51fd41aac3f1b8e1a38bca7355c757fa46166851 (plain)
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
// 4 november 2014

package ui

import (
	"fmt"
)

// #include "objc_darwin.h"
import "C"

type progressbar struct {
	*controlSingleObject
}

func newProgressBar() ProgressBar {
	return &progressbar{
		controlSingleObject:		newControlSingleObject(C.newProgressBar()),
	}
}

func (p *progressbar) Percent() int {
	return int(C.progressbarPercent(p.id))
}

func (p *progressbar) SetPercent(percent int) {
	if percent < 0 || percent > 100 {
		panic(fmt.Errorf("given ProgressBar percentage %d out of range", percent))
	}
	C.progressbarSetPercent(p.id, C.intmax_t(percent))
}