Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
twgh committed Jul 29, 2024
1 parent b1a6c1e commit 3d3b333
Show file tree
Hide file tree
Showing 66 changed files with 457 additions and 272 deletions.
3 changes: 2 additions & 1 deletion README-en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">XCGUI</h1>
<p align="center">
<a href="https://github.com/twgh/xcgui/releases"><img src="https://img.shields.io/badge/release-1.3.391-blue" alt="release"></a>
<a href="https://github.com/twgh/xcgui/releases"><img src="https://img.shields.io/badge/release-1.3.392-blue" alt="release"></a>
<a href="http://www.xcgui.com"><img src="https://img.shields.io/badge/XCGUI-3.3.9-blue" alt="XCGUI"></a>
<a href="https://golang.org"> <img src="https://img.shields.io/badge/golang-≥1.16-blue" alt="golang"></a>
<a href="https://pkg.go.dev/github.com/twgh/xcgui"><img src="https://img.shields.io/badge/go.dev-reference-brightgreen" alt="GoDoc"></a>
Expand All @@ -21,6 +21,7 @@




## Introduction

English | [简体中文](./README.md)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">XCGUI</h1>
<p align="center">
<a href="https://github.com/twgh/xcgui/releases"><img src="https://img.shields.io/badge/release-1.3.391-blue" alt="release"></a>
<a href="https://github.com/twgh/xcgui/releases"><img src="https://img.shields.io/badge/release-1.3.392-blue" alt="release"></a>
<a href="http://www.xcgui.com"><img src="https://img.shields.io/badge/XCGUI-3.3.9-blue" alt="XCGUI"></a>
<a href="https://golang.org"> <img src="https://img.shields.io/badge/golang-≥1.16-blue" alt="golang"></a>
<a href="https://pkg.go.dev/github.com/twgh/xcgui"><img src="https://img.shields.io/badge/go.dev-reference-brightgreen" alt="GoDoc"></a>
Expand All @@ -22,6 +22,7 @@




## 介绍

