Finished the implementation of Combobox on Mac OS X.

This commit is contained in:
Pietro Gagliardi 2014-03-02 18:38:45 -05:00
parent e20b468472
commit 4bc35e2db5
4 changed files with 19 additions and 2 deletions

View File

@ -31,6 +31,11 @@ id _objc_msgSend_uint(id obj, SEL sel, uintptr_t a)
same as above, but for NSInteger same as above, but for NSInteger
*/ */
intptr_t objc_msgSend_intret_noargs(id obj, SEL sel)
{
return (intptr_t) ((NSInteger) objc_msgSend(obj, sel));
}
id objc_msgSend_int(id obj, SEL sel, intptr_t a) id objc_msgSend_int(id obj, SEL sel, intptr_t a)
{ {
return objc_msgSend(obj, sel, (NSInteger) a); return objc_msgSend(obj, sel, (NSInteger) a);

View File

@ -44,6 +44,8 @@ struct xsize {
extern struct xsize objc_msgSend_stret_size_noargs(id obj, SEL sel); extern struct xsize objc_msgSend_stret_size_noargs(id obj, SEL sel);
extern intptr_t objc_msgSend_intret_noargs(id obj, SEL sel);
#define m1(name, type1) \ #define m1(name, type1) \
inline id objc_msgSend_ ## name (id obj, SEL sel, type1 a) \ inline id objc_msgSend_ ## name (id obj, SEL sel, type1 a) \
{ \ { \

View File

@ -26,6 +26,7 @@ type classData struct {
alttextsel C.SEL 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
// TODO others // TODO others
delete func(id C.id, index int) delete func(id C.id, index int)
} }
@ -180,6 +181,9 @@ var classTypes = [nctypes]*classData{
C.objc_msgSend_id_int(id, _insertItemWithTitleAtIndex, str, C.intptr_t(before)) C.objc_msgSend_id_int(id, _insertItemWithTitleAtIndex, str, C.intptr_t(before))
} }
}, },
selIndex: func(id C.id) int {
return int(C.objc_msgSend_intret_noargs(id, _indexOfSelectedItem))
},
delete: func(id C.id, index int) { delete: func(id C.id, index int) {
C.objc_msgSend_int(id, _removeItemAtIndex, C.intptr_t(index)) C.objc_msgSend_int(id, _removeItemAtIndex, C.intptr_t(index))
}, },
@ -341,8 +345,13 @@ if classTypes[s.ctype].insertBefore == nil { return nil }
} }
func (s *sysData) selectedIndex() int { func (s *sysData) selectedIndex() int {
// TODO if classTypes[s.ctype].selIndex == nil { return -1 }
return -1 ret := make(chan int)
defer close(ret)
uitask <- func() {
ret <- classTypes[s.ctype].selIndex(s.id)
}
return <-ret
} }
func (s *sysData) selectedIndices() []int { func (s *sysData) selectedIndices() []int {

View File

@ -28,6 +28,7 @@ important things:
- Cocoa coordinates have (0,0) at the bottom left: need to fix this somehow - Cocoa coordinates have (0,0) at the bottom left: need to fix this somehow
- I think Cocoa NSButton text is not vertically aligned properly...? - I think Cocoa NSButton text is not vertically aligned properly...?
- resizing Cocoa windows does not redraw controls correctly - resizing Cocoa windows does not redraw controls correctly
- NSComboBox scans the entered text to see if it matches one of the items and returns the index of that item if it does; find out how to suppress this so that it returns -1 unless the item was chosen from the list (like the other platforms)
- figure out what to do about deleting a nonexistent item; each backend responds differently by default - figure out what to do about deleting a nonexistent item; each backend responds differently by default
- there's no GTK+ error handling whatsoever; we need to figure out how it works - there's no GTK+ error handling whatsoever; we need to figure out how it works
- make sure GTK+ documentation point differences don't matter - make sure GTK+ documentation point differences don't matter