ui

package module
v0.0.0-...-a9e01a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2016 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MOUSE_LEFT   = MouseKey(0)
	MOUSE_RIGHT  = MouseKey(1)
	MOUSE_MIDDLE = MouseKey(2)
)
View Source
const (
	FILL_SOLID  = FillStyleType(0)
	FILL_LINEAR = FillStyleType(1)
)
View Source
const (
	KEY_BACK  = Key(C.gKEY_BACK)
	KEY_TAB   = Key(C.gKEY_TAB)
	KEY_ENTER = Key(C.gKEY_ENTER)
	KEY_SHIFT = Key(C.gKEY_SHIFT)
	KEY_CTRL  = Key(C.gKEY_CTRL)
	KEY_ALT   = Key(C.gKEY_ALT)
	KEY_PAUSE = Key(C.gKEY_PAUSE)
	KEY_CAPS  = Key(C.gKEY_CAPS)
	KEY_ESC   = Key(C.gKEY_ESC)
	KEY_SPACE = Key(C.gKEY_SPACE)

	KEY_PAGEUP   = Key(C.gKEY_PAGEUP)
	KEY_PAGEDOWN = Key(C.gKEY_PAGEDOWN)
	KEY_END      = Key(C.gKEY_END)
	KEY_HOME     = Key(C.gKEY_HOME)

	KEY_LEFT  = Key(C.gKEY_LEFT)
	KEY_UP    = Key(C.gKEY_UP)
	KEY_RIGHT = Key(C.gKEY_RIGHT)
	KEY_DOWN  = Key(C.gKEY_DOWN)

	KEY_PRINT  = Key(C.gKEY_PRINT)
	KEY_INSERT = Key(C.gKEY_INSERT)
	KEY_DELETE = Key(C.gKEY_DELETE)
	KEY_HELP   = Key(C.gKEY_HELP)

	KEY_NUM0 = Key(C.gKEY_NUM0)
	KEY_NUM1 = Key(C.gKEY_NUM1)
	KEY_NUM2 = Key(C.gKEY_NUM2)
	KEY_NUM3 = Key(C.gKEY_NUM3)
	KEY_NUM4 = Key(C.gKEY_NUM4)
	KEY_NUM5 = Key(C.gKEY_NUM5)
	KEY_NUM6 = Key(C.gKEY_NUM6)
	KEY_NUM7 = Key(C.gKEY_NUM7)
	KEY_NUM8 = Key(C.gKEY_NUM8)
	KEY_NUM9 = Key(C.gKEY_NUM9)

	KEY_F1  = Key(C.gKEY_F1)
	KEY_F2  = Key(C.gKEY_F2)
	KEY_F3  = Key(C.gKEY_F3)
	KEY_F4  = Key(C.gKEY_F4)
	KEY_F5  = Key(C.gKEY_F5)
	KEY_F6  = Key(C.gKEY_F6)
	KEY_F7  = Key(C.gKEY_F7)
	KEY_F8  = Key(C.gKEY_F8)
	KEY_F9  = Key(C.gKEY_F9)
	KEY_F10 = Key(C.gKEY_F10)
	KEY_F11 = Key(C.gKEY_F11)
	KEY_F12 = Key(C.gKEY_F12)

	KEY_NUMLOCK = Key(C.gKEY_NUMLOCK)
	KEY_LSHIFT  = Key(C.gKEY_LSHIFT)
	KEY_RSHIFT  = Key(C.gKEY_RSHIFT)
	KEY_LCTRL   = Key(C.gKEY_LCTRL)
	KEY_RCTRL   = Key(C.gKEY_RCTRL)
	KEY_LALT    = Key(C.gKEY_LALT)
	KEY_RALT    = Key(C.gKEY_RALT)

	KEY_A = Key(C.gKEY_A)
	KEY_B = Key(C.gKEY_B)
	KEY_C = Key(C.gKEY_C)
	KEY_D = Key(C.gKEY_D)
	KEY_E = Key(C.gKEY_E)
	KEY_F = Key(C.gKEY_F)
	KEY_G = Key(C.gKEY_G)
	KEY_H = Key(C.gKEY_H)
	KEY_I = Key(C.gKEY_I)
	KEY_J = Key(C.gKEY_J)
	KEY_K = Key(C.gKEY_K)
	KEY_L = Key(C.gKEY_L)
	KEY_M = Key(C.gKEY_M)
	KEY_N = Key(C.gKEY_N)
	KEY_O = Key(C.gKEY_O)
	KEY_P = Key(C.gKEY_P)
	KEY_Q = Key(C.gKEY_Q)
	KEY_R = Key(C.gKEY_R)
	KEY_S = Key(C.gKEY_S)
	KEY_T = Key(C.gKEY_T)
	KEY_U = Key(C.gKEY_U)
	KEY_V = Key(C.gKEY_V)
	KEY_W = Key(C.gKEY_W)
	KEY_X = Key(C.gKEY_X)
	KEY_Y = Key(C.gKEY_Y)
	KEY_Z = Key(C.gKEY_Z)

	KEY_1 = Key(C.gKEY_1)
	KEY_2 = Key(C.gKEY_2)
	KEY_3 = Key(C.gKEY_3)
	KEY_4 = Key(C.gKEY_4)
	KEY_5 = Key(C.gKEY_5)
	KEY_6 = Key(C.gKEY_6)
	KEY_7 = Key(C.gKEY_7)
	KEY_8 = Key(C.gKEY_8)
	KEY_9 = Key(C.gKEY_9)
	KEY_0 = Key(C.gKEY_0)

	KEY_MINUS_UNDERLINE = Key(C.gKEY_MINUS_UNDERLINE) // -_
	KEY_ADDA_ND         = Key(C.gKEY_ADDA_ND)         // +=
	KEY_BACKLASH        = Key(C.gKEY_BACKLASH)        // |\
	KEY_TILDE           = Key(C.gKEY_TILDE)           // `~
	KEY_SEMICONLON      = Key(C.gKEY_SEMICONLON)      // :;
	KEY_QUOTES          = Key(C.gKEY_QUOTES)          // '"
	KEY_COMMA           = Key(C.gKEY_COMMA)           // <,
	KEY_PERIOD          = Key(C.gKEY_PERIOD)          // .>
	KEY_FORWARDSLASH    = Key(C.gKEY_FORWARDSLASH)    // /?
	KEY_BRACKETLEFT     = Key(C.gKEY_BRACKETLEFT)     // [{
	KEY_BRACKETRIGHT    = Key(C.gKEY_BRACKETRIGHT)    // ]}

	KEY_NUM_FORWARDSLASH = Key(C.gKEY_NUM_FORWARDSLASH)
	KEY_NUM_ASTERISK     = Key(C.gKEY_NUM_ASTERISK)
	KEY_NUM_MINUS        = Key(C.gKEY_NUM_MINUS)
	KEY_NUM_ADD          = Key(C.gKEY_NUM_ADD)
	KEY_NUM_DOT          = Key(C.gKEY_NUM_DOT)
)

