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


Golang C.LONG函数代码示例

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


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

示例1: NewPropRange

func NewPropRange(obj, how, min, max int) propHeader {
	var p C.DIPROPRANGE
	p.diph.dwSize = C.sizeof_DIPROPRANGE
	p.diph.dwHeaderSize = C.sizeof_DIPROPHEADER
	p.diph.dwObj = C.DWORD(obj)
	p.diph.dwHow = C.DWORD(how)
	p.lMin = C.LONG(min)
	p.lMax = C.LONG(max)
	return &propRange{p}
}
开发者ID:gonutz,项目名称:di8,代码行数:10,代码来源:IDirectInputDevice8.go

示例2: setSize

// Change the size of the rendering region of the window
func (wi *windowInternal) setSize(x, y uint) {
	// SetWindowPos wants the total size of the window (including title bar and borders),
	// so we have to compute it
	rect := C.RECT{0, 0, C.LONG(x), C.LONG(y)}
	style := C.GetWindowLong(wi.window.Handle, C.GWL_STYLE)
	C.__AdjustWindowRect(&rect, C.DWORD(style), C.FALSE)
	width := C.int(rect.right - rect.left)
	height := C.int(rect.bottom - rect.top)

	C.SetWindowPos(wi.window.Handle, nil, 0, 0, width, height, C.SWP_NOMOVE|C.SWP_NOZORDER)
}
开发者ID:Popog,项目名称:go-glml,代码行数:12,代码来源:windowinternal_windows.go

示例3: commitResize

func (g *group) commitResize(c *allocation, d *sizing) {
	var r C.RECT

	// pretend that the client area of the group box only includes the actual empty space
	// container will handle the necessary adjustments properly
	r.left = 0
	r.top = 0
	r.right = C.LONG(c.width)
	r.bottom = C.LONG(c.height)
	g.container.move(&r)
	basecommitResize(g, c, d)
}
开发者ID:NotBadPad,项目名称:ui,代码行数:12,代码来源:group_windows.go

示例4: initialize

// Creates the window. This function expects not to be called on a ContextThread
func (wi *windowInternal) initialize(monitor *Monitor, mode VideoMode, title string, style WindowStyle) ThreadError {
	// Compute position and size
	screenDC := C.GetDC(nil)
	width := C.int(mode.Width)
	height := C.int(mode.Height)
	left := (C.GetDeviceCaps(screenDC, C.HORZRES) - width) / 2
	top := (C.GetDeviceCaps(screenDC, C.VERTRES) - height) / 2
	C.ReleaseDC(nil, screenDC)

	// Choose the window style according to the Style parameter
	win32Style := C.DWORD(C.WS_VISIBLE)
	if style == WindowStyleNone {
		win32Style |= C.WS_POPUP
	} else {
		if style&WindowStyleTitlebar != 0 {
			win32Style |= C.WS_CAPTION | C.WS_MINIMIZEBOX
		}
		if style&WindowStyleResize != 0 {
			win32Style |= C.WS_THICKFRAME | C.WS_MAXIMIZEBOX
		}
		if style&WindowStyleClose != 0 {
			win32Style |= C.WS_SYSMENU
		}
	}

	// In windowed mode, adjust width and height so that window will have the requested client area
	fullscreen := style&WindowStyleFullscreen != 0
	if !fullscreen {
		rectangle := C.RECT{
			left:   C.LONG(left),
			top:    C.LONG(top),
			right:  C.LONG(left + width),
			bottom: C.LONG(top + height),
		}
		C.__AdjustWindowRect(&rectangle, win32Style, C.FALSE)
		left = C.int(rectangle.left)
		top = C.int(rectangle.top)
		width = C.int(rectangle.right - rectangle.left)
		height = C.int(rectangle.bottom - rectangle.top)
	}
	wTitle, _ := utf16Convert(title)
	wi.window.Handle = C.CreateWindowExW(0, className, wTitle, win32Style, left, top, width, height, nil, nil, windowClass.hInstance, C.LPVOID(wi))

	// Switch to fullscreen if requested
	if fullscreen {
		wi.switchToFullscreen(monitor, mode)
	}

	return nil
}
开发者ID:Popog,项目名称:go-glml,代码行数:51,代码来源:windowinternal_windows.go

示例5: Repaint

