More go fmt.

This commit is contained in:
Pietro Gagliardi 2014-06-10 11:38:52 -04:00
parent 37bc89fe52
commit a3222f248d
4 changed files with 40 additions and 45 deletions

View File

@ -10,17 +10,17 @@ import (
// Label text is drawn on a single line; text that does not fit is truncated.
// TODO vertical alignment
type Label struct {
lock sync.Mutex
created bool
sysData *sysData
initText string
lock sync.Mutex
created bool
sysData *sysData
initText string
}
// NewLabel creates a new Label with the specified text.
func NewLabel(text string) *Label {
return &Label{
sysData: mksysdata(c_label),
initText: text,
sysData: mksysdata(c_label),
initText: text,
}
}
@ -62,11 +62,11 @@ func (l *Label) make(window *sysData) error {
func (l *Label) setRect(x int, y int, width int, height int, rr *[]resizerequest) {
*rr = append(*rr, resizerequest{
sysData: l.sysData,
x: x,
y: y,
width: width,
height: height,
sysData: l.sysData,
x: x,
y: y,
width: width,
height: height,
})
}

View File

@ -8,26 +8,26 @@ import (
// A LineEdit is a control which allows you to enter a single line of text.
type LineEdit struct {
lock sync.Mutex
created bool
sysData *sysData
initText string
password bool
lock sync.Mutex
created bool
sysData *sysData
initText string
password bool
}
// NewLineEdit makes a new LineEdit with the specified text.
func NewLineEdit(text string) *LineEdit {
return &LineEdit{
sysData: mksysdata(c_lineedit),
initText: text,
sysData: mksysdata(c_lineedit),
initText: text,
}
}
// NewPasswordEdit makes a new LineEdit which allows the user to enter a password.
func NewPasswordEdit() *LineEdit {
return &LineEdit{
sysData: mksysdata(c_lineedit),
password: true,
sysData: mksysdata(c_lineedit),
password: true,
}
}
@ -70,11 +70,11 @@ func (l *LineEdit) make(window *sysData) error {
func (l *LineEdit) setRect(x int, y int, width int, height int, rr *[]resizerequest) {
*rr = append(*rr, resizerequest{
sysData: l.sysData,
x: x,
y: y,
width: width,
height: height,
sysData: l.sysData,
x: x,
y: y,
width: width,
height: height,
})
}

View File

@ -12,16 +12,16 @@ import (
// For information on scrollbars, see "Scrollbars" in the Overview.
// Due to implementation issues, the presence of horizontal scrollbars is currently implementation-defined.
type Listbox struct {
lock sync.Mutex
created bool
sysData *sysData
initItems []string
lock sync.Mutex
created bool
sysData *sysData
initItems []string
}
func newListbox(multiple bool, items ...string) (l *Listbox) {
l = &Listbox{
sysData: mksysdata(c_listbox),
initItems: items,
sysData: mksysdata(c_listbox),
initItems: items,
}
l.sysData.alternate = multiple
return l
@ -70,7 +70,7 @@ func (l *Listbox) InsertBefore(what string, before int) {
if before < 0 || before >= len(l.initItems) {
goto badrange
}
m = make([]string, 0, len(l.initItems) + 1)
m = make([]string, 0, len(l.initItems)+1)
m = append(m, l.initItems[:before]...)
m = append(m, what)
l.initItems = append(m, l.initItems[before:]...)
@ -94,7 +94,7 @@ func (l *Listbox) Delete(index int) {
if index < 0 || index >= len(l.initItems) {
goto badrange
}
l.initItems = append(l.initItems[:index], l.initItems[index + 1:]...)
l.initItems = append(l.initItems[:index], l.initItems[index+1:]...)
return
badrange:
panic(fmt.Errorf("index %d out of range in Listbox.Delete()", index))
@ -152,11 +152,11 @@ func (l *Listbox) make(window *sysData) (err error) {
func (l *Listbox) setRect(x int, y int, width int, height int, rr *[]resizerequest) {
*rr = append(*rr, resizerequest{
sysData: l.sysData,
x: x,
y: y,
width: width,
height: height,
sysData: l.sysData,
x: x,
y: y,
width: width,
height: height,
})
}

View File

@ -2,10 +2,6 @@
package ui
import (
// ...
)
/*
The Cocoa API was not designed to be used directly in code; you were intended to build your user interfaces with Interface Builder. There is no dedicated listbox class; we have to synthesize it with a NSTableView. And this is difficult in code.
@ -81,7 +77,6 @@ func listboxArrayItemAt(array C.id, index int) string {
return fromListboxItem(dict)
}
/*
Now we have to establish the binding. To do this, we need the following things:
- the object to bind (NSTableColumn)
@ -139,7 +134,7 @@ The actual creation code was moved to objc_darwin.go.
func makeListboxScrollView(listbox C.id) C.id {
scrollview := makeScrollView(listbox)
C.giveScrollViewBezelBorder(scrollview) // this is what Interface Builder gives the scroll view
C.giveScrollViewBezelBorder(scrollview) // this is what Interface Builder gives the scroll view
return scrollview
}
@ -190,7 +185,7 @@ func listboxSelectedIndices(listbox C.id) (list []int) {
list = make([]int, count)
list[0] = int(C.listboxIndexesFirst(indices))
for i := 1; i < count; i++ {
list[i] = int(C.listboxIndexesNext(indices, C.uintptr_t(list[i - 1])))
list[i] = int(C.listboxIndexesNext(indices, C.uintptr_t(list[i-1])))
}
return list
}