gd

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

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

Go to latest
Published: Jun 19, 2021 License: BSD-2-Clause Imports: 12 Imported by: 0

README

gd

windows go下的 duilib,directui 界面库.

借助go语言对c++版的duilib进行重写,一些函数的并没有完全追从c++的方法进行一模一样的进行重写,一些功能和特性上,肯定是减少了,但会逐步的进行完善.确保能够在windows上能够稳定运行.

大致会在2021.10月完成第一版的重写

  • 完成基本的事件消息循环
  • 支持布局和简单控件

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegWinClass       = make(map[string]bool)
	DefaultWndProcPtr uintptr
	Hwnd2WindowBase   = make(map[win.HWND]*WindowBase)
)

必须先注册窗口类

Functions

func DrawColor

func DrawColor(hdc win.HDC, rc win.RECT, argb win.ARGB)

func DrawImage

func DrawImage(hdc win.HDC)

func DrawRect

func DrawRect(hdc win.HDC, rc win.RECT, size int)

func DrawRectRound

func DrawRectRound(hdc win.HDC, rc win.RECT, size int)

func GetSpLitInt

func GetSpLitInt(src, splic string) (out []int)

func GetSpLitInt32

func GetSpLitInt32(src, splic string) (out []int32)

func InitWidget

func InitWidget(widget Widget, parent Window, className string, style, exStyle uint32) error

初始化一个 widget

func InitWindow

func InitWindow(window, parent Window, className string, style, exStyle uint32) error

func MustRegWin

func MustRegWin(className string, wndProcPtr uintptr, style uint32) error

func MustRegWinProcPtr

func MustRegWinProcPtr(className string, wndProcPtr uintptr)

func NewErr

func NewErr(str string) error

func String2Int16

func String2Int16(src string) uint64

Types

type Color

type Color uint32

func RGB

func RGB(r, g, b byte) Color

func (Color) B

func (c Color) B() byte

func (Color) G

func (c Color) G() byte

func (Color) R

func (c Color) R() byte

type ContainerUI

type ContainerUI struct {
	UI ControlUI

	// 绘制子节点
	Item []interface{}
}

type ControlUI

type ControlUI struct {
	Cover *ControlUI
	// Bkcolor string
	Bkcolor uint64
	XYFixed Size // width="100" + height="30"(用处:尺寸,与pos相冲突,谁在后,以谁为准。)
	Item    []interface{}
}

type Default

type Default struct {
	Shared string `xml:"shared,attr"`
}

type DialogBuilder

type DialogBuilder struct {
}

func (*DialogBuilder) Create

func (c *DialogBuilder) Create(sfilexml string, manager *PaintManagerUI)

读取xml 解析数据 可以做遍历两个树,一个是整个控件的xml属性,一个是真实的值,还有一个map存储所有的控件(有一个sid:唯一的值.)

func (*DialogBuilder) Parse

func (c *DialogBuilder) Parse(sfilexml string, manager *PaintManagerUI, xw *WindowXml)

解析子控件数据

func (*DialogBuilder) RangeListParse

func (c *DialogBuilder) RangeListParse(el []*etree.Element, manager *PaintManagerUI) (r1 []interface{})

type DoControlUI

type DoControlUI interface {
	Paint(hdc win.HDC, rcPaint win.RECT) bool
	DoPaint(hdc win.HDC, rcPaint win.RECT) bool
}

type Font

type Font struct {
	Shared string `xml:"shared,attr"`
	Id     string `xml:"id,attr"`
}

type Include

type Include struct {
	Source string `xml:"source,attr"`
}

type PaintManagerUI

type PaintManagerUI struct {
	HWndPaint     win.HWND
	Name          string
	HDCPaint      win.HDC
	HDcOffscreen  win.HDC
	HDcBackground win.HDC

	// Root    DoControlUI
	R1 []interface{}
	R2 []interface{}

	// RootXml *WindowXml
	WindowUI *WindowUI
	DialogBuilder
	BStartPaint bool // 是否开始绘制
}

func (*PaintManagerUI) Init

func (c *PaintManagerUI) Init(hWnd win.HWND, pstrName string)

func (*PaintManagerUI) MessageHandler