========= key const ======

View Source
const (
	STYLE_DEFAULT = C.gWS_DEFAULT
	STYLE_CHILD   = C.gWS_CHILD
	STYLE_TOOL    = C.gWS_TOOL

	FONT_BOLD      = int(C.gFONT_BOLD)
	FONT_ITALIC    = int(C.gFONT_ITALIC)
	FONT_UNDERLINE = int(C.gFONT_UNDERLINE)
	FONT_STRIKEOUT = int(C.gFONT_STRIKEOUT)
)

Variables

View Source
var (
	DefaultBackground  = NewRGB(23, 24, 20)
	DefaultFrontground = NewRGB(39, 40, 34)
	DefaultLineColor   = NewRGB(60, 61, 56)
	DefaultFontColor   = NewRGB(255, 255, 255)
)
View Source
var DefaultFont = NewFont("宋体", 0, 12)

set canvas font new canvas use this font

Functions

func AddFont

func AddFont(p string) error

add font resource

func Init

func Init() error

========= init ========

func RGBA_F_To_UINT

func RGBA_F_To_UINT(r, g, b, a float32) (uint8, uint8, uint8, uint8)

func RemoveFont

func RemoveFont(p string) error

func RunLoop

func RunLoop(win Frame)

Types

type Canvas

type Canvas struct {
	Font *Font

	Line struct {
		Width int
		Color *RGB
	}

	FillStyle FillStyle
	// contains filtered or unexported fields
}

======= canvas =========

func NewCanvas

func NewCanvas(h DC, f Frame) *Canvas

