Split out the code to add a Control to a Mac OS X Window into its own function.
This commit is contained in:
parent
11d4f96e77
commit
b2e49b3698
|
@ -239,8 +239,7 @@ func makeListbox(parentWindow C.id, alternate bool) C.id {
|
||||||
C.objc_msgSend_id(listbox, _setHeaderView, C.nilid)
|
C.objc_msgSend_id(listbox, _setHeaderView, C.nilid)
|
||||||
// TODO others?
|
// TODO others?
|
||||||
listbox = newListboxScrollView(listbox)
|
listbox = newListboxScrollView(listbox)
|
||||||
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
addControl(parentWindow, listbox)
|
||||||
C.objc_msgSend_id(windowView, _addSubview, listbox)
|
|
||||||
return listbox
|
return listbox
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,11 @@ var (
|
||||||
_setDoubleValue = sel_getUid("setDoubleValue:")
|
_setDoubleValue = sel_getUid("setDoubleValue:")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func addControl(parentWindow C.id, control C.id) {
|
||||||
|
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
||||||
|
C.objc_msgSend_id(windowView, _addSubview, control)
|
||||||
|
}
|
||||||
|
|
||||||
func controlShow(what C.id) {
|
func controlShow(what C.id) {
|
||||||
C.objc_msgSend_bool(what, _setHidden, C.BOOL(C.NO))
|
C.objc_msgSend_bool(what, _setHidden, C.BOOL(C.NO))
|
||||||
}
|
}
|
||||||
|
@ -127,8 +132,7 @@ var classTypes = [nctypes]*classData{
|
||||||
objc_msgSend_uint(button, _setBezelStyle, 1) // NSRoundedBezelStyle
|
objc_msgSend_uint(button, _setBezelStyle, 1) // NSRoundedBezelStyle
|
||||||
C.objc_msgSend_id(button, _setTarget, appDelegate)
|
C.objc_msgSend_id(button, _setTarget, appDelegate)
|
||||||
C.objc_msgSend_sel(button, _setAction, _buttonClicked)
|
C.objc_msgSend_sel(button, _setAction, _buttonClicked)
|
||||||
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
addControl(parentWindow, button)
|
||||||
C.objc_msgSend_id(windowView, _addSubview, button)
|
|
||||||
return button
|
return button
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
|
@ -142,8 +146,7 @@ var classTypes = [nctypes]*classData{
|
||||||
checkbox = objc_msgSend_rect(checkbox, _initWithFrame,
|
checkbox = objc_msgSend_rect(checkbox, _initWithFrame,
|
||||||
0, 0, 100, 100)
|
0, 0, 100, 100)
|
||||||
objc_msgSend_uint(checkbox, _setButtonType, 3) // NSSwitchButton
|
objc_msgSend_uint(checkbox, _setButtonType, 3) // NSSwitchButton
|
||||||
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
addControl(parentWindow, checkbox)
|
||||||
C.objc_msgSend_id(windowView, _addSubview, checkbox)
|
|
||||||
return checkbox
|
return checkbox
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
|
@ -166,8 +169,7 @@ var classTypes = [nctypes]*classData{
|
||||||
0, 0, 100, 100,
|
0, 0, 100, 100,
|
||||||
C.BOOL(C.NO))
|
C.BOOL(C.NO))
|
||||||
}
|
}
|
||||||
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
addControl(parentWindow, combobox)
|
||||||
C.objc_msgSend_id(windowView, _addSubview, combobox)
|
|
||||||
return combobox
|
return combobox
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
|
@ -209,8 +211,7 @@ var classTypes = [nctypes]*classData{
|
||||||
}
|
}
|
||||||
lineedit = objc_msgSend_rect(lineedit, _initWithFrame,
|
lineedit = objc_msgSend_rect(lineedit, _initWithFrame,
|
||||||
0, 0, 100, 100)
|
0, 0, 100, 100)
|
||||||
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
addControl(parentWindow, lineedit)
|
||||||
C.objc_msgSend_id(windowView, _addSubview, lineedit)
|
|
||||||
return lineedit
|
return lineedit
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
|
@ -228,8 +229,7 @@ var classTypes = [nctypes]*classData{
|
||||||
C.objc_msgSend_bool(label, _setBordered, C.BOOL(C.NO))
|
C.objc_msgSend_bool(label, _setBordered, C.BOOL(C.NO))
|
||||||
C.objc_msgSend_bool(label, _setDrawsBackground, C.BOOL(C.NO))
|
C.objc_msgSend_bool(label, _setDrawsBackground, C.BOOL(C.NO))
|
||||||
// TODO others?
|
// TODO others?
|
||||||
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
addControl(parentWindow, label)
|
||||||
C.objc_msgSend_id(windowView, _addSubview, label)
|
|
||||||
return label
|
return label
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
|
@ -256,8 +256,7 @@ var classTypes = [nctypes]*classData{
|
||||||
C.objc_msgSend_int(pbar, _setStyle, 0) // NSProgressIndicatorBarStyle
|
C.objc_msgSend_int(pbar, _setStyle, 0) // NSProgressIndicatorBarStyle
|
||||||
objc_msgSend_uint(pbar, _setControlSize, 0) // NSRegularControlSize
|
objc_msgSend_uint(pbar, _setControlSize, 0) // NSRegularControlSize
|
||||||
C.objc_msgSend_bool(pbar, _setIndeterminate, C.BOOL(C.NO))
|
C.objc_msgSend_bool(pbar, _setIndeterminate, C.BOOL(C.NO))
|
||||||
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
addControl(parentWindow, pbar)
|
||||||
C.objc_msgSend_id(windowView, _addSubview, pbar)
|
|
||||||
return pbar
|
return pbar
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
|
|
Loading…
Reference in New Issue