Removed objc_msgSend_rect(). This also consolidates all initWithFrame: calls into a simple initWithDummyFrame().
This commit is contained in:
parent
dd4a7b9cbe
commit
5a5b486b6a
|
@ -278,8 +278,7 @@ func areaView_flagsChanged(self C.id, sel C.SEL, e C.id) {
|
|||
|
||||
func newAreaScrollView(area C.id) C.id {
|
||||
scrollview := objc_alloc(_NSScrollView)
|
||||
scrollview = objc_msgSend_rect(scrollview, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
scrollview = initWithDummyFrame(scrollview)
|
||||
C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES))
|
||||
C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES))
|
||||
C.objc_msgSend_bool(scrollview, _setAutohidesScrollers, C.BOOL(C.YES))
|
||||
|
@ -293,8 +292,7 @@ func areaInScrollView(scrollview C.id) C.id {
|
|||
|
||||
func makeArea(parentWindow C.id, alternate bool) C.id {
|
||||
area := objc_alloc(_goArea)
|
||||
area = objc_msgSend_rect(area, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
area = initWithDummyFrame(area)
|
||||
// TODO others?
|
||||
area = newAreaScrollView(area)
|
||||
addControl(parentWindow, area)
|
||||
|
|
|
@ -103,7 +103,7 @@ struct xrect objc_msgSend_stret_rect_noargs(id obj, SEL sel)
|
|||
|
||||
#define OurRect() (NSMakeRect((CGFloat) x, (CGFloat) y, (CGFloat) w, (CGFloat) h))
|
||||
|
||||
id _objc_msgSend_rect(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h)
|
||||
id objc_msgSend_rect(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h)
|
||||
{
|
||||
return objc_msgSend(obj, sel, OurRect());
|
||||
}
|
||||
|
|
|
@ -193,8 +193,7 @@ var (
|
|||
|
||||
func newListboxScrollView(listbox C.id) C.id {
|
||||
scrollview := objc_alloc(_NSScrollView)
|
||||
scrollview = objc_msgSend_rect(scrollview, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
scrollview = initWithDummyFrame(scrollview)
|
||||
C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES))
|
||||
C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES))
|
||||
C.objc_msgSend_bool(scrollview, _setAutohidesScrollers, C.BOOL(C.YES))
|
||||
|
@ -234,8 +233,7 @@ var (
|
|||
|
||||
func makeListbox(parentWindow C.id, alternate bool) C.id {
|
||||
listbox := objc_alloc(_NSTableView)
|
||||
listbox = objc_msgSend_rect(listbox, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
listbox = initWithDummyFrame(listbox)
|
||||
C.objc_msgSend_id(listbox, _addTableColumn, newListboxTableColumn())
|
||||
multi := C.BOOL(C.NO)
|
||||
if alternate {
|
||||
|
|
|
@ -56,12 +56,3 @@ func fromNSString(str C.id) string {
|
|||
cstr := C.objc_msgSend_noargs(str, _UTF8String)
|
||||
return C.GoString((*C.char)(unsafe.Pointer(cstr)))
|
||||
}
|
||||
|
||||
/*
|
||||
These are wrapper functions for the functions in bleh_darwin.m to wrap around stdint.h type casting.
|
||||
*/
|
||||
|
||||
func objc_msgSend_rect(obj C.id, sel C.SEL, x int, y int, w int, h int) C.id {
|
||||
return C._objc_msgSend_rect(obj, sel,
|
||||
C.int64_t(x), C.int64_t(y), C.int64_t(w), C.int64_t(h))
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ extern uintptr_t objc_msgSend_ushortret_noargs(id objc, SEL sel);
|
|||
|
||||
m1(str, char *) /* TODO Go string? */
|
||||
m1(id, id)
|
||||
extern id _objc_msgSend_rect(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h);
|
||||
extern id objc_msgSend_rect(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h);
|
||||
m1(sel, SEL)
|
||||
extern id objc_msgSend_uint(id obj, SEL sel, uintptr_t a);
|
||||
m1(ptr, void *)
|
||||
|
|
|
@ -84,6 +84,12 @@ var (
|
|||
_numberOfItems = sel_getUid("numberOfItems")
|
||||
)
|
||||
|
||||
// because the only way to make a new NSControl/NSView is with a frame (it gets overridden later)
|
||||
func initWithDummyFrame(self C.id) C.id {
|
||||
return C.objc_msgSend_rect(self, _initWithFrame,
|
||||
C.int64_t(0), C.int64_t(0), C.int64_t(100), C.int64_t(100))
|
||||
}
|
||||
|
||||
func addControl(parentWindow C.id, control C.id) {
|
||||
windowView := C.objc_msgSend_noargs(parentWindow, _contentView)
|
||||
C.objc_msgSend_id(windowView, _addSubview, control)
|
||||
|
@ -134,9 +140,7 @@ var classTypes = [nctypes]*classData{
|
|||
c_button: &classData{
|
||||
make: func(parentWindow C.id, alternate bool) C.id {
|
||||
button := objc_alloc(_NSButton)
|
||||
// NSControl requires that we specify a frame; dummy frame for now
|
||||
button = objc_msgSend_rect(button, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
button = initWithDummyFrame(button)
|
||||
C.objc_msgSend_uint(button, _setBezelStyle, C.uintptr_t(1)) // NSRoundedBezelStyle
|
||||
C.objc_msgSend_id(button, _setTarget, appDelegate)
|
||||
C.objc_msgSend_sel(button, _setAction, _buttonClicked)
|
||||
|
@ -154,8 +158,7 @@ var classTypes = [nctypes]*classData{
|
|||
c_checkbox: &classData{
|
||||
make: func(parentWindow C.id, alternate bool) C.id {
|
||||
checkbox := objc_alloc(_NSButton)
|
||||
checkbox = objc_msgSend_rect(checkbox, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
checkbox = initWithDummyFrame(checkbox)
|
||||
C.objc_msgSend_uint(checkbox, _setButtonType, C.uintptr_t(3)) // NSSwitchButton
|
||||
addControl(parentWindow, checkbox)
|
||||
return checkbox
|
||||
|
@ -171,8 +174,7 @@ var classTypes = [nctypes]*classData{
|
|||
|
||||
if alternate {
|
||||
combobox = objc_alloc(_NSComboBox)
|
||||
combobox = objc_msgSend_rect(combobox, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
combobox = initWithDummyFrame(combobox)
|
||||
C.objc_msgSend_bool(combobox, _setUsesDataSource, C.BOOL(C.NO))
|
||||
} else {
|
||||
combobox = objc_alloc(_NSPopUpButton)
|
||||
|
@ -222,8 +224,7 @@ var classTypes = [nctypes]*classData{
|
|||
} else {
|
||||
lineedit = objc_alloc(_NSTextField)
|
||||
}
|
||||
lineedit = objc_msgSend_rect(lineedit, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
lineedit = initWithDummyFrame(lineedit)
|
||||
addControl(parentWindow, lineedit)
|
||||
return lineedit
|
||||
},
|
||||
|
@ -236,8 +237,7 @@ var classTypes = [nctypes]*classData{
|
|||
c_label: &classData{
|
||||
make: func(parentWindow C.id, alternate bool) C.id {
|
||||
label := objc_alloc(_NSTextField)
|
||||
label = objc_msgSend_rect(label, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
label = initWithDummyFrame(label)
|
||||
C.objc_msgSend_bool(label, _setEditable, C.BOOL(C.NO))
|
||||
C.objc_msgSend_bool(label, _setBordered, C.BOOL(C.NO))
|
||||
C.objc_msgSend_bool(label, _setDrawsBackground, C.BOOL(C.NO))
|
||||
|
@ -264,8 +264,7 @@ var classTypes = [nctypes]*classData{
|
|||
c_progressbar: &classData{
|
||||
make: func(parentWindow C.id, alternate bool) C.id {
|
||||
pbar := objc_alloc(_NSProgressIndicator)
|
||||
pbar = objc_msgSend_rect(pbar, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
pbar = initWithDummyFrame(pbar)
|
||||
// TODO really int?
|
||||
C.objc_msgSend_int(pbar, _setStyle, 0) // NSProgressIndicatorBarStyle
|
||||
C.objc_msgSend_uint(pbar, _setControlSize, C.uintptr_t(0)) // NSRegularControlSize
|
||||
|
@ -370,7 +369,8 @@ func (s *sysData) setText(text string) {
|
|||
func (s *sysData) setRect(x int, y int, width int, height int, winheight int) error {
|
||||
// winheight - y because (0,0) is the bottom-left corner of the window and not the top-left corner
|
||||
// (winheight - y) - height because (x, y) is the bottom-left corner of the control and not the top-left
|
||||
objc_msgSend_rect(s.id, _setFrame, x, (winheight - y) - height, width, height)
|
||||
C.objc_msgSend_rect(s.id, _setFrame,
|
||||
C.int64_t(x), C.int64_t((winheight - y) - height), C.int64_t(width), C.int64_t(height))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -506,8 +506,8 @@ func (s *sysData) setAreaSize(width int, height int) {
|
|||
defer close(ret)
|
||||
uitask <- func() {
|
||||
area := areaInScrollView(s.id)
|
||||
objc_msgSend_rect(area, _setFrame,
|
||||
int(0), int(0), width, height)
|
||||
C.objc_msgSend_rect(area, _setFrame,
|
||||
C.int64_t(0), C.int64_t(0), C.int64_t(width), C.int64_t(height))
|
||||
C.objc_msgSend_noargs(area, _display) // and redraw
|
||||
ret <- struct{}{}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue