From 11557025950e17aa3738c0015c94d93ea0c52424 Mon Sep 17 00:00:00 2001 From: VIVIMAN Date: Wed, 7 Sep 2022 02:43:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=AB=E5=BD=A9=E4=BB=A3=E7=A0=81=E5=AD=A6?= =?UTF-8?q?=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data_func/go_to_xcgui/demo01/main.go | 20 ++++++ .../data_func/go_to_xcgui/demo02/main.go | 26 ++++++++ .../data_func/go_to_xcgui/demo03/main.go | 30 +++++++++ .../data_func/go_to_xcgui/demo04/1.ico | Bin 0 -> 19518 bytes .../data_func/go_to_xcgui/demo04/main.go | 61 ++++++++++++++++++ .../data_func/go_to_xcgui/demo05/1.ico | Bin 0 -> 19518 bytes .../data_func/go_to_xcgui/demo05/main.go | 45 +++++++++++++ .../data_func/go_to_xcgui/main01/main.go | 30 +++++++++ .../data_func/go_to_xcgui/main02/demo.zip | Bin 0 -> 1184 bytes .../data_func/go_to_xcgui/main02/main.go | 39 +++++++++++ golang_learn/go.mod | 1 + golang_learn/go.sum | 2 + 12 files changed, 254 insertions(+) create mode 100644 golang_learn/data_func/go_to_xcgui/demo01/main.go create mode 100644 golang_learn/data_func/go_to_xcgui/demo02/main.go create mode 100644 golang_learn/data_func/go_to_xcgui/demo03/main.go create mode 100644 golang_learn/data_func/go_to_xcgui/demo04/1.ico create mode 100644 golang_learn/data_func/go_to_xcgui/demo04/main.go create mode 100644 golang_learn/data_func/go_to_xcgui/demo05/1.ico create mode 100644 golang_learn/data_func/go_to_xcgui/demo05/main.go create mode 100644 golang_learn/data_func/go_to_xcgui/main01/main.go create mode 100644 golang_learn/data_func/go_to_xcgui/main02/demo.zip create mode 100644 golang_learn/data_func/go_to_xcgui/main02/main.go diff --git a/golang_learn/data_func/go_to_xcgui/demo01/main.go b/golang_learn/data_func/go_to_xcgui/demo01/main.go new file mode 100644 index 0000000..972c982 --- /dev/null +++ b/golang_learn/data_func/go_to_xcgui/demo01/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "github.com/twgh/xcgui/app" + "github.com/twgh/xcgui/window" + "github.com/twgh/xcgui/xcc" +) + +func main() { + // 炫彩_初始化, 参数填true是启用D2D硬件加速, 效果更好. 但xp系统不支持d2d, 这时候你就得填false来关闭d2d了 + a := app.New(true) + // 创建普通窗口, 宽300, 高200, 标题是"xcgui window", xcc.Window_Style_Default是使用默认窗口风格 + w := window.New(0, 0, 300, 200, "xcgui window", 0, xcc.Window_Style_Default) + // 显示窗口 + w.Show(true) + // 运行消息循环, 程序会被阻塞在这里不退出, 当炫彩窗口数量为0时退出 + a.Run() + // 退出界面库释放资源 + a.Exit() +} diff --git a/golang_learn/data_func/go_to_xcgui/demo02/main.go b/golang_learn/data_func/go_to_xcgui/demo02/main.go new file mode 100644 index 0000000..17f1419 --- /dev/null +++ b/golang_learn/data_func/go_to_xcgui/demo02/main.go @@ -0,0 +1,26 @@ +package main + +import ( + _ "embed" + "github.com/twgh/xcgui/app" + "github.com/twgh/xcgui/window" + "github.com/twgh/xcgui/xcc" + "os" +) + +//go:embed XCGUI.dll +var dll []byte + +func main() { + _ = os.WriteFile("xcgui.dll", dll, 0666) + // 炫彩_初始化, 参数填true是启用D2D硬件加速, 效果更好. 但xp系统不支持d2d, 这时候你就得填false来关闭d2d了 + a := app.New(true) + // 创建普通窗口, 宽300, 高200, 标题是"xcgui window", xcc.Window_Style_Default是使用默认窗口风格 + w := window.New(0, 0, 300, 200, "xcgui window", 0, xcc.Window_Style_Default) + // 显示窗口 + w.Show(true) + // 运行消息循环, 程序会被阻塞在这里不退出, 当炫彩窗口数量为0时退出 + a.Run() + // 退出界面库释放资源 + a.Exit() +} diff --git a/golang_learn/data_func/go_to_xcgui/demo03/main.go b/golang_learn/data_func/go_to_xcgui/demo03/main.go new file mode 100644 index 0000000..ddc3192 --- /dev/null +++ b/golang_learn/data_func/go_to_xcgui/demo03/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "github.com/twgh/xcgui/app" + "github.com/twgh/xcgui/window" + "github.com/twgh/xcgui/xcc" +) + +func main() { + // 炫彩_初始化, 参数填true是启用D2D硬件加速, 效果更好. 但xp系统不支持d2d, 这时候你就得填false来关闭d2d了 + a := app.New(true) + // 创建普通窗口, 宽430, 高300, 标题是"xcgui", xcc.Window_Style_Default是使用默认窗口风格, xcc.Window_Style_Drag_Window是允许拖动窗口 + w := window.New(0, 0, 430, 300, "xcgui", 0, xcc.Window_Style_Default|xcc.Window_Style_Drag_Window) + + // 设置窗口边框大小:标题栏高度34 + w.SetBorderSize(0, 34, 0, 0) + // 设置窗口透明类型:阴影窗口, 带透明通道, 边框阴影, 窗口透明或半透明 + w.SetTransparentType(xcc.Window_Transparent_Shadow) + // 设置窗口透明度:255就是不透明 + w.SetTransparentAlpha(255) + // 设置窗口阴影:阴影大小8, 深度255, 圆角内收大小10, 是否强制直角false, 阴影颜色0也就是黑色 + w.SetShadowInfo(8, 255, 10, false, 0) + + // 显示窗口 + w.Show(true) + // 运行消息循环, 程序会被阻塞在这里不退出, 当炫彩窗口数量为0时退出 + a.Run() + // 退出界面库释放资源 + a.Exit() +} diff --git a/golang_learn/data_func/go_to_xcgui/demo04/1.ico b/golang_learn/data_func/go_to_xcgui/demo04/1.ico new file mode 100644 index 0000000000000000000000000000000000000000..4e90a2172ffdc41dbb7d2817cc593e106b00abb3 GIT binary patch literal 19518 zcmeHPyKWmt6djV1C`(bS#EJ9NrVCUUX@l5B+7$YVAirSODqRPG?ay&xe}G|sfF!4I z(kO-+K?tDCW9Qs^=ds+GB}E|K6{J1)+A&0R@JOkQg?RUui?!$ot~;EPcGDKcB)>#zEb=9Z`IM!-|EGSOZD*Kxw?PbGD2Qh)q@ zu3o;pR2#Ds_0x}ks>AQk)DQRGs_W}(?R;we$3No=j4QCd70}N`w>3Aq-SxI^|M`uY zJ2N(dHMna_3}8L>P4kT#!Mg0*602sBE`?0w#o|nk@f}OGKe!d!-7yXk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~C#3f|pFDSx=fCD;alzE(=5w?4YLB~dP0J2c%be4`vCSmQ^~gG(`z-hG@oWhZ z&9^V~-{+&Quk}uT;k1}&G%bp5~3ci_JJqpW(%Iho)2*KF%9 zeYJ3h!he(bQ`qla+jV|JsozeqnzFa4PrYmzW8cj;*l6_hVZ>?W{Q=(W9Obdcx$}UL z28y@+8AV(`K8qsN_Xnp8wa@@-%qIPkdt#FwqRME!oTb2K(I91bw_sfgn5IH>jVno;)pn1k#GUw?m?`8I0z z+Tz>iwU;>LEH6^l5IDj4XWD!2gw$RO%hxfly!jfkeG58#3Yc;@?g6YNoP{7IH%urlXnUkuQTwKh^AOKFb$OMUgzW+-> zpIwwizx3boWy|+pTrU>Cc(YAQ(SO;@#%;%^g4_i%Tn^a=AUnXDkx7>ek*|=W2b8Z+ z0hzfB*%DApBL@&DrV-#WFjY_x@8}kR42Job6UCx!Obm$7Co!Z0yjj^mCNl$}3DCh| H%pe{BzU+3s literal 0 HcmV?d00001 diff --git a/golang_learn/data_func/go_to_xcgui/main02/main.go b/golang_learn/data_func/go_to_xcgui/main02/main.go new file mode 100644 index 0000000..f3b91bf --- /dev/null +++ b/golang_learn/data_func/go_to_xcgui/main02/main.go @@ -0,0 +1,39 @@ +package main + +import ( + _ "embed" + "github.com/twgh/xcgui/app" + "github.com/twgh/xcgui/widget" + "github.com/twgh/xcgui/window" + "github.com/twgh/xcgui/xc" +) + +// TODO 失败 +//go:embed XCGUI.dll +var dll []byte + +//go:embed demo.zip +var zip []byte + +func main() { + // 把 xcgui.dll 写出到windows临时目录 + _ = xc.WriteDll(dll) + a := app.New(true) + // 创建窗口从内存压缩包中的布局文件 + w := window.NewByLayoutZipMem(zip, "main.xml", "123456", 0, 0) + + // 获取窗口布局文件中的按钮 + btn := widget.NewButtonByName("viviman") + // 注册按钮被单击事件 + btn.Event_BnClick(func(pbHandled *bool) int { + a.Alert("提示", btn.GetText()+"被点击") + return 0 + }) + + // 调整布局, 必须 + w.AdjustLayout() + // 显示窗口 + w.Show(true) + a.Run() + a.Exit() +} diff --git a/golang_learn/go.mod b/golang_learn/go.mod index 6bb332a..4e4e9f0 100644 --- a/golang_learn/go.mod +++ b/golang_learn/go.mod @@ -44,6 +44,7 @@ require ( github.com/temoto/robotstxt v1.1.2 // indirect github.com/tidwall/gjson v1.13.0 github.com/tidwall/sjson v1.2.4 + github.com/twgh/xcgui v1.3.360 github.com/xuri/excelize/v2 v2.5.0 github.com/yeka/zip v0.0.0-20180914125537-d046722c6feb golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 diff --git a/golang_learn/go.sum b/golang_learn/go.sum index 7c80e07..5a8a1f3 100644 --- a/golang_learn/go.sum +++ b/golang_learn/go.sum @@ -459,6 +459,8 @@ github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.4 h1:cuiLzLnaMeBhRmEv00Lpk3tkYrcxpmbU81tAY4Dw0tc= github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM= +github.com/twgh/xcgui v1.3.360 h1:4+rFpbE3SXc8S2h3jkQDDDj3zrxXPSi5CC6jKljYfX8= +github.com/twgh/xcgui v1.3.360/go.mod h1:16uhvR074Kq1coBif0l6b40CsnwDB9bGiXnGQumi5vI= github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=