Finished migrating sysdata_darwin.go away from calling objc_msgSend() directly. initWithDummyFrame() is still there as other files use it.
This commit is contained in:
parent
3949fb94e9
commit
791345fa97
|
@ -24,12 +24,8 @@ type classData struct {
|
||||||
getinside func(scrollview C.id) C.id
|
getinside func(scrollview C.id) C.id
|
||||||
show func(what C.id)
|
show func(what C.id)
|
||||||
hide func(what C.id)
|
hide func(what C.id)
|
||||||
// settext func(what C.id, text string)
|
settext func(what C.id, text C.id)
|
||||||
settextsel C.SEL
|
text func(what C.id, alternate bool) C.id
|
||||||
// text func(what C.id) string
|
|
||||||
textsel C.SEL
|
|
||||||
// alttextsel func(what C.id) string
|
|
||||||
alttextsel C.SEL
|
|
||||||
append func(id C.id, what string, alternate bool)
|
append func(id C.id, what string, alternate bool)
|
||||||
insertBefore func(id C.id, what string, before int, alternate bool)
|
insertBefore func(id C.id, what string, before int, alternate bool)
|
||||||
selIndex func(id C.id) int
|
selIndex func(id C.id) int
|
||||||
|
@ -142,8 +138,12 @@ var classTypes = [nctypes]*classData{
|
||||||
hide: func(what C.id) {
|
hide: func(what C.id) {
|
||||||
C.windowHide(what)
|
C.windowHide(what)
|
||||||
},
|
},
|
||||||
settextsel: _setTitle,
|
settext: func(what C.id, text C.id) {
|
||||||
textsel: _title,
|
C.windowSetTitle(what, text)
|
||||||
|
},
|
||||||
|
text: func(what C.id, alternate bool) C.id {
|
||||||
|
return C.windowTitle(what)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
c_button: &classData{
|
c_button: &classData{
|
||||||
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
||||||
|
@ -155,8 +155,12 @@ var classTypes = [nctypes]*classData{
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
hide: controlHide,
|
hide: controlHide,
|
||||||
settextsel: _setTitle,
|
settext: func(what C.id, text C.id) {
|
||||||
textsel: _title,
|
C.buttonSetText(what, text)
|
||||||
|
},
|
||||||
|
text: func(what C.id, alternate bool) C.id {
|
||||||
|
return C.buttonText(what)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
c_checkbox: &classData{
|
c_checkbox: &classData{
|
||||||
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
||||||
|
@ -167,8 +171,12 @@ var classTypes = [nctypes]*classData{
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
hide: controlHide,
|
hide: controlHide,
|
||||||
settextsel: _setTitle,
|
settext: func(what C.id, text C.id) {
|
||||||
textsel: _title,
|
C.buttonSetText(what, text)
|
||||||
|
},
|
||||||
|
text: func(what C.id, alternate bool) C.id {
|
||||||
|
return C.buttonText(what)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
c_combobox: &classData{
|
c_combobox: &classData{
|
||||||
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
||||||
|
@ -179,8 +187,9 @@ var classTypes = [nctypes]*classData{
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
hide: controlHide,
|
hide: controlHide,
|
||||||
textsel: _titleOfSelectedItem,
|
text: func(what C.id, alternate bool) C.id {
|
||||||
alttextsel: _stringValue,
|
return C.comboboxText(what, toBOOL(alternate))
|
||||||
|
},
|
||||||
append: func(id C.id, what string, alternate bool) {
|
append: func(id C.id, what string, alternate bool) {
|
||||||
C.comboboxAppend(id, toBOOL(alternate), toNSString(what))
|
C.comboboxAppend(id, toBOOL(alternate), toNSString(what))
|
||||||
},
|
},
|
||||||
|
@ -210,9 +219,12 @@ var classTypes = [nctypes]*classData{
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
hide: controlHide,
|
hide: controlHide,
|
||||||
settextsel: _setStringValue,
|
settext: func(what C.id, text C.id) {
|
||||||
textsel: _stringValue,
|
C.lineeditSetText(what, text)
|
||||||
alttextsel: _stringValue,
|
},
|
||||||
|
text: func(what C.id, alternate bool) C.id {
|
||||||
|
return C.lineeditText(what)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
c_label: &classData{
|
c_label: &classData{
|
||||||
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
||||||
|
@ -223,8 +235,12 @@ var classTypes = [nctypes]*classData{
|
||||||
},
|
},
|
||||||
show: controlShow,
|
show: controlShow,
|
||||||
hide: controlHide,
|
hide: controlHide,
|
||||||
settextsel: _setStringValue,
|
settext: func(what C.id, text C.id) {
|
||||||
textsel: _stringValue,
|
C.lineeditSetText(what, text)
|
||||||
|
},
|
||||||
|
text: func(what C.id, alternate bool) C.id {
|
||||||
|
return C.lineeditText(what)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
c_listbox: &classData{
|
c_listbox: &classData{
|
||||||
make: makeListbox,
|
make: makeListbox,
|
||||||
|
@ -332,7 +348,7 @@ func (s *sysData) setText(text string) {
|
||||||
ret := make(chan struct{})
|
ret := make(chan struct{})
|
||||||
defer close(ret)
|
defer close(ret)
|
||||||
uitask <- func() {
|
uitask <- func() {
|
||||||
C.objc_msgSend_id(s.id, classTypes[s.ctype].settextsel, toNSString(text))
|
classTypes[s.ctype].settext(s.id, toNSString(text))
|
||||||
ret <- struct{}{}
|
ret <- struct{}{}
|
||||||
}
|
}
|
||||||
<-ret
|
<-ret
|
||||||
|
@ -357,14 +373,10 @@ func (s *sysData) isChecked() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sysData) text() string {
|
func (s *sysData) text() string {
|
||||||
sel := classTypes[s.ctype].textsel
|
|
||||||
if s.alternate {
|
|
||||||
sel = classTypes[s.ctype].alttextsel
|
|
||||||
}
|
|
||||||
ret := make(chan string)
|
ret := make(chan string)
|
||||||
defer close(ret)
|
defer close(ret)
|
||||||
uitask <- func() {
|
uitask <- func() {
|
||||||
str := C.objc_msgSend_noargs(s.id, sel)
|
str := classTypes[s.ctype].text(s.id, s.alternate)
|
||||||
ret <- fromNSString(str)
|
ret <- fromNSString(str)
|
||||||
}
|
}
|
||||||
return <-ret
|
return <-ret
|
||||||
|
|
|
@ -9,10 +9,15 @@ extern void applyStandardControlFont(id);
|
||||||
extern id makeWindow(id);
|
extern id makeWindow(id);
|
||||||
extern void windowShow(id);
|
extern void windowShow(id);
|
||||||
extern void windowHide(id);
|
extern void windowHide(id);
|
||||||
|
extern void windowSetTitle(id, id);
|
||||||
|
extern id windowTitle(id);
|
||||||
extern id makeButton(void);
|
extern id makeButton(void);
|
||||||
extern void buttonSetTargetAction(id, id);
|
extern void buttonSetTargetAction(id, id);
|
||||||
|
extern void buttonSetText(id, id);
|
||||||
|
extern id buttonText(id);
|
||||||
extern id makeCheckbox(void);
|
extern id makeCheckbox(void);
|
||||||
extern id makeCombobox(BOOL);
|
extern id makeCombobox(BOOL);
|
||||||
|
extern id comboboxText(id, BOOL);
|
||||||
extern void comboboxAppend(id, BOOL, id);
|
extern void comboboxAppend(id, BOOL, id);
|
||||||
extern void comboboxInsertBefore(id, BOOL, id, intptr_t);
|
extern void comboboxInsertBefore(id, BOOL, id, intptr_t);
|
||||||
extern intptr_t comboboxSelectedIndex(id);
|
extern intptr_t comboboxSelectedIndex(id);
|
||||||
|
@ -20,6 +25,8 @@ extern void comboboxDelete(id, intptr_t);
|
||||||
extern intptr_t comboboxLen(id);
|
extern intptr_t comboboxLen(id);
|
||||||
extern void comboboxSelectIndex(id, BOOL, intptr_t);
|
extern void comboboxSelectIndex(id, BOOL, intptr_t);
|
||||||
extern id makeLineEdit(BOOL); // TODO I accidentally left this as taking no arguments and clang didn't complain when compiling sysdata_darwin.m?!
|
extern id makeLineEdit(BOOL); // TODO I accidentally left this as taking no arguments and clang didn't complain when compiling sysdata_darwin.m?!
|
||||||
|
extern void lineeditSetText(id, id);
|
||||||
|
extern id lineeditText(id);
|
||||||
extern id makeLabel(void);
|
extern id makeLabel(void);
|
||||||
extern id makeProgressBar(void);
|
extern id makeProgressBar(void);
|
||||||
extern void setRect(id, intptr_t, intptr_t, intptr_t, intptr_t);
|
extern void setRect(id, intptr_t, intptr_t, intptr_t, intptr_t);
|
||||||
|
|
|
@ -80,6 +80,16 @@ void windowHide(id window)
|
||||||
[toNSWindow(window) orderOut:window];
|
[toNSWindow(window) orderOut:window];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void windowSetTitle(id window, id title)
|
||||||
|
{
|
||||||
|
[toNSWindow(window) setTitle:title];
|
||||||
|
}
|
||||||
|
|
||||||
|
id windowTitle(id window)
|
||||||
|
{
|
||||||
|
return [toNSWindow(window) title];
|
||||||
|
}
|
||||||
|
|
||||||
id makeButton(void)
|
id makeButton(void)
|
||||||
{
|
{
|
||||||
NSButton *button;
|
NSButton *button;
|
||||||
|
@ -96,6 +106,16 @@ void buttonSetTargetAction(id button, id delegate)
|
||||||
[toNSButton(button) setAction:@selector(buttonClicked:)];
|
[toNSButton(button) setAction:@selector(buttonClicked:)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void buttonSetText(id button, id text)
|
||||||
|
{
|
||||||
|
[toNSButton(button) setTitle:text];
|
||||||
|
}
|
||||||
|
|
||||||
|
id buttonText(id button)
|
||||||
|
{
|
||||||
|
return [toNSButton(button) title];
|
||||||
|
}
|
||||||
|
|
||||||
id makeCheckbox(void)
|
id makeCheckbox(void)
|
||||||
{
|
{
|
||||||
NSButton *checkbox;
|
NSButton *checkbox;
|
||||||
|
@ -125,6 +145,13 @@ id makeCombobox(BOOL editable)
|
||||||
return combobox;
|
return combobox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id comboboxText(id combobox, BOOL editable)
|
||||||
|
{
|
||||||
|
if (!editable)
|
||||||
|
return [toNSPopUpButton(combobox) titleOfSelectedItem];
|
||||||
|
return [toNSComboBox(combobox) stringValue];
|
||||||
|
}
|
||||||
|
|
||||||
void comboboxAppend(id combobox, BOOL editable, id str)
|
void comboboxAppend(id combobox, BOOL editable, id str)
|
||||||
{
|
{
|
||||||
if (!editable) {
|
if (!editable) {
|
||||||
|
@ -193,6 +220,16 @@ id makeLineEdit(BOOL password)
|
||||||
initWithFrame:dummyRect];
|
initWithFrame:dummyRect];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lineeditSetText(id lineedit, id text)
|
||||||
|
{
|
||||||
|
[toNSTextField(lineedit) setStringValue:text];
|
||||||
|
}
|
||||||
|
|
||||||
|
id lineeditText(id lineedit)
|
||||||
|
{
|
||||||
|
return [toNSTextField(lineedit) stringValue];
|
||||||
|
}
|
||||||
|
|
||||||
id makeLabel(void)
|
id makeLabel(void)
|
||||||
{
|
{
|
||||||
NSTextField *label;
|
NSTextField *label;
|
||||||
|
|
Loading…
Reference in New Issue