func (c *PaintManagerUI) MessageHandler(msg uint32, wParam, lParam uintptr) (bool, uintptr)

func (*PaintManagerUI) OnGetMinMaxInfo

func (c *PaintManagerUI) OnGetMinMaxInfo(msg uint32, wParam, lParam uintptr) (bool, uintptr)

func (*PaintManagerUI) OnNcHitTest

func (c *PaintManagerUI) OnNcHitTest(msg uint32, wParam, lParam uintptr) (bool, uintptr)

func (*PaintManagerUI) OnSize

func (c *PaintManagerUI) OnSize(msg uint32, wParam, lParam uintptr) (bool, uintptr)

func (*PaintManagerUI) SetInitSize

func (c *PaintManagerUI) SetInitSize(cx, cy int32)

func (*PaintManagerUI) TranslateMessage

func (c *PaintManagerUI) TranslateMessage(msg *win.MSG) bool

type Rect

type Rect struct {
	X, Y, W, H int
}

func (Rect) Bottom

func (c Rect) Bottom() int

func (*Rect) IsZero

func (c *Rect) IsZero() bool

func (Rect) Left

func (c Rect) Left() int

func (Rect) Right

func (c Rect) Right() int

func (Rect) Top

func (c Rect) Top() int

type Size

type Size struct {
	Cx, Cy int32
}

type Widget

type Widget interface {
	Window
}

方法

type WidgetBase

type WidgetBase struct {
	WindowBase
}

func NewWidgetBase

func NewWidgetBase() (*WidgetBase, error)

type Window

type Window interface {
	// 返回当前的句柄
	Handle() win.HWND
	// 返回一个可以操作的实例
	AsWindowBase() *WindowBase
	Run()
	WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr
}

统一window 操作方法.

func WindowFromHandle

func WindowFromHandle(hwnd win.HWND) Window

type WindowBase

type WindowBase struct {
	Hwnd         win.HWND
	Window       Window
	Visible      bool // 是否隐藏
	Enabled      bool // 是否禁用
	Name         string
	PaintManager PaintManagerUI
}

func (*WindowBase) AsWindowBase

func (c *WindowBase) AsWindowBase() *WindowBase

func (*WindowBase) Handle

func (c *WindowBase) Handle() win.HWND

func (*WindowBase) OnCreate

func (c *WindowBase) OnCreate(hwnd win.HWND, msg uint32, wParam, lParam uintptr)

func (*WindowBase) Run

func (c *WindowBase) Run()

func (*WindowBase) WndProc

func (c *WindowBase) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr

type WindowBase2

type WindowBase2 struct {
	Hwnd  win.HWND
	Index int
}

type WindowCfg

type WindowCfg struct {
	Window    Window
	Parent    Window
	ClassName string
	Style     uint32
	ExStyle   uint32
	Bounds    Rect
}

type WindowUI

type WindowUI struct {
	Xml      WindowXml
	InitSize Size

	MininfoUI   Size
	MaxinfoUI   Size
	Caption     win.RECT
	SizeBox     win.RECT
	Roundcorner Size
	XMLNodeItem []interface{} //xml控件集合
	NodeItem    []interface{} //绘制控件集合

	XMLControl map[string]interface{} // 所有的控件集合
}

func (*WindowUI) Parse

func (c *WindowUI) Parse(content []byte, paint *PaintManagerUI)

从xml-->属性

func (*WindowUI) SetInitSize

func (c *WindowUI) SetInitSize(cx, cy int32, hWnd win.HWND)

func (*WindowUI) UnParse

func (c *WindowUI) UnParse()

从属性值-->xml

type WindowXml

type WindowXml struct {
	XMLName     xml.Name `xml:"Window"`
	Size        string   `xml:"size,attr"`        // 最初窗口大小
	SizeBox     string   `xml:"sizebox,attr"`     // 标题栏和客户区之间的可以改变大小的上下箭头或左右箭头,区域越大,越容易方便改变窗口大小
	Caption     string   `xml:"caption,attr"`     // 标题栏的区域(鼠标可以托动的区域),鼠标放上去小箭头的模样.
	Roundcorner string   `xml:"roundcorner,attr"` // 设置窗口的圆角大小,值只有x,y起作用
	Mininfo     string   `xml:"mininfo,attr"`     // 窗口最小Size
	Maxinfo     string   `xml:"maxinfo,attr"`     // 窗口最大Size

	Include []Include `xml:"Include"`
	Font    []Font    `xml:"Font"`
	Default []Default `xml:"Default"`
}

