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
|
||||
show func(what C.id)
|
||||
hide func(what C.id)
|
||||
// settext func(what C.id, text string)
|
||||
settextsel C.SEL
|
||||
// text func(what C.id) string
|
||||
textsel C.SEL
|
||||
// alttextsel func(what C.id) string
|
||||
alttextsel C.SEL
|
||||
settext func(what C.id, text C.id)
|
||||
text func(what C.id, alternate bool) C.id
|
||||
append func(id C.id, what string, alternate bool)
|
||||
insertBefore func(id C.id, what string, before int, alternate bool)
|
||||
selIndex func(id C.id) int
|
||||
|
@ -142,8 +138,12 @@ var classTypes = [nctypes]*classData{
|
|||
hide: func(what C.id) {
|
||||
C.windowHide(what)
|
||||
},
|
||||
settextsel: _setTitle,
|
||||
textsel: _title,
|
||||
settext: func(what C.id, text C.id) {
|
||||
C.windowSetTitle(what, text)
|
||||
},
|
||||
text: func(what C.id, alternate bool) C.id {
|
||||
return C.windowTitle(what)
|
||||
},
|
||||
},
|
||||
c_button: &classData{
|
||||
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
||||
|
@ -155,8 +155,12 @@ var classTypes = [nctypes]*classData{
|
|||
},
|
||||
show: controlShow,
|
||||
hide: controlHide,
|
||||
settextsel: _setTitle,
|
||||
textsel: _title,
|
||||
settext: func(what C.id, text C.id) {
|
||||
C.buttonSetText(what, text)
|
||||
},
|
||||
text: func(what C.id, alternate bool) C.id {
|
||||
return C.buttonText(what)
|
||||
},
|
||||
},
|
||||
c_checkbox: &classData{
|
||||
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
||||
|
@ -167,8 +171,12 @@ var classTypes = [nctypes]*classData{
|
|||
},
|
||||
show: controlShow,
|
||||
hide: controlHide,
|
||||
settextsel: _setTitle,
|
||||
textsel: _title,
|
||||
settext: func(what C.id, text C.id) {
|
||||
C.buttonSetText(what, text)
|
||||
},
|
||||
text: func(what C.id, alternate bool) C.id {
|
||||
return C.buttonText(what)
|
||||
},
|
||||
},
|
||||
c_combobox: &classData{
|
||||
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
||||
|
@ -179,8 +187,9 @@ var classTypes = [nctypes]*classData{
|
|||
},
|
||||
show: controlShow,
|
||||
hide: controlHide,
|
||||
textsel: _titleOfSelectedItem,
|
||||
alttextsel: _stringValue,
|
||||
text: func(what C.id, alternate bool) C.id {
|
||||
return C.comboboxText(what, toBOOL(alternate))
|
||||
},
|
||||
append: func(id C.id, what string, alternate bool) {
|
||||
C.comboboxAppend(id, toBOOL(alternate), toNSString(what))
|
||||
},
|
||||
|
@ -210,9 +219,12 @@ var classTypes = [nctypes]*classData{
|
|||
},
|
||||
show: controlShow,
|
||||
hide: controlHide,
|
||||
settextsel: _setStringValue,
|
||||
textsel: _stringValue,
|
||||
alttextsel: _stringValue,
|
||||
settext: func(what C.id, text C.id) {
|
||||
C.lineeditSetText(what, text)
|
||||
},
|
||||
text: func(what C.id, alternate bool) C.id {
|
||||
return C.lineeditText(what)
|
||||
},
|
||||
},
|
||||
c_label: &classData{
|
||||
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
|
||||
|
@ -223,8 +235,12 @@ var classTypes = [nctypes]*classData{
|
|||
},
|
||||
show: controlShow,
|
||||
hide: controlHide,
|
||||
settextsel: _setStringValue,
|
||||
textsel: _stringValue,
|
||||
settext: func(what C.id, text C.id) {
|
||||
C.lineeditSetText(what, text)
|
||||
},
|
||||
text: func(what C.id, alternate bool) C.id {
|
||||
return C.lineeditText(what)
|
||||
},
|
||||
},
|
||||
c_listbox: &classData{
|
||||
make: makeListbox,
|
||||
|
@ -332,7 +348,7 @@ func (s *sysData) setText(text string) {
|
|||
ret := make(chan struct{})
|
||||
defer close(ret)
|
||||
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
|
||||
|
@ -357,14 +373,10 @@ func (s *sysData) isChecked() bool {
|
|||
}
|
||||
|
||||
func (s *sysData) text() string {
|
||||
sel := classTypes[s.ctype].textsel
|
||||
if s.alternate {
|
||||
sel = classTypes[s.ctype].alttextsel
|
||||
}
|
||||
ret := make(chan string)
|
||||
defer close(ret)
|
||||
uitask <- func() {
|
||||
str := C.objc_msgSend_noargs(s.id, sel)
|
||||
str := classTypes[s.ctype].text(s.id, s.alternate)
|
||||
ret <- fromNSString(str)
|
||||
}
|
||||
return <-ret
|
||||
|
|
|
@ -9,10 +9,15 @@ extern void applyStandardControlFont(id);
|
|||
extern id makeWindow(id);
|
||||
extern void windowShow(id);
|
||||
extern void windowHide(id);
|
||||
extern void windowSetTitle(id, id);
|
||||
extern id windowTitle(id);
|
||||
extern id makeButton(void);
|
||||
extern void buttonSetTargetAction(id, id);
|
||||
extern void buttonSetText(id, id);
|
||||
extern id buttonText(id);
|
||||
extern id makeCheckbox(void);
|
||||
extern id makeCombobox(BOOL);
|
||||
extern id comboboxText(id, BOOL);
|
||||
extern void comboboxAppend(id, BOOL, id);
|
||||
extern void comboboxInsertBefore(id, BOOL, id, intptr_t);
|
||||
extern intptr_t comboboxSelectedIndex(id);
|
||||
|
@ -20,6 +25,8 @@ extern void comboboxDelete(id, intptr_t);
|
|||
extern intptr_t comboboxLen(id);
|
||||
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 void lineeditSetText(id, id);
|
||||
extern id lineeditText(id);
|
||||
extern id makeLabel(void);
|
||||
extern id makeProgressBar(void);
|
||||
extern void setRect(id, intptr_t, intptr_t, intptr_t, intptr_t);
|
||||
|
|
|
@ -80,6 +80,16 @@ void windowHide(id 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)
|
||||
{
|
||||
NSButton *button;
|
||||
|
@ -96,6 +106,16 @@ void buttonSetTargetAction(id button, id delegate)
|
|||
[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)
|
||||
{
|
||||
NSButton *checkbox;
|
||||
|
@ -125,6 +145,13 @@ id makeCombobox(BOOL editable)
|
|||
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)
|
||||
{
|
||||
if (!editable) {
|
||||
|
@ -193,6 +220,16 @@ id makeLineEdit(BOOL password)
|
|||
initWithFrame:dummyRect];
|
||||
}
|
||||
|
||||
void lineeditSetText(id lineedit, id text)
|
||||
{
|
||||
[toNSTextField(lineedit) setStringValue:text];
|
||||
}
|
||||
|
||||
id lineeditText(id lineedit)
|
||||
{
|
||||
return [toNSTextField(lineedit) stringValue];
|
||||
}
|
||||
|
||||
id makeLabel(void)
|
||||
{
|
||||
NSTextField *label;
|
||||
|
|
Loading…
Reference in New Issue