func (a *area) Repaint(r image.Rectangle) {
	var hscroll, vscroll C.int
	var rect C.RECT

	C.SendMessageW(a.hwnd, C.msgAreaGetScroll, C.WPARAM(uintptr(unsafe.Pointer(&hscroll))), C.LPARAM(uintptr(unsafe.Pointer(&vscroll))))
	r = r.Add(image.Pt(int(hscroll), int(vscroll))) // adjust by scroll position
	r = image.Rect(0, 0, a.width, a.height).Intersect(r)
	if r.Empty() {
		return
	}
	rect.left = C.LONG(r.Min.X)
	rect.top = C.LONG(r.Min.Y)
	rect.right = C.LONG(r.Max.X)
	rect.bottom = C.LONG(r.Max.Y)
	C.SendMessageW(a.hwnd, C.msgAreaRepaint, 0, C.LPARAM(uintptr(unsafe.Pointer(&rect))))
}
开发者ID:sjn1978,项目名称:ui,代码行数:16,代码来源:area_windows.go

示例6: setMousePosition

// Set the current position of the mouse in window coordinates
func (wi *windowInternal) setMousePosition(x, y int) ThreadError {
	if !wi.window.IsValid() {
		// TODO ERROR
		return nil
	}

	point := C.POINT{x: C.LONG(x), y: C.LONG(y)}
	if C.__ScreenToClient(wi.window.Handle, &point) == 0 {
		return NewThreadError(fmt.Errorf("ScreenToClient (%d)", C.GetLastError()), false)
	}

	if C.SetCursorPos(C.int(x), C.int(y)) == 0 {
		return NewThreadError(fmt.Errorf("SetCursorPos (%d)", C.GetLastError()), false)
	}

	return nil
}
开发者ID:Popog,项目名称:go-glml,代码行数:18,代码来源:windowinternal_windows.go

示例7: commitResize

// a tab control contains other controls; size appropriately
func (t *tab) commitResize(c *allocation, d *sizing) {
	var r C.RECT

	// figure out what the rect for each child is...
	// the tab contents are children of the tab itself, so ignore c.x and c.y, which are relative to the window!
	r.left = C.LONG(0)
	r.top = C.LONG(0)
	r.right = C.LONG(c.width)
	r.bottom = C.LONG(c.height)
	C.tabGetContentRect(t._hwnd, &r)
	// and resize tabs
	// don't resize just the current tab; resize all tabs!
	for _, c := range t.tabs {
		// because each widget is actually a child of the Window, the origin is the one we calculated above
		c.move(&r)
	}
	// and now resize the tab control itself
	basecommitResize(t, c, d)
}
开发者ID:NotBadPad,项目名称:ui,代码行数:20,代码来源:tab_windows.go

示例8: commitResize

// a tab control contains other controls; size appropriately
func (t *tab) commitResize(c *allocation, d *sizing) {
	var r C.RECT

	// figure out what the rect for each child is...
	// the tab contents are children of the tab itself, so ignore c.x and c.y, which are relative to the window!
	r.left = C.LONG(0)
	r.top = C.LONG(0)
	r.right = C.LONG(c.width)
	r.bottom = C.LONG(c.height)
	C.tabGetContentRect(t._hwnd, &r)
	// and resize tabs
	// resize only the current tab; we trigger a resize on a tab change to make sure things look correct
	if len(t.tabs) > 0 {
		t.tabs[C.SendMessageW(t._hwnd, C.TCM_GETCURSEL, 0, 0)].move(&r)
	}
	// save the tab size so we can
	t.switchrect = r
	// and now resize the tab control itself
	basecommitResize(t, c, d)
}
开发者ID:NotBadPad,项目名称:ui,代码行数:21,代码来源:windows-one-tab.go

示例9: xpreferredSize

func (g *group) xpreferredSize(d *sizing) (width, height int) {
	var r C.RECT

	width, height = g.child.preferredSize(d)
	if width < int(g.textlen) { // if the text is longer, try not to truncate
		width = int(g.textlen)
	}
	r.left = 0
	r.top = 0
	r.right = C.LONG(width)
	r.bottom = C.LONG(height)
	// use negative numbers to increase the size of the rectangle
	if g.margined {
		marginRectDLU(&r, -groupYMarginTop, -groupYMarginBottom, -groupXMargin, -groupXMargin, d)
	} else {
		// unforutnately, as mentioned above, the size of a groupbox includes the label and border
		// 1 character cell (4DLU x, 8DLU y) on each side (but only 3DLU on the bottom) should be enough to make up for that; TODO is not, we can change it
		// TODO make these named constants
		marginRectDLU(&r, -8, -3, -4, -4, d)
	}
	return int(r.right - r.left), int(r.bottom - r.top)
}
开发者ID:sjn1978,项目名称:ui,代码行数:22,代码来源:group_windows.go

示例10: ToMatrix

