summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--area_darwin.go38
-rw-r--r--futureplans.md2
-rw-r--r--listbox_darwin.go18
-rw-r--r--objc_darwin.go26
-rw-r--r--todo.md1
5 files changed, 45 insertions, 40 deletions
diff --git a/area_darwin.go b/area_darwin.go
index 9cdda68..a2f2361 100644
--- a/area_darwin.go
+++ b/area_darwin.go
@@ -74,6 +74,19 @@ func mkAreaClass() error {
return nil
}
+func makeArea(parentWindow C.id, alternate bool) C.id {
+ area := C.objc_msgSend_noargs(_goArea, _alloc)
+ area = initWithDummyFrame(area)
+ // TODO others?
+ area = newScrollView(area)
+ addControl(parentWindow, area)
+ return area
+}
+
+func areaInScrollView(scrollview C.id) C.id {
+ return getScrollViewContent(scrollview)
+}
+
var (
_drawAtPoint = sel_getUid("drawAtPoint:")
)
@@ -261,28 +274,3 @@ func areaView_flagsChanged(self C.id, sel C.SEL, e C.id) {
ke.Up = (ke.Modifiers & mod) == 0
sendKeyEvent(self, ke)
}
-
-// TODO combine these with the listbox functions?
-
-func newAreaScrollView(area C.id) C.id {
- scrollview := C.objc_msgSend_noargs(_NSScrollView, _alloc)
- scrollview = initWithDummyFrame(scrollview)
- C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES))
- C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES))
- C.objc_msgSend_bool(scrollview, _setAutohidesScrollers, C.BOOL(C.YES))
- C.objc_msgSend_id(scrollview, _setDocumentView, area)
- return scrollview
-}
-
-func areaInScrollView(scrollview C.id) C.id {
- return C.objc_msgSend_noargs(scrollview, _documentView)
-}
-
-func makeArea(parentWindow C.id, alternate bool) C.id {
- area := C.objc_msgSend_noargs(_goArea, _alloc)
- area = initWithDummyFrame(area)
- // TODO others?
- area = newAreaScrollView(area)
- addControl(parentWindow, area)
- return area
-}
diff --git a/futureplans.md b/futureplans.md
index 7fefd67..a75fe02 100644
--- a/futureplans.md
+++ b/futureplans.md
@@ -100,6 +100,8 @@ big dumb things:
- raymond chen does it here: http://blogs.msdn.com/b/oldnewthing/archive/2005/04/22/410773.aspx (check the implementation of Window::s_WndProc())
- ...and suggests we do it here http://blogs.msdn.com/b/oldnewthing/archive/2014/02/03/10496248.aspx (**NOTE THE DATE**) - the comments on this one provide some potential ideas, including IIntrospect's comment about HCBT_CREATEWND; later Raymond says we should not worry about SetWindowLongPtr() failing
- and raymond suggests GWL_USERDATA here: http://blogs.msdn.com/b/oldnewthing/archive/2005/03/03/384285.aspx
+- listboxes should have horizontal scrollbars on all platforms; this is way too hard on OS X and doesn't work; my code is in experiments/
+ - also moved the Windows code there for the sake of efficiency
specifics:
diff --git a/listbox_darwin.go b/listbox_darwin.go
index b5f26a8..7d10a5f 100644
--- a/listbox_darwin.go
+++ b/listbox_darwin.go
@@ -185,17 +185,12 @@ func listboxTableColumn(listbox C.id) C.id {
/*
The NSTableViews don't draw their own scrollbars; we have to drop our NSTableViews in NSScrollViews for this. The NSScrollView is also what provides the Listbox's border.
+
+The actual creation code was moved to objc_darwin.go.
*/
var (
- _NSScrollView = objc_getClass("NSScrollView")
-
- _setHasHorizontalScroller = sel_getUid("setHasHorizontalScroller:")
- _setHasVerticalScroller = sel_getUid("setHasVerticalScroller:")
- _setAutohidesScrollers = sel_getUid("setAutohidesScrollers:")
_setBorderType = sel_getUid("setBorderType:")
- _setDocumentView = sel_getUid("setDocumentView:")
- _documentView = sel_getUid("documentView")
)
func newListboxScrollView(listbox C.id) C.id {
@@ -203,18 +198,13 @@ func newListboxScrollView(listbox C.id) C.id {
_NSBezelBorder = 2
)
- scrollview := C.objc_msgSend_noargs(_NSScrollView, _alloc)
- scrollview = initWithDummyFrame(scrollview)
- C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES))
- C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES))
- C.objc_msgSend_bool(scrollview, _setAutohidesScrollers, C.BOOL(C.YES))
+ scrollview := newScrollView(listbox)
C.objc_msgSend_uint(scrollview, _setBorderType, _NSBezelBorder) // this is what Interface Builder gives the scroll view
- C.objc_msgSend_id(scrollview, _setDocumentView, listbox)
return scrollview
}
func listboxInScrollView(scrollview C.id) C.id {
- return C.objc_msgSend_noargs(scrollview, _documentView)
+ return getScrollViewContent(scrollview)
}
/*
diff --git a/objc_darwin.go b/objc_darwin.go
index 855dc58..b8d5f8f 100644
--- a/objc_darwin.go
+++ b/objc_darwin.go
@@ -54,6 +54,32 @@ func fromNSString(str C.id) string {
return C.GoString((*C.char)(unsafe.Pointer(cstr)))
}
+// These consolidate the NSScrollView code (used by listbox_darwin.go and area_darwin.go) into a single place.
+
+var (
+ _NSScrollView = objc_getClass("NSScrollView")
+
+ _setHasHorizontalScroller = sel_getUid("setHasHorizontalScroller:")
+ _setHasVerticalScroller = sel_getUid("setHasVerticalScroller:")
+ _setAutohidesScrollers = sel_getUid("setAutohidesScrollers:")
+ _setDocumentView = sel_getUid("setDocumentView:")
+ _documentView = sel_getUid("documentView")
+)
+
+func newScrollView(content C.id) C.id {
+ scrollview := C.objc_msgSend_noargs(_NSScrollView, _alloc)
+ scrollview = initWithDummyFrame(scrollview)
+ C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES))
+ C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES))
+ C.objc_msgSend_bool(scrollview, _setAutohidesScrollers, C.BOOL(C.YES))
+ C.objc_msgSend_id(scrollview, _setDocumentView, content)
+ return scrollview
+}
+
+func getScrollViewContent(scrollview C.id) C.id {
+ return C.objc_msgSend_noargs(scrollview, _documentView)
+}
+
// These create new classes.
// selector contains the information for a new selector.
diff --git a/todo.md b/todo.md
index 839985c..c137cab 100644
--- a/todo.md
+++ b/todo.md
@@ -1,6 +1,5 @@
important things:
- 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)
-- consolidate scroll view code in Mac OS X
- make sure mouse events trigger when we move the mouse over an Area with a button held on OS X
- area test time label weirdness
- does not show anything past the date on windows