More go fmt.
This commit is contained in:
parent
37bc89fe52
commit
a3222f248d
22
label.go
22
label.go
|
@ -10,17 +10,17 @@ import (
|
||||||
// Label text is drawn on a single line; text that does not fit is truncated.
|
// Label text is drawn on a single line; text that does not fit is truncated.
|
||||||
// TODO vertical alignment
|
// TODO vertical alignment
|
||||||
type Label struct {
|
type Label struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
created bool
|
created bool
|
||||||
sysData *sysData
|
sysData *sysData
|
||||||
initText string
|
initText string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLabel creates a new Label with the specified text.
|
// NewLabel creates a new Label with the specified text.
|
||||||
func NewLabel(text string) *Label {
|
func NewLabel(text string) *Label {
|
||||||
return &Label{
|
return &Label{
|
||||||
sysData: mksysdata(c_label),
|
sysData: mksysdata(c_label),
|
||||||
initText: text,
|
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) {
|
func (l *Label) setRect(x int, y int, width int, height int, rr *[]resizerequest) {
|
||||||
*rr = append(*rr, resizerequest{
|
*rr = append(*rr, resizerequest{
|
||||||
sysData: l.sysData,
|
sysData: l.sysData,
|
||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
lineedit.go
28
lineedit.go
|
@ -8,26 +8,26 @@ import (
|
||||||
|
|
||||||
// A LineEdit is a control which allows you to enter a single line of text.
|
// A LineEdit is a control which allows you to enter a single line of text.
|
||||||
type LineEdit struct {
|
type LineEdit struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
created bool
|
created bool
|
||||||
sysData *sysData
|
sysData *sysData
|
||||||
initText string
|
initText string
|
||||||
password bool
|
password bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLineEdit makes a new LineEdit with the specified text.
|
// NewLineEdit makes a new LineEdit with the specified text.
|
||||||
func NewLineEdit(text string) *LineEdit {
|
func NewLineEdit(text string) *LineEdit {
|
||||||
return &LineEdit{
|
return &LineEdit{
|
||||||
sysData: mksysdata(c_lineedit),
|
sysData: mksysdata(c_lineedit),
|
||||||
initText: text,
|
initText: text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPasswordEdit makes a new LineEdit which allows the user to enter a password.
|
// NewPasswordEdit makes a new LineEdit which allows the user to enter a password.
|
||||||
func NewPasswordEdit() *LineEdit {
|
func NewPasswordEdit() *LineEdit {
|
||||||
return &LineEdit{
|
return &LineEdit{
|
||||||
sysData: mksysdata(c_lineedit),
|
sysData: mksysdata(c_lineedit),
|
||||||
password: true,
|
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) {
|
func (l *LineEdit) setRect(x int, y int, width int, height int, rr *[]resizerequest) {
|
||||||
*rr = append(*rr, resizerequest{
|
*rr = append(*rr, resizerequest{
|
||||||
sysData: l.sysData,
|
sysData: l.sysData,
|
||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
26
listbox.go
26
listbox.go
|
@ -12,16 +12,16 @@ import (
|
||||||
// For information on scrollbars, see "Scrollbars" in the Overview.
|
// For information on scrollbars, see "Scrollbars" in the Overview.
|
||||||
// Due to implementation issues, the presence of horizontal scrollbars is currently implementation-defined.
|
// Due to implementation issues, the presence of horizontal scrollbars is currently implementation-defined.
|
||||||
type Listbox struct {
|
type Listbox struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
created bool
|
created bool
|
||||||
sysData *sysData
|
sysData *sysData
|
||||||
initItems []string
|
initItems []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newListbox(multiple bool, items ...string) (l *Listbox) {
|
func newListbox(multiple bool, items ...string) (l *Listbox) {
|
||||||
l = &Listbox{
|
l = &Listbox{
|
||||||
sysData: mksysdata(c_listbox),
|
sysData: mksysdata(c_listbox),
|
||||||
initItems: items,
|
initItems: items,
|
||||||
}
|
}
|
||||||
l.sysData.alternate = multiple
|
l.sysData.alternate = multiple
|
||||||
return l
|
return l
|
||||||
|
@ -70,7 +70,7 @@ func (l *Listbox) InsertBefore(what string, before int) {
|
||||||
if before < 0 || before >= len(l.initItems) {
|
if before < 0 || before >= len(l.initItems) {
|
||||||
goto badrange
|
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, l.initItems[:before]...)
|
||||||
m = append(m, what)
|
m = append(m, what)
|
||||||
l.initItems = append(m, l.initItems[before:]...)
|
l.initItems = append(m, l.initItems[before:]...)
|
||||||
|
@ -94,7 +94,7 @@ func (l *Listbox) Delete(index int) {
|
||||||
if index < 0 || index >= len(l.initItems) {
|
if index < 0 || index >= len(l.initItems) {
|
||||||
goto badrange
|
goto badrange
|
||||||
}
|
}
|
||||||
l.initItems = append(l.initItems[:index], l.initItems[index + 1:]...)
|
l.initItems = append(l.initItems[:index], l.initItems[index+1:]...)
|
||||||
return
|
return
|
||||||
badrange:
|
badrange:
|
||||||
panic(fmt.Errorf("index %d out of range in Listbox.Delete()", index))
|
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) {
|
func (l *Listbox) setRect(x int, y int, width int, height int, rr *[]resizerequest) {
|
||||||
*rr = append(*rr, resizerequest{
|
*rr = append(*rr, resizerequest{
|
||||||
sysData: l.sysData,
|
sysData: l.sysData,
|
||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
package ui
|
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.
|
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)
|
return fromListboxItem(dict)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Now we have to establish the binding. To do this, we need the following things:
|
Now we have to establish the binding. To do this, we need the following things:
|
||||||
- the object to bind (NSTableColumn)
|
- 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 {
|
func makeListboxScrollView(listbox C.id) C.id {
|
||||||
scrollview := makeScrollView(listbox)
|
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
|
return scrollview
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +185,7 @@ func listboxSelectedIndices(listbox C.id) (list []int) {
|
||||||
list = make([]int, count)
|
list = make([]int, count)
|
||||||
list[0] = int(C.listboxIndexesFirst(indices))
|
list[0] = int(C.listboxIndexesFirst(indices))
|
||||||
for i := 1; i < count; i++ {
|
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
|
return list
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue