Preparation for adding tracking areas to Mac OS X Areas: we need to now pass in the sysData to each control's make() function so Area can save the tracking area somewhere (this will also come in handy when I change alternate from a bool to an integer index).

This commit is contained in:
Pietro Gagliardi 2014-05-10 14:59:11 -04:00
parent d8d671b0b0
commit 5819e52f8d
3 changed files with 13 additions and 12 deletions

View File

@ -74,7 +74,7 @@ func mkAreaClass() error {
return nil
}
func makeArea(parentWindow C.id, alternate bool) C.id {
func makeArea(parentWindow C.id, alternate bool, s *sysData) C.id {
area := C.objc_msgSend_noargs(_goArea, _alloc)
area = initWithDummyFrame(area)
// TODO others?

View File

@ -234,7 +234,7 @@ var (
_deselectAll = sel_getUid("deselectAll:")
)
func makeListbox(parentWindow C.id, alternate bool) C.id {
func makeListbox(parentWindow C.id, alternate bool, s *sysData) C.id {
listbox := C.objc_msgSend_noargs(_NSTableView, _alloc)
listbox = initWithDummyFrame(listbox)
C.objc_msgSend_id(listbox, _addTableColumn, newListboxTableColumn())

View File

@ -15,11 +15,12 @@ import "C"
type sysData struct {
cSysData
id C.id
id C.id
trackingArea C.id // for Area
}
type classData struct {
make func(parentWindow C.id, alternate bool) C.id
make func(parentWindow C.id, alternate bool, s *sysData) C.id
getinside func(scrollview C.id) C.id
show func(what C.id)
hide func(what C.id)
@ -125,7 +126,7 @@ func applyStandardControlFont(id C.id) {
var classTypes = [nctypes]*classData{
c_window: &classData{
make: func(parentWindow C.id, alternate bool) C.id {
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
const (
_NSBorderlessWindowMask = 0
_NSTitledWindowMask = 1 << 0
@ -160,7 +161,7 @@ var classTypes = [nctypes]*classData{
textsel: _title,
},
c_button: &classData{
make: func(parentWindow C.id, alternate bool) C.id {
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
const (
_NSRoundedBezelStyle = 1
)
@ -180,7 +181,7 @@ var classTypes = [nctypes]*classData{
textsel: _title,
},
c_checkbox: &classData{
make: func(parentWindow C.id, alternate bool) C.id {
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
const (
_NSSwitchButton = 3
)
@ -198,7 +199,7 @@ var classTypes = [nctypes]*classData{
textsel: _title,
},
c_combobox: &classData{
make: func(parentWindow C.id, alternate bool) C.id {
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
var combobox C.id
if alternate {
@ -262,7 +263,7 @@ var classTypes = [nctypes]*classData{
},
},
c_lineedit: &classData{
make: func(parentWindow C.id, alternate bool) C.id {
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
var lineedit C.id
if alternate {
@ -282,7 +283,7 @@ var classTypes = [nctypes]*classData{
alttextsel: _stringValue,
},
c_label: &classData{
make: func(parentWindow C.id, alternate bool) C.id {
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
const (
_NSLineBreakByWordWrapping = iota
_NSLineBreakByCharWrapping
@ -324,7 +325,7 @@ var classTypes = [nctypes]*classData{
selectIndices: selectListboxIndices,
},
c_progressbar: &classData{
make: func(parentWindow C.id, alternate bool) C.id {
make: func(parentWindow C.id, alternate bool, s *sysData) C.id {
const (
_NSProgressIndicatorBarStyle = 0
)
@ -382,7 +383,7 @@ func (s *sysData) make(window *sysData) error {
ret := make(chan C.id)
defer close(ret)
uitask <- func() {
ret <- ct.make(parentWindow, s.alternate)
ret <- ct.make(parentWindow, s.alternate, s)
}
s.id = <-ret
if ct.getinside != nil {