当前位置: 首页>>代码示例>>Golang>>正文


Golang C.intptr_t函数代码示例

本文整理汇总了Golang中C.intptr_t函数的典型用法代码示例。如果您正苦于以下问题:Golang intptr_t函数的具体用法?Golang intptr_t怎么用?Golang intptr_t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了intptr_t函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: finishNewTable

func finishNewTable(b *tablebase, ty reflect.Type) Table {
	id := C.newTable()
	t := &table{
		scroller:  newScroller(id, true), // border on Table
		tablebase: b,
		selected:  newEvent(),
	}
	t.fpreferredSize = t.xpreferredSize
	// also sets the delegate
	C.tableMakeDataSource(t.id, unsafe.Pointer(t))
	for i := 0; i < ty.NumField(); i++ {
		colname := ty.Field(i).Tag.Get("uicolumn")
		if colname == "" {
			colname = ty.Field(i).Name
		}
		cname := C.CString(colname)
		coltype := C.colTypeText
		editable := false
		switch {
		case ty.Field(i).Type == reflect.TypeOf((*image.RGBA)(nil)):
			coltype = C.colTypeImage
		case ty.Field(i).Type.Kind() == reflect.Bool:
			coltype = C.colTypeCheckbox
			editable = true
		}
		C.tableAppendColumn(t.id, C.intptr_t(i), cname, C.int(coltype), toBOOL(editable))
		C.free(unsafe.Pointer(cname)) // free now (not deferred) to conserve memory
	}
	return t
}
开发者ID:sjn1978,项目名称:ui,代码行数:30,代码来源:table_darwin.go

示例2: goTableDataSource_getValue

//export goTableDataSource_getValue
func goTableDataSource_getValue(data unsafe.Pointer, row C.intptr_t, col C.intptr_t, outtype *C.int) unsafe.Pointer {
	t := (*table)(data)
	t.RLock()
	defer t.RUnlock()
	d := reflect.Indirect(reflect.ValueOf(t.data))
	datum := d.Index(int(row)).Field(int(col))
	switch {
	case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)):
		*outtype = C.colTypeImage
		d := datum.Interface().(*image.RGBA)
		img := C.toTableImage(unsafe.Pointer(pixelData(d)), C.intptr_t(d.Rect.Dx()), C.intptr_t(d.Rect.Dy()), C.intptr_t(d.Stride))
		return unsafe.Pointer(img)
	case datum.Kind() == reflect.Bool:
		*outtype = C.colTypeCheckbox
		if datum.Bool() == true {
			// return a non-nil pointer
			// outtype isn't Go-side so it'll work
			return unsafe.Pointer(outtype)
		}
		return nil
	default:
		s := fmt.Sprintf("%v", datum)
		return unsafe.Pointer(C.CString(s))
	}
}
开发者ID:sjn1978,项目名称:ui,代码行数:26,代码来源:table_darwin.go

示例3: tableGetCell

//export tableGetCell
func tableGetCell(data unsafe.Pointer, tnm *C.tableNM) C.LRESULT {
	t := (*table)(data)
	t.RLock()
	defer t.RUnlock()
	d := reflect.Indirect(reflect.ValueOf(t.data))
	datum := d.Index(int(tnm.row)).Field(int(tnm.column))
	switch {
	case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)):
		i := datum.Interface().(*image.RGBA)
		hbitmap := C.toBitmap(unsafe.Pointer(i), C.intptr_t(i.Rect.Dx()), C.intptr_t(i.Rect.Dy()))
		bitmap := C.uintptr_t(uintptr(unsafe.Pointer(hbitmap)))
		t.freeLock.Lock()
		t.free[bitmap] = true // bitmap freed with C.freeBitmap()
		t.freeLock.Unlock()
		return C.LRESULT(bitmap)
	case datum.Kind() == reflect.Bool:
		if datum.Bool() == true {
			return C.TRUE
		}
		return C.FALSE
	default:
		s := fmt.Sprintf("%v", datum)
		text := C.uintptr_t(uintptr(unsafe.Pointer(toUTF16(s))))
		t.freeLock.Lock()
		t.free[text] = false // text freed with C.free()
		t.freeLock.Unlock()
		return C.LRESULT(text)
	}
}
开发者ID:sjn1978,项目名称:ui,代码行数:30,代码来源:table_windows.go

示例4: commitResize