type XMLContainer

type XMLContainer struct {
	DoControlUI

	ID     string          // 序号
	XML    *XMLContainerUI // xml属性
	UI     *ContainerUI    // 控件真实属性
	CoreUI *XMLControl
	Item   []interface{}
}

面板绘制

func NewXMLContainer

func NewXMLContainer() *XMLContainer

func (*XMLContainer) DoPaint

func (c *XMLContainer) DoPaint(hdc win.HDC, rcPaint win.RECT) bool

func (*XMLContainer) Paint

func (c *XMLContainer) Paint(hdc win.HDC, rcPaint win.RECT) bool

func (*XMLContainer) SetAttr

func (c *XMLContainer) SetAttr(attr etree.Attr)

type XMLContainerUI

type XMLContainerUI struct {
	CoreUI XMLControlUI

	Inset           string `xml:"inset,attr"`
	Mousechild      string `xml:"mousechild,attr"`
	Vscrollbarstyle string `xml:"vscrollbarstyle,attr"`
	Hscrollbar      string `xml:"hscrollbar,attr"`
	Hscrollbarstyle string `xml:"hscrollbarstyle,attr"`
	Childpadding    string `xml:"childpadding,attr"`
	Childvalign     string `xml:"childvalign,attr"`
	Childalign      string `xml:"childalign,attr"`
}

type XMLControl

type XMLControl struct {
	DoControlUI
	ID       string        // 序号
	XML      *XMLControlUI // xml属性
	UI       *ControlUI    // 控件真实属性
	HDCPaint *PaintManagerUI
	Item     []interface{}
}

func NewXMLControl

func NewXMLControl() *XMLControl

func (*XMLControl) DoPaint

func (c *XMLControl) DoPaint(hdc win.HDC, rcPaint win.RECT) bool

func (*XMLControl) Paint

func (c *XMLControl) Paint(hdc win.HDC, rcPaint win.RECT) bool

func (*XMLControl) SetAttr

func (c *XMLControl) SetAttr(attr etree.Attr)

func (*XMLControl) SetPaint

func (c *XMLControl) SetPaint(pa *PaintManagerUI)

type XMLControlUI

type XMLControlUI struct {
	Pos     string `xml:"pos,attr"`
	Padding string `xml:"padding,attr"`

	Name             string `xml:"name,attr"`
	Bkcolor          string `xml:"bkcolor,attr"`
	Bkcolor1         string `xml:"bkcolor1,attr"`
	Bkcolor2         string `xml:"bkcolor2,attr"`
	Bkcolor3         string `xml:"bkcolor3,attr"`
	BorderColor      string `xml:"bordercolor,attr"`
	FocusBorderColor string `xml:"focusbordercolor,attr"`
	Colorhsl         string `xml:"colorhsl,attr"`
	BorderSize       string `xml:"bordersize,attr"`
	BorderStyle      string `xml:"borderstyle,attr"`
	BorderRound      string `xml:"borderround,attr"`
	Bkimage          string `xml:"bkimage,attr"`

	Width     string `xml:"width,attr"`
	Height    string `xml:"height,attr"`
	MinWidth  string `xml:"minwidth,attr"`
	MinHeight string `xml:"minheight,attr"`
	MaxWidth  string `xml:"maxwidth,attr"`
	MaxHeight string `xml:"maxheight,attr"`
	Text      string `xml:"text,attr"`
	Tooltip   string `xml:"tooltip,attr"`

	UserData   string `xml:"userdata,attr"`
	Tag        string `xml:"tag,attr"`
	Enabled    string `xml:"enabled,attr"`
	Mouse      string `xml:"mouse,attr"`
	KeyHoard   string `xml:"keyboard,attr"`
	Visible    string `xml:"visible,attr"`
	Float      string `xml:"float,attr"`
	Menu       string `xml:"menu,attr"`
	Virtualwnd string `xml:"virtualwnd,attr"`
}

Jump to

Keyboard shortcuts

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