Ejemplo n.º 1
0
Archivo: font.go Proyecto: wangch/walk
func newFontFromLOGFONT(lf *win.LOGFONT, dpi int) (*Font, error) {
	if lf == nil {
		return nil, newError("lf cannot be nil")
	}

	family := win.UTF16PtrToString(&lf.LfFaceName[0])
	pointSize := int(win.MulDiv(lf.LfHeight, 72, int32(dpi)))
	if pointSize < 0 {
		pointSize = -pointSize
	}

	var style FontStyle
	if lf.LfWeight > win.FW_NORMAL {
		style |= FontBold
	}
	if lf.LfItalic == win.TRUE {
		style |= FontItalic
	}
	if lf.LfUnderline == win.TRUE {
		style |= FontUnderline
	}
	if lf.LfStrikeOut == win.TRUE {
		style |= FontStrikeOut
	}

	return NewFont(family, pointSize, style)
}
Ejemplo n.º 2
0
func (tt *ToolTip) Text(tool Widget) string {
	ti := tt.toolInfo(tool)
	if ti == nil {
		return ""
	}

	return win.UTF16PtrToString(ti.LpszText)
}
Ejemplo n.º 3
0
// Text returns the current text data of the clipboard.
func (c *ClipboardService) Text() (text string, err error) {
	err = c.withOpenClipboard(func() error {
		hMem := win.HGLOBAL(win.GetClipboardData(win.CF_UNICODETEXT))
		if hMem == 0 {
			return lastError("GetClipboardData")
		}

		p := win.GlobalLock(hMem)
		if p == nil {
			return lastError("GlobalLock()")
		}
		defer win.GlobalUnlock(hMem)

		text = win.UTF16PtrToString((*uint16)(p))

		return nil
	})

	return
}