Example #1
0
File: font.go Project: wangch/walk
func init() {
	// Retrieve screen DPI
	hDC := win.GetDC(0)
	defer win.ReleaseDC(0, hDC)
	screenDPIX = int(win.GetDeviceCaps(hDC, win.LOGPIXELSX))
	screenDPIY = int(win.GetDeviceCaps(hDC, win.LOGPIXELSY))

	// Initialize default font
	var err error
	if defaultFont, err = NewFont("MS Shell Dlg 2", 8, 0); err != nil {
		panic("failed to create default font")
	}
}
Example #2
0
func (c *Canvas) init() (*Canvas, error) {
	c.dpix = int(win.GetDeviceCaps(c.hdc, win.LOGPIXELSX))
	c.dpiy = int(win.GetDeviceCaps(c.hdc, win.LOGPIXELSY))

	if win.SetBkMode(c.hdc, win.TRANSPARENT) == 0 {
		return nil, newError("SetBkMode failed")
	}

	switch win.SetStretchBltMode(c.hdc, win.HALFTONE) {
	case 0, win.ERROR_INVALID_PARAMETER:
		return nil, newError("SetStretchBltMode failed")
	}

	if !win.SetBrushOrgEx(c.hdc, 0, 0, nil) {
		return nil, newError("SetBrushOrgEx failed")
	}

	return c, nil
}
Example #3
0
func (c *Canvas) Bounds() Rectangle {
	return Rectangle{
		Width:  int(win.GetDeviceCaps(c.hdc, win.HORZRES)),
		Height: int(win.GetDeviceCaps(c.hdc, win.VERTRES)),
	}
}