canvas ctor

func (*Canvas) Arc

func (c *Canvas) Arc(p *Point, radius int, start, end float64)

arc path p center of a circle r radius start angle end angle

func (*Canvas) BeginPath

func (c *Canvas) BeginPath(p *Point)

begin path x, y path start point

func (*Canvas) Beizer2

func (c *Canvas) Beizer2(sp, cp, ep *Point)

quadratic beizer

func (*Canvas) Beizer3

func (c *Canvas) Beizer3(sp, cp1, cp2, ep *Point)

cube beizer

func (*Canvas) DrawImage

func (c *Canvas) DrawImage(img *Image, pt *Point)

func (*Canvas) DrawText

func (c *Canvas) DrawText(str string, pt *Point, size int)

func (*Canvas) EndPath

func (c *Canvas) EndPath()

func (*Canvas) Fill

func (c *Canvas) Fill()

func (*Canvas) FillRect

func (c *Canvas) FillRect(r *Rectangle)

func (*Canvas) LineMoveTo

func (c *Canvas) LineMoveTo(p *Point)

func (*Canvas) LineTo

func (c *Canvas) LineTo(p *Point)

func (*Canvas) Pix

func (c *Canvas) Pix(p *Point) *RGB

---------- pix -----------

func (*Canvas) Rect

func (c *Canvas) Rect(r *Rectangle)

func (*Canvas) RoundRect

func (c *Canvas) RoundRect(r *Rectangle, radius int)

func (*Canvas) SetPix

func (c *Canvas) SetPix(p *Point, rgb *RGB)

func (*Canvas) Stroke

func (c *Canvas) Stroke()

type Char

type Char C.gCHAR

type DC

type DC C.gDC

type FillStyle

type FillStyle interface {
	Type() FillStyleType
	// contains filtered or unexported methods
}

type FillStyleType

type FillStyleType int

type Font

type Font struct {
	Face  string
	Style int
	Color *RGB
	Size  int
}

func NewFont

func NewFont(s string, st, size int) *Font

type Frame

type Frame interface {
	Handle() Handle
	Destory()
	GetMessage() bool
	Show() // show and updata window

	Size() *Size
	SetSize(s *Size)

	Opacity() uint8
	SetOpacity(a uint8)

	MoveBottom() // move win to layer bottom
	MoveTop()    // move win to layer up

	Location() *Point
	SetLocation(p *Point)
	// modules
	Modules() map[Handle]Frame
	AddModule(m Frame)
	ReomoveModule(m Frame)
	SetModules(ms map[Handle]Frame)
	FindModule(h Handle) Frame

	Rect() *Rectangle
	SetRect(r *Rectangle)

	SetIcon(ico *Image)
	Repaint()

	// ---- event ----
	OnClose() bool     // return true send close to window
	OnPaint(c *Canvas) // begin paint event
	OnSize(s *Size)
	OnDestory()
	OnMove(p *Point)

	OnFocus()
	OnFocusOut()

	OnKeyDown(k Key)
	OnKeyUp(k Key)

	OnMouseDown(p *Point, btn MouseKey)
	OnMouseUp(p *Point, btn MouseKey)
	OnMouseDouble(p *Point, btn MouseKey)
	OnMouseWheel(p *Point, wheel int)

	OnCreated()
	OnShow()

	OnMouseMove(p *Point)
	OnMouseLeave()
	OnMouseHover()
	// contains filtered or unexported methods
}

all control interface

var MainFrame Frame

type Handle

type Handle C.gHANDLE

========= type ======== windows handle

type Image

type Image struct {
	// contains filtered or unexported fields
}

func LoadImage

func LoadImage(path string) (*Image, error)

func NewImage

func NewImage(img image.Image) *Image

func (*Image) At

func (i *Image) At(x, y int) color.RGBA

func (*Image) RGBA

func (i *Image) RGBA(x, y int) (r uint8, g uint8, b uint8, a uint8)

func (*Image) RGBAF

func (i *Image) RGBAF(x, y int) (r float32, g float32, b float32, a float32)

func (*Image) Size

func (i *Image) Size() *Size

type Key

type Key int

type Module

type Module struct {
	// contains filtered or unexported fields
}

========== Module ==========

func NewModule

func NewModule(size *Size, p *Point, style int, parent Frame) (*Module, error)

