From 5819e52f8de793d781c8de86d6ae16aa832fdfe1 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 10 May 2014 14:59:11 -0400 Subject: [PATCH] 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). --- area_darwin.go | 2 +- listbox_darwin.go | 2 +- sysdata_darwin.go | 21 +++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/area_darwin.go b/area_darwin.go index 39a5fb3..2041494 100644 --- a/area_darwin.go +++ b/area_darwin.go @@ -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? diff --git a/listbox_darwin.go b/listbox_darwin.go index 5a1042d..1001a46 100644 --- a/listbox_darwin.go +++ b/listbox_darwin.go @@ -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()) diff --git a/sysdata_darwin.go b/sysdata_darwin.go index db68c43..08ca202 100644 --- a/sysdata_darwin.go +++ b/sysdata_darwin.go @@ -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 {