// ToMatrix converts a sparse matrix in triplet form to column-compressed form using Umfpack's
// routines. "realloc_a" indicates whether the internal "a" matrix must be reallocated or not,
// for instance, in case the structure of the triplet has changed.
//  INPUT:
//   a -- a previous CCMatrix to be filled in; otherwise, "nil" tells to allocate a new one
//  OUTPUT:
//   the previous "a" matrix or a pointer to a new one
func (t *Triplet) ToMatrix(a *CCMatrix) *CCMatrix {
	if t.pos < 1 {
		chk.Panic(_sparsemat_umfpack_err1, t.pos)
	}
	if a == nil {
		a = new(CCMatrix)
		a.m, a.n, a.nnz = t.m, t.n, t.pos
		a.p = make([]int, a.n+1)
		a.i = make([]int, a.nnz)
		a.x = make([]float64, a.nnz)
	}
	Ti := (*C.LONG)(unsafe.Pointer(&t.i[0]))
	Tj := (*C.LONG)(unsafe.Pointer(&t.j[0]))
	Tx := (*C.double)(unsafe.Pointer(&t.x[0]))
	Ap := (*C.LONG)(unsafe.Pointer(&a.p[0]))
	Ai := (*C.LONG)(unsafe.Pointer(&a.i[0]))
	Ax := (*C.double)(unsafe.Pointer(&a.x[0]))
	status := C.umfpack_dl_triplet_to_col(C.LONG(a.m), C.LONG(a.n), C.LONG(a.nnz), Ti, Tj, Tx, Ap, Ai, Ax, nil)
	if status != C.UMFPACK_OK {
		chk.Panic(_sparsemat_umfpack_err2, Uerr2Text[int(status)])
	}
	return a
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:30,代码来源:sparsemat_umfpack.go

示例11: Shuffle

// Shuffle shuffles slice of integers
func Shuffle(values []int) {
	C.SfmtShuffle((*C.LONG)(unsafe.Pointer(&values[0])), C.LONG(len(values)))
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:4,代码来源:sfmt.go

示例12: Rand

// Rand generates pseudo random integer between low and high
//  Input:
//   low  -- lower limit
//   high -- upper limit
//  Output:
//   random integer
func Rand(low, high int) int {
	return int(C.SfmtRand(C.LONG(low), C.LONG(high)))
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:9,代码来源:sfmt.go

示例13: Init

// Init initialises random numbers generator
//  Input:
//   seed -- seed value; use seed <= 0 to use current time
func Init(seed int) {
	if seed <= 0 {
		seed = int(time.Now().Unix())
	}
	C.SfmtInit(C.LONG(seed))
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:9,代码来源:sfmt.go

示例14: processEvent


//.........这里部分代码省略.........
		if !wi.keyRepeatEnabled && lParam&(1<<30) != 0 {
			break
		}

		events = append(events, TextEnteredEvent{
			Character: rune(wParam),
		})

	case C.WM_KEYDOWN, C.WM_SYSKEYDOWN: // Keydown event
		if !wi.keyRepeatEnabled && C.__HIWORD(C.DWORD(lParam))&C.KF_REPEAT != 0 {
			break
		}

		events = append(events, KeyPressedEvent{
			Code:    virtualKeyCodeToSF(wParam, lParam),
			Alt:     C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_MENU))) != 0,
			Control: C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_CONTROL))) != 0,
			Shift:   C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_SHIFT))) != 0,
			System:  C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_LWIN))) != 0 || C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_RWIN))) != 0,
		})

	case C.WM_KEYUP, C.WM_SYSKEYUP: // Keyup event
		events = append(events, KeyReleasedEvent{
			Code:    virtualKeyCodeToSF(wParam, lParam),
			Alt:     C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_MENU))) != 0,
			Control: C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_CONTROL))) != 0,
			Shift:   C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_SHIFT))) != 0,
			System:  C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_LWIN))) != 0 || C.__HIWORD(C.DWORD(C.GetAsyncKeyState(C.VK_RWIN))) != 0,
		})

	case C.WM_MOUSEWHEEL: // Mouse wheel event
		// Mouse position is in screen coordinates, convert it to window coordinates
		position := C.POINT{
			x: C.LONG(C.__LOWORD(C.DWORD(lParam))),
			y: C.LONG(C.__HIWORD(C.DWORD(lParam))),
		}
		C.__ScreenToClient(wi.window.Handle, &position)

		events = append(events, MouseWheelEvent{
			Delta: int(int16(C.__HIWORD(C.DWORD(wParam))) / 120),
			X:     int(position.x),
			Y:     int(position.y),
		})

	case C.WM_LBUTTONDOWN, C.WM_RBUTTONDOWN: // Mouse left/right button down event
		button := mouse_vkeys_handed_map[mouseKey{message, C.GetSystemMetrics(C.SM_SWAPBUTTON) == C.TRUE}]
		events = append(events, MouseButtonPressedEvent{
			Button: button,
			X:      int(C.__LOWORD(C.DWORD(lParam))),
			Y:      int(C.__HIWORD(C.DWORD(lParam))),
		})

	case C.WM_LBUTTONUP, C.WM_RBUTTONUP: // Mouse left/right button up event
		button := mouse_vkeys_handed_map[mouseKey{message, C.GetSystemMetrics(C.SM_SWAPBUTTON) == C.TRUE}]
		events = append(events, MouseButtonReleasedEvent{
			Button: button,
			X:      int(C.__LOWORD(C.DWORD(lParam))),
			Y:      int(C.__HIWORD(C.DWORD(lParam))),
		})

	case C.WM_MBUTTONDOWN: // Mouse wheel button down event
		events = append(events, MouseButtonPressedEvent{
			Button: MouseMiddle,
			X:      int(C.__LOWORD(C.DWORD(lParam))),
			Y:      int(C.__HIWORD(C.DWORD(lParam))),
		})
