示例#1
0
//export appDelegate_windowDidResize
func appDelegate_windowDidResize(win C.id) {
	s := getSysData(win)
	wincv := C.windowGetContentView(win) // we want the content view's size, not the window's
	r := C.frame(wincv)
	// (0,0) is the bottom left corner but this is handled in sysData.translateAllocationCoords()
	s.resizeWindow(int(r.width), int(r.height))
	C.display(win) // redraw everything
}
示例#2
0
//export appDelegate_windowDidResize
func appDelegate_windowDidResize(win C.id) {
	s := getSysData(win)
	wincv := C.windowGetContentView(win) // we want the content view's size, not the window's
	r := C.frame(wincv)
	// winheight is used here because (0,0) is the bottom-left corner, not the top-left corner
	s.doResize(0, 0, int(r.width), int(r.height), int(r.height))
	C.display(win) // redraw everything
}
示例#3
0
文件: area_darwin.go 项目: UIKit0/ui
func areaMouseEvent(self C.id, e C.id, click bool, up bool) {
	var me MouseEvent

	s := getSysData(self)
	xp := C.getTranslatedEventPoint(self, e)
	me.Pos = image.Pt(int(xp.x), int(xp.y))
	// for the most part, Cocoa won't geenerate an event outside the Area... except when dragging outside the Area, so check for this
	max := C.frame(self)
	if !me.Pos.In(image.Rect(0, 0, int(max.width), int(max.height))) {
		return
	}
	me.Modifiers = parseModifiers(e)
	which := uint(C.buttonNumber(e)) + 1
	if which == 3 { // swap middle and right button numbers
		which = 2
	} else if which == 2 {
		which = 3
	}
	if click && up {
		me.Up = which
	} else if click {
		me.Down = which
		// this already works the way we want it to so nothing special needed like with Windows and GTK+
		me.Count = uint(C.clickCount(e))
	} else {
		which = 0 // reset for Held processing below
	}
	// the docs do say don't use this for tracking (mouseMoved:) since it returns the state now, and mouse move events work by tracking, but as far as I can tell dragging the mouse over the inactive window does not generate an event on Mac OS X, so :/ (tracking doesn't touch dragging anyway except during mouseEntered: and mouseExited:, which we don't handle, and the only other tracking message, cursorChanged:, we also don't handle (yet...? need to figure out if this is how to set custom cursors or not), so)
	held := C.pressedMouseButtons()
	if which != 1 && (held&1) != 0 { // button 1
		me.Held = append(me.Held, 1)
	}
	if which != 2 && (held&4) != 0 { // button 2; mind the swap
		me.Held = append(me.Held, 2)
	}
	if which != 3 && (held&2) != 0 { // button 3
		me.Held = append(me.Held, 3)
	}
	held >>= 3
	for i := uint(4); held != 0; i++ {
		if which != i && (held&1) != 0 {
			me.Held = append(me.Held, i)
		}
		held >>= 1
	}
	repaint := s.handler.Mouse(me)
	if repaint {
		C.display(self)
	}
}
示例#4
0
文件: area_darwin.go 项目: UIKit0/ui
//export areaView_drawRect
func areaView_drawRect(self C.id, rect C.struct_xrect) {
	s := getSysData(self)
	// no need to clear the clip rect; the NSScrollView does that for us (see the setDrawsBackground: call in objc_darwin.m)
	// rectangles in Cocoa are origin/size, not point0/point1; if we don't watch for this, weird things will happen when scrolling
	cliprect := image.Rect(int(rect.x), int(rect.y), int(rect.x+rect.width), int(rect.y+rect.height))
	max := C.frame(self)
	cliprect = image.Rect(0, 0, int(max.width), int(max.height)).Intersect(cliprect)
	if cliprect.Empty() { // no intersection; nothing to paint
		return
	}
	i := s.handler.Paint(cliprect)
	C.drawImage(
		unsafe.Pointer(pixelData(i)), C.intptr_t(i.Rect.Dx()), C.intptr_t(i.Rect.Dy()), C.intptr_t(i.Stride),
		C.intptr_t(cliprect.Min.X), C.intptr_t(cliprect.Min.Y))
}
示例#5
0
func (s *sysData) getAuxResizeInfo(d *sysSizeData) {
	d.neighborAlign = C.alignmentInfo(s.id, C.frame(s.id))
}