func (l *label) commitResize(c *allocation, d *sizing) {
	if !l.standalone && c.neighbor != nil {
		c.neighbor.getAuxResizeInfo(d)
		if d.neighborAlign.baseline != 0 { // no adjustment needed if the given control has no baseline
			// in order for the baseline value to be correct, the label MUST BE AT THE HEIGHT THAT OS X WANTS IT TO BE!
			// otherwise, the baseline calculation will be relative to the bottom of the control, and everything will be wrong
			origsize := C.controlPreferredSize(l._id)
			c.height = int(origsize.height)
			newrect := C.struct_xrect{
				x:      C.intptr_t(c.x),
				y:      C.intptr_t(c.y),
				width:  C.intptr_t(c.width),
				height: C.intptr_t(c.height),
			}
			ourAlign := C.alignmentInfo(l._id, newrect)
			// we need to find the exact Y positions of the baselines
			// fortunately, this is easy now that (x,y) is the bottom-left corner
			thisbasey := ourAlign.rect.y + ourAlign.baseline
			neighborbasey := d.neighborAlign.rect.y + d.neighborAlign.baseline
			// now the amount we have to move the label down by is easy to find
			yoff := neighborbasey - thisbasey
			// and we just add that
			c.y += int(yoff)
		}
		// in the other case, the most correct thing would be for Label to be aligned to the alignment rect, but I can't get this working, and it looks fine as it is anyway
	}
	basecommitResize(l, c, d)
}
开发者ID:NotBadPad,项目名称:ui,代码行数:28,代码来源:label_darwin.go

示例5: setRect

func (s *sysData) setRect(x int, y int, width int, height int, winheight int) error {
	// winheight - y because (0,0) is the bottom-left corner of the window and not the top-left corner
	// (winheight - y) - height because (x, y) is the bottom-left corner of the control and not the top-left
	C.setRect(s.id,
		C.intptr_t(x), C.intptr_t((winheight-y)-height),
		C.intptr_t(width), C.intptr_t(height))
	return nil
}
开发者ID:BlackWidowMaker,项目名称:ui,代码行数:8,代码来源:sysdata_darwin.go

示例6: setAreaSize

func (s *sysData) setAreaSize(width int, height int) {
	ret := make(chan struct{})
	defer close(ret)
	uitask <- func() {
		C.setAreaSize(s.id, C.intptr_t(width), C.intptr_t(height))
		ret <- struct{}{}
	}
	<-ret
}
开发者ID:BlackWidowMaker,项目名称:ui,代码行数:9,代码来源:sysdata_darwin.go

示例7: setWindowSize

func (s *sysData) setWindowSize(width int, height int) error {
	ret := make(chan struct{})
	defer close(ret)
	uitask <- func() {
		C.windowSetContentSize(s.id, C.intptr_t(width), C.intptr_t(height))
		ret <- struct{}{}
	}
	<-ret
	return nil
}
开发者ID:BlackWidowMaker,项目名称:ui,代码行数:10,代码来源:sysdata_darwin.go

示例8: Repaint

func (a *area) Repaint(r image.Rectangle) {
	var s C.struct_xrect

	r = image.Rect(0, 0, a.width, a.height).Intersect(r)
	if r.Empty() {
		return
	}
	s.x = C.intptr_t(r.Min.X)
	s.y = C.intptr_t(r.Min.Y)
	s.width = C.intptr_t(r.Dx())
	s.height = C.intptr_t(r.Dy())
	C.areaRepaint(a.id, s)
}
开发者ID:sjn1978,项目名称:ui,代码行数:13,代码来源:area_darwin.go

示例9: containerResized

//export containerResized
func containerResized(data unsafe.Pointer) {
	c := (*container)(data)
	d := beginResize()
	// TODO make this a parameter
	b := C.containerBounds(c.id)
	if c.margined {
		b.x += C.intptr_t(macXMargin)
		b.y += C.intptr_t(macYMargin)
		b.width -= C.intptr_t(macXMargin) * 2
		b.height -= C.intptr_t(macYMargin) * 2
	}
	c.resize(int(b.x), int(b.y), int(b.width), int(b.height), d)
}
开发者ID:sjn1978,项目名称:ui,代码行数:14,代码来源:container_darwin.go

示例10: newWindow

func newWindow(title string, width int, height int, control Control) *window {
	id := C.newWindow(C.intptr_t(width), C.intptr_t(height))
	ctitle := C.CString(title)
	defer C.free(unsafe.Pointer(ctitle))
	C.windowSetTitle(id, ctitle)
	w := &window{
		id:        id,
		closing:   newEvent(),
		container: newContainer(control),
	}
	C.windowSetDelegate(w.id, unsafe.Pointer(w))
	C.windowSetContentView(w.id, w.container.id)
	return w
}
开发者ID:NotBadPad,项目名称:ui,代码行数:14,代码来源:window_darwin.go

示例11: commitResize

func (s *sysData) commitResize(c *allocation, d *sysSizeData) {
	if s.ctype == c_label && !s.alternate && c.neighbor != nil {
		c.neighbor.getAuxResizeInfo(d)
		if d.neighborAlign.baseline != 0 { // no adjustment needed if the given control has no baseline
			// in order for the baseline value to be correct, the label MUST BE AT THE HEIGHT THAT OS X WANTS IT TO BE!
			// otherwise, the baseline calculation will be relative to the bottom of the control, and everything will be wrong
			origsize := C.controlPrefSize(s.id)
			c.height = int(origsize.height)
			newrect := C.struct_xrect{
				x:      C.intptr_t(c.x),
				y:      C.intptr_t(c.y),
				width:  C.intptr_t(c.width),
				height: C.intptr_t(c.height),
			}
			ourAlign := C.alignmentInfo(s.id, newrect)
			// we need to find the exact Y positions of the baselines
			// fortunately, this is easy now that (x,y) is the bottom-left corner
			thisbasey := ourAlign.alignmentRect.y + ourAlign.baseline
			neighborbasey := d.neighborAlign.alignmentRect.y + d.neighborAlign.baseline
			// now the amount we have to move the label down by is easy to find
			yoff := neighborbasey - thisbasey
			// and we just add that
			c.y += int(yoff)
		}
		// TODO if there's no baseline, the alignment should be to the top /of the alignment rect/, not the frame
	}
	C.setRect(s.id, C.intptr_t(c.x), C.intptr_t(c.y), C.intptr_t(c.width), C.intptr_t(c.height))
}
开发者ID:UIKit0,项目名称:ui,代码行数:28,代码来源:controlsize_darwin.go

示例12: doPaint

//export doPaint
func doPaint(xrect *C.RECT, hscroll C.int, vscroll C.int, data unsafe.Pointer, dx *C.intptr_t, dy *C.intptr_t) unsafe.Pointer {
	a := (*area)(data)
	// both Windows RECT and Go image.Rect are point..point, so the following is correct
	cliprect := image.Rect(int(xrect.left), int(xrect.top), int(xrect.right), int(xrect.bottom))
	cliprect = cliprect.Add(image.Pt(int(hscroll), int(vscroll))) // adjust by scroll position
	// make sure the cliprect doesn't fall outside the size of the Area
	cliprect = cliprect.Intersect(image.Rect(0, 0, a.width, a.height))
	if !cliprect.Empty() { // we have an update rect
		i := a.handler.Paint(cliprect)
		*dx = C.intptr_t(i.Rect.Dx())
		*dy = C.intptr_t(i.Rect.Dy())
		return unsafe.Pointer(i)
	}
	return nil
}
开发者ID:sjn1978,项目名称:ui,代码行数:16,代码来源:area_windows.go

示例13: areaView_drawRect

//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))
}
开发者ID:UIKit0,项目名称:ui,代码行数:16,代码来源:area_darwin.go

示例14: goTableDataSource_getRowCount

//export goTableDataSource_getRowCount
func goTableDataSource_getRowCount(data unsafe.Pointer) C.intptr_t {
	t := (*table)(data)
	t.RLock()
	defer t.RUnlock()
	d := reflect.Indirect(reflect.ValueOf(t.data))
	return C.intptr_t(d.Len())
}
开发者ID:sjn1978,项目名称:ui,代码行数:8,代码来源:table_darwin.go

示例15: newWindow

func newWindow(title string, width int, height int, control Control) *window {
	id := C.newWindow(C.intptr_t(width), C.intptr_t(height))
	ctitle := C.CString(title)
	defer C.free(unsafe.Pointer(ctitle))
	C.windowSetTitle(id, ctitle)
	w := &window{
		id:      id,
		closing: newEvent(),
		child:   control,
	}
	C.windowSetDelegate(w.id, unsafe.Pointer(w))
	w.container = newContainer(w.child.resize)
	w.child.setParent(w.container.parent())
	C.windowSetContentView(w.id, w.container.id)
	// trigger an initial resize
	return w
}
开发者ID:sjn1978,项目名称:ui,代码行数:17,代码来源:window_darwin.go


注:本文中的C.intptr_t函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。