开发者ID:Popog,项目名称:go-glml,代码行数:67,代码来源:windowinternal_windows.go

示例15: Fact

// Fact performs symbolic/numeric factorisation. This method also converts the triplet form
// to the column-compressed form, including the summation of duplicated entries
func (o *LinSolUmfpack) Fact() (err error) {

	// start time
	if o.ton {
		o.tini = time.Now()
	}

	// message
	if o.verb {
		io.Pfgreen("\n . . . . . . . . . . . . . . LinSolUmfpack.Fact . . . . . . . . . . . . . . . \n\n")
	}

	// factorisation
	if o.cmplx {

		// UMFPACK: convert triplet to column-compressed format
		st := C.umfpack_zl_triplet_to_col(C.LONG(o.tC.m), C.LONG(o.tC.n), C.LONG(o.tC.pos), o.ti, o.tj, o.tx, o.tz, o.ap, o.ai, o.ax, o.az, nil)
		if st != C.UMFPACK_OK {
			return chk.Err(_linsol_umfpack_err04, Uerr2Text[int(st)])
		}

		// UMFPACK: symbolic factorisation
		st = C.umfpack_zl_symbolic(C.LONG(o.tC.m), C.LONG(o.tC.n), o.ap, o.ai, o.ax, o.az, &o.usymb, o.uctrl, nil)
		if st != C.UMFPACK_OK {
			return chk.Err(_linsol_umfpack_err05, Uerr2Text[int(st)])
		}

		// UMFPACK: numeric factorisation
		st = C.umfpack_zl_numeric(o.ap, o.ai, o.ax, o.az, o.usymb, &o.unum, o.uctrl, nil)
		if st != C.UMFPACK_OK {
			return chk.Err(_linsol_umfpack_err06, Uerr2Text[int(st)])
		}

	} else {

		// UMFPACK: convert triplet to column-compressed format
		st := C.umfpack_dl_triplet_to_col(C.LONG(o.tR.m), C.LONG(o.tR.n), C.LONG(o.tR.pos), o.ti, o.tj, o.tx, o.ap, o.ai, o.ax, nil)
		if st != C.UMFPACK_OK {
			return chk.Err(_linsol_umfpack_err07, Uerr2Text[int(st)])
		}

		// UMFPACK: symbolic factorisation
		st = C.umfpack_dl_symbolic(C.LONG(o.tR.m), C.LONG(o.tR.n), o.ap, o.ai, o.ax, &o.usymb, o.uctrl, nil)
		if st != C.UMFPACK_OK {
			return chk.Err(_linsol_umfpack_err08, Uerr2Text[int(st)])
		}

		// UMFPACK: numeric factorisation
		st = C.umfpack_dl_numeric(o.ap, o.ai, o.ax, o.usymb, &o.unum, o.uctrl, nil)
		if st != C.UMFPACK_OK {
			return chk.Err(_linsol_umfpack_err09, Uerr2Text[int(st)])
		}

		return

	}

	// duration
	if o.ton {
		io.Pfcyan("%s: Time spent in LinSolUmfpack.Fact  = %v\n", o.name, time.Now().Sub(o.tini))
	}
	return
}
开发者ID:PatrickSchm,项目名称:gosl,代码行数:65,代码来源:linsol_umfpack.go


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