[English](./README-en.md) | 简体中文
Expand Down
6 changes: 3 additions & 3 deletions ani/anima.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (a *Anima) AlphaEx(duration uint32, from_alpha uint8, to_alpha uint8, nLoop
//
// duration: 持续时间.
//
// color: ARGB 颜色.
// color: xc.RGBA 颜色.
//
// nLoopCount: 动画循环次数, 0: 无限循环.
//
Expand All @@ -194,9 +194,9 @@ func (a *Anima) Color(duration uint32, color int, nLoopCount int32, ease_flag xc
//
// duration: 持续时间.
//
// from: 起点颜色, ARGB 颜色.
// from: 起点颜色, xc.RGBA 颜色.
//
// to: 终点颜色, ARGB 颜色.
// to: 终点颜色, xc.RGBA 颜色.
//
// nLoopCount: 动画循环次数, 0: 无限循环.
//
Expand Down
2 changes: 1 addition & 1 deletion ani/anima_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (a *animaBase) EnableAutoDestroy(bEnable bool) *animaBase {
return a
}

// 动画_置回调.
// 动画_置回调. TODO: 有问题用不了, 因为 syscall.NewCallback 创建不了没有返回值的回调函数指针.
//
// callback: 回调函数.
func (a *animaBase) SetCallBack(callback xc.FunAnimation) *animaBase {
Expand Down
2 changes: 1 addition & 1 deletion ani/anima_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (a *AnimaItem) EnableCompleteRelease(bEnable bool) *AnimaItem {
return a
}

// 动画项_置回调.
// 动画项_置回调. TODO: 有问题用不了, 因为 syscall.NewCallback 创建不了没有返回值的回调函数指针.
//
// callback: 回调函数.
func (a *AnimaItem) SetCallback(callback xc.FunAnimationItem) *AnimaItem {
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (a *App) EnableResMonitor(bEnable bool) *App {

// 炫彩_置布局边界颜色.
//
// color: ARGB 颜色值.
// color: xc.RGBA 颜色值.
func (a *App) SetLayoutFrameColor(color int) *App {
xc.XC_SetLayoutFrameColor(color)
return a
Expand Down
6 changes: 3 additions & 3 deletions bkmanager/bkmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (b *BkManager) AddInfo(pText string) int32 {
//
// nState: 组合状态.
//
// color: ARGB 颜色.
// color: xc.RGBA 颜色.
//
// width: 线宽.
//
Expand All @@ -68,7 +68,7 @@ func (b *BkManager) AddBorder(nState xcc.CombinedState, color int, width, id int
//
// nState: 组合状态.
//
// color: ARGB 颜色.
// color: xc.RGBA 颜色.
//
// id: 背景对象ID, 可忽略(填0).
func (b *BkManager) AddFill(nState xcc.CombinedState, color int, id int32) *BkManager {
Expand Down Expand Up @@ -161,7 +161,7 @@ func (b *BkManager) SetInfo(pText string) int32 {
//
// nState: 组合状态.
//
// color: 接收返回的ARGB 颜色.
// color: 接收返回的 xc.RGBA 颜色.
func (b *BkManager) GetStateTextColor(nState xcc.CombinedState, color *int) bool {
return xc.XBkM_GetStateTextColor(b.Handle, nState, color)
}
Expand Down
8 changes: 4 additions & 4 deletions bkobj/bkobj.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (b *BkObj) SetRotate(angle float32) *BkObj {

// 背景对象_置填充颜色.
//
// color: ARGB 颜色值.
// color: xc.RGBA 颜色值.
func (b *BkObj) SetFillColor(color int) *BkObj {
xc.XBkObj_SetFillColor(b.Handle, color)
return b
Expand All @@ -105,7 +105,7 @@ func (b *BkObj) SetBorderWidth(width int32) *BkObj {

// 背景对象_置边框颜色.
//
// color: xc.ARGB 颜色值.
// color: xc.RGBA 颜色值.
func (b *BkObj) SetBorderColor(color int) *BkObj {
xc.XBkObj_SetBorderColor(b.Handle, color)
return b
Expand Down Expand Up @@ -189,12 +189,12 @@ func (b *BkObj) GetRotate() *BkObj {
return b
}

// 背景对象_取填充色, 返回ARGB填充色.
// 背景对象_取填充色, 返回 xc.RGBA 填充色.
func (b *BkObj) GetFillColor() int {
return xc.XBkObj_GetFillColor(b.Handle)
}

// 背景对象_取边框色, 返回ARGB边框色.
// 背景对象_取边框色, 返回 xc.RGBA 边框色.
func (b *BkObj) GetBorderColor() int {
return xc.XBkObj_GetBorderColor(b.Handle)
}
Expand Down
38 changes: 19 additions & 19 deletions drawx/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (d *Draw) GetHDC() uintptr {

// 绘制_置画刷颜色, 设置画刷颜色.
//
// color: ARGB 颜色值.
// color: xc.RGBA 颜色值.
func (d *Draw) SetBrushColor(color int) *Draw {
xc.XDraw_SetBrushColor(d.Handle, color)
return d
Expand Down Expand Up @@ -334,7 +334,7 @@ func (d *Draw) GDI_CreateSolidBrush(crColor int) uintptr {
//
// nWidth: 画笔宽度.
//
// crColor: ARGB 颜色.
// crColor: xc.RGBA 颜色.
func (d *Draw) GDI_CreatePen(fnPenStyle, nWidth int32, crColor int) uintptr {
return xc.XDraw_GDI_CreatePen(d.Handle, fnPenStyle, nWidth, crColor)
}
Expand Down Expand Up @@ -429,7 +429,7 @@ func (d *Draw) FillRectF(pRect *xc.RECTF) *Draw {
//
// pRect: 矩形区域.
//
// color: ARGB 颜色.
// color: xc.RGBA 颜色.
func (d *Draw) FillRectColor(pRect *xc.RECT, color int) *Draw {
xc.XDraw_FillRectColor(d.Handle, pRect, color)
return d
Expand All @@ -439,7 +439,7 @@ func (d *Draw) FillRectColor(pRect *xc.RECT, color int) *Draw {
//
// pRect: 矩形区域.
//
// color: ARGB 颜色.
// color: xc.RGBA 颜色.
func (d *Draw) FillRectColorF(pRect *xc.RECTF, color int) *Draw {
xc.XDraw_FillRectColorF(d.Handle, pRect, color)
return d
Expand Down Expand Up @@ -607,9 +607,9 @@ func (d *Draw) GDI_Rectangle(nLeftRect, nTopRect, nRightRect, nBottomRect int32)
//
// pRect: 矩形坐标.
//
// color1: 开始颜色, ARGB 颜色.
// color1: 开始颜色, xc.RGBA 颜色.
//
// color2: 结束颜色, ARGB 颜色.
// color2: 结束颜色, xc.RGBA 颜色.
//
// mode: 模式, GRADIENT_FILL_.
func (d *Draw) GradientFill2(pRect *xc.RECT, color1 int, color2 int, mode xcc.GRADIENT_FILL_) *Draw {
Expand All @@ -621,9 +621,9 @@ func (d *Draw) GradientFill2(pRect *xc.RECT, color1 int, color2 int, mode xcc.GR
//
// pRect: 矩形坐标.
//
// color1: 开始颜色, ARGB 颜色.
// color1: 开始颜色, xc.RGBA 颜色.
//
// color2: 结束颜色, ARGB 颜色.
// color2: 结束颜色, xc.RGBA 颜色.
//
// mode: 模式, GRADIENT_FILL_.
func (d *Draw) GradientFill2F(pRect *xc.RECTF, color1 int, color2 int, mode xcc.GRADIENT_FILL_) *Draw {
Expand All @@ -635,13 +635,13 @@ func (d *Draw) GradientFill2F(pRect *xc.RECTF, color1 int, color2 int, mode xcc.
//
// pRect: 矩形坐标.
//
// color1: 开始颜色, ARGB 颜色.
// color1: 开始颜色, xc.RGBA 颜色.
//
// color2: 结束颜色, ARGB 颜色.
// color2: 结束颜色, xc.RGBA 颜色.
//
// color3: 开始颜色, ARGB 颜色.
// color3: 开始颜色, xc.RGBA 颜色.
//
// color4: 结束颜色, ARGB 颜色.
// color4: 结束颜色, xc.RGBA 颜色.
//
// mode: 模式, GRADIENT_FILL_.
func (d *Draw) GradientFill4(pRect *xc.RECT, color1 int, color2 int, color3 int, color4 int, mode xcc.GRADIENT_FILL_) *Draw {
Expand All @@ -653,13 +653,13 @@ func (d *Draw) GradientFill4(pRect *xc.RECT, color1 int, color2 int, color3 int,
//
// pRect: 矩形坐标.
//
// color1: 开始颜色, ARGB 颜色.
// color1: 开始颜色, xc.RGBA 颜色.
//
// color2: 结束颜色, ARGB 颜色.
// color2: 结束颜色, xc.RGBA 颜色.
//
// color3: 开始颜色, ARGB 颜色.
// color3: 开始颜色, xc.RGBA 颜色.
//
// color4: 结束颜色, ARGB 颜色.
// color4: 结束颜色, xc.RGBA 颜色.
//
// mode: 模式, GRADIENT_FILL_.
func (d *Draw) GradientFill4F(pRect *xc.RECTF, color1 int, color2 int, color3 int, color4 int, mode xcc.GRADIENT_FILL_) *Draw {
Expand Down Expand Up @@ -1058,7 +1058,7 @@ func (d *Draw) DrawTextF(lpString string, lpRect *xc.RECTF) *Draw {
//
// lpRect: 坐标.
//
// colorLine: 下划线颜色, ARGB 颜色.
// colorLine: 下划线颜色, xc.RGBA 颜色.
func (d *Draw) DrawTextUnderline(lpString string, lpRect *xc.RECT, colorLine int) *Draw {
xc.XDraw_DrawTextUnderline(d.Handle, lpString, lpRect, colorLine)
return d
Expand All @@ -1070,7 +1070,7 @@ func (d *Draw) DrawTextUnderline(lpString string, lpRect *xc.RECT, colorLine int
//
// lpRect: 坐标.
//
// colorLine: 下划线颜色, ARGB 颜色.
// colorLine: 下划线颜色, xc.RGBA 颜色.
func (d *Draw) DrawTextUnderlineF(lpString string, lpRect *xc.RECTF, colorLine int) *Draw {
xc.XDraw_DrawTextUnderlineF(d.Handle, lpString, lpRect, colorLine)
return d
Expand Down Expand Up @@ -1210,7 +1210,7 @@ func (d *Draw) DrawSvgSize(hSvg int, nWidth, nHeight int32) *Draw {

// 绘制_D2D_清理, 使用指定颜色清理画布.
//
// color: ARGB 颜色值.
// color: xc.RGBA 颜色值.
func (d *Draw) D2D_Clear(color int) *Draw {
xc.XDraw_D2D_Clear(d.Handle, color)
return d
Expand Down
4 changes: 2 additions & 2 deletions imagex/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,15 @@ func (i *Image) SetDrawTypeAdaptive(leftSize, topSize, rightSize, bottomSize int

// 图片_置透明色, 指定图片透明颜色.
//
// color: ARGB 颜色.
// color: xc.RGBA 颜色.
func (i *Image) SetTranColor(color int) *Image {
xc.XImage_SetTranColor(i.Handle, color)
return i
}

// 图片_置透明色扩展, 指定图片透明颜色及透明度.
//
// color: ARGB 颜色.
// color: xc.RGBA 颜色.
//
// tranColor: 透明色的透明度.
func (i *Image) SetTranColorEx(color int, tranColor byte) *Image {
Expand Down
4 changes: 2 additions & 2 deletions wapi/user32.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ const (
//
// Type: 要加载的图像的类型。 wapi.IMAGE_ .
//
// cx: 图标或光标的宽度(以像素为单位)。 如果此参数为零且 fuLoad 参数 为LR_DEFAULTSIZE,则函数使用 SM_CXICON 或 SM_CXCURSOR 系统指标值来设置宽度。 如果此参数为零且未使用 LR_DEFAULTSIZE ,则函数使用实际资源宽度.
// cx: 图标或光标的宽度(以像素为单位)。 如果此参数为零且 fuLoad 参数 为 LR_DEFAULTSIZE,则函数使用 SM_CXICON 或 SM_CXCURSOR 系统指标值来设置宽度。 如果此参数为零且未使用 LR_DEFAULTSIZE ,则函数使用实际资源宽度.
//
// cy: 图标或光标的高度(以像素为单位)。 如果此参数为零且 fuLoad 参数 为LR_DEFAULTSIZE,则函数使用 SM_CYICON 或 SM_CYCURSOR 系统指标值来设置高度。 如果此参数为零且未使用 LR_DEFAULTSIZE ,则函数使用实际资源高度.
// cy: 图标或光标的高度(以像素为单位)。 如果此参数为零且 fuLoad 参数 为 LR_DEFAULTSIZE,则函数使用 SM_CYICON 或 SM_CYCURSOR 系统指标值来设置高度。 如果此参数为零且未使用 LR_DEFAULTSIZE ,则函数使用实际资源高度.
//
// fuLoad: 此参数可使用以下一个或多个值: wapi.LR_ .
//
Expand Down
10 changes: 10 additions & 0 deletions wapi/wutil/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,13 @@ func ChooseColor(hParent int) int {
}
return int(cc.RgbResult)
}

// HIcon 从文件加载图标. 返回 HICON 句柄.
// - 可用于需要 HICON 句柄的函数, 如设置托盘图标.
// - 如果失败, 可使用 syscall.GetLastError() 获取错误信息.
// - 当图标句柄不再使用时, 可使用 wapi.DestroyIcon 函数释放.
//
// iconPath: 图标路径.
func HIcon(iconPath string) uintptr {
return wapi.LoadImageW(0, iconPath, wapi.IMAGE_ICON, 0, 0, wapi.LR_LOADFROMFILE|wapi.LR_DEFAULTSIZE)
}
2 changes: 1 addition & 1 deletion wapi/wutil/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ func TestSaveFile(t *testing.T) {
func TestChooseColor(t *testing.T) {
rgb := wutil.ChooseColor(0)
fmt.Println("rgb颜色", rgb)
fmt.Println("ARGB颜色", xc.RGB2ARGB(rgb, 255))
fmt.Println("炫彩使用的颜色", xc.RGB2RGBA(rgb, 255))
}
15 changes: 9 additions & 6 deletions wapi/wutil/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ func ExampleNewHookKeyboard() {
tf.TFunc(func(a *app.App, w *window.Window) {
widget.NewShapeText(40, 40, 300, 30, "在任何窗口按键都能够监听到", w.Handle)
widget.NewEdit(40, 80, 300, 30, w.Handle).SetFocus()
checkBtn := widget.NewButton(40, 120, 300, 30, "拦截A键按下", w.Handle).SetTypeEx(xcc.Button_Type_Check)
checkBtn.EnableBkTransparent(true)

kbHook := wutil.NewHookKeyboard(func(nCode int32, wParam xcc.WM_, lParam *wapi.KBDLLHOOKSTRUCT) uintptr {
if nCode < 0 { // nCode小于0时不应继续处理
return wutil.CallNextHookEx_Keyboard(nCode, wParam, lParam)
}

if wParam == xcc.WM_KEYDOWN { // 键盘按下
fmt.Printf("按键按下: 虚拟键码=%d, 扫描码=%d\n", lParam.VkCode, lParam.ScanCode)

if lParam.VkCode == xcc.VK_A {
fmt.Println("拦截了A键, 是不会输入文本框的")
return 1 // 返回1可拦截, 这时按下A键是不会输入文本框的
if checkBtn.GetStateEx() == xcc.Button_State_Check {
if lParam.VkCode == xcc.VK_A {
fmt.Println("拦截了A键按下, 是不会输入文本框的, 部分程序不会被拦截, 自行研究")
return 1 // 返回1可拦截, 这时按下A键是不会输入文本框的, 部分程序不会被拦截, 因为它可能进行了特殊处理
}
}
fmt.Printf("按键按下: 虚拟键码=%d, 扫描码=%d\n", lParam.VkCode, lParam.ScanCode)
} else if wParam == xcc.WM_KEYUP { // 键盘弹起
fmt.Printf("按键弹起: 虚拟键码=%d, 扫描码=%d\n", lParam.VkCode, lParam.ScanCode)
}
Expand All @@ -50,7 +53,7 @@ func ExampleNewHookMouse() {

// 注册事件_窗口鼠标右键按下, 用来检测是否真的拦截了鼠标右键按下消息
w.Event_RBUTTONDOWN(func(nFlags uint, pPt *xc.POINT, pbHandled *bool) int {
fmt.Println("响应了炫彩窗口鼠标右键被按下消息, 证明没有被拦截:", nFlags, pPt)
xc.XC_Alert("提示", fmt.Sprintf("响应了炫彩窗口鼠标右键被按下消息, 证明没有被拦截, nFlags: %d, pPt: %v", nFlags, pPt))
return 0
})

Expand Down
17 changes: 10 additions & 7 deletions wapi/wutil/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@ import (

func TestNewHookKeyboard(t *testing.T) {
tf.TFunc(func(a *app.App, w *window.Window) {
widget.NewShapeText(40, 40, 300, 30, "在任何窗口操作键盘都能够监听到", w.Handle)
widget.NewShapeText(40, 40, 300, 30, "在任何窗口按键都能够监听到", w.Handle)
widget.NewEdit(40, 80, 300, 30, w.Handle).SetFocus()
checkBtn := widget.NewButton(40, 120, 300, 30, "拦截A键按下", w.Handle).SetTypeEx(xcc.Button_Type_Check)
checkBtn.EnableBkTransparent(true)

kbHook := wutil.NewHookKeyboard(func(nCode int32, wParam xcc.WM_, lParam *wapi.KBDLLHOOKSTRUCT) uintptr {
if nCode < 0 { // nCode小于0时不应继续处理
return wutil.CallNextHookEx_Keyboard(nCode, wParam, lParam)
}

if wParam == xcc.WM_KEYDOWN { // 键盘按下
fmt.Printf("按键按下: 虚拟键码=%d, 扫描码=%d\n", lParam.VkCode, lParam.ScanCode)

if lParam.VkCode == xcc.VK_A {
fmt.Println("拦截了A键, 是不会输入文本框的")
return 1 // 返回1可拦截, 这时按下A键是不会输入文本框的
if checkBtn.GetStateEx() == xcc.Button_State_Check {
if lParam.VkCode == xcc.VK_A {
fmt.Println("拦截了A键按下, 是不会输入文本框的, 部分程序不会被拦截, 自行研究")
return 1 // 返回1可拦截, 这时按下A键是不会输入文本框的, 部分程序不会被拦截, 因为它可能进行了特殊处理
}
}
fmt.Printf("按键按下: 虚拟键码=%d, 扫描码=%d\n", lParam.VkCode, lParam.ScanCode)
} else if wParam == xcc.WM_KEYUP { // 键盘弹起
fmt.Printf("按键弹起: 虚拟键码=%d, 扫描码=%d\n", lParam.VkCode, lParam.ScanCode)
}
Expand All @@ -51,7 +54,7 @@ func TestNewHookMouse(t *testing.T) {

// 注册事件_窗口鼠标右键按下, 用来检测是否真的拦截了鼠标右键按下消息
w.Event_RBUTTONDOWN(func(nFlags uint, pPt *xc.POINT, pbHandled *bool) int {
fmt.Println("响应了炫彩窗口鼠标右键被按下消息, 证明没有被拦截:", nFlags, pPt)
xc.XC_Alert("提示", fmt.Sprintf("响应了炫彩窗口鼠标右键被按下消息, 证明没有被拦截, nFlags: %d, pPt: %v", nFlags, pPt))
return 0
})

Expand Down
2 changes: 1 addition & 1 deletion widget/datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (d *DateTime) GetSelBkColor() int {

// 日期_置选择日期背景颜色, 设置被选择文字的背景颜色.
//
// crSelectBk: 文字被选中背景色, ARGB 颜色.
// crSelectBk: 文字被选中背景色, xc.RGBA 颜色.
func (d *DateTime) SetSelBkColor(crSelectBk int) *DateTime {
xc.XDateTime_SetSelBkColor(d.Handle, crSelectBk)
return d
Expand Down
Loading

0 comments on commit 3d3b333

Please sign in to comment.