ctor

func (*Module) AddModule

func (m *Module) AddModule(f Frame)

func (*Module) Destory

func (m *Module) Destory()

func (*Module) FindModule

func (m *Module) FindModule(h Handle) Frame

func (*Module) GetMessage

func (m *Module) GetMessage() bool

func (*Module) Handle

func (m *Module) Handle() Handle

func (*Module) Location

func (m *Module) Location() *Point

func (*Module) Modules

func (m *Module) Modules() map[Handle]Frame

func (*Module) MoveBottom

func (m *Module) MoveBottom()

func (*Module) MoveTop

func (m *Module) MoveTop()

func (*Module) OnClose

func (m *Module) OnClose() bool

=============== [ events ] =====================

func (*Module) OnCreated

func (m *Module) OnCreated()

func (*Module) OnDestory

func (m *Module) OnDestory()

func (*Module) OnFocus

func (m *Module) OnFocus()

func (*Module) OnFocusOut

func (m *Module) OnFocusOut()

func (*Module) OnKeyDown

func (m *Module) OnKeyDown(k Key)

func (*Module) OnKeyUp

func (m *Module) OnKeyUp(k Key)

func (*Module) OnMouseDouble

func (m *Module) OnMouseDouble(p *Point, btn MouseKey)

func (*Module) OnMouseDown

func (m *Module) OnMouseDown(p *Point, btn MouseKey)

func (*Module) OnMouseHover

func (m *Module) OnMouseHover()

func (*Module) OnMouseLeave

func (m *Module) OnMouseLeave()

func (*Module) OnMouseMove

func (m *Module) OnMouseMove(p *Point)

func (*Module) OnMouseUp

func (m *Module) OnMouseUp(p *Point, btn MouseKey)

func (*Module) OnMouseWheel

func (m *Module) OnMouseWheel(p *Point, wheel int)

func (*Module) OnMove

func (m *Module) OnMove(p *Point)

func (*Module) OnPaint

func (m *Module) OnPaint(c *Canvas)

func (*Module) OnShow

func (m *Module) OnShow()

func (*Module) OnSize

func (m *Module) OnSize(size *Size)

func (*Module) Opacity

func (m *Module) Opacity() uint8

func (*Module) Rect

func (m *Module) Rect() *Rectangle

func (*Module) ReomoveModule

func (m *Module) ReomoveModule(f Frame)

func (*Module) Repaint

func (m *Module) Repaint()

func (*Module) SetIcon

func (m *Module) SetIcon(img *Image)

func (*Module) SetLocation

func (m *Module) SetLocation(p *Point)

func (*Module) SetModules

func (m *Module) SetModules(ms map[Handle]Frame)

func (*Module) SetOpacity

func (m *Module) SetOpacity(a uint8)

func (*Module) SetRect

func (m *Module) SetRect(r *Rectangle)

func (*Module) SetSize

func (m *Module) SetSize(p *Size)

func (*Module) SetText

func (m *Module) SetText(t string)

func (*Module) Show

func (m *Module) Show()

func (*Module) Size

func (m *Module) Size() *Size

---

func (*Module) Text

func (m *Module) Text() string

type MouseKey

type MouseKey int

type Point

type Point struct {
	X, Y int
}

func CursorPos

func CursorPos() *Point

func NewPoint

func NewPoint(x, y int) *Point

type RGB

type RGB struct {
	R, G, B uint8
}

func NewRGB

func NewRGB(r, g, b uint8) *RGB

func (*RGB) Type

func (r *RGB) Type() FillStyleType

type Rectangle

type Rectangle struct {
	X, Y, Width, Height int
}

*************** rectangle ****************

func NewRect

func NewRect(x, y, width, height int) *Rectangle

func Rect

func Rect(left, top, right, bottom int) *Rectangle

func (*Rectangle) Bottom

func (r *Rectangle) Bottom() int

func (*Rectangle) Left

func (r *Rectangle) Left() int

func (*Rectangle) PointIn

func (r *Rectangle) PointIn(p *Point) bool

point int rect

func (*Rectangle) Right

func (r *Rectangle) Right() int

func (*Rectangle) Top

func (r *Rectangle) Top() int

type Size

type Size struct {
	Width, Height int
}

func NewSize

func NewSize(w, h int) *Size

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL