Consolidated NSScrollView code on Mac OS X to be all in one place.
This commit is contained in:
parent
136ddf5a5b
commit
417bdb8949
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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.
|
||||
|
|
1
todo.md
1
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
|
||||
|
|
Loading…
Reference in New Issue